frmDepositosAPlazo.vb 27 KB

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