Public Class frmReporto Dim oDAOGeneral As New DAOGeneral Dim Aniobase As Integer = 365 Const PorcentajeComisionCasa As Double = 0.2825 Const PorcentajeComisionBolsa As Double = 0.2825 Const PorcentajeComisionIOF As Double = 0.25 Dim PorcentajeISR As Double = 10 Dim oCEReporto As ReportosCE Dim oDAOReportos As ReportosDAO Dim Reporto As New ReportosCE Dim ReportoConsula As New ReportosDAO Private CodigoInversion As String Dim Estado As String = String.Empty Dim CargarUnaVez As Boolean = True Dim Operaciones As New Operaciones Dim NombreTitulo As New Dictionary(Of String, String) Dim Modificado As Boolean = False Dim InstrumentoFinanciero As String = oDAOGeneral.ObtenerInstrumento(Variables.Codigo) Dim CodigoRotar As Integer = 0 Private _Modo As String Private _IdDocumento As Integer Private _TipoDocumento As String Private Cargado As Boolean = False Private Procesado As Boolean = False Private Tabla As String = String.Empty Private Base As Integer = 0 Private IOFEstado As Integer = 0 Private RentaEstado As Integer = 0 Private TipoOperacionRepo As String = String.Empty Private CodigoRepo As String = String.Empty Private CodigoProveniente As String = String.Empty Dim CodigoCheque As String = String.Empty Sub New() ' Esta llamada es exigida por el diseñador. InitializeComponent() ' Agregue cualquier inicialización después de la llamada a InitializeComponent(). End Sub Public Property Modo As String Get Return _Modo End Get Set(value As String) _Modo = 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 AgregarCamposRepoVenta() Dim Correlativo, Base, Dias, Casa2, Nombre, FCompra, ComisionBolsa, ComisionCasa, codigo, FechaVenta, Monto, FechaVen, CostoFinanciero, Interes, Casa, Bolsa, TotalPagar As New DataGridViewTextBoxColumn Correlativo.Name = "Correlativo" codigo.Name = "codigo" codigo.Visible = False Monto.Name = "Monto" FechaVen.Name = "Fecha de Vencimiento" CostoFinanciero.Name = "Costos Financieros" Interes.Name = "Intereses" Casa.Name = "Casa" Bolsa.Name = "Bolsa" TotalPagar.Name = "Total a Pagar" dgvReportos.Columns.Add(Correlativo) dgvReportos.Columns.Add(Monto) dgvReportos.Columns.Add(FechaVen) dgvReportos.Columns.Add(CostoFinanciero) dgvReportos.Columns.Add(Interes) dgvReportos.Columns.Add(Casa) dgvReportos.Columns.Add(Bolsa) dgvReportos.Columns.Add(TotalPagar) Nombre.Name = "Nombre" FCompra.Name = "FCompra" ComisionCasa.Name = "ComisionCasa" ComisionBolsa.Name = "ComisionBolsa" Casa2.Name = "Casa2" Dias.Name = "Dias" Base.Name = "Base" Nombre.Visible = False FCompra.Visible = False ComisionCasa.Visible = False ComisionBolsa.Visible = False Casa2.Visible = False Base.Visible = False dgvReportos.Columns.Add(Nombre) dgvReportos.Columns.Add(FCompra) dgvReportos.Columns.Add(ComisionCasa) dgvReportos.Columns.Add(ComisionBolsa) dgvReportos.Columns.Add(Casa2) dgvReportos.Columns.Add(Dias) dgvReportos.Columns.Add(codigo) dgvReportos.Columns.Add(Base) End Sub Sub AgregarCampos(ByVal Tipo As Integer) Dim ValTrans, Dias, FVen, Rend, IOF, ComisionCB, CB, OtrosCostos, TotCostos, MontoLiq, InterGen, codigo As New DataGridViewTextBoxColumn Dim CostoTransfv, Correlativo, RendNetoAntImp, ValReCompra, ImpLiquidacion, IngrNeto, ValNeto, RendNetoDespImp As New DataGridViewTextBoxColumn Dim Nombre, FCompra, ComisionCasa, ComisionBolsa, Casa, Base, EstadoIOF, EstadoRenta As New DataGridViewTextBoxColumn Dim Cantidad As Integer = dgvReportos.ColumnCount If Cantidad = 0 Then Correlativo.Name = "Correlativo" codigo.Name = "Codigo" codigo.Visible = False ValTrans.Name = "Valor Trasado" Dias.Name = "Dias" FVen.Name = "Fecha de Vencimiento" Rend.Name = "Rendimiento" IOF.Name = "IOF" ComisionCB.Name = "Comision CB" CB.Name = "Comision Bolsa" OtrosCostos.Name = "Otros Costos" TotCostos.Name = "Total Costos" MontoLiq.Name = "Monto a Liquidar" InterGen.Name = "Interes a Genrerar" CostoTransfv.Name = "Costo de Transferencia" RendNetoAntImp.Name = "R% Neto (Antes de Impuesto)" ValReCompra.Name = "Valor de ReCompra" ImpLiquidacion.Name = "Impuesto de Liquidacion" IngrNeto.Name = "Ingreso Neto" ValNeto.Name = "Valor Neto" RendNetoDespImp.Name = "R% Neto (Despues de Impuesto)" Nombre.Name = "Nombre" FCompra.Name = "FCompra" ComisionCasa.Name = "ComisionCasa" ComisionBolsa.Name = "ComisionBolsa" Casa.Name = "Casa" Base.Name = "Base" EstadoIOF.Name = "EstadoIOF" EstadoRenta.Name = "EstadoRenta" Nombre.Visible = False FCompra.Visible = False ComisionCasa.Visible = False ComisionBolsa.Visible = False Casa.Visible = False Base.Visible = False EstadoIOF.Visible = False EstadoRenta.Visible = False Dim cod As String = Variables.Codigo If cod.IndexOf("REPOVENTA") > -1 Then RendNetoAntImp.HeaderText = "Costo Financiero (Antes de Impuesto)" RendNetoDespImp.HeaderText = "Costo Financiero (Despues de Impuesto)" Rend.HeaderText = "Costo Financiero" TotCostos.HeaderText = "Total a Pagar" Else RendNetoAntImp.HeaderText = "R% Neto (Antes de Impuesto)" RendNetoDespImp.HeaderText = "R% Neto (Despues de Impuesto)" Rend.HeaderText = "Rendimiento" TotCostos.HeaderText = "Total Costos" End If dgvReportos.Columns.Add(Correlativo) dgvReportos.Columns.Add(ValTrans) dgvReportos.Columns.Add(Dias) dgvReportos.Columns.Add(FVen) dgvReportos.Columns.Add(Rend) dgvReportos.Columns.Add(ComisionCB) dgvReportos.Columns.Add(CB) dgvReportos.Columns.Add(IOF) dgvReportos.Columns.Add(OtrosCostos) dgvReportos.Columns.Add(TotCostos) dgvReportos.Columns.Add(MontoLiq) dgvReportos.Columns.Add(InterGen) dgvReportos.Columns.Add(CostoTransfv) dgvReportos.Columns.Add(RendNetoAntImp) dgvReportos.Columns.Add(ValReCompra) dgvReportos.Columns.Add(ImpLiquidacion) dgvReportos.Columns.Add(IngrNeto) dgvReportos.Columns.Add(ValNeto) dgvReportos.Columns.Add(RendNetoDespImp) dgvReportos.Columns.Add(Nombre) dgvReportos.Columns.Add(FCompra) dgvReportos.Columns.Add(ComisionCasa) dgvReportos.Columns.Add(ComisionBolsa) dgvReportos.Columns.Add(Casa) dgvReportos.Columns.Add(codigo) dgvReportos.Columns.Add(Base) dgvReportos.Columns.Add(EstadoIOF) dgvReportos.Columns.Add(EstadoRenta) Dim CodImp, code As New DataGridViewTextBoxColumn CodImp.Name = "CodImp" code.Name = "codigo" ' dgvImpuestoAgregado.Columns.Add(CodImp) ' dgvImpuestoAgregado.Columns.Add(code) End If End Sub Sub LlenarBase() Dim Index As Integer = dgvReportos.Rows.Count - 2 Base = cboAnioBase.SelectedIndex Dim i As Integer = 0 While i <= Index dgvReportos.Rows(i).Cells("Base").Value = Base i += 1 End While End Sub Sub IngresarDatos() If Cargado Then If Procesado Then If Not dgvReportos.CurrentRow Is Nothing Then Dim Index As Integer = dgvReportos.CurrentRow.Index dgvReportos.Rows(Index).Cells("Nombre").Value = txtCodigoTitulo.Text dgvReportos.Rows(Index).Cells("FCompra").Value = dtpFechaCompra.Value If txtComisionCasa.Text.ToString.Trim("%") = 0 Then dgvReportos.Rows(Index).Cells("ComisionCasa").Value = "0.0" Else dgvReportos.Rows(Index).Cells("ComisionCasa").Value = CDec(txtComisionCasa.Text.ToString.Trim("%")) / 100 End If If txtComisionBolsa.Text.ToString.Trim("%") = 0 Then dgvReportos.Rows(Index).Cells("ComisionBolsa").Value = "0.0" Else dgvReportos.Rows(Index).Cells("ComisionBolsa").Value = CDec(txtComisionBolsa.Text.ToString.Trim("%")) / 100 End If 'If ChkIOF.Checked Then ' dgvReportos.Rows(Index).Cells("EstadoIOF").Value = 1 'Else ' dgvReportos.Rows(Index).Cells("EstadoIOF").Value = 0 'End If 'If ChkRenta.Checked Then ' dgvReportos.Rows(Index).Cells("EstadoRenta").Value = 1 'Else ' dgvReportos.Rows(Index).Cells("EstadoRenta").Value = 0 'End If If Variables.Codigo.IndexOf("REPO") > -1 Or Variables.Codigo.IndexOf("REPOVENTA") > -1 Then dgvReportos.Rows(Index).Cells("Casa").Value = cboCasaCorredora.SelectedValue 'Else ' dgvReportos.Rows(Index).Cells("Casa2").Value = cboCasaCorredora.SelectedValue ' dgvReportos.Rows(Index).Cells("Dias").Value = txtDias.Text End If End If End If End If End Sub Sub IngresarDatosReves() Procesado = False If Cargado Then If Not dgvReportos.CurrentRow Is Nothing Then Dim Index As Integer = dgvReportos.CurrentRow.Index Dim Nombre = dgvReportos.Rows(Index).Cells("Nombre").Value Dim FCompra = dgvReportos.Rows(Index).Cells("FCompra").Value Dim ComisionCasa = dgvReportos.Rows(Index).Cells("ComisionCasa").Value Dim ComisionBolsa = dgvReportos.Rows(Index).Cells("ComisionBolsa").Value Dim EstadoIOF = dgvReportos.Rows(Index).Cells("EstadoIOF").Value Dim EstadoRenta = dgvReportos.Rows(Index).Cells("EstadoRenta").Value Dim Casa = dgvReportos.Rows(Index).Cells("Casa").Value If Not Nombre Is DBNull.Value Then If Not Nombre Is Nothing Then If Not String.IsNullOrEmpty(Nombre) Then txtCodigoTitulo.Text = Nombre Else txtCodigoTitulo.Text = String.Empty End If Else txtCodigoTitulo.Text = String.Empty End If Else txtCodigoTitulo.Text = String.Empty End If If Not FCompra Is DBNull.Value Then If Not FCompra Is Nothing Then If Not String.IsNullOrEmpty(FCompra) Then dtpFechaCompra.Value = FCompra Else dtpFechaCompra.Value = Date.Now.Date End If Else dtpFechaCompra.Value = Date.Now.Date End If Else dtpFechaCompra.Value = Date.Now.Date End If If Not ComisionCasa Is DBNull.Value Then If Not ComisionCasa Is Nothing Then If Not String.IsNullOrEmpty(ComisionCasa.ToString.Trim("%")) Then txtComisionCasa.Text = ComisionCasa.ToString.Trim("%") * 100 Else txtComisionCasa.Text = "0.2825%" End If Else txtComisionCasa.Text = "0.2825%" End If Else txtComisionCasa.Text = "0.2825%" End If If Not ComisionBolsa Is DBNull.Value Then If Not ComisionBolsa Is Nothing Then If Not String.IsNullOrEmpty(ComisionBolsa.ToString.Trim("%")) Then txtComisionBolsa.Text = ComisionBolsa.ToString.Trim("%") * 100 Else txtComisionBolsa.Text = "0.2825%" End If Else txtComisionBolsa.Text = "0.2825%" End If Else txtComisionBolsa.Text = "0.2825%" End If If Not EstadoIOF Is DBNull.Value Then If Not EstadoIOF Is Nothing Then If Not String.IsNullOrEmpty(EstadoIOF) Then If Index = 0 Then If EstadoIOF = 1 Then ChkIOF.Checked = True Else ChkIOF.Checked = False End If Else Dim EstadoIOFAnt = dgvReportos.Rows(Index - 1).Cells("EstadoIOF").Value If EstadoIOFAnt = 1 Then ChkIOF.Checked = True Else ChkIOF.Checked = False End If End If Else If Not Index = 0 Then Dim EstadoIOFAnt = dgvReportos.Rows(Index - 1).Cells("EstadoIOF").Value If EstadoIOFAnt = 1 Then ChkIOF.Checked = True Else ChkIOF.Checked = False End If End If End If Else If Not Index = 0 Then Dim EstadoIOFAnt = dgvReportos.Rows(Index - 1).Cells("EstadoIOF").Value If EstadoIOFAnt = 1 Then ChkIOF.Checked = True Else ChkIOF.Checked = False End If End If End If Else If Not Index = 0 Then Dim EstadoIOFAnt = dgvReportos.Rows(Index - 1).Cells("EstadoIOF").Value If EstadoIOFAnt = 1 Then ChkIOF.Checked = True Else ChkIOF.Checked = False End If End If End If If Not EstadoRenta Is DBNull.Value Then If Not EstadoRenta Is Nothing Then If Not String.IsNullOrEmpty(EstadoRenta) Then If Index = 0 Then If EstadoRenta = 1 Then ChkRenta.Checked = True Else ChkRenta.Checked = False End If Else Dim EstadoRentaAnt = dgvReportos.Rows(Index - 1).Cells("EstadoRenta").Value If EstadoRentaAnt = 1 Then ChkRenta.Checked = True Else ChkRenta.Checked = False End If End If Else If Not Index = 0 Then Dim EstadoRentaAnt = dgvReportos.Rows(Index - 1).Cells("EstadoRenta").Value If EstadoRentaAnt = 1 Then ChkRenta.Checked = True Else ChkRenta.Checked = False End If End If End If Else If Not Index = 0 Then Dim EstadoRentaAnt = dgvReportos.Rows(Index - 1).Cells("EstadoRenta").Value If EstadoRentaAnt = 1 Then ChkRenta.Checked = True Else ChkRenta.Checked = False End If End If End If Else If Not Index = 0 Then Dim EstadoRentaAnt = dgvReportos.Rows(Index - 1).Cells("EstadoRenta").Value If EstadoRentaAnt = 1 Then ChkRenta.Checked = True Else ChkRenta.Checked = False End If End If End If 'If (InStr(Variables.Codigo, "REPO") > 0) Or (InStr(Variables.Codigo, "REPOVENTA") > 0) Then If Not Casa Is DBNull.Value Then If Not Casa Is Nothing Then If Not String.IsNullOrEmpty(Casa) Then cboCasaCorredora.SelectedValue = Casa Else cboCasaCorredora.SelectedIndex = -1 End If Else cboCasaCorredora.SelectedIndex = -1 End If Else cboCasaCorredora.SelectedIndex = -1 End If End If End If Procesado = True End Sub Sub ComisionCasa(ByVal ComisionCasa As Double, ByVal Index As Integer) Dim ValorTrasado As Double = 0.0 Dim Dias As Integer = 0 Dim por As Double = 0 ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString) Dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString) por = ComisionCasa Dim Fecha1 As Date = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString) Dim Fecha2 As Date = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString) dgvReportos.Rows(Index).Cells("Comision CB").Value = Operaciones.ConvertirDecimal(Reporto.Comision(ValorTrasado, Dias, por, Fecha1, Fecha2, Base).ToString) End Sub Function ComisionCasaCargar(ByVal Index As Integer) Dim ValorTrasado As Double = 0 Dim Dias As Integer = 0 Dim por As Double = 0 If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Valor Trasado").Value) Then ValorTrasado = dgvReportos.Rows(Index).Cells("Valor Trasado").Value End If If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value) Then Dias = dgvReportos.Rows(Index).Cells("Dias").Value End If If (String.IsNullOrEmpty(txtComisionCasa.Text.ToString.Trim("%"))) Then txtComisionCasa.Text = "0.2825%" Else por = CDec(txtComisionCasa.Text.ToString.Trim("%")) / 100 End If Dim Fecha1 As Date = dgvReportos.Rows(Index).Cells("FCompra").Value Dim Fecha2 As Date = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value Dim Com = Reporto.Comision(ValorTrasado, Dias, por, Fecha1, Fecha2, Base) dgvReportos.Rows(Index).Cells("Comision CB").Value = Com Return Com End Function Sub ComisionBolsa(ByVal ComisionBolsa As Double, ByVal Index As Integer) Dim ValorTrasado As Double = 0 Dim Dias As Integer = 0 Dim por As Double = 0 ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString) Dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString) por = ComisionBolsa Dim Fecha1 As Date = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString) Dim Fecha2 As Date = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString) dgvReportos.Rows(Index).Cells("Comision Bolsa").Value = Operaciones.ConvertirDecimal(Reporto.Comision(ValorTrasado, Dias, por, Fecha1, Fecha2, Base).ToString) End Sub Function ComisionBolsaCargar(ByVal Index As Integer) Dim ValorTrasado As Double = 0 Dim Dias As Integer = 0 Dim por As Double = 0 If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Valor Trasado").Value) Then ValorTrasado = dgvReportos.Rows(Index).Cells("Valor Trasado").Value End If If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value) Then Dias = dgvReportos.Rows(Index).Cells("Dias").Value End If If Not String.IsNullOrEmpty(txtComisionBolsa.Text.ToString.ToString.Trim("%")) Then por = txtComisionBolsa.Text.ToString.Trim("%") End If Dim Fecha1 As Date = dgvReportos.Rows(Index).Cells("FCompra").Value Dim Fecha2 As Date = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value Dim Com = Reporto.Comision(ValorTrasado, Dias, por, Fecha1, Fecha2, Base) dgvReportos.Rows(Index).Cells("Comision Bolsa").Value = Com Return Com End Function Sub IOF(ByVal Index As Integer) Dim ValorTrasado As Double = 0 Dim ComisionCasa As Double = 0 Dim ComisionBolsa As Double = 0 Dim dias As Integer = 0 Dim Porcentaje As Double = 0.0025 Dim Fecha1 As Date = Date.Now.Date Dim Fecha2 As Date = Date.Now.Date If ChkIOF.Checked Then ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString) ComisionCasa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision CB").Value.ToString) ComisionBolsa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision Bolsa").Value.ToString) dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString) Fecha1 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString) Fecha2 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString) dgvReportos.Rows(Index).Cells("IOF").Value = Operaciones.ConvertirDecimal(Reporto.IOF(ValorTrasado, ComisionCasa, ComisionBolsa, dias, Porcentaje, Fecha1, Fecha2, Base).ToString) Else dgvReportos.Rows(Index).Cells("IOF").Value = 0 End If End Sub ' Sub IOF() ' Dim Index As Integer = dgvReportos.CurrentRow.Index ' Dim ValorTrasado As Double = dgvReportos.Rows(Index).Cells(0).Value ' Dim CantidadRegistrosImpuestos = dgvImpuestoAgregado.Rows.Count - 1 'Dim CodeReg = dgvReportos.Rows(Index).Cells(18).Value 'Dim ComisionCasa As Double = dgvReportos.Rows(Index).Cells(4).Value 'Dim ComisionBolsa As Double = dgvReportos.Rows(Index).Cells(5).Value 'Dim dias As Integer = dgvReportos.Rows(Index).Cells(1).Value 'Dim Porcentaje As Double = 0.0 'For i As Integer = 0 To CantidadRegistrosImpuestos 'For j As Integer = 0 To CantidadRegistrosImpuestos 'If (dgvImpuestoAgregado.Rows(j).Cells(0).Value = "IOF" And dgvImpuestoAgregado.Rows(j).Cells(1).Value = CodeReg) Then ' Porcentaje = 0.0025 'Exit For 'Else ' Porcentaje = 0 ' End If 'Next 'Next ' dgvReportos.Rows(Index).Cells(6).Value = Reporto.IOF(ValorTrasado, ComisionCasa, ComisionBolsa, dias, Porcentaje) ' End Sub 'Sub IOFCargar(ByVal Index As Integer) 'Dim ValorTrasado As Double = dgvReportos.Rows(Index).Cells(0).Value 'Dim CantidadRegistrosImpuestos = dgvImpuestoAgregado.Rows.Count - 1 'Dim CodeReg = dgvReportos.Rows(Index).Cells(18).Value 'Dim ComisionCasa As Double = dgvReportos.Rows(Index).Cells(4).Value 'Dim ComisionBolsa As Double = dgvReportos.Rows(Index).Cells(5).Value 'Dim dias As Integer = dgvReportos.Rows(Index).Cells(1).Value 'Dim Porcentaje As Double = 0.0 'For i As Integer = 0 To CantidadRegistrosImpuestos 'For j As Integer = 0 To CantidadRegistrosImpuestos 'If (dgvImpuestoAgregado.Rows(j).Cells(0).Value = "IOF" And dgvImpuestoAgregado.Rows(j).Cells(1).Value = CodeReg) Then ' Porcentaje = 0.0025 'Exit For 'Else ' Porcentaje = 0 'End If 'Next 'Next ' dgvReportos.Rows(Index).Cells(6).Value = Reporto.IOF(ValorTrasado, ComisionCasa, ComisionBolsa, dias, Porcentaje) 'End Sub Sub TotalCostos(ByVal Index As Integer) Dim ComisionCasa As Double = 0 Dim ComisionBolsa As Double = 0 Dim IOF As Double = 0 Dim OC As Double = 0 Dim ValorTransado As Double = 0 Dim Instrumento As String = String.Empty If Variables.Codigo.IndexOf("REPOVENTA") > -1 Then Instrumento = "REPOVENTA" Else Instrumento = "REPO" End If ComisionCasa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision CB").Value.ToString) ComisionBolsa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision Bolsa").Value.ToString) IOF = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("IOF").Value.ToString) OC = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Otros Costos").Value.ToString) ValorTransado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString) dgvReportos.Rows(Index).Cells("Total Costos").Value = Operaciones.ConvertirDecimal(Reporto.TotCostos(ComisionCasa, ComisionBolsa, IOF, OC, ValorTransado, Instrumento).ToString) End Sub Function TotalCostosCargar(ByVal Index As Integer) Dim ComisionCasa As Double = 0 Dim ComisionBolsa As Double = 0 Dim IOF As Double = 0 Dim OC As Double = 0 If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Comision CB").Value) Then ComisionCasa = dgvReportos.Rows(Index).Cells("Comision CB").Value End If If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Comision Bolsa").Value) Then ComisionBolsa = dgvReportos.Rows(Index).Cells("Comision Bolsa").Value End If If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("IOF").Value) Then IOF = dgvReportos.Rows(Index).Cells("IOF").Value End If If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Otros Costos").Value) Then OC = dgvReportos.Rows(Index).Cells("Otros Costos").Value End If 'Dim Costos = Reporto.TotCostos(ComisionCasa, ComisionBolsa, IOF, OC) 'dgvReportos.Rows(Index).Cells("Total Costos").Value = Costos 'Return Costos End Function Sub MontoLiquidacion(ByVal Index As Integer) Dim ValorTrasado As Double = 0 Dim TotalCosto As Double = 0 ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString) TotalCosto = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Total Costos").Value.ToString) dgvReportos.Rows(Index).Cells("Monto a Liquidar").Value = Operaciones.ConvertirDecimal(Reporto.MontoLiquidacion(ValorTrasado, TotalCosto).ToString) End Sub Function MontoLiquidacionCargar(ByVal Index As Integer) Dim ValorTrasado As Double = 0 Dim TotalCosto As Double = 0 If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Valor Trasado").Value) Then ValorTrasado = dgvReportos.Rows(Index).Cells("Valor Trasado").Value End If If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Total Costos").Value) Then TotalCosto = dgvReportos.Rows(Index).Cells("Total Costos").Value End If Dim MontoLiq = Reporto.MontoLiquidacion(ValorTrasado, TotalCosto) dgvReportos.Rows(Index).Cells("Monto a Liquidar").Value = MontoLiq Return MontoLiq End Function Sub InteresGenerar(ByVal Index As Integer) Dim ValorTrasado As Double = 0 Dim rendimiento As Double = 0 Dim dias As Integer = 0 Dim Fecha1 As Date = Date.Now.Date Dim Fecha2 As Date = Date.Now.Date ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString) rendimiento = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Rendimiento").Value.ToString) dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString) Fecha1 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString) Fecha2 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString) dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value = Operaciones.ConvertirDecimal(Reporto.InteresGenerar(ValorTrasado, rendimiento, dias, Fecha1, Fecha2, Base).ToString) End Sub Function InteresGenerarCargar(ByVal Index As Integer) Dim ValorTrasado As Double = 0 Dim rendimiento As Double = 0 Dim dias As Integer = 0 Dim Fecha1 As Date = Date.Now.Date Dim Fecha2 As Date = Date.Now.Date If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Valor Trasado").Value) Then ValorTrasado = dgvReportos.Rows(Index).Cells("Valor Trasado").Value End If If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Rendimiento").Value) Then rendimiento = dgvReportos.Rows(Index).Cells("Rendimiento").Value End If If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value) Then dias = dgvReportos.Rows(Index).Cells("Dias").Value End If Fecha1 = dgvReportos.Rows(Index).Cells("FCompra").Value Fecha2 = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value Dim Interes = Reporto.InteresGenerar(ValorTrasado, rendimiento, dias, Fecha1, Fecha2, Base) dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value = Interes Return Interes End Function Sub RendimientoAntes(ByVal Index As Integer) Dim ValorTrasado As Double = 0 Dim dias As Integer = 0 Dim InteresGenerar As Double = 0 Dim Totcosto As Double = 0 Dim Fecha1 As Date = Date.Now.Date Dim Fecha2 As Date = Date.Now.Date ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString) dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString) InteresGenerar = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value.ToString) Totcosto = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Total Costos").Value.ToString) Fecha1 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString) Fecha2 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString) dgvReportos.Rows(Index).Cells("R% Neto (Antes de Impuesto)").Value = Operaciones.ConvertirDecimal(Reporto.RendimientoAntes(InteresGenerar, Totcosto, ValorTrasado, dias, Fecha1, Fecha2, Base, Tabla).ToString) End Sub Function RendimientoAntesCargar(ByVal Index As Integer) Dim ValorTrasado As Double = 0 Dim dias As Integer = 0 Dim InteresGenerar As Double = 0 Dim Totcosto As Double = 0 Dim Rendimiento As Double = 0 Dim Fecha1 As Date = Date.Now.Date Dim Fecha2 As Date = Date.Now.Date If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Valor Trasado").Value) Then ValorTrasado = dgvReportos.Rows(Index).Cells("Valor Trasado").Value End If If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value) Then dias = dgvReportos.Rows(Index).Cells("Dias").Value End If If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value) Then InteresGenerar = dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value End If If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Total Costos").Value) Then Totcosto = dgvReportos.Rows(Index).Cells("Total Costos").Value End If Fecha1 = dgvReportos.Rows(Index).Cells("FCompra").Value Fecha2 = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value Rendimiento = Reporto.RendimientoAntes(InteresGenerar, Totcosto, ValorTrasado, dias, Fecha1, Fecha2, Base, Tabla) dgvReportos.Rows(Index).Cells("R% Neto (Antes de Impuesto)").Value = Rendimiento Return Rendimiento End Function Sub ValorRecompra(ByVal Index As Integer) Dim ValorTrasado As Double = 0 Dim InteresGenerar As Double = 0 ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString) InteresGenerar = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value.ToString) dgvReportos.Rows(Index).Cells("Valor de ReCompra").Value = Operaciones.ConvertirDecimal(Reporto.ValorRecompras(ValorTrasado, InteresGenerar).ToString) End Sub Function ValorRecompraCargar(ByVal Index As Integer) Dim ValorTrasado As Double = 0 Dim InteresGenerar As Double = 0 If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Valor Trasado").Value) Then ValorTrasado = dgvReportos.Rows(Index).Cells("Valor Trasado").Value End If If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value) Then InteresGenerar = dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value End If Dim ReCompra = Reporto.ValorRecompras(ValorTrasado, InteresGenerar) dgvReportos.Rows(Index).Cells("Valor de ReCompra").Value = ReCompra Return ReCompra End Function Sub Renta(ByVal Index As String) Dim InteresGenerar As Double = 0 If ChkRenta.Checked Then InteresGenerar = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value.ToString) dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value = (InteresGenerar * 0.1) Else dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value = 0 End If End Sub ' Sub Renta() 'Dim Index = dgvReportos.CurrentRow.Index 'Dim InteresGenerar As Double = dgvReportos.Rows(Index).Cells(10).Value 'Dim CantidadRegistrosImpuestos = dgvImpuestoAgregado.Rows.Count - 1 'Dim CodeReg = dgvReportos.Rows(Index).Cells(18).Value 'Dim Porcentaje = 0.0 'For i As Integer = 0 To CantidadRegistrosImpuestos 'For j As Integer = 0 To CantidadRegistrosImpuestos 'If (dgvImpuestoAgregado.Rows(j).Cells(0).Value = "ISR" And dgvImpuestoAgregado.Rows(j).Cells(1).Value = CodeReg) Then ' Porcentaje = 0.1 'Exit For 'Else ' Porcentaje = 0 'End If 'Next 'Next ' dgvReportos.Rows(Index).Cells(14).Value = Reporto.Renta(InteresGenerar, Porcentaje) 'End Sub ' Sub RentaCargar(ByVal Index As Integer) 'Dim InteresGenerar As Double = dgvReportos.Rows(Index).Cells(10).Value 'Dim CantidadRegistrosImpuestos = dgvImpuestoAgregado.Rows.Count - 1 'Dim CodeReg = dgvReportos.Rows(Index).Cells(18).Value 'Dim Porcentaje = 0.0 'For i As Integer = 0 To CantidadRegistrosImpuestos 'For j As Integer = 0 To CantidadRegistrosImpuestos ' If (dgvImpuestoAgregado.Rows(j).Cells(0).Value = "ISR" And dgvImpuestoAgregado.Rows(j).Cells(1).Value = CodeReg) Then ' Porcentaje = 0.1 'Exit For 'Else ' Porcentaje = 0 'End If 'Next 'Next ' dgvReportos.Rows(Index).Cells(14).Value = Reporto.Renta(InteresGenerar, Porcentaje) 'End Sub Sub IngresoNeto(ByVal Index As Integer) Dim InteresGenerar As Double = 0 Dim Renta As Double = 0 InteresGenerar = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value.ToString) Renta = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value.ToString) dgvReportos.Rows(Index).Cells("Ingreso Neto").Value = Operaciones.ConvertirDecimal(Reporto.IngresoNet(InteresGenerar, Renta).ToString) End Sub Function IngresoNetoCargar(ByVal Index As Integer) Dim Renta As Double = 0 Dim InteresGenerar As Double = 0 If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value) Then InteresGenerar = dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value End If If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value)) Then dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value = 0 Renta = 0 Else Renta = dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value End If Dim ING = Reporto.IngresoNet(InteresGenerar, Renta) dgvReportos.Rows(Index).Cells("Ingreso Neto").Value = ING Return ING End Function Sub ValorNeto(ByVal Index As Integer) Dim ValorTrasado As Double = 0 Dim IngresoNeto As Double = 0 Dim CostoTrans As Double = 0 ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString) IngresoNeto = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Ingreso Neto").Value.ToString) CostoTrans = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Costo de Transferencia").Value.ToString) dgvReportos.Rows(Index).Cells("Valor Neto").Value = Operaciones.ConvertirDecimal(Reporto.ValorNet(ValorTrasado, IngresoNeto, CostoTrans).ToString) End Sub Function ValorNetoCargar(ByVal Index As Integer) Dim ValorTrasado As Double = 0 Dim IngresoNeto As Double = 0 Dim CostoTrans As Double = 0 If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Valor Trasado").Value)) Then ValorTrasado = dgvReportos.Rows(Index).Cells("Valor Trasado").Value End If If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Ingreso Neto").Value)) Then dgvReportos.Rows(Index).Cells("Ingreso Neto").Value = 0 Else IngresoNeto = dgvReportos.Rows(Index).Cells("Ingreso Neto").Value End If If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Costo de Transferencia").Value)) Then dgvReportos.Rows(Index).Cells("Costo de Transferencia").Value = 0 Else CostoTrans = dgvReportos.Rows(Index).Cells("Costo de Transferencia").Value End If Dim VN = Reporto.ValorNet(ValorTrasado, IngresoNeto, CostoTrans) dgvReportos.Rows(Index).Cells("Valor Neto").Value = VN Return VN End Function Sub RendimientoDespues(ByVal Index As Integer) Dim ValorTrasado As Double = 0 Dim IngresoNeto As Double = 0 Dim TotalCosto As Double = 0 Dim dias As Integer = 0 Dim Fecha1 As Date = Date.Now.Date Dim Fecha2 As Date = Date.Now.Date ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString) IngresoNeto = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Ingreso Neto").Value.ToString) TotalCosto = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Total Costos").Value.ToString) dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString) Fecha1 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString) Fecha2 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString) dgvReportos.Rows(Index).Cells("R% Neto (Despues de Impuesto)").Value = Operaciones.ConvertirDecimal(Reporto.RendimientoDespues(IngresoNeto, TotalCosto, ValorTrasado, dias, Fecha1, Fecha2, Base).ToString) End Sub Function RendimientoDespuesCargar(ByVal Index As Integer) Dim ValorTrasado As Double = 0 Dim IngresoNeto As Double = 0 Dim TotalCosto As Double = 0 Dim dias As Integer = 0 Dim Fecha1 As Date = Date.Now.Date Dim Fecha2 As Date = Date.Now.Date If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Valor Trasado").Value) Then ValorTrasado = dgvReportos.Rows(Index).Cells("Valor Trasado").Value End If If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Ingreso Neto").Value) Then IngresoNeto = dgvReportos.Rows(Index).Cells("Ingreso Neto").Value End If If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Total Costos").Value) Then TotalCosto = dgvReportos.Rows(Index).Cells("Total Costos").Value End If If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value) Then dias = dgvReportos.Rows(Index).Cells("Dias").Value End If Fecha1 = dgvReportos.Rows(Index).Cells("FCompra").Value Fecha2 = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value Dim Rend = Reporto.RendimientoDespues(IngresoNeto, TotalCosto, ValorTrasado, dias, Fecha1, Fecha2, Base) dgvReportos.Rows(Index).Cells("R% Neto (Despues de Impuesto)").Value = Rend Return Rend End Function Sub CargarFecha() Dim Index As Integer = dgvReportos.CurrentRow.Index Dim Fecha As Date = dtpFechaCompra.Value Dim Fecha2 As Date = Date.Now.Date If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value) Then Fecha2 = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value End If End Sub Private Sub CargarCasaCorredora() If cboCasaCorredora.Items.Count = 0 Or cboCasaCorredora.Items.Count = 1 Then Me.cboCasaCorredora.DataSource = oDAOGeneral.ListaTiposImpuesto Me.cboCasaCorredora.DisplayMember = "Descripcion" Me.cboCasaCorredora.ValueMember = "Codigo" Me.cboCasaCorredora.SelectedIndex = 0 End If End Sub 'Private Sub PrepararTablaImpuestos() ' Dim cboColumna, cboCodigoInv As DataGridViewComboBoxColumn ' cboColumna = New DataGridViewComboBoxColumn ' cboColumna.Name = "Valor" ' cboColumna.HeaderText = "CodImp" ' cboColumna.DataSource = oDAOGeneral.ListaImpuesto ' cboColumna.ValueMember = "CodImp" ' cboColumna.DisplayMember = "Descripcion" ' cboColumna.DataPropertyName = "CodImp" ' cboColumna.DisplayIndex = 1 'Me.dgvImpuestos.Columns.Add(cboColumna) ' cboCodigoInv = New DataGridViewComboBoxColumn ' cboCodigoInv.Name = "Codigo" ' cboCodigoInv.HeaderText = "Codigo" 'cboCodigoInv.DataSource = oDAOGeneral.ListaInversion(Variables.Codigo) ' cboCodigoInv.DisplayMember = "Descripcion" ' cboCodigoInv.DataPropertyName = "Codigo" ' cboCodigoInv.DisplayIndex = 2 'Me.dgvImpuestos.Columns.Add(cboCodigoInv) 'End Sub Sub CargarBase() If cboAnioBase.Items.Count = 0 Or cboAnioBase.Items.Count = 1 Then Me.cboAnioBase.DataSource = oDAOGeneral.ListaBase Me.cboAnioBase.DisplayMember = "Descripcion" Me.cboAnioBase.ValueMember = "Codigo" Me.cboAnioBase.SelectedIndex = 0 End If End Sub Private Sub frmReporto_Load(sender As Object, e As EventArgs) Handles MyBase.Load Titulo.TabPages.Remove(TbImpuestos) Dim CantidadFilas As Integer = dgvReportos.Rows.Count CargarCasaCorredora() CargarBase() If Variables.Codigo.IndexOf("REPO") > -1 And Not Variables.Codigo.IndexOf("REPOVENTA") > -1 Then Tabla = "REP0" lblReporto.Text = "Reporto de Compra" Variables.Inicio = True 'Call CargarRegistroBD txtComisionCasa.Text = PorcentajeComisionCasa txtComisionBolsa.Text = PorcentajeComisionBolsa ' txtIOF.Text = PorcentajeComisionIOF If CantidadFilas <= 1 Then AgregarCampos(1) ' PrepararTablaImpuestos() CargarReporto(Tabla) End If Calculos() Variables.Inicio = False 'AgregarCheckbox() 'CalcularCheckbox() Calculos() CargarUnaVez = False CodigoRotar = 0 ElseIf Variables.Codigo.IndexOf("REPOVENTA") > -1 Then OcultarValoresImp() Tabla = "REP0VENTA" lblReporto.Text = "Reporto de Venta" lblFechaCompra.Text = "Fecha de Venta" lblCodigoInstrumento.Visible = True txtCodigoInstrumento.Visible = True If Not String.IsNullOrEmpty(CodigoProveniente) Then txtCodigoInstrumento.Text = CodigoProveniente End If If CantidadFilas <= 1 Then AgregarCampos(2) ' PrepararTablaImpuestos() CargarReporto(Tabla) End If CodigoRotar = 0 Calculos() CargarMontoRepoVenta() End If Cargado = True CorrelativoSinBD() ExisteInversion() ValidarExistencia() Formato() CargarTransladoNuevo() End Sub Sub CargarMontoRepoVenta() If Operaciones.ConvertirDecimal(txtMonto.Text.ToString) > 0 Then If dgvReportos.Rows(0).Cells("Valor Trasado").Value = 0 Then dgvReportos.Rows(0).Cells("Valor Trasado").Value = txtMonto.Text txtMonto.Text = 0 End If End If End Sub Sub OcultarValoresImp() ChkIOF.Checked = False ChkRenta.Checked = False ChkRenta.Visible = False ChkIOF.Visible = False 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 Formato() If (String.IsNullOrEmpty(txtDias.Text.ToString)) Then txtDias.Text = 0 End If If (String.IsNullOrEmpty(txtComisionCasa.Text.ToString.Trim("%"))) Then txtComisionCasa.Text = "0.2825%" End If If (String.IsNullOrEmpty(txtComisionBolsa.Text.ToString.Trim("%"))) Then txtComisionBolsa.Text = "0.2825%" End If If txtComisionBolsa.Text.ToString.IndexOf("%") = -1 Then txtComisionBolsa.Text = txtComisionBolsa.Text.ToString + "%" End If If txtComisionCasa.Text.ToString.IndexOf("%") = -1 Then txtComisionCasa.Text = txtComisionCasa.Text.ToString + "%" End If If cboCasaCorredora.SelectedIndex = -1 Then Try cboCasaCorredora.SelectedIndex = 0 Catch ex As Exception End Try End If End Sub Sub IOFRentaEstado() Dim CantidadRegistro As Integer = dgvReportos.Rows.Count - 2 Dim EstadoImpIOF As Integer = 0 Dim EstadoImpRenta As Integer = 0 'Dim Index As Integer = dgvReportos.CurrentRow.Index 'If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("EstadoIOF").Value) Then ' EstadoImpIOF = dgvReportos.Rows(Index).Cells("EstadoIOF").Value 'End If 'If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("EstadoRenta").Value) Then ' EstadoImpRenta = dgvReportos.Rows(Index).Cells("EstadoRenta").Value 'End If If ChkIOF.Checked Then EstadoImpIOF = 1 Else EstadoImpIOF = 0 End If If ChkRenta.Checked Then EstadoImpRenta = 1 Else EstadoImpRenta = 0 End If Dim i As Integer = 0 While i <= CantidadRegistro dgvReportos.Rows(i).Cells("EstadoIOF").Value = EstadoImpIOF dgvReportos.Rows(i).Cells("EstadoRenta").Value = EstadoImpRenta i += 1 End While End Sub Sub AgregarCheckbox() If Variables.Codigo.IndexOf("REPO") > -1 Or Variables.Codigo.IndexOf("REPOVENTA") > -1 Then Dim Cantidad As Integer = dgvReportos.Rows.Count - 2 For i As Integer = 0 To Cantidad Dim IOF As New CheckBox Dim Renta As New CheckBox Dim Existe As Boolean = False Dim Codigo = dgvReportos.Rows(i).Cells("Codigo").Value For Each item As CheckBox In FlpIOF.Controls If item.Text.ToString = Codigo.ToString Then Existe = True End If Next If Not Existe Then If (Not dgvReportos.Rows(i).Cells("IOF").Value = 0) Then IOF.Name = Codigo.ToString + "ffeaeae8" IOF.Checked = True IOF.BackColor = ColorTranslator.FromHtml("#EAEAE8") Else IOF.Checked = False End If If (Not dgvReportos.Rows(i).Cells("Impuesto de Liquidacion").Value = 0) Then Renta.Name = CStr(Codigo) + "ffeaeae8" Renta.Checked = True Renta.BackColor = ColorTranslator.FromHtml("#EAEAE8") Else Renta.Checked = False End If IOF.Text = Codigo Renta.Text = Codigo AddHandler IOF.CheckedChanged, AddressOf eventoIOF AddHandler Renta.CheckedChanged, AddressOf eventoRenta FlpIOF.Controls.Add(IOF) FlpRenta.Controls.Add(Renta) End If Existe = False Next End If End Sub Sub eventoIOF(sender As Object, e As EventArgs) If (sender.checked) Then sender.BackColor = ColorTranslator.FromHtml("#EAEAE8") Else sender.BackColor = ColorTranslator.FromHtml("Transparent") End If CalcularCheckbox() Calculos() End Sub Sub eventoRenta(sender As Object, e As EventArgs) If (sender.checked) Then sender.BackColor = ColorTranslator.FromHtml("#EAEAE8") Else sender.BackColor = ColorTranslator.FromHtml("Transparent") End If CalcularCheckbox() Calculos() End Sub Sub CalcularCheckbox() Dim xCheckBox As New Control For Each xCheckBox In Me.FlpIOF.Controls If TypeOf xCheckBox Is CheckBox Then Dim Index = xCheckBox.TabIndex Try Dim codigo = dgvReportos.Rows(Index).Cells("Codigo").Value If Not String.IsNullOrEmpty(codigo) Then Dim ColorCodigo = CStr(codigo) + xCheckBox.BackColor.Name.ToString If (ColorCodigo = (codigo + "ffeaeae8")) Then Dim codigoText = xCheckBox.Text If (codigo = codigoText) Then IOF(Index) End If Else dgvReportos.Rows(Index).Cells("IOF").Value = 0 End If End If Catch ex As Exception End Try End If Next Dim xCheckBo As New Control For Each xCheckBo In Me.FlpRenta.Controls If TypeOf xCheckBo Is CheckBox Then Dim Index = xCheckBo.TabIndex Try Dim codigo = dgvReportos.Rows(Index).Cells("Codigo").Value If Not String.IsNullOrEmpty(codigo) Then Dim ColorCodigo = CStr(codigo) + xCheckBo.BackColor.Name.ToString If (ColorCodigo = (codigo + "ffeaeae8")) Then Dim codigoText = xCheckBo.Text If (codigo = codigoText) Then Renta(Index) End If Else dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value = 0 End If End If Catch ex As Exception End Try End If Next End Sub Sub ActualizarImpuestos(ByVal Valor As Integer) CargarReporto(Tabla) End Sub Sub RotarValores(ByVal Codigo As String) End Sub Sub CalculosRepoVentas(ByVal Index As Integer) End Sub Sub PrepararRepoVentas() Dim Cantidad As Integer = dgvReportos.Rows.Count - 2 Dim Index As Integer = 0 While Index <= Cantidad Dim IndexAnterior As Integer = 0 DefinirCorrelativo(Index) dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value = CalcularFechaVencimiento(Index) PrepararMonto(Index) PrepararCostosFinancieros(Index) dgvReportos.Rows(Index).Cells("Intereses").Value = CalcularInteres(Index, Base) dgvReportos.Rows(Index).Cells("Casa").Value = CalcularComisionCasa(Index, Base) dgvReportos.Rows(Index).Cells("Bolsa").Value = CalcularComisionBolsa(Index, Base) dgvReportos.Rows(Index).Cells("Total a Pagar").Value = TotalPagarSumaComisiones(Index) Index += 1 End While End Sub Sub DefinirCorrelativo(ByVal Index As Integer) 'Dim CorrelavivoAnterior As Integer = 0 'If (Index = 0) Then ' If (dgvReportos.Rows(Index).Cells("Correlativo").Value Is Nothing) Then ' dgvReportos.Rows(Index).Cells("Correlativo").Value = 1 ' End If 'Else ' CorrelavivoAnterior = dgvReportos.Rows(Index - 1).Cells("Correlativo").Value ' dgvReportos.Rows(Index).Cells("Correlativo").Value = CorrelavivoAnterior + 1 'End If End Sub Function TotalPagarSumaComisiones(ByVal Index As Integer) Dim ComisionCasa = 0.0, ComisionBolsa = 0.0, SumaComisiones = 0.0 If (Not dgvReportos.Rows(Index).Cells("Casa").Value Is Nothing) Then ComisionCasa = dgvReportos.Rows(Index).Cells("Casa").Value End If If (Not dgvReportos.Rows(Index).Cells("Bolsa").Value Is Nothing) Then ComisionBolsa = dgvReportos.Rows(Index).Cells("Bolsa").Value End If SumaComisiones = ComisionCasa + ComisionBolsa Return SumaComisiones End Function Function CalcularComisionBolsa(ByVal Index As Integer, ByVal IndexBase As Integer) Dim Monto = 0.0, Porcentaje = 0.0, Dias = 0, Comision = 0.0, Fecha1 = Date.Now.Date, Fecha2 = Date.Now.Date If (Not dgvReportos.Rows(Index).Cells("Monto").Value Is Nothing) Then Monto = dgvReportos.Rows(Index).Cells("Monto").Value End If If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("ComisionBolsa").Value)) Then Porcentaje = dgvReportos.Rows(Index).Cells("ComisionBolsa").Value End If If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value)) Then If String.IsNullOrEmpty(txtDias.Text) Then Dias = 0 Else Dias = txtDias.Text End If End If Dim Valor As Double = 0 Valor = (Monto * Porcentaje) * Dias / 365 Return Valor 'If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("FCompra").Value)) Then ' Fecha1 = dgvReportos.Rows(Index).Cells("FCompra").Value 'End If 'If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value)) Then ' Fecha2 = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value 'End If 'Dim Valor As Double = 0 'If (IndexBase = 0) Then ' Valor = (Monto * Porcentaje) * Dias / 360 ' Return Valor 'ElseIf (IndexBase = 1) Then ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0 ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0 ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2) ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2) ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' PrOpc1 = (Monto * Porcentaje) * DiasPrimeraFecha / 366 ' PrOpc2 = (Monto * Porcentaje) * DiasSegundaFecha / 365 ' Valor = PrOpc1 + PrOpc2 ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' Valor = (Monto * Porcentaje) * DiasSegundaFecha / 365 ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then ' Valor = (Monto * Porcentaje) * DiasPrimeraFecha / 366 ' Else ' Valor = 0 ' End If ' Return Valor 'ElseIf (IndexBase = 2) Then ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0 ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0 ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2) ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2) ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' PrOpc1 = (Monto * Porcentaje) * DiasPrimeraFecha / 366 ' PrOpc2 = (Monto * Porcentaje) * DiasSegundaFecha / 365 ' Valor = PrOpc1 + PrOpc2 ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' Valor = (Monto * Porcentaje) * DiasSegundaFecha / 365 ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then ' Valor = (Monto * Porcentaje) * DiasPrimeraFecha / 366 ' Else ' Valor = 0 ' End If ' Return Valor 'Else ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0 ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0 ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2) ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2) ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' PrOpc1 = (Monto * Porcentaje) * DiasPrimeraFecha / 360 ' PrOpc2 = (Monto * Porcentaje) * DiasSegundaFecha / 360 ' Valor = PrOpc1 + PrOpc2 ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' Valor = (Monto * Porcentaje) * DiasSegundaFecha / 360 ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then ' Valor = (Monto * Porcentaje) * DiasPrimeraFecha / 360 ' Else ' Valor = 0 ' End If ' Return Valor 'End If 'Return Valor End Function Function CalcularComisionCasa(ByVal Index As Integer, ByVal IndexBase As Integer) Dim Monto = 0.0, Porcentaje = 0.0, Dias = 0, Comision = 0.0, Fecha1 = Date.Now.Date, Fecha2 = Date.Now.Date If (Not dgvReportos.Rows(Index).Cells("Monto").Value Is Nothing) Then Monto = dgvReportos.Rows(Index).Cells("Monto").Value End If If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("ComisionCasa").Value)) Then Porcentaje = dgvReportos.Rows(Index).Cells("ComisionCasa").Value End If If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value)) Then Dias = dgvReportos.Rows(Index).Cells("Dias").Value End If If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("FCompra").Value)) Then Fecha1 = dgvReportos.Rows(Index).Cells("FCompra").Value End If If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value)) Then Fecha2 = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value End If '''''''''''''''''''''''''''''''''''''''' Dim Valor As Double = 0 Valor = (Monto * Porcentaje) * Dias / 365 'If (IndexBase = 0) Then ' Valor = (Monto * Porcentaje) * Dias / 360 ' Return Valor 'ElseIf (IndexBase = 1) Then ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0 ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0 ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2) ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2) ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' PrOpc1 = (Monto * Porcentaje) * DiasPrimeraFecha / 366 ' PrOpc2 = (Monto * Porcentaje) * DiasSegundaFecha / 365 ' Valor = PrOpc1 + PrOpc2 ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' Valor = (Monto * Porcentaje) * DiasSegundaFecha / 365 ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then ' Valor = (Monto * Porcentaje) * DiasPrimeraFecha / 366 ' Else ' Valor = 0 ' End If ' Return Valor 'ElseIf (IndexBase = 2) Then ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0 ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0 ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2) ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2) ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' PrOpc1 = (Monto * Porcentaje) * DiasPrimeraFecha / 366 ' PrOpc2 = (Monto * Porcentaje) * DiasSegundaFecha / 365 ' Valor = PrOpc1 + PrOpc2 ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' Valor = (Monto * Porcentaje) * DiasSegundaFecha / 365 ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then ' Valor = (Monto * Porcentaje) * DiasPrimeraFecha / 366 ' Else ' Valor = 0 ' End If ' Return Valor 'Else ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0 ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0 ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2) ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2) ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' PrOpc1 = (Monto * Porcentaje) * DiasPrimeraFecha / 360 ' PrOpc2 = (Monto * Porcentaje) * DiasSegundaFecha / 360 ' Valor = PrOpc1 + PrOpc2 ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' Valor = (Monto * Porcentaje) * DiasSegundaFecha / 360 ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then ' Valor = (Monto * Porcentaje) * DiasPrimeraFecha / 360 ' Else ' Valor = 0 ' End If ' Return Valor 'End If Return Valor End Function Function CalcularInteres(ByVal Index As Integer, ByVal IndexBase As Integer) Dim Monto = 0.0, CostoFinanciero = 0.0, Dias = 0, Interes = 0.0, Fecha1 = Date.Now.Date, Fecha2 = Date.Now.Date If (Not dgvReportos.Rows(Index).Cells("Monto").Value Is Nothing) Then Monto = dgvReportos.Rows(Index).Cells("Monto").Value End If If (Not dgvReportos.Rows(Index).Cells("Costos Financieros").Value Is Nothing) Then CostoFinanciero = dgvReportos.Rows(Index).Cells("Costos Financieros").Value End If If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value)) Then Dias = dgvReportos.Rows(Index).Cells("Dias").Value End If If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("FCompra").Value)) Then Fecha1 = dgvReportos.Rows(Index).Cells("FCompra").Value End If If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value)) Then Fecha2 = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value End If '''''''''''''''''''''''''''''''''''''''''''''''' Dim Valor As Double = 0 Valor = (Monto * CostoFinanciero) * Dias / 365 Return Valor 'If (IndexBase = 0) Then ' Valor = (Monto * CostoFinanciero) * Dias / 360 ' Return Valor 'ElseIf (IndexBase = 1) Then ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0 ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0 ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2) ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2) ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' PrOpc1 = (Monto * CostoFinanciero) * DiasPrimeraFecha / 366 ' PrOpc2 = (Monto * CostoFinanciero) * DiasSegundaFecha / 365 ' Valor = PrOpc1 + PrOpc2 ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' Valor = (Monto * CostoFinanciero) * DiasSegundaFecha / 365 ' MsgBox(Monto) ' MsgBox(CostoFinanciero) ' MsgBox(DiasSegundaFecha) ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then ' Valor = (Monto * CostoFinanciero) * DiasPrimeraFecha / 366 ' Else ' Valor = 0 ' End If ' Return Valor 'ElseIf (IndexBase = 2) Then ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0 ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0 ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2) ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2) ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' PrOpc1 = (Monto * CostoFinanciero) * DiasPrimeraFecha / 366 ' PrOpc2 = (Monto * CostoFinanciero) * DiasSegundaFecha / 365 ' Valor = PrOpc1 + PrOpc2 ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' Valor = (Monto * CostoFinanciero) * DiasSegundaFecha / 365 ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then ' Valor = (Monto * CostoFinanciero) * DiasPrimeraFecha / 366 ' Else ' Valor = 0 ' End If ' Return Valor 'Else ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0 ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0 ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2) ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2) ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' PrOpc1 = (Monto * CostoFinanciero) * DiasPrimeraFecha / 360 ' PrOpc2 = (Monto * CostoFinanciero) * DiasSegundaFecha / 360 ' Valor = PrOpc1 + PrOpc2 ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then ' Valor = (Monto * CostoFinanciero) * DiasSegundaFecha / 360 ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then ' Valor = (Monto * CostoFinanciero) * DiasPrimeraFecha / 360 ' Else ' Valor = 0 ' End If ' Return Valor 'End If 'Return Valor End Function Sub PrepararCostosFinancieros(ByVal Index As Integer) If (dgvReportos.Rows(Index).Cells("Costos Financieros").Value Is Nothing) Then dgvReportos.Rows(Index).Cells("Costos Financieros").Value = 0 End If End Sub Sub PrepararMonto(ByVal Index As Integer) If (dgvReportos.Rows(Index).Cells("Monto").Value Is Nothing) Then dgvReportos.Rows(Index).Cells("Monto").Value = 0 Else If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Monto").Value.ToString)) Then dgvReportos.Rows(Index).Cells("Monto").Value = 0 End If End If End Sub Sub RellenarTxt() 'If (InStr(Variables.Codigo, "REPOVENTA") > 0) Then ' If (String.IsNullOrEmpty(txtDias.Text.ToString)) Then ' txtDias.Text = "0" ' End If 'End If End Sub Sub RellenarDatos() Dim Index = dgvReportos.CurrentRow.Index 'If (Not dgvReportos.Rows(Index).IsNewRow) Then If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Monto").Value)) Then dgvReportos.Rows(Index).Cells("Monto").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value)) Then dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value = Date.Now.Date End If If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Costos Financieros").Value)) Then dgvReportos.Rows(Index).Cells("Costos Financieros").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Intereses").Value)) Then dgvReportos.Rows(Index).Cells("Intereses").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Casa").Value)) Then dgvReportos.Rows(Index).Cells("Casa").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Bolsa").Value)) Then dgvReportos.Rows(Index).Cells("Bolsa").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Total a Pagar").Value)) Then dgvReportos.Rows(Index).Cells("Total a Pagar").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Codigo").Value)) Then dgvReportos.Rows(Index).Cells("Codigo").Value = Correlativo() End If 'End If End Sub Function CalcularFechaVencimiento(ByVal Index As Integer) Dim Dias = 0, FechaVenta = Date.Now.Date, FechaVencimiento = Date.Now.Date IngresarDatos() If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("FCompra").Value)) Then FechaVenta = dgvReportos.Rows(Index).Cells("FCompra").Value End If If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value)) Then Dias = dgvReportos.Rows(Index).Cells("Dias").Value End If FechaVencimiento = FechaVenta.AddDays(Dias) Return FechaVencimiento End Function Function CalcularFechaVenta(ByVal Index As Integer, ByVal IndexAnterior As Integer) Dim FechaVenta As Date If (Not Index = 0) Then IndexAnterior = Index - 1 Dim FVencimiento = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString If (String.IsNullOrEmpty(FVencimiento)) Then FechaVenta = Date.Now.Date Else FechaVenta = FVencimiento End If Else FechaVenta = Date.Now.Date End If Return FechaVenta End Function Sub Calculos() If Variables.Codigo.IndexOf("REPO") > -1 Or Variables.Codigo.IndexOf("REPOVENTA") > -1 Then Dim Cantidad As Integer = dgvReportos.Rows.Count - 2 Dim Index As Integer = 0 While Index <= Cantidad Dim FCompra As Date Dim VComisionCasa As Double = 0 Dim VComisionBolsa As Double = 0 FCompra = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString) VComisionCasa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionCasa").Value.ToString) VComisionBolsa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionBolsa").Value.ToString) FechaVen(FCompra, Index) ComisionCasa(VComisionCasa, Index) ComisionBolsa(VComisionBolsa, Index) IOF(Index) TotalCostos(Index) MontoLiquidacion(Index) InteresGenerar(Index) RendimientoAntes(Index) ValorRecompra(Index) Renta(Index) IngresoNeto(Index) ValorNeto(Index) RendimientoDespues(Index) Index += 1 End While Else 'PrepararRepoVentas() End If End Sub Sub NuevaFila() If Variables.Codigo.IndexOf("REPO") > -1 Or Variables.Codigo.IndexOf("REPOVENTA") > -1 Then Dim i As Integer = dgvReportos.CurrentRow.Index Dim IndexAnterior As Integer = dgvReportos.CurrentRow.Index - 1 If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Codigo").Value)) Then dgvReportos.Rows(i).Cells("Codigo").Value = Correlativo() End If If Not i = 0 Then If (Not String.IsNullOrEmpty(dgvReportos.Rows(IndexAnterior).Cells("EstadoIOF").Value)) Then dgvReportos.Rows(i).Cells("EstadoIOF").Value = dgvReportos.Rows(IndexAnterior).Cells("EstadoIOF").Value Else dgvReportos.Rows(i).Cells("EstadoIOF").Value = 0 End If If (Not String.IsNullOrEmpty(dgvReportos.Rows(IndexAnterior).Cells("EstadoRenta").Value)) Then dgvReportos.Rows(i).Cells("EstadoRenta").Value = dgvReportos.Rows(IndexAnterior).Cells("EstadoRenta").Value Else dgvReportos.Rows(IndexAnterior).Cells("EstadoRenta").Value = 0 End If End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Valor Trasado").Value)) Then dgvReportos.Rows(i).Cells("Valor Trasado").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Dias").Value)) Then dgvReportos.Rows(i).Cells("Dias").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Fecha de Vencimiento").Value)) Then Dim FechaVenc As String = Format(Date.Now.Date, "dd/MM/yyyy") dgvReportos.Rows(i).Cells("Fecha de Vencimiento").Value = FechaVenc End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Rendimiento").Value)) Then dgvReportos.Rows(i).Cells("Rendimiento").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("IOF").Value)) Then dgvReportos.Rows(i).Cells("IOF").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Comision CB").Value)) Then dgvReportos.Rows(i).Cells("Comision CB").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Comision Bolsa").Value)) Then dgvReportos.Rows(i).Cells("Comision Bolsa").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Otros Costos").Value)) Then dgvReportos.Rows(i).Cells("Otros Costos").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Total Costos").Value)) Then dgvReportos.Rows(i).Cells("Total Costos").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Monto a Liquidar").Value)) Then dgvReportos.Rows(i).Cells("Monto a Liquidar").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Interes a Genrerar").Value)) Then dgvReportos.Rows(i).Cells("Interes a Genrerar").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Costo de Transferencia").Value)) Then dgvReportos.Rows(i).Cells("Costo de Transferencia").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("R% Neto (Antes de Impuesto)").Value)) Then dgvReportos.Rows(i).Cells("R% Neto (Antes de Impuesto)").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Valor de ReCompra").Value)) Then dgvReportos.Rows(i).Cells("Valor de ReCompra").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Impuesto de Liquidacion").Value)) Then dgvReportos.Rows(i).Cells("Impuesto de Liquidacion").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Ingreso Neto").Value)) Then dgvReportos.Rows(i).Cells("Ingreso Neto").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Valor Neto").Value)) Then dgvReportos.Rows(i).Cells("Valor Neto").Value = 0 End If If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("R% Neto (Despues de Impuesto)").Value)) Then dgvReportos.Rows(i).Cells("R% Neto (Despues de Impuesto)").Value = 0 End If End If End Sub Sub QuitarFila() Dim result As Integer = MsgBox("¿Está seguro que desea eliminar la fila?", MsgBoxStyle.OkCancel) ' Test result. Dim codigo As String = Variables.Codigo Dim Numero As Integer = dgvReportos.CurrentRow.Cells("codigo").Value If result = MsgBoxResult.Ok Then Try dgvReportos.Rows.Remove(dgvReportos.CurrentRow) ReportoConsula.Eliminar(codigo, Numero, Tabla) Catch ex As Exception MsgBox("No ha seleccionado una fila") End Try End If End Sub Sub FechaVen(ByVal FCompra As Date, ByVal Index As Integer) Dim FechaCompra As Date = FCompra Dim Dias As Integer = 0 Dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString) dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value = CStr(Format(Reporto.FechaDeVencimiento(FechaCompra, Dias), "dd/MM/yyyy")) End Sub Function FechaVenCargar(ByVal Index As Integer) Dim FechaCompra As Date = dtpFechaCompra.Value Dim Dias As Integer = 0 If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value) Then Dias = dgvReportos.Rows(Index).Cells("Dias").Value End If Dim FechaVencimiento = CStr(Format(Reporto.FechaDeVencimiento(FechaCompra, Dias), "dd/MM/yyyy")) dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value = FechaVencimiento Return FechaVencimiento End Function Sub CorrelativoSinBD() Dim Index As Integer = 0 Dim IndexCantidad As Integer = dgvReportos.Rows.Count - 2 Dim NumeroMayor As Integer = 0 While Index <= IndexCantidad dgvReportos.Rows(Index).Cells("Correlativo").Value = Index + 1 Index += 1 End While End Sub Function Correlativo() Dim Index As Integer = 0 Dim IndexCantidad As Integer = dgvReportos.Rows.Count - 2 Dim NumeroMayor As Integer = 0 While Index <= IndexCantidad Dim Numero As Integer = dgvReportos.Rows(Index).Cells("codigo").Value If Numero > NumeroMayor Then NumeroMayor = Numero End If Index += 1 End While Return NumeroMayor + 1 End Function Sub CargarReporto(ByVal Tabla As String) Dim ConvertirString As String Dim Activo = 0.0, ActivoRenta = 0.0 Dim EstadoIOF, EstadoRenta Dim dr = ReportoConsula.CargarReporto(Codigo, Tabla) If Tabla = "REP0" Or Tabla = "REP0VENTA" Then If (Not dr Is Nothing) Then While dr.Read If dr("EstadoIOF") Then EstadoIOF = 1 ChkIOF.Checked = True Else EstadoIOF = 0 ChkIOF.Checked = False End If If dr("EstadoRenta") Then EstadoRenta = 1 ChkRenta.Checked = True Else EstadoRenta = 0 ChkRenta.Checked = False End If Dim FechaVencimiento As Date = dr("FCompra") Dim Dias As Integer = dr("Dias") FechaVencimiento = FechaVencimiento.AddDays(Dias) ConvertirString = Format(FechaVencimiento, "dd/MM/yyyy") dtpFechaCompra.Value = dr("FCompra") If (dr("IOF")) Then Activo = 1 Else Activo = 0 End If If (dr("Renta")) Then ActivoRenta = 1 Else ActivoRenta = 0 End If Dim ComisionCasa As Double = 0 Dim ComisionBolsa As Double = 0 If Not String.IsNullOrEmpty(dr("ComisionCasa").ToString) Then ComisionCasa = dr("ComisionCasa") End If If Not String.IsNullOrEmpty(dr("ComisionBolsa").ToString) Then ComisionBolsa = dr("ComisionBolsa") End If If Tabla = "REP0VENTA" Then dgvReportos.Rows.Add("", dr("ValTrans"), dr("Dias"), ConvertirString, (dr("Rend")), 0, 0, 0, 0, 0, 0, 0, 0, 0, dr("CostoTransfr"), ActivoRenta, "", "", "", dr("Nombre"), dr("FCompra"), ComisionCasa, ComisionBolsa, dr("Casa"), dr("codigo"), "", EstadoIOF, EstadoRenta) End If End While End If Else 'If (Not dr Is Nothing) Then ' While dr.Read ' Dim Monto As Double = 0 ' Dim FVenc As Date = Date.Now.Date ' Dim CostFinanciero As Double = 0 ' Dim Nombre As String = String.Empty ' Dim FCompra As Date = Date.Now.Date ' Dim ComisionCasa As Double = 0 ' Dim ComisionBolsa As Double = 0 ' Dim Dias As Integer =0 ' Dim codigo As Integer = 0 ' Dim Casa2 As String = String.Empty ' If (Not String.IsNullOrEmpty(dr("Monto").ToString)) Then ' Monto = dr("Monto") ' End If ' If (Not String.IsNullOrEmpty(dr("FVenc").ToString)) Then ' FVenc = dr("FVenc") ' End If ' If (Not String.IsNullOrEmpty(dr("CostoFinanciero").ToString)) Then ' CostFinanciero = dr("CostoFinanciero") ' End If ' If (Not String.IsNullOrEmpty(dr("Nombre").ToString)) Then ' Nombre = dr("Nombre") ' End If ' If (Not String.IsNullOrEmpty(dr("FCompra").ToString)) Then ' FCompra = dr("FCompra") ' End If ' If (Not String.IsNullOrEmpty(dr("ComisionCasa").ToString)) Then ' ComisionCasa = dr("ComisionCasa") ' End If ' If (Not String.IsNullOrEmpty(dr("ComisionBolsa").ToString)) Then ' ComisionBolsa = dr("ComisionBolsa") ' End If ' If (Not String.IsNullOrEmpty(dr("Dias").ToString)) Then ' Dias = dr("Dias") ' End If ' If (Not String.IsNullOrEmpty(dr("codigo").ToString)) Then ' codigo = dr("codigo") ' End If ' If (Not String.IsNullOrEmpty(dr("Casa2").ToString)) Then ' Casa2 = dr("Casa2") ' End If ' 'cboAnioBase.SelectedIndex = dr("Base") ' Dim FechaVenFiltro As String = Format(FVenc, "dd/MM/yyyy") ' dgvReportos.Rows.Add("", Monto, FechaVenFiltro, CostFinanciero, 0, 0, 0, 0, Nombre, FCompra, ComisionCasa, ComisionBolsa, Casa2, Dias, codigo) ' End While 'End If End If End Sub Function ObtenerDatos(ByVal Index As Integer) Dim coleccion As New Collection Dim Renta, IOF, Nombre, FCompra, ValTrans, Dias, FVenc, Rend, CostoTransfr, codigo, ComisionCasa, ComisionBolsa, Casa, Casa2 Dim EstadoIOF, EstadoRenta If Variables.Codigo.IndexOf("REPO") > -1 Or Variables.Codigo.IndexOf("REPOVENTA") > -1 Then Dim ComisionCasaValor, ComisionBolsaValor, IOFValor, OtrosCostos, TotalCostos, MontoLiq Dim IntGenerar, RendAntImp, RendDesImp, ImpLiq, IngrNet, ValorNet ValorNet = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Neto").Value.ToString) IngrNet = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Ingreso Neto").Value.ToString) ImpLiq = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value) RendDesImp = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("R% Neto (Despues de Impuesto)").Value) RendAntImp = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("R% Neto (Antes de Impuesto)").Value) IntGenerar = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value) MontoLiq = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Monto a Liquidar").Value) TotalCostos = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Total Costos").Value) OtrosCostos = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Otros Costos").Value) IOFValor = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("IOF").Value) ComisionBolsaValor = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision Bolsa").Value) ComisionCasaValor = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision CB").Value) Nombre = dgvReportos.Rows(Index).Cells("Nombre").Value.ToString FCompra = Operaciones.ConvertirFechaBaseDatos(dgvReportos.Rows(Index).Cells("FCompra").Value) ValTrans = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value) Dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value) FVenc = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value) Rend = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Rendimiento").Value) CostoTransfr = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Costo de Transferencia").Value) codigo = dgvReportos.Rows(Index).Cells("Codigo").Value.ToString ComisionCasa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionCasa").Value) ComisionBolsa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionBolsa").Value) Casa = dgvReportos.Rows(Index).Cells("Casa").Value.ToString If (Not dgvReportos.Rows(Index).Cells("IOF").Value = 0) Then IOF = 1 Else IOF = 0 End If If (Not dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value = 0) Then Renta = 1 Else Renta = 0 End If If (dgvReportos.Rows(Index).Cells("EstadoIOF").Value = 1) Then EstadoIOF = 1 Else EstadoIOF = 0 End If If (dgvReportos.Rows(Index).Cells("EstadoRenta").Value = 1) Then EstadoRenta = 1 Else EstadoRenta = 0 End If coleccion.Add(Nombre) coleccion.Add(CDate(FCompra)) coleccion.Add(CDec(ValTrans)) coleccion.Add(CInt(Dias)) coleccion.Add(CDate(FVenc)) coleccion.Add(CDec(Rend)) coleccion.Add(CDec(CostoTransfr)) coleccion.Add(codigo) coleccion.Add(ComisionCasa) coleccion.Add(ComisionBolsa) coleccion.Add(Casa) coleccion.Add(IOF) coleccion.Add(Renta) coleccion.Add(Base) coleccion.Add(ComisionCasaValor) coleccion.Add(ComisionBolsaValor) coleccion.Add(IOFValor) coleccion.Add(OtrosCostos) coleccion.Add(TotalCostos) coleccion.Add(MontoLiq) coleccion.Add(IntGenerar) coleccion.Add(RendAntImp) coleccion.Add(RendDesImp) coleccion.Add(ImpLiq) coleccion.Add(IngrNet) coleccion.Add(ValorNet) coleccion.Add(EstadoIOF) coleccion.Add(EstadoRenta) End If Return coleccion End Function 'GETS Function GetFechaCompra() As Date Dim valor As Date valor = dtpFechaCompra.Value Return valor End Function Private Sub dgvReportos_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvReportos.CellEndEdit 'If (InStr(Variables.Codigo, "REPOVENTA") > 0) Then ' RellenarDatos() 'End If CorrelativoSinBD() Correlativo() Calculos() End Sub Private Sub dtpFechaCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaCompra.ValueChanged Formato() IngresarDatos() If Variables.Codigo.IndexOf("REPOVENTA") > -1 Then End If Modificado = True Calculos() End Sub Private Sub dgvReportos_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvReportos.CellClick IOFRentaEstado() IngresarDatosReves() NuevaFila() If Variables.Codigo.IndexOf("REPO") > -1 Or Variables.Codigo.IndexOf("REPOVENTA") > -1 Then Dim Index = dgvReportos.CurrentRow.Cells("codigo").Value CargarFecha() RotarValores(Index) Calculos() 'AgregarCheckbox() 'CalcularCheckbox() 'ElseIf (InStr(Variables.Codigo, "REPOVENTA") > 0) Then ' RellenarDatos() ' PrepararRepoVentas() End If Formato() End Sub Private Sub dgvReportos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvReportos.CellContentClick End Sub Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click End Sub Private Sub txtCodigoTitulo_TextChanged(sender As Object, e As EventArgs) Handles txtCodigoTitulo.TextChanged Modificado = True End Sub Private Sub txtIOF_TextChanged(sender As Object, e As EventArgs) End Sub Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click btnAccion.Text = "Modificar" 'btnAgregarImpuesto.Text = "Modificar" Estado = "M" End Sub Sub NuevoIngreso(ByVal AgregarModificar As Boolean, ByVal Cantidad As Integer, ByVal Tabla As String) Dim i As Integer = 0 Dim Index = dgvReportos.Rows.Count - 2 i = Cantidad While i <= Index Dim coleccion = ObtenerDatos(i) If ReportoConsula.Nuevo(coleccion, Codigo, Tabla) Is Nothing Then Exit Sub End If i += 1 End While MsgBox("Reportos actualizados") End Sub Function NuevoIngresoColeccion() Dim i As Integer = 0 Dim Index = dgvReportos.Rows.Count - 2 Dim diccionario As New Dictionary(Of String, Collection) While i <= Index Dim coleccion = ObtenerDatos(i) diccionario.Add(i, coleccion) i += 1 End While Return diccionario End Function Function CanRegistros(ByVal Tabla As String) Dim Codigo = Variables.Codigo Dim Cantidad As Integer = oDAOGeneral.CantidadRegistros(Codigo, Tabla) Return Cantidad End Function Sub ModificarIngreso() Dim i As Integer = 0 Dim CantidadRegistrosDB = CanRegistros(Tabla) While i < CantidadRegistrosDB Dim coleccion = ObtenerDatos(i) If ReportoConsula.Modificar(coleccion, Codigo, Tabla) Is Nothing Then Exit Sub End If i += 1 End While NuevoIngreso(True, CantidadRegistrosDB, Tabla) End Sub Private Sub btnAccion_Click(sender As Object, e As EventArgs) Handles btnAccion.Click LlenarBase() Dim Codigo = Variables.Codigo Dim diccionario As Dictionary(Of String, Collection) = NuevoIngresoColeccion() If (Estado = "N") Then ReportoConsula.ProcesoDatos(diccionario, Codigo, Tabla) 'ModificarIngreso() ValidarExistencia() ElseIf Not ExisteValidacion() Then Variables.ColeccionREPO = diccionario Me.Close() ElseIf (Estado = "M") Then 'ModificarIngreso() ReportoConsula.ProcesoDatos(diccionario, Codigo, Tabla) ValidarExistencia() ElseIf (Estado = "B") Then QuitarFila() ValidarExistencia() End If End Sub Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click btnAccion.Text = "Agregar" 'btnAgregarImpuesto.Text = "Agregar" Estado = "N" End Sub Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click btnAccion.Text = "Eliminar" ' btnAgregarImpuesto.Text = "Eliminar" Estado = "B" End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) End Sub Sub GuardarImpuesto() ' Dim Impuesto = dgvImpuestos.CurrentRow.Cells(0).Value ' Dim CodigoInv = Variables.Codigo ' Dim codigo = dgvImpuestos.CurrentRow.Cells(1).Value ' Dim ValorImpuesto = ReportoConsula.TraerImpuesto(Impuesto) ' Dim Valor = ReportoConsula.AgregarImpuesto(CodigoInv, codigo, Impuesto, 0) ' ActualizarImpuestos(Valor) End Sub Private Sub btnAgregarImpuesto_Click(sender As Object, e As EventArgs) GuardarImpuesto() End Sub Private Sub dgvImpuestos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) End Sub Private Sub TabPage3_Click(sender As Object, e As EventArgs) Handles TbImpuestos.Click End Sub Private Sub dgvImpuestoAgregado_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) End Sub Private Sub btnQuitar_Click(sender As Object, e As EventArgs) ModificarImpuestos() End Sub Sub ModificarImpuestos() 'Dim Index As Integer = dgvImpuestoAgregado.CurrentRow.Index 'Dim Cantidad As Integer = dgvImpuestoAgregado.Rows.Count - 1 'Dim Cadena As String = String.Empty 'Dim IsNothing As Boolean = False 'Dim Codigo 'Cadena = dgvImpuestoAgregado.CurrentRow.Cells(0).Value 'Codigo = dgvImpuestoAgregado.CurrentRow.Cells(1).Value 'If (String.IsNullOrEmpty(Cadena) Or String.IsNullOrEmpty(Codigo)) Then 'MsgBox("No se puede quitar una cadena vacía") 'Else 'ModificarImpu(Cadena, Codigo) 'End If End Sub Sub ModificarImpu(ByVal Impuesto As String, ByVal Codigo As Integer) Dim CodigoInv = Variables.Codigo 'Dim ValorImpuesto = ReportoConsula.TraerImpuesto(Impuesto) Dim Valor = ReportoConsula.AgregarImpuesto(CodigoInv, Codigo, Impuesto, 1) ActualizarImpuestos(Valor) 'ActualizarImpuestos(Valor) 'RefrescarValorControles() End Sub Private Sub FlpIOF_Click(sender As Object, e As EventArgs) Handles FlpIOF.Click End Sub Private Sub FlpIOF_MouseClick(sender As Object, e As MouseEventArgs) Handles FlpIOF.MouseClick End Sub Private Sub FlpIOF_ChangeUICues(sender As Object, e As UICuesEventArgs) Handles FlpIOF.ChangeUICues End Sub Private Sub FlpIOF_Paint(sender As Object, e As PaintEventArgs) Handles FlpIOF.Paint End Sub Private Sub txtComisionCasa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionCasa.KeyPress If String.IsNullOrEmpty(txtComisionCasa.Text.ToString.Trim("%")) Then If e.KeyChar = "." Then txtComisionCasa.Text = "0.0%" Exit Sub End If End If If (Not txtComisionCasa.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 txtComisionBolsa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionBolsa.KeyPress If String.IsNullOrEmpty(txtComisionBolsa.Text.ToString.Trim("%")) Then If e.KeyChar = "." Then txtComisionBolsa.Text = "0.2825%" Exit Sub End If End If If (Not txtComisionBolsa.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 BindingNavigator1_RefreshItems(sender As Object, e As EventArgs) Handles BindingNavigator1.RefreshItems End Sub Private Sub txtComisionCasa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionCasa.TextChanged IngresarDatos() Modificado = True Calculos() End Sub Private Sub txtComisionBolsa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionBolsa.TextChanged IngresarDatos() If (InstrumentoFinanciero = "REPOVENTA") Then End If Modificado = True Calculos() End Sub Private Sub txtDias_TextChanged(sender As Object, e As EventArgs) Handles txtDias.TextChanged IngresarDatos() If (InstrumentoFinanciero = "REPOVENTA") Then End If Modificado = True Calculos() End Sub Private Sub cboCasaCorredora_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboCasaCorredora.SelectedIndexChanged Modificado = True IngresarDatos() End Sub Private Sub txtCodigoTitulo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtCodigoTitulo.KeyPress End Sub Private Sub txtDias_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtDias.KeyPress If String.IsNullOrEmpty(txtDias.Text) Then If e.KeyChar = "." Then txtDias.Text = "0" Exit Sub End If End If If (Not txtDias.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 txtCodigoTitulo_KeyUp(sender As Object, e As KeyEventArgs) Handles txtCodigoTitulo.KeyUp IngresarDatos() End Sub Private Sub txtComisionCasa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionCasa.KeyUp If txtComisionCasa.Text = "." Then txtComisionCasa.Text = ".0%" End If IngresarDatos() Calculos() End Sub Private Sub txtComisionBolsa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionBolsa.KeyUp If txtComisionBolsa.Text = "." Then txtComisionBolsa.Text = ".0%" End If IngresarDatos() Calculos() End Sub Sub ValidarExistencia() Dim General As New DAOGeneral Dim Codigo As String = Variables.Codigo Dim Tabla As String = String.Empty If Variables.Codigo.IndexOf("REPOVENTA") > -1 Then Tabla = "REP0VENTA" ElseIf Variables.Codigo.IndexOf("REPO") > -1 Then Tabla = "REP0" End If 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 btnAccion.Text = "Aceptar" End Sub Function ExisteValidacion() Dim General As New DAOGeneral Dim Codigo As String = Variables.Codigo Dim Tabla As String = String.Empty If Variables.Codigo.IndexOf("REPOVENTA") > -1 Then Tabla = "REP0VENTA" ElseIf Variables.Codigo.IndexOf("REPO") > -1 Then Tabla = "REP0" End If Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla) Return Existe End Function Private Sub btnGuardar_Click(sender As Object, e As EventArgs) End Sub Private Sub dgvReportos_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) Handles dgvReportos.CellBeginEdit CorrelativoSinBD() Correlativo() End Sub Private Sub txtDias_KeyUp(sender As Object, e As KeyEventArgs) Handles txtDias.KeyUp If txtDias.Text = "." Then txtDias.Text = ".0" End If IngresarDatos() Calculos() End Sub Private Sub cboAnioBase_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboAnioBase.SelectedIndexChanged LlenarBase() IngresarDatos() If (InstrumentoFinanciero = "REPOVENTA") Then End If Modificado = True Calculos() End Sub Private Sub txtDias_Leave(sender As Object, e As EventArgs) Handles txtDias.Leave RellenarTxt() Formato() End Sub Private Sub txtComisionCasa_Leave(sender As Object, e As EventArgs) Handles txtComisionCasa.Leave Formato() End Sub Private Sub txtComisionBolsa_Leave(sender As Object, e As EventArgs) Handles txtComisionBolsa.Leave Formato() End Sub Private Sub frmReporto_Resize(sender As Object, e As EventArgs) Handles MyBase.Resize dgvReportos.Width = Me.Width - 10 dgvReportos.Height = Me.Height - 290 End Sub Private Sub ChkIOF_CheckedChanged(sender As Object, e As EventArgs) Handles ChkIOF.CheckedChanged IOFRentaEstado() Modificado = True IngresarDatos() Calculos() End Sub Private Sub ChkRenta_CheckedChanged(sender As Object, e As EventArgs) Handles ChkRenta.CheckedChanged IOFRentaEstado() Modificado = True IngresarDatos() Calculos() End Sub Private Sub txtCodigoInstrumento_TextChanged(sender As Object, e As EventArgs) Handles txtCodigoInstrumento.TextChanged IngresarDatos() Modificado = True Calculos() End Sub Sub SeleccionarInstrumento() Dim frmInstrumentos As New frmSeleccionTitulosReportos frmInstrumentos.Show() End Sub Private Sub btnSaldoDisponible_Click(sender As Object, e As EventArgs) SeleccionarInstrumento() End Sub Private Sub btnRequisicion_Click(sender As Object, e As EventArgs) End Sub Sub CargarTransladoNuevo() Dim Existe As Boolean = ExisteInversion() If Not RetCodigoInversionExiste And Not Existe Then If dgvReportos.Rows(0).Cells("Valor Trasado").Value = 0 Then dgvReportos.Rows(0).Cells("Valor Trasado").Value = Variables.RetMonto End If End If End Sub End Class