| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255 |
- Public Class frmFOIN
- Dim oCEFOIN As FondosDeInversionCE = New FondosDeInversionCE
- Dim oDAOGeneral As New DAOGeneral
- Dim FOIN As New FondoInversionDAO
- Dim EstadoBoton As String
- Dim Operaciones As New Operaciones
- Dim IndexBase As Integer = 0
- Dim TipoTransaccion As String = String.Empty
- Private Sub frmFOIN_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- CargarBase()
- CargarPeriodicidad()
- AgregarCampos()
- CargarRegistroPrincipal()
- CargarFilas()
- Rellenar()
- Calculos()
- ExisteInversion()
- ValidarExistencia()
- End Sub
- Sub ValidarExistencia()
- Dim General As New DAOGeneral
- Dim Codigo As String = Variables.Codigo
- Dim Tabla As String = String.Empty
- Tabla = "FINV"
- 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
- 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 CargarBase()
- If Me.cboAnioBase.Items.Count = 0 Or Me.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
- Sub Rellenar()
- If (String.IsNullOrEmpty(txtValorNominal.Text.ToString)) Then
- txtValorNominal.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtCuotasDeParticipacion.Text.ToString)) Then
- txtCuotasDeParticipacion.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtValorDeParticipacion.Text.ToString)) Then
- txtValorDeParticipacion.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtPorcentajeComisionCasa.Text.ToString.Trim("%"))) Then
- txtPorcentajeComisionCasa.Text = "0.0%"
- End If
- If (String.IsNullOrEmpty(txtPorcentajeComisionBolsa.Text.ToString.Trim("%"))) Then
- txtPorcentajeComisionBolsa.Text = "0.0%"
- End If
- If (String.IsNullOrEmpty(txtComisionCasa.Text.ToString)) Then
- txtComisionCasa.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtComisionBolsa.Text.ToString)) Then
- txtComisionBolsa.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtValorTransado.Text.ToString)) Then
- txtValorTransado.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtDiasLiq.Text.ToString)) Then
- txtDiasLiq.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtRendimientoOfrecido.Text.ToString.Trim("%"))) Then
- txtRendimientoOfrecido.Text = "0.0%"
- End If
- If (String.IsNullOrEmpty(txtPlazo.Text.ToString)) Then
- txtPlazo.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtDividendo.Text.ToString.Trim("%"))) Then
- txtDividendo.Text = "0.0%"
- End If
- End Sub
- Function CalcularFecha(ByVal FechaInicial As Date, ByVal DiaFijo As Integer)
- 'Declaracion de Variables'
- Dim Base As Integer = 0
- Dim Periodicidad As String = cboPeriodicidad.SelectedValue
- Dim TipoCalculo As String = String.Empty
- Dim FechaFinal As Date = Date.Today.Date
- 'Seleccion de Tipo de Calculo'
- If RadioButton1.Checked Then
- TipoCalculo = "FinMes"
- Else
- If RadioButton2.Checked Then
- TipoCalculo = "Mensual"
- End If
- End If
- IndexBase = cboAnioBase.SelectedIndex
- If (IndexBase = 0 Or IndexBase = 2) Then
- Base = 360
- If TipoCalculo = "FinMes" Then
- FechaFinal = Operaciones.FechaFinMes(FechaInicial, Periodicidad, Base)
- ElseIf TipoCalculo = "Mensual" Then
- FechaFinal = Operaciones.FechaMensual(FechaInicial, Periodicidad, TipoCalculo, 0, DiaFijo, Base)
- End If
- ElseIf IndexBase = 1 Or IndexBase = 3 Then
- Base = 365
- If TipoCalculo = "FinMes" Then
- FechaFinal = Operaciones.FechaFinMes(FechaInicial, Periodicidad, Base)
- ElseIf TipoCalculo = "Mensual" Then
- FechaFinal = Operaciones.FechaMensual(FechaInicial, Periodicidad, TipoCalculo, 0, DiaFijo, Base)
- End If
- End If
- Return FechaFinal
- End Function
- Sub AgregarFecha()
- Dim Index As Integer = dgvIngresos.CurrentRow.Index
- Dim IndexAnterior As Integer = Index - 1
- Dim FechaAnterior As Date = Date.Today.Date
- Dim FechaActual As Date = Date.Today.Date
- Dim FechaLiquidacion As Date = dtpFechaLiquidacion.Value
- Dim DiaFijo As Integer = FechaLiquidacion.Day
- If Index > 0 Then
- FechaAnterior = Operaciones.ConvertirFecha(dgvIngresos.Rows(IndexAnterior).Cells("Fecha de Corte").Value.ToString)
- FechaActual = CalcularFecha(FechaAnterior, DiaFijo)
- dgvIngresos.Rows(Index).Cells("Fecha de Corte").Value = Format((FechaActual), "dd/MM/yyyy").ToString
- Else
- FechaActual = CalcularFecha(Operaciones.ConvertirFecha(FechaLiquidacion), DiaFijo)
- dgvIngresos.Rows(Index).Cells("Fecha de Corte").Value = Format(FechaActual, "dd/MM/yyyy").ToString
- End If
- End Sub
- Sub AgregarDias()
- Dim Index As Integer = dgvIngresos.CurrentRow.Index
- Dim IndexAnterior As Integer = Index - 1
- Dim FechaAnterior As String = String.Empty
- Dim FechaActual As String = String.Empty
- Dim FechaLiquidacion As Date = Format(dtpFechaLiquidacion.Value, "dd/MM/yyyy")
- Dim BaseIndex As Integer = cboAnioBase.SelectedIndex
- Dim BaseCalculo As Integer = 0
- Dim Meses As Integer = 0
- Dim TipoCalculo As String = String.Empty
- Dim DiasFinales As Integer = 0
- Dim CantidadDiasNormal360 As Integer = 0
- Dim CantidadDias360 As Integer = 0
- Dim Periodicidad As String = cboPeriodicidad.SelectedValue
- If Periodicidad = "M" Then
- Meses = 1
- ElseIf Periodicidad = "T" Then
- Meses = 3
- ElseIf Periodicidad = "S" Then
- Meses = 6
- ElseIf Periodicidad = "A" Then
- Meses = 12
- End If
- CantidadDiasNormal360 = Meses * 30
- If BaseIndex = 0 Or BaseIndex = 2 Then
- BaseCalculo = 360
- ElseIf BaseIndex = 1 Or BaseIndex = 3 Then
- BaseCalculo = 365
- End If
- If RadioButton1.Checked Then
- TipoCalculo = "FinMes"
- Else
- If RadioButton2.Checked Then
- TipoCalculo = "Mensual"
- End If
- End If
- If Index > 0 Then
- FechaAnterior = Operaciones.ConvertirFecha(dgvIngresos.Rows(IndexAnterior).Cells("Fecha de Corte").Value.ToString)
- FechaActual = Operaciones.ConvertirFecha(dgvIngresos.Rows(Index).Cells("Fecha de Corte").Value.ToString)
- If BaseCalculo = 360 Then
- If TipoCalculo = "FinMes" Then
- DiasFinales = Operaciones.Base360(FechaAnterior, FechaActual)
- ElseIf TipoCalculo = "Mensual" Then
- DiasFinales = CantidadDiasNormal360
- End If
- ElseIf BaseCalculo = 365 Then
- DiasFinales = Operaciones.Base365(FechaAnterior, FechaActual)
- End If
- Else
- 'Primera Fecha'
- FechaActual = Operaciones.ConvertirFecha(dgvIngresos.Rows(Index).Cells("Fecha de Corte").Value.ToString)
- If BaseCalculo = 360 Then
- If TipoCalculo = "FinMes" Then
- DiasFinales = Operaciones.Base360(FechaLiquidacion, FechaActual)
- ElseIf TipoCalculo = "Mensual" Then
- DiasFinales = CantidadDiasNormal360
- End If
- ElseIf BaseCalculo = 365 Then
- DiasFinales = Operaciones.Base365(FechaLiquidacion, FechaActual)
- End If
- End If
- dgvIngresos.Rows(Index).Cells("Dias").Value = DiasFinales
- End Sub
- Sub AgregarDividendo()
- Dim Index As Integer = dgvIngresos.CurrentRow.Index
- Dim Dividendo As String = String.Empty
- Dim DividendoAgregar As String = String.Empty
- Dim DividendoTexto As String = txtDividendo.Text.ToString.Trim("%")
- Dim NuevaFila As Boolean = False
- If dgvIngresos.Rows(Index).Cells("Dividendo").Value Is Nothing Then
- NuevaFila = True
- Else
- Dividendo = dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString
- End If
- If String.IsNullOrEmpty(Dividendo) Then
- If String.IsNullOrEmpty(DividendoTexto) Then
- DividendoAgregar = "0"
- Else
- DividendoAgregar = DividendoTexto
- End If
- dgvIngresos.Rows(Index).Cells("Dividendo").Value = (DividendoAgregar.ToString + "%")
- End If
- End Sub
- Sub AgregarIngreso()
- Dim Index As Integer = dgvIngresos.CurrentRow.Index
- Dim CuotasParticipacion As Double = 0
- Dim Dividendo As Double = 0
- Dim Dias As Integer = 0
- Dim Calculo As Double = 0
- If Index > 0 Then
- CuotasParticipacion = Operaciones.ConvertirDecimal(txtCuotasDeParticipacion.Text.ToString)
- If Not dgvIngresos.Rows(Index).Cells("Dividendo").Value Is Nothing Then
- Dividendo = Operaciones.ConvertirDecimal(dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString)
- End If
- Calculo = CuotasParticipacion * (Dividendo / 100)
- Else
- CuotasParticipacion = Operaciones.ConvertirDecimal(txtCuotasDeParticipacion.Text.ToString)
- If Not dgvIngresos.Rows(Index).Cells("Dividendo").Value Is Nothing Then
- Dividendo = Operaciones.ConvertirDecimal(dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString)
- End If
- If Not dgvIngresos.Rows(Index).Cells("Dias").Value Is Nothing Then
- Dias = Operaciones.ConvertirEntero(dgvIngresos.Rows(Index).Cells("Dias").Value)
- End If
- If Not Dias = 0 Then
- Dim FechaTemporal As Date = dtpFechaLiquidacion.Value.AddDays(1)
- If FechaTemporal.Month = dtpFechaLiquidacion.Value.Month Then
- Calculo = (((Dividendo / 100) * CuotasParticipacion) / Dias)
- Else
- Calculo = CuotasParticipacion * (Dividendo / 100)
- End If
- End If
- End If
- dgvIngresos.Rows(Index).Cells("Ingresos").Value = Calculo
- End Sub
- Sub AgregarRendimientos()
- Dim Index As Integer = dgvIngresos.CurrentRow.Index
- Dim ValorNominal As Double = 0
- Dim Dividendo As Double = 0
- Dim Dias As Integer = 0
- Dim Ingreso As Double = 0
- Dim Calculo As Double = 0
- Dim IndexBase As Integer = 0
- Dim BaseCalculo As Integer = 0
- If Not String.IsNullOrEmpty(txtValorNominal.Text.ToString) Then
- ValorNominal = txtValorNominal.Text
- End If
- If Not dgvIngresos.Rows(Index).Cells("Dividendo").Value Is Nothing Then
- Dividendo = Operaciones.ConvertirDecimal(dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString)
- End If
- If Not dgvIngresos.Rows(Index).Cells("Ingresos").Value Is Nothing Then
- Ingreso = Operaciones.ConvertirDecimal(dgvIngresos.Rows(Index).Cells("Ingresos").Value)
- End If
- If Not dgvIngresos.Rows(Index).Cells("Dias").Value Is Nothing Then
- Dias = Operaciones.ConvertirEntero(dgvIngresos.Rows(Index).Cells("Dias").Value)
- End If
- IndexBase = cboAnioBase.SelectedIndex
- If IndexBase = 0 Or IndexBase = 2 Then
- BaseCalculo = 360
- ElseIf IndexBase = 1 Or IndexBase = 3 Then
- BaseCalculo = 365
- End If
- If Not Dias = 0 And Not ValorNominal = 0 And Not BaseCalculo = 0 Then
- Calculo = Ingreso / ValorNominal * BaseCalculo / Dias
- End If
- dgvIngresos.Rows(Index).Cells("Rendimiento Mensual").Value = (Calculo * 100).ToString + "%"
- End Sub
- Sub AgregarNumDiv()
- Dim Index As Integer = dgvIngresos.CurrentRow.Index
- Dim IndexAnterior As Integer = Index - 1
- Dim I_NumDivAnterior As Integer = 0
- Dim I_NumDivActual As Integer = 0
- Dim S_NumDivAnterior As String = String.Empty
- Dim S_NumDivActual As String = String.Empty
- S_NumDivActual = dgvIngresos.Rows(Index).Cells("NumDiv").Value
- I_NumDivActual = Operaciones.ConvertirEntero(S_NumDivActual)
- If Index > 0 Then
- S_NumDivAnterior = dgvIngresos.Rows(IndexAnterior).Cells("NumDiv").Value
- I_NumDivAnterior = Operaciones.ConvertirEntero(S_NumDivAnterior)
- If I_NumDivActual = 0 Then
- I_NumDivActual = I_NumDivAnterior + 1
- dgvIngresos.Rows(Index).Cells("NumDiv").Value = I_NumDivActual
- End If
- Else
- If I_NumDivActual = 0 Then
- I_NumDivActual = 1
- dgvIngresos.Rows(Index).Cells("NumDiv").Value = I_NumDivActual
- End If
- End If
- End Sub
- Sub AgregarCorrelativo()
- Dim Cantidad As Integer = dgvIngresos.Rows.Count - 2
- Dim Index As Integer = 0
- While Index <= Cantidad
- Dim Correlativo As Integer = Index + 1
- dgvIngresos.Rows(Index).Cells("correlativo").Value = Correlativo
- Index += 1
- End While
- End Sub
- Sub CalculosTabla()
- AgregarCorrelativo()
- AgregarFecha()
- AgregarDias()
- AgregarDividendo()
- AgregarIngreso()
- AgregarRendimientos()
- AgregarNumDiv()
- End Sub
- Sub CargarPeriodicidad()
- Me.cboPeriodicidad.DataSource = oDAOGeneral.ListaPeriodicidad
- Me.cboPeriodicidad.DisplayMember = "Descripcion"
- Me.cboPeriodicidad.ValueMember = "Codigo"
- ' Me.cboPeriodicidad.SelectedIndex = -1
- End Sub
- Private Sub Calculos()
- Dim SCuotasDeParticipacion As String = String.Empty
- Dim SValorParticipacion As String = String.Empty
- Dim SValorNominal As String = String.Empty
- Dim SValorTransado As String = String.Empty
- Dim SDiasPlazo As String = String.Empty
- Dim SPorcentajeComisionCasa As String = String.Empty
- Dim SPorcentajeComisionBolsa As String = String.Empty
- Dim SComisionCasa As String = String.Empty
- Dim SComisionBolsa As String = String.Empty
- Dim SDiasLiquidos As String = String.Empty
- Dim ICuotasDeParticipacion As Double = 0
- Dim IValorParticipacion As Double = 0
- Dim IValorNominal As Double = 0
- Dim IValorTransado As Double = 0
- Dim FechaLiquidacion As Date = Date.Today.Date
- Dim FechaOperacion As Date = Date.Today.Date
- Dim FechaVencimiento As Date = Date.Today.Date
- Dim IDiasPlazo As Integer = 0
- Dim IPorcentajeComisionCasa As Double = 0
- Dim IPorcentajeComisionBolsa As Double = 0
- Dim IComisionCasa As Double = 0
- Dim IComisionBolsa As Double = 0
- Dim IDiasLiquidos As Integer = 0
- SDiasPlazo = txtPlazo.Text.ToString
- IDiasPlazo = Operaciones.ConvertirEntero(SDiasPlazo)
- SDiasLiquidos = txtDiasLiq.Text.ToString
- IDiasLiquidos = Operaciones.ConvertirEntero(SDiasLiquidos)
- SPorcentajeComisionCasa = txtPorcentajeComisionCasa.Text.ToString
- IPorcentajeComisionCasa = Operaciones.ConvertirDecimal(SPorcentajeComisionCasa) / 100
- SPorcentajeComisionBolsa = txtPorcentajeComisionBolsa.Text.ToString
- IPorcentajeComisionBolsa = Operaciones.ConvertirDecimal(SPorcentajeComisionBolsa) / 100
- SCuotasDeParticipacion = txtCuotasDeParticipacion.Text.ToString
- ICuotasDeParticipacion = Operaciones.ConvertirDecimal(SCuotasDeParticipacion)
- SValorParticipacion = txtValorDeParticipacion.Text.ToString
- IValorParticipacion = Operaciones.ConvertirDecimal(SValorParticipacion)
- FechaOperacion = dtpFechaOperacion.Value
- txtValorNominal.Text = oCEFOIN.CalculoValorNominal(ICuotasDeParticipacion, IValorParticipacion)
- SValorNominal = txtValorNominal.Text.ToString
- IValorNominal = Operaciones.ConvertirDecimal(SValorNominal)
- txtValorTransado.Text = IValorNominal
- IValorTransado = IValorNominal
- dtpFechaLiquidacion.Value = FechaOperacion
- dtpFechaLiquidacion.Value = oCEFOIN.CalculoFechaLiq(Format(FechaOperacion, "dd/MM/yyyy").ToString, IDiasLiquidos)
- FechaLiquidacion = dtpFechaLiquidacion.Value
- txtComisionCasa.Text = CalculoComision(IPorcentajeComisionCasa, IValorTransado)
- txtComisionBolsa.Text = CalculoComision(IPorcentajeComisionBolsa, IValorTransado)
- IndexBase = cboAnioBase.SelectedIndex
- If (IndexBase = 0 Or IndexBase = 2) Then
- dtpFechaVencimiento.Value = Operaciones.FechaDias360(FechaLiquidacion, IDiasPlazo)
- ElseIf IndexBase = 1 Or IndexBase = 3 Then
- dtpFechaVencimiento.Value = FechaLiquidacion.AddDays(IDiasPlazo)
- End If
- End Sub
- Function CalculoComision(ByVal PorcComision As Double, ByVal ValTra As Double)
- Return PorcComision * ValTra
- End Function
- Private Sub txtCuotasDeParticipacion_TextChanged(sender As Object, e As EventArgs) Handles txtCuotasDeParticipacion.TextChanged
- If Not Double.TryParse(txtCuotasDeParticipacion.Text, oCEFOIN.CuotasDeParticipacion) Then
- lblErrCuotasDeParticipacion.Visible = True
- Else
- lblErrCuotasDeParticipacion.Visible = False
- End If
- Calculos()
- End Sub
- Private Sub txtCuotasDeParticipacion_LostFocus(sender As Object, e As EventArgs) Handles txtCuotasDeParticipacion.LostFocus
- If Not Double.TryParse(txtCuotasDeParticipacion.Text, oCEFOIN.CuotasDeParticipacion) Then
- lblErrCuotasDeParticipacion.Visible = True
- Else
- lblErrCuotasDeParticipacion.Visible = False
- End If
- Me.txtCuotasDeParticipacion.Text = oCEFOIN.CuotasDeParticipacion.ToString()
- RefrescarValorControles()
- End Sub
- Private Sub txtValorDeParticipacion_TextChanged(sender As Object, e As EventArgs) Handles txtValorDeParticipacion.TextChanged
- If Not Double.TryParse(txtValorDeParticipacion.Text, oCEFOIN.ValorDeParticipacion) Then
- lblErrValorDeParticipacion.Visible = True
- Else
- lblErrValorDeParticipacion.Visible = False
- End If
- Calculos()
- End Sub
- Private Sub txtValorDeParticipacion_LostFocus(sender As Object, e As EventArgs) Handles txtValorDeParticipacion.LostFocus
- If Not Double.TryParse(txtValorDeParticipacion.Text, oCEFOIN.ValorDeParticipacion) Then
- lblErrValorDeParticipacion.Visible = True
- Else
- lblErrValorDeParticipacion.Visible = False
- End If
- Me.txtValorDeParticipacion.Text = oCEFOIN.ValorDeParticipacion.ToString()
- RefrescarValorControles()
- End Sub
- Sub RefrescarValorControles()
- Me.txtValorNominal.Text = oCEFOIN.ValorNominal.ToString()
- Me.txtComisionCasa.Text = oCEFOIN.ComisionCasa.ToString()
- Me.txtComisionBolsa.Text = oCEFOIN.ComisionBolsa.ToString()
- Me.txtValorTransado.Text = oCEFOIN.ValorTransado.ToString()
- End Sub
- Private Sub txtPorcentajeComisionCasa_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeComisionCasa.TextChanged
- Dim valor As Double
- If (txtPorcentajeComisionCasa.ToString.IndexOf("%") = -1) Then
- txtPorcentajeComisionCasa.Text += "%"
- End If
- If Not Double.TryParse(Me.txtPorcentajeComisionCasa.Text.Replace("%", ""), valor) Then
- lblErrComisionCasa.Visible = True
- Else
- lblErrComisionCasa.Visible = False
- End If
- oCEFOIN.PorcentajeComisionCasa = valor / 100
- Calculos()
- End Sub
- Private Sub txtPorcentajeComisionCasa_LostFocus(sender As Object, e As EventArgs) Handles txtPorcentajeComisionCasa.LostFocus
- Me.txtPorcentajeComisionCasa.Text = oCEFOIN.PorcentajeComisionCasa.ToString(Configuraciones.CodigoTXTPorcentaje)
- RefrescarValorControles()
- End Sub
- Private Sub txtPorcentajeComisionBolsa_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeComisionBolsa.TextChanged
- Dim valor As Double
- If (txtPorcentajeComisionBolsa.ToString.IndexOf("%") = -1) Then
- txtPorcentajeComisionBolsa.Text += "%"
- End If
- If Not Double.TryParse(Me.txtPorcentajeComisionBolsa.Text.Replace("%", ""), valor) Then
- lblErrComisionBolsa.Visible = True
- Else
- lblErrComisionBolsa.Visible = False
- End If
- oCEFOIN.PorcentajeComisionBolsa = valor / 100
- Calculos()
- End Sub
- Private Sub txtPorcentajeComisionBolsa_LostFocus(sender As Object, e As EventArgs) Handles txtPorcentajeComisionBolsa.LostFocus
- Me.txtPorcentajeComisionBolsa.Text = oCEFOIN.PorcentajeComisionBolsa.ToString(Configuraciones.CodigoTXTPorcentaje)
- RefrescarValorControles()
- End Sub
- Private Sub dtpFechaOperacion_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaOperacion.ValueChanged
- Calculos()
- End Sub
- Private Sub dtpFechaLiquidacion_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaLiquidacion.ValueChanged
- oCEFOIN.FechaLiquidacion = dtpFechaLiquidacion.Value.Date
- End Sub
- Private Sub dtpFechaVencimiento_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimiento.ValueChanged
- oCEFOIN.FechaVencimiento = dtpFechaVencimiento.Value.Date
- End Sub
- Private Sub txtRendimientoOfrecido_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoOfrecido.TextChanged
- Calculos()
- If (txtRendimientoOfrecido.ToString.IndexOf("%") = -1) Then
- txtRendimientoOfrecido.Text += "%"
- End If
- End Sub
- Private Sub txtRendimientoOfrecido_LostFocus(sender As Object, e As EventArgs) Handles txtRendimientoOfrecido.LostFocus
- End Sub
- Private Sub cboPeriodicidad_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboPeriodicidad.SelectedIndexChanged
- If Not TypeOf cboPeriodicidad.SelectedValue Is DataRowView Then
- If Not cboPeriodicidad.SelectedValue Is Nothing Then
- oCEFOIN.Periodicidad = cboPeriodicidad.SelectedValue.ToString
- End If
- End If
- End Sub
- Private Sub cboAnioBase_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboAnioBase.SelectedIndexChanged
- If Not TypeOf cboAnioBase.SelectedItem Is DataRowView Then
- oCEFOIN.AnioBase = cboAnioBase.SelectedItem
- End If
- End Sub
- Private Sub txtPlazo_TextChanged(sender As Object, e As EventArgs) Handles txtPlazo.TextChanged
- Calculos()
- End Sub
- Private Sub btnRefrescar_Click(sender As Object, e As EventArgs) Handles btnQuitar.Click
- QuitarFila()
- End Sub
- Private Sub txtDividendo_TextChanged(sender As Object, e As EventArgs)
- Calculos()
- End Sub
- Private Sub txtDividendo_LostFocus(sender As Object, e As EventArgs)
- End Sub
- Private Sub txtCuotasDeParticipacion_KeyUp(sender As Object, e As KeyEventArgs) Handles txtCuotasDeParticipacion.KeyUp
- Calculos()
- End Sub
- Private Sub txtValorDeParticipacion_KeyUp(sender As Object, e As KeyEventArgs) Handles txtValorDeParticipacion.KeyUp
- Calculos()
- End Sub
- Private Sub txtDiasLiq_KeyUp(sender As Object, e As KeyEventArgs) Handles txtDiasLiq.KeyUp
- Calculos()
- End Sub
- Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
- TipoTransaccion = "M"
- btnAccion.Text = "Modificar"
- End Sub
- Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
- TipoTransaccion = "N"
- btnAccion.Text = "Nuevo"
- End Sub
- Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
- TipoTransaccion = "B"
- btnAccion.Text = "Eliminar"
- End Sub
- Private Sub btnAccion_Click(sender As Object, e As EventArgs) Handles btnAccion.Click
- Dim codigo As String = Variables.Codigo
- Dim Coleccion As Collection = ColeccionDatos()
- Dim Diccionario As Dictionary(Of String, Collection) = NuevoIngresoDiccionario()
- If (TipoTransaccion = "N") Then
- FOIN.ProcesoDatos(Coleccion, codigo, Diccionario, "Nuevo")
- ElseIf (TipoTransaccion = "M") Then
- FOIN.ProcesoDatos(Coleccion, codigo, Diccionario, "Modificar")
- ElseIf (TipoTransaccion = "B") Then
- Eliminar()
- ElseIf Not ExisteValidacion() Then
- Variables.ColeccionFINV = Coleccion
- Variables.ColeccionFINVDi = Diccionario
- Me.Close()
- End If
- End Sub
- Sub Eliminar()
- Dim codigo As String = Variables.Codigo
- FOIN.Eliminar(codigo)
- End Sub
- Function ExisteValidacion()
- Dim General As New DAOGeneral
- Dim Codigo As String = Variables.Codigo
- Dim Tabla As String = String.Empty
- Tabla = "FINV"
- Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
- Return Existe
- End Function
- Private Function NuevoIngresoDiccionario()
- Dim Diccionario As New Dictionary(Of String, Collection)
- Dim Cantidad As Integer = dgvIngresos.Rows.Count - 2
- Dim Index As Integer = 0
- While Index <= Cantidad
- Dim coleccion As New Collection
- Dim FechaCorte, Dias, Dividendo, Ingreso, RendMensual, NumDiv
- NumDiv = Operaciones.ConvertirEntero(dgvIngresos.Rows(Index).Cells("NumDiv").Value)
- FechaCorte = Operaciones.ConvertirFecha(dgvIngresos.Rows(Index).Cells("Fecha de Corte").Value)
- Dias = Operaciones.ConvertirEntero(dgvIngresos.Rows(Index).Cells("Dias").Value)
- Dividendo = Operaciones.ConvertirDecimal(dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString) / 100
- Ingreso = Operaciones.ConvertirDecimal(dgvIngresos.Rows(Index).Cells("Ingresos").Value)
- RendMensual = Operaciones.ConvertirDecimal(dgvIngresos.Rows(Index).Cells("Rendimiento Mensual").Value.ToString) / 100
- coleccion.Add(NumDiv)
- coleccion.Add(FechaCorte)
- coleccion.Add(Dias)
- coleccion.Add(Dividendo)
- coleccion.Add(Ingreso)
- coleccion.Add(RendMensual)
- Diccionario.Add(NumDiv, coleccion)
- Index += 1
- End While
- Return Diccionario
- End Function
- Private Function ColeccionDatos()
- Dim Coleccion As New Collection
- Dim TipoCalculo As String = Me.TipoCalculo
- Coleccion.Add(txtValorNominal.Text)
- Coleccion.Add(txtCuotasDeParticipacion.Text)
- Coleccion.Add(txtValorDeParticipacion.Text)
- Coleccion.Add((txtPorcentajeComisionCasa.Text.ToString.Trim("%")) / 100)
- Coleccion.Add((txtPorcentajeComisionBolsa.Text.ToString.Trim("%")) / 100)
- Coleccion.Add(txtComisionCasa.Text)
- Coleccion.Add(txtComisionBolsa.Text)
- Coleccion.Add(txtValorTransado.Text)
- Coleccion.Add(dtpFechaOperacion.Value)
- Coleccion.Add(dtpFechaLiquidacion.Value)
- Coleccion.Add(dtpFechaVencimiento.Value)
- Coleccion.Add(txtDiasLiq.Text)
- Coleccion.Add(CDec(txtRendimientoOfrecido.Text.ToString.Trim("%")) / 100)
- Coleccion.Add(cboPeriodicidad.SelectedValue)
- Coleccion.Add(cboAnioBase.SelectedIndex)
- Coleccion.Add(txtPlazo.Text)
- Coleccion.Add(txtDividendo.Text.ToString.Trim("%") / 100)
- Coleccion.Add(TipoCalculo)
- Return Coleccion
- End Function
- Function TipoCalculo()
- Dim TipCalculo As String = "FinMes"
- If RadioButton1.Checked Then
- TipCalculo = "FinMes"
- Else
- If RadioButton2.Checked Then
- TipCalculo = "Mensual"
- End If
- End If
- Return TipCalculo
- End Function
- Private Sub CargarRegistroPrincipal()
- Dim FONV As New FondoInversionDAO
- Dim Codigo As String = Variables.Codigo
- Dim Coleccion As Collection = FONV.Cargar(Codigo)
- Dim TipoOperacion As String = String.Empty
- If Not Coleccion.Count = 0 Then
- txtValorNominal.Text = Operaciones.ConvertirDecimal(Coleccion(1).ToString)
- txtCuotasDeParticipacion.Text = Operaciones.ConvertirDecimal(Coleccion(2).ToString)
- txtValorDeParticipacion.Text = Operaciones.ConvertirDecimal(Coleccion(3).ToString)
- txtPorcentajeComisionCasa.Text = Operaciones.ConvertirDecimal((Coleccion(4) * 100).ToString)
- txtPorcentajeComisionBolsa.Text = Operaciones.ConvertirDecimal((Coleccion(5) * 100).ToString)
- txtComisionCasa.Text = Operaciones.ConvertirDecimal(Coleccion(6).ToString)
- txtComisionBolsa.Text = Operaciones.ConvertirDecimal(Coleccion(7).ToString)
- txtValorTransado.Text = Operaciones.ConvertirDecimal(Coleccion(8).ToString)
- dtpFechaOperacion.Value = Operaciones.ConvertirFecha(Coleccion(9).ToString)
- dtpFechaLiquidacion.Value = Operaciones.ConvertirFecha(Coleccion(10).ToString)
- dtpFechaVencimiento.Value = Operaciones.ConvertirFecha(Coleccion(11))
- txtDiasLiq.Text = Operaciones.ConvertirEntero(Coleccion(12).ToString)
- txtRendimientoOfrecido.Text = Operaciones.ConvertirDecimal((Coleccion(13) * 100).ToString)
- cboPeriodicidad.SelectedValue = Coleccion(14).ToString
- cboAnioBase.SelectedIndex = Operaciones.ConvertirEntero(Coleccion(15).ToString)
- txtPlazo.Text = Operaciones.ConvertirEntero(Coleccion(16).ToString)
- txtDividendo.Text = Operaciones.ConvertirDecimal((Coleccion(17) * 100).ToString)
- TipoOperacion = Coleccion(18).ToString
- If TipoOperacion = "FinMes" Then
- RadioButton1.Checked = True
- Else
- If TipoOperacion = "Mensual" Then
- RadioButton2.Checked = True
- End If
- End If
- End If
- End Sub
- Sub CargarFilas()
- Dim FONV As New FondoInversionDAO
- Dim Codigo As String = Variables.Codigo
- Dim Tabla As DataTable = FONV.CargarFilas(Codigo)
- For Each rows As DataRow In Tabla.Rows
- Dim NumDiv As Integer = 0
- Dim Fecha As Date = Date.Today.Date
- Dim Dias As Integer = 0
- Dim Dividendo As String = String.Empty
- Dim Ingreso As Double = 0
- Dim Rend As String = String.Empty
- NumDiv = Operaciones.ConvertirEntero(rows("NumDiv").ToString)
- Fecha = Operaciones.ConvertirFecha(rows("Fecha").ToString)
- Dias = Operaciones.ConvertirEntero(rows("Dias").ToString)
- Dividendo = (Operaciones.ConvertirDecimal(rows("Dividendo").ToString) * 100).ToString + "%"
- Ingreso = Operaciones.ConvertirDecimal(rows("Ingreso").ToString)
- Rend = (Operaciones.ConvertirDecimal(rows("Rend").ToString) * 100).ToString + "%"
- dgvIngresos.Rows.Add("", Fecha, Dias, Dividendo, Ingreso, Rend, NumDiv)
- Next
- AgregarCorrelativo()
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs)
- End Sub
- Sub AgregarCampos()
- Dim CantidadColumnas As Integer = dgvIngresos.ColumnCount
- If CantidadColumnas = 0 Then
- Dim FechaCorte, Dias, Dividendo, Ingreso, RendMensual, correlativo, NumDiv As New DataGridViewTextBoxColumn
- correlativo.Name = "correlativo"
- FechaCorte.Name = "Fecha de Corte"
- Dias.Name = "Dias"
- Dividendo.Name = "Dividendo"
- Ingreso.Name = "Ingresos"
- RendMensual.Name = "Rendimiento Mensual"
- NumDiv.Name = "NumDiv"
- dgvIngresos.Columns.Add(correlativo)
- dgvIngresos.Columns.Add(FechaCorte)
- dgvIngresos.Columns.Add(Dias)
- dgvIngresos.Columns.Add(Dividendo)
- dgvIngresos.Columns.Add(Ingreso)
- dgvIngresos.Columns.Add(RendMensual)
- dgvIngresos.Columns.Add(NumDiv)
- End If
- End Sub
- Private Sub dgvIngresos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellContentClick
- End Sub
- Private Sub dgvIngresos_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgvIngresos.CellMouseClick
- CalculosTabla()
- End Sub
- Private Sub dgvIngresos_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellEndEdit
- End Sub
- Private Sub txtDiasLiq_TextChanged(sender As Object, e As EventArgs) Handles txtDiasLiq.TextChanged
- Rellenar()
- Calculos()
- End Sub
- Private Sub btnModificar_Click(sender As Object, e As EventArgs)
- End Sub
- Private Sub btnEliminar_Click(sender As Object, e As EventArgs)
- End Sub
- Private Sub BindingNavigator1_RefreshItems(sender As Object, e As EventArgs) Handles BindingNavigator1.RefreshItems
- End Sub
- Private Sub btnRescate_Click(sender As Object, e As EventArgs)
- End Sub
- Private Sub txtCuotasDeParticipacion_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtCuotasDeParticipacion.KeyPress
- If String.IsNullOrEmpty(sender.Text) Then
- If e.KeyChar = "." Then
- sender.Text = "0"
- Exit Sub
- End If
- End If
- If (Not sender.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 txtValorDeParticipacion_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtValorDeParticipacion.KeyPress
- If String.IsNullOrEmpty(sender.Text) Then
- If e.KeyChar = "." Then
- sender.Text = "0"
- Exit Sub
- End If
- End If
- If (Not sender.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 txtPorcentajeComisionCasa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeComisionCasa.KeyPress
- If String.IsNullOrEmpty(sender.Text) Then
- If e.KeyChar = "." Then
- sender.Text = "0"
- Exit Sub
- End If
- End If
- If (Not sender.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 txtPorcentajeComisionBolsa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeComisionBolsa.KeyPress
- If String.IsNullOrEmpty(sender.Text) Then
- If e.KeyChar = "." Then
- sender.Text = "0"
- Exit Sub
- End If
- End If
- If (Not sender.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 txtDiasLiq_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtDiasLiq.KeyPress
- If String.IsNullOrEmpty(sender.Text) Then
- If e.KeyChar = "." Then
- sender.Text = "0"
- Exit Sub
- End If
- End If
- If (Not sender.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 txtRendimientoOfrecido_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtRendimientoOfrecido.KeyPress
- If String.IsNullOrEmpty(sender.Text) Then
- If e.KeyChar = "." Then
- sender.Text = "0"
- Exit Sub
- End If
- End If
- If (Not sender.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(sender.Text) Then
- If e.KeyChar = "." Then
- sender.Text = "0"
- Exit Sub
- End If
- End If
- If (Not sender.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 GroupBox3_Enter(sender As Object, e As EventArgs) Handles GroupBox3.Enter
- End Sub
- Private Sub GroupBox2_Enter(sender As Object, e As EventArgs) Handles GroupBox2.Enter
- End Sub
- Private Sub dgvIngresos_Click(sender As Object, e As EventArgs) Handles dgvIngresos.Click
- End Sub
- Private Sub Button1_Click_1(sender As Object, e As EventArgs)
- End Sub
- Private Sub DateTimePicker1_ValueChanged(sender As Object, e As EventArgs)
- End Sub
- Private Sub btnCancelat_Click(sender As Object, e As EventArgs) Handles btnCancelat.Click
- Me.Close()
- End Sub
- Sub QuitarFila()
- Dim CantidadFilas As Integer = dgvIngresos.Rows.Count - 1
- If CantidadFilas > 0 Then
- 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 = dgvIngresos.CurrentRow.Cells("NumDiv").Value
- If result = MsgBoxResult.Ok Then
- Try
- dgvIngresos.Rows.Remove(dgvIngresos.CurrentRow)
- FOIN.EliminarIngreso(codigo, Numero)
- Catch ex As Exception
- MsgBox("No ha seleccionado una fila")
- End Try
- End If
- Else
- MsgBox("Actualmente no tiene registros")
- End If
- End Sub
- Private Sub txtCuotasDeParticipacion_Leave(sender As Object, e As EventArgs) Handles txtCuotasDeParticipacion.Leave
- Rellenar()
- End Sub
- Private Sub txtValorDeParticipacion_Leave(sender As Object, e As EventArgs) Handles txtValorDeParticipacion.Leave
- Rellenar()
- End Sub
- Private Sub txtPorcentajeComisionCasa_Leave(sender As Object, e As EventArgs) Handles txtPorcentajeComisionCasa.Leave
- Rellenar()
- End Sub
- Private Sub txtPorcentajeComisionBolsa_Leave(sender As Object, e As EventArgs) Handles txtPorcentajeComisionBolsa.Leave
- Rellenar()
- End Sub
- Private Sub txtDiasLiq_Leave(sender As Object, e As EventArgs) Handles txtDiasLiq.Leave
- Rellenar()
- End Sub
- Private Sub txtRendimientoOfrecido_Leave(sender As Object, e As EventArgs) Handles txtRendimientoOfrecido.Leave
- Rellenar()
- End Sub
- Private Sub txtPlazo_Leave(sender As Object, e As EventArgs) Handles txtPlazo.Leave
- Rellenar()
- End Sub
- Private Sub txtDividendo_TextChanged_1(sender As Object, e As EventArgs) Handles txtDividendo.TextChanged
- If (txtDividendo.ToString.IndexOf("%") = -1) Then
- txtDividendo.Text += "%"
- End If
- Rellenar()
- End Sub
- Private Sub txtDividendo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtDividendo.KeyPress
- If String.IsNullOrEmpty(sender.Text) Then
- If e.KeyChar = "." Then
- sender.Text = "0"
- Exit Sub
- End If
- End If
- If (Not sender.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 dgvIngresos_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellClick
- End Sub
- End Class
|