| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141 |
- 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 = Variables.TrasladarCMVTA.CantidadContratosFUTU
- txtComisionBrokerCompra.Text = Variables.TrasladarCMVTA.ComisionBrokerFUTU
- dtpLiquidacionCompra.Value = Variables.TrasladarCMVTA.FechaLiquidacionFUTU
- dtpOperacionCompra.Value = Variables.TrasladarCMVTA.FechaOperacionFUTU
- dtpVencimientoCompra.Value = Variables.TrasladarCMVTA.FechaVencimientoFUTU
- txtIdentificacionContratoCompra.Text = Variables.TrasladarCMVTA.IdContratoFUTU
- txtValorUnidadCompra.Text = Variables.TrasladarCMVTA.PrecioUnitarioFUTU
- txtUnidadesContratoCompra.Text = Variables.TrasladarCMVTA.UnidadesPorContratoFUTU
- End If
- End If
- End Sub
- Function ExisteVenta()
- Dim Ventas As Boolean = False
- Dim General As New DAOGeneral
- Dim Codigo As String = Variables.Codigo
- Ventas = General.ExisteVenta(Codigo)
- Return Ventas
- End Function
- 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
- If String.IsNullOrEmpty(txtCantidadContratosCompra.Text.ToString) Then
- CantContCompra = 0
- Else
- CantContCompra = txtCantidadContratosCompra.Text
- End If
- If String.IsNullOrEmpty(txtUnidadesContratoCompra.Text.ToString) Then
- UnidadContratoCompra = 0
- Else
- UnidadContratoCompra = txtUnidadesContratoCompra.Text
- End If
- If String.IsNullOrEmpty(txtValorUnidadCompra.Text.ToString) Then
- ValorUnidadCompra = 0
- Else
- ValorUnidadCompra = txtValorUnidadCompra.Text
- End If
- If String.IsNullOrEmpty(txtComisionBrokerCompra.Text.ToString) Then
- ComisionBrokerCompra = 0
- Else
- ComisionBrokerCompra = txtComisionBrokerCompra.Text
- End If
- If String.IsNullOrEmpty(txtCantidadContratosVenta.Text.ToString) Then
- CantContVenta = 0
- Else
- CantContVenta = txtCantidadContratosVenta.Text
- End If
- If String.IsNullOrEmpty(txtUnidadesContratoVenta.Text.ToString) Then
- UnidadContratoVenta = 0
- Else
- UnidadContratoVenta = txtUnidadesContratoVenta.Text
- End If
- If String.IsNullOrEmpty(txtValorUnidadVenta.Text.ToString) Then
- ValorUnidadVenta = 0
- Else
- ValorUnidadVenta = txtValorUnidadVenta.Text
- End If
- If String.IsNullOrEmpty(txtComisionBrokerVenta.Text.ToString) Then
- ComisionBrokerVenta = 0
- Else
- ComisionBrokerVenta = txtComisionBrokerVenta.Text
- End If
- Dim ValorTransadoCompra = ValorTransado(CantContCompra, UnidadContratoCompra, ValorUnidadCompra)
- Dim ValorTransadoVenta = ValorTransado(CantContVenta, UnidadContratoVenta, ValorUnidadVenta)
- Dim ValorRecibidoCompra = ValorRecibido(ValorTransadoCompra, ComisionBrokerCompra)
- Dim ValorRecibidoVenta = ValorPagado(ValorTransadoVenta, ComisionBrokerVenta)
- If Double.IsInfinity(ValorTransadoCompra) Or Double.IsNaN(ValorTransadoCompra) Then
- txtValorTransadoCompra.Text = 0
- Else
- txtValorTransadoCompra.Text = ValorTransadoCompra
- End If
- If Double.IsInfinity(ValorTransadoVenta) Or Double.IsNaN(ValorTransadoVenta) Then
- txtValorTransadoVenta.Text = 0
- Else
- txtValorTransadoVenta.Text = ValorTransadoVenta
- End If
- If Double.IsInfinity(ValorRecibidoCompra) Or Double.IsNaN(ValorRecibidoCompra) Then
- txtValorRecibidoCompra.Text = 0
- Else
- txtValorRecibidoCompra.Text = ValorRecibidoCompra
- End If
- If Double.IsInfinity(ValorRecibidoVenta) Or Double.IsNaN(ValorRecibidoVenta) Then
- txtValorRecibidoVenta.Text = 0
- Else
- txtValorRecibidoVenta.Text = ValorRecibidoVenta
- End If
- If (cboOperacionVenta.SelectedIndex = 0) Then
- Dim GananciaPerdida = Format(Me.GananciaPerdida(txtValorRecibidoVenta.Text, txtValorRecibidoCompra.Text), "0.0000")
- If Double.IsInfinity(GananciaPerdida) Or Double.IsNaN(GananciaPerdida) Then
- txtGananciaPerdida.Text = 0
- Else
- txtGananciaPerdida.Text = GananciaPerdida
- End If
- ElseIf (cboOperacionVenta.SelectedIndex = 1) Then
- Dim GananciaPerdida = Format(Me.GananciaPerdida(txtValorRecibidoCompra.Text, txtValorRecibidoVenta.Text), "0.0000")
- If Double.IsInfinity(GananciaPerdida) Or Double.IsNaN(GananciaPerdida) Then
- txtGananciaPerdida.Text = 0
- Else
- txtGananciaPerdida.Text = GananciaPerdida
- End If
- 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")
- If Double.IsInfinity(Rendimientos) Or Double.IsNaN(Rendimientos) Then
- txtRendimiento.Text = "0.0%"
- Else
- txtRendimiento.Text = CStr(Rendimientos) + "%"
- End If
- End Sub
- Function ValorTransado(ByVal CantidadContratos As Double, ByVal UnidadesContrato As Double, ByVal ValorUnidad As Double)
- Dim ValorTrans As Double = 0
- If (String.IsNullOrEmpty(CantidadContratos.ToString) And String.IsNullOrEmpty(UnidadesContrato.ToString) And String.IsNullOrEmpty(ValorUnidad.ToString)) Then
- ValorTrans = 0
- Else
- ValorTrans = CantidadContratos * UnidadesContrato * ValorUnidad
- End If
- 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 = CDate(coleccion(1))
- dtpLiquidacionCompra.Value = CDate(coleccion(2))
- dtpVencimientoCompra.Value = CDate(coleccion(3))
- txtValorUnidadCompra.Text = CDec(coleccion(4))
- txtValorTransadoCompra.Text = CDec(coleccion(5))
- txtComisionBrokerCompra.Text = CDec(coleccion(6))
- txtValorRecibidoCompra.Text = CDec(coleccion(7))
- txtIdentificacionContratoCompra.Text = CStr(coleccion(8))
- txtCantidadContratosCompra.Text = CInt(coleccion(9))
- txtUnidadesContratoCompra.Text = CInt(coleccion(10))
- dtpOperacionVenta.Value = CDate(coleccion(11))
- dtpLiquidacionVenta.Value = CDate(coleccion(12))
- dtpVencimientoVenta.Value = CDate(coleccion(13))
- txtValorUnidadVenta.Text = CDec(coleccion(14))
- txtValorTransadoVenta.Text = CDec(coleccion(15))
- txtComisionBrokerVenta.Text = CDec(coleccion(16))
- txtValorRecibidoVenta.Text = CDec(coleccion(17))
- txtIdentificacionContratoVenta.Text = CStr(coleccion(18))
- txtCantidadContratosVenta.Text = CInt(coleccion(19))
- txtUnidadesContratoVenta.Text = CInt(coleccion(20))
- txtGananciaPerdida.Text = CDec(coleccion(21))
- txtRendimiento.Text = CDec(coleccion(22))
- 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
- 'If String.IsNullOrEmpty(txtIdentificacionContratoCompra.Text) Then
- ' If e.KeyChar = "." Then
- ' txtIdentificacionContratoCompra.Text = "0"
- ' Exit Sub
- ' End If
- 'End If
- 'If (Not txtIdentificacionContratoCompra.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 txtIdentificacionContratoVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtIdentificacionContratoVenta.KeyPress
- 'If String.IsNullOrEmpty(txtIdentificacionContratoVenta.Text) Then
- ' If e.KeyChar = "." Then
- ' txtIdentificacionContratoVenta.Text = "0"
- ' Exit Sub
- ' End If
- 'End If
- 'If (Not txtIdentificacionContratoVenta.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 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
- End Class
|