| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047 |
- 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()
- CargarTransladoNuevo()
- 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
- Sub CargarTransladoNuevo()
- Dim Existe As Boolean = ExisteInversion()
- If CantFormAbierto = False Then
- If Not RetCodigoInversionExiste And Not Existe Then
- Dim TipoTransaccionCompraVenta As String = Variables.TipoTransaccionCompraVenta
- If TipoTransaccionCompraVenta = "C" Then
- txtValorUnidadCompra.Text = Variables.RetPrecio
- txtCantidadContratosCompra.Text = Variables.RetCantidadContratosFuturos
- txtUnidadesContratoCompra.Text = Variables.RetUnidadesContratosFuturos
- ElseIf TipoTransaccionCompraVenta = "V" Then
- txtValorUnidadVenta.Text = Variables.RetPrecio
- txtCantidadContratosVenta.Text = Variables.RetCantidadContratosFuturos
- txtUnidadesContratoVenta.Text = Variables.RetUnidadesContratosFuturos
- End If
- End If
- 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
|