| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066 |
- Public Class frmDepositosAPlazo
- Dim AnioBase As Integer = 365
- Dim oDAPCE As New DepositosAPlazoCE
- Dim oDAPDAO As New DepositosAPlazoDAO
- Dim oDAOGeneral As New DAOGeneral
- Private vCargado As Boolean = False
- Dim Estado As String = " "
- Dim codigo As String = Variables.Codigo
- Dim Operaciones As New Operaciones
- Dim DepositoCalcular As New DepositosAPlazoCE
- 'Dim oUtilidades As New Utilidades
- Private _TipoTransaccion As String
- Private _IdDocumento As Integer
- Private _TipoDocumento As String
- Private _CodigoInversion As String
- Private Property CodigoInversion As String
- Get
- Return _CodigoInversion
- End Get
- Set(value As String)
- _CodigoInversion = value
- End Set
- End Property
- Public Property TipoTransaccion As String
- Get
- Return _TipoTransaccion
- End Get
- Set(value As String)
- _TipoTransaccion = value
- End Set
- End Property
- Private Property IdDocumento As Integer
- Get
- Return _IdDocumento
- End Get
- Set(value As Integer)
- _IdDocumento = value
- End Set
- End Property
- Private Property TipoDocumento As String
- Get
- Return _TipoDocumento
- End Get
- Set(value As String)
- _TipoDocumento = value
- End Set
- End Property
- Sub RellenarDatos()
- If (String.IsNullOrEmpty(txtMontoInversion.Text.ToString)) Then
- txtMontoInversion.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtPlazo.Text.ToString)) Then
- txtPlazo.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtTasa.Text.ToString.Trim("%"))) Then
- txtTasa.Text = "0.0%"
- End If
- End Sub
- Private Sub frmDAP_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- 'Me.txtBase.Text = AnioBase.ToString
- dgvIntereses.Columns.Clear()
- AgregarCampos()
- Call CargarPeriodos()
- If TipoTransaccion Is Nothing Then
- TipoTransaccion = "N"
- PrepararNuevo()
- End If
- Call CargarRegistroBD()
- PreparardgvIntereses()
- CalcularPlazo()
- Calculo()
- vCargado = True
- ExisteInversion()
- ValidarExistencia()
- CargarTransladoNuevo()
- End Sub
- Function ExisteInversion()
- Dim Codigo As String = Variables.Codigo
- Dim TablaINV As String = "INV0"
- Dim TablaPINV As String = "PIN0"
- Dim General As New DAOGeneral
- Dim InvPro = Variables.InvPro
- If InvPro = "I" Then
- Dim INV0 As Boolean = General.ExisteTitulo(Codigo, TablaINV)
- If INV0 Then
- navNuevo.Visible = True
- Return True
- Else
- navNuevo.Visible = False
- Return False
- End If
- End If
- If InvPro = "P" Then
- Dim PINV0 As Boolean = General.ExisteTitulo(Codigo, TablaPINV)
- If PINV0 Then
- navNuevo.Visible = True
- Return True
- Else
- navNuevo.Visible = False
- Return False
- End If
- End If
- Return False
- End Function
- Sub ValidarExistencia()
- Dim General As New DAOGeneral
- Dim Codigo As String = Variables.Codigo
- Dim Tabla As String = String.Empty
- Tabla = "DAP0"
- Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
- If (Existe) Then
- navNuevo.Enabled = False
- navModificar.Enabled = True
- navEliminar.Enabled = True
- Else
- navNuevo.Enabled = True
- navModificar.Enabled = False
- navEliminar.Enabled = False
- 'LimpiarCampos()
- End If
- Estado = String.Empty
- btnGME.Text = "Aceptar"
- End Sub
- Function ExisteValidacion()
- Dim General As New DAOGeneral
- Dim Codigo As String = Variables.Codigo
- Dim Tabla As String = String.Empty
- Tabla = "DAP0"
- Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
- Return Existe
- End Function
- Sub LimpiarCampos()
- txtMontoInversion.Text = "0"
- txtPlazo.Text = 0
- txtTasa.Text = 0
- cboPeriodicidad.SelectedIndex = 0
- txtRendimientoBruto.Text = "0.0%"
- txtRendimientoNeto.Text = "0.0%"
- dtpFechaOperacion.Value = Date.Now.Date
- dtpFechaVencimiento.Value = Date.Now.Date
- End Sub
- Private Sub txtPlazo_TextChanged(sender As Object, e As EventArgs)
- 'If Modo = "N" Then
- ' RefrescarFechaVencimiento()
- ' CalcularIntereses()
- 'End If
- Calculo()
- End Sub
- Private Sub txtPlazo_LostFocus(sender As Object, e As EventArgs)
- ' ControlPlazo()
- End Sub
- Private Sub ControlPlazo()
- Dim valor As Integer
- If Not Integer.TryParse(txtPlazo.Text.ToString, valor) Then
- txtPlazo.Focus()
- txtPlazo.BackColor = Configuraciones.ColorFondoError
- Else
- txtPlazo.BackColor = Color.White
- If TipoTransaccion = "N" Or TipoTransaccion = "M" Then
- oDAPCE.Plazo = valor
- End If
- RefrescarValorControles()
- End If
- End Sub
- Private Sub dtpFechaOperacion_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaOperacion.ValueChanged
- 'If Modo = "N" Then
- ' RefrescarFechaVencimiento()
- 'End If
- 'ControlFechaOperacion()
- CalcularPlazo()
- Calculo()
- End Sub
- Private Sub ControlFechaOperacion()
- Dim valor As Date
- valor = dtpFechaOperacion.Value.Date
- If TipoTransaccion = "N" Then
- oDAPCE.FechaOperacion = valor
- End If
- RefrescarValorControles()
- End Sub
- Private Sub txtIngresoBruto_TextChanged(sender As Object, e As EventArgs)
- 'If Modo = "N" Then
- ' RefrescarRendimientoBruto()
- 'End If
- End Sub
- Private Sub txtTasa_TextChanged(sender As Object, e As EventArgs) Handles txtTasa.TextChanged
- 'If Modo = "N" Then
- ' CalcularIntereses()
- 'End If
- Calculo()
- If (txtTasa.ToString.IndexOf("%") = -1) Then
- txtTasa.Text += "%"
- End If
- CalcularPlazo()
- Calculo()
- End Sub
- Private Sub txtTasa_LostFocus(sender As Object, e As EventArgs) Handles txtTasa.LostFocus
- ' ControlTasa()
- End Sub
- Private Sub ControlTasa()
- Dim valor As Double
- If Not Double.TryParse(txtTasa.Text, valor) Then
- txtTasa.Focus()
- txtTasa.BackColor = Configuraciones.ColorFondoError
- Else
- txtTasa.BackColor = Color.White
- If TipoTransaccion = "N" Or TipoTransaccion = "M" Then
- oDAPCE.Tasa = valor
- End If
- RefrescarValorControles()
- End If
- End Sub
- Private Sub txtMontoInversion_TextChanged(sender As Object, e As EventArgs) Handles txtMontoInversion.TextChanged
- 'If Modo = "N" Then
- ' CalcularIntereses()
- 'End If
- CalcularPlazo()
- Calculo()
- End Sub
- Private Sub txtMontoInversion_LostFocus(sender As Object, e As EventArgs) Handles txtMontoInversion.LostFocus
- ' ControlMontoInversion()
- End Sub
- Private Sub ControlMontoInversion()
- Dim valor As Double
- If Not Double.TryParse(txtMontoInversion.Text, valor) Then
- txtMontoInversion.Focus()
- txtMontoInversion.BackColor = Configuraciones.ColorFondoError
- Else
- txtMontoInversion.BackColor = Color.White
- If TipoTransaccion = "N" Or TipoTransaccion = "M" Then
- oDAPCE.MontoDeInversion = valor
- End If
- RefrescarValorControles()
- End If
- End Sub
- Private Sub txtIngresoNeto_TextChanged(sender As Object, e As EventArgs)
- 'If Modo = "N" Then
- ' RefrescarRendimientoNeto()
- 'End If
- End Sub
- Sub CargarPeriodos()
- If cboPeriodicidad.Items.Count = 0 Or cboPeriodicidad.Items.Count = 1 Then
- Me.cboPeriodicidad.DataSource = oDAOGeneral.ListaPeriodicidad
- Me.cboPeriodicidad.DisplayMember = "Descripcion"
- Me.cboPeriodicidad.ValueMember = "Codigo"
- Me.cboPeriodicidad.SelectedIndex = 0
- End If
- End Sub
- Private Sub btnAceptar_Click(sender As Object, e As EventArgs)
- If (Estado = "N") Then
- NuevoElemento()
- ElseIf (Estado = "M") Then
- ModificarElemento()
- ElseIf (Estado = "B") Then
- EliminarElemento()
- End If
- End Sub
- Function RetornarObjeto()
- Return oDAPCE
- End Function
- Private Sub CargarRegistroBD()
- oDAPCE = Nothing
- oDAPDAO = New DepositosAPlazoDAO
- CodigoInversion = Variables.Codigo
- 'oDAPDAO.CargarRegistro(oDAPCE, TipoDocumento, IdDocumento)
- oDAPCE = oDAPDAO.CargarRegistro(Me.CodigoInversion)
- TipoTransaccion = "C"
- RefrescarValorControles()
- End Sub
- Public Sub CargarRegistro(vId As Integer, vTipo As String)
- TipoTransaccion = "C"
- IdDocumento = vId
- TipoDocumento = vTipo
- End Sub
- Private Sub dtpFechaVencimiento_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimiento.ValueChanged
- 'ControlFechaVencimiento()
- CalcularPlazo()
- Calculo()
- End Sub
- Private Sub ControlFechaVencimiento()
- Dim valor As Date
- valor = dtpFechaVencimiento.Value.Date.ToString
- If TipoTransaccion = "N" Or TipoTransaccion = "M" Then
- oDAPCE.FechaVencimiento = valor
- End If
- RefrescarValorControles()
- End Sub
- Private Sub cboPeriodicidad_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboPeriodicidad.SelectedIndexChanged
- 'ControlPreriodicidad()
- CalcularPlazo()
- Calculo()
- End Sub
- Private Sub ControlPreriodicidad()
- Dim valor As String
- If vCargado Then
- If TipoTransaccion = "N" Or TipoTransaccion = "M" Then
- valor = cboPeriodicidad.SelectedValue
- oDAPCE.Periodicidad = valor
- End If
- If TipoTransaccion IsNot Nothing Then
- RefrescarValorControles()
- End If
- End If
- End Sub
- Public Sub CargarRegistro(ByRef vCodigoInversion As String)
- TipoTransaccion = "C"
- Me.CodigoInversion = vCodigoInversion
- End Sub
- Private Sub RefrescarValorControles()
- If Not oDAPCE Is Nothing Then
- Me.txtMontoInversion.Text = oDAPCE.MontoDeInversion.ToString(Configuraciones.CodigoTXTMontos)
- Me.dtpFechaOperacion.Value = oDAPCE.FechaOperacion
- Me.dtpFechaVencimiento.Value = oDAPCE.FechaVencimiento
- Me.txtTasa.Text = oDAPCE.Tasa.ToString(Configuraciones.CodigoTXTMontos)
-
- txtPlazo.Text = oDAPCE.Plazo.ToString
- 'txtPlazo.Text = 10 'oDAPCE.Plazo.ToString
- 'anio base
- Me.cboPeriodicidad.SelectedValue = oDAPCE.Periodicidad
- Me.txtRendimientoBruto.Text = oDAPCE.RendimientoBruto.ToString(Configuraciones.CodigoTXTMontos)
- Me.txtRendimientoNeto.Text = oDAPCE.RendimientoNeto.ToString(Configuraciones.CodigoTXTMontos)
- For Each item As DataRow In oDAPCE.dtIntereses.Rows
- Me.txtImpuesto.Text = item("PorcImp") * 100
- Next
- End If
- End Sub
- Private Sub PreparardgvIntereses()
- End Sub
- Private Sub PrepararCalculoIntereses(ByVal IdFila As Integer, idColumna As Integer)
- Dim vFila As DataGridViewRow = dgvIntereses.Rows(IdFila)
- Dim vFilaAnterior As DataGridViewRow
- Dim vFecha As Date
- Dim vFechaAnterior As Date
- Dim vPeriodicidad As String = oDAPCE.Periodicidad
- Dim vDiasDelPeriodo As Integer
- If vFila.IsNewRow Then
- If IdFila = 0 Then
- vFecha = oDAPCE.FechaOperacion
- Else
- vFilaAnterior = dgvIntereses.Rows(IdFila - 1)
- vFecha = vFilaAnterior.Cells("Fecha").Value
- End If
- 'vFecha = vFechaAnterior
- If vPeriodicidad = "M" Then
- vDiasDelPeriodo = 30
- ElseIf vPeriodicidad = "T" Then
- vDiasDelPeriodo = 90
- ElseIf vPeriodicidad = "S" Then
- vDiasDelPeriodo = 180
- Else
- vDiasDelPeriodo = 30
- End If
- vFila.Cells("Plazo").Value = vDiasDelPeriodo
- If Not IdFila = 0 Then
- vFecha = vFecha.AddDays(vFila.Cells("Plazo").Value)
- End If
- vFila.Cells("Fecha").Value = vFecha
- vFila.Cells("PorcImp").Value = 0.1
- vFila.Cells("Estado").Value = "A"
- dgvIntereses.Rows(IdFila).Selected = False
- 'dgvIntereses.Rows.Insert(IdFila + 1)
- 'MsgBox("IsNewRow")
- Else
- 'MsgBox("No IsNewRow")
- End If
- 'CalcularIntereses(IdFila)
- 'dgvIntereses.Refresh()
- End Sub
- Private Sub dgvIntereses_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) Handles dgvIntereses.CellBeginEdit
- 'MsgBox("CellBeginEdit")
- ' PrepararCalculoIntereses(e.RowIndex, e.ColumnIndex)
- End Sub
- Private Sub CalcularIntereses(ByVal IdFila As Integer, ByVal IdCol As Integer)
- Dim vFila As DataGridViewRow = dgvIntereses.Rows(IdFila)
- Dim vFilaAnterior As DataGridViewRow
- Dim vPlazo As Integer = 0
- Dim vFechaAnterior As Date
- Dim vFecha As Date
- Dim vIngresoBruto As Double = 0
- Dim vMontoInversion As Double = oDAPCE.MontoDeInversion
- Dim vTasa As Double = oDAPCE.Tasa
- Dim vPorcentajeImpuesto As Double = 0
- Dim vMontoImpuesto As Double = 0
- Dim vIngresoNeto As Double = 0
- If (Not String.IsNullOrEmpty(vTasa.ToString) And Not vTasa.ToString = "0") Then
- vTasa = vTasa / 100
- End If
- If (Not String.IsNullOrEmpty(vPorcentajeImpuesto.ToString) And Not vPorcentajeImpuesto.ToString = "0") Then
- vPorcentajeImpuesto = vPorcentajeImpuesto / 100
- End If
- If IdFila = 0 Then
- vFechaAnterior = oDAPCE.FechaOperacion
- Else
- vFilaAnterior = dgvIntereses.Rows(IdFila - 1)
- vFechaAnterior = vFilaAnterior.Cells("Fecha").Value
- End If
- 'vFecha = vFila.Cells("Fecha").Value
- vFecha = vFechaAnterior
- 'If vFila.IsNewRow Then
- Integer.TryParse(vFila.Cells("Plazo").Value.ToString, vPlazo)
- Double.TryParse(vFila.Cells("PorcImp").Value.ToString, vPorcentajeImpuesto)
- vFecha = DateAdd(DateInterval.Day, vPlazo, vFecha)
- vIngresoBruto = vMontoInversion * vTasa * vPlazo
- If (Not String.IsNullOrEmpty(Utilidades.CalcularDiasDelAnio(vFecha).ToString) And Not Utilidades.CalcularDiasDelAnio(vFecha) = 0) Then
- vIngresoBruto = vIngresoBruto / Utilidades.CalcularDiasDelAnio(vFecha)
- Else
- vIngresoBruto = "0.0"
- End If
- vFila.Cells("IngrBruto").Value = vIngresoBruto
- vMontoImpuesto = vIngresoBruto * vPorcentajeImpuesto
- vFila.Cells("MontoImp").Value = vMontoImpuesto
- vIngresoNeto = vIngresoBruto - vMontoImpuesto
- vFila.Cells("IngrNeto").Value = vIngresoNeto
- 'End If
- If dgvIntereses.IsCurrentCellDirty Then
- dgvIntereses.CommitEdit(DataGridViewDataErrorContexts.Commit)
- End If
- RefrescarClaseEntidad()
- RefrescarValorControles()
- End Sub
- Private Sub RefrescarClaseEntidad()
- ControlMontoInversion()
- ControlFechaOperacion()
- ControlFechaVencimiento()
- ControlTasa()
- ControlPlazo()
- ControlPreriodicidad()
- End Sub
- Private Sub dgvIntereses_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIntereses.CellEndEdit
- 'If e.ColumnIndex = dgvIntereses.Columns("PorcImp").Index Then
- ' Dim valor As Double
- ' valor = dgvIntereses.Rows(e.RowIndex).Cells("PorcImp").Value
- ' valor = valor / 100
- ' dgvIntereses.Rows(e.RowIndex).Cells("PorcImp").Value = valor
- 'End If
- 'CalcularIntereses(e.RowIndex, e.ColumnIndex)
- End Sub
- Private Sub dgvIntereses_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIntereses.CellContentClick
- End Sub
- Private Sub PrepararNuevo()
- oDAPCE = New DepositosAPlazoCE
- RefrescarValorControles()
- 'PreparardgvIntereses()
- End Sub
- Private Sub dgvIntereses_CellLeave(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIntereses.CellLeave
- End Sub
- Private Sub dgvIntereses_CellEnter(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIntereses.CellEnter
- End Sub
- Private Sub dgvIntereses_RowPostPaint(sender As Object, e As DataGridViewRowPostPaintEventArgs) Handles dgvIntereses.RowPostPaint
- 'MsgBox("RowPostPaint")
- End Sub
- Private Sub dgvIntereses_RowPrePaint(sender As Object, e As DataGridViewRowPrePaintEventArgs) Handles dgvIntereses.RowPrePaint
- 'MsgBox("RowPrePaint")
- End Sub
- Private Sub dgvIntereses_RowsAdded(sender As Object, e As DataGridViewRowsAddedEventArgs) Handles dgvIntereses.RowsAdded
- 'MsgBox("RowsAdded")
- End Sub
- Private Sub dgvIntereses_RowValidated(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIntereses.RowValidated
- End Sub
- Private Sub ActualizarRegistro()
- Dim res As Integer
- RefrescarClaseEntidad()
- res = oDAPDAO.Actualizar(oDAPCE)
- If res > 0 Then
- MsgBox("Registro Guardado")
- Else
- MsgBox("Algo no salio bien.")
- End If
- End Sub
- Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
- btnGME.Text = "Modificar"
- Estado = "M"
- End Sub
- Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
- btnGME.Text = "Nuevo"
- Estado = "N"
- End Sub
- Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
- btnGME.Text = "Eliminar"
- Estado = "B"
- End Sub
- Function ColeccionDatos()
- Dim Coleccion As New Collection
- Dim MontoInv, FOper, FVenc, Tasa, Plazo, Periodic, RendBr, RendNet, IngrBrutoTot, IngrNetoTot, Renta As String
- MontoInv = CDec(txtMontoInversion.Text)
- FOper = CDate(dtpFechaOperacion.Value)
- FVenc = CDate(dtpFechaVencimiento.Value)
- Tasa = CDec(txtTasa.Text.ToString.Trim("%"))
- Plazo = CInt(txtPlazo.Text)
- Periodic = cboPeriodicidad.SelectedValue
- RendBr = CDec(txtRendimientoBruto.Text.ToString.Trim("%")) / 100
- RendNet = CDec(txtRendimientoNeto.Text.ToString.Trim("%")) / 100
- IngrBrutoTot = txtIngresoBruto.Text
- IngrNetoTot = txtIngresoNeto.Text
- Renta = txtRenta.Text
- Coleccion.Add(MontoInv)
- Coleccion.Add(FOper)
- Coleccion.Add(FVenc)
- Coleccion.Add(Tasa)
- Coleccion.Add(Plazo)
- Coleccion.Add(Periodic)
- Coleccion.Add(RendBr)
- Coleccion.Add(RendNet)
- Coleccion.Add(IngrBrutoTot)
- Coleccion.Add(IngrNetoTot)
- Coleccion.Add(Renta)
- Return Coleccion
- End Function
- Function ColeccionElementos(ByVal Index As Integer)
- Dim Coleccion As New Collection
- Dim Correlativo, plazo, Fecha, IngBruto, PorcImp, MontoImp, IngrNeto As String
- Correlativo = dgvIntereses.Rows(Index).Cells("Correlativo").Value.ToString
- plazo = dgvIntereses.Rows(Index).Cells("Plazo").Value.ToString
- Fecha = dgvIntereses.Rows(Index).Cells("Fecha").Value.ToString
- IngBruto = dgvIntereses.Rows(Index).Cells("Ingreso Bruto").Value.ToString
- PorcImp = dgvIntereses.Rows(Index).Cells("% Impuesto").Value.ToString.Trim("%")
- MontoImp = dgvIntereses.Rows(Index).Cells("Monto del Impuesto").Value.ToString
- IngrNeto = dgvIntereses.Rows(Index).Cells("Ingreso Neto").Value.ToString
- Coleccion.Add(Correlativo)
- Coleccion.Add(plazo)
- Coleccion.Add(Fecha)
- Coleccion.Add(IngBruto)
- Coleccion.Add(PorcImp)
- Coleccion.Add(MontoImp)
- Coleccion.Add(IngrNeto)
- Return Coleccion
- End Function
- Sub Calculo()
- Dim Plazo As Integer = 0
- If Not String.IsNullOrEmpty(txtPlazo.Text.ToString) Then
- Plazo = txtPlazo.Text
- End If
- dtpFechaVencimiento.Value = dtpFechaOperacion.Value.AddDays(Plazo)
- CalcularRendBruto()
- CalcularRendNeto()
- End Sub
- Sub CalcularRendBruto()
- 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
- Dim Total = TotalIngreso()
- Dim MontoInv = CDec(txtMontoInversion.Text)
- Dim Base = 365
- Dim pla = CDec(txtPlazo.Text)
- Dim tot As Double = 0
- If (Not MontoInv = 0 And Not pla = 0) Then
- tot = (Total / MontoInv) * (Base / pla)
- End If
- txtRendimientoBruto.Text = CStr((tot * 100)) + "%"
- Else
- txtRendimientoBruto.Text = "0.0%"
- End If
- End Sub
- Sub CalcularRendNeto()
- 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
- Dim Total = TotalIngresoNeto()
- Dim MontoInv = CDec(txtMontoInversion.Text)
- Dim Base = 365
- Dim pla = CDec(txtPlazo.Text)
- Dim tot As Double = 0
- If (Not MontoInv = 0 And Not pla = 0) Then
- tot = (Total / MontoInv) * (Base / pla)
- End If
- txtRendimientoNeto.Text = CStr((tot * 100)) + "%"
- Else
- txtRendimientoNeto.Text = "0.0%"
- End If
- End Sub
- Function TotalIngreso()
- Dim Cantidad = CDec(dgvIntereses.Rows.Count - 1)
- Dim TotalIngr As Double = 0
- For i As Integer = 0 To Cantidad
- TotalIngr = TotalIngr + CDec(dgvIntereses.Rows(i).Cells("Ingreso Bruto").Value)
- Next
- Return TotalIngr
- End Function
- Function TotalIngresoNeto()
- Dim Cantidad = dgvIntereses.Rows.Count - 1
- Dim TotalIngr As Double = 0
- For i As Integer = 0 To Cantidad
- TotalIngr = TotalIngr + CDec(dgvIntereses.Rows(i).Cells("Ingreso Neto").Value)
- Next
- Return TotalIngr
- End Function
- Private Sub Button1_Click(sender As Object, e As EventArgs)
- 'ColeccionElementos()
- End Sub
- Function NuevoElemento()
- Dim Index As Integer = dgvIntereses.Rows.Count - 2
- Dim diccionario As New Dictionary(Of String, Collection)
- For i As Integer = 0 To Index
- Dim colec As Collection = ColeccionElementos(i)
- 'oDAPDAO.NuevoElemento(colec, codigo)
- diccionario.Add(i, colec)
- Next
- Return diccionario
- End Function
- Function NuevoElementoGuardar()
- Dim Index As Integer = dgvIntereses.Rows.Count - 2
- For i As Integer = 0 To Index
- Dim colec As Collection = ColeccionElementos(i)
- oDAPDAO.NuevoElemento(colec, codigo)
- Next
- End Function
- Sub ModificarElemento()
- oDAPDAO.EliminarElemento(codigo)
- NuevoElementoGuardar()
- End Sub
- Sub EliminarElemento()
- oDAPDAO.EliminarElemento(codigo)
- End Sub
- Sub Nuevo()
- Dim colec As Collection = ColeccionDatos()
- Dim Diccionario As Dictionary(Of String, Collection) = NuevoElemento()
- oDAPDAO.NuevoDato(colec, Diccionario, codigo)
- End Sub
- Sub Modificar()
- Dim colec As Collection = ColeccionDatos()
- Dim Diccionario As Dictionary(Of String, Collection) = NuevoElemento()
- oDAPDAO.ModificarDato(colec, codigo, NuevoElemento())
- End Sub
- Sub Eliminar()
- Dim codigo As String = Variables.Codigo
- oDAPDAO.Eliminar(codigo)
- End Sub
- Private Sub btnGME_Click(sender As Object, e As EventArgs) Handles btnGME.Click
- If (Estado = "N") Then
- Nuevo()
- ElseIf (Estado = "M") Then
- Modificar()
- ElseIf (Estado = "B") Then
- Eliminar()
- ElseIf Not ExisteValidacion() Then
- Variables.ColeccionDAP = ColeccionDatos()
- Variables.ColeccionDAPDi = NuevoElemento()
- Me.Close()
- End If
- End Sub
- Private Sub txtRendimientoBruto_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoBruto.TextChanged
- End Sub
- Private Sub Button1_Click_1(sender As Object, e As EventArgs)
- Me.Operaciones.CambioBase(dtpFechaOperacion.Value, dtpFechaVencimiento.Value)
- End Sub
- Private Sub txtPlazo_TextChanged_1(sender As Object, e As EventArgs) Handles txtPlazo.TextChanged
- CalcularPlazo()
- Calculo()
- End Sub
- Sub AgregarCampos()
- Dim Correlativo, Plazo, Fecha, IngrBruto, PorcImp, MontoImp, IngrNeto As New DataGridViewTextBoxColumn
- Correlativo.Name = "Correlativo"
- Plazo.Name = "Plazo"
- Fecha.Name = "Fecha"
- IngrBruto.Name = "Ingreso Bruto"
- PorcImp.Name = "% Impuesto"
- PorcImp.DefaultCellStyle.Format = Configuraciones.CodigoTXTPorcentaje
- MontoImp.Name = "Monto del Impuesto"
- IngrNeto.Name = "Ingreso Neto"
- dgvIntereses.Columns.Add(Correlativo)
- dgvIntereses.Columns.Add(Plazo)
- dgvIntereses.Columns.Add(Fecha)
- dgvIntereses.Columns.Add(IngrBruto)
- dgvIntereses.Columns.Add(PorcImp)
- dgvIntereses.Columns.Add(MontoImp)
- dgvIntereses.Columns.Add(IngrNeto)
- End Sub
- Sub CalcularPlazo()
- dgvIntereses.Rows.Clear()
- Dim PlazoGlobal As Integer = 0
- If String.IsNullOrEmpty(txtPlazo.Text) Then
- PlazoGlobal = 0
- Else
- PlazoGlobal = CDec(txtPlazo.Text)
- End If
- Dim Periodicidad As String = String.Empty
- If Not cboPeriodicidad.SelectedValue Is Nothing Then
- Try
- Periodicidad = cboPeriodicidad.SelectedValue
- Catch ex As Exception
- End Try
- End If
- Dim FechaInicial As Date = dtpFechaOperacion.Value
- Dim IngrBruto As Double = 0.0
- Dim Monto
- If String.IsNullOrEmpty(txtMontoInversion.Text) Then
- Monto = 0
- Else
- Monto = txtMontoInversion.Text
- End If
- Dim Tasa As Double = 0
- If (Not String.IsNullOrEmpty(txtTasa.Text.ToString.Trim("%")) And Not txtTasa.Text.ToString.Trim("%") = "0") Then
- Tasa = (txtTasa.Text.Trim("%") / 100)
- End If
- Dim Impuesto As Double = 0
- If (Not String.IsNullOrEmpty(txtImpuesto.Text.ToString.Trim("%")) And Not txtImpuesto.Text.ToString.Trim("%") = "0") Then
- Impuesto = (txtImpuesto.Text.Trim("%") / 100)
- End If
- Dim Renta As Double = 0.0
- Dim FechaAnterior As Date
- Dim IngresoNeto As Double = 0.0
- Dim SumaIngresoBruto, SumaRenta, SumaIngresoNeto As Double
- Dim Plazo = DepositoCalcular.CalcularPlazo(Periodicidad)
- Dim Cantidad = DepositoCalcular.CalcularIteraciones(PlazoGlobal, Plazo)
- Dim Fecha As String = String.Empty
- For i As Integer = 1 To Cantidad
- If (i = 1) Then
- Fecha = Format(DepositoCalcular.CalcularFecha(Plazo, FechaInicial), "dd/MM/yyyy")
- IngrBruto = DepositoCalcular.CalculosIngrBruto(FechaInicial, Fecha, Monto, Tasa, Plazo)
- Else
- If (String.IsNullOrEmpty(Fecha.ToString)) Then
- Exit Sub
- End If
- FechaAnterior = Fecha
- Fecha = Format(DepositoCalcular.CalcularFecha(Plazo, Fecha), "dd/MM/yyyy")
- IngrBruto = DepositoCalcular.CalculosIngrBruto(FechaAnterior, Fecha, Monto, Tasa, Plazo)
- End If
- Renta = DepositoCalcular.Renta(Impuesto, IngrBruto)
- IngresoNeto = DepositoCalcular.CalculosIngNeto(IngrBruto, Renta)
- SumaIngresoBruto = SumaIngresoBruto + IngrBruto
- SumaRenta = SumaRenta + Renta
- SumaIngresoNeto = SumaIngresoNeto + IngresoNeto
- dgvIntereses.Rows.Add(i, Plazo, Fecha, IngrBruto, Impuesto, Renta, IngresoNeto)
- Next
- txtIngresoBruto.Text = SumaIngresoBruto
- txtRenta.Text = SumaRenta
- txtIngresoNeto.Text = SumaIngresoNeto
- End Sub
- Private Sub txtMontoInversion_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtMontoInversion.KeyPress
- If String.IsNullOrEmpty(txtMontoInversion.Text) Then
- If e.KeyChar = "." Then
- txtMontoInversion.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtMontoInversion.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtPlazo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPlazo.KeyPress
- If String.IsNullOrEmpty(txtPlazo.Text) Then
- If e.KeyChar = "." Then
- txtPlazo.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtPlazo.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtTasa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtTasa.KeyPress
- If String.IsNullOrEmpty(txtTasa.Text) Then
- If e.KeyChar = "." Then
- txtTasa.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtTasa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtMontoInversion_Leave(sender As Object, e As EventArgs) Handles txtMontoInversion.Leave
- RellenarDatos()
- End Sub
- Private Sub txtPlazo_Leave(sender As Object, e As EventArgs) Handles txtPlazo.Leave
- RellenarDatos()
- End Sub
- Private Sub txtTasa_Leave(sender As Object, e As EventArgs) Handles txtTasa.Leave
- RellenarDatos()
- End Sub
- Private Sub txtMontoInversion_KeyUp(sender As Object, e As KeyEventArgs) Handles txtMontoInversion.KeyUp
- If txtMontoInversion.Text = "." Then
- txtMontoInversion.Text = ".0"
- End If
- End Sub
- Private Sub txtPlazo_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPlazo.KeyUp
- If txtPlazo.Text = "." Then
- txtPlazo.Text = ".0"
- End If
- End Sub
- Private Sub txtTasa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtTasa.KeyUp
- If txtTasa.Text = "." Then
- txtTasa.Text = ".0"
- End If
- End Sub
- Private Sub txtImpuesto_TextChanged(sender As Object, e As EventArgs) Handles txtImpuesto.TextChanged
- CalcularPlazo()
- Calculo()
- End Sub
- Sub CargarTransladoNuevo()
- Dim Existe As Boolean = ExisteInversion()
- If Not RetCodigoInversionExiste And Not Existe Then
- txtMontoInversion.Text = Variables.RetMonto
- txtTasa.Text = Variables.RetRendimiento
- End If
- End Sub
- End Class
|