frmFOIN.vb 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288
  1. Public Class frmFOIN
  2. Dim oCEFOIN As FondosDeInversionCE = New FondosDeInversionCE
  3. Dim oDAOGeneral As New DAOGeneral
  4. Dim FOIN As New FondoInversionDAO
  5. Dim EstadoBoton As String
  6. Dim Operaciones As New Operaciones
  7. Dim IndexBase As Integer = 0
  8. Dim TipoTransaccion As String = String.Empty
  9. Private Sub frmFOIN_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  10. CargarBase()
  11. CargarPeriodicidad()
  12. AgregarCampos()
  13. CargarRegistroPrincipal()
  14. CargarFilas()
  15. Rellenar()
  16. Calculos()
  17. ExisteInversion()
  18. ValidarExistencia()
  19. CargarTransladoNuevo()
  20. End Sub
  21. Sub ValidarExistencia()
  22. Dim General As New DAOGeneral
  23. Dim Codigo As String = Variables.Codigo
  24. Dim Tabla As String = String.Empty
  25. Tabla = "FINV"
  26. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  27. If (Existe) Then
  28. navNuevo.Enabled = False
  29. navModificar.Enabled = True
  30. navEliminar.Enabled = True
  31. Else
  32. navNuevo.Enabled = True
  33. navModificar.Enabled = False
  34. navEliminar.Enabled = False
  35. End If
  36. End Sub
  37. Function ExisteInversion()
  38. Dim Codigo As String = Variables.Codigo
  39. Dim TablaINV As String = "INV0"
  40. Dim TablaPINV As String = "PIN0"
  41. Dim General As New DAOGeneral
  42. Dim InvPro = Variables.InvPro
  43. If InvPro = "I" Then
  44. Dim INV0 As Boolean = General.ExisteTitulo(Codigo, TablaINV)
  45. If INV0 Then
  46. navNuevo.Visible = True
  47. Return True
  48. Else
  49. navNuevo.Visible = False
  50. Return False
  51. End If
  52. End If
  53. If InvPro = "P" Then
  54. Dim PINV0 As Boolean = General.ExisteTitulo(Codigo, TablaPINV)
  55. If PINV0 Then
  56. navNuevo.Visible = True
  57. Return True
  58. Else
  59. navNuevo.Visible = False
  60. Return False
  61. End If
  62. End If
  63. Return False
  64. End Function
  65. Sub CargarBase()
  66. If Me.cboAnioBase.Items.Count = 0 Or Me.cboAnioBase.Items.Count = 1 Then
  67. Me.cboAnioBase.DataSource = oDAOGeneral.ListaBase
  68. Me.cboAnioBase.DisplayMember = "Descripcion"
  69. Me.cboAnioBase.ValueMember = "Codigo"
  70. Me.cboAnioBase.SelectedIndex = 0
  71. End If
  72. End Sub
  73. Sub Rellenar()
  74. If (String.IsNullOrEmpty(txtValorNominal.Text.ToString)) Then
  75. txtValorNominal.Text = "0.0"
  76. End If
  77. If (String.IsNullOrEmpty(txtCuotasDeParticipacion.Text.ToString)) Then
  78. txtCuotasDeParticipacion.Text = "0.0"
  79. End If
  80. If (String.IsNullOrEmpty(txtValorDeParticipacion.Text.ToString)) Then
  81. txtValorDeParticipacion.Text = "0.0"
  82. End If
  83. If (String.IsNullOrEmpty(txtPorcentajeComisionCasa.Text.ToString.Trim("%"))) Then
  84. txtPorcentajeComisionCasa.Text = "0.0%"
  85. End If
  86. If (String.IsNullOrEmpty(txtPorcentajeComisionBolsa.Text.ToString.Trim("%"))) Then
  87. txtPorcentajeComisionBolsa.Text = "0.0%"
  88. End If
  89. If (String.IsNullOrEmpty(txtComisionCasa.Text.ToString)) Then
  90. txtComisionCasa.Text = "0.0"
  91. End If
  92. If (String.IsNullOrEmpty(txtComisionBolsa.Text.ToString)) Then
  93. txtComisionBolsa.Text = "0.0"
  94. End If
  95. If (String.IsNullOrEmpty(txtValorTransado.Text.ToString)) Then
  96. txtValorTransado.Text = "0.0"
  97. End If
  98. If (String.IsNullOrEmpty(txtDiasLiq.Text.ToString)) Then
  99. txtDiasLiq.Text = "0.0"
  100. End If
  101. If (String.IsNullOrEmpty(txtRendimientoOfrecido.Text.ToString.Trim("%"))) Then
  102. txtRendimientoOfrecido.Text = "0.0%"
  103. End If
  104. If (String.IsNullOrEmpty(txtPlazo.Text.ToString)) Then
  105. txtPlazo.Text = "0.0"
  106. End If
  107. If (String.IsNullOrEmpty(txtDividendo.Text.ToString.Trim("%"))) Then
  108. txtDividendo.Text = "0.0%"
  109. End If
  110. End Sub
  111. Function CalcularFecha(ByVal FechaInicial As Date, ByVal DiaFijo As Integer)
  112. 'Declaracion de Variables'
  113. Dim Base As Integer = 0
  114. Dim Periodicidad As String = cboPeriodicidad.SelectedValue
  115. Dim TipoCalculo As String = String.Empty
  116. Dim FechaFinal As Date = Date.Today.Date
  117. 'Seleccion de Tipo de Calculo'
  118. If RadioButton1.Checked Then
  119. TipoCalculo = "FinMes"
  120. Else
  121. If RadioButton2.Checked Then
  122. TipoCalculo = "Mensual"
  123. End If
  124. End If
  125. IndexBase = cboAnioBase.SelectedIndex
  126. If (IndexBase = 0 Or IndexBase = 2) Then
  127. Base = 360
  128. If TipoCalculo = "FinMes" Then
  129. FechaFinal = Operaciones.FechaFinMes(FechaInicial, Periodicidad, Base)
  130. ElseIf TipoCalculo = "Mensual" Then
  131. FechaFinal = Operaciones.FechaMensual(FechaInicial, Periodicidad, TipoCalculo, 0, DiaFijo, Base)
  132. End If
  133. ElseIf IndexBase = 1 Or IndexBase = 3 Then
  134. Base = 365
  135. If TipoCalculo = "FinMes" Then
  136. FechaFinal = Operaciones.FechaFinMes(FechaInicial, Periodicidad, Base)
  137. ElseIf TipoCalculo = "Mensual" Then
  138. FechaFinal = Operaciones.FechaMensual(FechaInicial, Periodicidad, TipoCalculo, 0, DiaFijo, Base)
  139. End If
  140. End If
  141. Return FechaFinal
  142. End Function
  143. Sub AgregarFecha()
  144. Dim Index As Integer = dgvIngresos.CurrentRow.Index
  145. Dim IndexAnterior As Integer = Index - 1
  146. Dim FechaAnterior As String = String.Empty
  147. Dim FechaActual As String = String.Empty
  148. Dim FechaLiquidacion As Date = dtpFechaLiquidacion.Value
  149. Dim DiaFijo As Integer = FechaLiquidacion.Day
  150. If Index > 0 Then
  151. FechaAnterior = dgvIngresos.Rows(IndexAnterior).Cells("Fecha de Corte").Value.ToString
  152. If String.IsNullOrEmpty(FechaAnterior) Then
  153. MsgBox("Error de Formato en Fecha")
  154. Exit Sub
  155. Else
  156. FechaActual = CalcularFecha(CDate(FechaAnterior), DiaFijo)
  157. End If
  158. If String.IsNullOrEmpty(FechaActual) Then
  159. MsgBox("Error de Formato en Fecha")
  160. Exit Sub
  161. Else
  162. dgvIngresos.Rows(Index).Cells("Fecha de Corte").Value = Format(CDate(FechaActual), "dd/MM/yyyy").ToString
  163. End If
  164. Else
  165. FechaActual = CalcularFecha(CDate(FechaLiquidacion), DiaFijo)
  166. dgvIngresos.Rows(Index).Cells("Fecha de Corte").Value = Format(CDate(FechaActual), "dd/MM/yyyy").ToString
  167. End If
  168. End Sub
  169. Sub AgregarDias()
  170. Dim Index As Integer = dgvIngresos.CurrentRow.Index
  171. Dim IndexAnterior As Integer = Index - 1
  172. Dim FechaAnterior As String = String.Empty
  173. Dim FechaActual As String = String.Empty
  174. Dim FechaLiquidacion As Date = Format(dtpFechaLiquidacion.Value, "dd/MM/yyyy")
  175. Dim BaseIndex As Integer = cboAnioBase.SelectedIndex
  176. Dim BaseCalculo As Integer = 0
  177. Dim Meses As Integer = 0
  178. Dim TipoCalculo As String = String.Empty
  179. Dim DiasFinales As Integer = 0
  180. Dim CantidadDiasNormal360 As Integer = 0
  181. Dim CantidadDias360 As Integer = 0
  182. Dim Periodicidad As String = cboPeriodicidad.SelectedValue
  183. If Periodicidad = "M" Then
  184. Meses = 1
  185. ElseIf Periodicidad = "T" Then
  186. Meses = 3
  187. ElseIf Periodicidad = "S" Then
  188. Meses = 6
  189. ElseIf Periodicidad = "A" Then
  190. Meses = 12
  191. End If
  192. CantidadDiasNormal360 = Meses * 30
  193. If BaseIndex = 0 Or BaseIndex = 2 Then
  194. BaseCalculo = 360
  195. ElseIf BaseIndex = 1 Or BaseIndex = 3 Then
  196. BaseCalculo = 365
  197. End If
  198. If RadioButton1.Checked Then
  199. TipoCalculo = "FinMes"
  200. Else
  201. If RadioButton2.Checked Then
  202. TipoCalculo = "Mensual"
  203. End If
  204. End If
  205. If Index > 0 Then
  206. FechaAnterior = dgvIngresos.Rows(IndexAnterior).Cells("Fecha de Corte").Value.ToString
  207. FechaActual = dgvIngresos.Rows(Index).Cells("Fecha de Corte").Value.ToString
  208. If Not String.IsNullOrEmpty(FechaAnterior) And Not String.IsNullOrEmpty(FechaActual) Then
  209. If BaseCalculo = 360 Then
  210. If TipoCalculo = "FinMes" Then
  211. DiasFinales = Operaciones.Base360(FechaAnterior, FechaActual)
  212. ElseIf TipoCalculo = "Mensual" Then
  213. DiasFinales = CantidadDiasNormal360
  214. End If
  215. ElseIf BaseCalculo = 365 Then
  216. DiasFinales = Operaciones.Base365(FechaAnterior, FechaActual)
  217. End If
  218. End If
  219. Else
  220. 'Primera Fecha'
  221. FechaActual = dgvIngresos.Rows(Index).Cells("Fecha de Corte").Value.ToString
  222. If Not String.IsNullOrEmpty(FechaLiquidacion) And Not String.IsNullOrEmpty(FechaActual) Then
  223. If BaseCalculo = 360 Then
  224. If TipoCalculo = "FinMes" Then
  225. DiasFinales = Operaciones.Base360(FechaLiquidacion, FechaActual)
  226. ElseIf TipoCalculo = "Mensual" Then
  227. DiasFinales = CantidadDiasNormal360
  228. End If
  229. ElseIf BaseCalculo = 365 Then
  230. DiasFinales = Operaciones.Base365(FechaLiquidacion, FechaActual)
  231. End If
  232. End If
  233. End If
  234. dgvIngresos.Rows(Index).Cells("Dias").Value = DiasFinales
  235. End Sub
  236. Sub AgregarDividendo()
  237. Dim Index As Integer = dgvIngresos.CurrentRow.Index
  238. Dim Dividendo As String = String.Empty
  239. Dim DividendoAgregar As String = String.Empty
  240. Dim DividendoTexto As String = txtDividendo.Text.ToString.Trim("%")
  241. Dim NuevaFila As Boolean = False
  242. If dgvIngresos.Rows(Index).Cells("Dividendo").Value Is Nothing Then
  243. NuevaFila = True
  244. Else
  245. Dividendo = dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString
  246. End If
  247. If String.IsNullOrEmpty(Dividendo) Then
  248. If String.IsNullOrEmpty(DividendoTexto) Then
  249. DividendoAgregar = "0"
  250. Else
  251. DividendoAgregar = DividendoTexto
  252. End If
  253. dgvIngresos.Rows(Index).Cells("Dividendo").Value = (DividendoAgregar.ToString + "%")
  254. End If
  255. End Sub
  256. Sub AgregarIngreso()
  257. Dim Index As Integer = dgvIngresos.CurrentRow.Index
  258. Dim CuotasParticipacion As Double = 0
  259. Dim Dividendo As Double = 0
  260. Dim Dias As Integer = 0
  261. Dim Calculo As Double = 0
  262. If Index > 0 Then
  263. If Not String.IsNullOrEmpty(txtCuotasDeParticipacion.Text.ToString) Then
  264. CuotasParticipacion = txtCuotasDeParticipacion.Text
  265. End If
  266. If Not dgvIngresos.Rows(Index).Cells("Dividendo").Value Is Nothing Then
  267. If Not String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString.Trim("%")) Then
  268. Dividendo = dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString.Trim("%")
  269. End If
  270. End If
  271. Calculo = CuotasParticipacion * (Dividendo / 100)
  272. Else
  273. If Not String.IsNullOrEmpty(txtCuotasDeParticipacion.Text.ToString) Then
  274. CuotasParticipacion = txtCuotasDeParticipacion.Text
  275. End If
  276. If Not dgvIngresos.Rows(Index).Cells("Dividendo").Value Is Nothing Then
  277. If Not String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString.Trim("%")) Then
  278. Dividendo = dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString.Trim("%")
  279. End If
  280. End If
  281. If Not dgvIngresos.Rows(Index).Cells("Dias").Value Is Nothing Then
  282. If Not String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("Dias").Value.ToString) Then
  283. Dias = dgvIngresos.Rows(Index).Cells("Dias").Value
  284. End If
  285. End If
  286. If Not Dias = 0 Then
  287. Dim FechaTemporal As Date = dtpFechaLiquidacion.Value.AddDays(1)
  288. If FechaTemporal.Month = dtpFechaLiquidacion.Value.Month Then
  289. Calculo = (((Dividendo / 100) * CuotasParticipacion) / Dias)
  290. Else
  291. Calculo = CuotasParticipacion * (Dividendo / 100)
  292. End If
  293. End If
  294. End If
  295. dgvIngresos.Rows(Index).Cells("Ingresos").Value = Calculo
  296. End Sub
  297. Sub AgregarRendimientos()
  298. Dim Index As Integer = dgvIngresos.CurrentRow.Index
  299. Dim ValorNominal As Double = 0
  300. Dim Dividendo As Double = 0
  301. Dim Dias As Integer = 0
  302. Dim Ingreso As Double = 0
  303. Dim Calculo As Double = 0
  304. Dim IndexBase As Integer = 0
  305. Dim BaseCalculo As Integer = 0
  306. If Not String.IsNullOrEmpty(txtValorNominal.Text.ToString) Then
  307. ValorNominal = txtValorNominal.Text
  308. End If
  309. If Not dgvIngresos.Rows(Index).Cells("Dividendo").Value Is Nothing Then
  310. If Not String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString.Trim("%")) Then
  311. Dividendo = dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString.Trim("%")
  312. End If
  313. End If
  314. If Not dgvIngresos.Rows(Index).Cells("Ingresos").Value Is Nothing Then
  315. If Not String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("Ingresos").Value.ToString) Then
  316. Ingreso = dgvIngresos.Rows(Index).Cells("Ingresos").Value
  317. End If
  318. End If
  319. If Not dgvIngresos.Rows(Index).Cells("Dias").Value Is Nothing Then
  320. If Not String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("Dias").Value.ToString) Then
  321. Dias = dgvIngresos.Rows(Index).Cells("Dias").Value
  322. End If
  323. End If
  324. IndexBase = cboAnioBase.SelectedIndex
  325. If IndexBase = 0 Or IndexBase = 2 Then
  326. BaseCalculo = 360
  327. ElseIf IndexBase = 1 Or IndexBase = 3 Then
  328. BaseCalculo = 365
  329. End If
  330. If Not Dias = 0 And Not ValorNominal = 0 And Not BaseCalculo = 0 Then
  331. Calculo = Ingreso / ValorNominal * BaseCalculo / Dias
  332. End If
  333. dgvIngresos.Rows(Index).Cells("Rendimiento Mensual").Value = (Calculo * 100).ToString + "%"
  334. End Sub
  335. Sub AgregarNumDiv()
  336. Dim Index As Integer = dgvIngresos.CurrentRow.Index
  337. Dim IndexAnterior As Integer = Index - 1
  338. Dim I_NumDivAnterior As Integer = 0
  339. Dim I_NumDivActual As Integer = 0
  340. Dim S_NumDivAnterior As String = String.Empty
  341. Dim S_NumDivActual As String = String.Empty
  342. S_NumDivActual = dgvIngresos.Rows(Index).Cells("NumDiv").Value
  343. I_NumDivActual = Operaciones.ConvertirEntero(S_NumDivActual)
  344. If Index > 0 Then
  345. S_NumDivAnterior = dgvIngresos.Rows(IndexAnterior).Cells("NumDiv").Value
  346. I_NumDivAnterior = Operaciones.ConvertirEntero(S_NumDivAnterior)
  347. If I_NumDivActual = 0 Then
  348. I_NumDivActual = I_NumDivAnterior + 1
  349. dgvIngresos.Rows(Index).Cells("NumDiv").Value = I_NumDivActual
  350. End If
  351. Else
  352. If I_NumDivActual = 0 Then
  353. I_NumDivActual = 1
  354. dgvIngresos.Rows(Index).Cells("NumDiv").Value = I_NumDivActual
  355. End If
  356. End If
  357. End Sub
  358. Sub AgregarCorrelativo()
  359. Dim Cantidad As Integer = dgvIngresos.Rows.Count - 2
  360. Dim Index As Integer = 0
  361. While Index <= Cantidad
  362. Dim Correlativo As Integer = Index + 1
  363. dgvIngresos.Rows(Index).Cells("correlativo").Value = Correlativo
  364. Index += 1
  365. End While
  366. End Sub
  367. Sub CalculosTabla()
  368. AgregarCorrelativo()
  369. AgregarFecha()
  370. AgregarDias()
  371. AgregarDividendo()
  372. AgregarIngreso()
  373. AgregarRendimientos()
  374. AgregarNumDiv()
  375. End Sub
  376. Sub CargarPeriodicidad()
  377. Me.cboPeriodicidad.DataSource = oDAOGeneral.ListaPeriodicidad
  378. Me.cboPeriodicidad.DisplayMember = "Descripcion"
  379. Me.cboPeriodicidad.ValueMember = "Codigo"
  380. ' Me.cboPeriodicidad.SelectedIndex = -1
  381. End Sub
  382. Private Sub Calculos()
  383. Dim SCuotasDeParticipacion As String = String.Empty
  384. Dim SValorParticipacion As String = String.Empty
  385. Dim SValorNominal As String = String.Empty
  386. Dim SValorTransado As String = String.Empty
  387. Dim SDiasPlazo As String = String.Empty
  388. Dim SPorcentajeComisionCasa As String = String.Empty
  389. Dim SPorcentajeComisionBolsa As String = String.Empty
  390. Dim SComisionCasa As String = String.Empty
  391. Dim SComisionBolsa As String = String.Empty
  392. Dim SDiasLiquidos As String = String.Empty
  393. Dim ICuotasDeParticipacion As Double = 0
  394. Dim IValorParticipacion As Double = 0
  395. Dim IValorNominal As Double = 0
  396. Dim IValorTransado As Double = 0
  397. Dim FechaLiquidacion As Date = Date.Today.Date
  398. Dim FechaOperacion As Date = Date.Today.Date
  399. Dim FechaVencimiento As Date = Date.Today.Date
  400. Dim IDiasPlazo As Integer = 0
  401. Dim IPorcentajeComisionCasa As Double = 0
  402. Dim IPorcentajeComisionBolsa As Double = 0
  403. Dim IComisionCasa As Double = 0
  404. Dim IComisionBolsa As Double = 0
  405. Dim IDiasLiquidos As Integer = 0
  406. SDiasPlazo = txtPlazo.Text.ToString
  407. IDiasPlazo = Operaciones.ConvertirEntero(SDiasPlazo)
  408. SDiasLiquidos = txtDiasLiq.Text.ToString
  409. IDiasLiquidos = Operaciones.ConvertirEntero(SDiasLiquidos)
  410. SPorcentajeComisionCasa = txtPorcentajeComisionCasa.Text.ToString
  411. IPorcentajeComisionCasa = Operaciones.ConvertirDecimal(SPorcentajeComisionCasa) / 100
  412. SPorcentajeComisionBolsa = txtPorcentajeComisionBolsa.Text.ToString
  413. IPorcentajeComisionBolsa = Operaciones.ConvertirDecimal(SPorcentajeComisionBolsa) / 100
  414. SCuotasDeParticipacion = txtCuotasDeParticipacion.Text.ToString
  415. ICuotasDeParticipacion = Operaciones.ConvertirDecimal(SCuotasDeParticipacion)
  416. SValorParticipacion = txtValorDeParticipacion.Text.ToString
  417. IValorParticipacion = Operaciones.ConvertirDecimal(SValorParticipacion)
  418. FechaOperacion = dtpFechaOperacion.Value
  419. txtValorNominal.Text = oCEFOIN.CalculoValorNominal(ICuotasDeParticipacion, IValorParticipacion)
  420. SValorNominal = txtValorNominal.Text.ToString
  421. IValorNominal = Operaciones.ConvertirDecimal(SValorNominal)
  422. txtValorTransado.Text = IValorNominal
  423. IValorTransado = IValorNominal
  424. dtpFechaLiquidacion.Value = FechaOperacion
  425. dtpFechaLiquidacion.Value = oCEFOIN.CalculoFechaLiq(FechaOperacion, IDiasLiquidos)
  426. FechaLiquidacion = dtpFechaLiquidacion.Value
  427. txtComisionCasa.Text = CalculoComision(IPorcentajeComisionCasa, IValorTransado)
  428. txtComisionBolsa.Text = CalculoComision(IPorcentajeComisionBolsa, IValorTransado)
  429. IndexBase = cboAnioBase.SelectedIndex
  430. If (IndexBase = 0 Or IndexBase = 2) Then
  431. dtpFechaVencimiento.Value = Operaciones.FechaDias360(FechaLiquidacion, IDiasPlazo)
  432. ElseIf IndexBase = 1 Or IndexBase = 3 Then
  433. dtpFechaVencimiento.Value = FechaLiquidacion.AddDays(IDiasPlazo)
  434. End If
  435. End Sub
  436. Function CalculoComision(ByVal PorcComision As Double, ByVal ValTra As Double)
  437. Return PorcComision * ValTra
  438. End Function
  439. Private Sub txtCuotasDeParticipacion_TextChanged(sender As Object, e As EventArgs) Handles txtCuotasDeParticipacion.TextChanged
  440. If Not Double.TryParse(txtCuotasDeParticipacion.Text, oCEFOIN.CuotasDeParticipacion) Then
  441. lblErrCuotasDeParticipacion.Visible = True
  442. Else
  443. lblErrCuotasDeParticipacion.Visible = False
  444. End If
  445. Calculos()
  446. End Sub
  447. Private Sub txtCuotasDeParticipacion_LostFocus(sender As Object, e As EventArgs) Handles txtCuotasDeParticipacion.LostFocus
  448. If Not Double.TryParse(txtCuotasDeParticipacion.Text, oCEFOIN.CuotasDeParticipacion) Then
  449. lblErrCuotasDeParticipacion.Visible = True
  450. Else
  451. lblErrCuotasDeParticipacion.Visible = False
  452. End If
  453. Me.txtCuotasDeParticipacion.Text = oCEFOIN.CuotasDeParticipacion.ToString()
  454. RefrescarValorControles()
  455. End Sub
  456. Private Sub txtValorDeParticipacion_TextChanged(sender As Object, e As EventArgs) Handles txtValorDeParticipacion.TextChanged
  457. If Not Double.TryParse(txtValorDeParticipacion.Text, oCEFOIN.ValorDeParticipacion) Then
  458. lblErrValorDeParticipacion.Visible = True
  459. Else
  460. lblErrValorDeParticipacion.Visible = False
  461. End If
  462. Calculos()
  463. End Sub
  464. Private Sub txtValorDeParticipacion_LostFocus(sender As Object, e As EventArgs) Handles txtValorDeParticipacion.LostFocus
  465. If Not Double.TryParse(txtValorDeParticipacion.Text, oCEFOIN.ValorDeParticipacion) Then
  466. lblErrValorDeParticipacion.Visible = True
  467. Else
  468. lblErrValorDeParticipacion.Visible = False
  469. End If
  470. Me.txtValorDeParticipacion.Text = oCEFOIN.ValorDeParticipacion.ToString()
  471. RefrescarValorControles()
  472. End Sub
  473. Sub RefrescarValorControles()
  474. Me.txtValorNominal.Text = oCEFOIN.ValorNominal.ToString()
  475. Me.txtComisionCasa.Text = oCEFOIN.ComisionCasa.ToString()
  476. Me.txtComisionBolsa.Text = oCEFOIN.ComisionBolsa.ToString()
  477. Me.txtValorTransado.Text = oCEFOIN.ValorTransado.ToString()
  478. End Sub
  479. Private Sub txtPorcentajeComisionCasa_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeComisionCasa.TextChanged
  480. Dim valor As Double
  481. If (txtPorcentajeComisionCasa.ToString.IndexOf("%") = -1) Then
  482. txtPorcentajeComisionCasa.Text += "%"
  483. End If
  484. If Not Double.TryParse(Me.txtPorcentajeComisionCasa.Text.Replace("%", ""), valor) Then
  485. lblErrComisionCasa.Visible = True
  486. Else
  487. lblErrComisionCasa.Visible = False
  488. End If
  489. oCEFOIN.PorcentajeComisionCasa = valor / 100
  490. Calculos()
  491. End Sub
  492. Private Sub txtPorcentajeComisionCasa_LostFocus(sender As Object, e As EventArgs) Handles txtPorcentajeComisionCasa.LostFocus
  493. Me.txtPorcentajeComisionCasa.Text = oCEFOIN.PorcentajeComisionCasa.ToString(Configuraciones.CodigoTXTPorcentaje)
  494. RefrescarValorControles()
  495. End Sub
  496. Private Sub txtPorcentajeComisionBolsa_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeComisionBolsa.TextChanged
  497. Dim valor As Double
  498. If (txtPorcentajeComisionBolsa.ToString.IndexOf("%") = -1) Then
  499. txtPorcentajeComisionBolsa.Text += "%"
  500. End If
  501. If Not Double.TryParse(Me.txtPorcentajeComisionBolsa.Text.Replace("%", ""), valor) Then
  502. lblErrComisionBolsa.Visible = True
  503. Else
  504. lblErrComisionBolsa.Visible = False
  505. End If
  506. oCEFOIN.PorcentajeComisionBolsa = valor / 100
  507. Calculos()
  508. End Sub
  509. Private Sub txtPorcentajeComisionBolsa_LostFocus(sender As Object, e As EventArgs) Handles txtPorcentajeComisionBolsa.LostFocus
  510. Me.txtPorcentajeComisionBolsa.Text = oCEFOIN.PorcentajeComisionBolsa.ToString(Configuraciones.CodigoTXTPorcentaje)
  511. RefrescarValorControles()
  512. End Sub
  513. Private Sub dtpFechaOperacion_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaOperacion.ValueChanged
  514. Calculos()
  515. End Sub
  516. Private Sub dtpFechaLiquidacion_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaLiquidacion.ValueChanged
  517. oCEFOIN.FechaLiquidacion = dtpFechaLiquidacion.Value.Date
  518. End Sub
  519. Private Sub dtpFechaVencimiento_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimiento.ValueChanged
  520. oCEFOIN.FechaVencimiento = dtpFechaVencimiento.Value.Date
  521. End Sub
  522. Private Sub txtRendimientoOfrecido_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoOfrecido.TextChanged
  523. Calculos()
  524. If (txtRendimientoOfrecido.ToString.IndexOf("%") = -1) Then
  525. txtRendimientoOfrecido.Text += "%"
  526. End If
  527. End Sub
  528. Private Sub txtRendimientoOfrecido_LostFocus(sender As Object, e As EventArgs) Handles txtRendimientoOfrecido.LostFocus
  529. End Sub
  530. Private Sub cboPeriodicidad_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboPeriodicidad.SelectedIndexChanged
  531. If Not TypeOf cboPeriodicidad.SelectedValue Is DataRowView Then
  532. If Not cboPeriodicidad.SelectedValue Is Nothing Then
  533. oCEFOIN.Periodicidad = cboPeriodicidad.SelectedValue.ToString
  534. End If
  535. End If
  536. End Sub
  537. Private Sub cboAnioBase_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboAnioBase.SelectedIndexChanged
  538. If Not TypeOf cboAnioBase.SelectedItem Is DataRowView Then
  539. oCEFOIN.AnioBase = cboAnioBase.SelectedItem
  540. End If
  541. End Sub
  542. Private Sub txtPlazo_TextChanged(sender As Object, e As EventArgs) Handles txtPlazo.TextChanged
  543. Calculos()
  544. End Sub
  545. Private Sub btnRefrescar_Click(sender As Object, e As EventArgs) Handles btnQuitar.Click
  546. QuitarFila()
  547. End Sub
  548. Private Sub txtDividendo_TextChanged(sender As Object, e As EventArgs)
  549. Calculos()
  550. End Sub
  551. Private Sub txtDividendo_LostFocus(sender As Object, e As EventArgs)
  552. End Sub
  553. Private Sub txtCuotasDeParticipacion_KeyUp(sender As Object, e As KeyEventArgs) Handles txtCuotasDeParticipacion.KeyUp
  554. Calculos()
  555. End Sub
  556. Private Sub txtValorDeParticipacion_KeyUp(sender As Object, e As KeyEventArgs) Handles txtValorDeParticipacion.KeyUp
  557. Calculos()
  558. End Sub
  559. Private Sub txtDiasLiq_KeyUp(sender As Object, e As KeyEventArgs) Handles txtDiasLiq.KeyUp
  560. Calculos()
  561. End Sub
  562. Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
  563. TipoTransaccion = "M"
  564. btnAccion.Text = "Modificar"
  565. End Sub
  566. Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
  567. TipoTransaccion = "N"
  568. btnAccion.Text = "Nuevo"
  569. End Sub
  570. Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
  571. TipoTransaccion = "B"
  572. btnAccion.Text = "Eliminar"
  573. End Sub
  574. Private Sub btnAccion_Click(sender As Object, e As EventArgs) Handles btnAccion.Click
  575. Dim codigo As String = Variables.Codigo
  576. Dim Coleccion As Collection = ColeccionDatos()
  577. Dim Diccionario As Dictionary(Of String, Collection) = NuevoIngresoDiccionario()
  578. If (TipoTransaccion = "N") Then
  579. FOIN.ProcesoDatos(Coleccion, codigo, Diccionario, "Nuevo")
  580. ElseIf (TipoTransaccion = "M") Then
  581. FOIN.ProcesoDatos(Coleccion, codigo, Diccionario, "Modificar")
  582. ElseIf (TipoTransaccion = "B") Then
  583. Eliminar()
  584. ElseIf Not ExisteValidacion() Then
  585. Variables.ColeccionFINV = Coleccion
  586. Variables.ColeccionFINVDi = Diccionario
  587. Me.Close()
  588. End If
  589. End Sub
  590. Sub Eliminar()
  591. Dim codigo As String = Variables.Codigo
  592. FOIN.Eliminar(codigo)
  593. End Sub
  594. Function ExisteValidacion()
  595. Dim General As New DAOGeneral
  596. Dim Codigo As String = Variables.Codigo
  597. Dim Tabla As String = String.Empty
  598. Tabla = "FINV"
  599. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  600. Return Existe
  601. End Function
  602. Private Function NuevoIngresoDiccionario()
  603. Dim Diccionario As New Dictionary(Of String, Collection)
  604. Dim Cantidad As Integer = dgvIngresos.Rows.Count - 2
  605. Dim Index As Integer = 0
  606. While Index <= Cantidad
  607. Dim coleccion As New Collection
  608. Dim FechaCorte, Dias, Dividendo, Ingreso, RendMensual, NumDiv
  609. NumDiv = dgvIngresos.Rows(Index).Cells("NumDiv").Value
  610. FechaCorte = dgvIngresos.Rows(Index).Cells("Fecha de Corte").Value
  611. Dias = dgvIngresos.Rows(Index).Cells("Dias").Value
  612. Dividendo = (CDec(dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString.Trim("%")) / 100)
  613. Ingreso = dgvIngresos.Rows(Index).Cells("Ingresos").Value
  614. RendMensual = (dgvIngresos.Rows(Index).Cells("Rendimiento Mensual").Value.ToString.Trim("%") / 100)
  615. coleccion.Add(NumDiv)
  616. coleccion.Add(FechaCorte)
  617. coleccion.Add(Dias)
  618. coleccion.Add(Dividendo)
  619. coleccion.Add(Ingreso)
  620. coleccion.Add(RendMensual)
  621. Diccionario.Add(NumDiv, coleccion)
  622. Index += 1
  623. End While
  624. Return Diccionario
  625. End Function
  626. Private Function ColeccionDatos()
  627. Dim Coleccion As New Collection
  628. Dim TipoCalculo As String = Me.TipoCalculo
  629. Coleccion.Add(txtValorNominal.Text)
  630. Coleccion.Add(txtCuotasDeParticipacion.Text)
  631. Coleccion.Add(txtValorDeParticipacion.Text)
  632. Coleccion.Add((txtPorcentajeComisionCasa.Text.ToString.Trim("%")) / 100)
  633. Coleccion.Add((txtPorcentajeComisionBolsa.Text.ToString.Trim("%")) / 100)
  634. Coleccion.Add(txtComisionCasa.Text)
  635. Coleccion.Add(txtComisionBolsa.Text)
  636. Coleccion.Add(txtValorTransado.Text)
  637. Coleccion.Add(dtpFechaOperacion.Value)
  638. Coleccion.Add(dtpFechaLiquidacion.Value)
  639. Coleccion.Add(dtpFechaVencimiento.Value)
  640. Coleccion.Add(txtDiasLiq.Text)
  641. Coleccion.Add(CDec(txtRendimientoOfrecido.Text.ToString.Trim("%")) / 100)
  642. Coleccion.Add(cboPeriodicidad.SelectedValue)
  643. Coleccion.Add(cboAnioBase.SelectedIndex)
  644. Coleccion.Add(txtPlazo.Text)
  645. Coleccion.Add(txtDividendo.Text.ToString.Trim("%") / 100)
  646. Coleccion.Add(TipoCalculo)
  647. Return Coleccion
  648. End Function
  649. Function TipoCalculo()
  650. Dim TipCalculo As String = "FinMes"
  651. If RadioButton1.Checked Then
  652. TipCalculo = "FinMes"
  653. Else
  654. If RadioButton2.Checked Then
  655. TipCalculo = "Mensual"
  656. End If
  657. End If
  658. Return TipCalculo
  659. End Function
  660. Private Sub CargarRegistroPrincipal()
  661. Dim FONV As New FondoInversionDAO
  662. Dim Codigo As String = Variables.Codigo
  663. Dim Coleccion As Collection = FONV.Cargar(Codigo)
  664. Dim TipoOperacion As String = String.Empty
  665. If Not Coleccion.Count = 0 Then
  666. txtValorNominal.Text = Operaciones.ConvertirDecimal(Coleccion(1).ToString)
  667. txtCuotasDeParticipacion.Text = Operaciones.ConvertirDecimal(Coleccion(2).ToString)
  668. txtValorDeParticipacion.Text = Operaciones.ConvertirDecimal(Coleccion(3).ToString)
  669. txtPorcentajeComisionCasa.Text = Operaciones.ConvertirDecimal((Coleccion(4) * 100).ToString)
  670. txtPorcentajeComisionBolsa.Text = Operaciones.ConvertirDecimal((Coleccion(5) * 100).ToString)
  671. txtComisionCasa.Text = Operaciones.ConvertirDecimal(Coleccion(6).ToString)
  672. txtComisionBolsa.Text = Operaciones.ConvertirDecimal(Coleccion(7).ToString)
  673. txtValorTransado.Text = Operaciones.ConvertirDecimal(Coleccion(8).ToString)
  674. dtpFechaOperacion.Value = Operaciones.ConvertirFecha(Coleccion(9).ToString)
  675. dtpFechaLiquidacion.Value = Operaciones.ConvertirFecha(Coleccion(10).ToString)
  676. dtpFechaVencimiento.Value = Operaciones.ConvertirFecha(Coleccion(11))
  677. txtDiasLiq.Text = Operaciones.ConvertirEntero(Coleccion(12).ToString)
  678. txtRendimientoOfrecido.Text = Operaciones.ConvertirDecimal((Coleccion(13) * 100).ToString)
  679. cboPeriodicidad.SelectedValue = Coleccion(14).ToString
  680. cboAnioBase.SelectedIndex = Operaciones.ConvertirEntero(Coleccion(15).ToString)
  681. txtPlazo.Text = Operaciones.ConvertirEntero(Coleccion(16).ToString)
  682. txtDividendo.Text = Operaciones.ConvertirDecimal((Coleccion(17) * 100).ToString)
  683. TipoOperacion = Coleccion(18).ToString
  684. If TipoOperacion = "FinMes" Then
  685. RadioButton1.Checked = True
  686. Else
  687. If TipoOperacion = "Mensual" Then
  688. RadioButton2.Checked = True
  689. End If
  690. End If
  691. End If
  692. End Sub
  693. Sub CargarFilas()
  694. Dim FONV As New FondoInversionDAO
  695. Dim Codigo As String = Variables.Codigo
  696. Dim Tabla As DataTable = FONV.CargarFilas(Codigo)
  697. For Each rows As DataRow In Tabla.Rows
  698. Dim NumDiv As Integer = 0
  699. Dim Fecha As Date = Date.Today.Date
  700. Dim Dias As Integer = 0
  701. Dim Dividendo As String = String.Empty
  702. Dim Ingreso As Double = 0
  703. Dim Rend As String = String.Empty
  704. NumDiv = Operaciones.ConvertirEntero(rows("NumDiv").ToString)
  705. Fecha = Operaciones.ConvertirFecha(rows("Fecha").ToString)
  706. Dias = Operaciones.ConvertirEntero(rows("Dias").ToString)
  707. Dividendo = (Operaciones.ConvertirDecimal(rows("Dividendo").ToString) * 100).ToString + "%"
  708. Ingreso = Operaciones.ConvertirDecimal(rows("Ingreso").ToString)
  709. Rend = (Operaciones.ConvertirDecimal(rows("Rend").ToString) * 100).ToString + "%"
  710. dgvIngresos.Rows.Add("", Fecha, Dias, Dividendo, Ingreso, Rend, NumDiv)
  711. Next
  712. AgregarCorrelativo()
  713. End Sub
  714. Private Sub Button1_Click(sender As Object, e As EventArgs)
  715. End Sub
  716. Sub AgregarCampos()
  717. Dim CantidadColumnas As Integer = dgvIngresos.ColumnCount
  718. If CantidadColumnas = 0 Then
  719. Dim FechaCorte, Dias, Dividendo, Ingreso, RendMensual, correlativo, NumDiv As New DataGridViewTextBoxColumn
  720. correlativo.Name = "correlativo"
  721. FechaCorte.Name = "Fecha de Corte"
  722. Dias.Name = "Dias"
  723. Dividendo.Name = "Dividendo"
  724. Ingreso.Name = "Ingresos"
  725. RendMensual.Name = "Rendimiento Mensual"
  726. NumDiv.Name = "NumDiv"
  727. dgvIngresos.Columns.Add(correlativo)
  728. dgvIngresos.Columns.Add(FechaCorte)
  729. dgvIngresos.Columns.Add(Dias)
  730. dgvIngresos.Columns.Add(Dividendo)
  731. dgvIngresos.Columns.Add(Ingreso)
  732. dgvIngresos.Columns.Add(RendMensual)
  733. dgvIngresos.Columns.Add(NumDiv)
  734. End If
  735. End Sub
  736. Private Sub dgvIngresos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellContentClick
  737. End Sub
  738. Private Sub dgvIngresos_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgvIngresos.CellMouseClick
  739. CalculosTabla()
  740. End Sub
  741. Private Sub dgvIngresos_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellEndEdit
  742. End Sub
  743. Private Sub txtDiasLiq_TextChanged(sender As Object, e As EventArgs) Handles txtDiasLiq.TextChanged
  744. Rellenar()
  745. Calculos()
  746. End Sub
  747. Private Sub btnModificar_Click(sender As Object, e As EventArgs)
  748. End Sub
  749. Private Sub btnEliminar_Click(sender As Object, e As EventArgs)
  750. End Sub
  751. Private Sub BindingNavigator1_RefreshItems(sender As Object, e As EventArgs) Handles BindingNavigator1.RefreshItems
  752. End Sub
  753. Private Sub btnRescate_Click(sender As Object, e As EventArgs)
  754. End Sub
  755. Private Sub txtCuotasDeParticipacion_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtCuotasDeParticipacion.KeyPress
  756. If String.IsNullOrEmpty(sender.Text) Then
  757. If e.KeyChar = "." Then
  758. sender.Text = "0"
  759. Exit Sub
  760. End If
  761. End If
  762. If (Not sender.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  763. Operaciones.ValidarEntrada(sender, e, True)
  764. Else
  765. Operaciones.ValidarEntrada(sender, e, False)
  766. End If
  767. End Sub
  768. Private Sub txtValorDeParticipacion_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtValorDeParticipacion.KeyPress
  769. If String.IsNullOrEmpty(sender.Text) Then
  770. If e.KeyChar = "." Then
  771. sender.Text = "0"
  772. Exit Sub
  773. End If
  774. End If
  775. If (Not sender.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  776. Operaciones.ValidarEntrada(sender, e, True)
  777. Else
  778. Operaciones.ValidarEntrada(sender, e, False)
  779. End If
  780. End Sub
  781. Private Sub txtPorcentajeComisionCasa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeComisionCasa.KeyPress
  782. If String.IsNullOrEmpty(sender.Text) Then
  783. If e.KeyChar = "." Then
  784. sender.Text = "0"
  785. Exit Sub
  786. End If
  787. End If
  788. If (Not sender.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  789. Operaciones.ValidarEntrada(sender, e, True)
  790. Else
  791. Operaciones.ValidarEntrada(sender, e, False)
  792. End If
  793. End Sub
  794. Private Sub txtPorcentajeComisionBolsa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeComisionBolsa.KeyPress
  795. If String.IsNullOrEmpty(sender.Text) Then
  796. If e.KeyChar = "." Then
  797. sender.Text = "0"
  798. Exit Sub
  799. End If
  800. End If
  801. If (Not sender.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  802. Operaciones.ValidarEntrada(sender, e, True)
  803. Else
  804. Operaciones.ValidarEntrada(sender, e, False)
  805. End If
  806. End Sub
  807. Private Sub txtDiasLiq_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtDiasLiq.KeyPress
  808. If String.IsNullOrEmpty(sender.Text) Then
  809. If e.KeyChar = "." Then
  810. sender.Text = "0"
  811. Exit Sub
  812. End If
  813. End If
  814. If (Not sender.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  815. Operaciones.ValidarEntrada(sender, e, True)
  816. Else
  817. Operaciones.ValidarEntrada(sender, e, False)
  818. End If
  819. End Sub
  820. Private Sub txtRendimientoOfrecido_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtRendimientoOfrecido.KeyPress
  821. If String.IsNullOrEmpty(sender.Text) Then
  822. If e.KeyChar = "." Then
  823. sender.Text = "0"
  824. Exit Sub
  825. End If
  826. End If
  827. If (Not sender.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  828. Operaciones.ValidarEntrada(sender, e, True)
  829. Else
  830. Operaciones.ValidarEntrada(sender, e, False)
  831. End If
  832. End Sub
  833. Private Sub txtPlazo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPlazo.KeyPress
  834. If String.IsNullOrEmpty(sender.Text) Then
  835. If e.KeyChar = "." Then
  836. sender.Text = "0"
  837. Exit Sub
  838. End If
  839. End If
  840. If (Not sender.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  841. Operaciones.ValidarEntrada(sender, e, True)
  842. Else
  843. Operaciones.ValidarEntrada(sender, e, False)
  844. End If
  845. End Sub
  846. Private Sub GroupBox3_Enter(sender As Object, e As EventArgs) Handles GroupBox3.Enter
  847. End Sub
  848. Private Sub GroupBox2_Enter(sender As Object, e As EventArgs) Handles GroupBox2.Enter
  849. End Sub
  850. Private Sub dgvIngresos_Click(sender As Object, e As EventArgs) Handles dgvIngresos.Click
  851. End Sub
  852. Private Sub Button1_Click_1(sender As Object, e As EventArgs)
  853. End Sub
  854. Private Sub DateTimePicker1_ValueChanged(sender As Object, e As EventArgs)
  855. End Sub
  856. Private Sub btnCancelat_Click(sender As Object, e As EventArgs) Handles btnCancelat.Click
  857. Me.Close()
  858. End Sub
  859. Sub QuitarFila()
  860. Dim CantidadFilas As Integer = dgvIngresos.Rows.Count - 1
  861. If CantidadFilas > 0 Then
  862. Dim result As Integer = MsgBox("¿Está seguro que desea eliminar la fila?", MsgBoxStyle.OkCancel)
  863. ' Test result.
  864. Dim codigo As String = Variables.Codigo
  865. Dim Numero As Integer = dgvIngresos.CurrentRow.Cells("NumDiv").Value
  866. If result = MsgBoxResult.Ok Then
  867. Try
  868. dgvIngresos.Rows.Remove(dgvIngresos.CurrentRow)
  869. FOIN.EliminarIngreso(codigo, Numero)
  870. Catch ex As Exception
  871. MsgBox("No ha seleccionado una fila")
  872. End Try
  873. End If
  874. Else
  875. MsgBox("Actualmente no tiene registros")
  876. End If
  877. End Sub
  878. Private Sub txtCuotasDeParticipacion_Leave(sender As Object, e As EventArgs) Handles txtCuotasDeParticipacion.Leave
  879. Rellenar()
  880. End Sub
  881. Private Sub txtValorDeParticipacion_Leave(sender As Object, e As EventArgs) Handles txtValorDeParticipacion.Leave
  882. Rellenar()
  883. End Sub
  884. Private Sub txtPorcentajeComisionCasa_Leave(sender As Object, e As EventArgs) Handles txtPorcentajeComisionCasa.Leave
  885. Rellenar()
  886. End Sub
  887. Private Sub txtPorcentajeComisionBolsa_Leave(sender As Object, e As EventArgs) Handles txtPorcentajeComisionBolsa.Leave
  888. Rellenar()
  889. End Sub
  890. Private Sub txtDiasLiq_Leave(sender As Object, e As EventArgs) Handles txtDiasLiq.Leave
  891. Rellenar()
  892. End Sub
  893. Private Sub txtRendimientoOfrecido_Leave(sender As Object, e As EventArgs) Handles txtRendimientoOfrecido.Leave
  894. Rellenar()
  895. End Sub
  896. Private Sub txtPlazo_Leave(sender As Object, e As EventArgs) Handles txtPlazo.Leave
  897. Rellenar()
  898. End Sub
  899. Private Sub txtDividendo_TextChanged_1(sender As Object, e As EventArgs) Handles txtDividendo.TextChanged
  900. If (txtDividendo.ToString.IndexOf("%") = -1) Then
  901. txtDividendo.Text += "%"
  902. End If
  903. Rellenar()
  904. End Sub
  905. Private Sub txtDividendo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtDividendo.KeyPress
  906. If String.IsNullOrEmpty(sender.Text) Then
  907. If e.KeyChar = "." Then
  908. sender.Text = "0"
  909. Exit Sub
  910. End If
  911. End If
  912. If (Not sender.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  913. Operaciones.ValidarEntrada(sender, e, True)
  914. Else
  915. Operaciones.ValidarEntrada(sender, e, False)
  916. End If
  917. End Sub
  918. Sub CargarTransladoNuevo()
  919. Dim Existe As Boolean = ExisteInversion()
  920. If Not RetCodigoInversionExiste And Not Existe Then
  921. txtRendimientoOfrecido.Text = Variables.RetRendimiento
  922. txtCuotasDeParticipacion.Text = Variables.RetCuotaParticipacionFINV
  923. txtValorDeParticipacion.Text = Variables.RetValorParticipacionFINV
  924. End If
  925. End Sub
  926. End Class