frmLetes.vb 73 KB

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