| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601 |
- Public Class frmPropuestasDeInversion
- Dim _valor
- Public Sub New(valor As String)
- _valor = valor
- End Sub
- Public Sub New()
- End Sub
- Dim oDAOGeneral As New DAOGeneral
- Dim oDAOPropuestasDeInversion As New DAOPropuestaInversion
- Dim InstrumentoFinanciero As Object
- Dim oCEAcciones As AccionesCE
- Dim oCEBonos As BonosCE
- Dim oCEDAP As DepositosAPlazoCE
- Dim oCELetes As LETESCE
- Dim oCEReportos As ReportosCE
- Dim ResultadoMsgBox As Integer
- Public Modo As String = "N"
- Dim DocId As Integer
- Private Sub frmPropuestasDeInversion_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Call CargarEstadosDocumento()
- Call CargarEmpresas()
- Call CargarInstrumentosFinancieros()
- Call CargarEmisores()
- Call CargarCalificacionDeRiesgo()
- Call CargarCalificadoraDeRiesgo()
- Call CargarOrigenDeFondos()
- If Modo = "N" Then
- ModoNuevo()
- End If
- If Modo = "B" Then
- ModoBusqueda()
- End If
- If Modo = "C" Then
- ModoConsulta()
- End If
- End Sub
- 'Activa el modo de busqueda dentro del form'
- Sub ModoBusqueda()
- Me.Modo = "B"
- LimpiarControles()
- RestablecerControles()
- DeshabilitarControles()
- Me.btnAccion.Text = "Buscar"
- End Sub
- 'Limpia la pantalla para ingresar nuevos datos'
- Sub ModoNuevo()
- Me.Modo = "N"
- LimpiarControles()
- HabilitarControles()
- Me.cboEstado.SelectedValue = "P"
- RestablecerControles()
- Me.btnAccion.Text = "Guardar"
- End Sub
- 'Establece una consulta'
- Sub ModoConsulta()
- Me.Modo = "C"
- RestablecerControles()
- Me.btnAccion.Text = "Aceptar"
- End Sub
- 'Deshabilita los controles para hacer una busqueda'
- Sub DeshabilitarControles()
- cboOrigenDeFodos.Enabled = False
- txtMontoInversion.Enabled = False
- txtPrecio.Enabled = False
- txtRendimiento.Enabled = False
- txtIngresos.Enabled = False
- txtJustificacion.Enabled = False
- txtComentarios.Enabled = False
- End Sub
- 'Regresa los controles a su estado inicial'
- Sub HabilitarControles()
- cboOrigenDeFodos.Enabled = True
- txtMontoInversion.Enabled = True
- txtPrecio.Enabled = True
- txtRendimiento.Enabled = True
- txtIngresos.Enabled = True
- txtJustificacion.Enabled = True
- txtComentarios.Enabled = True
- End Sub
- 'Restablece los controles nuevamente para su uso'
- Sub LimpiarControles()
- txtAsunto.Text = ""
- cboEmpresas.SelectedIndex = -1
- cboInstrumentosFinancieros.SelectedIndex = -1
- cboEmisores.SelectedIndex = -1
- cboCalificacionDeRiesgo.SelectedIndex = -1
- cboCalificadoraDeRiesgo.SelectedIndex = -1
- cboOrigenDeFodos.SelectedIndex = -1
- txtMontoInversion.Text = ""
- txtPrecio.Text = ""
- txtRendimiento.Text = ""
- txtIngresos.Text = ""
- txtCodigoPropuesta.Text = ""
- 'If Modo = "N" Then
- ' cboEstado.SelectedValue = "P"
- 'Else
- cboEstado.SelectedIndex = -1
- 'End If
- txtJustificacion.Text = ""
- txtComentarios.Text = ""
- End Sub
- 'Private Sub txtMontoInversion_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtMontoInversion.KeyPress
- ' If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back AndAlso e.KeyChar <> "." Then
- ' e.Handled = True
- ' End If
- 'End Sub
- 'El boton de aceptar realiza su funcion dependiendo del estado del modo'
- Private Sub btnAccion_Click(sender As Object, e As EventArgs) Handles btnAccion.Click
- 'Si el frm esta en modo busqueda'
- If Me.Modo = "B" Then
- Dim ObjCEPropuestaInversion As New CEPropuestaInversion
- ObjCEPropuestaInversion.CodigoInversion = Me.GetCodigoInversion
- ObjCEPropuestaInversion.Asunto = Me.GetAsunto
- ObjCEPropuestaInversion.CodigoEmpresa = Me.GetEmpresa
- ObjCEPropuestaInversion.CodigoInstrumentoFinanciero = Me.GetInstrumento
- ObjCEPropuestaInversion.CodigoEmisor = Me.GetEmisor
- ObjCEPropuestaInversion.CodigoCalificacionDeRiesgo = Me.GetCalificacionDeRiesgo
- ObjCEPropuestaInversion.CodigoEmpresaCalificadora = Me.GetCalificadoraDeRiesgo
- ObjCEPropuestaInversion.EstadoDocumento = Me.GetEstadoDoc
- frmBuscarDeLista.dgvBuscarDeLista.DataSource = oDAOPropuestasDeInversion.BuscarPropuestasInversion(ObjCEPropuestaInversion).Tables("Resultado")
- If frmBuscarDeLista.ShowDialog = DialogResult.OK Then
- 'Me.DocId = frmBuscarDeLista.CodigoPrincipal
- If Not frmBuscarDeLista.CodigoPrincipal = Nothing Then
- CargarRegistro(frmBuscarDeLista.CodigoPrincipal)
- End If
- End If
- End If
- 'Es el valor por defecto y sirve para agregar una nueva vista'
- If Me.Modo = "N" Then
- If ValidarControles() Then
- Dim ObjCEPropuestaInversion As New CEPropuestaInversion
- ObjCEPropuestaInversion.CodigoInversion = Me.GetCodigoInversion
- ObjCEPropuestaInversion.EstadoDocumento = Me.GetEstadoDoc
- ObjCEPropuestaInversion.Asunto = Me.GetAsunto
- ObjCEPropuestaInversion.CodigoEmpresa = Me.GetEmpresa
- ObjCEPropuestaInversion.CodigoInstrumentoFinanciero = Me.GetInstrumento
- ObjCEPropuestaInversion.CodigoEmisor = Me.GetEmisor
- ObjCEPropuestaInversion.CodigoCalificacionDeRiesgo = Me.GetCalificacionDeRiesgo
- ObjCEPropuestaInversion.CodigoEmpresaCalificadora = Me.GetCalificadoraDeRiesgo
- ObjCEPropuestaInversion.OrigenDeFondos = Me.GetOrigenDeFondos
- ObjCEPropuestaInversion.Comentarios = Me.GetComentarios
- ObjCEPropuestaInversion.Justificacion = Me.GetJustificacion
- ObjCEPropuestaInversion.TipoOperacion = Me.GetTipoOperacion
- If InstrumentoFinanciero Is Nothing Then
- ResultadoMsgBox = MessageBox.Show("No se ha ingresado detalles del Instrumento." & vbCrLf & "Desea continuar sin detalles?", "Sin Detalles", MessageBoxButtons.YesNo)
- End If
- If ResultadoMsgBox = DialogResult.Yes Then
- 'oDAOPropuestasDeInversion.NuevaPropuesta(ObjCEPropuestaInversion, InstrumentoFinanciero)
- Me.Dispose()
- End If
- Else
- MsgBox("Completar Valores")
- End If
- End If
- End Sub
- Private Sub btnNuevo_Click(sender As Object, e As EventArgs) Handles btnNuevo.Click
- ModoNuevo() 'Llama al metodo nuevo y me ingresa los datos'
- End Sub
- Private Sub btnBuscar_Click(sender As Object, e As EventArgs) Handles btnBuscar.Click
- ModoBusqueda() 'Activa el modo de busqueda'
- End Sub
- Sub CargarRegistro(IdRegistro As Integer)
- Dim ObjCEPropuestaInversion As New CEPropuestaInversion
- 'oDAOPropuestasDeInversion.CargarPropuesta(ObjCEPropuestaInversion, IdRegistro)
- Me.txtCodigoPropuesta.Text = ObjCEPropuestaInversion.CodigoInversion
- Me.cboEstado.SelectedValue = ObjCEPropuestaInversion.EstadoDocumento
- If ObjCEPropuestaInversion.TipoOperacion = "C" Then
- Me.rbtnCompra.Checked = True
- End If
- If ObjCEPropuestaInversion.TipoOperacion = "V" Then
- Me.rbtnVenta.Checked = True
- End If
- Me.txtAsunto.Text = ObjCEPropuestaInversion.Asunto
- Me.cboEmpresas.SelectedValue = ObjCEPropuestaInversion.CodigoEmpresa
- Me.cboInstrumentosFinancieros.SelectedValue = ObjCEPropuestaInversion.CodigoInstrumentoFinanciero
- Me.cboEmisores.SelectedValue = ObjCEPropuestaInversion.CodigoEmisor
- Me.cboCalificacionDeRiesgo.SelectedValue = ObjCEPropuestaInversion.CodigoCalificacionDeRiesgo
- Me.cboCalificadoraDeRiesgo.SelectedValue = ObjCEPropuestaInversion.CodigoEmpresaCalificadora
- Me.cboOrigenDeFodos.SelectedValue = ObjCEPropuestaInversion.OrigenDeFondos
- Me.txtJustificacion.Text = ObjCEPropuestaInversion.Justificacion
- Me.txtComentarios.Text = ObjCEPropuestaInversion.Comentarios
- HabilitarControles()
- ModoConsulta()
- DocId = IdRegistro
- ModoConsulta()
- End Sub
- Private Sub btnLimpiar_Click(sender As Object, e As EventArgs) Handles btnLimpiar.Click
- If Modo = "B" Then 'Si esta en modo busqueda limpia los controles'
- Me.LimpiarControles()
- End If
- End Sub
- Sub CargarEstadosDocumento()
- Me.cboEstado.DataSource = oDAOPropuestasDeInversion.ListaEstadoDocumento.Tables("EstadosDocumento")
- Me.cboEstado.DisplayMember = "Descripcion"
- Me.cboEstado.ValueMember = "Codigo"
- Me.cboEstado.SelectedIndex = -1
- End Sub
- Sub CargarEmpresas()
- Me.cboEmpresas.DataSource = oDAOGeneral.ListaEmpresas
- Me.cboEmpresas.DisplayMember = "Descripcion"
- Me.cboEmpresas.ValueMember = "Codigo"
- Me.cboEmpresas.SelectedIndex = -1
- End Sub
- Sub CargarInstrumentosFinancieros()
- Me.cboInstrumentosFinancieros.DataSource = oDAOGeneral.ListaInstrumentos("Propuesta")
- Me.cboInstrumentosFinancieros.DisplayMember = "Descripcion"
- Me.cboInstrumentosFinancieros.ValueMember = "Codigo"
- Me.cboInstrumentosFinancieros.SelectedIndex = -1
- End Sub
- Sub CargarEmisores()
- Me.cboEmisores.DataSource = oDAOGeneral.ListaEmisores
- Me.cboEmisores.DisplayMember = "Descripcion"
- Me.cboEmisores.ValueMember = "Codigo"
- Me.cboEmisores.SelectedIndex = -1
- End Sub
- Sub CargarCalificacionDeRiesgo()
- Me.cboCalificacionDeRiesgo.DataSource = oDAOGeneral.ListaCalificacionesDeRiesgo
- Me.cboCalificacionDeRiesgo.DisplayMember = "Descripcion"
- Me.cboCalificacionDeRiesgo.ValueMember = "Codigo"
- Me.cboCalificacionDeRiesgo.SelectedIndex = -1
- End Sub
- Sub CargarCalificadoraDeRiesgo()
- Me.cboCalificadoraDeRiesgo.DataSource = oDAOGeneral.ListaEmpresasCalificadoras
- Me.cboCalificadoraDeRiesgo.DisplayMember = "Descripcion"
- Me.cboCalificadoraDeRiesgo.ValueMember = "Codigo"
- Me.cboCalificadoraDeRiesgo.SelectedIndex = -1
- End Sub
- Sub CargarOrigenDeFondos()
- Me.cboOrigenDeFodos.DataSource = oDAOGeneral.ListaOrigenDeFondos
- Me.cboOrigenDeFodos.DisplayMember = "Descripcion"
- Me.cboOrigenDeFodos.ValueMember = "Codigo"
- Me.cboOrigenDeFodos.SelectedIndex = -1
- End Sub
- Function GetCodigoInversion() As String
- Return txtCodigoPropuesta.Text
- End Function
- Function GetEstadoDoc() As String
- Dim valor As String
- If cboEstado.SelectedIndex = -1 Then
- valor = ""
- Else
- valor = cboEstado.SelectedValue
- End If
- Return valor
- End Function
- 'valida si la seleccion es de compra o venta,dependiendo de lo que haya seleccionado el usuario'
- Function GetTipoOperacion() As String
- Dim valor As String = ""
- If Me.rbtnCompra.Checked Then
- valor = "C"
- End If
- If Me.rbtnVenta.Checked Then
- valor = "V"
- End If
- Return valor
- End Function
- 'Retorna el valor del texbox de los asuntos'
- Function GetAsunto() As String
- Return txtAsunto.Text
- End Function
- 'Retorna que empresa eligio el usuario'
- Function GetEmpresa() As String
- Dim valor As String
- If cboEmpresas.SelectedIndex = -1 Then
- valor = ""
- Else
- valor = cboEmpresas.SelectedValue
- End If
- Return valor
- End Function
- 'Retorna que instrumento financiero selecciono'
- Function GetInstrumento() As String
- Dim valor As String
- If cboInstrumentosFinancieros.SelectedIndex = -1 Then
- valor = ""
- Else
- valor = cboInstrumentosFinancieros.SelectedValue
- End If
- Return valor
- End Function
- 'Retorna que entidad sera la que emita'
- Function GetEmisor() As Integer
- Dim valor As Integer
- If cboEmisores.SelectedIndex = -1 Then
- valor = 0
- Else
- valor = cboEmisores.SelectedValue
- End If
- Return valor
- End Function
- 'Retorna el valor del calificador de riesgo'
- Function GetCalificacionDeRiesgo() As String
- Dim valor As String
- If cboCalificacionDeRiesgo.SelectedIndex = -1 Then
- valor = ""
- Else
- valor = cboCalificacionDeRiesgo.SelectedValue
- End If
- Return valor
- End Function
- 'Retorna el valor de quien sera la calificadora de los riesgos'
- Function GetCalificadoraDeRiesgo() As String
- Dim valor As String
- If cboCalificadoraDeRiesgo.SelectedIndex = -1 Then
- valor = ""
- Else
- valor = cboCalificadoraDeRiesgo.SelectedValue
- End If
- Return valor
- End Function
- 'Retorna el valor de los origenes de fondos'
- Function GetOrigenDeFondos() As String
- Dim valor As String
- If cboOrigenDeFodos.SelectedIndex = -1 Then
- valor = ""
- Else
- valor = cboOrigenDeFodos.SelectedValue
- End If
- Return valor
- End Function
- 'Devuelve la justificacion de la nueva propuesta de inversion'
- Function GetJustificacion() As String
- Return txtJustificacion.Text
- End Function
- 'Devuelve los comentarios extra de la nueva propuesta de inversion'
- Function GetComentarios() As String
- Return txtComentarios.Text
- End Function
- 'Reportes de crystal report'
- Private Sub btnImprimir_Click(sender As Object, e As EventArgs) Handles btnImprimir.Click
- If Not DocId = Nothing Then
- Dim Imprimir As New frmImprimir
- Imprimir.NombreRPT = "PrintPropuestaDeInversion.rpt"
- Imprimir.IdDocumento = DocId
- Imprimir.ShowDialog()
- End If
- End Sub
- 'valida los controles'
- Function ValidarControles() As Boolean
- RestablecerControles()
- Dim ControlesValidos As Boolean = True
- If GetAsunto.Length = 0 Then
- txtAsunto.BackColor = Color.FromArgb(223, 152, 152)
- ControlesValidos = False
- End If
- If GetEmpresa.Length = 0 Then
- cboEmpresas.BackColor = Color.FromArgb(223, 152, 152)
- ControlesValidos = False
- End If
- If GetInstrumento.Length = 0 Then
- cboInstrumentosFinancieros.BackColor = Color.FromArgb(223, 152, 152)
- ControlesValidos = False
- End If
- If GetEmisor() = 0 Or GetEmisor() = Nothing Then
- cboEmisores.BackColor = Color.FromArgb(223, 152, 152)
- ControlesValidos = False
- End If
- If GetCalificacionDeRiesgo.Length = 0 Then
- cboCalificacionDeRiesgo.BackColor = Color.FromArgb(223, 152, 152)
- ControlesValidos = False
- End If
- If GetCalificadoraDeRiesgo.Length = 0 Then
- cboCalificadoraDeRiesgo.BackColor = Color.FromArgb(223, 152, 152)
- ControlesValidos = False
- End If
- If GetOrigenDeFondos.Length = 0 Then
- cboOrigenDeFodos.BackColor = Color.FromArgb(223, 152, 152)
- ControlesValidos = False
- End If
- If GetCodigoInversion.Length = 0 Then
- txtCodigoPropuesta.BackColor = Color.FromArgb(223, 152, 152)
- ControlesValidos = False
- End If
- If rbtnCompra.Checked = False And rbtnVenta.Checked = False Then
- Me.gbTipoOperacion.BackColor = Color.FromArgb(223, 152, 152)
- ControlesValidos = False
- End If
- Return ControlesValidos
- End Function
- 'Restablece los colores'
- Sub RestablecerControles()
- txtAsunto.BackColor = Color.FromArgb(255, 255, 255)
- cboEmpresas.BackColor = Color.FromArgb(255, 255, 255)
- cboInstrumentosFinancieros.BackColor = Color.FromArgb(255, 255, 255)
- cboEmisores.BackColor = Color.FromArgb(255, 255, 255)
- cboCalificacionDeRiesgo.BackColor = Color.FromArgb(255, 255, 255)
- cboCalificadoraDeRiesgo.BackColor = Color.FromArgb(255, 255, 255)
- cboOrigenDeFodos.BackColor = Color.FromArgb(255, 255, 255)
- txtMontoInversion.BackColor = Color.FromArgb(255, 255, 255)
- txtPrecio.BackColor = Color.FromArgb(255, 255, 255)
- txtRendimiento.BackColor = Color.FromArgb(255, 255, 255)
- txtIngresos.BackColor = Color.FromArgb(255, 255, 255)
- txtCodigoPropuesta.BackColor = Color.FromArgb(255, 255, 255)
- Me.gbTipoOperacion.BackColor = Color.FromArgb(255, 255, 255)
- End Sub
- 'Instrumentos financieros detect cuando se ha detectado un cambio'
- Private Sub cboInstrumentosFinancieros_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboInstrumentosFinancieros.SelectedIndexChanged
- Dim vCodigoIF As String
- Dim vEmpresa As String
- Dim vCodigo As String
- Try
- vEmpresa = Me.cboEmpresas.SelectedValue.ToString
- vCodigoIF = Me.cboInstrumentosFinancieros.SelectedValue.ToString
- Catch ex As Exception
- vEmpresa = ""
- vCodigoIF = ""
- End Try
- If Modo = "N" Then
- vCodigo = SeriesDAO.SiguienteCodigoInversion(vEmpresa, vCodigoIF)
- Me.txtCodigoPropuesta.Text = vCodigo
- End If
- End Sub
- 'Boton de detalles'
- Private Sub btnDetallerIF_Click(sender As Object, e As EventArgs) Handles btnDetallerIF.Click
- If GetInstrumento() = "ACC" Then
- Dim oFormulario As New frmAcciones
- If Modo = "C" Then
- oFormulario.CargarRegistro(DocId, "P")
- oFormulario.ShowDialog()
- End If
- If Modo = "N" Then
- oFormulario.TipoTransaccion = "N"
- If oFormulario.ShowDialog = DialogResult.OK Then
- Me.oCEAcciones = New AccionesCE
- Me.oCEAcciones = oFormulario.RetornarObjeto
- InstrumentoFinanciero = Me.oCEAcciones
- oFormulario.Dispose()
- End If
- End If
- End If
- If GetInstrumento() = "LETE" Then
- Dim oFormulario As New frmLetes
- If Modo = "C" Then
- oFormulario.CargarRegistro(DocId, "P")
- oFormulario.ShowDialog()
- End If
- If Modo = "N" Then
- oFormulario.Modo = "N"
- If oFormulario.ShowDialog = DialogResult.OK Then
- Me.oCELetes = New LETESCE
- Me.oCELetes = oFormulario.RetornarObjeto
- InstrumentoFinanciero = Me.oCELetes
- oFormulario.Dispose()
- End If
- End If
- End If
- If GetInstrumento() = "DAP" Then
- Dim oFormulario As New frmDepositosAPlazo
- If Modo = "C" Then
- oFormulario.CargarRegistro(DocId, "P")
- oFormulario.ShowDialog()
- End If
- If Modo = "N" Then
- oFormulario.TipoTransaccion = "N"
- If oFormulario.ShowDialog = DialogResult.OK Then
- Me.oCEDAP = New DepositosAPlazoCE
- Me.oCEDAP = oFormulario.RetornarObjeto
- InstrumentoFinanciero = Me.oCEDAP
- oFormulario.Dispose()
- End If
- End If
- End If
- If GetInstrumento() = "REPO" Then
- Dim oFormulario As New frmReporto
- If Modo = "C" Then
- oFormulario.ShowDialog()
- End If
- If Modo = "N" Then
- oFormulario.Modo = "N"
- If oFormulario.ShowDialog = DialogResult.OK Then
- Me.oCEReportos = New ReportosCE
- InstrumentoFinanciero = oCEReportos
- oFormulario.Dispose()
- End If
- End If
- End If
- End Sub
- Private Sub cboEmpresas_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboEmpresas.SelectedIndexChanged
- End Sub
- Private Sub ToolStripLabel3_Click(sender As Object, e As EventArgs) Handles ToolStripLabel3.Click
- End Sub
- End Class
|