| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412 |
- Public Class frmSeleccionPoolTitulos
- Private Operaciones As New Operaciones
- Dim oDAOGeneral As New DAOGeneral
- Dim PoolTitulos As New PoolTitulosDAO
- Private Sub frmSeleccionPoolTitulos_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- CargarCodigo()
- CargarInstrumentos()
- CargarEmpresas()
- OcultarColumnas()
- End Sub
- Sub OcultarColumnas()
- dgvTitulos.Columns("IdFlujo").Visible = False
- dgvTitulos.Columns("IdEspLR").Visible = False
- dgvTitulos.Columns("CodigoInstrumento").Visible = False
- dgvTitulos.Columns("CodigoEmpresa").Visible = False
- dgvTitulos.Columns("Estado").Visible = False
- dgvPool.Columns("IdFlujo").Visible = False
- dgvPool.Columns("IdEspLR").Visible = False
- dgvPool.Columns("Instrumento").Visible = False
- dgvPool.Columns("Empresa").Visible = False
- End Sub
- Sub CargarCodigo()
- Dim CodigoAsociacion As String = String.Empty
- CodigoAsociacion = PoolTitulos.NuevoCodigo()
- txtcodigo.Text = CodigoAsociacion
- End Sub
- Sub CargarInstrumentos()
- If Me.cboInstrumentos.Items.Count = 0 Or Me.cboInstrumentos.Items.Count = 1 Then
- Me.cboInstrumentos.DataSource = oDAOGeneral.ListaInstrumentos
- Me.cboInstrumentos.DisplayMember = "Descripcion"
- Me.cboInstrumentos.ValueMember = "Codigo"
- Me.cboInstrumentos.SelectedIndex = 0
- End If
- End Sub
- Private Sub CargarEmpresas()
- Me.cboEmpresa.DataSource = oDAOGeneral.ListaEmpresas
- Me.cboEmpresa.DisplayMember = "Descripcion"
- Me.cboEmpresa.ValueMember = "Codigo"
- Me.cboEmpresa.SelectedIndex = 0
- End Sub
- Sub CargarDatosBusqueda()
- Dim ds As New DataSet
- Dim FechaOperacion1 As Date = Date.Today.Date
- Dim FechaOperacion2 As Date = Date.Today.Date
- Dim Empresa As String = ""
- Dim Instrumento As String = ""
- Dim Estado As String = ""
- If Not cboEmpresa.SelectedValue Is Nothing Then
- Empresa = cboEmpresa.SelectedValue.ToString()
- End If
- If Not cboInstrumentos.SelectedValue Is Nothing Then
- Instrumento = cboInstrumentos.SelectedValue.ToString()
- End If
- Dim TipoFecha As Integer = 0
- If rdbVigente.Checked Then
- Estado = "A"
- End If
- If rdbFecha.Checked Then
- FechaOperacion1 = Format(dtpFechaOperacion.Value, "dd/MM/yyyy")
- ElseIf rdbRangoFechas.Checked Then
- FechaOperacion1 = Format(dtpFechaOperacion1.Value, "dd/MM/yyyy")
- FechaOperacion2 = Format(dtpFechaOperacion2.Value, "dd/MM/yyyy")
- TipoFecha = 1
- Else
- TipoFecha = 2
- End If
- If TipoFecha = 0 Then
- ds = PoolTitulos.FiltroReportoVenta(FechaOperacion1, "", Estado, Empresa, Instrumento)
- ElseIf TipoFecha = 1 Then
- ds = PoolTitulos.FiltroReportoVenta(FechaOperacion1, FechaOperacion2, Estado, Empresa, Instrumento)
- Else
- ds = PoolTitulos.FiltroReportoVenta("", "", Estado, Empresa, Instrumento)
- End If
- dgvTitulos.DataSource = ds.Tables(0)
- End Sub
- Private Sub dtpFechaOperacion_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaOperacion.ValueChanged
- CargarDatosBusqueda()
- End Sub
- Private Sub dtpFechaOperacion1_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaOperacion1.ValueChanged
- CargarDatosBusqueda()
- End Sub
- Private Sub dtpFechaOperacion2_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaOperacion2.ValueChanged
- CargarDatosBusqueda()
- End Sub
- Private Sub rdbVigente_CheckedChanged(sender As Object, e As EventArgs) Handles rdbVigente.CheckedChanged
- CargarDatosBusqueda()
- End Sub
- Private Sub rdbTodosVigencia_CheckedChanged(sender As Object, e As EventArgs) Handles rdbTodosVigencia.CheckedChanged
- CargarDatosBusqueda()
- End Sub
- Private Sub cboEmpresa_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboEmpresa.SelectedIndexChanged
- dgvPool.Rows.Clear()
- CargarDatosBusqueda()
- End Sub
- Private Sub cboInstrumentos_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboInstrumentos.SelectedIndexChanged
- CargarDatosBusqueda()
- End Sub
- Sub VerDetalles()
- If MsgBox("¿Desea Ver los Detalles del Instrumento?", MsgBoxStyle.OkCancel) = DialogResult.OK Then
- If Not dgvTitulos.CurrentRow Is Nothing Then
- Dim Instrumento As String = String.Empty
- Dim codigo As String = String.Empty
- Instrumento = dgvTitulos.CurrentRow.Cells("CodigoInstrumento").Value.ToString
- codigo = dgvTitulos.CurrentRow.Cells("CodigoInversion").Value.ToString
- If Instrumento = "FINV" Then
- Variables.Codigo = codigo
- frmFOIN.ShowDialog()
- End If
- ''#########################################################################
- ''#########################################################################
- If Instrumento = "FUTU" Or Instrumento = "OPC" Then
- Variables.Codigo = codigo
- frmFuturos.ShowDialog()
- End If
- ''#########################################################################
- ''#########################################################################
- ''#########################################################################
- ''#########################################################################
- If Instrumento = "PPER" Then
- Variables.Codigo = codigo
- frmPrestamoPersonal.ShowDialog()
- End If
- ''#########################################################################
- ''#########################################################################
- ''#########################################################################
- ''#########################################################################
- If Instrumento = "PEMP" Then
- Variables.Codigo = codigo
- frmPrestamoEmpresariales.ShowDialog()
- End If
- ''#########################################################################
- ''#########################################################################
- ''#########################################################################
- ''#########################################################################
- If Instrumento = "LETE" Or Instrumento = "PBUR" Or Instrumento = "VCN" Or Instrumento = "CETE" Then
- Variables.Codigo = codigo
- frmLetes.ShowDialog()
- End If
- ''#########################################################################
- ''#########################################################################
- ''#########################################################################
- ''#########################################################################
- If Instrumento = "BONO" Or Instrumento = "CINV" Or Instrumento = "TIT" Or Instrumento = "EURB" Then
- Variables.Codigo = codigo
- frmCertificadosDeInversion.ShowDialog()
- End If
- ''#########################################################################
- ''#########################################################################
- If Instrumento = "DAP" Then
- Variables.Codigo = codigo
- frmDepositosAPlazo.Show()
- End If
- ''#########################################################################
- ''#########################################################################
- ''#########################################################################
- ''#########################################################################
- If Instrumento = "NEST" Then
- Variables.Codigo = codigo
- frmNotaEstructurada.ShowDialog()
- End If
- Else
- MsgBox("No se ha seleccionado ninguna fila")
- End If
- End If
- End Sub
- Private Sub dgvTitulos_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvTitulos.CellClick
- End Sub
- Private Sub btnVer_Click(sender As Object, e As EventArgs) Handles btnVer.Click
- VerDetalles()
- End Sub
- Sub PasarDatos()
- If txtMontoUsar.Text <= 0 Then
- MsgBox("El Monto no puede ser 0")
- Else
- Dim MontoUsado As Double = Operaciones.ConvertirDecimal(txtMontoUsar.Text.ToString)
- Dim MontoTotal As Double = Operaciones.ConvertirDecimal(dgvTitulos.CurrentRow.Cells("MontoActual").Value.ToString)
- If MontoUsado >= MontoTotal Then
- MsgBox("La Cantidad supera el monto disponible")
- txtMontoUsar.Text = MontoTotal * 0.95
- Else
- If dgvTitulos.CurrentRow Is Nothing Then
- MsgBox("No se ha seleccionado ninguna fila")
- Else
- Dim CodigoTitulo As String = String.Empty
- Dim Instrumento As String = String.Empty
- Dim Empresa As String = String.Empty
- Dim NombreInstrumento As String = String.Empty
- Dim NombreEmpresa As String = String.Empty
- Dim Porcentaje As String = "0 %"
- Dim FechaCreacion As Date = Date.Now.Date
- Dim CodigoInversion As String = String.Empty
- Dim IdFlujo As Integer = 0
- Dim IdEspLR As Integer = 0
- Dim ExisteRegistro As Boolean = False
- Dim Total As Double = 0
- CodigoTitulo = dgvTitulos.CurrentRow.Cells("CodigoInversion").Value.ToString
- Instrumento = dgvTitulos.CurrentRow.Cells("CodigoInstrumento").Value.ToString
- Empresa = dgvTitulos.CurrentRow.Cells("CodigoEmpresa").Value.ToString
- NombreEmpresa = dgvTitulos.CurrentRow.Cells("Empresa").Value.ToString
- NombreInstrumento = dgvTitulos.CurrentRow.Cells("Instrumento").Value.ToString
- Porcentaje = ((MontoUsado / MontoTotal) * 100).ToString + " %"
- IdFlujo = dgvTitulos.CurrentRow.Cells("IdFlujo").Value.ToString
- IdEspLR = dgvTitulos.CurrentRow.Cells("IdEspLR").Value.ToString
- For Each Rows As DataGridViewRow In dgvPool.Rows
- If Rows.Cells("CodigoTitulo").Value.ToString = CodigoTitulo Then
- ExisteRegistro = True
- End If
- Next
- If ExisteRegistro Then
- MsgBox("El Registro ya esta se esta usando")
- Else
- dgvPool.Rows.Add(CodigoTitulo, Instrumento, NombreInstrumento, Empresa, NombreEmpresa, MontoTotal, MontoUsado, Porcentaje, Format(FechaCreacion, "dd/MM/yyyy").ToString, IdFlujo, IdEspLR)
- End If
- End If
- End If
- End If
- End Sub
- Private Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles btnAgregar.Click
- PasarDatos()
- End Sub
- Sub Guardar()
- If dgvPool.Rows.Count = 0 Then
- MsgBox("No se ha ingresado ninguna fila")
- Else
- Dim Valores As New Collection
- Valores = GuardarValores()
- PoolTitulos.ProcesoDatos(Valores)
- End If
- End Sub
- Function GuardarValores() As Collection
- Dim ColRegistros As New Collection
- Dim Tipo As String = String.Empty
- Dim CantidadFilas = dgvPool.Rows.Count - 1
- Dim Index As Integer = 0
- While (CantidadFilas >= Index)
- Dim DicRegistrosInstrumentos As New Dictionary(Of String, Object)
- Dim CodigoTitulo As String = dgvPool.Rows(Index).Cells("CodigoTitulo").Value.ToString
- Dim Instrumento As String = dgvPool.Rows(Index).Cells("Instrumento").Value.ToString
- Dim Empresa As String = dgvPool.Rows(Index).Cells("Empresa").Value.ToString
- Dim MontoTotal As Double = Operaciones.ConvertirDecimal(dgvPool.Rows(Index).Cells("MontoTotal").Value.ToString)
- Dim MontoUsado As Double = Operaciones.ConvertirDecimal(dgvPool.Rows(Index).Cells("MontoUsado").Value.ToString)
- Dim Porcentaje As Double = Operaciones.ConvertirDecimal(dgvPool.Rows(Index).Cells("Porcentaje").Value.ToString)
- Dim FechaCreacion As Date = Operaciones.ConvertirFecha(dgvPool.Rows(Index).Cells("FechaCreacion").Value.ToString)
- Dim Asociado As String = "No"
- Dim CodigoAsociacion As String = txtcodigo.Text.ToString
- Dim IdFlujo As Integer = Operaciones.ConvertirEntero(dgvPool.Rows(Index).Cells("IdFlujo").Value.ToString)
- Dim IdEspLR As Integer = Operaciones.ConvertirEntero(dgvPool.Rows(Index).Cells("IdEspLR").Value.ToString)
- ''AgregarCampos al Dicionario
- DicRegistrosInstrumentos.Add("CodigoTitulo", CodigoTitulo)
- DicRegistrosInstrumentos.Add("CodigoAsociacion", CodigoAsociacion)
- DicRegistrosInstrumentos.Add("Instrumento", Instrumento)
- DicRegistrosInstrumentos.Add("Empresa", Empresa)
- DicRegistrosInstrumentos.Add("MontoTotal", MontoTotal)
- DicRegistrosInstrumentos.Add("MontoUsado", MontoUsado)
- DicRegistrosInstrumentos.Add("Porcentaje", Porcentaje / 100)
- DicRegistrosInstrumentos.Add("FechaCreacion", FechaCreacion)
- DicRegistrosInstrumentos.Add("Asociado", Asociado)
- DicRegistrosInstrumentos.Add("IdFlujo", IdFlujo)
- DicRegistrosInstrumentos.Add("IdEspLR", IdEspLR)
- ColRegistros.Add(DicRegistrosInstrumentos)
- Index += 1
- End While
- Return ColRegistros
- End Function
- Private Sub btnGenerarPool_Click(sender As Object, e As EventArgs) Handles btnGenerarPool.Click
- Guardar()
- frmColaTitulos.Inicializacion()
- frmColaTitulos.dgvDetalles.DataSource = Nothing
- Me.Close()
- End Sub
- Private Sub dgvTitulos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvTitulos.CellContentClick
- End Sub
- Private Sub txtPorcentaje_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtMontoUsar.KeyPress
- If String.IsNullOrEmpty(txtMontoUsar.Text) Then
- If e.KeyChar = "." Then
- txtMontoUsar.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtMontoUsar.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 txtPorcentaje_KeyUp(sender As Object, e As KeyEventArgs) Handles txtMontoUsar.KeyUp
- If txtMontoUsar.Text = "." Then
- txtMontoUsar.Text = ".0"
- End If
- End Sub
- Private Sub txtPorcentaje_Leave(sender As Object, e As EventArgs) Handles txtMontoUsar.Leave
- End Sub
- Private Sub txtPorcentaje_TextChanged(sender As Object, e As EventArgs) Handles txtMontoUsar.TextChanged
- End Sub
- Private Sub txtcodigo_TextChanged(sender As Object, e As EventArgs) Handles txtcodigo.TextChanged
- End Sub
- Private Sub btnLimpiar_Click(sender As Object, e As EventArgs) Handles btnLimpiar.Click
- txtMontoUsar.Text = 0
- dgvPool.Rows.Clear()
- End Sub
- End Class
|