| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106 |
- 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 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
- 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
- End Class
|