Public Class frmFuturos Dim Estado As String = String.Empty Dim FuturosConsulta As New FuturosDAO Dim General As New DAOGeneral Dim InstrumentoFinanciero As String = General.ObtenerInstrumento(Variables.Codigo) Dim CambiarOperacionApoyo As Boolean = False Dim Numero As Integer = -1 Dim Operaciones As New Operaciones Private TipoOperacion As String = String.Empty 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(TipOper As String) Me.New TipoOperacion = TipOper End Sub Private Sub btnAceptar_Click(sender As Object, e As EventArgs) End Sub Private Sub frmFuturos_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim VExisteInversion As Boolean = False If Variables.TipoOperacionCMVTA = "C" Then GrpVenta.Enabled = False GrpCompra.Enabled = True Else GrpVenta.Enabled = True GrpCompra.Enabled = False End If If Variables.Codigo.IndexOf("OPC") > -1 Then lblTitulo.Text = "Opciones" InstrumentoFinanciero = "OPC" ElseIf Variables.Codigo.IndexOf("FUTU") > -1 Then InstrumentoFinanciero = "FUTU" End If CargarDatos() VExisteInversion = ExisteInversion() ValidarExistencia() RellenarDatos() ConfiguracionCMVTA(VExisteInversion) End Sub Sub ConfiguracionCMVTA(ByRef VExisteInversion As Boolean) Dim Codigo As String = Variables.Codigo Dim ExisteCMVTA As Boolean = General.ExisteCMVTA(Codigo) If Not ExisteCMVTA And Variables.InvocadorProInv = "frmINV" Then btnVenderTitulo.Visible = True End If If CantFormAbierto = False And Not VExisteInversion Then If Not Variables.TrasladarCMVTA Is Nothing Then txtCantidadContratosCompra.Text = Operaciones.ConvertirEntero(Variables.TrasladarCMVTA.CantidadContratosFUTU.ToString) txtComisionBrokerCompra.Text = Operaciones.ConvertirDecimal(Variables.TrasladarCMVTA.ComisionBrokerFUTU.ToString) dtpLiquidacionCompra.Value = Operaciones.ConvertirFecha(Variables.TrasladarCMVTA.FechaLiquidacionFUTU.ToString) dtpOperacionCompra.Value = Operaciones.ConvertirFecha(Variables.TrasladarCMVTA.FechaOperacionFUTU.ToString) dtpVencimientoCompra.Value = Operaciones.ConvertirFecha(Variables.TrasladarCMVTA.FechaVencimientoFUTU.ToString) txtIdentificacionContratoCompra.Text = Variables.TrasladarCMVTA.IdContratoFUTU txtValorUnidadCompra.Text = Operaciones.ConvertirDecimal(Variables.TrasladarCMVTA.PrecioUnitarioFUTU.ToString) txtUnidadesContratoCompra.Text = Operaciones.ConvertirEntero(Variables.TrasladarCMVTA.UnidadesPorContratoFUTU.ToString) End If 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 ValidarExistencia() Dim General As New DAOGeneral Dim Codigo As String = Variables.Codigo Dim Tabla As String = String.Empty If (InstrumentoFinanciero = "FUTU") Then Tabla = "FUT0" ElseIf (InstrumentoFinanciero = "OPC") Then Tabla = "OPC0" End If 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 Estado = String.Empty btnAceptar.Text = "Aceptar" End Sub Function ExisteValidacion() Dim General As New DAOGeneral Dim Codigo As String = Variables.Codigo Dim Tabla As String = String.Empty If (InstrumentoFinanciero = "FUTU") Then Tabla = "FUT0" ElseIf (InstrumentoFinanciero = "OPC") Then Tabla = "OPC0" End If Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla) Return Existe End Function Sub CambiarPosicion() If (CambiarOperacionApoyo) Then Dim NuevaPosicionCompraH, NuevaPosicionVentaH, NuevaPosicionCompraV, NuevaPosicionVentaV NuevaPosicionCompraH = GrpCompra.Left NuevaPosicionCompraV = GrpCompra.Top NuevaPosicionVentaH = GrpVenta.Left NuevaPosicionVentaV = GrpVenta.Top GrpVenta.Left = NuevaPosicionCompraH GrpVenta.Top = NuevaPosicionCompraV GrpCompra.Left = NuevaPosicionVentaH GrpCompra.Top = NuevaPosicionVentaV CambiarOperacionApoyo = False Calculos() End If End Sub Sub Calculos() Dim CantContCompra, UnidadContratoCompra, ValorUnidadCompra, ComisionBrokerCompra As Double Dim CantContVenta, UnidadContratoVenta, ValorUnidadVenta, ComisionBrokerVenta As Double CantContCompra = Operaciones.ConvertirEntero(txtCantidadContratosCompra.Text.ToString) UnidadContratoCompra = Operaciones.ConvertirDecimal(txtUnidadesContratoCompra.Text.ToString) ValorUnidadCompra = Operaciones.ConvertirDecimal(txtValorUnidadCompra.Text.ToString) ComisionBrokerCompra = Operaciones.ConvertirDecimal(txtComisionBrokerCompra.Text.ToString) CantContVenta = Operaciones.ConvertirEntero(txtCantidadContratosVenta.Text.ToString) UnidadContratoVenta = Operaciones.ConvertirDecimal(txtUnidadesContratoVenta.Text.ToString) ValorUnidadVenta = Operaciones.ConvertirDecimal(txtValorUnidadVenta.Text.ToString) ComisionBrokerVenta = Operaciones.ConvertirDecimal(txtComisionBrokerVenta.Text.ToString) Dim ValorTransadoCompra = ValorTransado(CantContCompra, UnidadContratoCompra, ValorUnidadCompra) Dim ValorTransadoVenta = ValorTransado(CantContVenta, UnidadContratoVenta, ValorUnidadVenta) Dim ValorRecibidoCompra = ValorRecibido(ValorTransadoCompra, ComisionBrokerCompra) Dim ValorRecibidoVenta = ValorPagado(ValorTransadoVenta, ComisionBrokerVenta) txtValorTransadoCompra.Text = Operaciones.ConvertirDecimal(ValorTransadoCompra.ToString) txtValorTransadoVenta.Text = Operaciones.ConvertirDecimal(ValorTransadoVenta.ToString) txtValorRecibidoCompra.Text = Operaciones.ConvertirDecimal(ValorRecibidoCompra.ToString) txtValorRecibidoVenta.Text = Operaciones.ConvertirDecimal(ValorRecibidoVenta.ToString) If (cboOperacionVenta.SelectedIndex = 0) Then Dim GananciaPerdida = Format(Me.GananciaPerdida(txtValorRecibidoVenta.Text, txtValorRecibidoCompra.Text), "0.0000") txtGananciaPerdida.Text = Operaciones.ConvertirDecimal(GananciaPerdida.ToString) ElseIf (cboOperacionVenta.SelectedIndex = 1) Then Dim GananciaPerdida = Format(Me.GananciaPerdida(txtValorRecibidoCompra.Text, txtValorRecibidoVenta.Text), "0.0000") txtGananciaPerdida.Text = Operaciones.ConvertirDecimal(GananciaPerdida.ToString) Else txtGananciaPerdida.Text = "0.0" End If Dim Dias = DiasFechas(dtpLiquidacionCompra.Value, dtpLiquidacionVenta.Value) Dim Rendimientos = Format((Rendimiento(txtGananciaPerdida.Text, txtValorRecibidoVenta.Text, Dias) * 100), "0.0000") txtRendimiento.Text = Operaciones.ConvertirDecimal(Rendimientos.ToString).ToString + "%" End Sub Function ValorTransado(ByVal CantidadContratos As Double, ByVal UnidadesContrato As Double, ByVal ValorUnidad As Double) Dim ValorTrans As Double = 0 ValorTrans = Operaciones.ConvertirEntero(CantidadContratos.ToString) * Operaciones.ConvertirDecimal(UnidadesContrato.ToString) * Operaciones.ConvertirDecimal(ValorUnidad.ToString) Return ValorTrans End Function Function ValorRecibido(ByVal ValorTransado As Double, ByVal ComisionBroker As Double) Dim ValorRec As Double = 0 ValorRec = ValorTransado + ComisionBroker Return ValorRec End Function Function ValorPagado(ByVal ValorTransado As Double, ByVal ComisionBroker As Double) Dim ValorRec As Double = 0 ValorRec = ValorTransado - ComisionBroker Return ValorRec End Function Function GananciaPerdida(ByVal ValorTraCompra As Double, ByVal ValorPagado As Double) Dim Valor As Double Valor = ValorTraCompra - ValorPagado Return Valor End Function Function Rendimiento(ByVal GananciaPerdida As Double, ByVal ValorRecibidoVenta As Double, ByVal Dias As Double) Dim Valor As Double If (ValorRecibidoVenta = 0 Or Dias = 0) Then Valor = 0 Else Valor = GananciaPerdida / ValorRecibidoVenta * 365 / Dias End If Return Valor End Function Function DiasFechas(ByVal FechaLiC As Date, ByVal FechaLiV As Date) Dim Dias As Integer Dias = DateDiff(DateInterval.Day, FechaLiV, FechaLiC) Return Dias End Function Private Sub txtCantidadContratosCompra_TextChanged(sender As Object, e As EventArgs) Handles txtCantidadContratosCompra.TextChanged CopiarDatosAVenta() Calculos() End Sub Private Sub txtCantidadContratosVenta_TextChanged(sender As Object, e As EventArgs) Handles txtCantidadContratosVenta.TextChanged CopiarDatosACompra() Calculos() End Sub Private Sub txtUnidadesContratoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtUnidadesContratoCompra.TextChanged CopiarDatosAVenta() Calculos() End Sub Private Sub txtUnidadesContratoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtUnidadesContratoVenta.TextChanged CopiarDatosACompra() Calculos() End Sub Private Sub txtValorUnidadCompra_TextChanged(sender As Object, e As EventArgs) Handles txtValorUnidadCompra.TextChanged Calculos() End Sub Private Sub txtValorUnidadVenta_TextChanged(sender As Object, e As EventArgs) Handles txtValorUnidadVenta.TextChanged Calculos() End Sub Private Sub txtComisionBrokerCompra_TextChanged(sender As Object, e As EventArgs) Handles txtComisionBrokerCompra.TextChanged Calculos() End Sub Private Sub txtComisionBrokerVenta_TextChanged(sender As Object, e As EventArgs) Handles txtComisionBrokerVenta.TextChanged Calculos() End Sub Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click btnAceptar.Text = "Modificar" Estado = "M" End Sub Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click btnAceptar.Text = "Nuevo" Estado = "N" End Sub Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click btnAceptar.Text = "Eliminar" Estado = "B" End Sub Function ColeccionDatos() Dim coleccion As New Collection Dim FOperC, FLiqC, FVenC, VaUnidadC, ValorTransadoC, CoBrokerC, VaRecC, IdContratoC, CantidadContC, UnidadesContC Dim FOperV, FLiqV, FVenV, VaUnidadV, ValorTransadoV, CoBrokerV, VaRecV, IdContratoV, CantidadContV, UnidadesContV Dim TipoOperacion As String = "Corto" If (cboOperacionVenta.SelectedIndex = 1) Then TipoOperacion = "Largo" End If Dim GananciaPerdida, Rendimiento FOperC = dtpOperacionCompra.Value FLiqC = dtpLiquidacionCompra.Value FVenC = dtpVencimientoCompra.Value VaUnidadC = txtValorUnidadCompra.Text ValorTransadoC = txtValorTransadoCompra.Text CoBrokerC = txtComisionBrokerCompra.Text VaRecC = txtValorRecibidoCompra.Text IdContratoC = txtIdentificacionContratoCompra.Text CantidadContC = txtCantidadContratosCompra.Text UnidadesContC = txtUnidadesContratoCompra.Text FOperV = dtpOperacionVenta.Value FLiqV = dtpLiquidacionVenta.Value FVenV = dtpVencimientoVenta.Value VaUnidadV = txtValorUnidadVenta.Text ValorTransadoV = txtValorTransadoVenta.Text CoBrokerV = txtComisionBrokerVenta.Text VaRecV = txtValorRecibidoVenta.Text IdContratoV = txtIdentificacionContratoVenta.Text CantidadContV = txtCantidadContratosVenta.Text UnidadesContV = txtUnidadesContratoVenta.Text GananciaPerdida = txtGananciaPerdida.Text Rendimiento = txtRendimiento.Text.Trim("%") / 100 coleccion.Add(FOperC) coleccion.Add(FLiqC) coleccion.Add(FVenC) coleccion.Add(VaUnidadC) coleccion.Add(ValorTransadoC) coleccion.Add(CoBrokerC) coleccion.Add(VaRecC) coleccion.Add(IdContratoC) coleccion.Add(CantidadContC) coleccion.Add(UnidadesContC) coleccion.Add(FOperV) coleccion.Add(FLiqV) coleccion.Add(FVenV) coleccion.Add(VaUnidadV) coleccion.Add(ValorTransadoV) coleccion.Add(CoBrokerV) coleccion.Add(VaRecV) coleccion.Add(IdContratoV) coleccion.Add(CantidadContV) coleccion.Add(UnidadesContV) coleccion.Add(GananciaPerdida) coleccion.Add(Rendimiento) coleccion.Add(TipoOperacion) Return coleccion End Function Sub RellenarDatos() If (cboOperacionVenta.SelectedIndex = -1) Then cboOperacionVenta.SelectedIndex = 1 End If If (String.IsNullOrEmpty(txtValorUnidadCompra.Text.ToString)) Then txtValorUnidadCompra.Text = "0.0" End If If (String.IsNullOrEmpty(txtValorTransadoCompra.Text.ToString)) Then txtValorTransadoCompra.Text = "0.0" End If If (String.IsNullOrEmpty(txtComisionBrokerCompra.Text.ToString)) Then txtComisionBrokerCompra.Text = "0.0" End If If (String.IsNullOrEmpty(txtValorRecibidoCompra.Text.ToString)) Then txtValorRecibidoCompra.Text = "0.0" End If If (String.IsNullOrEmpty(txtIdentificacionContratoCompra.Text.ToString)) Then txtIdentificacionContratoCompra.Text = " " End If If (String.IsNullOrEmpty(txtCantidadContratosCompra.Text.ToString)) Then txtCantidadContratosCompra.Text = "0.0" End If If (String.IsNullOrEmpty(txtUnidadesContratoCompra.Text.ToString)) Then txtUnidadesContratoCompra.Text = "0.0" End If If (String.IsNullOrEmpty(txtValorUnidadVenta.Text.ToString)) Then txtValorUnidadVenta.Text = "0.0" End If If (String.IsNullOrEmpty(txtValorTransadoVenta.Text.ToString)) Then txtValorTransadoVenta.Text = "0.0" End If If (String.IsNullOrEmpty(txtComisionBrokerVenta.Text.ToString)) Then txtComisionBrokerVenta.Text = "0.0" End If If (String.IsNullOrEmpty(txtValorRecibidoVenta.Text.ToString)) Then txtValorRecibidoVenta.Text = "0.0" End If If (String.IsNullOrEmpty(txtIdentificacionContratoVenta.Text.ToString)) Then txtIdentificacionContratoVenta.Text = " " End If If (String.IsNullOrEmpty(txtCantidadContratosVenta.Text.ToString)) Then txtCantidadContratosVenta.Text = "0.0" End If If (String.IsNullOrEmpty(txtUnidadesContratoVenta.Text.ToString)) Then txtUnidadesContratoVenta.Text = "0.0" End If If (String.IsNullOrEmpty(txtGananciaPerdida.Text.ToString)) Then txtGananciaPerdida.Text = "0.0" End If If (String.IsNullOrEmpty(txtRendimiento.Text.Trim("%").ToString)) Then txtRendimiento.Text = "0.0%" End If End Sub Sub CargarDatos() Dim codigo = Variables.Codigo Dim coleccion As New Collection If (InstrumentoFinanciero = "FUTU") Then coleccion = FuturosConsulta.CargarDatos(codigo) ElseIf (InstrumentoFinanciero = "OPC") Then coleccion = FuturosConsulta.CargarDatosOpciones(codigo) End If If (Not coleccion.Count = 1) Then If (InstrumentoFinanciero = "FUTU" Or InstrumentoFinanciero = "OPC") Then dtpOperacionCompra.Value = Operaciones.ConvertirFecha(coleccion(1).ToString) dtpLiquidacionCompra.Value = Operaciones.ConvertirFecha(coleccion(2).ToString) dtpVencimientoCompra.Value = Operaciones.ConvertirFecha(coleccion(3).ToString) txtValorUnidadCompra.Text = Operaciones.ConvertirDecimal(coleccion(4).ToString) txtValorTransadoCompra.Text = Operaciones.ConvertirDecimal(coleccion(5).ToString) txtComisionBrokerCompra.Text = Operaciones.ConvertirDecimal(coleccion(6).ToString) txtValorRecibidoCompra.Text = Operaciones.ConvertirDecimal(coleccion(7).ToString) txtIdentificacionContratoCompra.Text = coleccion(8).ToString txtCantidadContratosCompra.Text = Operaciones.ConvertirEntero(coleccion(9).ToString) txtUnidadesContratoCompra.Text = Operaciones.ConvertirDecimal(coleccion(10).ToString) dtpOperacionVenta.Value = Operaciones.ConvertirFecha(coleccion(11).ToString) dtpLiquidacionVenta.Value = Operaciones.ConvertirFecha(coleccion(12).ToString) dtpVencimientoVenta.Value = Operaciones.ConvertirFecha(coleccion(13).ToString) txtValorUnidadVenta.Text = Operaciones.ConvertirDecimal(coleccion(14).ToString) txtValorTransadoVenta.Text = Operaciones.ConvertirDecimal(coleccion(15).ToString) txtComisionBrokerVenta.Text = Operaciones.ConvertirDecimal(coleccion(16).ToString) txtValorRecibidoVenta.Text = Operaciones.ConvertirDecimal(coleccion(17).ToString) txtIdentificacionContratoVenta.Text = coleccion(18).ToString txtCantidadContratosVenta.Text = Operaciones.ConvertirEntero(coleccion(19).ToString) txtUnidadesContratoVenta.Text = Operaciones.ConvertirDecimal(coleccion(20).ToString) txtGananciaPerdida.Text = Operaciones.ConvertirDecimal(coleccion(21).ToString) txtRendimiento.Text = Operaciones.ConvertirDecimal(coleccion(22).ToString) If (coleccion(23).ToString = "Corto") Then cboOperacionVenta.SelectedIndex = 0 ElseIf (coleccion(23).ToString = "Largo") Then cboOperacionVenta.SelectedIndex = 1 End If End If End If End Sub Sub Nuevo() Dim codigo = Variables.Codigo Dim Coleccion = ColeccionDatos() FuturosConsulta.Nuevo(codigo, Coleccion) End Sub Sub NuevoOpciones() Dim codigo = Variables.Codigo Dim Coleccion = ColeccionDatos() FuturosConsulta.NuevoOpciones(codigo, Coleccion) End Sub Sub Modificar() Dim codigo = Variables.Codigo Dim Coleccion = ColeccionDatos() FuturosConsulta.Modificar(codigo, Coleccion) End Sub Sub ModificarOpciones() Dim codigo = Variables.Codigo Dim Coleccion = ColeccionDatos() FuturosConsulta.ModificarOpciones(codigo, Coleccion) End Sub Sub Eliminar() Dim codigo = Variables.Codigo FuturosConsulta.Eliminar(codigo) End Sub Sub EliminarOpciones() Dim codigo = Variables.Codigo FuturosConsulta.EliminarOpciones(codigo) End Sub Private Sub btnAceptar_Click_1(sender As Object, e As EventArgs) Handles btnAceptar.Click Dim Instrumento As String = Variables.Codigo If Instrumento.IndexOf("FUTU") > -1 Then If (Estado = "N") Then Nuevo() ElseIf (Estado = "M") Then Modificar() ElseIf (Estado = "B") Then Eliminar() ElseIf Not ExisteValidacion() Then Variables.ColeccionFUTU = ColeccionDatos() Me.Close() End If End If If Instrumento.IndexOf("OPC") > -1 Then If (Estado = "N") Then NuevoOpciones() ElseIf (Estado = "M") Then ModificarOpciones() ElseIf (Estado = "B") Then EliminarOpciones() ElseIf Not ExisteValidacion() Then Variables.ColeccionFUTU = ColeccionDatos() Me.Close() End If End If ValidarExistencia() End Sub Private Sub dtpLiquidacionCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpLiquidacionCompra.ValueChanged Calculos() RellenarDatos() End Sub Private Sub dtpLiquidacionVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpLiquidacionVenta.ValueChanged RellenarDatos() Calculos() End Sub Private Sub txtGananciaPerdida_TextChanged(sender As Object, e As EventArgs) Handles txtGananciaPerdida.TextChanged Calculos() End Sub Private Sub txtRendimiento_TextChanged(sender As Object, e As EventArgs) Handles txtRendimiento.TextChanged Calculos() End Sub Private Sub BindingNavigator1_RefreshItems(sender As Object, e As EventArgs) Handles BindingNavigator1.RefreshItems End Sub Private Sub cboOperacionVenta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboOperacionVenta.SelectedIndexChanged If (Not Numero = cboOperacionVenta.SelectedIndex) Then CambiarOperacionApoyo = True Numero = cboOperacionVenta.SelectedIndex End If CambiarPosicion() End Sub Private Sub txtValorUnidadCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtValorUnidadCompra.KeyPress If String.IsNullOrEmpty(txtValorUnidadCompra.Text) Then If e.KeyChar = "." Then txtValorUnidadCompra.Text = "0" Exit Sub End If End If If (Not txtValorUnidadCompra.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 txtValorUnidadVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtValorUnidadVenta.KeyPress If String.IsNullOrEmpty(txtValorUnidadVenta.Text) Then If e.KeyChar = "." Then txtValorUnidadVenta.Text = "0" Exit Sub End If End If If (Not txtValorUnidadVenta.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 txtComisionBrokerCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionBrokerCompra.KeyPress If String.IsNullOrEmpty(txtComisionBrokerCompra.Text) Then If e.KeyChar = "." Then txtComisionBrokerCompra.Text = "0" Exit Sub End If End If If (Not txtComisionBrokerCompra.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 txtComisionBrokerVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionBrokerVenta.KeyPress If String.IsNullOrEmpty(txtComisionBrokerVenta.Text) Then If e.KeyChar = "." Then txtComisionBrokerVenta.Text = "0" Exit Sub End If End If If (Not txtComisionBrokerVenta.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 txtIdentificacionContratoCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtIdentificacionContratoCompra.KeyPress End Sub Private Sub txtIdentificacionContratoVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtIdentificacionContratoVenta.KeyPress End Sub Private Sub txtCantidadContratosCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtCantidadContratosCompra.KeyPress If String.IsNullOrEmpty(txtCantidadContratosCompra.Text) Then If e.KeyChar = "." Then txtCantidadContratosCompra.Text = "0" Exit Sub End If End If If (Not txtCantidadContratosCompra.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 txtCantidadContratosVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtCantidadContratosVenta.KeyPress If String.IsNullOrEmpty(txtCantidadContratosVenta.Text) Then If e.KeyChar = "." Then txtCantidadContratosVenta.Text = "0" Exit Sub End If End If If (Not txtCantidadContratosVenta.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 txtUnidadesContratoCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtUnidadesContratoCompra.KeyPress If String.IsNullOrEmpty(txtUnidadesContratoCompra.Text) Then If e.KeyChar = "." Then txtUnidadesContratoCompra.Text = "0" Exit Sub End If End If If (Not txtUnidadesContratoCompra.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 txtUnidadesContratoVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtUnidadesContratoVenta.KeyPress If String.IsNullOrEmpty(txtUnidadesContratoVenta.Text) Then If e.KeyChar = "." Then txtUnidadesContratoVenta.Text = "0" Exit Sub End If End If If (Not txtUnidadesContratoVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then Operaciones.ValidarEntrada(sender, e, True) Else Operaciones.ValidarEntrada(sender, e, False) End If End Sub Sub CopiarDatosACompra() If (cboOperacionVenta.SelectedIndex = 0) Then txtCantidadContratosCompra.Text = txtCantidadContratosVenta.Text txtUnidadesContratoCompra.Text = txtUnidadesContratoVenta.Text End If End Sub Sub CopiarDatosAVenta() If (cboOperacionVenta.SelectedIndex = 1) Then txtCantidadContratosVenta.Text = txtCantidadContratosCompra.Text txtUnidadesContratoVenta.Text = txtUnidadesContratoCompra.Text End If End Sub Private Sub txtIdentificacionContratoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtIdentificacionContratoCompra.TextChanged End Sub Private Sub dtpOperacionCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpOperacionCompra.ValueChanged RellenarDatos() End Sub Private Sub dtpVencimientoCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpVencimientoCompra.ValueChanged RellenarDatos() End Sub Private Sub txtValorUnidadCompra_Leave(sender As Object, e As EventArgs) Handles txtValorUnidadCompra.Leave RellenarDatos() End Sub Private Sub txtComisionBrokerCompra_Leave(sender As Object, e As EventArgs) Handles txtComisionBrokerCompra.Leave RellenarDatos() End Sub Private Sub txtIdentificacionContratoCompra_Leave(sender As Object, e As EventArgs) Handles txtIdentificacionContratoCompra.Leave RellenarDatos() End Sub Private Sub txtCantidadContratosCompra_Leave(sender As Object, e As EventArgs) Handles txtCantidadContratosCompra.Leave RellenarDatos() End Sub Private Sub txtUnidadesContratoCompra_Leave(sender As Object, e As EventArgs) Handles txtUnidadesContratoCompra.Leave RellenarDatos() End Sub Private Sub dtpOperacionVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpOperacionVenta.ValueChanged RellenarDatos() End Sub Private Sub dtpVencimientoVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpVencimientoVenta.ValueChanged RellenarDatos() End Sub Private Sub txtValorUnidadVenta_Leave(sender As Object, e As EventArgs) Handles txtValorUnidadVenta.Leave RellenarDatos() End Sub Private Sub txtComisionBrokerVenta_Leave(sender As Object, e As EventArgs) Handles txtComisionBrokerVenta.Leave RellenarDatos() End Sub Private Sub txtIdentificacionContratoVenta_Leave(sender As Object, e As EventArgs) Handles txtIdentificacionContratoVenta.Leave RellenarDatos() End Sub Private Sub txtCantidadContratosVenta_Leave(sender As Object, e As EventArgs) Handles txtCantidadContratosVenta.Leave RellenarDatos() End Sub Private Sub txtUnidadesContratoVenta_Leave(sender As Object, e As EventArgs) Handles txtUnidadesContratoVenta.Leave RellenarDatos() End Sub Private Sub txtValorUnidadCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtValorUnidadCompra.KeyUp If txtValorUnidadCompra.Text = "." Then txtValorUnidadCompra.Text = ".0" End If End Sub Private Sub txtComisionBrokerCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionBrokerCompra.KeyUp If txtComisionBrokerCompra.Text = "." Then txtComisionBrokerCompra.Text = ".0" End If End Sub Private Sub txtCantidadContratosCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtCantidadContratosCompra.KeyUp If txtCantidadContratosCompra.Text = "." Then txtCantidadContratosCompra.Text = ".0" End If End Sub Private Sub txtUnidadesContratoCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtUnidadesContratoCompra.KeyUp If txtUnidadesContratoCompra.Text = "." Then txtUnidadesContratoCompra.Text = ".0" End If End Sub Private Sub txtValorUnidadVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtValorUnidadVenta.KeyUp If txtValorUnidadVenta.Text = "." Then txtValorUnidadVenta.Text = ".0" End If End Sub Private Sub txtComisionBrokerVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionBrokerVenta.KeyUp If txtComisionBrokerVenta.Text = "." Then txtComisionBrokerVenta.Text = ".0" End If End Sub Private Sub txtIdentificacionContratoVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtIdentificacionContratoVenta.KeyUp End Sub Private Sub txtCantidadContratosVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtCantidadContratosVenta.KeyUp If txtCantidadContratosVenta.Text = "." Then txtCantidadContratosVenta.Text = ".0" End If End Sub Private Sub txtUnidadesContratoVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtUnidadesContratoVenta.KeyUp If txtUnidadesContratoVenta.Text = "." Then txtUnidadesContratoVenta.Text = ".0" End If End Sub Private Sub btnVenderTitulo_Click(sender As Object, e As EventArgs) Handles btnVenderTitulo.Click If Variables.InvocadorProInv = "frmINV" Then Dim TrasladarDatos As New TrasladarDatosCMVTA Dim General As New DAOGeneral Dim Codigo = Variables.Codigo Dim Tabla As String = "INV0" TrasladarDatos = RellenarDatosCMVTA() Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla) If Existe Then Dim CodigoInversion As String = Variables.Codigo Dim frmPINVCMVTA As New frmPIN("V", CodigoInversion, TrasladarDatos) frmINV.Close() Me.Close() frmPINVCMVTA.ShowDialog() End If End If End Sub Function RellenarDatosCMVTA() Dim TrasladarDatos As New TrasladarDatosCMVTA TrasladarDatos.CantidadContratosFUTU = Operaciones.ConvertirEntero(txtCantidadContratosCompra.Text.ToString) TrasladarDatos.ComisionBrokerFUTU = Operaciones.ConvertirDecimal(txtComisionBrokerCompra.Text.ToString) TrasladarDatos.FechaLiquidacionFUTU = Operaciones.ConvertirFecha(dtpLiquidacionCompra.Value.ToString) TrasladarDatos.FechaOperacionFUTU = Operaciones.ConvertirFecha(dtpOperacionCompra.Value.ToString) TrasladarDatos.FechaVencimientoFUTU = Operaciones.ConvertirFecha(dtpVencimientoCompra.Value.ToString) TrasladarDatos.UnidadesPorContratoFUTU = Operaciones.ConvertirDecimal(txtUnidadesContratoCompra.Text.ToString) TrasladarDatos.IdContratoFUTU = Operaciones.ConvertirDecimal(txtIdentificacionContratoCompra.Text.ToString) TrasladarDatos.PrecioUnitarioFUTU = Operaciones.ConvertirDecimal(txtValorUnidadCompra.Text.ToString) TrasladarDatos.NombreInstrumento = "FUTU" TrasladarDatos.AgregarCMVTA = True Return TrasladarDatos End Function Private Sub txtValorTransadoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtValorTransadoCompra.TextChanged End Sub Private Sub txtValorRecibidoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtValorRecibidoCompra.TextChanged End Sub Private Sub txtValorTransadoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtValorTransadoVenta.TextChanged End Sub Private Sub txtValorRecibidoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtValorRecibidoVenta.TextChanged End Sub End Class