frmCertificadosDeInversion.vb 134 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993
  1. Public Class frmCertificadosDeInversion
  2. Dim oCEPrincipal As New CertificadoDeInversionCE
  3. Dim oDAOPrincipal As New CertificadosDeInversionDAO
  4. Dim oDAOGeneral As New DAOGeneral
  5. Dim Bonos As New BonosCE
  6. Dim TotalValorCupones As Double
  7. Dim Index
  8. Dim BonoCalculo As New FormulasBonoCE
  9. Dim Cargar As Boolean = True
  10. Dim BonosConsulta As New BonosDAO
  11. Dim Operaciones As New Operaciones
  12. Dim ModificarRenta As Boolean = True
  13. Dim Tipo As Integer = 0
  14. Dim IndexBaseC As Integer = 0
  15. Dim IndexBaseV As Integer = 0
  16. Dim PeriodoC As Integer = 0
  17. Dim PeriodoV As Integer = 0
  18. Private _IdDocumento As Integer
  19. Private _TipoDocumento As String
  20. Private _CodigoInversion As String
  21. Private _TipoTransaccion As String 'N=Nuevo, A=Actualizar, C=Consulta
  22. Private TipoPeriodicidad As Integer = 0
  23. Public InstanciaAmortizacion As New DataGridView
  24. Public InstanciaIngresos As New DataGridView
  25. Private TipoOperacion As String
  26. Public Sub New()
  27. InitializeComponent()
  28. End Sub
  29. Public Sub New(TipoOper As String)
  30. Me.New
  31. TipoOperacion = TipoOper
  32. End Sub
  33. Sub CargarBase()
  34. If cboAnioBaseC.Items.Count = 0 Or cboAnioBaseC.Items.Count = 1 Then
  35. Me.cboAnioBaseC.DataSource = oDAOGeneral.ListaBase
  36. Me.cboAnioBaseC.DisplayMember = "Descripcion"
  37. Me.cboAnioBaseC.ValueMember = "Codigo"
  38. Me.cboAnioBaseC.SelectedIndex = 0
  39. End If
  40. If cboAnioBaseV.Items.Count = 0 Or cboAnioBaseV.Items.Count = 1 Then
  41. Me.cboAnioBaseV.DataSource = oDAOGeneral.ListaBase
  42. Me.cboAnioBaseV.DisplayMember = "Descripcion"
  43. Me.cboAnioBaseV.ValueMember = "Codigo"
  44. Me.cboAnioBaseV.SelectedIndex = 0
  45. End If
  46. End Sub
  47. Public Property TipoTransaccion As String
  48. Get
  49. Return _TipoTransaccion
  50. End Get
  51. Set(value As String)
  52. _TipoTransaccion = value
  53. End Set
  54. End Property
  55. Private Property IdDocumento As Integer
  56. Get
  57. Return _IdDocumento
  58. End Get
  59. Set(value As Integer)
  60. _IdDocumento = value
  61. End Set
  62. End Property
  63. Private Property TipoDocumento As String
  64. Get
  65. Return _TipoDocumento
  66. End Get
  67. Set(value As String)
  68. _TipoDocumento = value
  69. End Set
  70. End Property
  71. Private Property CodigoInversion As String
  72. Get
  73. Return _CodigoInversion
  74. End Get
  75. Set(value As String)
  76. _CodigoInversion = value
  77. End Set
  78. End Property
  79. Function FechaCupon(ByVal liquidacion As Date, ByVal Vencimiento As Date, ByVal frecuencia As Integer)
  80. Dim periodos As Integer = 0
  81. If frecuencia = 1 Then
  82. periodos = -12
  83. ElseIf frecuencia = 2 Then
  84. periodos = -6
  85. ElseIf frecuencia = 4 Then
  86. periodos = -3
  87. ElseIf frecuencia = 12 Then
  88. periodos = -1
  89. End If
  90. If (Not periodos = 0) Then
  91. While Vencimiento > liquidacion
  92. Vencimiento = Vencimiento.AddMonths(periodos)
  93. End While
  94. Else
  95. Return liquidacion
  96. End If
  97. Return Vencimiento
  98. End Function
  99. Sub ValidarExistencia()
  100. Dim General As New DAOGeneral
  101. Dim Codigo As String = Variables.Codigo
  102. Dim Tabla As String = String.Empty
  103. Dim Ins As String = Instrumento()
  104. If (Ins = "TIT") Then
  105. Tabla = "TIT"
  106. ElseIf (Ins = "EURB") Then
  107. Tabla = "EURB0"
  108. ElseIf (Ins = "BONO") Then
  109. Tabla = "BON0"
  110. ElseIf (Ins = "CINV") Then
  111. Tabla = "CIN0"
  112. End If
  113. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  114. If Tabla = "TIT" Then
  115. If (Existe) Then
  116. navNuevo.Enabled = False
  117. navModificar.Enabled = True
  118. navEliminar.Enabled = True
  119. btnIngresos.Enabled = True
  120. Else
  121. navNuevo.Enabled = True
  122. navModificar.Enabled = False
  123. navEliminar.Enabled = False
  124. btnIngresos.Enabled = False
  125. End If
  126. Else
  127. If (Existe) Then
  128. navNuevo.Enabled = False
  129. navModificar.Enabled = True
  130. navEliminar.Enabled = True
  131. btnIngresos.Enabled = True
  132. Else
  133. navNuevo.Enabled = True
  134. navModificar.Enabled = False
  135. navEliminar.Enabled = False
  136. btnIngresos.Enabled = False
  137. End If
  138. End If
  139. TipoTransaccion = String.Empty
  140. btnAceptar.Text = "Aceptar"
  141. End Sub
  142. Function ExisteValidacion()
  143. Dim General As New DAOGeneral
  144. Dim Codigo As String = Variables.Codigo
  145. Dim Tabla As String = String.Empty
  146. Dim Ins As String = Instrumento()
  147. If (Ins = "TIT") Then
  148. Tabla = "TIT"
  149. ElseIf (Ins = "EURB") Then
  150. Tabla = "EURB0"
  151. ElseIf (Ins = "BONO") Then
  152. Tabla = "BON0"
  153. ElseIf (Ins = "CINV") Then
  154. Tabla = "CIN0"
  155. End If
  156. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  157. Return Existe
  158. End Function
  159. Private Sub frmBonos_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  160. Dim VExisteInversion As Boolean = False
  161. If Variables.TipoOperacionCMVTA = "C" Then
  162. GrpVenta.Enabled = False
  163. GrpCompra.Enabled = True
  164. Else
  165. GrpVenta.Enabled = True
  166. GrpCompra.Enabled = False
  167. End If
  168. VExisteInversion = ExisteInversion()
  169. ValidarExistencia()
  170. Dim Ins As String = Instrumento()
  171. CargarBase()
  172. AsignacionPeriodicidad()
  173. If (Not Ins = "TIT") Then
  174. btnIngresos.Visible = False
  175. End If
  176. If (Ins = "TIT") Then
  177. btnIngresos.Visible = True
  178. lblBono.Text = "Titularizacion"
  179. ConfTitularizacion()
  180. ElseIf (Ins = "EURB") Then
  181. lblBono.Text = "Euro Bonos"
  182. ElseIf (Ins = "BONO") Then
  183. lblBono.Text = "Bonos"
  184. End If
  185. Bono()
  186. Tipo = 1
  187. Call CargarPeriodos()
  188. PrepararTablaIngresos()
  189. If Me.TipoTransaccion Is Nothing Then
  190. Me.TipoTransaccion = "N"
  191. End If
  192. CargarIngresos()
  193. RefrescarValorControles()
  194. Cargar = False
  195. BotonQuitar()
  196. CamposTiempo()
  197. CargarTransladoNuevo()
  198. ConfiguracionCMVTA(VExisteInversion)
  199. End Sub
  200. Sub ConfiguracionCMVTA(ByRef VExisteInversion As Boolean)
  201. Dim Codigo As String = Variables.Codigo
  202. Dim ExisteCMVTA As Boolean = oDAOGeneral.ExisteCMVTA(Codigo)
  203. If Not ExisteCMVTA And Variables.InvocadorProInv = "frmINV" Then
  204. btnVenderTitulo.Visible = True
  205. End If
  206. If CantFormAbierto = False And Not VExisteInversion Then
  207. If Not Variables.TrasladarCMVTA Is Nothing Then
  208. cboAnioBaseC.SelectedIndex = Variables.TrasladarCMVTA.BaseCINV
  209. txtPorcentajeCuponCompra.Text = Variables.TrasladarCMVTA.CuponCINV
  210. dtpFechaLiquidacionCompra.Value = Variables.TrasladarCMVTA.FechaLiquidacionCINV
  211. dtpFechaVencimientoCompra.Value = Variables.TrasladarCMVTA.FechaVencimientoCINV
  212. cboPeriodosC.SelectedValue = Variables.TrasladarCMVTA.PeriodicidadCINV
  213. txtComisionPorBolsaCompra.Text = Variables.TrasladarCMVTA.PorcentajeComisionBolsaCINV
  214. txtComisionPorCompraCasa.Text = Variables.TrasladarCMVTA.PorcentajeComisionCasaCINV
  215. txtPrecioCompra.Text = Variables.TrasladarCMVTA.PrecioCompraCINV
  216. txtPrecioAlVencimientoCompra.Text = Variables.TrasladarCMVTA.PrecioVencimientoCINV
  217. dtpUltimaFechaCuponCompra.Value = Variables.TrasladarCMVTA.UltimaFechaCuponCINV
  218. txtValorNominalCompra.Text = Variables.TrasladarCMVTA.ValorNominalCINV
  219. txtYTMAlVencimientoCompra.Text = Variables.TrasladarCMVTA.YTMVencimientoCINV
  220. End If
  221. End If
  222. End Sub
  223. Sub CamposTiempo()
  224. If Not TypeOf cboPeriodosC.SelectedValue Is DataRowView Then
  225. Variables.PeriodicidadTIT = cboPeriodosC.SelectedValue
  226. End If
  227. Variables.BaseTIT = cboAnioBaseC.SelectedIndex
  228. End Sub
  229. Sub ConfTitularizacion()
  230. dgvIngresos.Dispose()
  231. TbIngresos.Parent = Nothing
  232. Dim TbAmortizacion As New TabPage
  233. Dim frmTitularizacion As New frmResultadoTitularizacion()
  234. TbAmortizacion.Name = "tbAmortizacion"
  235. TbAmortizacion.Text = "Amortizacion"
  236. If TabCampos.TabCount = 2 Then
  237. frmTitularizacion.Dock = DockStyle.Fill
  238. frmTitularizacion.TopLevel = False
  239. frmTitularizacion.Parent = TbAmortizacion
  240. TabCampos.Controls.Add(TbAmortizacion)
  241. frmTitularizacion.Show()
  242. End If
  243. End Sub
  244. Function ExisteInversion()
  245. Dim Codigo As String = Variables.Codigo
  246. Dim TablaINV As String = "INV0"
  247. Dim TablaPINV As String = "PIN0"
  248. Dim General As New DAOGeneral
  249. Dim InvPro = Variables.InvPro
  250. If InvPro = "I" Then
  251. Dim INV0 As Boolean = General.ExisteTitulo(Codigo, TablaINV)
  252. If INV0 Then
  253. navNuevo.Visible = True
  254. Return True
  255. Else
  256. navNuevo.Visible = False
  257. Return False
  258. End If
  259. End If
  260. If InvPro = "P" Then
  261. Dim PINV0 As Boolean = General.ExisteTitulo(Codigo, TablaPINV)
  262. If PINV0 Then
  263. navNuevo.Visible = True
  264. Return True
  265. Else
  266. navNuevo.Visible = False
  267. Return False
  268. End If
  269. End If
  270. Return False
  271. End Function
  272. Sub Bono()
  273. dtpSiguienteFechaCuponCompra.Enabled = False
  274. dtpSiguienteFechaCuponVenta.Enabled = False
  275. dtpUltimaFechaCuponCompra.Enabled = True
  276. dtpUltimaFechaCuponVenta.Enabled = True
  277. End Sub
  278. Private Function Parametros()
  279. Dim Coleccion As New Collection
  280. Dim PeriodoCompra = cboPeriodosC.SelectedValue
  281. Dim ValorNominalCompra = txtValorNominalCompra.Text
  282. Dim UltCuponCompra = dtpUltimaFechaCuponCompra.Value
  283. Dim SigFechaCuponCompra = dtpSiguienteFechaCuponCompra.Value
  284. Dim FechaLiqCompra = dtpFechaLiquidacionCompra.Value
  285. Dim FechaVenCompra = dtpFechaVencimientoCompra.Value
  286. Dim PorcentajeCuponCompra = txtPorcentajeCuponCompra.Text.TrimEnd("%") / 100
  287. Dim PrecioVenciCompra = txtPrecioAlVencimientoCompra.Text
  288. Dim PrecioCompra = txtPrecioCompra.Text
  289. Dim DiasBase = IndexBaseC
  290. Dim CostoTransCompra = txtCostoTransferenciaCompra.Text
  291. Dim PorcCupC = txtPorcentajeCuponCompra.Text.TrimEnd("%") / 100
  292. Dim PeriodoVenta = cboPeriodosV.SelectedValue
  293. Dim ValorNominalVenta = txtValorNominalVenta.Text
  294. Dim UltCuponVenta = dtpUltimaFechaCuponVenta.Value
  295. Dim SigFechaCuponVenta = dtpSiguienteFechaCuponVenta.Value
  296. Dim FechaLiqVenta = dtpFechaLiquidacionVenta.Value
  297. Dim FechaVenVenta = dtpFechaVencimientoVenta.Value
  298. Dim PorcentajeCuponVenta = txtPorcentajeCuponVenta.Text.TrimEnd("%") / 100
  299. Dim PrecioVenciVenta = txtPrecioAlVencimientoVenta.Text
  300. Dim PrecioVenta = txtPrecioVenta.Text
  301. Dim DiasBaseV = IndexBaseV
  302. Dim CostoTransVenta = txtCuponesRecibidos.Text
  303. Dim PorcCupV = txtPorcentajeCuponVenta.Text.TrimEnd("%") / 100
  304. Dim ComisionPorCompraCasa = txtComisionPorCompraCasa.Text.TrimEnd("%") / 100
  305. Dim ComisionPorCompraBolsa = txtComisionPorBolsaCompra.Text.TrimEnd("%") / 100
  306. Dim ComisionPorVentaCasa = txtComisionPorVentaCasa.Text.TrimEnd("%") / 100
  307. Dim ComisionPorVentaBolsa = txtComisionPorBolsaVenta.Text.TrimEnd("%") / 100
  308. Dim YTMCompra = txtYTMAlVencimientoComisionCompra.Text.TrimEnd("%") / 100
  309. Dim YTMVenta = txtYTMAlVencimientoComisionVenta.Text.TrimEnd("%") / 100
  310. Dim DiasVenC, DiasVenV, DiasAcuC, DiasAcuV, YTMVenC, YTMVenV, IntAcuC, IntAcuV, IntPorAcuC, IntPorAcuV, PrecSucioC, PrecSucioV
  311. Dim ComisionCasaC, ComisionCasaV, ComisionBolsaC, ComisionBolsaV, ValTransC, ValTransV, MontoPagar, MontoRecibir, CostTrans, CupRecibidos
  312. DiasVenC = txtDiasAlVencimientoCompra.Text
  313. DiasVenV = txtDiasAlVencimientoVenta.Text
  314. DiasAcuC = txtDiasAcumuladosCompra.Text
  315. DiasAcuV = txtDiasAcumuladosVenta.Text
  316. YTMVenC = txtYTMAlVencimientoCompra.Text.ToString.Trim("%") / 100
  317. YTMVenV = txtYTMAlVencimientoVenta.Text.ToString.Trim("%") / 100
  318. IntAcuC = txtInteresAcumuladoCompra.Text
  319. IntAcuV = txtInteresAcumuladoVenta.Text
  320. IntPorAcuC = txtPorcentajeInteresAcumuladoCompra.Text.ToString.Trim("%") / 100
  321. IntPorAcuV = txtPorcentajeInteresAcumuladoVenta.Text.ToString.Trim("%") / 100
  322. PrecSucioC = txtPrecioSucioCompra.Text.ToString.Trim("%") / 100
  323. PrecSucioV = txtPrecioSucioVenta.Text.ToString.Trim("%") / 100
  324. ComisionCasaC = txtComisionCompraCasa.Text
  325. ComisionCasaV = txtComisionVentaCasa.Text
  326. ComisionBolsaC = txtComisionCompraBolsa.Text
  327. ComisionBolsaV = txtComisionVentaBolsa.Text
  328. ValTransC = txtValorTransadoCompra.Text
  329. ValTransV = txtValorTransadoVenta.Text
  330. MontoPagar = txtMontoAPagar.Text
  331. MontoRecibir = txtMontoARecibir.Text
  332. CostTrans = txtCostoTransferenciaCompra.Text
  333. CupRecibidos = txtCuponesRecibidos.Text
  334. Dim Codigo = Variables.Codigo
  335. Coleccion.Add(PeriodoCompra)
  336. Coleccion.Add(ValorNominalCompra)
  337. Coleccion.Add(UltCuponCompra)
  338. Coleccion.Add(SigFechaCuponCompra)
  339. Coleccion.Add(FechaLiqCompra)
  340. Coleccion.Add(FechaVenCompra)
  341. Coleccion.Add(PorcentajeCuponCompra)
  342. Coleccion.Add(PrecioVenciCompra)
  343. Coleccion.Add(PrecioCompra)
  344. Coleccion.Add(DiasBase)
  345. Coleccion.Add(CostoTransCompra)
  346. Coleccion.Add(PeriodoVenta)
  347. Coleccion.Add(ValorNominalVenta)
  348. Coleccion.Add(UltCuponVenta)
  349. Coleccion.Add(SigFechaCuponVenta)
  350. Coleccion.Add(FechaLiqVenta)
  351. Coleccion.Add(FechaVenVenta)
  352. Coleccion.Add(PorcentajeCuponVenta)
  353. Coleccion.Add(PrecioVenciVenta)
  354. Coleccion.Add(PrecioVenta)
  355. Coleccion.Add(DiasBaseV)
  356. Coleccion.Add(CostoTransVenta)
  357. Coleccion.Add(Codigo)
  358. Coleccion.Add(PorcCupC)
  359. Coleccion.Add(PorcCupV)
  360. Coleccion.Add(ComisionPorCompraCasa)
  361. Coleccion.Add(ComisionPorCompraBolsa)
  362. Coleccion.Add(ComisionPorVentaCasa)
  363. Coleccion.Add(ComisionPorVentaBolsa)
  364. Coleccion.Add(YTMCompra)
  365. Coleccion.Add(YTMVenta)
  366. Coleccion.Add(CInt(DiasVenC))
  367. Coleccion.Add(CInt(DiasVenV))
  368. Coleccion.Add(CInt(DiasAcuC))
  369. Coleccion.Add(CInt(DiasAcuV))
  370. Coleccion.Add(CDec(YTMVenC))
  371. Coleccion.Add(CDec(YTMVenV))
  372. Coleccion.Add(CDec(IntAcuC))
  373. Coleccion.Add(CDec(IntAcuV))
  374. Coleccion.Add(CDec(IntPorAcuC))
  375. Coleccion.Add(CDec(IntPorAcuV))
  376. Coleccion.Add(CDec(PrecSucioC))
  377. Coleccion.Add(CDec(PrecSucioV))
  378. Coleccion.Add(CDec(ComisionCasaC))
  379. Coleccion.Add(CDec(ComisionCasaV))
  380. Coleccion.Add(CDec(ComisionBolsaC))
  381. Coleccion.Add(CDec(ComisionBolsaV))
  382. Coleccion.Add(CDec(ValTransC))
  383. Coleccion.Add(CDec(ValTransV))
  384. Coleccion.Add(CDec(MontoPagar))
  385. Coleccion.Add(CDec(MontoRecibir))
  386. Coleccion.Add(CDec(CostTrans))
  387. Coleccion.Add(CDec(CupRecibidos))
  388. Return Coleccion
  389. End Function
  390. Private Sub LimpiarElementos()
  391. Dim Fecha = DateTime.Today
  392. dgvIngresos.Rows.Clear()
  393. cboPeriodosC.SelectedIndex = -1
  394. txtValorNominalCompra.Text = String.Empty
  395. dtpUltimaFechaCuponCompra.Value = Fecha
  396. dtpSiguienteFechaCuponCompra.Value = Fecha
  397. dtpFechaLiquidacionCompra.Value = Fecha
  398. dtpFechaVencimientoCompra.Value = Fecha
  399. txtPorcentajeCuponCompra.Text = String.Empty
  400. txtPrecioAlVencimientoCompra.Text = String.Empty
  401. txtPrecioCompra.Text = String.Empty
  402. cboAnioBaseC.SelectedIndex = 0
  403. txtCostoTransferenciaCompra.Text = String.Empty
  404. txtYTMAlVencimientoCompra.Text = String.Empty
  405. txtYTMAlVencimientoComisionCompra.Text = String.Empty
  406. txtComisionCompraCasa.Text = String.Empty
  407. txtComisionCompraBolsa.Text = String.Empty
  408. cboPeriodosV.SelectedIndex = -1
  409. txtValorNominalVenta.Text = String.Empty
  410. dtpUltimaFechaCuponVenta.Value = Fecha
  411. dtpSiguienteFechaCuponVenta.Value = Fecha
  412. dtpFechaLiquidacionVenta.Value = Fecha
  413. dtpFechaVencimientoVenta.Value = Fecha
  414. txtPorcentajeCuponVenta.Text = String.Empty
  415. txtPrecioAlVencimientoVenta.Text = String.Empty
  416. txtPrecioVenta.Text = String.Empty
  417. cboAnioBaseV.SelectedIndex = 0
  418. txtCuponesRecibidos.Text = String.Empty
  419. txtYTMAlVencimientoVenta.Text = String.Empty
  420. txtYTMAlVencimientoComisionVenta.Text = String.Empty
  421. txtComisionVentaCasa.Text = String.Empty
  422. txtComisionVentaBolsa.Text = String.Empty
  423. End Sub
  424. Private Sub btnAceptar_Click(sender As Object, e As EventArgs) Handles btnAceptar.Click
  425. Dim Codigo = Variables.Codigo
  426. If TipoTransaccion = "N" Then
  427. oDAOPrincipal.Nuevo(Parametros, Instrumento)
  428. ElseIf Not ExisteValidacion() Then
  429. Variables.ColeccionCINV = Parametros()
  430. Me.Close()
  431. End If
  432. If TipoTransaccion = "M" Then
  433. Dim Diccionario As New Dictionary(Of Integer, Collection)
  434. Diccionario = ModificarIngreso()
  435. oDAOPrincipal.ProcesoDatos(Parametros, Diccionario, Instrumento)
  436. End If
  437. If TipoTransaccion = "B" Then
  438. oDAOPrincipal.
  439. Eliminar(Codigo, Instrumento)
  440. LimpiarElementos()
  441. End If
  442. ValidarExistencia()
  443. End Sub
  444. Public Sub CargarRegistro(ByVal CodInversion As String)
  445. TipoTransaccion = "C"
  446. CodigoInversion = CodInversion
  447. End Sub
  448. Private Sub dtpUltimaFechaCuponCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpUltimaFechaCuponCompra.ValueChanged
  449. Formato()
  450. Calculos()
  451. ValidacionErrores()
  452. End Sub
  453. Private Sub dtpSiguienteFechaCuponCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpSiguienteFechaCuponCompra.ValueChanged
  454. Formato()
  455. Calculos()
  456. ValidacionErrores()
  457. End Sub
  458. Private Sub dtpFechaLiquidacionCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaLiquidacionCompra.ValueChanged
  459. Formato()
  460. Calculos()
  461. ValidacionErrores()
  462. End Sub
  463. Private Sub dtpFechaVencimientoCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimientoCompra.ValueChanged
  464. Formato()
  465. Calculos()
  466. ValidacionErrores()
  467. End Sub
  468. Private Sub txtPorcentajeCuponCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeCuponCompra.TextChanged
  469. Calculos()
  470. ValidacionErrores()
  471. End Sub
  472. Private Sub txtPrecioCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioCompra.TextChanged
  473. Calculos()
  474. ValidacionErrores()
  475. End Sub
  476. Private Sub txtPrecioAlVencimientoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoCompra.TextChanged
  477. Calculos()
  478. ValidacionErrores()
  479. End Sub
  480. Private Sub txtCostoTransferenciaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtCostoTransferenciaCompra.TextChanged
  481. Calculos()
  482. ValidacionErrores()
  483. End Sub
  484. Private Sub dtpFechaVencimientoVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimientoVenta.ValueChanged
  485. Formato()
  486. Calculos()
  487. ValidacionErrores()
  488. End Sub
  489. Private Sub cboAnioBaseC_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboAnioBaseC.SelectedIndexChanged
  490. Formato()
  491. Calculos()
  492. ValidacionErrores()
  493. CamposTiempo()
  494. End Sub
  495. Private Sub cboAnioBaseV_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboAnioBaseV.SelectedIndexChanged
  496. Formato()
  497. Calculos()
  498. ValidacionErrores()
  499. CamposTiempo()
  500. End Sub
  501. Sub CargarPeriodos()
  502. If cboPeriodosC.Items.Count = 0 Or cboPeriodosC.Items.Count = 1 Then
  503. Me.cboPeriodosC.DataSource = oDAOGeneral.ListaPeriodicidad
  504. Me.cboPeriodosC.ValueMember = "Codigo"
  505. Me.cboPeriodosC.DisplayMember = "Descripcion"
  506. Me.cboPeriodosC.SelectedIndex = 0
  507. End If
  508. If cboPeriodosV.Items.Count = 0 Or cboPeriodosV.Items.Count = 1 Then
  509. Me.cboPeriodosV.DataSource = oDAOGeneral.ListaPeriodicidad
  510. Me.cboPeriodosV.ValueMember = "Codigo"
  511. Me.cboPeriodosV.DisplayMember = "Descripcion"
  512. Me.cboPeriodosV.SelectedIndex = 0
  513. End If
  514. End Sub
  515. Private Sub cboPeriodosC_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboPeriodosC.SelectedIndexChanged
  516. Formato()
  517. Calculos()
  518. ControlPeriodosCompra()
  519. ValidacionErrores()
  520. CamposTiempo()
  521. End Sub
  522. Private Sub cboPeriodosV_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboPeriodosV.SelectedIndexChanged
  523. Formato()
  524. Calculos()
  525. ValidacionErrores()
  526. CamposTiempo()
  527. End Sub
  528. Private Sub RefrescarValorControles()
  529. Dim codigo = Variables.Codigo
  530. Dim coleccion = oDAOPrincipal.CargarRegistro(codigo, Instrumento)
  531. If (Not coleccion.Count = 1) Then
  532. Dim Operaciones As New Operaciones
  533. If coleccion(10) = 0 Then
  534. IndexBaseC = 0
  535. ElseIf coleccion(10) = 1 Then
  536. IndexBaseC = 1
  537. ElseIf coleccion(10) = 2 Then
  538. IndexBaseC = 2
  539. Else
  540. IndexBaseC = 3
  541. End If
  542. If coleccion(21) = 0 Then
  543. IndexBaseV = 0
  544. ElseIf coleccion(21) = 1 Then
  545. IndexBaseV = 1
  546. ElseIf coleccion(21) = 2 Then
  547. IndexBaseV = 2
  548. Else
  549. IndexBaseV = 3
  550. End If
  551. cboPeriodosC.SelectedValue = coleccion(1).ToString
  552. If (String.IsNullOrEmpty(coleccion(2).ToString)) Then
  553. txtValorNominalCompra.Text = 0
  554. Else
  555. txtValorNominalCompra.Text = coleccion(2).ToString
  556. End If
  557. If (String.IsNullOrEmpty(coleccion(3).ToString)) Then
  558. dtpUltimaFechaCuponCompra.Value = Date.Now.Date
  559. Else
  560. dtpUltimaFechaCuponCompra.Value = coleccion(3).ToString
  561. End If
  562. If (String.IsNullOrEmpty(coleccion(4).ToString)) Then
  563. dtpSiguienteFechaCuponCompra.Value = Date.Now.Date
  564. Else
  565. dtpSiguienteFechaCuponCompra.Value = coleccion(4).ToString
  566. End If
  567. If (String.IsNullOrEmpty(coleccion(5).ToString)) Then
  568. dtpFechaLiquidacionCompra.Value = Date.Now.Date
  569. Else
  570. dtpFechaLiquidacionCompra.Value = coleccion(5).ToString
  571. End If
  572. If (String.IsNullOrEmpty(coleccion(6).ToString)) Then
  573. dtpFechaVencimientoCompra.Value = Date.Now.Date
  574. Else
  575. dtpFechaVencimientoCompra.Value = coleccion(6).ToString
  576. End If
  577. ' txtPorcentajeCuponCompra.Text = coleccion(7)
  578. If (String.IsNullOrEmpty(coleccion(8).ToString)) Then
  579. txtPrecioAlVencimientoCompra.Text = 0
  580. Else
  581. txtPrecioAlVencimientoCompra.Text = coleccion(8).ToString
  582. End If
  583. If (String.IsNullOrEmpty(coleccion(9).ToString)) Then
  584. Else
  585. txtPrecioCompra.Text = coleccion(9).ToString
  586. End If
  587. cboAnioBaseC.SelectedIndex = IndexBaseC
  588. If (String.IsNullOrEmpty(coleccion(11).ToString)) Then
  589. txtCostoTransferenciaCompra.Text = 0
  590. Else
  591. txtCostoTransferenciaCompra.Text = coleccion(11).ToString
  592. End If
  593. txtPorcentajeInteresAcumuladoCompra.Text = String.Empty
  594. If (String.IsNullOrEmpty(coleccion(23).ToString)) Then
  595. txtPorcentajeCuponCompra.Text = 0
  596. Else
  597. txtPorcentajeCuponCompra.Text = (CDec(coleccion(23) * 100).ToString)
  598. End If
  599. If (String.IsNullOrEmpty(txtComisionPorCompraCasa.Text)) Then
  600. txtComisionPorCompraCasa.Text = 0
  601. End If
  602. If (String.IsNullOrEmpty(txtValorTransadoCompra.Text)) Then
  603. txtValorTransadoCompra.Text = 0
  604. End If
  605. If (String.IsNullOrEmpty(txtComisionPorBolsaCompra.Text)) Then
  606. txtComisionPorBolsaCompra.Text = 0
  607. End If
  608. txtComisionCompraCasa.Text = Operaciones.Comisiones(CDec(txtComisionPorCompraCasa.Text.TrimEnd("%") / 100), CDec(txtValorTransadoCompra.Text)).ToString
  609. txtComisionCompraBolsa.Text = Operaciones.Comisiones(CDec(txtComisionPorBolsaCompra.Text.TrimEnd("%") / 100), CDec(txtValorTransadoCompra.Text)).ToString
  610. If (String.IsNullOrEmpty(txtYTMAlVencimientoCompra.Text.ToString)) Then
  611. txtYTMAlVencimientoCompra.Text = 0
  612. End If
  613. If (String.IsNullOrEmpty(coleccion(12).ToString)) Then
  614. cboPeriodosV.SelectedValue = 0
  615. Else
  616. cboPeriodosV.SelectedValue = coleccion(12).ToString
  617. End If
  618. If (String.IsNullOrEmpty(coleccion(13).ToString)) Then
  619. txtValorNominalVenta.Text = 0
  620. Else
  621. txtValorNominalVenta.Text = coleccion(13).ToString
  622. End If
  623. If (String.IsNullOrEmpty(coleccion(14).ToString)) Then
  624. dtpUltimaFechaCuponVenta.Value = Date.Now.Date
  625. Else
  626. dtpUltimaFechaCuponVenta.Value = coleccion(14).ToString
  627. End If
  628. If (String.IsNullOrEmpty(coleccion(15).ToString)) Then
  629. dtpSiguienteFechaCuponVenta.Value = Date.Now.Date
  630. Else
  631. dtpSiguienteFechaCuponVenta.Value = coleccion(15).ToString
  632. End If
  633. If (String.IsNullOrEmpty(coleccion(16).ToString)) Then
  634. dtpFechaLiquidacionVenta.Value = Date.Now.Date
  635. Else
  636. dtpFechaLiquidacionVenta.Value = coleccion(16).ToString
  637. End If
  638. If (String.IsNullOrEmpty(coleccion(17).ToString)) Then
  639. dtpFechaVencimientoVenta.Value = Date.Now.Date
  640. Else
  641. dtpFechaVencimientoVenta.Value = coleccion(17).ToString
  642. End If
  643. If (String.IsNullOrEmpty(coleccion(24).ToString)) Then
  644. txtPorcentajeCuponVenta.Text = 0
  645. Else
  646. txtPorcentajeCuponVenta.Text = CDec(coleccion(24) * 100).ToString
  647. End If
  648. If (String.IsNullOrEmpty(coleccion(19).ToString)) Then
  649. txtPrecioAlVencimientoVenta.Text = 0
  650. Else
  651. txtPrecioAlVencimientoVenta.Text = coleccion(19).ToString
  652. End If
  653. If (String.IsNullOrEmpty(coleccion(20).ToString)) Then
  654. txtPrecioVenta.Text = 0
  655. Else
  656. txtPrecioVenta.Text = coleccion(20).ToString
  657. End If
  658. cboAnioBaseV.SelectedIndex = IndexBaseV
  659. If (String.IsNullOrEmpty(coleccion(22).ToString)) Then
  660. txtCuponesRecibidos.Text = 0
  661. Else
  662. txtCuponesRecibidos.Text = coleccion(22).ToString
  663. End If
  664. If (String.IsNullOrEmpty(txtComisionPorVentaCasa.Text)) Then
  665. txtComisionPorVentaCasa.Text = 0
  666. End If
  667. If (String.IsNullOrEmpty(txtComisionPorBolsaVenta.Text)) Then
  668. txtComisionPorBolsaVenta.Text = 0
  669. End If
  670. If String.IsNullOrEmpty(txtYTMAlVencimientoVenta.Text.ToString) Then
  671. txtYTMAlVencimientoVenta.Text = 0
  672. End If
  673. If (String.IsNullOrEmpty(coleccion(25).ToString)) Then
  674. txtComisionPorCompraCasa.Text = 0
  675. Else
  676. txtComisionPorCompraCasa.Text = (CDec(coleccion(25)) * 100).ToString
  677. End If
  678. If (String.IsNullOrEmpty(coleccion(26).ToString)) Then
  679. txtComisionPorBolsaCompra.Text = 0
  680. Else
  681. txtComisionPorBolsaCompra.Text = (CDec(coleccion(26)) * 100).ToString
  682. End If
  683. If (String.IsNullOrEmpty(coleccion(27).ToString)) Then
  684. txtComisionPorVentaCasa.Text = 0
  685. Else
  686. txtComisionPorVentaCasa.Text = (CDec(coleccion(27)) * 100).ToString
  687. End If
  688. If (String.IsNullOrEmpty(coleccion(28).ToString)) Then
  689. txtComisionPorBolsaVenta.Text = 0
  690. Else
  691. txtComisionPorBolsaVenta.Text = (CDec(coleccion(28)) * 100).ToString
  692. End If
  693. If (String.IsNullOrEmpty(coleccion(29).ToString)) Then
  694. txtYTMAlVencimientoComisionCompra.Text = 0
  695. Else
  696. txtYTMAlVencimientoComisionCompra.Text = (CDec(coleccion(29)) * 100).ToString
  697. End If
  698. If (String.IsNullOrEmpty(coleccion(30).ToString)) Then
  699. txtYTMAlVencimientoComisionVenta.Text = 0
  700. Else
  701. txtYTMAlVencimientoComisionVenta.Text = (CDec(coleccion(30)) * 100).ToString
  702. End If
  703. 'Campos Extras'
  704. If Not String.IsNullOrEmpty(coleccion(31).ToString) Then
  705. txtDiasAlVencimientoCompra.Text = coleccion(31).ToString
  706. End If
  707. If Not String.IsNullOrEmpty(coleccion(32).ToString) Then
  708. txtDiasAlVencimientoVenta.Text = coleccion(32).ToString
  709. End If
  710. If Not String.IsNullOrEmpty(coleccion(33).ToString) Then
  711. txtDiasAcumuladosCompra.Text = coleccion(33).ToString
  712. End If
  713. If Not String.IsNullOrEmpty(coleccion(34).ToString) Then
  714. txtDiasAcumuladosVenta.Text = coleccion(34).ToString
  715. End If
  716. If Not String.IsNullOrEmpty(coleccion(35).ToString) Then
  717. txtYTMAlVencimientoCompra.Text = (coleccion(35) * 100).ToString + "%"
  718. End If
  719. If Not String.IsNullOrEmpty(coleccion(36).ToString) Then
  720. txtYTMAlVencimientoVenta.Text = (coleccion(36) * 100).ToString + "%"
  721. End If
  722. If Not String.IsNullOrEmpty(coleccion(37).ToString) Then
  723. txtPorcentajeInteresAcumuladoCompra.Text = (coleccion(37) * 100).ToString + "%"
  724. End If
  725. If Not String.IsNullOrEmpty(coleccion(38).ToString) Then
  726. txtPorcentajeInteresAcumuladoVenta.Text = (coleccion(38) * 100).ToString + "%"
  727. End If
  728. If Not String.IsNullOrEmpty(coleccion(39).ToString) Then
  729. txtInteresAcumuladoCompra.Text = coleccion(39).ToString
  730. End If
  731. If Not String.IsNullOrEmpty(coleccion(40).ToString) Then
  732. txtInteresAcumuladoVenta.Text = coleccion(40).ToString
  733. End If
  734. If Not String.IsNullOrEmpty(coleccion(41).ToString) Then
  735. txtPrecioSucioCompra.Text = (coleccion(41) * 100).ToString
  736. End If
  737. If Not String.IsNullOrEmpty(coleccion(42).ToString) Then
  738. txtPrecioSucioVenta.Text = (coleccion(42) * 100).ToString
  739. End If
  740. If Not String.IsNullOrEmpty(coleccion(43).ToString) Then
  741. txtComisionCompraCasa.Text = coleccion(43).ToString
  742. End If
  743. If Not String.IsNullOrEmpty(coleccion(44).ToString) Then
  744. txtComisionVentaCasa.Text = coleccion(44).ToString
  745. End If
  746. If Not String.IsNullOrEmpty(coleccion(45).ToString) Then
  747. txtComisionCompraBolsa.Text = coleccion(45).ToString
  748. End If
  749. If Not String.IsNullOrEmpty(coleccion(46).ToString) Then
  750. txtComisionVentaBolsa.Text = coleccion(46).ToString
  751. End If
  752. If Not String.IsNullOrEmpty(coleccion(47).ToString) Then
  753. txtValorTransadoCompra.Text = coleccion(47).ToString
  754. End If
  755. If Not String.IsNullOrEmpty(coleccion(48).ToString) Then
  756. txtValorTransadoVenta.Text = coleccion(48).ToString
  757. End If
  758. If Not String.IsNullOrEmpty(coleccion(49).ToString) Then
  759. txtMontoAPagar.Text = coleccion(49).ToString
  760. End If
  761. If Not String.IsNullOrEmpty(coleccion(50).ToString) Then
  762. txtMontoARecibir.Text = coleccion(50).ToString
  763. End If
  764. If Not String.IsNullOrEmpty(coleccion(51).ToString) Then
  765. txtCuponesRecibidos.Text = coleccion(51).ToString
  766. End If
  767. End If
  768. End Sub
  769. Sub Formato()
  770. If cboPeriodosC.SelectedIndex = -1 Then
  771. If cboPeriodosC.Items.Count > 0 Then
  772. cboPeriodosC.SelectedIndex = 0
  773. End If
  774. End If
  775. If cboPeriodosV.SelectedIndex = -1 Then
  776. If cboPeriodosV.Items.Count > 0 Then
  777. cboPeriodosV.SelectedIndex = 0
  778. End If
  779. End If
  780. If cboAnioBaseC.SelectedIndex = -1 Then
  781. If cboAnioBaseC.Items.Count > 0 Then
  782. cboAnioBaseC.SelectedIndex = 0
  783. End If
  784. End If
  785. If cboAnioBaseV.SelectedIndex = -1 Then
  786. If cboAnioBaseV.Items.Count > 0 Then
  787. cboAnioBaseV.SelectedIndex = 0
  788. End If
  789. End If
  790. If IsNumeric(txtPorcentajeInteresAcumuladoCompra.Text.ToString.Trim("%")) Then
  791. If Double.IsNaN(txtPorcentajeInteresAcumuladoCompra.Text.ToString.Trim("%")) Then
  792. txtPorcentajeInteresAcumuladoCompra.Text = "0.0%"
  793. End If
  794. End If
  795. If IsNumeric(txtPorcentajeInteresAcumuladoVenta.Text.ToString.Trim("%")) Then
  796. If Double.IsNaN(txtPorcentajeInteresAcumuladoVenta.Text.ToString.Trim("%")) Then
  797. txtPorcentajeInteresAcumuladoVenta.Text = "0.0%"
  798. End If
  799. End If
  800. If IsNumeric(txtPrecioSucioCompra.Text.ToString.Trim("%")) Then
  801. If Double.IsNaN(txtPrecioSucioCompra.Text.ToString.Trim("%")) Then
  802. txtPrecioSucioCompra.Text = "0.0%"
  803. End If
  804. End If
  805. If IsNumeric(txtPrecioSucioVenta.Text.ToString.Trim("%")) Then
  806. If Double.IsNaN(txtPrecioSucioVenta.Text.ToString.Trim("%")) Then
  807. txtPrecioSucioVenta.Text = "0.0%"
  808. End If
  809. End If
  810. If (String.IsNullOrEmpty(txtValorNominalCompra.Text.ToString)) Then
  811. txtValorNominalCompra.Text = "0.0"
  812. End If
  813. If (String.IsNullOrEmpty(txtDiasAlVencimientoCompra.Text)) Then
  814. txtDiasAlVencimientoCompra.Text = "0.0"
  815. End If
  816. If (String.IsNullOrEmpty(txtDiasAcumuladosCompra.Text)) Then
  817. txtDiasAcumuladosCompra.Text = "0.0"
  818. End If
  819. If (String.IsNullOrEmpty(txtPorcentajeCuponCompra.Text)) Then
  820. txtPorcentajeCuponCompra.Text = "0.0"
  821. End If
  822. If (String.IsNullOrEmpty(txtYTMAlVencimientoComisionCompra.Text)) Then
  823. txtYTMAlVencimientoComisionCompra.Text = "0.0"
  824. End If
  825. If (String.IsNullOrEmpty(txtYTMAlVencimientoCompra.Text)) Then
  826. txtYTMAlVencimientoCompra.Text = "0.0"
  827. End If
  828. If (String.IsNullOrEmpty(txtPrecioAlVencimientoCompra.Text)) Then
  829. txtPrecioAlVencimientoCompra.Text = "0.0"
  830. End If
  831. If (String.IsNullOrEmpty(txtPrecioCompra.Text)) Then
  832. txtPrecioCompra.Text = "0.0"
  833. End If
  834. If (String.IsNullOrEmpty(txtInteresAcumuladoCompra.Text)) Then
  835. txtInteresAcumuladoCompra.Text = "0.0"
  836. End If
  837. If (String.IsNullOrEmpty(txtPorcentajeInteresAcumuladoCompra.Text)) Then
  838. txtPorcentajeInteresAcumuladoCompra.Text = "0.0"
  839. End If
  840. If (String.IsNullOrEmpty(txtPrecioSucioCompra.Text)) Then
  841. txtPrecioSucioCompra.Text = "0.0"
  842. End If
  843. If (String.IsNullOrEmpty(txtComisionPorCompraCasa.Text)) Then
  844. txtComisionPorCompraCasa.Text = "0.0"
  845. End If
  846. If (String.IsNullOrEmpty(txtComisionCompraCasa.Text)) Then
  847. txtComisionCompraCasa.Text = "0.0"
  848. End If
  849. If (String.IsNullOrEmpty(txtComisionPorBolsaCompra.Text)) Then
  850. txtComisionPorBolsaCompra.Text = "0.0"
  851. End If
  852. If (String.IsNullOrEmpty(txtComisionCompraBolsa.Text)) Then
  853. txtComisionCompraBolsa.Text = "0.0"
  854. End If
  855. If (String.IsNullOrEmpty(txtValorTransadoCompra.Text)) Then
  856. txtValorTransadoCompra.Text = "0.0"
  857. End If
  858. If (String.IsNullOrEmpty(txtMontoAPagar.Text)) Then
  859. txtMontoAPagar.Text = "0.0"
  860. End If
  861. If (String.IsNullOrEmpty(txtCostoTransferenciaCompra.Text)) Then
  862. txtCostoTransferenciaCompra.Text = "0.0"
  863. End If
  864. If (String.IsNullOrEmpty(txtValorNominalVenta.Text)) Then
  865. txtValorNominalVenta.Text = "0.0"
  866. End If
  867. If (String.IsNullOrEmpty(txtDiasAlVencimientoVenta.Text)) Then
  868. txtDiasAlVencimientoVenta.Text = "0.0"
  869. End If
  870. If (String.IsNullOrEmpty(txtDiasAcumuladosVenta.Text)) Then
  871. txtDiasAcumuladosVenta.Text = "0.0"
  872. End If
  873. If (String.IsNullOrEmpty(txtPorcentajeCuponVenta.Text)) Then
  874. txtPorcentajeCuponVenta.Text = "0.0"
  875. End If
  876. If (String.IsNullOrEmpty(txtYTMAlVencimientoComisionVenta.Text)) Then
  877. txtYTMAlVencimientoComisionVenta.Text = "0.0"
  878. End If
  879. If (String.IsNullOrEmpty(txtYTMAlVencimientoVenta.Text)) Then
  880. txtYTMAlVencimientoVenta.Text = "0.0"
  881. End If
  882. If (String.IsNullOrEmpty(txtPrecioAlVencimientoVenta.Text)) Then
  883. txtPrecioAlVencimientoVenta.Text = "0.0"
  884. End If
  885. If (String.IsNullOrEmpty(txtPrecioVenta.Text)) Then
  886. txtPrecioVenta.Text = "0.0"
  887. End If
  888. If (String.IsNullOrEmpty(txtInteresAcumuladoVenta.Text)) Then
  889. txtInteresAcumuladoVenta.Text = "0.0"
  890. End If
  891. If (String.IsNullOrEmpty(txtPorcentajeInteresAcumuladoVenta.Text)) Then
  892. txtPorcentajeInteresAcumuladoVenta.Text = "0.0"
  893. End If
  894. If (String.IsNullOrEmpty(txtPrecioSucioVenta.Text)) Then
  895. txtPrecioSucioVenta.Text = "0.0"
  896. End If
  897. If (String.IsNullOrEmpty(txtComisionPorVentaCasa.Text)) Then
  898. txtComisionPorVentaCasa.Text = "0.0"
  899. End If
  900. If (String.IsNullOrEmpty(txtComisionVentaCasa.Text)) Then
  901. txtComisionVentaCasa.Text = "0.0"
  902. End If
  903. If (String.IsNullOrEmpty(txtComisionPorBolsaVenta.Text)) Then
  904. txtComisionPorBolsaVenta.Text = "0.0"
  905. End If
  906. If (String.IsNullOrEmpty(txtComisionVentaBolsa.Text)) Then
  907. txtComisionVentaBolsa.Text = "0.0"
  908. End If
  909. If (String.IsNullOrEmpty(txtValorTransadoVenta.Text)) Then
  910. txtValorTransadoVenta.Text = "0.0"
  911. End If
  912. If (String.IsNullOrEmpty(txtMontoARecibir.Text)) Then
  913. txtMontoARecibir.Text = "0.0"
  914. End If
  915. If (String.IsNullOrEmpty(txtCuponesRecibidos.Text)) Then
  916. txtCuponesRecibidos.Text = "0.0"
  917. End If
  918. If (txtPorcentajeCuponCompra.ToString.IndexOf("%") = -1) Then
  919. txtPorcentajeCuponCompra.Text += "%"
  920. End If
  921. If (txtYTMAlVencimientoCompra.ToString.IndexOf("%") = -1) Then
  922. txtYTMAlVencimientoCompra.Text += "%"
  923. End If
  924. If (txtPorcentajeCuponVenta.ToString.IndexOf("%") = -1) Then
  925. txtPorcentajeCuponVenta.Text += "%"
  926. End If
  927. If (txtYTMAlVencimientoVenta.ToString.IndexOf("%") = -1) Then
  928. txtYTMAlVencimientoVenta.Text += "%"
  929. End If
  930. If (txtComisionPorCompraCasa.ToString.IndexOf("%") = -1) Then
  931. txtComisionPorCompraCasa.Text += "%"
  932. End If
  933. If (txtComisionPorBolsaCompra.ToString.IndexOf("%") = -1) Then
  934. txtComisionPorBolsaCompra.Text += "%"
  935. End If
  936. If (txtComisionPorVentaCasa.ToString.IndexOf("%") = -1) Then
  937. txtComisionPorVentaCasa.Text += "%"
  938. End If
  939. If (txtComisionPorBolsaVenta.ToString.IndexOf("%") = -1) Then
  940. txtComisionPorBolsaVenta.Text += "%"
  941. End If
  942. End Sub
  943. Sub Calculos()
  944. If (Not Cargar) Then
  945. Dim V_dtpSiguienteFechaCuponCompra = Date.Now.Date, V_dtpFechaVencimientoCompra = Date.Now.Date, V_dtpFechaLiquidacionCompra = Date.Now.Date, V_dtpUltimaFechaCuponCompra = Date.Now.Date
  946. Dim V_txtValorNominalCompra = 0.0, V_txtPorcentajeCuponCompra = 0.0, V_txtDiasAcumuladosCompra = 0, V_txtInteresAcumuladoCompra = 0.0
  947. Dim V_txtPorcentajeInteresAcumuladoCompra = 0.0, V_txtComisionPorCompraCasa = 0.0, V_txtValorTransadoCompra = 0.0
  948. Dim V_txtComisionPorBolsaCompra = 0.0, V_txtComisionCompraCasa = 0.0, V_txtComisionCompraBolsa = 0.0
  949. Dim V_txtYTMAlVencimientoCompra = 0.0, V_txtYTMAlVencimientoComisionCompra = 0.0, V_txtMontoAPagar = 0.0, V_txtPrecioCompra = 0.0
  950. Dim V_txtPrecioAlVencimientoCompra = 0.0, V_txtCostoTransferenciaCompra = 0.0, V_txtPrecioSucioCompra = 0.0
  951. Dim V_txtDiasAlVencimientoCompra = 0
  952. Dim TipoPeriodoCompra As Integer = 0
  953. Dim V_dtpSiguienteFechaCuponVenta = Date.Now.Date, V_dtpFechaVencimientoVenta = Date.Now.Date, V_dtpFechaLiquidacionVenta = Date.Now.Date, V_dtpUltimaFechaCuponVenta = Date.Now.Date
  954. Dim V_txtValorNominalVenta = 0.0, V_txtPorcentajeCuponVenta = 0.0, V_txtDiasAcumuladosVenta = 0, V_txtInteresAcumuladoVenta = 0.0
  955. Dim V_txtPorcentajeInteresAcumuladoVenta = 0.0, V_txtComisionPorVentaCasa = 0.0, V_txtValorTransadoVenta = 0.0
  956. Dim V_txtComisionPorBolsaVenta = 0.0, V_txtComisionVentaCasa = 0.0, V_txtComisionVentaBolsa = 0.0
  957. Dim V_txtYTMAlVencimientoVenta = 0.0, V_txtYTMAlVencimientoComisionVenta = 0.0, V_txtPrecioVenta = 0.0
  958. Dim V_txtPrecioAlVencimientoVenta = 0.0, V_txtCostoTransferenciaVenta = 0.0, V_txtPrecioSucioVenta = 0.0
  959. Dim V_txtDiasAlVencimientoVenta = 0.0, V_txtMontoARecibir = 0.0, V_txtCuponesRecibidos = 0.0
  960. Dim TipoPeriodoVenta As Integer = 0
  961. V_dtpSiguienteFechaCuponCompra = dtpSiguienteFechaCuponCompra.Value
  962. V_dtpSiguienteFechaCuponVenta = dtpSiguienteFechaCuponVenta.Value
  963. V_dtpUltimaFechaCuponCompra = dtpUltimaFechaCuponCompra.Value
  964. V_dtpUltimaFechaCuponVenta = dtpUltimaFechaCuponVenta.Value
  965. V_dtpFechaVencimientoCompra = dtpFechaVencimientoCompra.Value
  966. V_dtpFechaVencimientoVenta = dtpFechaVencimientoVenta.Value
  967. V_dtpFechaLiquidacionCompra = dtpFechaLiquidacionCompra.Value
  968. V_dtpFechaLiquidacionVenta = dtpFechaLiquidacionVenta.Value
  969. If String.IsNullOrEmpty(txtValorNominalCompra.Text) Then
  970. V_txtValorNominalCompra = 0
  971. Else
  972. V_txtValorNominalCompra = txtValorNominalCompra.Text
  973. End If
  974. If String.IsNullOrEmpty(txtValorNominalVenta.Text) Then
  975. V_txtValorNominalVenta = 0
  976. Else
  977. V_txtValorNominalVenta = txtValorNominalVenta.Text
  978. End If
  979. If String.IsNullOrEmpty(txtPorcentajeCuponCompra.Text.Trim("%")) Then
  980. V_txtPorcentajeCuponCompra = 0
  981. Else
  982. V_txtPorcentajeCuponCompra = CDec(txtPorcentajeCuponCompra.Text.Trim("%") / 100)
  983. End If
  984. If String.IsNullOrEmpty(txtPorcentajeCuponVenta.Text.Trim("%")) Then
  985. V_txtPorcentajeCuponVenta = 0
  986. Else
  987. V_txtPorcentajeCuponVenta = CDec(txtPorcentajeCuponVenta.Text.Trim("%") / 100)
  988. End If
  989. If String.IsNullOrEmpty(txtYTMAlVencimientoCompra.Text.Trim("%")) Then
  990. V_txtYTMAlVencimientoCompra = 0
  991. Else
  992. V_txtYTMAlVencimientoCompra = CDec(txtYTMAlVencimientoCompra.Text.Trim("%") / 100)
  993. End If
  994. If String.IsNullOrEmpty(txtYTMAlVencimientoVenta.Text.Trim("%")) Then
  995. V_txtYTMAlVencimientoVenta = 0
  996. Else
  997. V_txtYTMAlVencimientoVenta = CDec(txtYTMAlVencimientoVenta.Text.Trim("%") / 100)
  998. End If
  999. If String.IsNullOrEmpty(txtPrecioCompra.Text) Then
  1000. V_txtPrecioCompra = 0
  1001. Else
  1002. V_txtPrecioCompra = txtPrecioCompra.Text
  1003. End If
  1004. If String.IsNullOrEmpty(txtPrecioVenta.Text) Then
  1005. V_txtPrecioVenta = 0
  1006. Else
  1007. V_txtPrecioVenta = txtPrecioVenta.Text
  1008. End If
  1009. If String.IsNullOrEmpty(txtPrecioAlVencimientoCompra.Text) Then
  1010. V_txtPrecioAlVencimientoCompra = 0
  1011. Else
  1012. V_txtPrecioAlVencimientoCompra = txtPrecioAlVencimientoCompra.Text
  1013. End If
  1014. If String.IsNullOrEmpty(txtPrecioAlVencimientoVenta.Text) Then
  1015. V_txtPrecioAlVencimientoVenta = 0
  1016. Else
  1017. V_txtPrecioAlVencimientoVenta = txtPrecioAlVencimientoVenta.Text
  1018. End If
  1019. If String.IsNullOrEmpty(txtComisionPorCompraCasa.Text.Trim("%")) Then
  1020. V_txtComisionPorCompraCasa = 0
  1021. Else
  1022. V_txtComisionPorCompraCasa = CDec(txtComisionPorCompraCasa.Text.Trim("%")) / 100
  1023. End If
  1024. If String.IsNullOrEmpty(txtComisionPorVentaCasa.Text.Trim("%")) Then
  1025. V_txtComisionPorVentaCasa = 0
  1026. Else
  1027. V_txtComisionPorVentaCasa = CDec(txtComisionPorVentaCasa.Text.Trim("%")) / 100
  1028. End If
  1029. If String.IsNullOrEmpty(txtComisionCompraCasa.Text) Then
  1030. V_txtComisionCompraCasa = 0
  1031. Else
  1032. V_txtComisionCompraCasa = txtComisionCompraCasa.Text
  1033. End If
  1034. If String.IsNullOrEmpty(txtComisionVentaCasa.Text) Then
  1035. V_txtComisionVentaCasa = 0
  1036. Else
  1037. V_txtComisionVentaCasa = txtComisionVentaCasa.Text
  1038. End If
  1039. If String.IsNullOrEmpty(txtComisionPorBolsaCompra.Text.Trim("%")) Then
  1040. V_txtComisionPorBolsaCompra = 0
  1041. Else
  1042. V_txtComisionPorBolsaCompra = CDec(txtComisionPorBolsaCompra.Text.Trim("%")) / 100
  1043. End If
  1044. If String.IsNullOrEmpty(txtComisionPorBolsaVenta.Text.Trim("%")) Then
  1045. V_txtComisionPorBolsaVenta = 0
  1046. Else
  1047. V_txtComisionPorBolsaVenta = CDec(txtComisionPorBolsaVenta.Text.Trim("%")) / 100
  1048. End If
  1049. If String.IsNullOrEmpty(txtComisionCompraBolsa.Text) Then
  1050. V_txtComisionCompraBolsa = 0
  1051. Else
  1052. V_txtComisionCompraBolsa = txtComisionCompraBolsa.Text
  1053. End If
  1054. If String.IsNullOrEmpty(txtComisionVentaBolsa.Text) Then
  1055. V_txtComisionVentaBolsa = 0
  1056. Else
  1057. V_txtComisionVentaBolsa = txtComisionVentaBolsa.Text
  1058. End If
  1059. If String.IsNullOrEmpty(txtCostoTransferenciaCompra.Text) Then
  1060. V_txtCostoTransferenciaCompra = 0
  1061. Else
  1062. V_txtCostoTransferenciaCompra = txtCostoTransferenciaCompra.Text
  1063. End If
  1064. If (cboPeriodosC.SelectedValue = "M") Then
  1065. TipoPeriodoCompra = 12
  1066. PeriodoC = 1
  1067. ElseIf (cboPeriodosC.SelectedValue = "T") Then
  1068. TipoPeriodoCompra = 4
  1069. PeriodoC = 3
  1070. ElseIf (cboPeriodosC.SelectedValue = "S") Then
  1071. TipoPeriodoCompra = 2
  1072. PeriodoC = 6
  1073. ElseIf (cboPeriodosC.SelectedValue = "A") Then
  1074. TipoPeriodoCompra = 1
  1075. PeriodoC = 12
  1076. End If
  1077. If (cboPeriodosV.SelectedValue = "M") Then
  1078. TipoPeriodoVenta = 12
  1079. PeriodoV = 1
  1080. ElseIf (cboPeriodosV.SelectedValue = "T") Then
  1081. TipoPeriodoVenta = 4
  1082. PeriodoV = 3
  1083. ElseIf (cboPeriodosV.SelectedValue = "S") Then
  1084. TipoPeriodoVenta = 2
  1085. PeriodoV = 6
  1086. ElseIf (cboPeriodosV.SelectedValue = "A") Then
  1087. TipoPeriodoVenta = 1
  1088. PeriodoV = 12
  1089. End If
  1090. If cboAnioBaseC.SelectedIndex = 0 Then
  1091. IndexBaseC = 0
  1092. ElseIf cboAnioBaseC.SelectedIndex = 1 Then
  1093. IndexBaseC = 1
  1094. ElseIf cboAnioBaseC.SelectedIndex = 2 Then
  1095. IndexBaseC = 2
  1096. Else
  1097. IndexBaseC = 3
  1098. End If
  1099. If cboAnioBaseV.SelectedIndex = 0 Then
  1100. IndexBaseV = 0
  1101. ElseIf cboAnioBaseV.SelectedIndex = 1 Then
  1102. IndexBaseV = 1
  1103. ElseIf cboAnioBaseV.SelectedIndex = 2 Then
  1104. IndexBaseV = 2
  1105. Else
  1106. IndexBaseV = 3
  1107. End If
  1108. If (Tipo = 0) Then
  1109. dtpUltimaFechaCuponCompra.Value = FechaCupon(V_dtpFechaLiquidacionCompra, V_dtpFechaVencimientoCompra, TipoPeriodoCompra)
  1110. dtpUltimaFechaCuponVenta.Value = FechaCupon(V_dtpFechaLiquidacionVenta, V_dtpFechaVencimientoVenta, TipoPeriodoVenta)
  1111. Else
  1112. dtpSiguienteFechaCuponCompra.Value = FechaTipo(V_dtpUltimaFechaCuponCompra, TipoPeriodoCompra)
  1113. dtpSiguienteFechaCuponVenta.Value = FechaTipo(V_dtpUltimaFechaCuponVenta, TipoPeriodoVenta)
  1114. End If
  1115. V_dtpSiguienteFechaCuponCompra = dtpSiguienteFechaCuponCompra.Value
  1116. V_dtpSiguienteFechaCuponVenta = dtpSiguienteFechaCuponVenta.Value
  1117. V_dtpUltimaFechaCuponCompra = dtpUltimaFechaCuponCompra.Value
  1118. V_dtpUltimaFechaCuponVenta = dtpUltimaFechaCuponVenta.Value
  1119. V_dtpFechaVencimientoCompra = dtpFechaVencimientoCompra.Value
  1120. V_dtpFechaVencimientoVenta = dtpFechaVencimientoVenta.Value
  1121. V_dtpFechaLiquidacionCompra = dtpFechaLiquidacionCompra.Value
  1122. V_dtpFechaLiquidacionVenta = dtpFechaLiquidacionVenta.Value
  1123. 'Valores de Compra
  1124. V_txtDiasAlVencimientoCompra = BonoCalculo.DiasVencimiento(V_dtpFechaLiquidacionCompra, V_dtpFechaVencimientoCompra, IndexBaseC)
  1125. V_txtDiasAcumuladosCompra = Operaciones.DiasAcumulados(V_dtpUltimaFechaCuponCompra, V_dtpFechaLiquidacionCompra, IndexBaseC)
  1126. V_txtInteresAcumuladoCompra = BonoCalculo.InteresAcumulado(V_txtValorNominalCompra, V_txtPorcentajeCuponCompra, V_dtpUltimaFechaCuponCompra, V_dtpFechaLiquidacionCompra, V_txtDiasAcumuladosCompra, IndexBaseC)
  1127. V_txtPorcentajeInteresAcumuladoCompra = BonoCalculo.InteresAcumuladoPor(V_txtInteresAcumuladoCompra, V_txtValorNominalCompra, PeriodoC, IndexBaseC) * 100
  1128. V_txtPrecioSucioCompra = BonoCalculo.PrecioSucio(V_txtPrecioCompra, V_txtPorcentajeInteresAcumuladoCompra / 100)
  1129. V_txtValorTransadoCompra = BonoCalculo.ValorTrasado(V_txtPrecioCompra, V_txtValorNominalCompra)
  1130. V_txtComisionCompraCasa = CalcularComision(V_txtComisionPorCompraCasa, V_txtValorTransadoCompra)
  1131. V_txtComisionCompraBolsa = CalcularComision(V_txtComisionPorBolsaCompra, V_txtValorTransadoCompra)
  1132. V_txtYTMAlVencimientoComisionCompra = Bonos.CalcularYTMComision(CDec(V_txtYTMAlVencimientoCompra), CDec(V_txtComisionPorCompraCasa), V_txtDiasAlVencimientoCompra, CDec(V_txtComisionPorBolsaCompra), V_dtpFechaLiquidacionCompra, V_dtpFechaVencimientoCompra, IndexBaseC)
  1133. V_txtMontoAPagar = BonoCalculo.MontoPagar(V_txtValorTransadoCompra, V_txtComisionCompraBolsa, V_txtComisionCompraCasa, V_txtInteresAcumuladoCompra, V_txtCostoTransferenciaCompra)
  1134. 'Valores de Venta
  1135. V_txtDiasAlVencimientoVenta = BonoCalculo.DiasVencimiento(V_dtpFechaLiquidacionVenta, V_dtpFechaVencimientoVenta, IndexBaseV)
  1136. V_txtDiasAcumuladosVenta = Operaciones.DiasAcumulados(V_dtpUltimaFechaCuponVenta, V_dtpFechaLiquidacionVenta, IndexBaseV)
  1137. V_txtInteresAcumuladoVenta = BonoCalculo.InteresAcumulado(V_txtValorNominalVenta, V_txtPorcentajeCuponVenta, V_dtpUltimaFechaCuponVenta, V_dtpFechaLiquidacionVenta, V_txtDiasAcumuladosVenta, IndexBaseV)
  1138. V_txtPorcentajeInteresAcumuladoVenta = BonoCalculo.InteresAcumuladoPor(V_txtInteresAcumuladoVenta, V_txtValorNominalVenta, PeriodoV, IndexBaseV) * 100
  1139. V_txtPrecioSucioVenta = BonoCalculo.PrecioSucio(V_txtPrecioVenta, V_txtPorcentajeInteresAcumuladoVenta / 100)
  1140. V_txtValorTransadoVenta = BonoCalculo.ValorTrasado(V_txtPrecioVenta, V_txtValorNominalVenta)
  1141. V_txtComisionVentaCasa = CalcularComision(V_txtComisionPorVentaCasa, V_txtValorTransadoVenta)
  1142. V_txtComisionVentaBolsa = CalcularComision(V_txtComisionPorBolsaVenta, V_txtValorTransadoVenta)
  1143. V_txtYTMAlVencimientoComisionVenta = Bonos.CalcularYTMComision(V_txtYTMAlVencimientoVenta, V_txtComisionPorVentaCasa, V_txtDiasAlVencimientoVenta, V_txtComisionPorBolsaVenta, V_dtpFechaLiquidacionVenta, V_dtpFechaVencimientoVenta, IndexBaseV)
  1144. V_txtMontoARecibir = BonoCalculo.MontoRecibir(V_txtValorTransadoVenta, V_txtComisionVentaBolsa, V_txtComisionVentaCasa, V_txtInteresAcumuladoVenta)
  1145. V_txtCuponesRecibidos = Recibido()
  1146. 'Valores de Compra
  1147. txtDiasAlVencimientoCompra.Text = Format(V_txtDiasAlVencimientoCompra, "0.0000")
  1148. txtDiasAcumuladosCompra.Text = Format(V_txtDiasAcumuladosCompra, "0.0000")
  1149. txtInteresAcumuladoCompra.Text = Format(V_txtInteresAcumuladoCompra, "0.0000")
  1150. txtPorcentajeInteresAcumuladoCompra.Text = CStr(Format(V_txtPorcentajeInteresAcumuladoCompra, "0.000")) + "%"
  1151. txtPrecioSucioCompra.Text = Format(V_txtPrecioSucioCompra, "0.0000")
  1152. txtValorTransadoCompra.Text = Format(V_txtValorTransadoCompra, "0.0000")
  1153. txtComisionCompraCasa.Text = Format(V_txtComisionCompraCasa, "0.0000")
  1154. txtComisionCompraBolsa.Text = Format(V_txtComisionCompraBolsa, "0.0000")
  1155. txtYTMAlVencimientoComisionCompra.Text = CStr(Format(V_txtYTMAlVencimientoComisionCompra, "0.0000") * 100) + "%"
  1156. txtMontoAPagar.Text = Format(V_txtMontoAPagar, "0.0000")
  1157. txtComisionCompraCasa.Text = Format(V_txtComisionCompraCasa, "0.0000")
  1158. txtComisionCompraBolsa.Text = Format(V_txtComisionCompraBolsa, "0.0000")
  1159. 'Valores de Venta
  1160. FechaCupon(V_dtpFechaLiquidacionVenta, V_dtpFechaVencimientoVenta, TipoPeriodoVenta)
  1161. txtDiasAlVencimientoVenta.Text = Format(V_txtDiasAlVencimientoVenta, "0.0000")
  1162. txtDiasAcumuladosVenta.Text = Format(V_txtDiasAcumuladosVenta, "0.0000")
  1163. txtInteresAcumuladoVenta.Text = Format(V_txtInteresAcumuladoVenta, "0.0000")
  1164. txtPorcentajeInteresAcumuladoVenta.Text = CStr(Format(V_txtPorcentajeInteresAcumuladoVenta, "0.0000")) + "%"
  1165. txtPrecioSucioVenta.Text = Format(V_txtPrecioSucioVenta, "0.0000")
  1166. txtValorTransadoVenta.Text = Format(V_txtValorTransadoVenta, "0.0000")
  1167. txtComisionVentaCasa.Text = Format(V_txtComisionVentaCasa, "0.0000")
  1168. txtComisionVentaBolsa.Text = Format(V_txtComisionVentaBolsa, "0.0000")
  1169. txtYTMAlVencimientoComisionVenta.Text = CStr(Format(V_txtYTMAlVencimientoComisionVenta, "0.0000") * 100) + "%"
  1170. txtMontoARecibir.Text = Format(V_txtMontoARecibir, "0.0000")
  1171. txtCuponesRecibidos.Text = Format(V_txtCuponesRecibidos, "0.0000")
  1172. txtComisionVentaCasa.Text = Format(V_txtComisionVentaCasa, "0.0000")
  1173. txtComisionVentaBolsa.Text = Format(V_txtComisionVentaBolsa, "0.0000")
  1174. End If
  1175. CorrelativoSinBD()
  1176. End Sub
  1177. Function CalcularComision(ByVal Porcentaje As Double, ByVal VTransado As Double)
  1178. Return Porcentaje * VTransado
  1179. End Function
  1180. Private Sub RefrescarClaseEntidad()
  1181. ControlUltimaFechaCuponCompra()
  1182. ControlSiguienteFechaCuponCompra()
  1183. ControlFechaLiquidacionCompra()
  1184. ControlFechaVencimientoCompra()
  1185. ControlAnioBaseCompra()
  1186. ControlUltimaFechaCuponCompra()
  1187. ControlSiguienteFechaCuponCompra()
  1188. ControlFechaLiquidacionCompra()
  1189. ControlFechaVencimientoCompra()
  1190. ControlAnioBaseCompra()
  1191. End Sub
  1192. Private Sub ControlPeriodosCompra()
  1193. Dim valor As String
  1194. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  1195. If Me.cboPeriodosC.SelectedIndex = -1 Then
  1196. valor = ""
  1197. Else
  1198. If (String.IsNullOrEmpty(Me.cboPeriodosC.SelectedValue)) Then
  1199. valor = String.Empty
  1200. Else
  1201. valor = Me.cboPeriodosC.SelectedValue
  1202. End If
  1203. End If
  1204. oCEPrincipal.PeriodicidadCompra = valor
  1205. End If
  1206. End Sub
  1207. Function FechaTipo(ByVal ultimafecha As DateTime, ByVal frecuencia As Integer)
  1208. Dim periodos As Integer = 0
  1209. Dim Fecha As Date
  1210. If frecuencia = 1 Then
  1211. periodos = 12
  1212. ElseIf frecuencia = 2 Then
  1213. periodos = 6
  1214. ElseIf frecuencia = 4 Then
  1215. periodos = 3
  1216. ElseIf frecuencia = 12 Then
  1217. periodos = 1
  1218. End If
  1219. Fecha = ultimafecha.AddMonths(periodos)
  1220. Return Fecha
  1221. End Function
  1222. Private Sub ControlUltimaFechaCuponCompra()
  1223. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  1224. Me.oCEPrincipal.UltimaFechaCuponCompra = dtpUltimaFechaCuponCompra.Value.Date
  1225. End If
  1226. End Sub
  1227. Private Sub ControlSiguienteFechaCuponCompra()
  1228. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  1229. Me.oCEPrincipal.SiguienteFechaCuponCompra = dtpSiguienteFechaCuponCompra.Value.Date
  1230. End If
  1231. End Sub
  1232. Private Sub ControlFechaLiquidacionCompra()
  1233. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  1234. Me.oCEPrincipal.FechaLiquidacionCompra = dtpFechaLiquidacionCompra.Value.Date
  1235. End If
  1236. End Sub
  1237. Private Sub ControlFechaVencimientoCompra()
  1238. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  1239. Me.oCEPrincipal.FechaVencimientoCompra = dtpFechaVencimientoCompra.Value.Date
  1240. End If
  1241. End Sub
  1242. Private Sub ControlAnioBaseCompra()
  1243. Dim valor As Integer
  1244. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  1245. valor = cboAnioBaseC.SelectedItem
  1246. Me.oCEPrincipal.DiasBaseCompra = valor
  1247. End If
  1248. End Sub
  1249. Private Sub txtValorNominalCompra_LostFocus(sender As Object, e As EventArgs) Handles txtValorNominalCompra.LostFocus
  1250. End Sub
  1251. Private Sub txtPorcentajeCuponCompra_LostFocus(sender As Object, e As EventArgs) Handles txtPorcentajeCuponCompra.LostFocus
  1252. End Sub
  1253. Private Sub txtPrecioAlVencimientoCompra_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoCompra.LostFocus
  1254. End Sub
  1255. Private Sub txtPrecioCompra_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioCompra.LostFocus
  1256. End Sub
  1257. Private Sub txtCostoTransferenciaCompra_LostFocus(sender As Object, e As EventArgs) Handles txtCostoTransferenciaCompra.LostFocus
  1258. End Sub
  1259. Private Sub dtpSiguienteFechaCuponVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpSiguienteFechaCuponVenta.ValueChanged
  1260. Formato()
  1261. Calculos()
  1262. ValidacionErrores()
  1263. End Sub
  1264. Private Sub txtCostoTransferenciaVenta_TextChanged(sender As Object, e As EventArgs)
  1265. End Sub
  1266. Private Sub dgvImpuestosYComisiones_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs)
  1267. End Sub
  1268. Private Sub dgvImpuestosYComisiones_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellContentClick
  1269. Formato()
  1270. End Sub
  1271. Private Sub dgvImpuestosYComisiones_UserDeletedRow(sender As Object, e As DataGridViewRowEventArgs)
  1272. oCEPrincipal.ImpuestosYComisiones.AcceptChanges()
  1273. End Sub
  1274. Private Sub PrepararTablaIngresos()
  1275. Dim CantidadColumnas As Integer = dgvIngresos.ColumnCount
  1276. If CantidadColumnas = 0 Then
  1277. Dim oDataGridViewTextBoxColumn As DataGridViewTextBoxColumn
  1278. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1279. oDataGridViewTextBoxColumn.Name = "CodInv"
  1280. oDataGridViewTextBoxColumn.DataPropertyName = "CodInv"
  1281. oDataGridViewTextBoxColumn.HeaderText = "Código Inversión"
  1282. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  1283. oDataGridViewTextBoxColumn.Visible = False
  1284. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1285. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1286. oDataGridViewTextBoxColumn.Name = "NumCupon"
  1287. oDataGridViewTextBoxColumn.DataPropertyName = "NumCupon"
  1288. oDataGridViewTextBoxColumn.HeaderText = "No. Cupón"
  1289. oDataGridViewTextBoxColumn.ValueType = GetType(Integer)
  1290. oDataGridViewTextBoxColumn.Visible = False
  1291. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1292. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1293. oDataGridViewTextBoxColumn.Name = "Correlativo"
  1294. oDataGridViewTextBoxColumn.DataPropertyName = "Correlativo"
  1295. oDataGridViewTextBoxColumn.HeaderText = "No. Cupón"
  1296. oDataGridViewTextBoxColumn.ValueType = GetType(Integer)
  1297. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1298. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1299. oDataGridViewTextBoxColumn.Name = "FechaCupon"
  1300. oDataGridViewTextBoxColumn.DataPropertyName = "FechaCupon"
  1301. oDataGridViewTextBoxColumn.HeaderText = "Fecha Cupón"
  1302. oDataGridViewTextBoxColumn.ValueType = GetType(Date)
  1303. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1304. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1305. oDataGridViewTextBoxColumn.Name = "Dias"
  1306. oDataGridViewTextBoxColumn.DataPropertyName = "Dias"
  1307. oDataGridViewTextBoxColumn.HeaderText = "Dias "
  1308. oDataGridViewTextBoxColumn.ValueType = GetType(Integer)
  1309. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1310. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1311. oDataGridViewTextBoxColumn.Name = "Ingreso"
  1312. oDataGridViewTextBoxColumn.DataPropertyName = "Ingreso"
  1313. oDataGridViewTextBoxColumn.HeaderText = "Ingreso"
  1314. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  1315. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  1316. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1317. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1318. oDataGridViewTextBoxColumn.Name = "PorcentajeImpuesto"
  1319. oDataGridViewTextBoxColumn.DataPropertyName = "PorcImpuesto"
  1320. oDataGridViewTextBoxColumn.HeaderText = "% Impuesto"
  1321. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  1322. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  1323. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1324. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1325. oDataGridViewTextBoxColumn.Name = "MontoImpuesto"
  1326. oDataGridViewTextBoxColumn.DataPropertyName = "MontoImpuesto"
  1327. oDataGridViewTextBoxColumn.HeaderText = "Impuesto"
  1328. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  1329. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  1330. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1331. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1332. oDataGridViewTextBoxColumn.Name = "Liquido"
  1333. oDataGridViewTextBoxColumn.DataPropertyName = "Liquido"
  1334. oDataGridViewTextBoxColumn.HeaderText = "Liquido"
  1335. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  1336. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  1337. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1338. End If
  1339. End Sub
  1340. Private Sub txtValorNominalVenta_LostFocus(sender As Object, e As EventArgs) Handles txtValorNominalVenta.LostFocus
  1341. End Sub
  1342. Private Sub txtPorcentajeCuponVenta_LostFocus(sender As Object, e As EventArgs) Handles txtPorcentajeCuponVenta.LostFocus
  1343. End Sub
  1344. Private Sub txtPrecioAlVencimientoVenta_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoVenta.LostFocus
  1345. End Sub
  1346. Private Sub txtPrecioVenta_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioVenta.LostFocus
  1347. End Sub
  1348. Private Sub dgvIngresos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
  1349. End Sub
  1350. Private Sub dgvIngresos_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) Handles dgvIngresos.CellBeginEdit
  1351. End Sub
  1352. Private Sub dgvIngresos_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellEndEdit
  1353. Dim Tabla As String = Instrumento()
  1354. If Not Tabla = "TIT" Then
  1355. CalculoIngresosBONO()
  1356. End If
  1357. End Sub
  1358. Private Sub dgvIngresos_UserDeletedRow(sender As Object, e As DataGridViewRowEventArgs) Handles dgvIngresos.UserDeletedRow
  1359. oCEPrincipal.Ingresos.AcceptChanges()
  1360. End Sub
  1361. Private Sub txtValorNominal_Op_TextChanged(sender As Object, e As EventArgs) Handles txtValorNominal_Op.TextChanged
  1362. End Sub
  1363. Private Sub LLenarResultadosOperacion()
  1364. Dim FechaCompra = dtpFechaLiquidacionCompra.Value
  1365. Dim FechaVenta = dtpFechaLiquidacionVenta.Value
  1366. Dim Dias As Integer = Operaciones.Dias(FechaCompra, FechaVenta, IndexBaseC)
  1367. txtValorNominal_Op.Text = Operaciones.ConvertirDecimal(txtValorNominalCompra.Text.ToString)
  1368. txtPlazo_Op.Text = Operaciones.ConvertirDecimal(PlazoOperacion().ToString)
  1369. txtPrecioCompra_Op.Text = Operaciones.ConvertirDecimal(txtPrecioCompra.Text.ToString)
  1370. txtPrecioVenta_Op.Text = Operaciones.ConvertirDecimal(txtPrecioVenta.Text.ToString)
  1371. txtGananciaPerdidaCapital_Op.Text = Operaciones.ConvertirDecimal(GananciaPerdida().ToString)
  1372. txtIngresosPorIntereses_Op.Text = Operaciones.ConvertirDecimal(IngresosInteres().ToString)
  1373. txtCostosTotales_Op.Text = Operaciones.ConvertirDecimal(CostosTotales().ToString)
  1374. txtGananciaPerdidaTotal_Op.Text = Operaciones.ConvertirDecimal(MontoGananciaPerdida().ToString)
  1375. txtRendimientoGananciaPerdida_Op.Text = Operaciones.ConvertirDecimal(RendimientoGananciaPerdida(Dias, FechaCompra, FechaVenta, IndexBaseC).ToString)
  1376. txtRendimientoIntereses_Op.Text = Operaciones.ConvertirDecimal(RendimientoInteres(Dias, FechaCompra, FechaVenta, IndexBaseC).ToString)
  1377. txtRendimientoAntesISR_Op.Text = Operaciones.ConvertirDecimal(RendimientoNeto(Dias, FechaCompra, FechaVenta, IndexBaseC).ToString)
  1378. txtRendimientoDespuesISR_Op.Text = Operaciones.ConvertirDecimal(RendimientoNetoDespues(Dias, FechaCompra, FechaVenta, IndexBaseC).ToString)
  1379. End Sub
  1380. Private Function PlazoOperacion()
  1381. Dim FechaVenta As Date = dtpFechaLiquidacionVenta.Value
  1382. Dim FechaCompra As Date = dtpFechaLiquidacionCompra.Value
  1383. Dim Dias = Operaciones.Dias(FechaCompra, FechaVenta, IndexBaseC)
  1384. Return Dias
  1385. End Function
  1386. Private Function GananciaPerdida()
  1387. Dim ValorTrasadoVenta = txtValorTransadoVenta.Text
  1388. Dim ValorTrasadoCompra = txtValorTransadoCompra.Text
  1389. Dim Total = ValorTrasadoVenta - ValorTrasadoCompra
  1390. Return Total
  1391. End Function
  1392. Private Function IngresosInteres()
  1393. Dim Registros = dgvIngresos.Rows.Count
  1394. Dim Suma As Double = 0.0
  1395. Registros = Registros - 2
  1396. For i As Integer = 0 To Registros
  1397. Suma = Suma + Double.Parse(dgvIngresos.Item(4, i).Value)
  1398. Next
  1399. Dim InteresAcumulado = txtInteresAcumuladoVenta.Text
  1400. Return (Suma + InteresAcumulado)
  1401. End Function
  1402. Private Function CostosTotales()
  1403. Dim ComisionCompraCasa = txtComisionCompraCasa.Text
  1404. Dim ComisionVentaCasa = txtComisionVentaCasa.Text
  1405. Dim ComisionCompraBolsa = txtComisionCompraBolsa.Text
  1406. Dim ComisionVentaBolsa = txtComisionVentaBolsa.Text
  1407. Dim CostoTransferenciaCompra = txtCostoTransferenciaCompra.Text
  1408. If (Double.TryParse(ComisionCompraCasa, Nothing) And Double.TryParse(ComisionCompraBolsa, Nothing) And Double.TryParse(CostoTransferenciaCompra, Nothing) And Double.TryParse(ComisionCompraBolsa, Nothing) And Double.TryParse(ComisionVentaBolsa, Nothing)) Then
  1409. Dim Total = (CDec(ComisionCompraCasa) + CDec(ComisionCompraBolsa) + CDec(CostoTransferenciaCompra) + CDec(ComisionVentaCasa) + CDec(ComisionVentaBolsa)) * -1
  1410. Return Total
  1411. End If
  1412. Return "0"
  1413. End Function
  1414. Private Function MontoGananciaPerdida()
  1415. Dim GananciaPerdida = txtGananciaPerdidaCapital_Op.Text
  1416. Dim CostosTotales = txtCostosTotales_Op.Text
  1417. Dim IngresoInteres = txtIngresosPorIntereses_Op.Text
  1418. Dim Total = CDec(GananciaPerdida) + CDec(CostosTotales) + txtIngresosPorIntereses_Op.Text
  1419. Return Total
  1420. End Function
  1421. Private Function RendimientoGananciaPerdida(ByVal Dias As Integer, ByVal Fecha1 As Date, ByVal Fecha2 As Date, ByVal IndexBase As Integer)
  1422. Dim GananciaCapital = txtGananciaPerdidaCapital_Op.Text
  1423. Dim ValorNominal = txtValorNominal_Op.Text
  1424. Dim Valor As Double = 0
  1425. If (IndexBase = 0) Then
  1426. Valor = GananciaCapital / ValorNominal * 360 / Dias
  1427. Return (Valor * 100).ToString() + "%"
  1428. ElseIf (IndexBase = 1) Then
  1429. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1430. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1431. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1432. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1433. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1434. PrOpc1 = GananciaCapital / ValorNominal * 366 / DiasPrimeraFecha
  1435. PrOpc2 = GananciaCapital / ValorNominal * 365 / DiasSegundaFecha
  1436. Valor = PrOpc1 + PrOpc2
  1437. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1438. Valor = GananciaCapital / ValorNominal * 365 / DiasSegundaFecha
  1439. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1440. Valor = GananciaCapital / ValorNominal * 366 / DiasPrimeraFecha
  1441. Else
  1442. Valor = 0
  1443. End If
  1444. Return (Valor * 100).ToString() + "%"
  1445. ElseIf (IndexBase = 2) Then
  1446. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1447. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1448. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
  1449. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
  1450. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1451. PrOpc1 = GananciaCapital / ValorNominal * 366 / DiasPrimeraFecha
  1452. PrOpc2 = GananciaCapital / ValorNominal * 365 / DiasSegundaFecha
  1453. Valor = PrOpc1 + PrOpc2
  1454. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1455. Valor = GananciaCapital / ValorNominal * 365 / DiasSegundaFecha
  1456. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1457. Valor = GananciaCapital / ValorNominal * 366 / DiasPrimeraFecha
  1458. Else
  1459. Valor = 0
  1460. End If
  1461. Return (Valor * 100).ToString() + "%"
  1462. Else
  1463. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1464. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1465. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1466. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1467. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1468. PrOpc1 = GananciaCapital / ValorNominal * 360 / DiasPrimeraFecha
  1469. PrOpc2 = GananciaCapital / ValorNominal * 360 / DiasSegundaFecha
  1470. Valor = PrOpc1 + PrOpc2
  1471. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1472. Valor = GananciaCapital / ValorNominal * 360 / DiasSegundaFecha
  1473. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1474. Valor = GananciaCapital / ValorNominal * 360 / DiasPrimeraFecha
  1475. Else
  1476. Valor = 0
  1477. End If
  1478. Return (Valor * 100).ToString() + "%"
  1479. End If
  1480. Return (Valor * 100).ToString() + "%"
  1481. End Function
  1482. Private Function RendimientoInteres(ByVal Dias As Integer, ByVal Fecha1 As Date, ByVal Fecha2 As Date, ByVal IndexBase As Integer)
  1483. Dim IngresosInteres = txtIngresosPorIntereses_Op.Text
  1484. Dim ValorNominal = txtValorNominal_Op.Text
  1485. Dim Valor As Double = 0
  1486. If (IndexBase = 0) Then
  1487. Valor = IngresosInteres / ValorNominal * 360 / Dias
  1488. Return (Valor * 100).ToString() + "%"
  1489. ElseIf (IndexBase = 1) Then
  1490. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1491. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1492. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1493. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1494. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1495. PrOpc1 = IngresosInteres / ValorNominal * 366 / DiasPrimeraFecha
  1496. PrOpc2 = IngresosInteres / ValorNominal * 365 / DiasSegundaFecha
  1497. Valor = PrOpc1 + PrOpc2
  1498. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1499. Valor = IngresosInteres / ValorNominal * 365 / DiasSegundaFecha
  1500. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1501. Valor = IngresosInteres / ValorNominal * 366 / DiasPrimeraFecha
  1502. Else
  1503. Valor = 0
  1504. End If
  1505. Return (Valor * 100).ToString() + "%"
  1506. ElseIf (IndexBase = 2) Then
  1507. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1508. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1509. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
  1510. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
  1511. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1512. PrOpc1 = IngresosInteres / ValorNominal * 366 / DiasPrimeraFecha
  1513. PrOpc2 = IngresosInteres / ValorNominal * 365 / DiasSegundaFecha
  1514. Valor = PrOpc1 + PrOpc2
  1515. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1516. Valor = IngresosInteres / ValorNominal * 365 / DiasSegundaFecha
  1517. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1518. Valor = IngresosInteres / ValorNominal * 366 / DiasPrimeraFecha
  1519. Else
  1520. Valor = 0
  1521. End If
  1522. Return (Valor * 100).ToString() + "%"
  1523. Else
  1524. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1525. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1526. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1527. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1528. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1529. PrOpc1 = IngresosInteres / ValorNominal * 360 / DiasPrimeraFecha
  1530. PrOpc2 = IngresosInteres / ValorNominal * 360 / DiasSegundaFecha
  1531. Valor = PrOpc1 + PrOpc2
  1532. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1533. Valor = IngresosInteres / ValorNominal * 360 / DiasSegundaFecha
  1534. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1535. Valor = IngresosInteres / ValorNominal * 360 / DiasPrimeraFecha
  1536. Else
  1537. Valor = 0
  1538. End If
  1539. Return (Valor * 100).ToString() + "%"
  1540. End If
  1541. End Function
  1542. Private Function RendimientoNeto(ByVal Dias As Integer, ByVal Fecha1 As Date, ByVal Fecha2 As Date, ByVal IndexBase As Integer)
  1543. Dim MontoGananciaPerdidaTotal = txtGananciaPerdidaTotal_Op.Text
  1544. Dim ValorNominal = txtValorNominal_Op.Text
  1545. Dim Valor As Double = 0
  1546. If (IndexBase = 0) Then
  1547. Valor = MontoGananciaPerdidaTotal / ValorNominal * 360 / Dias
  1548. Return (Valor * 100).ToString() + "%"
  1549. ElseIf (IndexBase = 1) Then
  1550. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1551. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1552. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1553. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1554. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1555. PrOpc1 = MontoGananciaPerdidaTotal / ValorNominal * 366 / DiasPrimeraFecha
  1556. PrOpc2 = MontoGananciaPerdidaTotal / ValorNominal * 365 / DiasSegundaFecha
  1557. Valor = PrOpc1 + PrOpc2
  1558. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1559. Valor = MontoGananciaPerdidaTotal / ValorNominal * 365 / DiasSegundaFecha
  1560. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1561. Valor = MontoGananciaPerdidaTotal / ValorNominal * 366 / DiasPrimeraFecha
  1562. Else
  1563. Valor = 0
  1564. End If
  1565. Return (Valor * 100).ToString() + "%"
  1566. ElseIf (IndexBase = 2) Then
  1567. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1568. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1569. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
  1570. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
  1571. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1572. PrOpc1 = MontoGananciaPerdidaTotal / ValorNominal * 366 / DiasPrimeraFecha
  1573. PrOpc2 = MontoGananciaPerdidaTotal / ValorNominal * 365 / DiasSegundaFecha
  1574. Valor = PrOpc1 + PrOpc2
  1575. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1576. Valor = MontoGananciaPerdidaTotal / ValorNominal * 365 / DiasSegundaFecha
  1577. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1578. Valor = MontoGananciaPerdidaTotal / ValorNominal * 366 / DiasPrimeraFecha
  1579. Else
  1580. Valor = 0
  1581. End If
  1582. Return (Valor * 100).ToString() + "%"
  1583. Else
  1584. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1585. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1586. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1587. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1588. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1589. PrOpc1 = MontoGananciaPerdidaTotal / ValorNominal * 360 / DiasPrimeraFecha
  1590. PrOpc2 = MontoGananciaPerdidaTotal / ValorNominal * 360 / DiasSegundaFecha
  1591. Valor = PrOpc1 + PrOpc2
  1592. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1593. Valor = MontoGananciaPerdidaTotal / ValorNominal * 360 / DiasSegundaFecha
  1594. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1595. Valor = MontoGananciaPerdidaTotal / ValorNominal * 360 / DiasPrimeraFecha
  1596. Else
  1597. Valor = 0
  1598. End If
  1599. Return (Valor * 100).ToString() + "%"
  1600. End If
  1601. End Function
  1602. Private Function Recibido()
  1603. Dim Registros = dgvIngresos.Rows.Count
  1604. Dim Suma As Double = 0.0
  1605. Registros = Registros - 1
  1606. For i As Integer = 0 To Registros
  1607. If (Not String.IsNullOrEmpty(dgvIngresos.Rows(i).Cells("Ingreso").Value)) Then
  1608. Suma = Suma + Double.Parse(dgvIngresos.Rows(i).Cells("Ingreso").Value)
  1609. End If
  1610. Next
  1611. Return Suma
  1612. End Function
  1613. Private Function RendimientoNetoDespues(ByVal Dias As Integer, ByVal Fecha1 As Date, ByVal Fecha2 As Date, ByVal IndexBase As Integer)
  1614. Dim Registros = dgvIngresos.Rows.Count
  1615. Dim Suma As Double = 0.0
  1616. Registros = Registros - 1
  1617. For i As Integer = 0 To Registros
  1618. If (Not String.IsNullOrEmpty(dgvIngresos.Rows(i).Cells("MontoImpuesto").Value)) Then
  1619. Suma = Suma + Double.Parse(dgvIngresos.Rows(i).Cells("MontoImpuesto").Value)
  1620. End If
  1621. Next
  1622. Dim MontoGananciaTotal = txtGananciaPerdidaTotal_Op.Text
  1623. Dim Impuesto = Suma
  1624. Dim ValorNominal = txtValorNominal_Op.Text
  1625. Dim Valor As Double = 0
  1626. If (IndexBase = 0) Then
  1627. Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 360 / Dias
  1628. Return (Valor * 100).ToString() + "%"
  1629. ElseIf (IndexBase = 1) Then
  1630. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1631. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1632. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1633. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1634. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1635. PrOpc1 = (MontoGananciaTotal - Impuesto) / ValorNominal * 366 / DiasPrimeraFecha
  1636. PrOpc2 = (MontoGananciaTotal - Impuesto) / ValorNominal * 365 / DiasSegundaFecha
  1637. Valor = PrOpc1 + PrOpc2
  1638. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1639. Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 365 / DiasSegundaFecha
  1640. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1641. Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 366 / DiasPrimeraFecha
  1642. Else
  1643. Valor = 0
  1644. End If
  1645. Return (Valor * 100).ToString() + "%"
  1646. ElseIf (IndexBase = 2) Then
  1647. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1648. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1649. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
  1650. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
  1651. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1652. PrOpc1 = (MontoGananciaTotal - Impuesto) / ValorNominal * 366 / DiasPrimeraFecha
  1653. PrOpc2 = (MontoGananciaTotal - Impuesto) / ValorNominal * 365 / DiasSegundaFecha
  1654. Valor = PrOpc1 + PrOpc2
  1655. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1656. Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 366 / DiasPrimeraFecha
  1657. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1658. Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 365 / DiasSegundaFecha
  1659. Else
  1660. Valor = 0
  1661. End If
  1662. Return (Valor * 100).ToString() + "%"
  1663. Else
  1664. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1665. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1666. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1667. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1668. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1669. PrOpc1 = (MontoGananciaTotal - Impuesto) / ValorNominal * 360 / DiasPrimeraFecha
  1670. PrOpc2 = (MontoGananciaTotal - Impuesto) / ValorNominal * 360 / DiasSegundaFecha
  1671. Valor = PrOpc1 + PrOpc2
  1672. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1673. Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 360 / DiasSegundaFecha
  1674. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1675. Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 360 / DiasPrimeraFecha
  1676. Else
  1677. Valor = 0
  1678. End If
  1679. Return (Valor * 100).ToString() + "%"
  1680. End If
  1681. End Function
  1682. Private Sub TabPage4_Click(sender As Object, e As EventArgs) Handles TabPage4.Click
  1683. End Sub
  1684. Private Sub TabPage1_Click(sender As Object, e As EventArgs) Handles TabPage1.Click
  1685. End Sub
  1686. Private Sub TabPage2_Click(sender As Object, e As EventArgs) Handles TbIngresos.Click
  1687. End Sub
  1688. Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
  1689. TipoTransaccion = "M"
  1690. btnAceptar.Text = "Modificar"
  1691. 'btnAccionComisiones.Text = "Modificar"
  1692. End Sub
  1693. Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
  1694. TipoTransaccion = "N"
  1695. btnAceptar.Text = "Nuevo"
  1696. End Sub
  1697. Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
  1698. TipoTransaccion = "B"
  1699. btnAceptar.Text = "Eliminar"
  1700. End Sub
  1701. Private Sub txtYTMAlVencimientoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtYTMAlVencimientoCompra.TextChanged
  1702. Calculos()
  1703. ValidacionErrores()
  1704. End Sub
  1705. Private Sub txtPorcentajeInteresAcumuladoVenta_TextChanged(sender As Object, e As EventArgs)
  1706. End Sub
  1707. Private Sub txtYTMAlVencimientoComisionCompra_TextChanged(sender As Object, e As EventArgs) Handles txtYTMAlVencimientoComisionCompra.TextChanged
  1708. End Sub
  1709. Private Sub txtValorNominalVenta_TextChanged(sender As Object, e As EventArgs) Handles txtValorNominalVenta.TextChanged
  1710. Calculos()
  1711. ValidacionErrores()
  1712. End Sub
  1713. Private Sub txtPorcentajeCuponVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeCuponVenta.TextChanged
  1714. Calculos()
  1715. ValidacionErrores()
  1716. End Sub
  1717. Private Sub txtPrecioAlVencimientoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoVenta.TextChanged
  1718. Calculos()
  1719. ValidacionErrores()
  1720. End Sub
  1721. Private Sub txtValorNominalCompra_TextChanged(sender As Object, e As EventArgs) Handles txtValorNominalCompra.TextChanged
  1722. Calculos()
  1723. ValidacionErrores()
  1724. End Sub
  1725. Private Sub txtPrecioSucioCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioSucioCompra.TextChanged
  1726. End Sub
  1727. Private Sub Button1_Click(sender As Object, e As EventArgs)
  1728. RefrescarValorControles()
  1729. End Sub
  1730. Private Sub txtPrecioVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioVenta.TextChanged
  1731. Calculos()
  1732. ValidacionErrores()
  1733. End Sub
  1734. Private Sub btnAccionIngreso_Click(sender As Object, e As EventArgs)
  1735. End Sub
  1736. Private Sub TabControl1_TabIndexChanged(sender As Object, e As EventArgs) Handles TabCampos.TabIndexChanged
  1737. Formato()
  1738. Formato()
  1739. End Sub
  1740. Private Sub dgvIngresos_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellClick
  1741. Index = e.RowIndex
  1742. PrepararCalculos()
  1743. Formato()
  1744. End Sub
  1745. Private Sub txtDiasAcumuladosCompra_TextChanged(sender As Object, e As EventArgs) Handles txtDiasAcumuladosCompra.TextChanged
  1746. End Sub
  1747. Private Sub TabControl1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TabCampos.SelectedIndexChanged
  1748. ValidacionErrores()
  1749. BotonQuitar()
  1750. If (dgvIngresos.Rows.Count < 2) Then
  1751. End If
  1752. If (TabCampos.SelectedIndex = 2) Or (TabCampos.SelectedIndex = 1) Then
  1753. LLenarResultadosOperacion()
  1754. End If
  1755. End Sub
  1756. Private Sub dtpUltimaFechaCuponVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpUltimaFechaCuponVenta.ValueChanged
  1757. Formato()
  1758. Calculos()
  1759. ValidacionErrores()
  1760. End Sub
  1761. Private Sub dtpFechaLiquidacionVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaLiquidacionVenta.ValueChanged
  1762. Formato()
  1763. Calculos()
  1764. ValidacionErrores()
  1765. End Sub
  1766. Private Sub txtYTMAlVencimientoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtYTMAlVencimientoVenta.TextChanged
  1767. Calculos()
  1768. ValidacionErrores()
  1769. End Sub
  1770. Private Sub btnAmortizacion_Click(sender As Object, e As EventArgs)
  1771. frmResultadoTitularizacion.Show()
  1772. End Sub
  1773. Function ColeccionIngresos(ByRef index As Integer)
  1774. Dim coleccion As New Collection
  1775. Dim NoCupon, Fecha, Ingreso, PorcImpuesto, Impuesto, Dias, Liquido As String
  1776. NoCupon = dgvIngresos.Rows(index).Cells("NumCupon").Value
  1777. Fecha = dgvIngresos.Rows(index).Cells("FechaCupon").Value
  1778. Dias = dgvIngresos.Rows(index).Cells("Dias").Value
  1779. Ingreso = dgvIngresos.Rows(index).Cells("Ingreso").Value
  1780. PorcImpuesto = dgvIngresos.Rows(index).Cells("PorcentajeImpuesto").Value
  1781. If Not PorcImpuesto Is Nothing Then
  1782. PorcImpuesto = CDec((PorcImpuesto.ToString().Trim("%")) / 100)
  1783. End If
  1784. Impuesto = dgvIngresos.Rows(index).Cells("MontoImpuesto").Value
  1785. Liquido = dgvIngresos.Rows(index).Cells("Liquido").Value
  1786. coleccion.Add(NoCupon)
  1787. coleccion.Add(Fecha)
  1788. coleccion.Add(Dias)
  1789. coleccion.Add(Ingreso)
  1790. coleccion.Add(PorcImpuesto)
  1791. coleccion.Add(Impuesto)
  1792. coleccion.Add(Liquido)
  1793. Return coleccion
  1794. End Function
  1795. Function Instrumento()
  1796. Dim codigo As String = Variables.Codigo
  1797. Dim Tabla As String = String.Empty
  1798. If codigo.IndexOf("TIT") > -1 Then
  1799. Tabla = "TIT"
  1800. ElseIf codigo.IndexOf("EURB") > -1 Then
  1801. Tabla = "EURB"
  1802. ElseIf codigo.IndexOf("BONO") > -1 Then
  1803. Tabla = "BONO"
  1804. ElseIf codigo.IndexOf("CINV") > -1 Then
  1805. Tabla = "CINV"
  1806. End If
  1807. Return Tabla
  1808. End Function
  1809. Function ModificarIngreso()
  1810. Dim i As Integer = 0
  1811. Dim Cantidad As Integer = dgvIngresos.Rows.Count - 2
  1812. Dim Diccionario As New Dictionary(Of Integer, Collection)
  1813. While i <= Cantidad
  1814. Dim coleccion = ColeccionIngresos(i)
  1815. Diccionario.Add(i, coleccion)
  1816. i += 1
  1817. End While
  1818. Return Diccionario
  1819. End Function
  1820. Sub CargarIngresos()
  1821. Dim codigo As String = Variables.Codigo
  1822. Dim dr = BonosConsulta.CargarIngreso(codigo, Instrumento)
  1823. While dr.Read
  1824. Dim Porc = dr("PorcImpuesto")
  1825. If String.IsNullOrEmpty(Porc.ToString) Then
  1826. Porc = "0.0%"
  1827. Else
  1828. Porc = (Porc * 100).ToString + "%"
  1829. End If
  1830. dgvIngresos.Rows.Add("", dr("NumCupon"), "", dr("FechaCupon"), dr("Dias"), dr("Ingreso"), Porc, dr("MontoImpuesto"), dr("Liquido"))
  1831. End While
  1832. End Sub
  1833. Private Sub txtComisionPorCompraCasa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorCompraCasa.TextChanged
  1834. Calculos()
  1835. ValidacionErrores()
  1836. End Sub
  1837. Private Sub txtComisionPorBolsaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorBolsaCompra.TextChanged
  1838. Calculos()
  1839. ValidacionErrores()
  1840. End Sub
  1841. Private Sub txtComisionPorVentaCasa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorVentaCasa.TextChanged
  1842. Calculos()
  1843. ValidacionErrores()
  1844. End Sub
  1845. Private Sub txtComisionPorBolsaVenta_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorBolsaVenta.TextChanged
  1846. Calculos()
  1847. ValidacionErrores()
  1848. End Sub
  1849. Private Sub txtMontoARecibir_TextChanged(sender As Object, e As EventArgs) Handles txtMontoARecibir.TextChanged
  1850. Calculos()
  1851. End Sub
  1852. Private Sub txtCostosTotales_Op_TextChanged(sender As Object, e As EventArgs) Handles txtCostosTotales_Op.TextChanged
  1853. End Sub
  1854. Private Sub txtRendimientoDespuesISR_Op_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoDespuesISR_Op.TextChanged
  1855. End Sub
  1856. Private Sub txtPrecioSucioVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioSucioVenta.TextChanged
  1857. End Sub
  1858. Private Sub txtGananciaPerdidaCapital_Op_TextChanged(sender As Object, e As EventArgs) Handles txtGananciaPerdidaCapital_Op.TextChanged
  1859. End Sub
  1860. Private Sub txtValorNominalCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtValorNominalCompra.KeyPress
  1861. If String.IsNullOrEmpty(txtValorNominalCompra.Text) Then
  1862. If e.KeyChar = "." Then
  1863. txtValorNominalCompra.Text = "0"
  1864. Exit Sub
  1865. End If
  1866. End If
  1867. If (Not txtValorNominalCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1868. Operaciones.ValidarEntrada(sender, e, True)
  1869. Else
  1870. Operaciones.ValidarEntrada(sender, e, False)
  1871. End If
  1872. End Sub
  1873. Private Sub txtValorNominalVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtValorNominalVenta.KeyPress
  1874. If String.IsNullOrEmpty(txtValorNominalVenta.Text) Then
  1875. If e.KeyChar = "." Then
  1876. txtValorNominalVenta.Text = "0"
  1877. Exit Sub
  1878. End If
  1879. End If
  1880. If (Not txtValorNominalVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1881. Operaciones.ValidarEntrada(sender, e, True)
  1882. Else
  1883. Operaciones.ValidarEntrada(sender, e, False)
  1884. End If
  1885. End Sub
  1886. Private Sub txtPorcentajeCuponCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeCuponCompra.KeyPress
  1887. If String.IsNullOrEmpty(txtPorcentajeCuponCompra.Text) Then
  1888. If e.KeyChar = "." Then
  1889. txtPorcentajeCuponCompra.Text = "0"
  1890. Exit Sub
  1891. End If
  1892. End If
  1893. If (Not txtPorcentajeCuponCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1894. Operaciones.ValidarEntrada(sender, e, True)
  1895. Else
  1896. Operaciones.ValidarEntrada(sender, e, False)
  1897. End If
  1898. End Sub
  1899. Private Sub txtPorcentajeCuponVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeCuponVenta.KeyPress
  1900. If String.IsNullOrEmpty(txtPorcentajeCuponVenta.Text) Then
  1901. If e.KeyChar = "." Then
  1902. txtPorcentajeCuponVenta.Text = "0"
  1903. Exit Sub
  1904. End If
  1905. End If
  1906. If (Not txtPorcentajeCuponVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1907. Operaciones.ValidarEntrada(sender, e, True)
  1908. Else
  1909. Operaciones.ValidarEntrada(sender, e, False)
  1910. End If
  1911. End Sub
  1912. Private Sub txtYTMAlVencimientoCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtYTMAlVencimientoCompra.KeyPress
  1913. If String.IsNullOrEmpty(txtYTMAlVencimientoCompra.Text) Then
  1914. If e.KeyChar = "." Then
  1915. txtYTMAlVencimientoCompra.Text = "0"
  1916. Exit Sub
  1917. End If
  1918. End If
  1919. If (Not txtYTMAlVencimientoCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1920. Operaciones.ValidarEntrada(sender, e, True)
  1921. Else
  1922. Operaciones.ValidarEntrada(sender, e, False)
  1923. End If
  1924. End Sub
  1925. Private Sub txtYTMAlVencimientoVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtYTMAlVencimientoVenta.KeyPress
  1926. If String.IsNullOrEmpty(txtYTMAlVencimientoVenta.Text) Then
  1927. If e.KeyChar = "." Then
  1928. txtYTMAlVencimientoVenta.Text = "0"
  1929. Exit Sub
  1930. End If
  1931. End If
  1932. If (Not txtYTMAlVencimientoVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1933. Operaciones.ValidarEntrada(sender, e, True)
  1934. Else
  1935. Operaciones.ValidarEntrada(sender, e, False)
  1936. End If
  1937. End Sub
  1938. Private Sub txtPrecioAlVencimientoCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioAlVencimientoCompra.KeyPress
  1939. If String.IsNullOrEmpty(txtPrecioAlVencimientoCompra.Text) Then
  1940. If e.KeyChar = "." Then
  1941. txtPrecioAlVencimientoCompra.Text = "0"
  1942. Exit Sub
  1943. End If
  1944. End If
  1945. If (Not txtPrecioAlVencimientoCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1946. Operaciones.ValidarEntrada(sender, e, True)
  1947. Else
  1948. Operaciones.ValidarEntrada(sender, e, False)
  1949. End If
  1950. End Sub
  1951. Private Sub txtPrecioAlVencimientoVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioAlVencimientoVenta.KeyPress
  1952. If String.IsNullOrEmpty(txtPrecioAlVencimientoVenta.Text) Then
  1953. If e.KeyChar = "." Then
  1954. txtPrecioAlVencimientoVenta.Text = "0"
  1955. Exit Sub
  1956. End If
  1957. End If
  1958. If (Not txtPrecioAlVencimientoVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1959. Operaciones.ValidarEntrada(sender, e, True)
  1960. Else
  1961. Operaciones.ValidarEntrada(sender, e, False)
  1962. End If
  1963. End Sub
  1964. Private Sub txtPrecioCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioCompra.KeyPress
  1965. If String.IsNullOrEmpty(txtPrecioCompra.Text) Then
  1966. If e.KeyChar = "." Then
  1967. txtPrecioCompra.Text = "0"
  1968. Exit Sub
  1969. End If
  1970. End If
  1971. If (Not txtPrecioCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1972. Operaciones.ValidarEntrada(sender, e, True)
  1973. Else
  1974. Operaciones.ValidarEntrada(sender, e, False)
  1975. End If
  1976. End Sub
  1977. Private Sub txtPrecioVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioVenta.KeyPress
  1978. If String.IsNullOrEmpty(txtPrecioVenta.Text) Then
  1979. If e.KeyChar = "." Then
  1980. txtPrecioVenta.Text = "0"
  1981. Exit Sub
  1982. End If
  1983. End If
  1984. If (Not txtPrecioVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1985. Operaciones.ValidarEntrada(sender, e, True)
  1986. Else
  1987. Operaciones.ValidarEntrada(sender, e, False)
  1988. End If
  1989. End Sub
  1990. Private Sub txtComisionPorCompraCasa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorCompraCasa.KeyPress
  1991. If String.IsNullOrEmpty(txtComisionPorCompraCasa.Text) Then
  1992. If e.KeyChar = "." Then
  1993. txtComisionPorCompraCasa.Text = "0"
  1994. Exit Sub
  1995. End If
  1996. End If
  1997. If (Not txtComisionPorCompraCasa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1998. Operaciones.ValidarEntrada(sender, e, True)
  1999. Else
  2000. Operaciones.ValidarEntrada(sender, e, False)
  2001. End If
  2002. End Sub
  2003. Private Sub txtComisionPorVentaCasa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorVentaCasa.KeyPress
  2004. If String.IsNullOrEmpty(txtComisionPorVentaCasa.Text) Then
  2005. If e.KeyChar = "." Then
  2006. txtComisionPorVentaCasa.Text = "0"
  2007. Exit Sub
  2008. End If
  2009. End If
  2010. If (Not txtComisionPorVentaCasa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  2011. Operaciones.ValidarEntrada(sender, e, True)
  2012. Else
  2013. Operaciones.ValidarEntrada(sender, e, False)
  2014. End If
  2015. End Sub
  2016. Private Sub txtComisionPorBolsaCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorBolsaCompra.KeyPress
  2017. If String.IsNullOrEmpty(txtComisionPorBolsaCompra.Text) Then
  2018. If e.KeyChar = "." Then
  2019. txtComisionPorBolsaCompra.Text = "0"
  2020. Exit Sub
  2021. End If
  2022. End If
  2023. If (Not txtComisionPorBolsaCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  2024. Operaciones.ValidarEntrada(sender, e, True)
  2025. Else
  2026. Operaciones.ValidarEntrada(sender, e, False)
  2027. End If
  2028. End Sub
  2029. Private Sub txtComisionPorBolsaVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorBolsaVenta.KeyPress
  2030. If String.IsNullOrEmpty(txtComisionPorBolsaVenta.Text) Then
  2031. If e.KeyChar = "." Then
  2032. txtComisionPorBolsaVenta.Text = "0"
  2033. Exit Sub
  2034. End If
  2035. End If
  2036. If (Not txtComisionPorBolsaVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  2037. Operaciones.ValidarEntrada(sender, e, True)
  2038. Else
  2039. Operaciones.ValidarEntrada(sender, e, False)
  2040. End If
  2041. End Sub
  2042. Private Sub txtCostoTransferenciaCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtCostoTransferenciaCompra.KeyPress
  2043. If String.IsNullOrEmpty(txtCostoTransferenciaCompra.Text) Then
  2044. If e.KeyChar = "." Then
  2045. txtCostoTransferenciaCompra.Text = "0"
  2046. Exit Sub
  2047. End If
  2048. End If
  2049. If (Not txtCostoTransferenciaCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  2050. Operaciones.ValidarEntrada(sender, e, True)
  2051. Else
  2052. Operaciones.ValidarEntrada(sender, e, False)
  2053. End If
  2054. End Sub
  2055. Private Sub txtMontoARecibir_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtMontoARecibir.KeyPress
  2056. If String.IsNullOrEmpty(txtMontoARecibir.Text) Then
  2057. If e.KeyChar = "." Then
  2058. txtMontoARecibir.Text = "0"
  2059. Exit Sub
  2060. End If
  2061. End If
  2062. If (Not txtMontoARecibir.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  2063. Operaciones.ValidarEntrada(sender, e, True)
  2064. Else
  2065. Operaciones.ValidarEntrada(sender, e, False)
  2066. End If
  2067. End Sub
  2068. Private Sub txtPrecioCompra_Op_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioCompra_Op.TextChanged
  2069. End Sub
  2070. Private Sub txtPrecioVenta_Op_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioVenta_Op.TextChanged
  2071. End Sub
  2072. Private Sub txtInteresAcumuladoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtInteresAcumuladoCompra.TextChanged
  2073. End Sub
  2074. Sub AsignacionPeriodicidad()
  2075. Dim Periodicidad As String = cboPeriodosC.SelectedValue
  2076. If (Periodicidad = "M") Then
  2077. TipoPeriodicidad = 1
  2078. ElseIf (Periodicidad = "T") Then
  2079. TipoPeriodicidad = 3
  2080. ElseIf (Periodicidad = "S") Then
  2081. TipoPeriodicidad = 6
  2082. ElseIf (Periodicidad = "A") Then
  2083. TipoPeriodicidad = 12
  2084. End If
  2085. End Sub
  2086. Sub PrepararCalculos()
  2087. AsignacionPeriodicidad()
  2088. Dim Index = dgvIngresos.CurrentRow.Index
  2089. Dim IndexAnterior = Index - 1
  2090. Dim Respaldo As String = Format(dtpSiguienteFechaCuponCompra.Value, "dd/MM/yyyy")
  2091. Dim FechaSig = CDate(Respaldo)
  2092. Dim Fechaliq = dtpFechaLiquidacionCompra.Value
  2093. Dim FechaCupon, Dias, Ingreso, PorcentajeImpuesto, MontoImpuesto, Liquido
  2094. FechaCupon = dgvIngresos.Rows(Index).Cells("FechaCupon").Value
  2095. Dias = dgvIngresos.Rows(Index).Cells("Dias").Value
  2096. Ingreso = dgvIngresos.Rows(Index).Cells("Ingreso").Value
  2097. PorcentajeImpuesto = dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value
  2098. If (Not PorcentajeImpuesto Is Nothing) Then
  2099. PorcentajeImpuesto = CDec(PorcentajeImpuesto.ToString.Trim("%")) / 100
  2100. Else
  2101. PorcentajeImpuesto = "0.0%"
  2102. End If
  2103. MontoImpuesto = dgvIngresos.Rows(Index).Cells("MontoImpuesto").Value
  2104. Liquido = dgvIngresos.Rows(Index).Cells("Liquido").Value
  2105. If (String.IsNullOrEmpty(FechaCupon)) Then
  2106. If (Index = 0) Then
  2107. FechaCupon = FechaSig
  2108. Else
  2109. Dim FechaAnterior As Date = dgvIngresos.Rows(IndexAnterior).Cells("FechaCupon").Value
  2110. FechaCupon = Operaciones.Meses(TipoPeriodicidad, FechaAnterior, FechaSig)
  2111. End If
  2112. dgvIngresos.Rows(Index).Cells("FechaCupon").Value = FechaCupon
  2113. End If
  2114. If (String.IsNullOrEmpty(Dias)) Then
  2115. Dim Dia As Integer = 0
  2116. If (Index = 0) Then
  2117. Dia = Operaciones.DiasAcumulados(Fechaliq, FechaSig, IndexBaseC)
  2118. Else
  2119. Dim DiaAnterior As Date = dgvIngresos.Rows(IndexAnterior).Cells("FechaCupon").Value
  2120. Dim DiaActual = dgvIngresos.Rows(Index).Cells("FechaCupon").Value
  2121. Dia = Operaciones.DiasAcumulados(DiaAnterior, DiaActual, IndexBaseC)
  2122. End If
  2123. dgvIngresos.Rows(Index).Cells("Dias").Value = Dia
  2124. End If
  2125. If (String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("NumCupon").Value)) Then
  2126. dgvIngresos.Rows(Index).Cells("NumCupon").Value = Correlativo()
  2127. End If
  2128. If (String.IsNullOrEmpty(Ingreso)) Then
  2129. dgvIngresos.Rows(Index).Cells("Ingreso").Value = 0
  2130. End If
  2131. If (Index = 0) Then
  2132. If (String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value)) Then
  2133. dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value = "0.0%"
  2134. End If
  2135. Else
  2136. dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value = dgvIngresos.Rows(IndexAnterior).Cells("PorcentajeImpuesto").Value
  2137. End If
  2138. If dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value.ToString.IndexOf("%") = -1 Then
  2139. dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value = dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value.ToString + "%"
  2140. End If
  2141. If (String.IsNullOrEmpty(MontoImpuesto)) Then
  2142. dgvIngresos.Rows(Index).Cells("MontoImpuesto").Value = 0
  2143. End If
  2144. If (String.IsNullOrEmpty(Liquido)) Then
  2145. dgvIngresos.Rows(Index).Cells("Liquido").Value = 0
  2146. End If
  2147. CorrelativoSinBD()
  2148. End Sub
  2149. Function Correlativo()
  2150. Dim Index As Integer = 0
  2151. Dim IndexCantidad As Integer = dgvIngresos.Rows.Count - 2
  2152. Dim NumeroMayor As Integer = 0
  2153. While Index <= IndexCantidad
  2154. Dim Numero As Integer = dgvIngresos.Rows(Index).Cells("NumCupon").Value
  2155. If Numero > NumeroMayor Then
  2156. NumeroMayor = Numero
  2157. End If
  2158. Index += 1
  2159. End While
  2160. Return NumeroMayor + 1
  2161. End Function
  2162. Sub CorrelativoSinBD()
  2163. Dim Index As Integer = 0
  2164. Dim IndexCantidad As Integer = dgvIngresos.Rows.Count - 2
  2165. Dim NumeroMayor As Integer = 0
  2166. While Index <= IndexCantidad
  2167. dgvIngresos.Rows(Index).Cells("Correlativo").Value = Index + 1
  2168. Index += 1
  2169. End While
  2170. End Sub
  2171. Function PeriodoGracia()
  2172. Dim FechaEmision As Date = Variables.FechaEmisionTIT
  2173. Dim FechaPeriodoGracia As Date = FechaEmision
  2174. Dim CantidadPeriodoGracia As Integer = 0
  2175. Dim TipoPeriodoGracia As String = Variables.TipoPeriodoGracia
  2176. Dim CantidadPeriodo As String = Variables.CantidadPeriodo
  2177. If String.IsNullOrEmpty(CantidadPeriodo) Or CantidadPeriodo = "0" Then
  2178. Return False
  2179. Else
  2180. CantidadPeriodoGracia = CantidadPeriodo
  2181. End If
  2182. If TipoPeriodoGracia = "D" Or TipoPeriodoGracia = "M" Or TipoPeriodoGracia = "A" Then
  2183. If TipoPeriodoGracia = "D" Then
  2184. FechaPeriodoGracia = FechaEmision.AddDays(CantidadPeriodoGracia)
  2185. ElseIf TipoPeriodoGracia = "M" Then
  2186. FechaPeriodoGracia = FechaEmision.AddMonths(CantidadPeriodoGracia)
  2187. Else
  2188. FechaPeriodoGracia = FechaEmision.AddYears(CantidadPeriodoGracia)
  2189. End If
  2190. Return FechaPeriodoGracia
  2191. Else
  2192. Return False
  2193. End If
  2194. End Function
  2195. Function IngresosIntereses(ByVal ValorNominal As Double, ByVal PorcCupon As Double, ByVal Dias As Integer, ByVal Fecha1 As Date, Fecha2 As Date, ByVal IndexBase As Integer)
  2196. Dim Valor As Double = 0
  2197. If (IndexBase = 0) Then
  2198. Valor = ValorNominal * PorcCupon * Dias / 360
  2199. Return Valor
  2200. ElseIf (IndexBase = 1) Then
  2201. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  2202. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  2203. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  2204. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  2205. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2206. PrOpc1 = ValorNominal * PorcCupon * DiasPrimeraFecha / 366
  2207. PrOpc2 = ValorNominal * PorcCupon * DiasSegundaFecha / 365
  2208. Valor = PrOpc1 + PrOpc2
  2209. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2210. Valor = ValorNominal * PorcCupon * DiasSegundaFecha / 365
  2211. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  2212. Valor = ValorNominal * PorcCupon * DiasPrimeraFecha / 366
  2213. Else
  2214. Valor = 0
  2215. End If
  2216. Return Valor
  2217. ElseIf (IndexBase = 2) Then
  2218. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  2219. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  2220. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
  2221. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
  2222. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2223. PrOpc1 = ValorNominal * PorcCupon * DiasPrimeraFecha / 366
  2224. PrOpc2 = ValorNominal * PorcCupon * DiasSegundaFecha / 365
  2225. Valor = PrOpc1 + PrOpc2
  2226. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2227. Valor = ValorNominal * PorcCupon * DiasSegundaFecha / 365
  2228. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  2229. Valor = ValorNominal * PorcCupon * DiasPrimeraFecha / 366
  2230. Else
  2231. Valor = 0
  2232. End If
  2233. Return Valor
  2234. Else
  2235. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  2236. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  2237. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  2238. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  2239. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2240. PrOpc1 = ValorNominal * PorcCupon * DiasPrimeraFecha / 360
  2241. PrOpc2 = ValorNominal * PorcCupon * DiasSegundaFecha / 360
  2242. Valor = PrOpc1 + PrOpc2
  2243. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2244. Valor = ValorNominal * PorcCupon * DiasSegundaFecha / 360
  2245. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  2246. Valor = ValorNominal * PorcCupon * DiasPrimeraFecha / 360
  2247. Else
  2248. Valor = 0
  2249. End If
  2250. Return Valor
  2251. End If
  2252. Return Valor
  2253. End Function
  2254. Function IngresosInteresesTIT(ByVal ValorSaldo As Double, ByVal PorcCupon As Double, ByVal Dias As Integer, ByVal PrimerosDias As Integer, ByVal RestantesDias As Integer, ByVal IndexBase As Integer)
  2255. Dim Valor As Double = 0
  2256. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  2257. DiasPrimeraFecha = PrimerosDias
  2258. DiasSegundaFecha = RestantesDias
  2259. If (IndexBase = 0) Then
  2260. Valor = ValorSaldo * PorcCupon * Dias / 360
  2261. Return Valor
  2262. ElseIf (IndexBase = 1) Then
  2263. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  2264. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2265. PrOpc1 = ValorSaldo * PorcCupon * DiasPrimeraFecha / 366
  2266. PrOpc2 = ValorSaldo * PorcCupon * DiasSegundaFecha / 365
  2267. Valor = PrOpc1 + PrOpc2
  2268. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2269. Valor = ValorSaldo * PorcCupon * DiasSegundaFecha / 365
  2270. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  2271. Valor = ValorSaldo * PorcCupon * DiasPrimeraFecha / 366
  2272. Else
  2273. Valor = 0
  2274. End If
  2275. Return Valor
  2276. ElseIf (IndexBase = 2) Then
  2277. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  2278. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2279. PrOpc1 = ValorSaldo * PorcCupon * DiasPrimeraFecha / 366
  2280. PrOpc2 = ValorSaldo * PorcCupon * DiasSegundaFecha / 365
  2281. Valor = PrOpc1 + PrOpc2
  2282. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2283. Valor = ValorSaldo * PorcCupon * DiasSegundaFecha / 365
  2284. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  2285. Valor = ValorSaldo * PorcCupon * DiasPrimeraFecha / 366
  2286. Else
  2287. Valor = 0
  2288. End If
  2289. Return Valor
  2290. Else
  2291. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  2292. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2293. PrOpc1 = ValorSaldo * PorcCupon * DiasPrimeraFecha / 360
  2294. PrOpc2 = ValorSaldo * PorcCupon * DiasSegundaFecha / 360
  2295. Valor = PrOpc1 + PrOpc2
  2296. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2297. Valor = ValorSaldo * PorcCupon * DiasSegundaFecha / 360
  2298. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  2299. Valor = ValorSaldo * PorcCupon * DiasPrimeraFecha / 360
  2300. Else
  2301. Valor = 0
  2302. End If
  2303. Return Valor
  2304. End If
  2305. Return Valor
  2306. End Function
  2307. Function Impuestos(ByVal Ingresos As Double, PorcentajeRenta As Double)
  2308. Dim Total As Double
  2309. Total = Ingresos * PorcentajeRenta
  2310. Return Total
  2311. End Function
  2312. Function Liquido(ByVal Ingreso As Double, ByVal Renta As Double)
  2313. Dim Total As Double
  2314. Total = Ingreso - Renta
  2315. Return Total
  2316. End Function
  2317. Sub CalculoIngresosBONO()
  2318. Dim Ingreso As Double = 0
  2319. Dim ValorNominal = 0.0, PorcCupon = 0.0, Ingresos = 0.0, PorcentajeRenta = 0.0
  2320. Dim IngresosInt = 0.0, Impuestos = 0.0, Liquido = 0.0
  2321. ValorNominal = CDec(txtValorNominalCompra.Text)
  2322. PorcCupon = CDec(txtPorcentajeCuponCompra.Text.ToString.Trim("%")) / 100
  2323. Dim Index As Integer = dgvIngresos.CurrentRow.Index
  2324. Dim Fecha1 As Date = Date.Now.Date
  2325. Dim Fecha2 As Date = Date.Now.Date
  2326. Dim Dias As Integer = dgvIngresos.Rows(Index).Cells("Dias").Value
  2327. If (Index = 0) Then
  2328. Dim RespaldoFecha As String = Format(dtpFechaLiquidacionCompra.Value, "yyyy/MM/dd")
  2329. Fecha1 = RespaldoFecha
  2330. Fecha2 = dgvIngresos.Rows(Index).Cells("FechaCupon").Value
  2331. Else
  2332. Fecha1 = dgvIngresos.Rows(Index - 1).Cells("FechaCupon").Value
  2333. Fecha2 = dgvIngresos.Rows(Index).Cells("FechaCupon").Value
  2334. End If
  2335. If (Not dgvIngresos.CurrentRow.Cells("PorcentajeImpuesto").Value Is Nothing) Then
  2336. PorcentajeRenta = CDec(dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value.ToString.Trim("%")) / 100
  2337. Else
  2338. PorcentajeRenta = 0
  2339. End If
  2340. IngresosInt = IngresosIntereses(ValorNominal, PorcCupon, Dias, Fecha1, Fecha2, IndexBaseC)
  2341. Ingresos = Me.Impuestos(IngresosInt, PorcentajeRenta)
  2342. Liquido = Me.Liquido(IngresosInt, Ingresos)
  2343. dgvIngresos.CurrentRow.Cells("Ingreso").Value = IngresosInt
  2344. dgvIngresos.CurrentRow.Cells("MontoImpuesto").Value = Ingresos
  2345. dgvIngresos.CurrentRow.Cells("Liquido").Value = Liquido
  2346. End Sub
  2347. Sub PrepararIngresosTIT(ByVal Index As Integer, ByRef Amortizacion As DataGridView)
  2348. AsignacionPeriodicidad()
  2349. Dim IndexAnterior = Index - 1
  2350. Dim Respaldo As String = Format(dtpSiguienteFechaCuponCompra.Value, "dd/MM/yyyy")
  2351. Dim Dias, Ingreso, PorcentajeImpuesto, MontoImpuesto, Liquido, PorcentajeImpuestoAnterior
  2352. Dias = dgvIngresos.Rows(Index).Cells("Dias").Value
  2353. Ingreso = dgvIngresos.Rows(Index).Cells("Ingreso").Value
  2354. PorcentajeImpuesto = 10
  2355. If (Not PorcentajeImpuesto Is Nothing) Then
  2356. PorcentajeImpuesto = CDec(PorcentajeImpuesto.ToString.Trim("%")) / 100
  2357. Else
  2358. PorcentajeImpuesto = "0.0%"
  2359. End If
  2360. MontoImpuesto = 0
  2361. Liquido = 0
  2362. If (Index = 0) Then
  2363. PorcentajeImpuestoAnterior = "10.0%"
  2364. Else
  2365. PorcentajeImpuestoAnterior = dgvIngresos.Rows(IndexAnterior).Cells("PorcentajeImpuesto").Value
  2366. End If
  2367. Dim Dia As Integer = 0
  2368. If Not String.IsNullOrEmpty(Amortizacion.Rows(Index).Cells("Dias").Value) Then
  2369. Dia = Amortizacion.Rows(Index).Cells("Dias").Value
  2370. End If
  2371. Dim Fecha As Date = Date.Now.Date
  2372. If Not String.IsNullOrEmpty(Amortizacion.Rows(Index).Cells("Fecha").Value) Then
  2373. Fecha = Amortizacion.Rows(Index).Cells("Fecha").Value
  2374. End If
  2375. dgvIngresos.Rows.Add(0, 0, 0, Fecha, Dia, 0, PorcentajeImpuestoAnterior, 0, 0)
  2376. End Sub
  2377. Sub CalculoIngresosTIT()
  2378. Dim FechaPeriodoGracia = PeriodoGracia()
  2379. Dim CantidadAmortizacion As Integer = Variables.dgvAmortizacion.Rows.Count - 1
  2380. Dim Amortizacion = Variables.dgvAmortizacion
  2381. Dim Index As Integer = 0
  2382. Dim j As Integer = 0
  2383. While Index <= CantidadAmortizacion
  2384. PrepararIngresosTIT(Index, Amortizacion)
  2385. Index += 1
  2386. End While
  2387. While j <= CantidadAmortizacion
  2388. Dim PrimerosDias As Double = Amortizacion.Rows(j).Cells("PrimerosDias").Value
  2389. Dim RestantesDias As Double = Amortizacion.Rows(j).Cells("RestantesDias").Value
  2390. Dim FechaActualCupon = dgvIngresos.Rows(j).Cells("FechaCupon").Value
  2391. Dim Ingreso As Double = 0
  2392. Dim ValorSaldo = 0.0, PorcCupon = 0.0, Ingresos = 0.0, PorcentajeRenta = 0.0
  2393. Dim IngresosInt = 0.0, Impuestos = 0.0, Liquido = 0.0
  2394. Dim SaldoPendiente As Double = 0
  2395. 'If TypeOf FechaPeriodoGracia Is Boolean Then
  2396. If j = 0 Then
  2397. ValorSaldo = Variables.MontoCompraTIT
  2398. Else
  2399. ValorSaldo = Amortizacion.Rows(j - 1).Cells("Saldos").Value
  2400. End If
  2401. PorcCupon = CDec(txtPorcentajeCuponCompra.Text.ToString.Trim("%")) / 100
  2402. Dim Fecha1 As Date = Date.Now.Date
  2403. Dim Fecha2 As Date = Date.Now.Date
  2404. Dim Dias As Integer = dgvIngresos.Rows(j).Cells("Dias").Value
  2405. If (j = 0) Then
  2406. Dim RespaldoFecha As String = Format(dtpFechaLiquidacionCompra.Value, "yyyy/MM/dd")
  2407. Fecha1 = RespaldoFecha
  2408. Fecha2 = dgvIngresos.Rows(j).Cells("FechaCupon").Value
  2409. Else
  2410. Fecha1 = dgvIngresos.Rows(j - 1).Cells("FechaCupon").Value
  2411. Fecha2 = dgvIngresos.Rows(j).Cells("FechaCupon").Value
  2412. End If
  2413. If (Not dgvIngresos.Rows(j).Cells("PorcentajeImpuesto").Value Is Nothing) Then
  2414. PorcentajeRenta = CDec(dgvIngresos.Rows(j).Cells("PorcentajeImpuesto").Value.ToString.Trim("%")) / 100
  2415. Else
  2416. PorcentajeRenta = 0
  2417. End If
  2418. IngresosInt = IngresosInteresesTIT(ValorSaldo, PorcCupon, Dias, PrimerosDias, RestantesDias, IndexBaseC)
  2419. Ingresos = Me.Impuestos(IngresosInt, PorcentajeRenta)
  2420. Liquido = Me.Liquido(IngresosInt, Ingresos)
  2421. dgvIngresos.Rows(j).Cells("Ingreso").Value = IngresosInt
  2422. dgvIngresos.Rows(j).Cells("MontoImpuesto").Value = Ingresos
  2423. dgvIngresos.Rows(j).Cells("Liquido").Value = Liquido
  2424. j += 1
  2425. End While
  2426. End Sub
  2427. Private Sub txtPorcentajeInteresAcumuladoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeInteresAcumuladoCompra.TextChanged
  2428. End Sub
  2429. Private Sub btnQuitar_Click(sender As Object, e As EventArgs) Handles btnQuitar.Click
  2430. QuitarFila()
  2431. Calculos()
  2432. End Sub
  2433. Sub QuitarFila()
  2434. Dim CantidadFilas As Integer = dgvIngresos.Rows.Count - 1
  2435. If CantidadFilas > 0 Then
  2436. Dim result As Integer = MsgBox("¿Está seguro que desea eliminar la fila?", MsgBoxStyle.OkCancel)
  2437. ' Test result.
  2438. Dim codigo As String = Variables.Codigo
  2439. Dim Numero As Integer = dgvIngresos.CurrentRow.Cells("NumCupon").Value
  2440. If result = MsgBoxResult.Ok Then
  2441. Try
  2442. dgvIngresos.Rows.Remove(dgvIngresos.CurrentRow)
  2443. BonosConsulta.EliminarIngreso(codigo, Numero, Instrumento)
  2444. Catch ex As Exception
  2445. MsgBox("No ha seleccionado una fila")
  2446. End Try
  2447. End If
  2448. Else
  2449. MsgBox("Actualmente no tiene registros")
  2450. End If
  2451. End Sub
  2452. Private Sub txtCuponesRecibidos_TextChanged(sender As Object, e As EventArgs) Handles txtCuponesRecibidos.TextChanged
  2453. End Sub
  2454. Private Sub txtIngresosPorIntereses_Op_TextChanged(sender As Object, e As EventArgs) Handles txtIngresosPorIntereses_Op.TextChanged
  2455. End Sub
  2456. Private Sub txtRendimientoGananciaPerdida_Op_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoGananciaPerdida_Op.TextChanged
  2457. End Sub
  2458. Private Sub txtRendimientoIntereses_Op_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoIntereses_Op.TextChanged
  2459. End Sub
  2460. Private Sub txtRendimientoAntesISR_Op_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoAntesISR_Op.TextChanged
  2461. End Sub
  2462. Private Sub txtPlazo_Op_TextChanged(sender As Object, e As EventArgs) Handles txtPlazo_Op.TextChanged
  2463. End Sub
  2464. Private Sub txtDiasAcumuladosVenta_TextChanged(sender As Object, e As EventArgs) Handles txtDiasAcumuladosVenta.TextChanged
  2465. End Sub
  2466. Private Sub pnlPie_Paint(sender As Object, e As PaintEventArgs) Handles pnlPie.Paint
  2467. End Sub
  2468. Private Sub txtValorNominalCompra_Leave(sender As Object, e As EventArgs) Handles txtValorNominalCompra.Leave
  2469. Formato()
  2470. End Sub
  2471. Private Sub txtPorcentajeCuponCompra_Leave(sender As Object, e As EventArgs) Handles txtPorcentajeCuponCompra.Leave
  2472. Formato()
  2473. End Sub
  2474. Private Sub txtYTMAlVencimientoCompra_Leave(sender As Object, e As EventArgs) Handles txtYTMAlVencimientoCompra.Leave
  2475. Formato()
  2476. End Sub
  2477. Private Sub txtPrecioAlVencimientoCompra_Leave(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoCompra.Leave
  2478. Formato()
  2479. End Sub
  2480. Private Sub txtPrecioCompra_Leave(sender As Object, e As EventArgs) Handles txtPrecioCompra.Leave
  2481. Formato()
  2482. End Sub
  2483. Private Sub txtComisionPorCompraCasa_Leave(sender As Object, e As EventArgs) Handles txtComisionPorCompraCasa.Leave
  2484. Formato()
  2485. End Sub
  2486. Private Sub txtComisionPorBolsaCompra_Leave(sender As Object, e As EventArgs) Handles txtComisionPorBolsaCompra.Leave
  2487. Formato()
  2488. End Sub
  2489. Private Sub txtCostoTransferenciaCompra_Leave(sender As Object, e As EventArgs) Handles txtCostoTransferenciaCompra.Leave
  2490. Formato()
  2491. End Sub
  2492. Private Sub txtValorNominalVenta_Leave(sender As Object, e As EventArgs) Handles txtValorNominalVenta.Leave
  2493. Formato()
  2494. End Sub
  2495. Private Sub txtPorcentajeCuponVenta_Leave(sender As Object, e As EventArgs) Handles txtPorcentajeCuponVenta.Leave
  2496. Formato()
  2497. End Sub
  2498. Private Sub txtYTMAlVencimientoVenta_Leave(sender As Object, e As EventArgs) Handles txtYTMAlVencimientoVenta.Leave
  2499. Formato()
  2500. End Sub
  2501. Private Sub txtPrecioAlVencimientoVenta_Leave(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoVenta.Leave
  2502. Formato()
  2503. End Sub
  2504. Private Sub txtPrecioVenta_Leave(sender As Object, e As EventArgs) Handles txtPrecioVenta.Leave
  2505. Formato()
  2506. End Sub
  2507. Private Sub txtComisionPorVentaCasa_Leave(sender As Object, e As EventArgs) Handles txtComisionPorVentaCasa.Leave
  2508. Formato()
  2509. End Sub
  2510. Private Sub txtComisionPorBolsaVenta_Leave(sender As Object, e As EventArgs) Handles txtComisionPorBolsaVenta.Leave
  2511. Formato()
  2512. End Sub
  2513. Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles btnIngresos.Click
  2514. CalculoIngresosTIT()
  2515. End Sub
  2516. Private Sub txtValorNominalCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtValorNominalCompra.KeyUp
  2517. If txtValorNominalCompra.Text = "." Then
  2518. txtValorNominalCompra.Text = ".0"
  2519. End If
  2520. End Sub
  2521. Private Sub txtPorcentajeCuponCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPorcentajeCuponCompra.KeyUp
  2522. If txtPorcentajeCuponCompra.Text = "." Then
  2523. txtPorcentajeCuponCompra.Text = ".0"
  2524. End If
  2525. End Sub
  2526. Private Sub txtYTMAlVencimientoCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtYTMAlVencimientoCompra.KeyUp
  2527. If txtYTMAlVencimientoCompra.Text = "." Then
  2528. txtYTMAlVencimientoCompra.Text = ".0"
  2529. End If
  2530. End Sub
  2531. Private Sub txtPrecioAlVencimientoCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioAlVencimientoCompra.KeyUp
  2532. If txtPrecioAlVencimientoCompra.Text = "." Then
  2533. txtPrecioAlVencimientoCompra.Text = ".0"
  2534. End If
  2535. End Sub
  2536. Private Sub txtPrecioCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioCompra.KeyUp
  2537. If txtPrecioCompra.Text = "." Then
  2538. txtPrecioCompra.Text = ".0"
  2539. End If
  2540. End Sub
  2541. Private Sub txtComisionPorCompraCasa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorCompraCasa.KeyUp
  2542. If txtComisionPorCompraCasa.Text = "." Then
  2543. txtComisionPorCompraCasa.Text = ".0"
  2544. End If
  2545. End Sub
  2546. Private Sub txtComisionPorBolsaCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorBolsaCompra.KeyUp
  2547. If txtComisionPorBolsaCompra.Text = "." Then
  2548. txtComisionPorBolsaCompra.Text = ".0"
  2549. End If
  2550. End Sub
  2551. Private Sub txtCostoTransferenciaCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtCostoTransferenciaCompra.KeyUp
  2552. If txtCostoTransferenciaCompra.Text = "." Then
  2553. txtCostoTransferenciaCompra.Text = ".0"
  2554. End If
  2555. End Sub
  2556. Private Sub txtValorNominalVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtValorNominalVenta.KeyUp
  2557. If txtValorNominalVenta.Text = "." Then
  2558. txtValorNominalVenta.Text = ".0"
  2559. End If
  2560. End Sub
  2561. Private Sub txtPorcentajeCuponVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPorcentajeCuponVenta.KeyUp
  2562. If txtPorcentajeCuponVenta.Text = "." Then
  2563. txtPorcentajeCuponVenta.Text = ".0"
  2564. End If
  2565. End Sub
  2566. Private Sub txtYTMAlVencimientoVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtYTMAlVencimientoVenta.KeyUp
  2567. If txtYTMAlVencimientoVenta.Text = "." Then
  2568. txtYTMAlVencimientoVenta.Text = ".0"
  2569. End If
  2570. End Sub
  2571. Private Sub txtPrecioAlVencimientoVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioAlVencimientoVenta.KeyUp
  2572. If txtPrecioAlVencimientoVenta.Text = "." Then
  2573. txtPrecioAlVencimientoVenta.Text = ".0"
  2574. End If
  2575. End Sub
  2576. Private Sub txtPrecioVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioVenta.KeyUp
  2577. If txtPrecioVenta.Text = "." Then
  2578. txtPrecioVenta.Text = ".0"
  2579. End If
  2580. End Sub
  2581. Private Sub txtComisionPorVentaCasa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorVentaCasa.KeyUp
  2582. If txtComisionPorVentaCasa.Text = "." Then
  2583. txtComisionPorVentaCasa.Text = ".0"
  2584. End If
  2585. End Sub
  2586. Private Sub txtComisionPorBolsaVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorBolsaVenta.KeyUp
  2587. If txtComisionPorBolsaVenta.Text = "." Then
  2588. txtComisionPorBolsaVenta.Text = ".0"
  2589. End If
  2590. End Sub
  2591. Private Sub dgvIngresos_KeyPress(sender As Object, e As KeyPressEventArgs) Handles dgvIngresos.KeyPress
  2592. Formato()
  2593. End Sub
  2594. Private Sub dgvIngresos_Leave(sender As Object, e As EventArgs) Handles dgvIngresos.Leave
  2595. End Sub
  2596. Private Sub dgvIngresos_Click(sender As Object, e As EventArgs) Handles dgvIngresos.Click
  2597. Formato()
  2598. End Sub
  2599. Private Sub dgvIngresos_CellLeave(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellLeave
  2600. Formato()
  2601. End Sub
  2602. Sub ValidacionErrores()
  2603. If Not String.IsNullOrEmpty(txtPorcentajeInteresAcumuladoCompra.Text.ToString.Trim("%")) Then
  2604. If Double.IsNaN(txtPorcentajeInteresAcumuladoCompra.Text.ToString.Trim("%")) Then
  2605. txtPorcentajeInteresAcumuladoCompra.Text = "0.0%"
  2606. End If
  2607. If Double.IsInfinity(txtPorcentajeInteresAcumuladoCompra.Text.ToString.Trim("%")) Then
  2608. txtPorcentajeInteresAcumuladoCompra.Text = "0.0%"
  2609. End If
  2610. End If
  2611. If Not String.IsNullOrEmpty(txtPorcentajeInteresAcumuladoVenta.Text.ToString.Trim("%")) Then
  2612. If Double.IsNaN(txtPorcentajeInteresAcumuladoVenta.Text.ToString.Trim("%")) Then
  2613. txtPorcentajeInteresAcumuladoVenta.Text = "0.0%"
  2614. End If
  2615. If Double.IsInfinity(txtPorcentajeInteresAcumuladoVenta.Text.ToString.Trim("%")) Then
  2616. txtPorcentajeInteresAcumuladoVenta.Text = "0.0%"
  2617. End If
  2618. End If
  2619. If Not String.IsNullOrEmpty(txtPrecioSucioCompra.Text.ToString.Trim("%")) Then
  2620. If Double.IsNaN(txtPrecioSucioCompra.Text.ToString.Trim("%")) Then
  2621. txtPrecioSucioCompra.Text = "0.0%"
  2622. End If
  2623. If Double.IsInfinity(txtPrecioSucioCompra.Text.ToString.Trim("%")) Then
  2624. txtPrecioSucioCompra.Text = "0.0%"
  2625. End If
  2626. End If
  2627. If Not String.IsNullOrEmpty(txtPrecioSucioVenta.Text.ToString.Trim("%")) Then
  2628. If Double.IsNaN(txtPrecioSucioVenta.Text.ToString.Trim("%")) Then
  2629. txtPrecioSucioVenta.Text = "0.0%"
  2630. End If
  2631. If Double.IsInfinity(txtPrecioSucioVenta.Text.ToString.Trim("%")) Then
  2632. txtPrecioSucioVenta.Text = "0.0%"
  2633. End If
  2634. End If
  2635. End Sub
  2636. Sub BotonQuitar()
  2637. If TabCampos.SelectedIndex = 1 Then
  2638. btnQuitar.Visible = True
  2639. btnQuitar.Enabled = True
  2640. Else
  2641. btnQuitar.Visible = False
  2642. btnQuitar.Enabled = False
  2643. End If
  2644. End Sub
  2645. Private Sub lblRedencion_Click(sender As Object, e As EventArgs)
  2646. End Sub
  2647. Private Sub txtValorTransadoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtValorTransadoVenta.TextChanged
  2648. End Sub
  2649. Private Sub btnCancelar_Click(sender As Object, e As EventArgs) Handles btnCancelar.Click
  2650. End Sub
  2651. Private Sub Button1_Click_1(sender As Object, e As EventArgs)
  2652. End Sub
  2653. Sub CargarTransladoNuevo()
  2654. Dim Existe As Boolean = ExisteInversion()
  2655. If CantFormAbierto = False Then
  2656. If Not RetCodigoInversionExiste And Not Existe Then
  2657. Dim TipoTransaccionCompraVenta As String = Variables.TipoTransaccionCompraVenta
  2658. If TipoTransaccionCompraVenta = "C" Then
  2659. txtValorNominalCompra.Text = Variables.RetMonto
  2660. txtPrecioCompra.Text = Variables.RetPrecio
  2661. txtPorcentajeCuponCompra.Text = Variables.RetRendimiento
  2662. ElseIf TipoTransaccionCompraVenta = "V" Then
  2663. txtValorNominalVenta.Text = Variables.RetMonto
  2664. txtPrecioVenta.Text = Variables.RetPrecio
  2665. txtPorcentajeCuponVenta.Text = Variables.RetRendimiento
  2666. End If
  2667. End If
  2668. End If
  2669. End Sub
  2670. Private Sub btnVenderTitulo_Click(sender As Object, e As EventArgs) Handles btnVenderTitulo.Click
  2671. If Variables.InvocadorProInv = "frmINV" Then
  2672. Dim TrasladarDatos As New TrasladarDatosCMVTA
  2673. Dim General As New DAOGeneral
  2674. Dim Codigo = Variables.Codigo
  2675. Dim Tabla As String = "INV0"
  2676. TrasladarDatos = RellenarDatosCMVTA()
  2677. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  2678. If Existe Then
  2679. Dim CodigoInversion As String = Variables.Codigo
  2680. Dim frmPINVCMVTA As New frmPIN("V", CodigoInversion, TrasladarDatos)
  2681. frmINV.Close()
  2682. Me.Close()
  2683. frmPINVCMVTA.ShowDialog()
  2684. End If
  2685. End If
  2686. End Sub
  2687. Function RellenarDatosCMVTA()
  2688. Dim TrasladarDatos As New TrasladarDatosCMVTA
  2689. TrasladarDatos.BaseCINV = Operaciones.ConvertirEntero(cboAnioBaseC.SelectedIndex.ToString)
  2690. TrasladarDatos.CuponCINV = Operaciones.ConvertirDecimal(txtPorcentajeCuponCompra.Text.ToString)
  2691. TrasladarDatos.FechaLiquidacionCINV = Operaciones.ConvertirFecha(dtpFechaLiquidacionCompra.Value.ToString)
  2692. TrasladarDatos.FechaVencimientoCINV = Operaciones.ConvertirFecha(dtpFechaVencimientoCompra.Value.ToString)
  2693. TrasladarDatos.PeriodicidadCINV = cboPeriodosC.SelectedValue.ToString
  2694. TrasladarDatos.PorcentajeComisionBolsaCINV = Operaciones.ConvertirDecimal(txtComisionPorBolsaCompra.Text.ToString)
  2695. TrasladarDatos.PorcentajeComisionCasaCINV = Operaciones.ConvertirDecimal(txtComisionPorCompraCasa.Text.ToString)
  2696. TrasladarDatos.PrecioCompraCINV = Operaciones.ConvertirDecimal(txtPrecioCompra.Text.ToString)
  2697. TrasladarDatos.PrecioVencimientoCINV = Operaciones.ConvertirDecimal(txtPrecioAlVencimientoCompra.Text.ToString)
  2698. TrasladarDatos.UltimaFechaCuponCINV = Operaciones.ConvertirFecha(dtpUltimaFechaCuponCompra.Value)
  2699. TrasladarDatos.ValorNominalCINV = Operaciones.ConvertirDecimal(txtValorNominalCompra.Text.ToString)
  2700. TrasladarDatos.YTMVencimientoCINV = Operaciones.ConvertirDecimal(txtYTMAlVencimientoCompra.Text.ToString)
  2701. TrasladarDatos.NombreInstrumento = "CINV"
  2702. TrasladarDatos.AgregarCMVTA = True
  2703. Return TrasladarDatos
  2704. End Function
  2705. End Class