frmLetes.vb 86 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532
  1. Imports System.Globalization
  2. Public Class frmLetes
  3. Dim oCELetes As LETESCE
  4. Dim oDAOLetes As New LETESDAO
  5. Dim oDAOGeneral As New DAOGeneral
  6. Dim IndexBase As Integer = 0
  7. Dim TipoTransaccion = "OK"
  8. Dim Operaciones As New Operaciones
  9. Dim CalculosTablaDiasFecha As New CalculosTablaDiasFecha
  10. Dim CargaCompletaInstrumento As Boolean = False
  11. Dim V_txtPrecio = 0.0, V_txtValorTransado = 0.0, V_txtComisionCasa = 0.0, V_txtComisionBolsa = 0.0, V_txtIngresoBruto = 0.0, V_txtTotalAPagar = 0.0, V_txtIngresoNeto = 0.0, V_txtRendimientoNeto = 0.0, V_txtDiasAcumulados = 0.0
  12. Dim DecimalesRedondeo As Integer = 4
  13. Private CodigoInversion As String
  14. Dim Instrumento As String
  15. Private _Modo As String
  16. Private _IdDocumento As Integer
  17. Private _TipoDocumento As String
  18. Private _ValorNominal As Double
  19. Private _ValorTransado As Double
  20. Private _Precio As Double
  21. Private _PorcentajeCasa As Double
  22. Private _ComisionCasa As Double
  23. Private _PorcentajeBolsa As Double
  24. Private _ComisionBolsa As Double
  25. Private _TotalAPagar As Double
  26. Private _FechaOperacion As Date
  27. Private _FechaLiquidacion As Date
  28. Private _FechaVencimiento As Date
  29. Private _RendimientoBruto As Double
  30. Private _RendimientoNeto As Double
  31. Private _Periodicidad As String
  32. Private _Plazo As Integer
  33. Private _IngresoBruto As Double
  34. Private _IngresoNeto As Double
  35. Private PBUR As Double = False
  36. Private VCN As Double = False
  37. Private CET As Double = False
  38. Public Property Modo As String
  39. Get
  40. Return _Modo
  41. End Get
  42. Set(value As String)
  43. _Modo = value
  44. End Set
  45. End Property
  46. Private Property IdDocumento As Integer
  47. Get
  48. Return _IdDocumento
  49. End Get
  50. Set(value As Integer)
  51. _IdDocumento = value
  52. End Set
  53. End Property
  54. Private Property TipoDocumento As String
  55. Get
  56. Return _TipoDocumento
  57. End Get
  58. Set(value As String)
  59. _TipoDocumento = value
  60. End Set
  61. End Property
  62. 'GETS
  63. Function GetFechaOperacion() As Date
  64. Dim valor As Date
  65. valor = dtpFechaOperacion.Value
  66. Return valor
  67. End Function
  68. Function GetFechaLiquidacion() As Date
  69. Dim valor As Date
  70. valor = dtpFechaLiquidacion.Value
  71. Return valor
  72. End Function
  73. Function GetValorNominal() As Double
  74. Dim valor As Double
  75. If Me.txtValorNominal.Text.Length = 0 Then
  76. valor = 0
  77. Else
  78. valor = Me.txtValorNominal.Text
  79. End If
  80. Return valor
  81. End Function
  82. Function GetPrecio() As Double
  83. Dim valor As Double
  84. If Me.txtPrecio.Text.Length = 0 Then
  85. valor = 0
  86. Else
  87. Try
  88. valor = Me.txtPrecio.Text
  89. valor = valor / 100
  90. Catch ex As Exception
  91. valor = 0
  92. End Try
  93. End If
  94. Return valor
  95. End Function
  96. Function GetValorTransado() As Double
  97. Dim valor As Double
  98. If Me.txtValorTransado.Text.Length = 0 Then
  99. valor = 0
  100. Else
  101. valor = Me.txtValorTransado.Text
  102. End If
  103. Return valor
  104. End Function
  105. Function GetComisionBolsa() As Double
  106. Dim valor As Double
  107. If Me.txtComisionBolsa.Text.Length = 0 Then
  108. valor = 0
  109. Else
  110. valor = Me.txtComisionBolsa.Text
  111. End If
  112. Return valor
  113. End Function
  114. Function GetComisionCasa() As Double
  115. Dim valor As Double
  116. If Me.txtComisionCasa.Text.Length = 0 Then
  117. valor = 0
  118. Else
  119. valor = Me.txtComisionCasa.Text
  120. End If
  121. Return valor
  122. End Function
  123. Function GetTotalAPagar() As Double
  124. Dim valor As Double
  125. If Me.txtTotalAPagar.Text.Length = 0 Then
  126. valor = 0
  127. Else
  128. valor = Me.txtTotalAPagar.Text
  129. End If
  130. Return valor
  131. End Function
  132. 'CALCULOS
  133. Function CalcularValorApagar() As Double
  134. Dim valor As Double
  135. valor = GetValorTransado() + GetComisionBolsa() + GetComisionCasa()
  136. valor = Math.Round(valor, DecimalesRedondeo)
  137. Return valor
  138. End Function
  139. 'AUTO
  140. Sub RefrescarPlazoInversion()
  141. Me.txtPlazoInversion.Text = 0
  142. End Sub
  143. Sub RefrescarPrecio()
  144. Me.txtPrecio.Text = 0
  145. End Sub
  146. Sub RefrescarTotalAPagar()
  147. Me.txtTotalAPagar.Text = CalcularValorApagar()
  148. End Sub
  149. Sub CrearColumnasIngresosVCN()
  150. Dim Correlativo, Plazo, Fecha, Monto, CostoCedeval, PorcentajeRenta, Renta,
  151. CostoTransferencia, CostoBanco, TotalRecibir As New DataGridViewTextBoxColumn
  152. Correlativo.Name = "Correlativo"
  153. Plazo.Name = "Plazo"
  154. Fecha.Name = "Fecha"
  155. Monto.Name = "Monto"
  156. CostoCedeval.Name = "CostoCedeval"
  157. PorcentajeRenta.Name = "PorcentajeRenta"
  158. Renta.Name = "Renta"
  159. CostoTransferencia.Name = "CostoTransferencia"
  160. CostoBanco.Name = "CostoBanco"
  161. TotalRecibir.Name = "TotalRecibir"
  162. Correlativo.HeaderText = "Correlativo"
  163. Plazo.HeaderText = "Plazo"
  164. Fecha.HeaderText = "Fecha"
  165. Monto.HeaderText = "Monto"
  166. CostoCedeval.HeaderText = "Costo de Cedeval"
  167. PorcentajeRenta.HeaderText = "Porcentaje de la Renta"
  168. Renta.HeaderText = "Renta"
  169. CostoTransferencia.HeaderText = "Costo de Transferencia"
  170. CostoBanco.HeaderText = "Costo de Banco"
  171. TotalRecibir.HeaderText = "Total a Recibir"
  172. dgvIngresosVCN.Columns.Add(Correlativo)
  173. dgvIngresosVCN.Columns.Add(Plazo)
  174. dgvIngresosVCN.Columns.Add(Fecha)
  175. dgvIngresosVCN.Columns.Add(Monto)
  176. dgvIngresosVCN.Columns.Add(CostoCedeval)
  177. dgvIngresosVCN.Columns.Add(PorcentajeRenta)
  178. dgvIngresosVCN.Columns.Add(Renta)
  179. dgvIngresosVCN.Columns.Add(CostoTransferencia)
  180. dgvIngresosVCN.Columns.Add(CostoBanco)
  181. dgvIngresosVCN.Columns.Add(TotalRecibir)
  182. End Sub
  183. Sub CalculosIngresosVCN(ByRef TipoCalculo As String)
  184. If TipoCalculo = "Global" Then
  185. Dim AgregarFechasIndex As Integer = 0
  186. Dim AgregarMasCamposIndex As Integer = 0
  187. Dim IndexFilas As Integer = 0
  188. dgvIngresosVCN.Rows.Clear()
  189. While (True)
  190. Dim FechaIngresos As Date = Date.Now.Date ''"Fecha"
  191. Dim AgregarFechasInteriorIndex As Integer = 0
  192. Dim Salir As Boolean = False
  193. While AgregarFechasIndex >= AgregarFechasInteriorIndex
  194. If AgregarFechasIndex = 0 Then
  195. dgvIngresosVCN.Rows.Add()
  196. End If
  197. FechaIngresos = CalculosTablaDiasFecha.AgregarFechaIngresos(dgvIngresosVCN, dtpUltimaFecha, "Fecha", DefinirBaseDias(), DefinirPeriodicidad(),
  198. "Mensual", AgregarFechasInteriorIndex)
  199. If FechaIngresos > dtpFechaVencimiento.Value Then
  200. Salir = True
  201. Exit While
  202. End If
  203. dgvIngresosVCN.Rows(AgregarFechasInteriorIndex).Cells("Fecha").Value = Format(FechaIngresos, "dd/MM/yyyy").ToString
  204. AgregarFechasInteriorIndex += 1
  205. End While
  206. AgregarFechasIndex += 1
  207. If Salir Then
  208. Exit While
  209. Else
  210. If FechaIngresos < dtpFechaVencimiento.Value Then
  211. dgvIngresosVCN.Rows.Add()
  212. End If
  213. End If
  214. End While
  215. IndexFilas = dgvIngresosVCN.Rows.Count - 1
  216. While IndexFilas >= AgregarMasCamposIndex
  217. Dim Correlativo As Integer = 0 ''"Correlativo"
  218. Dim Dias As Integer = 0 '' "Plazo"
  219. Dim Monto As Double = 0
  220. Dim PorcentajeRenta As String = "10 %"
  221. Dim cero As Integer = "0"
  222. Correlativo = CalculosTablaDiasFecha.AgregarCorrelativo(dgvIngresosVCN, AgregarMasCamposIndex)
  223. dgvIngresosVCN.Rows(AgregarMasCamposIndex).Cells("Correlativo").Value = Correlativo
  224. Dias = CalculosTablaDiasFecha.AgregarDias(dgvIngresosVCN, dtpUltimaFecha, DefinirBaseDias(), DefinirPeriodicidad(),
  225. "Mensual", "Fecha", "Plazo", AgregarMasCamposIndex)
  226. dgvIngresosVCN.Rows(AgregarMasCamposIndex).Cells("Plazo").Value = Dias
  227. Monto = CalculoMontoVCN(AgregarMasCamposIndex)
  228. dgvIngresosVCN.Rows(AgregarMasCamposIndex).Cells("Monto").Value = Monto
  229. CalculosTablaDiasFecha.AgregarValoresCamposdgvVacios(dgvIngresosVCN, AgregarMasCamposIndex, "PorcentajeRenta",
  230. PorcentajeRenta)
  231. CalculosTablaDiasFecha.AgregarValoresCamposdgvVacios(dgvIngresosVCN, AgregarMasCamposIndex, "CostoTransferencia",
  232. cero)
  233. CalculosTablaDiasFecha.AgregarValoresCamposdgvVacios(dgvIngresosVCN, AgregarMasCamposIndex, "CostoBanco",
  234. cero)
  235. CalculosTablaDiasFecha.AgregarValoresCamposdgvVacios(dgvIngresosVCN, AgregarMasCamposIndex, "CostoCedeval",
  236. cero)
  237. CalcularRenta(AgregarMasCamposIndex)
  238. CalcularTotalRecibir(AgregarMasCamposIndex)
  239. AgregarMasCamposIndex += 1
  240. End While
  241. Else
  242. Dim index As Integer = dgvIngresosVCN.CurrentRow.Index
  243. Dim Monto As Double = 0
  244. Dim PorcentajeRenta As String = "10 %"
  245. Dim cero As Integer = "0"
  246. Monto = CalculoMontoVCN(index)
  247. dgvIngresosVCN.Rows(index).Cells("Monto").Value = Monto
  248. CalculosTablaDiasFecha.AgregarValoresCamposdgvVacios(dgvIngresosVCN, index, "PorcentajeRenta",
  249. PorcentajeRenta)
  250. CalculosTablaDiasFecha.AgregarValoresCamposdgvVacios(dgvIngresosVCN, index, "CostoTransferencia",
  251. cero)
  252. CalculosTablaDiasFecha.AgregarValoresCamposdgvVacios(dgvIngresosVCN, index, "CostoBanco",
  253. cero)
  254. CalculosTablaDiasFecha.AgregarValoresCamposdgvVacios(dgvIngresosVCN, index, "CostoCedeval",
  255. cero)
  256. CalcularRenta(index)
  257. CalcularTotalRecibir(index)
  258. End If
  259. End Sub
  260. Sub CalcularRenta(ByVal index As Integer)
  261. Dim Monto As Double = Operaciones.ConvertirDecimal(dgvIngresosVCN.Rows(index).Cells("Monto").Value)
  262. Dim PorcentajeRenta As Double = Operaciones.ConvertirDecimal(dgvIngresosVCN.Rows(index).Cells("PorcentajeRenta").Value) / 100
  263. dgvIngresosVCN.Rows(index).Cells("Renta").Value = Monto * PorcentajeRenta
  264. End Sub
  265. Sub CalcularTotalRecibir(ByVal index As Integer)
  266. Dim Monto As Double = Operaciones.ConvertirDecimal(dgvIngresosVCN.Rows(index).Cells("Monto").Value)
  267. Dim InteresAcumulado As Double = Operaciones.ConvertirDecimal(txtInteresAcumulado.Text)
  268. Dim Cedeval As Double = Operaciones.ConvertirDecimal(dgvIngresosVCN.Rows(index).Cells("CostoCedeval").Value)
  269. Dim Renta As Double = Operaciones.ConvertirDecimal(dgvIngresosVCN.Rows(index).Cells("Renta").Value)
  270. Dim CostoTransferencia As Double = Operaciones.ConvertirDecimal(dgvIngresosVCN.Rows(index).Cells("CostoTransferencia").Value)
  271. Dim CostoBanco As Double = Operaciones.ConvertirDecimal(dgvIngresosVCN.Rows(index).Cells("CostoBanco").Value)
  272. Dim Total As Double = 0
  273. If index = 0 Then
  274. Total = Monto - InteresAcumulado - Cedeval - Renta - CostoTransferencia - CostoBanco
  275. Else
  276. Total = Monto - Cedeval - Renta - CostoTransferencia - CostoBanco
  277. End If
  278. dgvIngresosVCN.Rows(index).Cells("TotalRecibir").Value = Total
  279. End Sub
  280. Function CalculoMontoVCN(ByRef index As Integer)
  281. Dim ListaDiasBase As New Dictionary(Of String, String)
  282. Dim Fecha1 As Date = Date.Now.Date
  283. Dim Fecha2 As Date = Date.Now.Date
  284. Dim indexAnterior As Integer = index - 1
  285. Dim TipoBase As String = String.Empty
  286. Dim DiasNormales As Integer = 0
  287. Dim DiasEspeciales As Integer = 0
  288. Dim MontoInversion As Double = Operaciones.ConvertirDecimal(txtValorNominal.Text.ToString)
  289. Dim PorcentajeCupon As Double = Operaciones.ConvertirDecimal(txtRendimientoBruto.Text.ToString) / 100
  290. Dim Total As Double = 0
  291. If index = 0 Then
  292. Fecha1 = dtpUltimaFecha.Value
  293. Fecha2 = Operaciones.ConvertirFecha(dgvIngresosVCN.Rows(index).Cells("Fecha").Value)
  294. ListaDiasBase = CalculosTablaDiasFecha.CalcularFormulasDiasBase(Fecha1, Fecha2, DefinirBaseDias())
  295. Else
  296. Fecha1 = Operaciones.ConvertirFecha(dgvIngresosVCN.Rows(indexAnterior).Cells("Fecha").Value)
  297. Fecha2 = Operaciones.ConvertirFecha(dgvIngresosVCN.Rows(index).Cells("Fecha").Value.ToString)
  298. ListaDiasBase = CalculosTablaDiasFecha.CalcularFormulasDiasBase(Fecha1, Fecha2, DefinirBaseDias())
  299. End If
  300. TipoBase = ListaDiasBase.Item("TipoBase").ToString
  301. DiasNormales = Operaciones.ConvertirEntero(ListaDiasBase.Item("DiasNormales").ToString)
  302. DiasEspeciales = Operaciones.ConvertirEntero(ListaDiasBase.Item("DiasEspeciales").ToString)
  303. If TipoBase = "360" Then
  304. Total = MontoInversion * DiasNormales * PorcentajeCupon / 360
  305. ElseIf TipoBase = "365" Then
  306. Total = (MontoInversion * DiasNormales * PorcentajeCupon / 365) +
  307. (MontoInversion * DiasEspeciales * PorcentajeCupon / 366)
  308. ElseIf TipoBase = "360/365" Then
  309. Total = (MontoInversion * DiasNormales * PorcentajeCupon / 365) +
  310. (MontoInversion * DiasEspeciales * PorcentajeCupon / 366)
  311. ElseIf TipoBase = "365/360" Then
  312. Total = (MontoInversion * DiasNormales * PorcentajeCupon / 360) +
  313. (MontoInversion * DiasEspeciales * PorcentajeCupon / 360)
  314. End If
  315. Return Total
  316. End Function
  317. Function DefinirBaseDias()
  318. Dim TipoBase As Integer = Operaciones.ConvertirEntero(cboBase.SelectedIndex)
  319. Return TipoBase
  320. End Function
  321. Function DefinirPeriodicidad()
  322. Dim Periodicidad As String = cboPeriodicidad.SelectedValue
  323. Return Periodicidad
  324. End Function
  325. 'EVENTOS
  326. Private Sub Button1_Click(sender As Object, e As EventArgs)
  327. RefrescarPlazoInversion()
  328. End Sub
  329. Private Sub txtRendimientoBruto_TextChanged(sender As Object, e As EventArgs)
  330. If Modo = "N" Then
  331. RefrescarPrecio()
  332. End If
  333. End Sub
  334. Private Sub txtPlazoInversion_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoBruto.TextChanged, txtPlazoInversion.TextChanged
  335. RellenarDatos()
  336. End Sub
  337. Private Sub dtpFechaVencimiento_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimiento.ValueChanged
  338. RellenarDatos()
  339. End Sub
  340. Private Sub dtpFechaLiquidacion_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaLiquidacion.ValueChanged
  341. RellenarDatos()
  342. End Sub
  343. Private Sub dtpFechaOperacion_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaOperacion.ValueChanged
  344. RellenarDatos()
  345. AgregarDiasExtra()
  346. End Sub
  347. Private Sub txtValorNominal_TextChanged(sender As Object, e As EventArgs) Handles txtValorNominal.TextChanged
  348. RellenarDatos()
  349. End Sub
  350. Private Sub txtPrecio_TextChanged(sender As Object, e As EventArgs) Handles txtPrecio.TextChanged
  351. End Sub
  352. Private Sub txtPorcentajeComisionCasa_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeComisionCasa.TextChanged
  353. RellenarDatos()
  354. End Sub
  355. Private Sub txtPorcentajeComisionBolsa_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeComisionBolsa.TextChanged
  356. RellenarDatos()
  357. End Sub
  358. Private Sub txtValorTransado_TextChanged(sender As Object, e As EventArgs) Handles txtValorTransado.TextChanged
  359. End Sub
  360. Private Sub txtComisionCasa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionCasa.TextChanged
  361. If Modo = "N" Then
  362. RefrescarTotalAPagar()
  363. End If
  364. End Sub
  365. Private Sub txtComisionBolsa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionBolsa.TextChanged
  366. If Modo = "N" Then
  367. RefrescarTotalAPagar()
  368. End If
  369. End Sub
  370. Private Sub txtTotalAPagar_TextChanged(sender As Object, e As EventArgs) Handles txtTotalAPagar.TextChanged
  371. End Sub
  372. Sub ValidarExistencia()
  373. Dim General As New DAOGeneral
  374. Dim Codigo As String = Variables.Codigo
  375. Dim Tabla As String = String.Empty
  376. If PBUR Then
  377. Tabla = "PBUR"
  378. ElseIf VCN Then
  379. Tabla = "VCN"
  380. ElseIf CET Then
  381. Tabla = "CET0"
  382. Else
  383. Tabla = "LET0"
  384. End If
  385. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  386. If (Existe) Then
  387. navNuevo.Enabled = False
  388. navModificar.Enabled = True
  389. navEliminar.Enabled = True
  390. Else
  391. navNuevo.Enabled = True
  392. navModificar.Enabled = False
  393. navEliminar.Enabled = False
  394. End If
  395. TipoTransaccion = String.Empty
  396. btnAceptar.Text = "Aceptar"
  397. End Sub
  398. Function ExisteValidacion()
  399. Dim General As New DAOGeneral
  400. Dim Codigo As String = Variables.Codigo
  401. Dim Tabla As String = String.Empty
  402. If PBUR Then
  403. Tabla = "PBUR"
  404. ElseIf VCN Then
  405. Tabla = "VCN"
  406. ElseIf CET Then
  407. Tabla = "CET0"
  408. Else
  409. Tabla = "LET0"
  410. End If
  411. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  412. Return Existe
  413. End Function
  414. Private Sub frmLetes_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  415. TipInstrumento()
  416. Me.ActiveControl = Me.txtValorNominal
  417. Call CargarCasasCorredoras()
  418. Call CargarBase()
  419. Call CargarPeriodicidad()
  420. If Variables.Codigo.IndexOf("LETE") > -1 Then
  421. Instrumento = "LETE"
  422. ElseIf Variables.Codigo.IndexOf("PBUR") > -1 Then
  423. Instrumento = "PBUR"
  424. lblBono.Text = "PAPEL BURSATIL"
  425. Me.Text = "PAPEL BURSATIL"
  426. lblInteresAcumulado.Visible = True
  427. lblDiasAcumulados.Visible = True
  428. dtpUltimaFecha.Visible = True
  429. txtInteresAcumulado.Visible = True
  430. chbValorPar.Visible = True
  431. ElseIf Variables.Codigo.IndexOf("CETE") > -1 Then
  432. Instrumento = "CETE"
  433. lblBono.Text = "CETES"
  434. Me.Text = "CETE"
  435. lblInteresAcumulado.Visible = True
  436. lblDiasAcumulados.Visible = True
  437. dtpUltimaFecha.Visible = True
  438. txtInteresAcumulado.Visible = True
  439. ConfiguracionCETE()
  440. ElseIf Variables.Codigo.IndexOf("VCN") > -1 Then
  441. grpIngresosVCN.Visible = True
  442. Instrumento = "VCN"
  443. lblBono.Text = "VALORES COMERCIALES"
  444. Me.Text = "VALORES COMERCIALES"
  445. lblInteresAcumulado.Visible = True
  446. lblDiasAcumulados.Visible = True
  447. lblOtrosCostos.Visible = True
  448. dtpUltimaFecha.Visible = True
  449. txtInteresAcumulado.Visible = True
  450. txtOtrosCostos.Visible = True
  451. chbValorPar.Visible = True
  452. dtpFechaVencimiento.Enabled = True
  453. txtPlazoInversion.ReadOnly = True
  454. dgvIngresosVCN.Columns.Clear()
  455. CrearColumnasIngresosVCN()
  456. CargarFilas()
  457. Else
  458. Instrumento = "NADA"
  459. End If
  460. CargarReg(Instrumento)
  461. Call CargarRegistroBD()
  462. SetPeriodicidad()
  463. AgregarPorcentaje()
  464. Rellenar()
  465. ExisteInversion()
  466. ValidarExistencia()
  467. CargaCompletaInstrumento = True
  468. End Sub
  469. Sub TipInstrumento()
  470. If Variables.Codigo.IndexOf("PBUR") > -1 Then
  471. PBUR = True
  472. End If
  473. If Variables.Codigo.IndexOf("VCN") > -1 Then
  474. VCN = True
  475. End If
  476. If Variables.Codigo.IndexOf("CETE") > -1 Then
  477. CET = True
  478. End If
  479. End Sub
  480. Sub SetPeriodicidad()
  481. If String.IsNullOrEmpty(Variables.Periodicidad) Then
  482. cboPeriodicidad.SelectedValue = "M"
  483. Else
  484. cboPeriodicidad.SelectedValue = Variables.Periodicidad
  485. End If
  486. End Sub
  487. Function ExisteInversion()
  488. Dim Codigo As String = Variables.Codigo
  489. Dim TablaINV As String = "INV0"
  490. Dim TablaPINV As String = "PIN0"
  491. Dim General As New DAOGeneral
  492. Dim InvPro = Variables.InvPro
  493. If InvPro = "I" Then
  494. Dim INV0 As Boolean = General.ExisteTitulo(Codigo, TablaINV)
  495. If INV0 Then
  496. navNuevo.Visible = True
  497. Return True
  498. Else
  499. navNuevo.Visible = False
  500. Return False
  501. End If
  502. End If
  503. If InvPro = "P" Then
  504. Dim PINV0 As Boolean = General.ExisteTitulo(Codigo, TablaPINV)
  505. If PINV0 Then
  506. navNuevo.Visible = True
  507. Return True
  508. Else
  509. navNuevo.Visible = False
  510. Return False
  511. End If
  512. End If
  513. Return False
  514. End Function
  515. Sub ConfiguracionCETE()
  516. txtPrecio.Text = "100%"
  517. End Sub
  518. Private Sub CargarReg(Instrumento)
  519. Dim Letes As New LETESDAO
  520. Dim Base As Integer = 0
  521. Dim dat = Letes.Cargar(Variables.Codigo, Instrumento)
  522. If (Not dat(1).ToString = "False") Then
  523. txtValorNominal.Text = Operaciones.ConvertirDecimal(dat(1).ToString)
  524. dtpFechaOperacion.Value = Operaciones.ConvertirFecha(dat(2).ToString)
  525. dtpFechaLiquidacion.Value = Operaciones.ConvertirFecha(dat(3).ToString)
  526. txtPlazoInversion.Text = Operaciones.ConvertirEntero(dat(4).ToString)
  527. If (String.IsNullOrEmpty(txtRendimientoBruto.Text)) Then
  528. txtRendimientoBruto.Text = CStr(Format((txtRendimientoBruto.Text), "0.00")) + "%"
  529. Else
  530. txtRendimientoBruto.Text = CStr(Operaciones.ConvertirDecimal(dat(5).ToString) * 100) + "%"
  531. End If
  532. cboCasasCorredoras.SelectedValue = dat(6).ToString
  533. cboPeriodicidad.SelectedValue = dat(7).ToString
  534. Base = Operaciones.ConvertirEntero(dat(8).ToString)
  535. cboBase.SelectedIndex = Base
  536. If (String.IsNullOrEmpty(dat(9).ToString)) Then
  537. txtPorcentajeComisionCasa.Text = Format(((txtPorcentajeComisionCasa.Text.Trim("%")) * 100), "0.00").ToString + "%"
  538. Else
  539. txtPorcentajeComisionCasa.Text = CStr(Operaciones.ConvertirDecimal(dat(9).ToString) * 100) + "%"
  540. End If
  541. If (String.IsNullOrEmpty(dat(10).ToString)) Then
  542. txtPorcentajeComisionBolsa.Text = Format((txtPorcentajeComisionBolsa.Text.Trim("%")) * 100, "0.00").ToString + "%"
  543. Else
  544. txtPorcentajeComisionBolsa.Text = CStr(Operaciones.ConvertirDecimal(dat(10).ToString) * 100) + "%"
  545. End If
  546. cboCasasCorredoras.SelectedValue = dat(12).ToString
  547. If (PBUR Or VCN) Then
  548. If (Not String.IsNullOrEmpty(dat(13).ToString)) Then
  549. chbValorPar.Checked = CBool(dat(13))
  550. End If
  551. If (Not String.IsNullOrEmpty(dat(14).ToString)) Then
  552. dtpUltimaFecha.Value = Operaciones.ConvertirFecha(dat(14).ToString)
  553. End If
  554. ElseIf CET Then
  555. If (Not String.IsNullOrEmpty(dat(13).ToString)) Then
  556. dtpUltimaFecha.Value = Operaciones.ConvertirFecha(dat(13).ToString)
  557. End If
  558. End If
  559. If VCN Then
  560. txtOtrosCostos.Text = Operaciones.ConvertirDecimal(dat(15).ToString)
  561. End If
  562. End If
  563. End Sub
  564. Private Sub Modificar(ByVal Instrumento As String)
  565. Dim ValNom As Double = Operaciones.ConvertirDecimal(txtValorNominal.Text.ToString)
  566. Dim FOpe As Date = Operaciones.ConvertirFecha(dtpFechaOperacion.Value.ToString)
  567. Dim FLiq As Date = Operaciones.ConvertirFecha(dtpFechaLiquidacion.Value.ToString)
  568. Dim RendBruto As Double = Operaciones.ConvertirDecimal(txtRendimientoBruto.Text.ToString) / 100
  569. Dim Plazo As Integer = Operaciones.ConvertirEntero(txtPlazoInversion.Text.ToString)
  570. Dim PorcentajeComisionCasa As Double = Operaciones.ConvertirDecimal(txtPorcentajeComisionCasa.Text.ToString) / 100
  571. Dim PorcentajeComisionBolsa As Double = Operaciones.ConvertirDecimal(txtPorcentajeComisionBolsa.Text.ToString) / 100
  572. Dim ValTrans As Double = Operaciones.ConvertirDecimal(txtValorTransado.Text.ToString)
  573. Dim Precio As Double = Operaciones.ConvertirDecimal(txtPrecio.Text.ToString.ToString) / 100
  574. Dim TotPagar As Double = Operaciones.ConvertirDecimal(txtTotalAPagar.Text.ToString)
  575. Dim RendNeto As Double = Operaciones.ConvertirDecimal(txtRendimientoNeto.Text.ToString) / 100
  576. Dim IngrBruto As Double = Operaciones.ConvertirDecimal(txtIngresoBruto.Text.ToString)
  577. Dim IngrNeto As Double = Operaciones.ConvertirDecimal(txtIngresoNeto.Text.ToString)
  578. Dim ComisionCasaValor As Double = Operaciones.ConvertirDecimal(txtComisionCasa.Text.ToString)
  579. Dim ComisionBolsaValor As Double = Operaciones.ConvertirDecimal(txtComisionBolsa.Text.ToString)
  580. Dim FUlt As Date = Operaciones.ConvertirFecha(dtpUltimaFecha.Value.ToString)
  581. Dim FRed As Date = Operaciones.ConvertirFecha(dtpRedencion.Value.ToString)
  582. Dim FVenc As Date = Operaciones.ConvertirFecha(dtpFechaVencimiento.Value.ToString)
  583. Dim IntAcumulado As Double = Operaciones.ConvertirDecimal(txtInteresAcumulado.Text.ToString.ToString) / 100
  584. Dim OtrosCostos As Double = Operaciones.ConvertirDecimal(txtOtrosCostos.Text.ToString)
  585. Dim periodo As String = String.Empty
  586. If Not cboPeriodicidad.SelectedIndex = -1 Then
  587. periodo = cboPeriodicidad.SelectedValue
  588. End If
  589. Dim Casas As String = String.Empty
  590. If Not cboCasasCorredoras.SelectedIndex = -1 Then
  591. Casas = cboCasasCorredoras.SelectedValue
  592. End If
  593. Dim ValorPar As Boolean = chbValorPar.Checked
  594. Dim Base As Integer
  595. Dim FechaUltima As Date = dtpUltimaFecha.Value
  596. If (cboBase.SelectedIndex = 0) Then
  597. Base = 0
  598. ElseIf (cboBase.SelectedIndex = 1) Then
  599. Base = 1
  600. ElseIf (cboBase.SelectedIndex = 2) Then
  601. Base = 2
  602. Else
  603. Base = 3
  604. End If
  605. Dim coleccion As New Collection
  606. coleccion.Add(ValNom)
  607. coleccion.Add(FOpe)
  608. coleccion.Add(FLiq)
  609. coleccion.Add(RendBruto)
  610. coleccion.Add(Plazo)
  611. coleccion.Add(Variables.Codigo)
  612. coleccion.Add(PorcentajeComisionCasa)
  613. coleccion.Add(PorcentajeComisionBolsa)
  614. coleccion.Add(periodo)
  615. coleccion.Add(Base)
  616. coleccion.Add(Casas)
  617. If (PBUR Or VCN) Then
  618. coleccion.Add(ValorPar)
  619. coleccion.Add(FechaUltima)
  620. ElseIf CET Then
  621. coleccion.Add(FechaUltima)
  622. End If
  623. If VCN Then
  624. coleccion.Add(OtrosCostos)
  625. End If
  626. coleccion.Add(ValTrans)
  627. coleccion.Add(Precio)
  628. coleccion.Add(TotPagar)
  629. coleccion.Add(RendNeto)
  630. coleccion.Add(IngrBruto)
  631. coleccion.Add(IngrNeto)
  632. coleccion.Add(ComisionCasaValor)
  633. coleccion.Add(ComisionBolsaValor)
  634. coleccion.Add(FUlt)
  635. coleccion.Add(FRed)
  636. coleccion.Add(FVenc)
  637. If CET Or PBUR Or VCN Then
  638. coleccion.Add(IntAcumulado)
  639. End If
  640. Dim EmpaquetarTablaBaseDatos As New Dictionary(Of Integer, Collection)
  641. EmpaquetarTablaBaseDatos = CalculosTablaDiasFecha.EmpaquetarTablaBaseDatos(dgvIngresosVCN)
  642. oDAOLetes.ActualizarLETE(coleccion, Instrumento, EmpaquetarTablaBaseDatos)
  643. End Sub
  644. Public Function Nuevo(ByVal Instrumento As String)
  645. Dim ValNom As Double = Operaciones.ConvertirDecimal(txtValorNominal.Text.ToString)
  646. Dim FOpe As Date = Operaciones.ConvertirFecha(dtpFechaOperacion.Value.ToString)
  647. Dim FLiq As Date = Operaciones.ConvertirFecha(dtpFechaLiquidacion.Value.ToString)
  648. Dim RendBruto As Double = Operaciones.ConvertirDecimal(txtRendimientoBruto.Text.ToString) / 100
  649. Dim Plazo As Integer = Operaciones.ConvertirEntero(txtPlazoInversion.Text.ToString)
  650. Dim PorcentajeComisionCasa As Double = Operaciones.ConvertirDecimal(txtPorcentajeComisionCasa.Text.ToString) / 100
  651. Dim PorcentajeComisionBolsa As Double = Operaciones.ConvertirDecimal(txtPorcentajeComisionBolsa.Text.ToString) / 100
  652. Dim ValTrans As Double = Operaciones.ConvertirDecimal(txtValorTransado.Text.ToString)
  653. Dim Precio As Double = Operaciones.ConvertirDecimal(txtPrecio.Text.ToString.ToString) / 100
  654. Dim TotPagar As Double = Operaciones.ConvertirDecimal(txtTotalAPagar.Text.ToString)
  655. Dim RendNeto As Double = Operaciones.ConvertirDecimal(txtRendimientoNeto.Text.ToString) / 100
  656. Dim IngrBruto As Double = Operaciones.ConvertirDecimal(txtIngresoBruto.Text.ToString)
  657. Dim IngrNeto As Double = Operaciones.ConvertirDecimal(txtIngresoNeto.Text.ToString)
  658. Dim ComisionCasaValor As Double = Operaciones.ConvertirDecimal(txtComisionCasa.Text.ToString)
  659. Dim ComisionBolsaValor As Double = Operaciones.ConvertirDecimal(txtComisionBolsa.Text.ToString)
  660. Dim FUlt As Date = Operaciones.ConvertirFecha(dtpUltimaFecha.Value.ToString)
  661. Dim FRed As Date = Operaciones.ConvertirFecha(dtpRedencion.Value.ToString)
  662. Dim FVenc As Date = Operaciones.ConvertirFecha(dtpFechaVencimiento.Value.ToString)
  663. Dim IntAcumulado As Double = Operaciones.ConvertirDecimal(txtInteresAcumulado.Text.ToString.ToString) / 100
  664. Dim periodo As String = String.Empty
  665. If Not cboPeriodicidad.SelectedIndex = -1 Then
  666. periodo = cboPeriodicidad.SelectedValue
  667. End If
  668. Dim Casas As String = String.Empty
  669. If Not cboCasasCorredoras.SelectedIndex = -1 Then
  670. Casas = cboCasasCorredoras.SelectedValue
  671. End If
  672. Dim ValorPar As Boolean = chbValorPar.Checked
  673. Dim Base As Integer
  674. Dim FechaUltima As Date = dtpUltimaFecha.Value
  675. Dim OtrosCostos = txtOtrosCostos.Text
  676. If (cboBase.SelectedIndex = 0) Then
  677. Base = 0
  678. ElseIf (cboBase.SelectedIndex = 1) Then
  679. Base = 1
  680. ElseIf (cboBase.SelectedIndex = 2) Then
  681. Base = 2
  682. Else
  683. Base = 3
  684. End If
  685. Dim coleccion As New Collection
  686. coleccion.Add(ValNom)
  687. coleccion.Add(FOpe)
  688. coleccion.Add(FLiq)
  689. coleccion.Add(RendBruto)
  690. coleccion.Add(Plazo)
  691. coleccion.Add(Variables.Codigo)
  692. coleccion.Add(PorcentajeComisionCasa)
  693. coleccion.Add(PorcentajeComisionBolsa)
  694. coleccion.Add(periodo)
  695. coleccion.Add(Base)
  696. coleccion.Add(Casas)
  697. If (PBUR Or VCN) Then
  698. coleccion.Add(ValorPar)
  699. coleccion.Add(FechaUltima)
  700. ElseIf CET Then
  701. coleccion.Add(FechaUltima)
  702. End If
  703. If VCN Then
  704. coleccion.Add(OtrosCostos)
  705. End If
  706. coleccion.Add(ValTrans)
  707. coleccion.Add(Precio)
  708. coleccion.Add(TotPagar)
  709. coleccion.Add(RendNeto)
  710. coleccion.Add(IngrBruto)
  711. coleccion.Add(IngrNeto)
  712. coleccion.Add(ComisionCasaValor)
  713. coleccion.Add(ComisionBolsaValor)
  714. coleccion.Add(FUlt)
  715. coleccion.Add(FRed)
  716. coleccion.Add(FVenc)
  717. If CET Or PBUR Or VCN Then
  718. coleccion.Add(IntAcumulado)
  719. End If
  720. Return coleccion
  721. End Function
  722. Sub NuevoRegistro(ByVal Instrumento As String)
  723. Dim Coleccion As New Collection
  724. Coleccion = Nuevo(Instrumento)
  725. Dim EmpaquetarTablaBaseDatos As New Dictionary(Of Integer, Collection)
  726. EmpaquetarTablaBaseDatos = CalculosTablaDiasFecha.EmpaquetarTablaBaseDatos(dgvIngresosVCN)
  727. Dim Proceder As Boolean = True
  728. If VCN Then
  729. If EmpaquetarTablaBaseDatos.Count = 0 Then
  730. Proceder = False
  731. End If
  732. End If
  733. If Coleccion.Count > 0 And Proceder Then
  734. oDAOLetes.NuevoIngreso(Coleccion, Instrumento, EmpaquetarTablaBaseDatos)
  735. Coleccion.Clear()
  736. End If
  737. End Sub
  738. Private Sub Eliminar(ByVal Instrumento As String)
  739. oDAOLetes.Eliminar(Variables.Codigo, Instrumento)
  740. End Sub
  741. Private Sub btnAceptar_Click(sender As Object, e As EventArgs) Handles btnAceptar.Click
  742. If (TipoTransaccion = "M") Then
  743. Modificar(Instrumento)
  744. ValidarExistencia()
  745. ElseIf (TipoTransaccion = "N") Then
  746. NuevoRegistro(Instrumento)
  747. ValidarExistencia()
  748. ElseIf (TipoTransaccion = "B") Then
  749. Eliminar(Instrumento)
  750. ValidarExistencia()
  751. ElseIf Not ExisteValidacion() Then
  752. Variables.ColeccionLETE = Nuevo(Instrumento)
  753. If VCN Then
  754. Variables.EmpaquetarTablaBaseDatos = CalculosTablaDiasFecha.EmpaquetarTablaBaseDatos(dgvIngresosVCN)
  755. End If
  756. Close()
  757. End If
  758. End Sub
  759. Function RetornarObjeto()
  760. Return oCELetes
  761. End Function
  762. Sub CargarCasasCorredoras()
  763. If Me.cboCasasCorredoras.Items.Count = 0 Or Me.cboCasasCorredoras.Items.Count = 1 Then
  764. Me.cboCasasCorredoras.DataSource = oDAOGeneral.ListaCasasCorredoras.Tables("CasasCorredoras")
  765. Me.cboCasasCorredoras.DisplayMember = "Descripcion"
  766. Me.cboCasasCorredoras.ValueMember = "Codigo"
  767. Me.cboCasasCorredoras.SelectedIndex = 0
  768. End If
  769. End Sub
  770. Sub CargarPeriodicidad()
  771. If cboPeriodicidad.Items.Count = 0 Or cboPeriodicidad.Items.Count = 1 Then
  772. Me.cboPeriodicidad.DataSource = oDAOGeneral.ListaPeriodicidad
  773. Me.cboPeriodicidad.DisplayMember = "Descripcion"
  774. Me.cboPeriodicidad.ValueMember = "Codigo"
  775. Me.cboPeriodicidad.SelectedIndex = 0
  776. End If
  777. End Sub
  778. Sub CargarBase()
  779. If Me.cboBase.Items.Count = 0 Or Me.cboBase.Items.Count = 1 Then
  780. Me.cboBase.DataSource = oDAOGeneral.ListaBase
  781. Me.cboBase.DisplayMember = "Descripcion"
  782. Me.cboBase.ValueMember = "Codigo"
  783. Me.cboBase.SelectedIndex = 0
  784. End If
  785. End Sub
  786. Private Sub CargarRegistroBD()
  787. Dim oCELetes As LETESCE
  788. CodigoInversion = Variables.Codigo
  789. If Not oCELetes Is Nothing Then
  790. Dim vValorNominal As Double = oCELetes.ValorNominal
  791. Dim vFechaOperacion As Date = oCELetes.FechaOperacion
  792. Dim vFechaLiquidacion As Date = oCELetes.FechaLiquidacion
  793. Dim vFechaVencimiento As Date = oCELetes.FechaVencimiento
  794. Dim vPlazoInversion As Integer = oCELetes.Plazo
  795. Dim vCodigoCasa As String = oCELetes.CodigoCasa
  796. Dim vPeriodicidad As String = oCELetes.Periodicidad
  797. Dim vRendimientoBruto As Double = oCELetes.RendimientoBruto
  798. Dim vRendimientoNeto As Double = oCELetes.RendimientoNeto
  799. Dim vIngresoBruto As Double = oCELetes.IngresoBruto
  800. Dim vIngresoNeto As Double = oCELetes.IngresoNeto
  801. Dim vValorTransado As Double = oCELetes.ValorNominal
  802. Dim vPrecio As Double = oCELetes.Precio
  803. Dim vTotalAPagar As Double = oCELetes.TotalaPagar
  804. vRendimientoBruto = vRendimientoBruto * 100
  805. vRendimientoNeto = vRendimientoNeto * 100
  806. vPrecio = vPrecio * 100
  807. End If
  808. End Sub
  809. Public Sub CargarRegistro(vId As Integer, vTipo As String)
  810. Modo = "C"
  811. IdDocumento = vId
  812. TipoDocumento = vTipo
  813. End Sub
  814. Private Sub txtRendimientoBruto_MouseCaptureChanged(sender As Object, e As EventArgs) Handles txtRendimientoBruto.MouseCaptureChanged
  815. End Sub
  816. Function ValorTrasado()
  817. Return Operaciones.ConvertirDecimal(txtValorNominal.Text.ToString) *
  818. (Operaciones.ConvertirDecimal(V_txtPrecio.ToString) / 100)
  819. End Function
  820. Function Precio()
  821. Dim Rendimiento As Double = Operaciones.ConvertirDecimal(txtRendimientoBruto.Text.ToString)
  822. Dim Plazo As Integer = Operaciones.ConvertirDecimal(txtPlazoInversion.Text.ToString)
  823. Dim Pr = 0.0
  824. If (IndexBase = 0) Then
  825. Pr = ((1 - ((Rendimiento / 100) / (1 + (Rendimiento / 100) * Plazo / 360)) * Plazo / 360)) * 100
  826. Return Pr
  827. ElseIf (IndexBase = 1) Then
  828. Dim FechaInicial = dtpFechaLiquidacion.Value
  829. Dim FechaFinal = dtpFechaVencimiento.Value
  830. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  831. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  832. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase(FechaInicial)
  833. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase(FechaFinal)
  834. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  835. If (Not CambioDeFecha = 0) Then
  836. If CambioDeFecha = 1 Then
  837. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  838. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  839. PrOpc1 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasPrimeraFecha / 366)) * DiasPrimeraFecha / 366))
  840. PrOpc2 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasSegundaFecha / 365)) * DiasSegundaFecha / 365))
  841. ElseIf CambioDeFecha = 2 Then
  842. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  843. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  844. PrOpc1 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasPrimeraFecha / 365)) * DiasPrimeraFecha / 365))
  845. PrOpc2 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasSegundaFecha / 366)) * DiasSegundaFecha / 366))
  846. End If
  847. Pr = (1 - (PrOpc1 + PrOpc2)) * 100
  848. Else
  849. If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then
  850. Pr = ((1 - ((Rendimiento / 100) / (1 + (Rendimiento / 100) * Plazo / 365)) * Plazo / 365)) * 100
  851. End If
  852. If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then
  853. Pr = ((1 - ((Rendimiento / 100) / (1 + (Rendimiento / 100) * Plazo / 366)) * Plazo / 366)) * 100
  854. End If
  855. End If
  856. Return Pr
  857. ElseIf (IndexBase = 2) Then
  858. ''''''''''''''''''
  859. Dim FechaInicial = dtpFechaLiquidacion.Value
  860. Dim FechaFinal = dtpFechaVencimiento.Value
  861. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  862. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  863. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase360(FechaInicial)
  864. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase360(FechaFinal)
  865. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  866. If (Not CambioDeFecha = 0) Then
  867. If CambioDeFecha = 1 Then
  868. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  869. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  870. PrOpc1 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasPrimeraFecha / 366)) * DiasPrimeraFecha / 366))
  871. PrOpc2 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasSegundaFecha / 365)) * DiasSegundaFecha / 365))
  872. ElseIf CambioDeFecha = 2 Then
  873. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  874. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  875. PrOpc1 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasPrimeraFecha / 365)) * DiasPrimeraFecha / 365))
  876. PrOpc2 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasSegundaFecha / 366)) * DiasSegundaFecha / 366))
  877. End If
  878. Pr = (1 - (PrOpc1 + PrOpc2)) * 100
  879. Else
  880. If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then
  881. Pr = ((1 - ((Rendimiento / 100) / (1 + (Rendimiento / 100) * Plazo / 365)) * Plazo / 365)) * 100
  882. End If
  883. If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then
  884. Pr = ((1 - ((Rendimiento / 100) / (1 + (Rendimiento / 100) * Plazo / 366)) * Plazo / 366)) * 100
  885. End If
  886. End If
  887. Return Pr
  888. Else
  889. Dim FechaInicial = dtpFechaLiquidacion.Value
  890. Dim FechaFinal = dtpFechaVencimiento.Value
  891. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  892. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  893. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase(FechaInicial)
  894. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase(FechaFinal)
  895. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  896. If (Not CambioDeFecha = 0) Then
  897. If CambioDeFecha = 1 Then
  898. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  899. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  900. PrOpc1 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasPrimeraFecha / 360)) * DiasPrimeraFecha / 360))
  901. PrOpc2 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasSegundaFecha / 360)) * DiasSegundaFecha / 360))
  902. ElseIf CambioDeFecha = 2 Then
  903. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  904. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  905. PrOpc1 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasPrimeraFecha / 360)) * DiasPrimeraFecha / 360))
  906. PrOpc2 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasSegundaFecha / 360)) * DiasSegundaFecha / 360))
  907. End If
  908. Pr = (1 - (PrOpc1 + PrOpc2)) * 100
  909. Else
  910. Pr = ((1 - ((Rendimiento / 100) / (1 + (Rendimiento / 100) * Plazo / 360)) * Plazo / 360)) * 100
  911. End If
  912. Return Pr
  913. End If
  914. Return 0
  915. End Function
  916. Function ComisionCasa()
  917. Dim ValorTras As Double = ValorTrasado()
  918. Dim ComisionDeCasa As Double = Operaciones.ConvertirDecimal(txtPorcentajeComisionCasa.Text.ToString)
  919. Dim PlazoInversion As Integer = Operaciones.ConvertirEntero(txtPlazoInversion.Text.ToString)
  920. Dim Comision = 0.0
  921. If (IndexBase = 0) Then
  922. Comision = (ValorTras * ComisionDeCasa / 100) * (PlazoInversion / 360)
  923. Return Comision
  924. ElseIf IndexBase = 1 Then
  925. Dim FechaInicial = dtpFechaLiquidacion.Value
  926. Dim FechaFinal = dtpFechaVencimiento.Value
  927. Dim ComisionOpc1 = 0.0, ComisionOpc2 = 0.0
  928. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  929. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase(FechaInicial)
  930. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase(FechaFinal)
  931. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  932. If (Not CambioDeFecha = 0) Then
  933. If CambioDeFecha = 1 Then
  934. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  935. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  936. ComisionOpc1 = (ValorTras * ComisionDeCasa / 100) * (DiasPrimeraFecha / 366)
  937. ComisionOpc2 = (ValorTras * ComisionDeCasa / 100) * (DiasSegundaFecha / 365)
  938. ElseIf CambioDeFecha = 2 Then
  939. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  940. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  941. ComisionOpc1 = (ValorTras * ComisionDeCasa / 100) * (DiasPrimeraFecha / 365)
  942. ComisionOpc2 = (ValorTras * ComisionDeCasa / 100) * (DiasSegundaFecha / 366)
  943. End If
  944. Comision = ComisionOpc1 + ComisionOpc2
  945. Else
  946. If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then
  947. Comision = (ValorTras * ComisionDeCasa / 100) * (PlazoInversion / 365)
  948. End If
  949. If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then
  950. Comision = (ValorTras * ComisionDeCasa / 100) * (PlazoInversion / 366)
  951. End If
  952. End If
  953. Return Comision
  954. ElseIf IndexBase = 2 Then
  955. Dim FechaInicial = dtpFechaLiquidacion.Value
  956. Dim FechaFinal = dtpFechaVencimiento.Value
  957. Dim ComisionOpc1 = 0.0, ComisionOpc2 = 0.0
  958. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  959. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase360(FechaInicial)
  960. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase360(FechaFinal)
  961. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  962. If (Not CambioDeFecha = 0) Then
  963. If CambioDeFecha = 1 Then
  964. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  965. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  966. ComisionOpc1 = (ValorTras * ComisionDeCasa / 100) * (DiasPrimeraFecha / 366)
  967. ComisionOpc2 = (ValorTras * ComisionDeCasa / 100) * (DiasSegundaFecha / 365)
  968. ElseIf CambioDeFecha = 2 Then
  969. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  970. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  971. ComisionOpc1 = (ValorTras * ComisionDeCasa / 100) * (DiasPrimeraFecha / 365)
  972. ComisionOpc2 = (ValorTras * ComisionDeCasa / 100) * (DiasSegundaFecha / 366)
  973. End If
  974. Comision = ComisionOpc1 + ComisionOpc2
  975. Else
  976. If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then
  977. Comision = (ValorTras * ComisionDeCasa / 100) * (PlazoInversion / 365)
  978. End If
  979. If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then
  980. Comision = (ValorTras * ComisionDeCasa / 100) * (PlazoInversion / 366)
  981. End If
  982. End If
  983. Return Comision
  984. Else
  985. Comision = (ValorTras * ComisionDeCasa / 100) * (PlazoInversion / 360)
  986. Return Comision
  987. End If
  988. Return 0
  989. End Function
  990. Function ComisionBolsa()
  991. Dim ValorTras As Double = ValorTrasado()
  992. Dim ComisionDeBolsa As Double = Operaciones.ConvertirDecimal(txtPorcentajeComisionBolsa.Text.ToString)
  993. Dim PlazoInversion As Integer = Operaciones.ConvertirEntero(txtPlazoInversion.Text.ToString)
  994. Dim Comision As Double = 0.0
  995. If (IndexBase = 0) Then
  996. Comision = (ValorTras * ComisionDeBolsa / 100) * (PlazoInversion / 360)
  997. Return Comision
  998. ElseIf IndexBase = 1 Then
  999. Dim FechaInicial = dtpFechaLiquidacion.Value
  1000. Dim FechaFinal = dtpFechaVencimiento.Value
  1001. Dim ComisionOpc1 = 0.0, ComisionOpc2 = 0.0
  1002. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  1003. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase(FechaInicial)
  1004. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase(FechaFinal)
  1005. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1006. If (Not CambioDeFecha = 0) Then
  1007. If CambioDeFecha = 1 Then
  1008. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1009. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1010. ComisionOpc1 = (ValorTras * ComisionDeBolsa / 100) * (DiasPrimeraFecha / 366)
  1011. ComisionOpc2 = (ValorTras * ComisionDeBolsa / 100) * (DiasSegundaFecha / 365)
  1012. ElseIf CambioDeFecha = 2 Then
  1013. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1014. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1015. ComisionOpc1 = (ValorTras * ComisionDeBolsa / 100) * (DiasPrimeraFecha / 365)
  1016. ComisionOpc2 = (ValorTras * ComisionDeBolsa / 100) * (DiasSegundaFecha / 366)
  1017. End If
  1018. Comision = ComisionOpc1 + ComisionOpc2
  1019. Else
  1020. If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then
  1021. Comision = (ValorTras * ComisionDeBolsa / 100) * (PlazoInversion / 365)
  1022. End If
  1023. If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then
  1024. Comision = (ValorTras * ComisionDeBolsa / 100) * (PlazoInversion / 366)
  1025. End If
  1026. End If
  1027. Return Comision
  1028. ElseIf IndexBase = 2 Then
  1029. Dim FechaInicial = dtpFechaLiquidacion.Value
  1030. Dim FechaFinal = dtpFechaVencimiento.Value
  1031. Dim ComisionOpc1 = 0.0, ComisionOpc2 = 0.0
  1032. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  1033. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase360(FechaInicial)
  1034. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase360(FechaFinal)
  1035. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1036. If (Not CambioDeFecha = 0) Then
  1037. If CambioDeFecha = 1 Then
  1038. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1039. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1040. ComisionOpc1 = (ValorTras * ComisionDeBolsa / 100) * (DiasPrimeraFecha / 366)
  1041. ComisionOpc2 = (ValorTras * ComisionDeBolsa / 100) * (DiasSegundaFecha / 365)
  1042. ElseIf CambioDeFecha = 2 Then
  1043. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1044. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1045. ComisionOpc1 = (ValorTras * ComisionDeBolsa / 100) * (DiasPrimeraFecha / 365)
  1046. ComisionOpc2 = (ValorTras * ComisionDeBolsa / 100) * (DiasSegundaFecha / 366)
  1047. End If
  1048. Comision = ComisionOpc1 + ComisionOpc2
  1049. Else
  1050. If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then
  1051. Comision = (ValorTras * ComisionDeBolsa / 100) * (PlazoInversion / 365)
  1052. End If
  1053. If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then
  1054. Comision = (ValorTras * ComisionDeBolsa / 100) * (PlazoInversion / 366)
  1055. End If
  1056. End If
  1057. Return Comision
  1058. Else
  1059. Comision = (ValorTras * ComisionDeBolsa / 100) * (PlazoInversion / 360)
  1060. Return Comision
  1061. End If
  1062. Return 0
  1063. End Function
  1064. Function RendimientoNeto()
  1065. Dim ValorNominal As Double = Operaciones.ConvertirDecimal(txtValorNominal.Text.ToString)
  1066. Dim TotalPagar As Double = Operaciones.ConvertirDecimal(V_txtTotalAPagar.ToString)
  1067. Dim PlazoInversion As Integer = Operaciones.ConvertirEntero(txtPlazoInversion.Text.ToString)
  1068. Dim RendBruto As Double = 0
  1069. Dim ComisionCasa As Double = 0
  1070. Dim ComisionBolsa As Double = 0
  1071. If Not String.IsNullOrEmpty(txtRendimientoBruto.Text.ToString.Trim("%")) Then
  1072. RendBruto = txtRendimientoBruto.Text.ToString.Trim("%")
  1073. End If
  1074. If Not String.IsNullOrEmpty(txtPorcentajeComisionCasa.Text.ToString.Trim("%")) Then
  1075. ComisionCasa = txtPorcentajeComisionCasa.Text.ToString.Trim("%")
  1076. End If
  1077. If Not String.IsNullOrEmpty(txtPorcentajeComisionBolsa.Text.ToString.Trim("%")) Then
  1078. ComisionBolsa = txtPorcentajeComisionBolsa.Text.ToString.Trim("%")
  1079. End If
  1080. If (CDec(TotalPagar) = 0 Or CDec(PlazoInversion) = 0) Then
  1081. Return 0
  1082. End If
  1083. If (Double.TryParse(RendBruto, Nothing) And Double.TryParse(RendBruto, Nothing) And Double.TryParse(CDec(ValorNominal), Nothing) And Double.TryParse(CDec(TotalPagar), Nothing) And Double.TryParse(CDec(PlazoInversion), Nothing)) Then
  1084. Dim RendimientoNet As Double = 0
  1085. If ((chbValorPar.Checked And (VCN Or PBUR))) Then
  1086. RendimientoNet = (RendBruto - ComisionCasa - ComisionBolsa) * 0.9
  1087. Return RendimientoNet
  1088. ElseIf CET Then
  1089. RendimientoNet = (RendBruto - ComisionCasa - ComisionBolsa)
  1090. Return RendimientoNet
  1091. Else
  1092. If (IndexBase = 0) Then
  1093. RendimientoNet = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (360 / CDec(PlazoInversion))) * 100)
  1094. Return RendimientoNet
  1095. ElseIf IndexBase = 1 Then
  1096. Dim FechaInicial = dtpFechaLiquidacion.Value
  1097. Dim FechaFinal = dtpFechaVencimiento.Value
  1098. Dim RendimientoNetOpc1 = 0.0, RendimientoNetOpc2 = 0.0
  1099. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  1100. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase(FechaInicial)
  1101. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase(FechaFinal)
  1102. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1103. If (Not CambioDeFecha = 0) Then
  1104. If CambioDeFecha = 1 Then
  1105. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1106. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1107. RendimientoNetOpc1 = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (366 / CDec(DiasPrimeraFecha))) * 100)
  1108. RendimientoNetOpc2 = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (365 / CDec(DiasSegundaFecha))) * 100)
  1109. ElseIf CambioDeFecha = 2 Then
  1110. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1111. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1112. RendimientoNetOpc1 = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (365 / CDec(DiasPrimeraFecha))) * 100)
  1113. RendimientoNetOpc2 = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (366 / CDec(DiasSegundaFecha))) * 100)
  1114. End If
  1115. RendimientoNet = RendimientoNetOpc1 + RendimientoNetOpc2
  1116. Else
  1117. If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then
  1118. RendimientoNet = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (365 / CDec(PlazoInversion))) * 100)
  1119. End If
  1120. If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then
  1121. RendimientoNet = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (366 / CDec(PlazoInversion))) * 100)
  1122. End If
  1123. End If
  1124. Return RendimientoNet
  1125. ElseIf IndexBase = 2 Then
  1126. Dim FechaInicial = dtpFechaLiquidacion.Value
  1127. Dim FechaFinal = dtpFechaVencimiento.Value
  1128. Dim RendimientoNetOpc1 = 0.0, RendimientoNetOpc2 = 0.0
  1129. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  1130. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase360(FechaInicial)
  1131. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase360(FechaFinal)
  1132. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1133. If (Not CambioDeFecha = 0) Then
  1134. If CambioDeFecha = 1 Then
  1135. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1136. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1137. RendimientoNetOpc1 = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (366 / CDec(DiasPrimeraFecha))) * 100)
  1138. RendimientoNetOpc2 = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (365 / CDec(DiasSegundaFecha))) * 100)
  1139. ElseIf CambioDeFecha = 2 Then
  1140. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1141. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1142. RendimientoNetOpc1 = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (365 / CDec(DiasPrimeraFecha))) * 100)
  1143. RendimientoNetOpc2 = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (366 / CDec(DiasSegundaFecha))) * 100)
  1144. End If
  1145. RendimientoNet = RendimientoNetOpc1 + RendimientoNetOpc2
  1146. Else
  1147. If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then
  1148. RendimientoNet = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (365 / CDec(PlazoInversion))) * 100)
  1149. End If
  1150. If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then
  1151. RendimientoNet = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (366 / CDec(PlazoInversion))) * 100)
  1152. End If
  1153. End If
  1154. Return RendimientoNet
  1155. Else
  1156. RendimientoNet = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (360 / CDec(PlazoInversion))) * 100)
  1157. Return RendimientoNet
  1158. End If
  1159. End If
  1160. End If
  1161. Return 0
  1162. End Function
  1163. Function IngresoBruto()
  1164. Dim ValorNominal As Double = 0
  1165. Dim ValorTrasado As Double = 0
  1166. ValorNominal = Operaciones.ConvertirDecimal(txtValorNominal.Text.ToString)
  1167. ValorTrasado = Operaciones.ConvertirDecimal(V_txtValorTransado.ToString)
  1168. Dim TasaPeriodo = Operaciones.ConvertirDecimal(txtRendimientoBruto.Text.ToString)
  1169. TasaPeriodo = Operaciones.ConvertirDecimal(txtRendimientoBruto.Text.ToString) / 100
  1170. Dim Base As Integer = 365
  1171. Dim Bruto As Double = 0
  1172. Dim Plazo As Integer = 0
  1173. Plazo = Operaciones.ConvertirEntero(txtPlazoInversion.Text.ToString)
  1174. If (chbValorPar.Checked Or CET) Then
  1175. Dim PlazoDias As Integer = 0
  1176. Dim Fecha1 = dtpFechaLiquidacion.Value
  1177. Dim Fecha2 = dtpFechaVencimiento.Value
  1178. IndexBase = cboBase.SelectedIndex
  1179. Dim Valor As Double = 0
  1180. If (IndexBase = 0) Then
  1181. Valor = CDec(ValorNominal * TasaPeriodo * Plazo) / 360
  1182. Return Valor
  1183. ElseIf (IndexBase = 1) Then
  1184. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1185. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1186. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1187. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1188. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1189. PrOpc1 = CDec(ValorNominal * TasaPeriodo * DiasPrimeraFecha) / 366
  1190. PrOpc2 = CDec(ValorNominal * TasaPeriodo * DiasSegundaFecha) / 365
  1191. Valor = PrOpc1 + PrOpc2
  1192. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1193. Valor = CDec(ValorNominal * TasaPeriodo * DiasSegundaFecha) / 365
  1194. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1195. Valor = CDec(ValorNominal * TasaPeriodo * DiasPrimeraFecha) / 366
  1196. Else
  1197. Valor = 0
  1198. End If
  1199. Return Valor
  1200. ElseIf (IndexBase = 2) Then
  1201. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1202. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1203. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
  1204. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
  1205. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1206. PrOpc1 = CDec(ValorNominal * TasaPeriodo * DiasPrimeraFecha) / 366
  1207. PrOpc2 = CDec(ValorNominal * TasaPeriodo * DiasSegundaFecha) / 365
  1208. Valor = PrOpc1 + PrOpc2
  1209. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1210. Valor = CDec(ValorNominal * TasaPeriodo * DiasSegundaFecha) / 365
  1211. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1212. Valor = CDec(ValorNominal * TasaPeriodo * DiasPrimeraFecha) / 366
  1213. Else
  1214. Valor = 0
  1215. End If
  1216. Return Valor
  1217. Else
  1218. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1219. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1220. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1221. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1222. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1223. PrOpc1 = CDec(ValorNominal * TasaPeriodo * DiasPrimeraFecha) / 360
  1224. PrOpc2 = CDec(ValorNominal * TasaPeriodo * DiasSegundaFecha) / 360
  1225. Valor = PrOpc1 + PrOpc2
  1226. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1227. Valor = CDec(ValorNominal * TasaPeriodo * DiasSegundaFecha) / 360
  1228. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1229. Valor = CDec(ValorNominal * TasaPeriodo * DiasPrimeraFecha) / 360
  1230. Else
  1231. Valor = 0
  1232. End If
  1233. Return Valor
  1234. End If
  1235. Else
  1236. If (Double.TryParse(ValorNominal, Nothing) And Double.TryParse(ValorTrasado, Nothing)) Then
  1237. Bruto = CDec(ValorNominal) - CDec(ValorTrasado)
  1238. Return Bruto
  1239. End If
  1240. End If
  1241. Return 0
  1242. End Function
  1243. Function IngresoNeto()
  1244. Dim ValorNominal As Double = Operaciones.ConvertirDecimal(txtValorNominal.Text.ToString)
  1245. Dim TotalPagar As Double = Operaciones.ConvertirDecimal(V_txtTotalAPagar.ToString)
  1246. Dim Neto As Double = 0
  1247. If chbValorPar.Checked Or CET Then
  1248. Dim IngBruto = Operaciones.ConvertirDecimal(txtIngresoBruto.Text.ToString)
  1249. Dim Descuentos = (Operaciones.ConvertirDecimal(txtComisionBolsa.Text.ToString) + Operaciones.ConvertirDecimal(txtComisionCasa.Text.ToString))
  1250. Neto = (IngBruto * 0.9) - Descuentos
  1251. Return Neto
  1252. End If
  1253. If (Double.TryParse(ValorNominal, Nothing) And Double.TryParse(TotalPagar, Nothing)) Then
  1254. Neto = CDec(ValorNominal) - CDec(TotalPagar)
  1255. Return Neto
  1256. End If
  1257. Return 0
  1258. End Function
  1259. Function TotalPagar()
  1260. Dim ValorTrasado As Double = Operaciones.ConvertirDecimal(V_txtValorTransado.ToString)
  1261. Dim ComisionCasa As Double = Operaciones.ConvertirDecimal(V_txtComisionCasa.ToString)
  1262. Dim ComisionBolsa As Double = Operaciones.ConvertirDecimal(V_txtComisionBolsa.ToString)
  1263. Dim OtrCost As Double = Operaciones.ConvertirDecimal(txtOtrosCostos.Text.ToString)
  1264. txtInteresAcumulado.Text = Operaciones.ConvertirDecimal(txtInteresAcumulado.Text.ToString)
  1265. Dim InteresAcumulado = Operaciones.ConvertirDecimal(txtInteresAcumulado.Text.ToString)
  1266. If (PBUR Or CET) Then
  1267. If (Double.TryParse(ValorTrasado, Nothing) And Double.TryParse(ComisionCasa, Nothing) And Double.TryParse(ComisionBolsa, Nothing)) Then
  1268. Dim Total = CDec(ValorTrasado) + CDec(ComisionCasa) + CDec(ComisionBolsa) + InteresAcumulado
  1269. Return Total
  1270. End If
  1271. ElseIf VCN Then
  1272. If (Double.TryParse(ValorTrasado, Nothing) And Double.TryParse(ComisionCasa, Nothing) And Double.TryParse(ComisionBolsa, Nothing)) Then
  1273. Dim Total = CDec(ValorTrasado) + CDec(ComisionCasa) + CDec(ComisionBolsa) + InteresAcumulado + OtrCost
  1274. Return Total
  1275. End If
  1276. Else
  1277. If (Double.TryParse(ValorTrasado, Nothing) And Double.TryParse(ComisionCasa, Nothing) And Double.TryParse(ComisionBolsa, Nothing)) Then
  1278. Dim Total = CDec(ValorTrasado) + CDec(ComisionCasa) + CDec(ComisionBolsa)
  1279. Return Total
  1280. End If
  1281. End If
  1282. Return 0
  1283. End Function
  1284. Sub Rellenar()
  1285. If (String.IsNullOrEmpty(txtOtrosCostos.Text.ToString)) Then
  1286. txtOtrosCostos.Text = "0.0"
  1287. End If
  1288. If (String.IsNullOrEmpty(txtPlazoInversion.Text.ToString)) Then
  1289. txtPlazoInversion.Text = "0.0"
  1290. End If
  1291. If (String.IsNullOrEmpty(txtValorNominal.Text.ToString.Trim("%"))) Then
  1292. txtValorNominal.Text = 0
  1293. txtValorNominal.Text = Format(txtValorNominal.Text, "0.0")
  1294. End If
  1295. If (String.IsNullOrEmpty(txtPorcentajeComisionCasa.Text.ToString.Trim("%"))) Then
  1296. txtPorcentajeComisionCasa.Text = 0
  1297. txtPorcentajeComisionCasa.Text = Format(txtPorcentajeComisionCasa.Text, "0.0")
  1298. End If
  1299. If (String.IsNullOrEmpty(txtPorcentajeComisionBolsa.Text.ToString.Trim("%"))) Then
  1300. txtPorcentajeComisionBolsa.Text = 0
  1301. txtPorcentajeComisionBolsa.Text = Format(txtPorcentajeComisionBolsa.Text, "0.0")
  1302. End If
  1303. If (String.IsNullOrEmpty(txtRendimientoBruto.Text.ToString.Trim("%"))) Then
  1304. txtRendimientoBruto.Text = 0
  1305. txtRendimientoBruto.Text = Format(txtRendimientoBruto.Text, "0.0")
  1306. End If
  1307. If (String.IsNullOrEmpty(txtInteresAcumulado.Text.ToString.Trim("%"))) Then
  1308. txtInteresAcumulado.Text = "0.0%"
  1309. End If
  1310. If (txtPorcentajeComisionCasa.Text.ToString.IndexOf("%") = -1) Then
  1311. txtPorcentajeComisionCasa.Text += "%"
  1312. End If
  1313. If (txtPorcentajeComisionBolsa.ToString.IndexOf("%") = -1) Then
  1314. txtPorcentajeComisionBolsa.Text += "%"
  1315. End If
  1316. If (txtRendimientoBruto.ToString.IndexOf("%") = -1) Then
  1317. txtRendimientoBruto.Text += "%"
  1318. End If
  1319. End Sub
  1320. Sub RellenarDatos()
  1321. If (cboBase.SelectedIndex = 0) Then
  1322. IndexBase = 0
  1323. ElseIf (cboBase.SelectedIndex = 1) Then
  1324. IndexBase = 1
  1325. ElseIf (cboBase.SelectedIndex = 2) Then
  1326. IndexBase = 2
  1327. ElseIf (cboBase.SelectedIndex = 3) Then
  1328. IndexBase = 3
  1329. End If
  1330. Dim FechaOperacion = Date.Now.Date, FechaLiquidacion = Date.Now.Date
  1331. AgregarDias()
  1332. If (CET) Then
  1333. V_txtPrecio = "100"
  1334. Else
  1335. If (chbValorPar.Checked) Then
  1336. V_txtPrecio = "100"
  1337. txtPrecio.Text = "100%"
  1338. Else
  1339. txtPrecio.Text = Format(Precio(), "0.0000")
  1340. V_txtPrecio = Format(Precio(), "0.000000000")
  1341. End If
  1342. End If
  1343. txtValorTransado.Text = Format(ValorTrasado(), "0.0000")
  1344. V_txtValorTransado = Format(ValorTrasado(), "0.000000000")
  1345. txtComisionCasa.Text = Format(ComisionCasa(), "0.0000")
  1346. V_txtComisionCasa = Format(ComisionCasa(), "0.000000000")
  1347. txtComisionBolsa.Text = Format(ComisionBolsa(), "0.0000")
  1348. V_txtComisionBolsa = Format(ComisionBolsa(), "0.000000000")
  1349. txtIngresoBruto.Text = Format(IngresoBruto(), "0.0000")
  1350. V_txtIngresoBruto = Format(IngresoBruto(), "0.000000000")
  1351. FechaOperacion = dtpFechaOperacion.Value
  1352. FechaLiquidacion = dtpFechaLiquidacion.Value
  1353. 'txtDiasAcumulados.Text = Operaciones.DiasAcumulados(FechaOperacion, FechaLiquidacion, 1).ToString()
  1354. Dim Dias = 0
  1355. Dim Fecha As String = Format(dtpUltimaFecha.Value, "yyyy/MM/dd")
  1356. dtpUltimaFecha.Value = Fecha
  1357. Dim FechaLiq As String = Format(dtpFechaLiquidacion.Value, "yyyy/MM/dd")
  1358. dtpFechaLiquidacion.Value = FechaLiq
  1359. If (IndexBase = 0 Or IndexBase = 2) Then
  1360. Dias = Operaciones.Base360(dtpUltimaFecha.Value, dtpFechaLiquidacion.Value)
  1361. ElseIf IndexBase = 1 Or IndexBase = 3 Then
  1362. Dias = Operaciones.Base365(dtpUltimaFecha.Value, dtpFechaLiquidacion.Value)
  1363. End If
  1364. V_txtDiasAcumulados = Dias
  1365. Dim ValorNominal, RendBruto
  1366. ValorNominal = txtValorNominal.Text
  1367. If String.IsNullOrEmpty(ValorNominal.ToString) Then
  1368. ValorNominal = 0
  1369. End If
  1370. RendBruto = txtRendimientoBruto.Text
  1371. If String.IsNullOrEmpty(RendBruto.ToString.Trim("%")) Then
  1372. RendBruto = 0
  1373. Else
  1374. RendBruto = txtRendimientoBruto.Text.TrimEnd("%") / 100
  1375. End If
  1376. txtInteresAcumulado.Text = Format(CDec(Operaciones.InteresAcumuladoPBUR(ValorNominal, RendBruto, V_txtDiasAcumulados, IndexBase, dtpUltimaFecha.Value, dtpFechaLiquidacion.Value)), "0.0000").ToString + "%"
  1377. txtTotalAPagar.Text = Format(TotalPagar(), "0.0000")
  1378. V_txtTotalAPagar = Format(TotalPagar(), "0.000000000")
  1379. txtIngresoNeto.Text = Format(IngresoNeto(), "0.0000")
  1380. V_txtIngresoNeto = Format(IngresoNeto(), "0.000000000")
  1381. txtRendimientoNeto.Text = Format(RendimientoNeto(), "0.0000")
  1382. V_txtRendimientoNeto = Format(RendimientoNeto(), "0.000000000")
  1383. AgregarPorcentaje()
  1384. If VCN And CargaCompletaInstrumento Then
  1385. CalculosIngresosVCN("Global")
  1386. End If
  1387. End Sub
  1388. Private Sub Button1_Click_1(sender As Object, e As EventArgs)
  1389. End Sub
  1390. Sub AgregarDias()
  1391. Dim Dias As Integer = 0
  1392. If Not String.IsNullOrEmpty(txtPlazoInversion.Text) Then
  1393. Dias = txtPlazoInversion.Text
  1394. End If
  1395. Dim Fechaliquidacion = Operaciones.ConvertirFecha(dtpFechaLiquidacion.Value.ToString)
  1396. Dim FechaVencimiento = Operaciones.ConvertirFecha(dtpFechaVencimiento.Value.ToString)
  1397. If (IndexBase = 0 Or IndexBase = 2) Then
  1398. If VCN And CargaCompletaInstrumento Then
  1399. txtPlazoInversion.Text = Operaciones.Base360(Fechaliquidacion, FechaVencimiento)
  1400. Else
  1401. dtpFechaVencimiento.Value = Operaciones.FechaDias360(Fechaliquidacion, Dias)
  1402. End If
  1403. ElseIf IndexBase = 1 Or IndexBase = 3 Then
  1404. If VCN And CargaCompletaInstrumento Then
  1405. txtPlazoInversion.Text = Operaciones.Base365(Fechaliquidacion, FechaVencimiento)
  1406. Else
  1407. dtpFechaVencimiento.Value = dtpFechaLiquidacion.Value.AddDays(Dias)
  1408. End If
  1409. End If
  1410. End Sub
  1411. Sub AgregarPorcentaje()
  1412. If (txtRendimientoBruto.ToString.IndexOf("%") = -1) Then
  1413. txtRendimientoBruto.Text += "%"
  1414. End If
  1415. If (txtPorcentajeComisionCasa.Text.ToString.IndexOf("%") = -1) Then
  1416. txtPorcentajeComisionCasa.Text += "%"
  1417. End If
  1418. If (txtPorcentajeComisionBolsa.ToString.IndexOf("%") = -1) Then
  1419. txtPorcentajeComisionBolsa.Text += "%"
  1420. End If
  1421. If (txtRendimientoNeto.ToString.IndexOf("%") = -1) Then
  1422. txtRendimientoNeto.Text += "%"
  1423. End If
  1424. If (txtPrecio.ToString.IndexOf("%") = -1) Then
  1425. txtPrecio.Text += "%"
  1426. End If
  1427. End Sub
  1428. Private Sub txtRendimientoBruto_Leave(sender As Object, e As EventArgs) Handles txtRendimientoBruto.Leave
  1429. Rellenar()
  1430. End Sub
  1431. Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
  1432. TipoTransaccion = "M"
  1433. btnAceptar.Text = "Modificar"
  1434. End Sub
  1435. Private Sub txtValorNominal_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtValorNominal.KeyPress
  1436. If String.IsNullOrEmpty(txtValorNominal.Text) Then
  1437. If e.KeyChar = "." Then
  1438. txtValorNominal.Text = "0"
  1439. Exit Sub
  1440. End If
  1441. End If
  1442. If (Not txtValorNominal.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1443. Operaciones.ValidarEntrada(sender, e, True)
  1444. Else
  1445. Operaciones.ValidarEntrada(sender, e, False)
  1446. End If
  1447. End Sub
  1448. Private Sub txtPlazoInversion_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPlazoInversion.KeyPress
  1449. If String.IsNullOrEmpty(txtPlazoInversion.Text) Then
  1450. If e.KeyChar = "." Then
  1451. txtPlazoInversion.Text = "0"
  1452. Exit Sub
  1453. End If
  1454. End If
  1455. If (Not txtPlazoInversion.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1456. Operaciones.ValidarEntrada(sender, e, True)
  1457. Else
  1458. Operaciones.ValidarEntrada(sender, e, False)
  1459. End If
  1460. End Sub
  1461. Private Sub txtPorcentajeComisionCasa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeComisionCasa.KeyPress
  1462. If String.IsNullOrEmpty(txtPorcentajeComisionCasa.Text) Then
  1463. If e.KeyChar = "." Then
  1464. txtPorcentajeComisionCasa.Text = "0"
  1465. Exit Sub
  1466. End If
  1467. End If
  1468. If (Not txtPorcentajeComisionCasa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1469. Operaciones.ValidarEntrada(sender, e, True)
  1470. Else
  1471. Operaciones.ValidarEntrada(sender, e, False)
  1472. End If
  1473. End Sub
  1474. Private Sub txtPorcentajeComisionBolsa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeComisionBolsa.KeyPress
  1475. If String.IsNullOrEmpty(txtPorcentajeComisionBolsa.Text) Then
  1476. If e.KeyChar = "." Then
  1477. txtPorcentajeComisionBolsa.Text = "0"
  1478. Exit Sub
  1479. End If
  1480. End If
  1481. If (Not txtPorcentajeComisionBolsa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1482. Operaciones.ValidarEntrada(sender, e, True)
  1483. Else
  1484. Operaciones.ValidarEntrada(sender, e, False)
  1485. End If
  1486. End Sub
  1487. Private Sub txtRendimientoBruto_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtRendimientoBruto.KeyPress
  1488. If String.IsNullOrEmpty(txtRendimientoBruto.Text) Then
  1489. If e.KeyChar = "." Then
  1490. txtRendimientoBruto.Text = "0"
  1491. Exit Sub
  1492. End If
  1493. End If
  1494. If (Not txtRendimientoBruto.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1495. Operaciones.ValidarEntrada(sender, e, True)
  1496. Else
  1497. Operaciones.ValidarEntrada(sender, e, False)
  1498. End If
  1499. End Sub
  1500. Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
  1501. TipoTransaccion = "N"
  1502. btnAceptar.Text = "Agregar"
  1503. End Sub
  1504. Private Sub chbValorPar_CheckedChanged(sender As Object, e As EventArgs) Handles chbValorPar.CheckedChanged
  1505. RellenarDatos()
  1506. End Sub
  1507. Private Sub txtRendimientoNeto_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoNeto.TextChanged
  1508. End Sub
  1509. Private Sub txtInteresAcumulado_TextChanged(sender As Object, e As EventArgs) Handles txtInteresAcumulado.TextChanged
  1510. End Sub
  1511. Private Sub txtIngresoBruto_TextChanged(sender As Object, e As EventArgs) Handles txtIngresoBruto.TextChanged
  1512. End Sub
  1513. Private Sub dtpUltimaFecha_ValueChanged(sender As Object, e As EventArgs)
  1514. RellenarDatos()
  1515. End Sub
  1516. Private Sub Label14_Click(sender As Object, e As EventArgs) Handles Label14.Click
  1517. End Sub
  1518. Private Sub cboPeriodicidad_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboPeriodicidad.SelectedIndexChanged
  1519. RellenarDatos()
  1520. End Sub
  1521. Private Sub cboCasasCorredoras_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboCasasCorredoras.SelectedIndexChanged
  1522. RellenarDatos()
  1523. End Sub
  1524. Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click
  1525. End Sub
  1526. Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
  1527. End Sub
  1528. Private Sub Label4_Click(sender As Object, e As EventArgs) Handles Label4.Click
  1529. End Sub
  1530. Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click
  1531. End Sub
  1532. Private Sub Label10_Click(sender As Object, e As EventArgs) Handles Label10.Click
  1533. End Sub
  1534. Private Sub Label5_Click(sender As Object, e As EventArgs) Handles Label5.Click
  1535. End Sub
  1536. Private Sub Label11_Click(sender As Object, e As EventArgs) Handles Label11.Click
  1537. End Sub
  1538. Private Sub txtIngresoNeto_TextChanged(sender As Object, e As EventArgs) Handles txtIngresoNeto.TextChanged
  1539. End Sub
  1540. Private Sub Label12_Click(sender As Object, e As EventArgs) Handles Label12.Click
  1541. End Sub
  1542. Private Sub Label13_Click(sender As Object, e As EventArgs) Handles Label13.Click
  1543. End Sub
  1544. Private Sub Label15_Click(sender As Object, e As EventArgs) Handles Label15.Click
  1545. End Sub
  1546. Private Sub Label16_Click(sender As Object, e As EventArgs) Handles Label16.Click
  1547. End Sub
  1548. Private Sub Label17_Click(sender As Object, e As EventArgs) Handles Label17.Click
  1549. End Sub
  1550. Private Sub Label6_Click(sender As Object, e As EventArgs) Handles Label6.Click
  1551. End Sub
  1552. Private Sub lblInteresAcumulado_Click(sender As Object, e As EventArgs) Handles lblInteresAcumulado.Click
  1553. End Sub
  1554. Private Sub dtpUltimaFecha_ValueChanged_1(sender As Object, e As EventArgs) Handles dtpUltimaFecha.ValueChanged
  1555. RellenarDatos()
  1556. End Sub
  1557. Private Sub txtOtrosCostos_TextChanged(sender As Object, e As EventArgs) Handles txtOtrosCostos.TextChanged
  1558. RellenarDatos()
  1559. End Sub
  1560. Private Sub txtOtrosCostos_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtOtrosCostos.KeyPress
  1561. If String.IsNullOrEmpty(txtOtrosCostos.Text) Then
  1562. If e.KeyChar = "." Then
  1563. txtOtrosCostos.Text = "0"
  1564. Exit Sub
  1565. End If
  1566. End If
  1567. If (Not txtOtrosCostos.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1568. Operaciones.ValidarEntrada(sender, e, True)
  1569. Else
  1570. Operaciones.ValidarEntrada(sender, e, False)
  1571. End If
  1572. End Sub
  1573. Private Sub btnRedencion_Click(sender As Object, e As EventArgs) Handles btnRedencion.Click
  1574. If (btnRedencion.Text = "Redención") Then
  1575. lblRedencion.Visible = True
  1576. dtpRedencion.Visible = True
  1577. btnRedencion.Text = "Cancelar"
  1578. Else
  1579. lblRedencion.Visible = False
  1580. dtpRedencion.Visible = False
  1581. btnRedencion.Text = "Redención"
  1582. End If
  1583. End Sub
  1584. Private Sub txtDiasAcumulados_TextChanged(sender As Object, e As EventArgs)
  1585. RellenarDatos()
  1586. End Sub
  1587. Private Sub txtValorNominal_Leave(sender As Object, e As EventArgs) Handles txtValorNominal.Leave
  1588. Rellenar()
  1589. End Sub
  1590. Private Sub txtPlazoInversion_Leave(sender As Object, e As EventArgs) Handles txtPlazoInversion.Leave
  1591. Rellenar()
  1592. End Sub
  1593. Private Sub txtOtrosCostos_Leave(sender As Object, e As EventArgs) Handles txtOtrosCostos.Leave
  1594. Rellenar()
  1595. End Sub
  1596. Private Sub txtValorNominal_ModifiedChanged(sender As Object, e As EventArgs) Handles txtValorNominal.ModifiedChanged
  1597. End Sub
  1598. Private Sub txtValorNominal_KeyUp(sender As Object, e As KeyEventArgs) Handles txtValorNominal.KeyUp
  1599. If txtValorNominal.Text = "." Then
  1600. txtValorNominal.Text = ".0"
  1601. End If
  1602. End Sub
  1603. Private Sub txtPlazoInversion_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPlazoInversion.KeyUp
  1604. If txtPlazoInversion.Text = "." Then
  1605. txtPlazoInversion.Text = ".0"
  1606. End If
  1607. End Sub
  1608. Private Sub txtPorcentajeComisionCasa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPorcentajeComisionCasa.KeyUp
  1609. If txtPorcentajeComisionCasa.Text = "." Then
  1610. txtPorcentajeComisionCasa.Text = ".0"
  1611. End If
  1612. End Sub
  1613. Private Sub txtPorcentajeComisionBolsa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPorcentajeComisionBolsa.KeyUp
  1614. If txtPorcentajeComisionBolsa.Text = "." Then
  1615. txtPorcentajeComisionBolsa.Text = ".0"
  1616. End If
  1617. End Sub
  1618. Private Sub txtRendimientoBruto_KeyUp(sender As Object, e As KeyEventArgs) Handles txtRendimientoBruto.KeyUp
  1619. If txtRendimientoBruto.Text = "." Then
  1620. txtRendimientoBruto.Text = ".0"
  1621. End If
  1622. End Sub
  1623. Private Sub txtOtrosCostos_KeyUp(sender As Object, e As KeyEventArgs) Handles txtOtrosCostos.KeyUp
  1624. If txtOtrosCostos.Text = "." Then
  1625. txtOtrosCostos.Text = ".0"
  1626. End If
  1627. End Sub
  1628. Private Sub dtpRedencion_ValueChanged(sender As Object, e As EventArgs) Handles dtpRedencion.ValueChanged
  1629. End Sub
  1630. Private Sub dgvIngresosVCN_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresosVCN.CellClick
  1631. End Sub
  1632. Private Sub dgvIngresosVCN_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresosVCN.CellEndEdit
  1633. CalculosIngresosVCN("UnRegistro")
  1634. End Sub
  1635. Private Sub btnReporto_Click(sender As Object, e As EventArgs)
  1636. End Sub
  1637. Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
  1638. TipoTransaccion = "B"
  1639. btnAceptar.Text = "Eliminar"
  1640. End Sub
  1641. Private Sub btnCancelar_Click(sender As Object, e As EventArgs) Handles btnCancelar.Click
  1642. Me.Close()
  1643. End Sub
  1644. Private Sub cboBase_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboBase.SelectedIndexChanged
  1645. RellenarDatos()
  1646. End Sub
  1647. Private Sub BindingNavigator1_RefreshItems(sender As Object, e As EventArgs) Handles BindingNavigator1.RefreshItems
  1648. End Sub
  1649. Private Sub txtPorcentajeComisionCasa_Leave(sender As Object, e As EventArgs) Handles txtPorcentajeComisionCasa.Leave
  1650. Rellenar()
  1651. End Sub
  1652. Private Sub txtPorcentajeComisionBolsa_Leave(sender As Object, e As EventArgs) Handles txtPorcentajeComisionBolsa.Leave
  1653. Rellenar()
  1654. End Sub
  1655. Sub AgregarDiasExtra()
  1656. dtpFechaLiquidacion.Value = dtpFechaOperacion.Value.AddDays(2)
  1657. End Sub
  1658. Sub CargarFilas()
  1659. Dim Codigo As String = Variables.Codigo
  1660. Dim Tabla As DataTable = oDAOLetes.CargarFilas(Codigo)
  1661. Dim Correlativo As Integer = 0
  1662. Dim CantidadFilas As Integer = 0
  1663. Dim IndexFilas As Integer = 0
  1664. For Each rows As DataRow In Tabla.Rows
  1665. Dim Plazo As Integer = 0
  1666. Dim Fecha As String = Format(Date.Today.Date, "dd/MM/yyyy").ToString
  1667. Dim Monto As Double = 0
  1668. Dim Cedeval As Double = 0
  1669. Dim PorcentajeRenta As String = "10%"
  1670. Dim Renta As Double = 0
  1671. Dim CostoTransferencia As Double = 0
  1672. Dim CostoBanco As Double = 0
  1673. Dim TotalRecibir As Double = 0
  1674. Plazo = Operaciones.ConvertirEntero(rows("Plazo").ToString)
  1675. Fecha = Format(Operaciones.ConvertirFecha(rows("Fecha").ToString), "dd/MM/yyyy").ToString
  1676. Monto = Operaciones.ConvertirDecimal(rows("Monto").ToString)
  1677. Cedeval = Operaciones.ConvertirDecimal(rows("Cedeval").ToString)
  1678. PorcentajeRenta = (Operaciones.ConvertirDecimal(rows("PorcentajeRenta").ToString) * 100).ToString + "%"
  1679. Renta = Operaciones.ConvertirDecimal(rows("Renta").ToString)
  1680. CostoTransferencia = Operaciones.ConvertirDecimal(rows("CostoTransferencia").ToString)
  1681. CostoBanco = Operaciones.ConvertirDecimal(rows("CostoBanco").ToString)
  1682. TotalRecibir = Operaciones.ConvertirDecimal(rows("TotalRecibir").ToString)
  1683. dgvIngresosVCN.Rows.Add("", Plazo, Fecha, Monto, Cedeval, PorcentajeRenta, Renta, CostoTransferencia, CostoBanco, TotalRecibir)
  1684. Next
  1685. CantidadFilas = dgvIngresosVCN.Rows.Count - 1
  1686. While CantidadFilas >= IndexFilas
  1687. Correlativo = CalculosTablaDiasFecha.AgregarCorrelativo(dgvIngresosVCN, IndexFilas)
  1688. dgvIngresosVCN.Rows(IndexFilas).Cells("Correlativo").Value = Correlativo
  1689. IndexFilas += 1
  1690. End While
  1691. End Sub
  1692. End Class