| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672 |
- Public Class frmSeleccionTitulosReportos
- Dim DAOGeneral As New DAOGeneral
- Dim Operaciones As New Operaciones
- Dim NombreTrasladar As String = String.Empty
- Dim ObtenerInstanciaObjetotexto As New TextBox
- Dim ObtenerInstanciaObjetocheque As New CheckBox
- Dim SeleccionDAO As New SeleccionTitulosReportosDAO
- Dim General As New DAOGeneral
- Dim CodigoAsociado As String = String.Empty
- Dim MontoUsado As Double = 0
- Dim Empresa As String = String.Empty
- Dim NombreEm As String = String.Empty
- Dim CodigoReporto As String = String.Empty
- Dim IdFlujo As Integer = 0
- Private Sub frmSeleccionTitulosReportos_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Formato()
- DefinirValoresIniciales()
- CargarTitulos()
- SaldoGarantia()
- Controladores(0)
- End Sub
- Sub DefinirValoresIniciales()
- txtCodigoAsociado.Text = CodigoAsociado
- txtMonto.Text = MontoUsado
- End Sub
- Sub New()
- ' Esta llamada es exigida por el diseñador.
- InitializeComponent()
- ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
- End Sub
- Sub New(DicDatos As Dictionary(Of String, Object))
- Me.New
- If DicDatos.ContainsKey("MontoUsado") Then
- Me.MontoUsado = DicDatos.Item("MontoUsado")
- End If
- If DicDatos.ContainsKey("CodigoAsociado") Then
- Me.CodigoAsociado = DicDatos.Item("CodigoAsociado")
- End If
- If DicDatos.ContainsKey("Empresa") Then
- Me.Empresa = DicDatos.Item("Empresa")
- End If
- If DicDatos.ContainsKey("NombreEmpresa") Then
- Me.NombreEm = DicDatos.Item("NombreEmpresa")
- End If
- If DicDatos.ContainsKey("CodigoReporto") Then
- Me.CodigoReporto = DicDatos.Item("CodigoReporto")
- End If
- If DicDatos.ContainsKey("IdFlujo") Then
- Me.IdFlujo = DicDatos.Item("IdFlujo")
- End If
- End Sub
- Sub CargarTitulos()
- Dim dt As New DataTable
- dt = DAOGeneral.ListaInstrumentos("Propuesta")
- For Each Item As DataRow In dt.Rows
- ''GeneracionCheques
- Dim cheque As New CheckBox
- cheque.Width = 215
- cheque.Margin = New Padding(90, 10, 0, 10)
- cheque.Name = Item("Codigo").ToString
- cheque.Text = Item("Descripcion").ToString
- flpTitulos.AutoScroll = True
- ''GeneracionTexto
- Dim texto As New TextBox
- Dim Label As New Label
- Label.Text = " "
- Label.ForeColor = Color.Maroon
- Label.Name = Item("Codigo").ToString
- texto.Width = 150
- texto.Margin = New Padding(0, 10, 0, 10)
- Label.Margin = New Padding(50, 10, 0, 10)
- texto.Name = Item("Codigo").ToString
- texto.Text = 0
- flpValor.AutoScroll = True
- texto.ReadOnly = True
- texto.BorderStyle = BorderStyle.FixedSingle
- texto.BackColor = SystemColors.Control
- AddHandler cheque.CheckedChanged, AddressOf ObtenerNombre
- AddHandler cheque.MouseMove, AddressOf Focuss
- flpTitulos.Controls.Add(cheque)
- flpValor.Controls.Add(Label)
- flpValor.Controls.Add(texto)
- Next
- End Sub
- Sub Focuss()
- flpValor.VerticalScroll.Value = flpTitulos.VerticalScroll.Value
- End Sub
- Sub ObtenerNombre(sender As Object, e As EventArgs)
- Controladores(1)
- NombreTrasladar = sender.name.ToString
- For Each Item In flpValor.Controls
- If TypeOf Item Is TextBox Then
- If Item.Name = NombreTrasladar Then
- If sender.checked Then
- ObtenerInstanciaObjetotexto = Item
- ObtenerInstanciaObjetocheque = sender
- Else
- ObtenerInstanciaObjetotexto = Item
- NombreTrasladar = sender.name.ToString
- Item.Text = 0
- ObtenerInstanciaObjetotexto.BackColor = SystemColors.Control
- ObtenerInstanciaObjetotexto.ForeColor = Color.Black
- ObtenerInstanciaObjetotexto = Nothing
- NombreTrasladar = String.Empty
- ObtenerInstanciaObjetocheque = Nothing
- End If
- End If
- ElseIf TypeOf Item Is Label Then
- If Item.Name = NombreTrasladar Then
- Item.text = "------>"
- Else
- Item.text = " "
- End If
- End If
- Next
- flpValor.VerticalScroll.Value = flpTitulos.VerticalScroll.Value
- End Sub
- Function TrasladarMonto()
- Dim MoverLimpio As Double = Operaciones.ConvertirDecimal(txtMover.Text.ToString)
- Dim PorcRest As Double = Operaciones.ConvertirDecimal(lblPorcentajeRestanteValor.Text.ToString)
- Dim MontoDisponible As Double = Operaciones.ConvertirDecimal(lblMontoDisponible.Text.ToString)
- Dim MontoTotal As Double = Operaciones.ConvertirDecimal(lblMontoPorcentaje.Text.ToString)
- If rdbMonto.Checked Then
- If (MoverLimpio <= 0) Then
- MsgBox("Ingrese un numero mayor a 0")
- Return 0
- ElseIf MoverLimpio > MontoTotal Then
- MsgBox("El Monto Máximo es de " + MontoTotal.ToString)
- Return 0
- ElseIf MoverLimpio > MontoDisponible Then
- MsgBox("Monto Fuera de Rango")
- Return 0
- Else
- If Not String.IsNullOrEmpty(NombreTrasladar) And Not ObtenerInstanciaObjetotexto Is Nothing Then
- If Not lblMontoDisponible.Text = 0 Then
- ObtenerInstanciaObjetotexto.BackColor = Color.Brown
- ObtenerInstanciaObjetotexto.ForeColor = Color.White
- End If
- End If
- CalculoSaldoUsado()
- Return 1
- End If
- Else
- If (MoverLimpio <= 0) Then
- MsgBox("Ingrese un numero mayor a 0")
- Return 0
- ElseIf MoverLimpio > 100 Then
- MsgBox("El Porcentaje máximo es de 100 %")
- Return 0
- ElseIf MoverLimpio > PorcRest Then
- MsgBox("Porcentaje Fuera de Rango")
- Return 0
- Else
- If Not String.IsNullOrEmpty(NombreTrasladar) And Not ObtenerInstanciaObjetotexto Is Nothing Then
- If Not lblMontoDisponible.Text = 0 Then
- ObtenerInstanciaObjetotexto.BackColor = Color.Brown
- ObtenerInstanciaObjetotexto.ForeColor = Color.White
- End If
- End If
- CalculoSaldoUsado()
- Return 1
- End If
- End If
- End Function
- Sub CalculoSaldoUsado()
- Dim TipoValor As String = String.Empty
- If rdbMonto.Checked Then
- TipoValor = "Monto"
- Else
- TipoValor = "Porc"
- End If
- ''Es Positivo
- If TipoValor = "Monto" Then
- ObtenerInstanciaObjetotexto.Text = txtMover.Text
- txtMover.Text = 0
- Else
- If Not lblMontoDisponible.Text = 0 Then
- ObtenerInstanciaObjetotexto.Text = (Operaciones.ConvertirDecimal(lblMontoPorcentaje.Text) * (Operaciones.ConvertirDecimal(txtMover.Text) / 100))
- Else
- MsgBox("No cuenta con suficientes fondos")
- End If
- End If
- End Sub
- Private Sub tlpValor_Paint(sender As Object, e As PaintEventArgs)
- End Sub
- Private Sub flpTitulos_Scroll(sender As Object, e As ScrollEventArgs) Handles flpTitulos.Scroll
- flpValor.VerticalScroll.Value = flpTitulos.VerticalScroll.Value
- End Sub
- Private Sub btnMover_Click(sender As Object, e As EventArgs) Handles btnMover.Click
- Dim Continuar As Integer = TrasladarMonto()
- If Continuar = 1 Then
- Controladores(2)
- End If
- End Sub
- Function ConteoSaldoUsado()
- Dim Monto As Double = 0
- Dim CantidadFilas = dgvDetalles.Rows.Count - 1
- Dim Index As Integer = 0
- While (CantidadFilas >= Index)
- Monto += Operaciones.ConvertirDecimal(dgvDetalles.Rows(Index).Cells("Monto").Value.ToString)
- Index += 1
- End While
- Return Monto
- End Function
- Function CalculoSaldo()
- Dim MontoActualPorcentaje As Double = 0
- Dim MontoUsado As Double = 0
- Dim MontoDisponible As Double = 0
- Dim Positivo As Boolean = False
- MontoActualPorcentaje = Operaciones.ConvertirDecimal(lblMontoPorcentaje.Text.ToString)
- MontoUsado = Operaciones.ConvertirDecimal(ConteoSaldoUsado.ToString)
- lblMontoUsado.Text = MontoUsado
- MontoDisponible = MontoActualPorcentaje - MontoUsado
- If MontoDisponible >= 0 Then
- lblMontoDisponible.Text = MontoDisponible
- Positivo = True
- Else
- Positivo = False
- End If
- Return Positivo
- End Function
- Private Sub btnCancelar_Click(sender As Object, e As EventArgs) Handles btnCancelar.Click
- txtMover.Text = 0
- If Not ObtenerInstanciaObjetocheque Is Nothing Then
- ObtenerInstanciaObjetocheque.Checked = False
- ObtenerInstanciaObjetocheque = Nothing
- End If
- Controladores(0)
- End Sub
- Private Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles btnAgregar.Click
- End Sub
- Private Sub flpTitulos_CursorChanged(sender As Object, e As EventArgs) Handles flpTitulos.CursorChanged
- End Sub
- Sub SaldoGarantia()
- Dim PorcentajeIngresado As Double = Operaciones.ConvertirDecimal(txtPorcentaje.Text.ToString)
- If PorcentajeIngresado > 100 Then
- txtPorcentaje.Text = "100 %"
- MsgBox("Porcentaje Demasiado Alto,Ingrese uno menor")
- End If
- Dim Porcentaje As Double = 0
- Dim ValorTitulo As Double = 0
- If Not String.IsNullOrEmpty(txtPorcentaje.Text) Then
- Porcentaje = (Operaciones.ConvertirDecimal(txtPorcentaje.Text.ToString) / 100)
- End If
- Dim Monto As Double = Operaciones.ConvertirDecimal(txtMonto.Text.ToString)
- Dim MontoDisponible As Double = Monto * Porcentaje
- ValorTitulo = Monto - MontoDisponible
- txtValorTitulo.Text = ValorTitulo
- lblMontoDisponible.Text = MontoDisponible
- lblMontoPorcentaje.Text = MontoDisponible
- End Sub
- Private Sub lblMontoDisponible_Click(sender As Object, e As EventArgs) Handles lblMontoDisponible.Click
- End Sub
- Private Sub txtPorcentaje_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentaje.TextChanged
- SaldoGarantia()
- End Sub
- Sub Guardar()
- Dim Valores As New Collection
- Valores = GuardarValores()
- SeleccionDAO.ProcesoDatos(Valores)
- End Sub
- Function GuardarValores() As Collection
- Dim ColRegistros As New Collection
- Dim Tipo As String = String.Empty
- If rdbMonto.Checked Then
- Tipo = "Monto"
- Else
- Tipo = "Porcentaje"
- End If
- Dim CantidadFilas = dgvDetalles.Rows.Count - 1
- Dim Index As Integer = 0
- While (CantidadFilas >= Index)
- Dim DicRegistrosInstrumentos As New Dictionary(Of String, Object)
- Dim CodigoAso As String = Me.CodigoAsociado
- Dim CodigoReporto As String = Me.CodigoReporto
- Dim IdFlujo As Integer = Operaciones.ConvertirEntero(Me.IdFlujo.ToString)
- Dim NombreInstrumento As String = dgvDetalles.Rows(Index).Cells("NombreInstrumento").Value.ToString
- Dim NombreEmpresa As String = dgvDetalles.Rows(Index).Cells("NombreEmpresa").Value.ToString
- Dim TipoAsignacion As String = Tipo
- Dim MontoInicial As Double = Operaciones.ConvertirDecimal(txtMonto.Text.ToString)
- Dim MontoTotalUsado As Double = Operaciones.ConvertirDecimal(lblMontoPorcentaje.Text.ToString)
- Dim PorcentajeRestante As Double = Operaciones.ConvertirDecimal(dgvDetalles.Rows(Index).Cells("PorcentajeRestantes").Value.ToString)
- Dim PorcentajeMontoUsado As Double = Operaciones.ConvertirDecimal(txtPorcentaje.Text.ToString)
- Dim MontoDisponible As Double = Operaciones.ConvertirDecimal(dgvDetalles.Rows(Index).Cells("SaldoDisponible").Value.ToString)
- Dim MontoUsado As Double = Operaciones.ConvertirDecimal(dgvDetalles.Rows(Index).Cells("SaldoUsado").Value.ToString)
- Dim MontoTitulo As Double = Operaciones.ConvertirDecimal(dgvDetalles.Rows(Index).Cells("Monto").Value.ToString)
- Dim MontoNoUsado As Double = Operaciones.ConvertirDecimal(txtValorTitulo.Text.ToString)
- Dim FechaCreado As Date = Date.Now.Date
- Dim EstadoProceso As String = "P"
- Dim Asociado As String = "No"
- ''AgregarCampos al Dicionario
- DicRegistrosInstrumentos.Add("CodigoAsociado", CodigoAso)
- DicRegistrosInstrumentos.Add("NombreInstrumento", NombreInstrumento)
- DicRegistrosInstrumentos.Add("NombreEmpresa", NombreEmpresa)
- DicRegistrosInstrumentos.Add("TipoAsignacion", TipoAsignacion)
- DicRegistrosInstrumentos.Add("MontoInicial", MontoInicial)
- DicRegistrosInstrumentos.Add("MontoTotalUsado", MontoTotalUsado)
- DicRegistrosInstrumentos.Add("PorcentajeRestante", PorcentajeRestante)
- DicRegistrosInstrumentos.Add("PorcentajeMontoUsado", PorcentajeMontoUsado)
- DicRegistrosInstrumentos.Add("MontoDisponible", MontoDisponible)
- DicRegistrosInstrumentos.Add("MontoUsado", MontoUsado)
- DicRegistrosInstrumentos.Add("MontoTitulo", MontoTitulo)
- DicRegistrosInstrumentos.Add("MontoNoUsado", MontoNoUsado)
- DicRegistrosInstrumentos.Add("FechaCreado", FechaCreado)
- DicRegistrosInstrumentos.Add("EstadoProceso", EstadoProceso)
- DicRegistrosInstrumentos.Add("Asociado", Asociado)
- DicRegistrosInstrumentos.Add("CodigoReporto", CodigoReporto)
- DicRegistrosInstrumentos.Add("IdFlujo", IdFlujo)
- ColRegistros.Add(DicRegistrosInstrumentos)
- Index += 1
- End While
- Return ColRegistros
- End Function
- Private Sub btnGenerar_Click(sender As Object, e As EventArgs) Handles btnGenerar.Click
- Guardar()
- frmColaTitulos.Inicializacion()
- frmColaTitulos.dgvDetalles.DataSource = Nothing
- Me.Close()
- End Sub
- Private Sub btnAgregarSiguiente_Click(sender As Object, e As EventArgs) Handles btnAgregarSiguiente.Click
- Dim Estado As String = String.Empty
- AgregarSiguiente()
- CalculoSaldo()
- PorcentajeRestante()
- Limpiar()
- Controladores(3)
- End Sub
- Sub AgregarSiguiente()
- Dim Nombre As String = String.Empty
- Dim NombreInstrumento As String = String.Empty
- Dim Monto As Double = 0
- Dim SaldoDisponible As Double = 0
- Dim SaldoUsado As Double = 0
- Dim PorcentajeRestante As Double = 0
- Dim Codigo As String = Variables.Codigo
- Dim Empresa As String = Me.Empresa
- Dim NombreEmpresa As String = Me.NombreEm
- For Each Item In flpValor.Controls
- If TypeOf Item Is TextBox Then
- If Item.BackColor = Color.Brown Then
- Nombre = Item.name.ToString
- Monto = Operaciones.ConvertirDecimal(Item.text.ToString)
- SaldoDisponible = Operaciones.ConvertirDecimal(lblMontoDisponible.Text.ToString) - Monto
- SaldoUsado = Operaciones.ConvertirDecimal(lblMontoUsado.Text.ToString) + Monto
- PorcentajeRestante = (SaldoDisponible / Operaciones.ConvertirDecimal(lblMontoPorcentaje.Text.ToString)) * 100
- End If
- End If
- Next
- For Each Item In flpTitulos.Controls
- If TypeOf Item Is CheckBox Then
- If Item.checked Then
- NombreInstrumento = Item.text.ToString
- If Not String.IsNullOrEmpty(NombreInstrumento) Then
- Exit For
- End If
- End If
- End If
- Next
- If String.IsNullOrEmpty(Nombre) And String.IsNullOrEmpty(Monto.ToString) Or
- String.IsNullOrEmpty(SaldoDisponible.ToString) Or String.IsNullOrEmpty(SaldoUsado.ToString) Or
- String.IsNullOrEmpty(PorcentajeRestante.ToString) Or String.IsNullOrEmpty(Empresa.ToString) Or
- String.IsNullOrEmpty(NombreInstrumento.ToString) Or String.IsNullOrEmpty(NombreEm.ToString) Then
- MsgBox("Error en Traspaso")
- Else
- dgvDetalles.Rows.Add(Nombre, NombreInstrumento, Empresa, NombreEm, Monto.ToString, SaldoDisponible.ToString, SaldoUsado.ToString, PorcentajeRestante.ToString + " %".ToString)
- End If
- End Sub
- Private Sub btnAgregarMismoIns_Click(sender As Object, e As EventArgs)
- End Sub
- Sub Limpiar()
- For Each Item In flpValor.Controls
- If TypeOf Item Is TextBox Then
- Item.text = 0
- Item.backcolor = SystemColors.Control
- End If
- If TypeOf Item Is Label Then
- Item.text = " "
- End If
- Next
- For Each Item In flpTitulos.Controls
- If TypeOf Item Is CheckBox Then
- Item.checked = False
- End If
- Next
- End Sub
- Private Sub lblMontoUsado_Click(sender As Object, e As EventArgs) Handles lblMontoUsado.Click
- End Sub
- Sub PorcentajeRestante()
- Dim PorcentajeCompleto As Integer = 0
- Dim MontoCompleto As Double = 0
- Dim MontoUsado As Double = 0
- Dim Porcentaje As Double = 0
- MontoCompleto = Operaciones.ConvertirDecimal(lblMontoPorcentaje.Text.ToString)
- MontoUsado = Operaciones.ConvertirDecimal(lblMontoUsado.Text.ToString)
- Porcentaje = 100 - ((MontoUsado / MontoCompleto) * 100)
- lblPorcentajeRestanteValor.Text = Porcentaje.ToString + " %"
- End Sub
- Sub Controladores(ByRef PasoDatos As Integer)
- If PasoDatos = 0 Then
- btnAgregarSiguiente.Enabled = False
- pnlControladores.Enabled = False
- btnCancelar.Enabled = False
- btnAgregar.Enabled = False
- flpTitulos.Enabled = True
- ElseIf PasoDatos = 1 Then
- flpTitulos.Enabled = False
- pnlControladores.Enabled = True
- btnCancelar.Enabled = True
- ElseIf PasoDatos = 2 Then
- btnAgregarSiguiente.Enabled = True
- pnlControladores.Enabled = False
- ElseIf PasoDatos = 3 Then
- btnAgregar.Enabled = False
- flpTitulos.Enabled = True
- pnlControladores.Enabled = False
- btnCancelar.Enabled = False
- btnAgregarSiguiente.Enabled = False
- If rdbMonto.Checked Then
- txtMover.Text = "1 "
- Else
- txtMover.Text = "1 %"
- End If
- End If
- End Sub
- Private Sub txtPorcentaje_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentaje.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
- Sub Formato()
- If rdbPorcentaje.Checked Then
- Dim Porcentaje As String = txtPorcentaje.Text.Trim(" ").Trim("%")
- Dim PorcentajeNumero As Double = 0
- PorcentajeNumero = Operaciones.ConvertirDecimal(Porcentaje)
- If PorcentajeNumero = 0 Then
- PorcentajeNumero = 1
- End If
- Porcentaje = PorcentajeNumero.ToString + " %"
- txtPorcentaje.Text = Porcentaje
- End If
- End Sub
- Private Sub txtPorcentaje_Leave(sender As Object, e As EventArgs) Handles txtPorcentaje.Leave
- Formato()
- End Sub
- Private Sub rdbMonto_CheckedChanged(sender As Object, e As EventArgs) Handles rdbMonto.CheckedChanged
- CambioCalculo()
- Formato()
- End Sub
- Private Sub rdbPorcentaje_CheckedChanged(sender As Object, e As EventArgs) Handles rdbPorcentaje.CheckedChanged
- CambioCalculo()
- Formato()
- End Sub
- Sub CambioCalculo()
- If rdbPorcentaje.Checked Then
- txtPorcentaje.Text = "100 %"
- txtMover.Text = "1 %"
- Else
- txtPorcentaje.Text = "100 %"
- txtMover.Text = "1"
- End If
- End Sub
- Private Sub lblPorcentajeRestanteValor_Click(sender As Object, e As EventArgs) Handles lblPorcentajeRestanteValor.Click
- End Sub
- Private Sub txtMover_Leave(sender As Object, e As EventArgs) Handles txtMover.Leave
- If rdbPorcentaje.Checked Then
- txtMover.Text = Operaciones.ConvertirDecimal(txtMover.Text.ToString).ToString + " %"
- End If
- End Sub
- Private Sub dgvDetalles_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvDetalles.CellContentClick
- End Sub
- End Class
|