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 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 If (String.IsNullOrEmpty(txtImpuesto.Text.ToString.Trim("%"))) Then txtImpuesto.Text = "10%" End If End Sub Private Sub frmDAP_Load(sender As Object, e As EventArgs) Handles MyBase.Load dgvIntereses.Columns.Clear() AgregarCampos() Call CargarPeriodos() If TipoTransaccion Is Nothing Then TipoTransaccion = "N" PrepararNuevo() End If If ExisteInversion() Then Call CargarRegistroBD() End If CalcularPlazo() Calculo() ValidarExistencia() vCargado = True End Sub Sub BloquearClickDerecho() txtPlazo.ContextMenuStrip = New ContextMenuStrip 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 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 Private Sub txtPlazo_TextChanged(sender As Object, e As EventArgs) Calculo() End Sub Private Sub txtPlazo_LostFocus(sender As Object, e As EventArgs) 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 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) End Sub Private Sub txtTasa_TextChanged(sender As Object, e As EventArgs) Handles txtTasa.TextChanged 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 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 CalcularPlazo() Calculo() End Sub Private Sub txtMontoInversion_LostFocus(sender As Object, e As EventArgs) Handles txtMontoInversion.LostFocus 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) 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 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 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 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 'anio base Me.cboPeriodicidad.SelectedValue = oDAPCE.Periodicidad Me.txtRendimientoBruto.Text = oDAPCE.RendimientoBruto.ToString(Configuraciones.CodigoTXTMontos) Me.txtRendimientoNeto.Text = oDAPCE.RendimientoNeto.ToString(Configuraciones.CodigoTXTMontos) If oDAPCE.dtIntereses.Rows.Count > 0 Then For Each item As DataRow In oDAPCE.dtIntereses.Rows Me.txtImpuesto.Text = Operaciones.ConvertirDecimal(item("PorcImp").ToString) * 100 Next Else Me.txtImpuesto.Text = "10%" End If End If End Sub Private Sub dgvIntereses_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) Handles dgvIntereses.CellBeginEdit 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 End Sub Private Sub dgvIntereses_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIntereses.CellContentClick End Sub Private Sub PrepararNuevo() oDAPCE = New DepositosAPlazoCE RefrescarValorControles() 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 End Sub Private Sub dgvIntereses_RowPrePaint(sender As Object, e As DataGridViewRowPrePaintEventArgs) Handles dgvIntereses.RowPrePaint End Sub Private Sub dgvIntereses_RowsAdded(sender As Object, e As DataGridViewRowsAddedEventArgs) Handles dgvIntereses.RowsAdded End Sub Private Sub dgvIntereses_RowValidated(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIntereses.RowValidated 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 = Operaciones.ConvertirDecimal(txtMontoInversion.Text.ToString) FOper = dtpFechaOperacion.Value FVenc = dtpFechaVencimiento.Value Tasa = Operaciones.ConvertirDecimal(txtTasa.Text.ToString) Plazo = Operaciones.ConvertirEntero(txtPlazo.Text.ToString) Periodic = cboPeriodicidad.SelectedValue RendBr = Operaciones.ConvertirDecimal(txtRendimientoBruto.Text.ToString) / 100 RendNet = Operaciones.ConvertirDecimal(txtRendimientoNeto.Text.ToString) / 100 IngrBrutoTot = Operaciones.ConvertirDecimal(txtIngresoBruto.Text.ToString) IngrNetoTot = Operaciones.ConvertirDecimal(txtIngresoNeto.Text.ToString) Renta = Operaciones.ConvertirDecimal(txtRenta.Text.ToString) 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 = Operaciones.ConvertirEntero(dgvIntereses.Rows(Index).Cells("Correlativo").Value.ToString) plazo = Operaciones.ConvertirEntero(dgvIntereses.Rows(Index).Cells("Plazo").Value.ToString) Fecha = Operaciones.ConvertirFecha(dgvIntereses.Rows(Index).Cells("Fecha").Value.ToString) IngBruto = Operaciones.ConvertirDecimal(dgvIntereses.Rows(Index).Cells("Ingreso Bruto").Value.ToString) PorcImp = Operaciones.ConvertirDecimal(dgvIntereses.Rows(Index).Cells("% Impuesto").Value.ToString) MontoImp = Operaciones.ConvertirDecimal(dgvIntereses.Rows(Index).Cells("Monto del Impuesto").Value.ToString) IngrNeto = Operaciones.ConvertirDecimal(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 Plazo = Operaciones.ConvertirEntero(txtPlazo.Text.ToString) 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 = Operaciones.ConvertirDecimal(txtMontoInversion.Text.ToString) Dim Base = 365 Dim pla = Operaciones.ConvertirEntero(txtPlazo.Text.ToString) 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 = Operaciones.ConvertirDecimal(txtMontoInversion.Text.ToString) Dim Base = 365 Dim pla = Operaciones.ConvertirEntero(txtPlazo.Text.ToString) 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 + Operaciones.ConvertirDecimal(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 + Operaciones.ConvertirDecimal(dgvIntereses.Rows(i).Cells("Ingreso Neto").Value) Next Return TotalIngr End Function Private Sub Button1_Click(sender As Object, e As EventArgs) 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) 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 PlazoGlobal = Operaciones.ConvertirDecimal(txtPlazo.Text.ToString) 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 Dim Tasa As Double = 0 Dim Impuesto As Double = 0 Monto = Operaciones.ConvertirDecimal(txtMontoInversion.Text.ToString) Tasa = Operaciones.ConvertirDecimal(txtTasa.Text.ToString) / 100 Impuesto = Operaciones.ConvertirDecimal(txtImpuesto.Text.ToString) / 100 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 If (txtImpuesto.ToString.IndexOf("%") = -1) Then txtImpuesto.Text += "%" End If CalcularPlazo() Calculo() End Sub Private Sub txtRendimientoNeto_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoNeto.TextChanged End Sub Private Sub BindingNavigator1_RefreshItems(sender As Object, e As EventArgs) Handles BindingNavigator1.RefreshItems End Sub Private Sub txtImpuesto_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtImpuesto.KeyPress If String.IsNullOrEmpty(txtImpuesto.Text) Then If e.KeyChar = "." Then txtImpuesto.Text = "0" Exit Sub End If End If If (Not txtImpuesto.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 txtImpuesto_KeyUp(sender As Object, e As KeyEventArgs) Handles txtImpuesto.KeyUp If txtImpuesto.Text = "." Then txtImpuesto.Text = ".0" End If End Sub Private Sub txtImpuesto_Leave(sender As Object, e As EventArgs) Handles txtImpuesto.Leave RellenarDatos() End Sub End Class