frmDepositosAPlazo.vb 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893
  1. Public Class frmDepositosAPlazo
  2. Dim AnioBase As Integer = 365
  3. Dim oDAPCE As New DepositosAPlazoCE
  4. Dim oDAPDAO As New DepositosAPlazoDAO
  5. Dim oDAOGeneral As New DAOGeneral
  6. Private vCargado As Boolean = False
  7. Dim Estado As String = " "
  8. Dim codigo As String = Variables.Codigo
  9. Dim Operaciones As New Operaciones
  10. Dim DepositoCalcular As New DepositosAPlazoCE
  11. Private _TipoTransaccion As String
  12. Private _IdDocumento As Integer
  13. Private _TipoDocumento As String
  14. Private _CodigoInversion As String
  15. Private Property CodigoInversion As String
  16. Get
  17. Return _CodigoInversion
  18. End Get
  19. Set(value As String)
  20. _CodigoInversion = value
  21. End Set
  22. End Property
  23. Public Property TipoTransaccion As String
  24. Get
  25. Return _TipoTransaccion
  26. End Get
  27. Set(value As String)
  28. _TipoTransaccion = value
  29. End Set
  30. End Property
  31. Private Property IdDocumento As Integer
  32. Get
  33. Return _IdDocumento
  34. End Get
  35. Set(value As Integer)
  36. _IdDocumento = value
  37. End Set
  38. End Property
  39. Private Property TipoDocumento As String
  40. Get
  41. Return _TipoDocumento
  42. End Get
  43. Set(value As String)
  44. _TipoDocumento = value
  45. End Set
  46. End Property
  47. Sub RellenarDatos()
  48. If (String.IsNullOrEmpty(txtMontoInversion.Text.ToString)) Then
  49. txtMontoInversion.Text = "0.0"
  50. End If
  51. If (String.IsNullOrEmpty(txtPlazo.Text.ToString)) Then
  52. txtPlazo.Text = "0.0"
  53. End If
  54. If (String.IsNullOrEmpty(txtTasa.Text.ToString.Trim("%"))) Then
  55. txtTasa.Text = "0.0%"
  56. End If
  57. End Sub
  58. Private Sub frmDAP_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  59. dgvIntereses.Columns.Clear()
  60. AgregarCampos()
  61. Call CargarPeriodos()
  62. If TipoTransaccion Is Nothing Then
  63. TipoTransaccion = "N"
  64. PrepararNuevo()
  65. End If
  66. Call CargarRegistroBD()
  67. CalcularPlazo()
  68. Calculo()
  69. vCargado = True
  70. ExisteInversion()
  71. ValidarExistencia()
  72. CargarTransladoNuevo()
  73. End Sub
  74. Function ExisteInversion()
  75. Dim Codigo As String = Variables.Codigo
  76. Dim TablaINV As String = "INV0"
  77. Dim TablaPINV As String = "PIN0"
  78. Dim General As New DAOGeneral
  79. Dim InvPro = Variables.InvPro
  80. If InvPro = "I" Then
  81. Dim INV0 As Boolean = General.ExisteTitulo(Codigo, TablaINV)
  82. If INV0 Then
  83. navNuevo.Visible = True
  84. Return True
  85. Else
  86. navNuevo.Visible = False
  87. Return False
  88. End If
  89. End If
  90. If InvPro = "P" Then
  91. Dim PINV0 As Boolean = General.ExisteTitulo(Codigo, TablaPINV)
  92. If PINV0 Then
  93. navNuevo.Visible = True
  94. Return True
  95. Else
  96. navNuevo.Visible = False
  97. Return False
  98. End If
  99. End If
  100. Return False
  101. End Function
  102. Sub ValidarExistencia()
  103. Dim General As New DAOGeneral
  104. Dim Codigo As String = Variables.Codigo
  105. Dim Tabla As String = String.Empty
  106. Tabla = "DAP0"
  107. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  108. If (Existe) Then
  109. navNuevo.Enabled = False
  110. navModificar.Enabled = True
  111. navEliminar.Enabled = True
  112. Else
  113. navNuevo.Enabled = True
  114. navModificar.Enabled = False
  115. navEliminar.Enabled = False
  116. End If
  117. Estado = String.Empty
  118. btnGME.Text = "Aceptar"
  119. End Sub
  120. Function ExisteValidacion()
  121. Dim General As New DAOGeneral
  122. Dim Codigo As String = Variables.Codigo
  123. Dim Tabla As String = String.Empty
  124. Tabla = "DAP0"
  125. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  126. Return Existe
  127. End Function
  128. Private Sub txtPlazo_TextChanged(sender As Object, e As EventArgs)
  129. Calculo()
  130. End Sub
  131. Private Sub txtPlazo_LostFocus(sender As Object, e As EventArgs)
  132. End Sub
  133. Private Sub ControlPlazo()
  134. Dim valor As Integer
  135. If Not Integer.TryParse(txtPlazo.Text.ToString, valor) Then
  136. txtPlazo.Focus()
  137. txtPlazo.BackColor = Configuraciones.ColorFondoError
  138. Else
  139. txtPlazo.BackColor = Color.White
  140. If TipoTransaccion = "N" Or TipoTransaccion = "M" Then
  141. oDAPCE.Plazo = valor
  142. End If
  143. RefrescarValorControles()
  144. End If
  145. End Sub
  146. Private Sub dtpFechaOperacion_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaOperacion.ValueChanged
  147. CalcularPlazo()
  148. Calculo()
  149. End Sub
  150. Private Sub ControlFechaOperacion()
  151. Dim valor As Date
  152. valor = dtpFechaOperacion.Value.Date
  153. If TipoTransaccion = "N" Then
  154. oDAPCE.FechaOperacion = valor
  155. End If
  156. RefrescarValorControles()
  157. End Sub
  158. Private Sub txtIngresoBruto_TextChanged(sender As Object, e As EventArgs)
  159. End Sub
  160. Private Sub txtTasa_TextChanged(sender As Object, e As EventArgs) Handles txtTasa.TextChanged
  161. Calculo()
  162. If (txtTasa.ToString.IndexOf("%") = -1) Then
  163. txtTasa.Text += "%"
  164. End If
  165. CalcularPlazo()
  166. Calculo()
  167. End Sub
  168. Private Sub txtTasa_LostFocus(sender As Object, e As EventArgs) Handles txtTasa.LostFocus
  169. End Sub
  170. Private Sub ControlTasa()
  171. Dim valor As Double
  172. If Not Double.TryParse(txtTasa.Text, valor) Then
  173. txtTasa.Focus()
  174. txtTasa.BackColor = Configuraciones.ColorFondoError
  175. Else
  176. txtTasa.BackColor = Color.White
  177. If TipoTransaccion = "N" Or TipoTransaccion = "M" Then
  178. oDAPCE.Tasa = valor
  179. End If
  180. RefrescarValorControles()
  181. End If
  182. End Sub
  183. Private Sub txtMontoInversion_TextChanged(sender As Object, e As EventArgs) Handles txtMontoInversion.TextChanged
  184. CalcularPlazo()
  185. Calculo()
  186. End Sub
  187. Private Sub txtMontoInversion_LostFocus(sender As Object, e As EventArgs) Handles txtMontoInversion.LostFocus
  188. End Sub
  189. Private Sub ControlMontoInversion()
  190. Dim valor As Double
  191. If Not Double.TryParse(txtMontoInversion.Text, valor) Then
  192. txtMontoInversion.Focus()
  193. txtMontoInversion.BackColor = Configuraciones.ColorFondoError
  194. Else
  195. txtMontoInversion.BackColor = Color.White
  196. If TipoTransaccion = "N" Or TipoTransaccion = "M" Then
  197. oDAPCE.MontoDeInversion = valor
  198. End If
  199. RefrescarValorControles()
  200. End If
  201. End Sub
  202. Private Sub txtIngresoNeto_TextChanged(sender As Object, e As EventArgs)
  203. End Sub
  204. Sub CargarPeriodos()
  205. If cboPeriodicidad.Items.Count = 0 Or cboPeriodicidad.Items.Count = 1 Then
  206. Me.cboPeriodicidad.DataSource = oDAOGeneral.ListaPeriodicidad
  207. Me.cboPeriodicidad.DisplayMember = "Descripcion"
  208. Me.cboPeriodicidad.ValueMember = "Codigo"
  209. Me.cboPeriodicidad.SelectedIndex = 0
  210. End If
  211. End Sub
  212. Private Sub btnAceptar_Click(sender As Object, e As EventArgs)
  213. If (Estado = "N") Then
  214. NuevoElemento()
  215. ElseIf (Estado = "M") Then
  216. ModificarElemento()
  217. ElseIf (Estado = "B") Then
  218. EliminarElemento()
  219. End If
  220. End Sub
  221. Function RetornarObjeto()
  222. Return oDAPCE
  223. End Function
  224. Private Sub CargarRegistroBD()
  225. oDAPCE = Nothing
  226. oDAPDAO = New DepositosAPlazoDAO
  227. CodigoInversion = Variables.Codigo
  228. oDAPCE = oDAPDAO.CargarRegistro(Me.CodigoInversion)
  229. TipoTransaccion = "C"
  230. RefrescarValorControles()
  231. End Sub
  232. Public Sub CargarRegistro(vId As Integer, vTipo As String)
  233. TipoTransaccion = "C"
  234. IdDocumento = vId
  235. TipoDocumento = vTipo
  236. End Sub
  237. Private Sub dtpFechaVencimiento_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimiento.ValueChanged
  238. CalcularPlazo()
  239. Calculo()
  240. End Sub
  241. Private Sub ControlFechaVencimiento()
  242. Dim valor As Date
  243. valor = dtpFechaVencimiento.Value.Date.ToString
  244. If TipoTransaccion = "N" Or TipoTransaccion = "M" Then
  245. oDAPCE.FechaVencimiento = valor
  246. End If
  247. RefrescarValorControles()
  248. End Sub
  249. Private Sub cboPeriodicidad_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboPeriodicidad.SelectedIndexChanged
  250. CalcularPlazo()
  251. Calculo()
  252. End Sub
  253. Private Sub ControlPreriodicidad()
  254. Dim valor As String
  255. If vCargado Then
  256. If TipoTransaccion = "N" Or TipoTransaccion = "M" Then
  257. valor = cboPeriodicidad.SelectedValue
  258. oDAPCE.Periodicidad = valor
  259. End If
  260. If TipoTransaccion IsNot Nothing Then
  261. RefrescarValorControles()
  262. End If
  263. End If
  264. End Sub
  265. Public Sub CargarRegistro(ByRef vCodigoInversion As String)
  266. TipoTransaccion = "C"
  267. Me.CodigoInversion = vCodigoInversion
  268. End Sub
  269. Private Sub RefrescarValorControles()
  270. If Not oDAPCE Is Nothing Then
  271. Me.txtMontoInversion.Text = oDAPCE.MontoDeInversion.ToString(Configuraciones.CodigoTXTMontos)
  272. Me.dtpFechaOperacion.Value = oDAPCE.FechaOperacion
  273. Me.dtpFechaVencimiento.Value = oDAPCE.FechaVencimiento
  274. Me.txtTasa.Text = oDAPCE.Tasa.ToString(Configuraciones.CodigoTXTMontos)
  275. txtPlazo.Text = oDAPCE.Plazo.ToString
  276. 'anio base
  277. Me.cboPeriodicidad.SelectedValue = oDAPCE.Periodicidad
  278. Me.txtRendimientoBruto.Text = oDAPCE.RendimientoBruto.ToString(Configuraciones.CodigoTXTMontos)
  279. Me.txtRendimientoNeto.Text = oDAPCE.RendimientoNeto.ToString(Configuraciones.CodigoTXTMontos)
  280. For Each item As DataRow In oDAPCE.dtIntereses.Rows
  281. Me.txtImpuesto.Text = Operaciones.ConvertirDecimal(item("PorcImp").ToString) * 100
  282. Next
  283. End If
  284. End Sub
  285. Private Sub dgvIntereses_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) Handles dgvIntereses.CellBeginEdit
  286. End Sub
  287. Private Sub RefrescarClaseEntidad()
  288. ControlMontoInversion()
  289. ControlFechaOperacion()
  290. ControlFechaVencimiento()
  291. ControlTasa()
  292. ControlPlazo()
  293. ControlPreriodicidad()
  294. End Sub
  295. Private Sub dgvIntereses_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIntereses.CellEndEdit
  296. End Sub
  297. Private Sub dgvIntereses_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIntereses.CellContentClick
  298. End Sub
  299. Private Sub PrepararNuevo()
  300. oDAPCE = New DepositosAPlazoCE
  301. RefrescarValorControles()
  302. End Sub
  303. Private Sub dgvIntereses_CellLeave(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIntereses.CellLeave
  304. End Sub
  305. Private Sub dgvIntereses_CellEnter(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIntereses.CellEnter
  306. End Sub
  307. Private Sub dgvIntereses_RowPostPaint(sender As Object, e As DataGridViewRowPostPaintEventArgs) Handles dgvIntereses.RowPostPaint
  308. End Sub
  309. Private Sub dgvIntereses_RowPrePaint(sender As Object, e As DataGridViewRowPrePaintEventArgs) Handles dgvIntereses.RowPrePaint
  310. End Sub
  311. Private Sub dgvIntereses_RowsAdded(sender As Object, e As DataGridViewRowsAddedEventArgs) Handles dgvIntereses.RowsAdded
  312. End Sub
  313. Private Sub dgvIntereses_RowValidated(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIntereses.RowValidated
  314. End Sub
  315. Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
  316. btnGME.Text = "Modificar"
  317. Estado = "M"
  318. End Sub
  319. Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
  320. btnGME.Text = "Nuevo"
  321. Estado = "N"
  322. End Sub
  323. Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
  324. btnGME.Text = "Eliminar"
  325. Estado = "B"
  326. End Sub
  327. Function ColeccionDatos()
  328. Dim Coleccion As New Collection
  329. Dim MontoInv, FOper, FVenc, Tasa, Plazo, Periodic, RendBr, RendNet, IngrBrutoTot, IngrNetoTot, Renta As String
  330. MontoInv = Operaciones.ConvertirDecimal(txtMontoInversion.Text.ToString)
  331. FOper = dtpFechaOperacion.Value
  332. FVenc = dtpFechaVencimiento.Value
  333. Tasa = Operaciones.ConvertirDecimal(txtTasa.Text.ToString)
  334. Plazo = Operaciones.ConvertirEntero(txtPlazo.Text.ToString)
  335. Periodic = cboPeriodicidad.SelectedValue
  336. RendBr = Operaciones.ConvertirDecimal(txtRendimientoBruto.Text.ToString) / 100
  337. RendNet = Operaciones.ConvertirDecimal(txtRendimientoNeto.Text.ToString) / 100
  338. IngrBrutoTot = Operaciones.ConvertirDecimal(txtIngresoBruto.Text.ToString)
  339. IngrNetoTot = Operaciones.ConvertirDecimal(txtIngresoNeto.Text.ToString)
  340. Renta = Operaciones.ConvertirDecimal(txtRenta.Text.ToString)
  341. Coleccion.Add(MontoInv)
  342. Coleccion.Add(FOper)
  343. Coleccion.Add(FVenc)
  344. Coleccion.Add(Tasa)
  345. Coleccion.Add(Plazo)
  346. Coleccion.Add(Periodic)
  347. Coleccion.Add(RendBr)
  348. Coleccion.Add(RendNet)
  349. Coleccion.Add(IngrBrutoTot)
  350. Coleccion.Add(IngrNetoTot)
  351. Coleccion.Add(Renta)
  352. Return Coleccion
  353. End Function
  354. Function ColeccionElementos(ByVal Index As Integer)
  355. Dim Coleccion As New Collection
  356. Dim Correlativo, plazo, Fecha, IngBruto, PorcImp, MontoImp, IngrNeto As String
  357. Correlativo = Operaciones.ConvertirEntero(dgvIntereses.Rows(Index).Cells("Correlativo").Value.ToString)
  358. plazo = Operaciones.ConvertirEntero(dgvIntereses.Rows(Index).Cells("Plazo").Value.ToString)
  359. Fecha = Operaciones.ConvertirFecha(dgvIntereses.Rows(Index).Cells("Fecha").Value.ToString)
  360. IngBruto = Operaciones.ConvertirDecimal(dgvIntereses.Rows(Index).Cells("Ingreso Bruto").Value.ToString)
  361. PorcImp = Operaciones.ConvertirDecimal(dgvIntereses.Rows(Index).Cells("% Impuesto").Value.ToString)
  362. MontoImp = Operaciones.ConvertirDecimal(dgvIntereses.Rows(Index).Cells("Monto del Impuesto").Value.ToString)
  363. IngrNeto = Operaciones.ConvertirDecimal(dgvIntereses.Rows(Index).Cells("Ingreso Neto").Value.ToString)
  364. Coleccion.Add(Correlativo)
  365. Coleccion.Add(plazo)
  366. Coleccion.Add(Fecha)
  367. Coleccion.Add(IngBruto)
  368. Coleccion.Add(PorcImp)
  369. Coleccion.Add(MontoImp)
  370. Coleccion.Add(IngrNeto)
  371. Return Coleccion
  372. End Function
  373. Sub Calculo()
  374. Dim Plazo As Integer = 0
  375. Plazo = Operaciones.ConvertirEntero(txtPlazo.Text.ToString)
  376. dtpFechaVencimiento.Value = dtpFechaOperacion.Value.AddDays(Plazo)
  377. CalcularRendBruto()
  378. CalcularRendNeto()
  379. End Sub
  380. Sub CalcularRendBruto()
  381. If (Not String.IsNullOrEmpty(txtMontoInversion.Text.ToString) And Not txtMontoInversion.Text.ToString = "0.0" And Not String.IsNullOrEmpty(txtPlazo.Text.ToString) And Not txtPlazo.Text.ToString = "0.0") Then
  382. Dim Total = TotalIngreso()
  383. Dim MontoInv = Operaciones.ConvertirDecimal(txtMontoInversion.Text.ToString)
  384. Dim Base = 365
  385. Dim pla = Operaciones.ConvertirEntero(txtPlazo.Text.ToString)
  386. Dim tot As Double = 0
  387. If (Not MontoInv = 0 And Not pla = 0) Then
  388. tot = (Total / MontoInv) * (Base / pla)
  389. End If
  390. txtRendimientoBruto.Text = CStr((tot * 100)) + "%"
  391. Else
  392. txtRendimientoBruto.Text = "0.0%"
  393. End If
  394. End Sub
  395. Sub CalcularRendNeto()
  396. If (Not String.IsNullOrEmpty(txtMontoInversion.Text.ToString) And Not txtMontoInversion.Text.ToString = "0.0" And Not String.IsNullOrEmpty(txtPlazo.Text.ToString) And Not txtPlazo.Text.ToString = "0.0") Then
  397. Dim Total = TotalIngresoNeto()
  398. Dim MontoInv = Operaciones.ConvertirDecimal(txtMontoInversion.Text.ToString)
  399. Dim Base = 365
  400. Dim pla = Operaciones.ConvertirEntero(txtPlazo.Text.ToString)
  401. Dim tot As Double = 0
  402. If (Not MontoInv = 0 And Not pla = 0) Then
  403. tot = (Total / MontoInv) * (Base / pla)
  404. End If
  405. txtRendimientoNeto.Text = CStr((tot * 100)) + "%"
  406. Else
  407. txtRendimientoNeto.Text = "0.0%"
  408. End If
  409. End Sub
  410. Function TotalIngreso()
  411. Dim Cantidad = CDec(dgvIntereses.Rows.Count - 1)
  412. Dim TotalIngr As Double = 0
  413. For i As Integer = 0 To Cantidad
  414. TotalIngr = TotalIngr + Operaciones.ConvertirDecimal(dgvIntereses.Rows(i).Cells("Ingreso Bruto").Value)
  415. Next
  416. Return TotalIngr
  417. End Function
  418. Function TotalIngresoNeto()
  419. Dim Cantidad = dgvIntereses.Rows.Count - 1
  420. Dim TotalIngr As Double = 0
  421. For i As Integer = 0 To Cantidad
  422. TotalIngr = TotalIngr + Operaciones.ConvertirDecimal(dgvIntereses.Rows(i).Cells("Ingreso Neto").Value)
  423. Next
  424. Return TotalIngr
  425. End Function
  426. Private Sub Button1_Click(sender As Object, e As EventArgs)
  427. End Sub
  428. Function NuevoElemento()
  429. Dim Index As Integer = dgvIntereses.Rows.Count - 2
  430. Dim diccionario As New Dictionary(Of String, Collection)
  431. For i As Integer = 0 To Index
  432. Dim colec As Collection = ColeccionElementos(i)
  433. diccionario.Add(i, colec)
  434. Next
  435. Return diccionario
  436. End Function
  437. Function NuevoElementoGuardar()
  438. Dim Index As Integer = dgvIntereses.Rows.Count - 2
  439. For i As Integer = 0 To Index
  440. Dim colec As Collection = ColeccionElementos(i)
  441. oDAPDAO.NuevoElemento(colec, codigo)
  442. Next
  443. End Function
  444. Sub ModificarElemento()
  445. oDAPDAO.EliminarElemento(codigo)
  446. NuevoElementoGuardar()
  447. End Sub
  448. Sub EliminarElemento()
  449. oDAPDAO.EliminarElemento(codigo)
  450. End Sub
  451. Sub Nuevo()
  452. Dim colec As Collection = ColeccionDatos()
  453. Dim Diccionario As Dictionary(Of String, Collection) = NuevoElemento()
  454. oDAPDAO.NuevoDato(colec, Diccionario, codigo)
  455. End Sub
  456. Sub Modificar()
  457. Dim colec As Collection = ColeccionDatos()
  458. Dim Diccionario As Dictionary(Of String, Collection) = NuevoElemento()
  459. oDAPDAO.ModificarDato(colec, codigo, NuevoElemento())
  460. End Sub
  461. Sub Eliminar()
  462. Dim codigo As String = Variables.Codigo
  463. oDAPDAO.Eliminar(codigo)
  464. End Sub
  465. Private Sub btnGME_Click(sender As Object, e As EventArgs) Handles btnGME.Click
  466. If (Estado = "N") Then
  467. Nuevo()
  468. ElseIf (Estado = "M") Then
  469. Modificar()
  470. ElseIf (Estado = "B") Then
  471. Eliminar()
  472. ElseIf Not ExisteValidacion() Then
  473. Variables.ColeccionDAP = ColeccionDatos()
  474. Variables.ColeccionDAPDi = NuevoElemento()
  475. Me.Close()
  476. End If
  477. End Sub
  478. Private Sub txtRendimientoBruto_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoBruto.TextChanged
  479. End Sub
  480. Private Sub Button1_Click_1(sender As Object, e As EventArgs)
  481. Me.Operaciones.CambioBase(dtpFechaOperacion.Value, dtpFechaVencimiento.Value)
  482. End Sub
  483. Private Sub txtPlazo_TextChanged_1(sender As Object, e As EventArgs) Handles txtPlazo.TextChanged
  484. CalcularPlazo()
  485. Calculo()
  486. End Sub
  487. Sub AgregarCampos()
  488. Dim Correlativo, Plazo, Fecha, IngrBruto, PorcImp, MontoImp, IngrNeto As New DataGridViewTextBoxColumn
  489. Correlativo.Name = "Correlativo"
  490. Plazo.Name = "Plazo"
  491. Fecha.Name = "Fecha"
  492. IngrBruto.Name = "Ingreso Bruto"
  493. PorcImp.Name = "% Impuesto"
  494. PorcImp.DefaultCellStyle.Format = Configuraciones.CodigoTXTPorcentaje
  495. MontoImp.Name = "Monto del Impuesto"
  496. IngrNeto.Name = "Ingreso Neto"
  497. dgvIntereses.Columns.Add(Correlativo)
  498. dgvIntereses.Columns.Add(Plazo)
  499. dgvIntereses.Columns.Add(Fecha)
  500. dgvIntereses.Columns.Add(IngrBruto)
  501. dgvIntereses.Columns.Add(PorcImp)
  502. dgvIntereses.Columns.Add(MontoImp)
  503. dgvIntereses.Columns.Add(IngrNeto)
  504. End Sub
  505. Sub CalcularPlazo()
  506. dgvIntereses.Rows.Clear()
  507. Dim PlazoGlobal As Integer = 0
  508. PlazoGlobal = Operaciones.ConvertirDecimal(txtPlazo.Text.ToString)
  509. Dim Periodicidad As String = String.Empty
  510. If Not cboPeriodicidad.SelectedValue Is Nothing Then
  511. Try
  512. Periodicidad = cboPeriodicidad.SelectedValue
  513. Catch ex As Exception
  514. End Try
  515. End If
  516. Dim FechaInicial As Date = dtpFechaOperacion.Value
  517. Dim IngrBruto As Double = 0.0
  518. Dim Monto
  519. Dim Tasa As Double = 0
  520. Dim Impuesto As Double = 0
  521. Monto = Operaciones.ConvertirDecimal(txtMontoInversion.Text.ToString)
  522. Tasa = Operaciones.ConvertirDecimal(txtTasa.Text.ToString) / 100
  523. Impuesto = Operaciones.ConvertirDecimal(txtImpuesto.Text.ToString) / 100
  524. Dim Renta As Double = 0.0
  525. Dim FechaAnterior As Date
  526. Dim IngresoNeto As Double = 0.0
  527. Dim SumaIngresoBruto, SumaRenta, SumaIngresoNeto As Double
  528. Dim Plazo = DepositoCalcular.CalcularPlazo(Periodicidad)
  529. Dim Cantidad = DepositoCalcular.CalcularIteraciones(PlazoGlobal, Plazo)
  530. Dim Fecha As String = String.Empty
  531. For i As Integer = 1 To Cantidad
  532. If (i = 1) Then
  533. Fecha = Format(DepositoCalcular.CalcularFecha(Plazo, FechaInicial), "dd/MM/yyyy")
  534. IngrBruto = DepositoCalcular.CalculosIngrBruto(FechaInicial, Fecha, Monto, Tasa, Plazo)
  535. Else
  536. If (String.IsNullOrEmpty(Fecha.ToString)) Then
  537. Exit Sub
  538. End If
  539. FechaAnterior = Fecha
  540. Fecha = Format(DepositoCalcular.CalcularFecha(Plazo, Fecha), "dd/MM/yyyy")
  541. IngrBruto = DepositoCalcular.CalculosIngrBruto(FechaAnterior, Fecha, Monto, Tasa, Plazo)
  542. End If
  543. Renta = DepositoCalcular.Renta(Impuesto, IngrBruto)
  544. IngresoNeto = DepositoCalcular.CalculosIngNeto(IngrBruto, Renta)
  545. SumaIngresoBruto = SumaIngresoBruto + IngrBruto
  546. SumaRenta = SumaRenta + Renta
  547. SumaIngresoNeto = SumaIngresoNeto + IngresoNeto
  548. dgvIntereses.Rows.Add(i, Plazo, Fecha, IngrBruto, Impuesto, Renta, IngresoNeto)
  549. Next
  550. txtIngresoBruto.Text = SumaIngresoBruto
  551. txtRenta.Text = SumaRenta
  552. txtIngresoNeto.Text = SumaIngresoNeto
  553. End Sub
  554. Private Sub txtMontoInversion_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtMontoInversion.KeyPress
  555. If String.IsNullOrEmpty(txtMontoInversion.Text) Then
  556. If e.KeyChar = "." Then
  557. txtMontoInversion.Text = "0"
  558. Exit Sub
  559. End If
  560. End If
  561. If (Not txtMontoInversion.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  562. Operaciones.ValidarEntrada(sender, e, True)
  563. Else
  564. Operaciones.ValidarEntrada(sender, e, False)
  565. End If
  566. End Sub
  567. Private Sub txtPlazo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPlazo.KeyPress
  568. If String.IsNullOrEmpty(txtPlazo.Text) Then
  569. If e.KeyChar = "." Then
  570. txtPlazo.Text = "0"
  571. Exit Sub
  572. End If
  573. End If
  574. If (Not txtPlazo.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  575. Operaciones.ValidarEntrada(sender, e, True)
  576. Else
  577. Operaciones.ValidarEntrada(sender, e, False)
  578. End If
  579. End Sub
  580. Private Sub txtTasa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtTasa.KeyPress
  581. If String.IsNullOrEmpty(txtTasa.Text) Then
  582. If e.KeyChar = "." Then
  583. txtTasa.Text = "0"
  584. Exit Sub
  585. End If
  586. End If
  587. If (Not txtTasa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  588. Operaciones.ValidarEntrada(sender, e, True)
  589. Else
  590. Operaciones.ValidarEntrada(sender, e, False)
  591. End If
  592. End Sub
  593. Private Sub txtMontoInversion_Leave(sender As Object, e As EventArgs) Handles txtMontoInversion.Leave
  594. RellenarDatos()
  595. End Sub
  596. Private Sub txtPlazo_Leave(sender As Object, e As EventArgs) Handles txtPlazo.Leave
  597. RellenarDatos()
  598. End Sub
  599. Private Sub txtTasa_Leave(sender As Object, e As EventArgs) Handles txtTasa.Leave
  600. RellenarDatos()
  601. End Sub
  602. Private Sub txtMontoInversion_KeyUp(sender As Object, e As KeyEventArgs) Handles txtMontoInversion.KeyUp
  603. If txtMontoInversion.Text = "." Then
  604. txtMontoInversion.Text = ".0"
  605. End If
  606. End Sub
  607. Private Sub txtPlazo_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPlazo.KeyUp
  608. If txtPlazo.Text = "." Then
  609. txtPlazo.Text = ".0"
  610. End If
  611. End Sub
  612. Private Sub txtTasa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtTasa.KeyUp
  613. If txtTasa.Text = "." Then
  614. txtTasa.Text = ".0"
  615. End If
  616. End Sub
  617. Private Sub txtImpuesto_TextChanged(sender As Object, e As EventArgs) Handles txtImpuesto.TextChanged
  618. CalcularPlazo()
  619. Calculo()
  620. End Sub
  621. Sub CargarTransladoNuevo()
  622. Dim Existe As Boolean = ExisteInversion()
  623. If Not RetCodigoInversionExiste And Not Existe Then
  624. txtMontoInversion.Text = Variables.RetMonto
  625. txtTasa.Text = Variables.RetRendimiento
  626. End If
  627. End Sub
  628. Private Sub txtRendimientoNeto_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoNeto.TextChanged
  629. End Sub
  630. Private Sub BindingNavigator1_RefreshItems(sender As Object, e As EventArgs) Handles BindingNavigator1.RefreshItems
  631. End Sub
  632. End Class