frmLetes.vb 74 KB

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