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