| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998 |
-
- Imports System.Data.OleDb
- Imports System.IO
- Public Class frmAcciones
- Private TipoOperacion As String
- Public Sub New()
- ' Esta llamada es exigida por el diseñador.
- InitializeComponent()
- ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
- End Sub
- Public Sub New(ByVal ConsTOperacion As String)
- ' Esta llamada es exigida por el diseñador.
- InitializeComponent()
- TOperacion(ConsTOperacion)
- TipoOperacion = ConsTOperacion
- ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
- End Sub
- Dim PorcentajeComisionBolsa_Compra As Double = 0.070625
- Dim PorcentajeComisionBolsa_Venta As Double = 0.0353125
- Dim Cargar As Boolean = True
- Dim PorcentajeComisionCasa_Compra As Double = 0.45
- Dim PorcentajeComisionCasa_Venta As Double = 0.4
- Dim Agregar As Boolean = False
- Dim PorcentajeLIOF As Double = 0.25
- Dim oAccionesCE As AccionesCE = New AccionesCE
- Dim oAccionesDAO As New AccionesDAO
- Dim oDAOGeneral As New DAOGeneral
- Dim Estado As String = ""
- Dim MostrarMensaje As Boolean = False
- Dim EditarDividendos As Boolean = False
- Dim EditarISR As Boolean = False
- Dim CambioCalculo = False
- Dim HabilitarBoton As Boolean = False
- Dim DobleClick As Boolean = False
- Dim Operaciones As New Operaciones
- Dim InstrumentoFinanciero As String = oDAOGeneral.ObtenerInstrumento(Variables.Codigo)
- Dim Cargado As Boolean = False
- Dim Cierre As Boolean = False
- Dim DatosCargados As Boolean = False
- Private _Modo As String
- Private _IdDocumento As Integer
- Private _TipoDocumento As String
- Private _CodigoInversion As String
- Private _TipoTransaccion As String
- Public Property TipoTransaccion As String
- Get
- Return _TipoTransaccion
- End Get
- Set(value As String)
- _TipoTransaccion = value
- End Set
- End Property
- Private Property IdDocumento As Integer
- Get
- Return _IdDocumento
- End Get
- Set(value As Integer)
- _IdDocumento = value
- End Set
- End Property
- Private Property TipoDocumento As String
- Get
- Return _TipoDocumento
- End Get
- Set(value As String)
- _TipoDocumento = value
- End Set
- End Property
- Private Property CodigoInversion As String
- Get
- Return _CodigoInversion
- End Get
- Set(value As String)
- _CodigoInversion = value
- End Set
- End Property
- Sub Instrumento()
- If (InstrumentoFinanciero = "ACCNC") Then
- lblTitulo.Text = "Acciones Nacionales Comunes"
- Me.Text = "Acciones Nacionales Comunes"
- ElseIf (InstrumentoFinanciero = "ACCNP") Then
- lblTitulo.Text = "Acciones Preferentes Nacionales"
- ModificacionesPreferentes()
- Me.Text = "Acciones Preferentes Nacionales"
- ElseIf (InstrumentoFinanciero = "ACCI") Then
- lblTitulo.Text = "Acciones Internacionales"
- Me.Text = "Acciones Internacionales"
- End If
- End Sub
- Function ColeccionDatos()
- Dim coleccion As New Collection
- Dim PrecioLimpioC, FOperC, FLiqC, DiasTC, GCapTotC, GCapUnC, RetAnBrC, RetAnNetC, UnC, ValTransC, MontoNetoC, PrecSucioC
- Dim PrecioLimpioV, FOperV, FLiqV, DiasTV, GCapTotV, GCapUnV, RetAnBrV, RetAnNetV, UnV, ValTransV, MontoNetoV, PrecSucioV
- Dim ComisionCompraCasa, ComisionCompraBolsa, ComisionVentaCasa, ComisionVentaBolsa As Double
- Dim IOF, Renta, Tipo, RetornoBruto, RetornoNeto
- Dim ComisionCompraCasaValor, ComisionCompraBolsaValor, ComisionVentaCasaValor, ComisionVentaBolsaValor As Double
- PrecioLimpioC = txtPrecioLimpioCompra.Text.Trim("%")
- FOperC = dtpFechaOperacionCompra.Value
- FLiqC = dtpFechaVencimientoCompra.Value
- DiasTC = txtDiasDeTenenciaCompra.Text.Trim("%")
- GCapTotC = txtGananciaCapitalTotalCompra.Text.Trim("%")
- GCapUnC = txtGananciaCapitalUnitarioCompra.Text.Trim("%")
- RetAnNetC = txtRetornoAnualNetoCompra.Text.Trim("%")
- UnC = txtUnidadesCompra.Text.Trim("%")
- ValTransC = txtValorTransadoCompra.Text.Trim("%")
- MontoNetoC = txtMontoNetoCompra.Text.Trim("%")
- PrecSucioC = txtPrecioSucioCompra.Text.Trim("%")
- PrecioLimpioV = txtPrecioLimpioVenta.Text.Trim("%")
- FOperV = dtpFechaOperacionVenta.Value
- FLiqV = dtpFechaVencimientoVenta.Value
- DiasTV = txtDiasDeTenenciaVenta.Text.Trim("%")
- GCapTotV = txtGananciaCapitalTotalVenta.Text.Trim("%")
- GCapUnV = txtGananciaCapitalUnitarioVenta.Text.Trim("%")
- RetAnBrV = txtRetornoAnualBrutoVenta.Text.Trim("%")
- RetAnNetV = txtRetornoAnualNetoVenta.Text.Trim("%")
- UnV = txtUnidadesVenta.Text.Trim("%")
- ValTransV = txtValorTransadoVenta.Text.Trim("%")
- MontoNetoV = txtMontoNetoVenta.Text.Trim("%")
- PrecSucioV = txtPrecioSucioVenta.Text.Trim("%")
- ComisionCompraCasa = txtComisionPorcentajeCasaCompra.Text.Trim("%") / 100
- ComisionCompraBolsa = txtComisionPorcentajeBolsaCompra.Text.Trim("%") / 100
- ComisionVentaCasa = txtComisionPorcentajeCasaVenta.Text.Trim("%") / 100
- ComisionVentaBolsa = txtComisionPorcentajeBolsaVenta.Text.Trim("%") / 100
- ComisionCompraCasaValor = txtComisionCasaCompra.Text
- ComisionCompraBolsaValor = txtComisionBolsaCompra.Text
- ComisionVentaCasaValor = txtComisionCasaVenta.Text
- ComisionVentaBolsaValor = txtComisionBolsaVenta.Text
- If (Not String.IsNullOrEmpty(txtRetornoAnualBrutoCompra.Text.ToString.ToString.Trim("%"))) Then
- RetornoBruto = txtRetornoAnualBrutoCompra.Text.Trim("%") / 100
- Else
- RetornoBruto = 0
- End If
- If (ChkIOF.Checked) Then
- IOF = 1
- Else
- IOF = 0
- End If
- If (ChkRenta.Checked) Then
- Renta = 1
- Else
- Renta = 0
- End If
- If rdbPorcentaje.Checked Then
- Tipo = "Porcentaje"
- Else
- Tipo = "Efectivo"
- End If
- coleccion.Add(PrecioLimpioC)
- coleccion.Add(FOperC)
- coleccion.Add(FLiqC)
- coleccion.Add(DiasTC)
- coleccion.Add(GCapTotC)
- coleccion.Add(GCapUnC)
- coleccion.Add(RetornoBruto)
- coleccion.Add(RetAnNetC)
- coleccion.Add(UnC)
- coleccion.Add(ValTransC)
- coleccion.Add(MontoNetoC)
- coleccion.Add(PrecSucioC)
- coleccion.Add(PrecioLimpioV)
- coleccion.Add(FOperV)
- coleccion.Add(FLiqV)
- coleccion.Add(DiasTV)
- coleccion.Add(GCapTotV)
- coleccion.Add(GCapUnV)
- coleccion.Add(RetAnBrV)
- coleccion.Add(RetAnNetV)
- coleccion.Add(UnV)
- coleccion.Add(ValTransV)
- coleccion.Add(MontoNetoV)
- coleccion.Add(PrecSucioV)
- coleccion.Add(ComisionCompraCasa)
- coleccion.Add(ComisionCompraBolsa)
- coleccion.Add(ComisionVentaCasa)
- coleccion.Add(ComisionVentaBolsa)
- coleccion.Add(IOF)
- coleccion.Add(Renta)
- coleccion.Add(Tipo)
- coleccion.Add(ComisionCompraCasaValor)
- coleccion.Add(ComisionCompraBolsaValor)
- coleccion.Add(ComisionVentaCasaValor)
- coleccion.Add(ComisionVentaBolsaValor)
- Return coleccion
- End Function
- Function Correlativo()
- Dim Index As Integer = 0
- Dim IndexCantidad As Integer = dgvDividendos.Rows.Count - 2
- Dim NumeroMayor As Integer = 0
- While Index <= IndexCantidad
- Dim Numero As Integer = dgvDividendos.Rows(Index).Cells("NumDiv").Value
- If Numero > NumeroMayor Then
- NumeroMayor = Numero
- End If
- Index += 1
- End While
- Return NumeroMayor + 1
- End Function
- Sub CorrelativoSinBD()
- Dim Index As Integer = 0
- Dim IndexCantidad As Integer = dgvDividendos.Rows.Count - 2
- Dim NumeroMayor As Integer = 0
- While Index <= IndexCantidad
- dgvDividendos.Rows(Index).Cells("Correlativo").Value = Index + 1
- Index += 1
- End While
- End Sub
- Function ColeccionesElementos(ByVal Index As Integer)
- Dim coleccion As New Collection
- Dim Fecha, Estado, Dividendo, CantidadBase, IngresoBruto, PorcISR, ISR, IngresoNeto, Correlativo, Tipo, FechaInicio, FechaCorte
- If rdbPorcentaje.Checked Then
- Tipo = "Porcentaje"
- Else
- Tipo = "Efectivo"
- End If
- Fecha = CDate(dgvDividendos.Rows(Index).Cells("Fecha").Value)
- Dividendo = dgvDividendos.Rows(Index).Cells("Dividendo").Value.ToString.Trim("%")
- If (Tipo = "Porcentaje") Then
- Dividendo /= 100
- End If
- CantidadBase = dgvDividendos.Rows(Index).Cells("CantidadBase").Value.ToString.TrimEnd("%")
- IngresoBruto = dgvDividendos.Rows(Index).Cells("IngresoBruto").Value.ToString.TrimEnd("%")
- PorcISR = dgvDividendos.Rows(Index).Cells("PorcISR").Value.ToString.TrimEnd("%")
- ISR = dgvDividendos.Rows(Index).Cells("ISR").Value.ToString.TrimEnd("%")
- IngresoNeto = dgvDividendos.Rows(Index).Cells("IngresoNeto").Value.ToString.TrimEnd("%")
- Estado = "A"
- Correlativo = dgvDividendos.Rows(Index).Cells("NumDiv").Value.ToString.TrimEnd("%")
- FechaInicio = dgvDividendos.Rows(Index).Cells("FechaInicio").Value
- FechaCorte = dgvDividendos.Rows(Index).Cells("FechaCorte").Value
- If (Tipo = "Porcentaje") Then
- If FechaInicio Is DBNull.Value Or FechaCorte Is DBNull.Value Then
- MsgBox("Verifique las fechas")
- Exit Function
- Else
- If (String.IsNullOrEmpty(FechaInicio) Or String.IsNullOrEmpty(FechaCorte)) Then
- MsgBox("Verifique las fechas")
- Exit Function
- End If
- End If
- End If
- coleccion.Add(Fecha)
- coleccion.Add(CDec(Dividendo))
- coleccion.Add(CDec(CantidadBase))
- coleccion.Add(CDec(IngresoBruto))
- coleccion.Add(CDec(PorcISR))
- coleccion.Add(CDec(ISR))
- coleccion.Add(CDec(IngresoNeto))
- coleccion.Add(Estado)
- coleccion.Add(CInt(Correlativo))
- coleccion.Add(FechaInicio)
- coleccion.Add(FechaCorte)
- Return coleccion
- End Function
- Sub NuevoElementoAccion(ByVal AgregarModificar As Boolean, ByVal Cantidad As Integer)
- Dim Codigo As String = Variables.Codigo
- Dim i As Integer = 0
- Dim Index = dgvDividendos.Rows.Count - 2
- i = Cantidad
- While i <= Index
- Dim coleccion = ColeccionesElementos(i)
- If (oAccionesDAO.NuevoElementoAccion(Codigo, coleccion) Is Nothing) Then
- Exit Sub
- End If
- i += 1
- End While
- MsgBox("Registro de ingresos actualizados")
- End Sub
- Function CanRegistros()
- Dim Tabla As String = String.Empty
- Tabla = "ACC1"
- Dim Codigo = Variables.Codigo
- Dim Cantidad As Integer = oDAOGeneral.CantidadRegistros(Codigo, Tabla)
- Return Cantidad
- End Function
- Sub ModificarElementoAccion()
- Dim i As Integer = 0
- Dim CantidadRegistrosDB = CanRegistros()
- While i < CantidadRegistrosDB
- Dim coleccion = ColeccionesElementos(i)
- If oAccionesDAO.ModificarElementoAccion(Codigo, coleccion) Is Nothing Then
- Exit Sub
- End If
- i += 1
- End While
- NuevoElementoAccion(True, CantidadRegistrosDB)
- End Sub
- Function ColeccionNuevo(ByVal codigo As String)
- Dim i As Integer = 0
- Dim diccionario As New Dictionary(Of String, Collection)
- Dim Index = dgvDividendos.Rows.Count - 2
- While i <= Index
- Dim coleccion = ColeccionesElementos(i)
- diccionario.Add(i, coleccion)
- i += 1
- End While
- Return diccionario
- End Function
- Public Function NuevaAccion()
- Dim Coleccion = ColeccionDatos()
- Return Coleccion
- End Function
- Sub Eliminar()
- Dim Codigo = Variables.Codigo
- oAccionesDAO.Eliminar(Codigo)
- End Sub
- Sub ModificacionesPreferentes()
- GrpVenta.Visible = False
- txtRetornoAnualBrutoCompra.Visible = True
- txtRetornoAnualBrutoCompra.ReadOnly = False
- txtRetornoAnualBrutoCompra.Text = "0.0"
- Label19.Visible = False
- End Sub
- Sub Redimencionar()
- dgvDividendos.Width = Me.Width - 10
- dgvDividendos.Height = Me.Height - 50
- End Sub
- Private Sub frmAcciones_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Dim VExisteInversion As Boolean = False
- VExisteInversion = ExisteInversion()
- If VExisteInversion Then
- TipoOperacion = "C"
- TipoTransaccion = "C"
- Else
- TipoOperacion = String.Empty
- TipoTransaccion = String.Empty
- End If
- If Variables.TipoOperacionCMVTA = "C" Then
- GrpVenta.Enabled = False
- GrpCompra.Enabled = True
- Else
- GrpVenta.Enabled = True
- GrpCompra.Enabled = False
- End If
- Call Instrumento()
- HabilitarBotones()
- PrepararTablaDividendos()
- If VExisteInversion Then
- TipoOperacion = "C"
- TipoTransaccion = "C"
- Else
- TipoOperacion = String.Empty
- TipoTransaccion = String.Empty
- End If
- If TipoTransaccion = "C" Then
- Call CargarRegistroBD()
- Formato()
- ValidarRentaIOF()
- CargarDividendos()
- End If
- ModificarDividendo()
- CalcularDividendos()
- Cargado = True
- ValidarExistencia()
- Formato()
- DatosCargados = True
- CargarTransladoNuevo()
- ConfiguracionCMVTA(VExisteInversion)
- End Sub
- Sub ConfiguracionCMVTA(ByRef VExisteInversion As Boolean)
- Dim Codigo As String = Variables.Codigo
- Dim ExisteCMVTA As Boolean = oDAOGeneral.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
- dtpFechaOperacionCompra.Value = Variables.TrasladarCMVTA.FechaOperacionACC
- dtpFechaVencimientoCompra.Value = Variables.TrasladarCMVTA.FechaVencimientoACC
- txtPrecioLimpioCompra.Text = Variables.TrasladarCMVTA.PrecioLimpioACC
- txtUnidadesCompra.Text = Variables.TrasladarCMVTA.UnidadesACC
- txtComisionPorcentajeCasaCompra.Text = Variables.TrasladarCMVTA.PorcentajeCasaACC
- txtComisionPorcentajeBolsaCompra.Text = Variables.TrasladarCMVTA.PorcentajeBolsaACC
- 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 ModificarDividendo()
- Dim Cantidad As Integer = dgvDividendos.Rows.Count - 2
- For i As Integer = 0 To Cantidad
- If rdbPorcentaje.Checked Then
- dgvDividendos.Rows(i).Cells("Dividendo").Value *= 100
- End If
- Next
- End Sub
- Private Sub chkAccionPreferente_CheckedChanged(sender As Object, e As EventArgs)
- End Sub
- Private Sub btnAceptar_Click(sender As Object, e As EventArgs) Handles btnAceptar.Click
- Dim codigo As String = Variables.Codigo
- Dim Accion As Collection = NuevaAccion()
- Dim ElementosAccion As Dictionary(Of String, Collection) = ColeccionNuevo(codigo)
- If (Estado = "N") Then
- oAccionesDAO.ProcesoDatos(Accion, codigo, ElementosAccion, "Nuevo")
- ElseIf Not ExisteValidacion() Then
- Variables.ColeccionACC = NuevaAccion()
- Me.Close()
- End If
- If Estado = "M" Then
- oAccionesDAO.ProcesoDatos(Accion, codigo, ElementosAccion, "Modificar")
- End If
- If Estado = "B" Then
- Eliminar()
- End If
- ValidarExistencia()
- End Sub
- Sub ValidarExistencia()
- Dim General As New DAOGeneral
- Dim Codigo As String = Variables.Codigo
- Dim Tabla As String = String.Empty
- Tabla = "ACC0"
- Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
- If (Existe) Then
- navNuevo.Enabled = False
- TbDividendos.Enabled = True
- navModificar.Enabled = True
- navEliminar.Enabled = True
- Else
- navNuevo.Enabled = True
- TbDividendos.Enabled = False
- navModificar.Enabled = False
- navEliminar.Enabled = False
- DatosCargados = True
- End If
- TipoTransaccion = 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
- Tabla = "ACC0"
- Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
- Return Existe
- End Function
- Public Function RetornarObjeto()
- Return oAccionesCE
- End Function
- Private Sub CargarRegistroBD()
- oAccionesCE = Nothing
- CodigoInversion = Variables.Codigo
- oAccionesCE = oAccionesDAO.CargarRegistro(Me.CodigoInversion)
- TipoTransaccion = "C"
- RefrescarValorControlesInicial()
- End Sub
- Public Sub CargarRegistro(vId As Integer, vTipo As String)
- TipoTransaccion = "C"
- IdDocumento = vId
- TipoDocumento = vTipo
- End Sub
- Public Sub CargarRegistro(ByRef vCodigoInversion As String)
- TipoTransaccion = "C"
- Me.CodigoInversion = vCodigoInversion
- End Sub
- Private Sub txtDiasDeTenencia_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtDiasDeTenenciaCompra.TextChanged
- End Sub
- Private Sub txtGananciaCapitalTotal_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtGananciaCapitalTotalCompra.TextChanged
- End Sub
- Private Sub txtGananciaCapitalUnitario_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtGananciaCapitalUnitarioCompra.TextChanged
- End Sub
- Private Sub txtRetornoAnualBruto_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtRetornoAnualBrutoCompra.TextChanged
- If (txtRetornoAnualBrutoCompra.ToString.IndexOf("%") = -1) Then
- txtRetornoAnualBrutoCompra.Text += "%"
- End If
- If (String.IsNullOrEmpty(txtRetornoAnualBrutoCompra.Text.ToString.Trim("%"))) Then
- txtRetornoAnualBrutoCompra.Text = "0.0%"
- End If
- End Sub
- Private Sub txtRetornoAnualNeto_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtRetornoAnualNetoCompra.TextChanged
- End Sub
- Private Sub cboCasa_C_SelectedIndexChanged(sender As Object, e As EventArgs)
- End Sub
- Private Sub txtPrecioSucio_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioSucioCompra.TextChanged
- End Sub
- Private Sub txtGananciaCapitalUnitario_Venta_TextChanged(sender As Object, e As EventArgs) Handles txtGananciaCapitalUnitarioVenta.TextChanged
- End Sub
- Private Sub txtRetornoAnualBruto_Venta_TextChanged(sender As Object, e As EventArgs) Handles txtRetornoAnualBrutoVenta.TextChanged
- End Sub
- Private Sub txtRetornoAnualNeto_Venta_TextChanged(sender As Object, e As EventArgs) Handles txtRetornoAnualNetoVenta.TextChanged
- End Sub
- Private Sub cboCasa_V_SelectedIndexChanged(sender As Object, e As EventArgs)
- End Sub
- '********** CONTROL DE VALORES **********
- 'COMPRA
- Private Sub ControlPrecioLimpioCompra()
- If DatosCargados Then
- Dim valor As Double = 0
- If Not Double.TryParse(Me.txtPrecioLimpioCompra.Text, valor) Then
- oAccionesCE.PrecioLimpioVenta = "0.0"
- Else
- oAccionesCE.PrecioLimpioCompra = valor
- Me.txtPrecioLimpioCompra.BackColor = Color.White
- If (Me.TipoTransaccion = "N") Then
- oAccionesCE.PrecioLimpioVenta = oAccionesCE.PrecioLimpioCompra
- End If
- RefrescarValorControles()
- End If
- End If
- End Sub
- Private Sub ControlFechaOperacionCompra()
- oAccionesCE.FechaOperacionCompra = Me.dtpFechaOperacionCompra.Value.Date
- RefrescarValorControles()
- End Sub
- Private Sub ControlFechaLiquidacionCompra()
- oAccionesCE.FechaVencimientoCompra = Me.dtpFechaVencimientoCompra.Value.Date
- RefrescarValorControles()
- End Sub
- Private Sub ControlCantidadCompra()
- Dim valor As Integer = 0
- If Not Integer.TryParse(Me.txtUnidadesCompra.Text, valor) Then
- oAccionesCE.CantidadCompra = "0"
- Else
- Me.txtUnidadesCompra.BackColor = Color.White
- oAccionesCE.CantidadCompra = valor
- If (Me.TipoTransaccion = "N" Or TipoTransaccion = "A") Then
- oAccionesCE.CantidadVenta = oAccionesCE.CantidadCompra
- End If
- RefrescarValorControles()
- End If
- End Sub
- 'VENTA
- Private Sub ControlPrecioLimpioVenta()
- If DatosCargados Then
- Dim valor As Double
- If Not Double.TryParse(Me.txtPrecioLimpioVenta.Text, valor) Then
- oAccionesCE.PrecioLimpioVenta = "0.0"
- Else
- Me.txtPrecioLimpioVenta.BackColor = Color.White
- oAccionesCE.PrecioLimpioVenta = valor
- End If
- RefrescarValorControles()
- End If
- End Sub
- Private Sub ControlFechaOperacionVenta()
- oAccionesCE.FechaOperacionVenta = dtpFechaOperacionVenta.Value.Date
- RefrescarValorControles()
- End Sub
- Private Sub ControlFechaLiquidacionVenta()
- oAccionesCE.FechaVencimientoVenta = dtpFechaVencimientoVenta.Value.Date
- RefrescarValorControles()
- End Sub
- Private Sub ControlCantidadVenta()
- Dim valor As Integer
- If Not Integer.TryParse(Me.txtUnidadesVenta.Text, valor) Then
- Me.txtUnidadesVenta.Text = "0"
- oAccionesCE.CantidadVenta = "0"
- Else
- Me.txtUnidadesVenta.BackColor = Color.White
- oAccionesCE.CantidadVenta = valor
- End If
- RefrescarValorControles()
- End Sub
- '********** FIN CONTROL DE VALORES **********
- '********** EVENTOS DE CONTROLES **********
- 'COMPRA
- Private Sub txtPrecioLimpioCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioLimpioCompra.TextChanged
- ControlPrecioLimpioCompra()
- End Sub
- Private Sub txtPrecioLimpioCompra_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioLimpioCompra.LostFocus
- ControlPrecioLimpioCompra()
- End Sub
- Private Sub dtpFechaOperacionCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaOperacionCompra.ValueChanged
- If DatosCargados Then
- ControlFechaOperacionCompra()
- RefrescarValorControles()
- Formato()
- End If
- End Sub
- Private Sub dtpFechaLiquidacionCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimientoCompra.ValueChanged
- If DatosCargados Then
- ControlFechaLiquidacionCompra()
- RefrescarValorControles()
- Formato()
- End If
- End Sub
- Private Sub txtUnidadesCompra_TextChanged(sender As Object, e As EventArgs) Handles txtUnidadesCompra.TextChanged
- If DatosCargados Then
- ControlCantidadCompra()
- CopiarDatos()
- End If
- End Sub
- Sub CopiarDatos()
- txtUnidadesVenta.Text = txtUnidadesCompra.Text
- End Sub
- Private Sub txtUnidadesCompra_LostFocus(sender As Object, e As EventArgs) Handles txtUnidadesCompra.LostFocus
- ControlCantidadCompra()
- End Sub
- 'VENTA
- Private Sub txtPrecioLimpioVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioLimpioVenta.TextChanged
- ControlPrecioLimpioVenta()
- End Sub
- Private Sub txtPrecioLimpioVenta_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioLimpioVenta.LostFocus
- ControlPrecioLimpioVenta()
- End Sub
- Private Sub dtpFechaOperacionVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaOperacionVenta.ValueChanged
- If DatosCargados Then
- ControlFechaOperacionVenta()
- RefrescarValorControles()
- End If
- End Sub
- Private Sub dtpFechaLiquidacionVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimientoVenta.ValueChanged
- If DatosCargados Then
- ControlFechaLiquidacionVenta()
- RefrescarValorControles()
- End If
- End Sub
- Private Sub txtUnidadesVenta_TextChanged(sender As Object, e As EventArgs) Handles txtUnidadesVenta.TextChanged
- If DatosCargados Then
- ControlCantidadVenta()
- MensajeAlerta()
- MostrarMensaje = True
- End If
- End Sub
- Sub MensajeAlerta()
- If (MostrarMensaje) Then
- Dim UnidadesVenta As Integer = 0
- Dim UnidadesCompra As Integer = 0
- If Not String.IsNullOrEmpty(txtUnidadesVenta.Text) Then
- UnidadesVenta = txtUnidadesVenta.Text
- End If
- If Not String.IsNullOrEmpty(txtUnidadesCompra.Text) Then
- UnidadesCompra = txtUnidadesCompra.Text
- End If
- If (CDec(UnidadesVenta) > CDec(UnidadesCompra)) Then
- MsgBox("Esta Tratando de Ingresar más acciones de las compradas, verifique los datos si ha cometido algún error.")
- End If
- End If
- End Sub
- Private Sub txtUnidadesVenta_LostFocus(sender As Object, e As EventArgs) Handles txtUnidadesVenta.LostFocus
- ControlCantidadVenta()
- End Sub
- Private Sub chkBolsa_CheckedChanged(sender As Object, e As EventArgs)
- End Sub
- '********** FIN EVENTOS DE CONTROLES **********
- '********** FUNCIONES **********
- Private Sub RefrescarClaseEntidad()
- ControlPrecioLimpioCompra()
- ControlFechaOperacionCompra()
- ControlFechaLiquidacionCompra()
- ControlCantidadCompra()
- ControlPrecioLimpioVenta()
- ControlFechaOperacionVenta()
- ControlFechaLiquidacionVenta()
- ControlCantidadVenta()
- End Sub
- Private Sub Formato()
- If DatosCargados Then
- If (String.IsNullOrEmpty(Me.txtRetornoAnualBrutoCompra.Text.ToString.Trim("%"))) Then
- Me.txtRetornoAnualBrutoCompra.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(Me.txtComisionPorcentajeCasaCompra.Text.Trim("%"))) Then
- Me.txtComisionPorcentajeCasaCompra.Text = "0.0%"
- End If
- If (String.IsNullOrEmpty(Me.txtComisionPorcentajeBolsaCompra.Text.Trim("%"))) Then
- Me.txtComisionPorcentajeBolsaCompra.Text = "0.0%"
- End If
- If (String.IsNullOrEmpty(Me.txtComisionPorcentajeCasaVenta.Text.Trim("%"))) Then
- Me.txtComisionPorcentajeCasaVenta.Text = "0.0%"
- End If
- If (String.IsNullOrEmpty(Me.txtComisionPorcentajeBolsaVenta.Text.Trim("%"))) Then
- Me.txtComisionPorcentajeBolsaVenta.Text = "0.0%"
- End If
- If (String.IsNullOrEmpty(Me.txtComisionPorcentajeBolsaCompra.Text.Trim("%"))) Then
- Me.txtComisionPorcentajeBolsaCompra.Text = "0.0%"
- End If
- If (String.IsNullOrEmpty(Me.txtComisionPorcentajeBolsaVenta.Text.Trim("%"))) Then
- Me.txtComisionPorcentajeBolsaVenta.Text = "0.0%"
- End If
- If String.IsNullOrEmpty(txtRetornoAnualBrutoVenta.Text.ToString) Then
- txtRetornoAnualBrutoVenta.Text = 0
- End If
- If String.IsNullOrEmpty(txtPrecioLimpioCompra.Text.ToString) Then
- txtPrecioLimpioCompra.Text = 0
- End If
- If String.IsNullOrEmpty(txtPrecioLimpioVenta.Text.ToString) Then
- txtPrecioLimpioVenta.Text = 0
- End If
- If String.IsNullOrEmpty(txtUnidadesCompra.Text.ToString) Then
- txtUnidadesCompra.Text = 0
- End If
- If String.IsNullOrEmpty(txtUnidadesVenta.Text.ToString) Then
- txtUnidadesVenta.Text = 0
- End If
- If (txtComisionPorcentajeCasaVenta.ToString.IndexOf("%") = -1) Then
- txtComisionPorcentajeCasaVenta.Text += "%"
- End If
- If (txtComisionPorcentajeBolsaVenta.ToString.IndexOf("%") = -1) Then
- txtComisionPorcentajeBolsaVenta.Text += "%"
- End If
- If String.IsNullOrEmpty(txtGananciaCapitalUnitarioVenta.Text) Then
- txtGananciaCapitalUnitarioVenta.Text = 0
- End If
- If String.IsNullOrEmpty(txtRetornoAnualNetoVenta.Text) Then
- txtRetornoAnualNetoVenta.Text = 0
- End If
- End If
- End Sub
- Sub RefrescarValorControlesInicial()
- Me.txtRetornoAnualBrutoCompra.Text = oAccionesCE.RetornoBruto * 100
- Dim IOF = oAccionesCE.IOF
- Dim Renta = oAccionesCE.Renta
- If (IOF) Then
- ChkIOF.Checked = True
- Else
- ChkIOF.Checked = False
- End If
- If (Renta) Then
- ChkRenta.Checked = True
- Else
- ChkRenta.Checked = False
- End If
- Me.txtComisionPorcentajeCasaCompra.Text = CStr(oAccionesCE.ComisionPorcentajeCompraCasa * 100) + "%"
- Me.txtComisionPorcentajeBolsaCompra.Text = CStr(oAccionesCE.ComisionPorcentajeCompraBolsa * 100) + "%"
- Me.txtComisionPorcentajeCasaVenta.Text = CStr(oAccionesCE.ComisionPorcentajeVentaCasa * 100) + "%"
- Me.txtComisionPorcentajeBolsaVenta.Text = CStr(oAccionesCE.ComisionPorcentajeVentaBolsa * 100) + "%"
- Me.txtComisionCasaCompra.Text = oAccionesCE.ComisionCompraCasa
- Me.txtComisionBolsaCompra.Text = oAccionesCE.ComisionCompraBolsa
- Me.txtComisionCasaVenta.Text = oAccionesCE.ComisionVentaCasa
- Me.txtComisionBolsaVenta.Text = oAccionesCE.ComisionVentaBolsa
- If (oAccionesCE.Tipo = "Porcentaje") Then
- rdbPorcentaje.Checked = True
- ElseIf (oAccionesCE.Tipo = "Efectivo") Then
- rdbEfectivo.Checked = True
- End If
- 'COMPRA
- Me.txtPrecioLimpioCompra.Text = oAccionesCE.PrecioLimpioCompra.ToString()
- dtpFechaOperacionCompra.Value = CDate(oAccionesCE.FechaOperacionCompra)
- dtpFechaVencimientoCompra.Value = CDate(oAccionesCE.FechaVencimientoCompra)
- Me.txtDiasDeTenenciaCompra.Text = oAccionesCE.DiasDeTenenciaCompra.ToString
- Me.txtGananciaCapitalTotalCompra.Text = oAccionesCE.GananciaDeCapitalTotalCompra.ToString
- Me.txtGananciaCapitalUnitarioCompra.Text = oAccionesCE.GananciaDeCapitalUnitarioCompra.ToString
- Me.txtRetornoAnualNetoCompra.Text = oAccionesCE.RetornoAnualizadoNetoCompra.ToString()
- Me.txtUnidadesCompra.Text = oAccionesCE.CantidadCompra.ToString
- Me.txtValorTransadoCompra.Text = oAccionesCE.ValorTransadoCompra.ToString()
- Dim ValorIOFCompra = 0.0, ValorRentaCompra = 0.0
- Me.txtMontoNetoCompra.Text = oAccionesCE.MontoNetoComprasus
- Me.txtPrecioSucioCompra.Text = oAccionesCE.PrecioSucioCompra.ToString()
- 'VENTA
- Me.txtPrecioLimpioVenta.Text = oAccionesCE.PrecioLimpioVenta.ToString()
- Me.dtpFechaOperacionVenta.Value = oAccionesCE.FechaOperacionVenta
- Me.dtpFechaVencimientoVenta.Value = oAccionesCE.FechaVencimientoVenta
- Me.txtDiasDeTenenciaVenta.Text = oAccionesCE.DiasDeTenenciaVenta.ToString
- Me.txtGananciaCapitalTotalVenta.Text = oAccionesCE.GananciaDeCapitalTotalVentasus.ToString()
- Me.txtGananciaCapitalUnitarioVenta.Text = oAccionesCE.GananciaDeCapitalUnitarioVenta.ToString
- txtRetornoAnualBrutoVenta.Text = oAccionesCE.RetornoAnualizadoBrutoVentasus.ToString
- Me.txtRetornoAnualNetoVenta.Text = oAccionesCE.RetornoAnualizadoNetoVenta.ToString()
- Me.txtUnidadesVenta.Text = oAccionesCE.CantidadVenta.ToString
- Me.txtValorTransadoVenta.Text = oAccionesCE.ValorTransadoVenta.ToString()
- Me.txtImpuestosYComisionesVenta.Text = oAccionesCE.SumaImpuestosYComisionesVenta.ToString()
- Dim ComisionCasaVenta As Double = 0
- Dim ComisionBolsaVenta As Double = 0
- Dim ValorTransadoVenta As Double = 0
- Dim ValorIOFVenta = 0.0, ValorRentaVenta = 0.0
- Me.txtMontoNetoVenta.Text = oAccionesCE.MontoNetoVentasus.ToString
- Me.txtPrecioSucioVenta.Text = oAccionesCE.PrecioSucioVentasus.ToString()
- End Sub
- Sub RefrescarValorControles()
- If DatosCargados Then
- If (Cargar) Then
- If (String.IsNullOrEmpty(oAccionesCE.RetornoBruto.ToString())) Then
- Else
- Me.txtRetornoAnualBrutoCompra.Text = oAccionesCE.RetornoBruto * 100
- End If
- If String.IsNullOrEmpty(txtGananciaCapitalUnitarioVenta.Text) Then
- txtGananciaCapitalUnitarioVenta.Text = 0
- End If
- If String.IsNullOrEmpty(txtRetornoAnualNetoVenta.Text) Then
- txtRetornoAnualNetoVenta.Text = 0
- End If
- Dim IOF = oAccionesCE.IOF
- Dim Renta = oAccionesCE.Renta
- If (IOF) Then
- ChkIOF.Checked = True
- Else
- ChkIOF.Checked = False
- End If
- If (Renta) Then
- ChkRenta.Checked = True
- Else
- ChkRenta.Checked = False
- End If
- If (String.IsNullOrEmpty(Me.txtComisionPorcentajeCasaCompra.Text.TrimEnd("%"))) Then
- If (String.IsNullOrEmpty(oAccionesCE.ComisionCompraCasa)) Then
- Else
- If Not oAccionesCE.ComisionCompraCasa = "0" Then
- Me.txtComisionPorcentajeCasaCompra.Text = CStr(oAccionesCE.ComisionCompraCasa * 100) + "%"
- End If
- End If
- End If
- If (String.IsNullOrEmpty(Me.txtComisionPorcentajeBolsaCompra.Text.TrimEnd("%"))) Then
- If (String.IsNullOrEmpty(oAccionesCE.ComisionCompraBolsa)) Then
- Else
- If Not oAccionesCE.ComisionCompraBolsa = "0" Then
- Me.txtComisionPorcentajeBolsaCompra.Text = CStr(oAccionesCE.ComisionCompraBolsa * 100) + "%"
- End If
- End If
- End If
- If (String.IsNullOrEmpty(Me.txtComisionPorcentajeCasaVenta.Text.TrimEnd("%"))) Then
- If (String.IsNullOrEmpty(oAccionesCE.ComisionVentaCasa)) Then
- End If
- If Not oAccionesCE.ComisionVentaCasa = "0" Then
- Me.txtComisionPorcentajeCasaVenta.Text = CStr(oAccionesCE.ComisionVentaCasa * 100) + "%"
- End If
- End If
- If (String.IsNullOrEmpty(Me.txtComisionPorcentajeBolsaVenta.Text.TrimEnd("%"))) Then
- If (String.IsNullOrEmpty(oAccionesCE.ComisionVentaBolsa)) Then
- Else
- If Not oAccionesCE.ComisionVentaBolsa = "0" Then
- Me.txtComisionPorcentajeBolsaVenta.Text = CStr(oAccionesCE.ComisionVentaBolsa * 100) + "%"
- End If
- End If
- End If
- Else
- If (oAccionesCE.Tipo = "Porcentaje") Then
- rdbPorcentaje.Checked = True
- ElseIf (oAccionesCE.Tipo = "Efectivo") Then
- rdbEfectivo.Checked = True
- End If
- End If
- 'COMPRA
- If (String.IsNullOrEmpty(oAccionesCE.PrecioLimpioCompra.ToString())) Then
- Else
- If Not oAccionesCE.PrecioLimpioCompra.ToString() = "0" Then
- Me.txtPrecioLimpioCompra.Text = oAccionesCE.PrecioLimpioCompra.ToString()
- End If
- End If
- If (String.IsNullOrEmpty(oAccionesCE.FechaOperacionCompra)) Then
- Me.dtpFechaOperacionCompra.Value = Date.Now.Date
- Else
- Me.dtpFechaOperacionCompra.Value = oAccionesCE.FechaOperacionCompra
- End If
- If (String.IsNullOrEmpty(oAccionesCE.FechaVencimientoCompra)) Then
- Me.dtpFechaVencimientoCompra.Value = Date.Now.Date
- Else
- Me.dtpFechaVencimientoCompra.Value = oAccionesCE.FechaVencimientoCompra
- End If
- If (String.IsNullOrEmpty(oAccionesCE.DiasDeTenenciaCompra.ToString)) Then
- Else
- Me.txtDiasDeTenenciaCompra.Text = oAccionesCE.DiasDeTenenciaCompra.ToString
- End If
- If (String.IsNullOrEmpty(oAccionesCE.GananciaDeCapitalTotalCompra.ToString)) Then
- Else
- Me.txtGananciaCapitalTotalCompra.Text = oAccionesCE.GananciaDeCapitalTotalCompra.ToString
- End If
- If (String.IsNullOrEmpty(oAccionesCE.GananciaDeCapitalUnitarioCompra.ToString)) Then
- Else
- Me.txtGananciaCapitalUnitarioCompra.Text = oAccionesCE.GananciaDeCapitalUnitarioCompra.ToString
- End If
- If (String.IsNullOrEmpty(oAccionesCE.RetornoAnualizadoNetoCompra.ToString(Configuraciones.CodigoTXTPorcentaje))) Then
- Else
- Me.txtRetornoAnualNetoCompra.Text = oAccionesCE.RetornoAnualizadoNetoCompra.ToString()
- End If
- If (String.IsNullOrEmpty(oAccionesCE.CantidadCompra.ToString)) Then
- Else
- If Not oAccionesCE.CantidadCompra.ToString = "0" Then
- Me.txtUnidadesCompra.Text = oAccionesCE.CantidadCompra.ToString
- End If
- End If
- If (String.IsNullOrEmpty(oAccionesCE.ValorTransadoCompra.ToString(Configuraciones.CodigoTXTMontos))) Then
- Else
- Me.txtValorTransadoCompra.Text = oAccionesCE.ValorTransadoCompra.ToString()
- End If
- Dim ComisionCasaCompra As Double = 0
- Dim ComisionBolsaCompra As Double = 0
- Dim ValorTransadoCompra As Double = 0
- If String.IsNullOrEmpty(txtComisionPorcentajeCasaCompra.Text.TrimEnd("%")) Then
- ComisionCasaCompra = 0
- Else
- ComisionCasaCompra = txtComisionPorcentajeCasaCompra.Text.TrimEnd("%") / 100
- End If
- If String.IsNullOrEmpty(txtComisionPorcentajeBolsaCompra.Text.TrimEnd("%")) Then
- ComisionBolsaCompra = 0
- Else
- ComisionBolsaCompra = txtComisionPorcentajeBolsaCompra.Text.TrimEnd("%") / 100
- End If
- If Not String.IsNullOrEmpty(txtValorTransadoCompra.Text) Then
- ValorTransadoCompra = txtValorTransadoCompra.Text
- End If
- Me.txtComisionCasaCompra.Text = CalcularComisionImpuestos(ComisionCasaCompra, txtValorTransadoCompra.Text)
- Me.txtComisionBolsaCompra.Text = CalcularComisionImpuestos(ComisionBolsaCompra, txtValorTransadoCompra.Text)
- If (String.IsNullOrEmpty(oAccionesCE.SumaImpuestosYComisionesCompra.ToString(Configuraciones.CodigoTXTMontos))) Then
- Else
- Me.txtImpuestosYComisionesCompra.Text = oAccionesCE.SumaImpuestosYComisionesCompra.ToString()
- End If
- Dim ValorIOFCompra = 0.0, ValorRentaCompra = 0.0
- If (Not String.IsNullOrEmpty(txtIOFCompra.Text.ToString)) Then
- ValorIOFCompra = txtIOFCompra.Text
- End If
- If (Not String.IsNullOrEmpty(txtRentaCompra.Text.ToString)) Then
- ValorRentaCompra = txtRentaCompra.Text
- End If
- If (String.IsNullOrEmpty(oAccionesCE.PrecioSucioCompra.ToString(Configuraciones.CodigoTXTMontos))) Then
- Else
- Me.txtPrecioSucioCompra.Text = oAccionesCE.PrecioSucioCompra.ToString()
- End If
- 'VENTA
- If (String.IsNullOrEmpty(oAccionesCE.PrecioLimpioVenta.ToString())) Then
- Else
- If Not oAccionesCE.PrecioLimpioVenta = 0 Then
- Me.txtPrecioLimpioVenta.Text = oAccionesCE.PrecioLimpioVenta.ToString()
- End If
- End If
- If (String.IsNullOrEmpty(oAccionesCE.FechaOperacionVenta)) Then
- Me.dtpFechaOperacionVenta.Value = Date.Now.Date
- Else
- Me.dtpFechaOperacionVenta.Value = oAccionesCE.FechaOperacionVenta
- End If
- If (String.IsNullOrEmpty(oAccionesCE.FechaVencimientoVenta)) Then
- Me.dtpFechaVencimientoVenta.Value = Date.Now.Date
- Else
- Me.dtpFechaVencimientoVenta.Value = oAccionesCE.FechaVencimientoVenta
- End If
- If (String.IsNullOrEmpty(oAccionesCE.DiasDeTenenciaVenta.ToString)) Then
- Else
- Me.txtDiasDeTenenciaVenta.Text = oAccionesCE.DiasDeTenenciaVenta.ToString
- End If
- If (String.IsNullOrEmpty(oAccionesCE.GananciaDeCapitalTotalVenta.ToString(Configuraciones.CodigoTXTMontos))) Then
- Else
- Me.txtGananciaCapitalTotalVenta.Text = oAccionesCE.GananciaDeCapitalTotalVenta.ToString()
- End If
- If (String.IsNullOrEmpty(oAccionesCE.GananciaDeCapitalUnitarioVenta.ToString)) Then
- Else
- If Double.IsNaN(oAccionesCE.GananciaDeCapitalUnitarioVenta.ToString) Then
- Else
- Me.txtGananciaCapitalUnitarioVenta.Text = oAccionesCE.GananciaDeCapitalUnitarioVenta.ToString
- End If
- End If
- If String.IsNullOrEmpty(txtRetornoAnualBrutoVenta.Text.ToString) Then
- txtRetornoAnualBrutoVenta.Text = 0
- End If
- Variables.IngresoBruto = CalcularIngresoBruto()
- Variables.IngresoNeto = CalcularIngresoNeto()
- If (rdbEfectivo.Checked) Then
- If (String.IsNullOrEmpty(oAccionesCE.RetornoAnualizadoBrutoVenta.ToString(Configuraciones.CodigoTXTPorcentaje))) Then
- Else
- Me.txtRetornoAnualBrutoVenta.Text = oAccionesCE.RetornoAnualizadoBrutoVenta.ToString()
- End If
- Else
- Dim Existe = dgvDividendos.Rows.Count
- If (Existe >= 1) Then
- If (Not dgvDividendos.Rows(0).Cells("Dividendo").Value Is Nothing) Then
- Dim Valor = dgvDividendos.Rows(0).Cells("Dividendo").Value.ToString.Trim("%")
- If (String.IsNullOrEmpty(Valor)) Then
- Else
- Me.txtRetornoAnualBrutoVenta.Text = CStr((CDec(Valor.ToString.Trim("%")) * 100)) + "%"
- End If
- End If
- End If
- End If
- If (rdbEfectivo.Checked) Then
- If (String.IsNullOrEmpty(oAccionesCE.RetornoAnualizadoNetoVenta.ToString(Configuraciones.CodigoTXTPorcentaje))) Then
- Else
- Me.txtRetornoAnualNetoVenta.Text = oAccionesCE.RetornoAnualizadoNetoVenta.ToString()
- End If
- Else
- Dim Existe = dgvDividendos.Rows.Count
- If (Existe >= 1) Then
- Dim Valor = dgvDividendos.Rows(0).Cells("PorcISR").Value
- If (String.IsNullOrEmpty(Valor)) Then
- Else
- Me.txtRetornoAnualNetoVenta.Text = CStr(CDec(txtRetornoAnualBrutoVenta.Text.Trim("%")) * (1 - Valor)) + "%"
- End If
- End If
- End If
- If (String.IsNullOrEmpty(oAccionesCE.CantidadVenta.ToString)) Then
- Else
- If Not oAccionesCE.CantidadVenta = 0 Then
- Me.txtUnidadesVenta.Text = oAccionesCE.CantidadVenta.ToString
- End If
- End If
- If (String.IsNullOrEmpty(oAccionesCE.ValorTransadoVenta.ToString())) Then
- Else
- Me.txtValorTransadoVenta.Text = oAccionesCE.ValorTransadoVenta.ToString()
- End If
- If (String.IsNullOrEmpty(oAccionesCE.SumaImpuestosYComisionesVenta.ToString())) Then
- Else
- Me.txtImpuestosYComisionesVenta.Text = oAccionesCE.SumaImpuestosYComisionesVenta.ToString()
- End If
- Dim ComisionCasaVenta As Double = 0
- Dim ComisionBolsaVenta As Double = 0
- Dim ValorTransadoVenta As Double = 0
- If Not String.IsNullOrEmpty(txtComisionPorcentajeCasaVenta.Text.TrimEnd("%")) Then
- ComisionCasaVenta = txtComisionPorcentajeCasaVenta.Text.TrimEnd("%") / 100
- End If
- If Not String.IsNullOrEmpty(txtComisionPorcentajeBolsaVenta.Text.TrimEnd("%")) Then
- ComisionBolsaVenta = txtComisionPorcentajeBolsaVenta.Text.TrimEnd("%") / 100
- End If
- If Not String.IsNullOrEmpty(txtValorTransadoVenta.Text) Then
- ValorTransadoVenta = txtValorTransadoVenta.Text
- End If
- Me.txtComisionCasaVenta.Text = CalcularComisionImpuestos(ComisionCasaVenta, ValorTransadoVenta)
- Me.txtComisionBolsaVenta.Text = CalcularComisionImpuestos(ComisionBolsaVenta, ValorTransadoVenta)
- txtGananciaCapitalTotalVenta.Text += SumaComisiones()
- Dim ValorIOFVenta = 0.0, ValorRentaVenta = 0.0
- If (Not String.IsNullOrEmpty(txtIOFVenta.Text.ToString)) Then
- ValorIOFVenta = txtIOFVenta.Text
- End If
- If (Not String.IsNullOrEmpty(txtRentaVenta.Text.ToString)) Then
- ValorRentaVenta = txtRentaVenta.Text
- End If
- If (String.IsNullOrEmpty(oAccionesCE.MontoNetoVenta.ToString())) Then
- Else
- Me.txtMontoNetoVenta.Text = CDec(oAccionesCE.MontoNetoVenta.ToString()) - CDec(txtComisionBolsaVenta.Text) - CDec(txtComisionCasaVenta.Text) - ValorIOFVenta - ValorRentaVenta
- End If
- If (String.IsNullOrEmpty(CDec(oAccionesCE.MontoNetoCompra.ToString(Configuraciones.CodigoTXTMontos)))) Or String.IsNullOrEmpty((CDec(txtComisionBolsaCompra.Text)) Or String.IsNullOrEmpty(CDec(txtComisionCasaCompra.Text)) Or String.IsNullOrEmpty(ValorIOFCompra) Or String.IsNullOrEmpty(ValorRentaCompra)) Then
- Else
- Me.txtMontoNetoCompra.Text = (CDec(oAccionesCE.MontoNetoCompra.ToString())) + (CDec(txtComisionBolsaCompra.Text) + CDec(txtComisionCasaCompra.Text) + ValorIOFCompra + ValorRentaCompra)
- End If
- If (String.IsNullOrEmpty(oAccionesCE.PrecioSucioVenta.ToString())) Then
- Me.txtPrecioSucioVenta.Text = "0.0"
- Else
- If Double.IsNaN(oAccionesCE.PrecioSucioVenta.ToString()) Then
- Me.txtPrecioSucioVenta.Text = "0.0"
- Else
- Me.txtPrecioSucioVenta.Text = oAccionesCE.PrecioSucioVenta.ToString()
- End If
- End If
- End If
- End Sub
- Function CalcularIngresoBruto()
- Dim Cantidad = dgvDividendos.Rows.Count - 1
- Dim FechaActual = Date.Now.Date
- Dim ContadorIngreso As Double = 0.0
- For i As Integer = 0 To Cantidad
- Try
- If (Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("Fecha").Value.ToString)) Then
- Dim FechaPrograma As Date = CDate(dgvDividendos.Rows(i).Cells("Fecha").Value.ToString)
- If (FechaActual >= FechaPrograma) Then
- If (Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("IngresoBruto").Value.ToString)) Then
- ContadorIngreso += CDec(dgvDividendos.Rows(i).Cells("IngresoBruto").Value.ToString)
- End If
- End If
- End If
- Catch ex As Exception
- End Try
- Next
- Return ContadorIngreso
- End Function
- Function CalcularIngresoNeto()
- Dim Cantidad = dgvDividendos.Rows.Count - 1
- Dim FechaActual = Date.Now.Date
- Dim ContadorIngreso As Double = 0.0
- For i As Integer = 0 To Cantidad
- Try
- If (Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("Fecha").Value.ToString)) Then
- Dim FechaPrograma As Date = CDate(dgvDividendos.Rows(i).Cells("Fecha").Value.ToString)
- If (FechaActual >= FechaPrograma) Then
- If (Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("IngresoNeto").Value.ToString)) Then
- ContadorIngreso += CDec(dgvDividendos.Rows(i).Cells("IngresoNeto").Value.ToString)
- End If
- End If
- End If
- Catch ex As Exception
- End Try
- Next
- Return ContadorIngreso
- End Function
- Function SumaComisiones()
- Dim ComisionCasaVenta As Double = txtComisionCasaVenta.Text
- Dim ComisionBolsaVenta As Double = txtComisionBolsaVenta.Text
- Dim Total As Double = 0.0
- Total = ComisionCasaVenta + ComisionBolsaVenta
- Return Total
- End Function
- Function CalcularComisionImpuestos(ByVal Comision As Double, ByVal ValorTransado As Double)
- Return Comision * ValorTransado
- End Function
- Private Sub PrepararTablaDividendos()
- Dim oDataGridViewTextBoxColumn As DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "CodInv"
- oDataGridViewTextBoxColumn.DataPropertyName = "CodInv"
- oDataGridViewTextBoxColumn.HeaderText = "Código Inversión"
- oDataGridViewTextBoxColumn.ValueType = GetType(String)
- oDataGridViewTextBoxColumn.Visible = False
- Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "Correlativo"
- oDataGridViewTextBoxColumn.DataPropertyName = "Correlativo"
- oDataGridViewTextBoxColumn.HeaderText = "Correlativo"
- oDataGridViewTextBoxColumn.ValueType = GetType(String)
- oDataGridViewTextBoxColumn.Visible = True
- Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "Fecha"
- oDataGridViewTextBoxColumn.DataPropertyName = "Fecha"
- oDataGridViewTextBoxColumn.HeaderText = "Fecha"
- oDataGridViewTextBoxColumn.Name = "Fecha"
- oDataGridViewTextBoxColumn.ValueType = GetType(Date)
- Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.ValueType = GetType(String)
- oDataGridViewTextBoxColumn.Name = "Dividendo"
- oDataGridViewTextBoxColumn.DataPropertyName = "Dividendo"
- oDataGridViewTextBoxColumn.HeaderText = "Dividendo"
- Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "CantidadBase"
- oDataGridViewTextBoxColumn.DataPropertyName = "CantidadBase"
- oDataGridViewTextBoxColumn.HeaderText = "Cantidad Base"
- oDataGridViewTextBoxColumn.ValueType = GetType(Double)
- oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
- Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "IngresoBruto"
- oDataGridViewTextBoxColumn.DataPropertyName = "IngresoBruto"
- oDataGridViewTextBoxColumn.HeaderText = "Ingreso Bruto"
- oDataGridViewTextBoxColumn.ValueType = GetType(Double)
- oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
- oDataGridViewTextBoxColumn.ReadOnly = True
- Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "PorcISR"
- oDataGridViewTextBoxColumn.DataPropertyName = "PorcISR"
- oDataGridViewTextBoxColumn.HeaderText = "% ISR"
- oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTPorcentaje
- oDataGridViewTextBoxColumn.ValueType = GetType(Double)
- Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "ISR"
- oDataGridViewTextBoxColumn.DataPropertyName = "ISR"
- oDataGridViewTextBoxColumn.HeaderText = "ISR"
- oDataGridViewTextBoxColumn.ValueType = GetType(Double)
- oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
- oDataGridViewTextBoxColumn.ReadOnly = True
- Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "IngresoNeto"
- oDataGridViewTextBoxColumn.DataPropertyName = "IngresoNeto"
- oDataGridViewTextBoxColumn.HeaderText = "Ingreso Neto"
- oDataGridViewTextBoxColumn.ValueType = GetType(Double)
- oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
- oDataGridViewTextBoxColumn.ReadOnly = True
- Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "Estado"
- oDataGridViewTextBoxColumn.DataPropertyName = "Estado"
- oDataGridViewTextBoxColumn.HeaderText = "Estado"
- oDataGridViewTextBoxColumn.ValueType = GetType(String)
- oDataGridViewTextBoxColumn.Visible = False
- Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "FechaInicio"
- oDataGridViewTextBoxColumn.DataPropertyName = "FechaInicio"
- oDataGridViewTextBoxColumn.HeaderText = "FechaInicio"
- oDataGridViewTextBoxColumn.ValueType = GetType(String)
- oDataGridViewTextBoxColumn.Visible = False
- Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "FechaCorte"
- oDataGridViewTextBoxColumn.DataPropertyName = "FechaCorte"
- oDataGridViewTextBoxColumn.HeaderText = "FechaCorte"
- oDataGridViewTextBoxColumn.ValueType = GetType(String)
- oDataGridViewTextBoxColumn.Visible = False
- Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "NumDiv"
- oDataGridViewTextBoxColumn.DataPropertyName = "NumDiv"
- oDataGridViewTextBoxColumn.HeaderText = "NuvDiv"
- oDataGridViewTextBoxColumn.ValueType = GetType(String)
- oDataGridViewTextBoxColumn.Visible = False
- Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
- End Sub
- Private Function FechaDividendo()
- Dim Index = dgvDividendos.CurrentRow.Index
- Dim IndexAnterior = Index - 1
- Dim FechaInicial = dtpFechaOperacionCompra.Value
- Dim FechaActual = dgvDividendos.Rows(Index).Cells("Fecha").Value
- Dim FechaCalcul As Date = Date.Now.Date
- If (String.IsNullOrEmpty(FechaActual)) Then
- If (Index = 0) Then
- FechaCalcul = Operaciones.Meses(12, FechaInicial, FechaInicial)
- Else
- Dim Fecha = dgvDividendos.Rows(IndexAnterior).Cells("Fecha").Value
- FechaCalcul = Operaciones.Meses(12, Fecha, FechaInicial)
- End If
- Else
- FechaCalcul = FechaActual
- End If
- Return FechaCalcul
- End Function
- Private Sub PrepararCalculoDividendos(ByVal IdFila As Integer)
- Dim vFila As DataGridViewRow = dgvDividendos.Rows(IdFila)
- If (rdbEfectivo.Checked) Then
- If vFila.IsNewRow Then
- vFila.Cells("Fecha").Value = FechaDividendo()
- vFila.Cells("Dividendo").Value = oAccionesCE.FactorDeDividendo
- End If
- If rdbEfectivo.Checked Then
- If (String.IsNullOrEmpty(txtUnidadesCompra.Text)) Then
- vFila.Cells("CantidadBase").Value = 0.0
- Else
- vFila.Cells("CantidadBase").Value = CDec(txtUnidadesCompra.Text)
- End If
- Else
- If (String.IsNullOrEmpty(txtValorTransadoCompra.Text)) Then
- vFila.Cells("CantidadBase").Value = 0.0
- Else
- vFila.Cells("CantidadBase").Value = CDec(txtValorTransadoCompra.Text)
- End If
- End If
- vFila.Cells("IngresoBruto").Value = 0.00
- vFila.Cells("PorcISR").Value = 0.05
- vFila.Cells("ISR").Value = 0.00
- vFila.Cells("IngresoNeto").Value = 0.00
- If dgvDividendos.Rows(IdFila).Cells("NumDiv").Value Is DBNull.Value Then
- dgvDividendos.Rows(IdFila).Cells("NumDiv").Value = Correlativo()
- Else
- If String.IsNullOrEmpty(dgvDividendos.Rows(IdFila).Cells("NumDiv").Value) Then
- dgvDividendos.Rows(IdFila).Cells("NumDiv").Value = Correlativo()
- End If
- End If
- Else
- If vFila.IsNewRow Then
- vFila.Cells("Fecha").Value = FechaDividendo()
- vFila.Cells("Dividendo").Value = oAccionesCE.FactorDeDividendo.ToString + "%"
- If (vFila.Cells("Dividendo").Value.ToString.IndexOf("%") = -1) Then
- vFila.Cells("Dividendo").Value += "%"
- End If
- If rdbEfectivo.Checked Then
- If (String.IsNullOrEmpty(txtUnidadesCompra.Text)) Then
- vFila.Cells("CantidadBase").Value = 0.0
- Else
- vFila.Cells("CantidadBase").Value = CDec(txtUnidadesCompra.Text)
- End If
- Else
- If (String.IsNullOrEmpty(txtValorTransadoCompra.Text)) Then
- vFila.Cells("CantidadBase").Value = 0.0
- Else
- vFila.Cells("CantidadBase").Value = CDec(txtValorTransadoCompra.Text)
- End If
- End If
- vFila.Cells("IngresoBruto").Value = 0.00
- vFila.Cells("PorcISR").Value = 0.05
- vFila.Cells("ISR").Value = 0.00
- vFila.Cells("IngresoNeto").Value = 0.00
- If dgvDividendos.Rows(IdFila).Cells("NumDiv").Value Is DBNull.Value Then
- dgvDividendos.Rows(IdFila).Cells("NumDiv").Value = Correlativo()
- Else
- If String.IsNullOrEmpty(dgvDividendos.Rows(IdFila).Cells("NumDiv").Value) Then
- dgvDividendos.Rows(IdFila).Cells("NumDiv").Value = Correlativo()
- End If
- End If
- End If
- End If
- If (vFila.Cells("Fecha").Value Is DBNull.Value) Then
- vFila.Cells("Fecha").Value = FechaDividendo()
- Else
- If String.IsNullOrEmpty(vFila.Cells("Fecha").Value) Then
- vFila.Cells("Fecha").Value = FechaDividendo()
- End If
- End If
- RefrescarValorControles()
- End Sub
- Sub AgregarFechaCO()
- dgvDividendos.CurrentRow.Cells("FechaInicio").Value = Variables.FechaInicialCorte
- dgvDividendos.CurrentRow.Cells("FechaCorte").Value = Variables.FechaCorteCorte
- End Sub
- Function CalculoIngresoBrutoEfectivo(ByVal CantidadUnidades As Double, ByVal Dividendo As Double)
- Dim Total = CantidadUnidades * (Dividendo)
- Return Total
- End Function
- Function CalculoIngresoBrutoPorcentaje(ByVal ValorTransado As Double, ByVal Dividendo As Double, ByVal Dias As Integer, ByVal Fecha As Date)
- Dim Total As Double = 0
- If (Operaciones.AñoBisiesto(Fecha) = 364) Then
- Total = (ValorTransado * (Dividendo / 100) * Dias) / 365
- End If
- If (Operaciones.AñoBisiesto(Fecha) = 365) Then
- Total = (ValorTransado * (Dividendo / 100) * Dias) / 366
- End If
- Return Total
- End Function
- Private Sub dgvDividendos_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) Handles dgvDividendos.CellBeginEdit
- PrepararCalculoDividendos(e.RowIndex)
- End Sub
- Private Sub dgvDividendos_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvDividendos.CellEndEdit
- CalcularDividendos()
- RefrescarValorControles()
- End Sub
- Private Sub dgvDividendos_UserDeletedRow(sender As Object, e As DataGridViewRowEventArgs) Handles dgvDividendos.UserDeletedRow
- End Sub
- Private Sub dgvImpuestosYComisiones_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs)
- End Sub
- Private Sub dgvImpuestosYComisiones_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs)
- End Sub
- Private Sub dgvImpuestosYComisiones_UserDeletedRow(sender As Object, e As DataGridViewRowEventArgs)
- oAccionesCE.ImpuestosYComisiones.AcceptChanges()
- End Sub
- Private Sub dgvImpuestosYComisiones_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
- End Sub
- Private Sub dgvDividendos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvDividendos.CellContentClick
- End Sub
- Private Sub TabPage2_Click(sender As Object, e As EventArgs)
- End Sub
- Private Sub txtImpuestosYComisionesCompra_TextChanged(sender As Object, e As EventArgs) Handles txtImpuestosYComisionesCompra.TextChanged
- End Sub
- Private Sub TOperacion(ByVal TOperacion As String)
- If (TOperacion = "N") Then
- HabilitarBotones()
- ElseIf (TOperacion = "B") Then
- DeshabilitarBotones()
- End If
- End Sub
- Sub HabilitarBotones()
- txtUnidadesCompra.Enabled = True
- txtUnidadesVenta.Enabled = True
- End Sub
- Sub DeshabilitarBotones()
- txtDiasDeTenenciaCompra.Enabled = False
- txtDiasDeTenenciaVenta.Enabled = False
- txtGananciaCapitalTotalCompra.Enabled = False
- txtGananciaCapitalTotalVenta.Enabled = False
- txtGananciaCapitalUnitarioCompra.Enabled = False
- txtGananciaCapitalUnitarioVenta.Enabled = False
- txtRetornoAnualBrutoCompra.Enabled = False
- txtRetornoAnualBrutoVenta.Enabled = False
- txtRetornoAnualNetoCompra.Enabled = False
- txtRetornoAnualNetoVenta.Enabled = False
- txtUnidadesCompra.Enabled = False
- txtUnidadesVenta.Enabled = False
- txtValorTransadoCompra.Enabled = False
- txtValorTransadoVenta.Enabled = False
- txtImpuestosYComisionesCompra.Enabled = False
- txtImpuestosYComisionesVenta.Enabled = False
- txtMontoNetoCompra.Enabled = False
- txtMontoNetoVenta.Enabled = False
- txtPrecioSucioCompra.Enabled = False
- txtPrecioSucioVenta.Enabled = False
- End Sub
- Private Sub dtgcomisiones_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
- End Sub
- Private Sub TabPage4_Click(sender As Object, e As EventArgs)
- End Sub
- Private Sub dtgcomisiones_CellContentClick_1(sender As Object, e As DataGridViewCellEventArgs)
- End Sub
- Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
- Estado = "N"
- btnAceptar.Text = "Nuevo"
- End Sub
- Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
- Estado = "M"
- btnAceptar.Text = "Modificar"
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs)
- If (Estado = "N") Then
- NuevaAccion()
- End If
- End Sub
- Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
- Estado = "B"
- btnAceptar.Text = "Eliminar"
- End Sub
- Private Sub btnAgregar_Click(sender As Object, e As EventArgs)
- End Sub
- Private Sub dgvDividendos_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvDividendos.CellClick
- ModificarFechaCorte()
- PrepararCalculoDividendos(e.RowIndex)
- End Sub
- Sub ModificarFechaCorte()
- If rdbPorcentaje.Checked Then
- Dim Index As Integer = dgvDividendos.CurrentRow.Index
- If dgvDividendos.Rows(Index).Cells("Fecha").ColumnIndex = dgvDividendos.CurrentCell.ColumnIndex Then
- Dim FechaReferencia = dgvDividendos.Rows(Index).Cells("Fecha").Value
- If (Not String.IsNullOrEmpty(FechaReferencia)) Then
- Dim año = FechaReferencia.Year
- Dim PrimeraFecha, SegundaFecha
- If (dgvDividendos.Rows(Index).Cells("FechaInicio").Value Is Nothing) Then
- PrimeraFecha = CDate("1/1/" + año.ToString)
- ElseIf (dgvDividendos.Rows(Index).Cells("FechaInicio").Value Is DBNull.Value) Then
- PrimeraFecha = CDate("1/1/" + año.ToString)
- Else
- PrimeraFecha = dgvDividendos.Rows(Index).Cells("FechaInicio").Value
- End If
- If (dgvDividendos.Rows(Index).Cells("FechaCorte").Value Is Nothing) Then
- SegundaFecha = CDate("31/12/" + año.ToString)
- ElseIf (dgvDividendos.Rows(Index).Cells("FechaCorte").Value Is DBNull.Value) Then
- SegundaFecha = CDate("31/12/" + año.ToString)
- Else
- SegundaFecha = dgvDividendos.Rows(Index).Cells("FechaCorte").Value
- End If
- Variables.FechaInicial = PrimeraFecha
- Variables.FechaCorte = SegundaFecha
- Variables.CorrelativoACC = dgvDividendos.Rows(Index).Cells("NumDiv").Value
- frmFechasAcciones.Show()
- End If
- Cierre = True
- End If
- End If
- End Sub
- Private Sub txtComisionPorcentajeCasaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorcentajeCasaCompra.TextChanged
- RefrescarValorControles()
- End Sub
- Private Sub txtComisionPorcentajeBolsaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorcentajeBolsaCompra.TextChanged
- RefrescarValorControles()
- End Sub
- Private Sub txtComisionPorcentajeCasaVenta_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorcentajeCasaVenta.TextChanged
- RefrescarValorControles()
- End Sub
- Private Sub txtComisionPorcentajeBolsaVenta_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorcentajeBolsaVenta.TextChanged
- RefrescarValorControles()
- End Sub
- Private Sub txtMontoNetoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtMontoNetoCompra.TextChanged
- End Sub
- Private Sub btnAgregarImpuesto_Click(sender As Object, e As EventArgs)
- End Sub
- Private Sub dgvImpuestoAgregado_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
- End Sub
- Private Sub btnQuitar_Click(sender As Object, e As EventArgs)
- End Sub
- Private Sub dgvImpuestoAgregado_CellClick(sender As Object, e As DataGridViewCellEventArgs)
- End Sub
- Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs)
- End Sub
- Private Sub BindingNavigator1_RefreshItems(sender As Object, e As EventArgs) Handles BindingNavigator1.RefreshItems
- End Sub
- Sub ValidarRentaIOF()
- If (ChkIOF.Checked) Then
- CalculosIOF()
- Else
- BloquearIOF()
- End If
- RefrescarValorControles()
- If (ChkRenta.Checked) Then
- CalculosRenta()
- Else
- BloquearRenta()
- End If
- RefrescarValorControles()
- End Sub
- Private Sub ChkIOF_CheckedChanged(sender As Object, e As EventArgs) Handles ChkIOF.CheckedChanged
- If (ChkIOF.Checked) Then
- oAccionesCE.IOF = 1
- CalculosIOF()
- Else
- oAccionesCE.IOF = 0
- BloquearIOF()
- End If
- RefrescarValorControles()
- End Sub
- Sub BloquearIOF()
- lblCompra1.Visible = False
- lblVenta1.Visible = False
- txtIOFCompra.Text = String.Empty
- txtIOFCompra.Visible = False
- txtIOFVenta.Text = String.Empty
- txtIOFVenta.Visible = False
- End Sub
- Sub CalculosIOF()
- If (Not String.IsNullOrEmpty(txtValorTransadoCompra.Text) And Not String.IsNullOrEmpty(txtValorTransadoVenta.Text)) Then
- lblCompra1.Visible = True
- lblVenta1.Visible = True
- txtIOFCompra.Visible = True
- txtIOFVenta.Visible = True
- Dim ValorTransadoCompra = txtValorTransadoCompra.Text
- Dim ValorTransadoVenta = txtValorTransadoVenta.Text
- txtIOFCompra.Text = CalculoImpuestos(ValorTransadoCompra, 0.0025)
- txtIOFVenta.Text = CalculoImpuestos(ValorTransadoVenta, 0.0025)
- End If
- End Sub
- Private Sub ChkRenta_CheckedChanged(sender As Object, e As EventArgs) Handles ChkRenta.CheckedChanged
- If (ChkRenta.Checked) Then
- oAccionesCE.Renta = 1
- CalculosRenta()
- Else
- oAccionesCE.Renta = 0
- BloquearRenta()
- End If
- RefrescarValorControles()
- End Sub
- Sub CalculosRenta()
- If (Not String.IsNullOrEmpty(txtValorTransadoCompra.Text) And Not String.IsNullOrEmpty(txtValorTransadoVenta.Text)) Then
- lblCompra2.Visible = True
- lblVenta2.Visible = True
- txtRentaVenta.Visible = True
- txtRentaCompra.Visible = True
- Dim ValorTransadoCompra = txtValorTransadoCompra.Text
- Dim ValorTransadoVenta = txtValorTransadoVenta.Text
- txtRentaCompra.Text = CalculoImpuestos(ValorTransadoCompra, 0.1)
- txtRentaVenta.Text = CalculoImpuestos(ValorTransadoVenta, 0.1)
- End If
- End Sub
- Sub BloquearRenta()
- lblCompra2.Visible = False
- lblVenta2.Visible = False
- txtRentaCompra.Text = String.Empty
- txtRentaCompra.Visible = False
- txtRentaVenta.Text = String.Empty
- txtRentaVenta.Visible = False
- End Sub
- Function CalculoImpuestos(ByVal ValorTransado As Double, ByVal Impuesto As Double)
- Dim Valor = ValorTransado * Impuesto
- Return Valor
- End Function
- Private Sub rdbEfectivo_CheckedChanged(sender As Object, e As EventArgs) Handles rdbEfectivo.CheckedChanged
- If (rdbEfectivo.Checked) Then
- LimpiarDividendosCambios(1)
- Else
- LimpiarDividendosCambios(2)
- End If
- CambiarBase()
- CambioCalculo = True
- CambioCalculo = False
- If (Cargado) Then
- RefrescarValorControles()
- End If
- End Sub
- Private Sub rdbPorcentaje_CheckedChanged(sender As Object, e As EventArgs) Handles rdbPorcentaje.CheckedChanged
- If (rdbEfectivo.Checked) Then
- LimpiarDividendosCambios(1)
- Else
- LimpiarDividendosCambios(2)
- End If
- CambiarBase()
- CambioCalculo = True
- CambioCalculo = False
- If (Cargado) Then
- RefrescarValorControles()
- End If
- End Sub
- Sub CambiarBase()
- Dim Cantidad As Integer = dgvDividendos.Rows.Count - 1
- For i As Integer = 0 To Cantidad
- If (dgvDividendos.Rows(i).Cells("NumDiv").Value Is DBNull.Value) Then
- Exit For
- Else
- If String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("NumDiv").Value) Then
- Exit For
- End If
- End If
- If rdbEfectivo.Checked Then
- If (String.IsNullOrEmpty(txtUnidadesCompra.Text)) Then
- dgvDividendos.Rows(i).Cells("CantidadBase").Value = 0.0
- Else
- dgvDividendos.Rows(i).Cells("CantidadBase").Value = CDec(txtUnidadesCompra.Text)
- End If
- Else
- If (String.IsNullOrEmpty(txtValorTransadoCompra.Text)) Then
- dgvDividendos.Rows(i).Cells("CantidadBase").Value = 0.0
- Else
- dgvDividendos.Rows(i).Cells("CantidadBase").Value = CDec(txtValorTransadoCompra.Text)
- End If
- End If
- Next
- CalcularDividendos()
- End Sub
- Private Sub dgvDividendos_Click(sender As Object, e As EventArgs) Handles dgvDividendos.Click
- End Sub
- Sub ClonarDatos()
- If (String.IsNullOrEmpty(txtUnidadesVenta.Text.ToString)) Then
- txtUnidadesVenta.Text = txtUnidadesCompra.Text
- End If
- End Sub
- Private Sub txtUnidadesCompra_Leave(sender As Object, e As EventArgs) Handles txtUnidadesCompra.Leave
- ClonarDatos()
- Formato()
- End Sub
- Private Sub rdbEfectivo_Click(sender As Object, e As EventArgs) Handles rdbEfectivo.Click
- End Sub
- Private Sub dgvDividendos_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvDividendos.CellDoubleClick
- End Sub
- Private Sub txtPrecioLimpioCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioLimpioCompra.KeyPress
- If String.IsNullOrEmpty(txtPrecioLimpioCompra.Text) Then
- If e.KeyChar = "." Then
- txtPrecioLimpioCompra.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtPrecioLimpioCompra.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 txtPrecioLimpioVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioLimpioVenta.KeyPress
- If String.IsNullOrEmpty(txtPrecioLimpioVenta.Text) Then
- If e.KeyChar = "." Then
- txtPrecioLimpioVenta.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtPrecioLimpioVenta.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 txtUnidadesCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtUnidadesCompra.KeyPress
- If String.IsNullOrEmpty(txtUnidadesCompra.Text) Then
- If e.KeyChar = "." Then
- txtUnidadesCompra.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtUnidadesCompra.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 txtUnidadesVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtUnidadesVenta.KeyPress
- If String.IsNullOrEmpty(txtUnidadesVenta.Text) Then
- If e.KeyChar = "." Then
- txtUnidadesVenta.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtUnidadesVenta.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 txtComisionPorcentajeCasaCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorcentajeCasaCompra.KeyPress
- If String.IsNullOrEmpty(txtComisionPorcentajeCasaCompra.Text) Then
- If e.KeyChar = "." Then
- txtComisionPorcentajeCasaCompra.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtComisionPorcentajeCasaCompra.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 txtComisionPorcentajeBolsaCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorcentajeBolsaCompra.KeyPress
- If String.IsNullOrEmpty(txtComisionPorcentajeBolsaCompra.Text) Then
- If e.KeyChar = "." Then
- txtComisionPorcentajeBolsaCompra.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtComisionPorcentajeBolsaCompra.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 txtComisionPorcentajeCasaVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorcentajeCasaVenta.KeyPress
- If String.IsNullOrEmpty(txtComisionPorcentajeCasaVenta.Text) Then
- If e.KeyChar = "." Then
- txtComisionPorcentajeCasaVenta.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtComisionPorcentajeCasaVenta.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 txtComisionPorcentajeBolsaVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorcentajeBolsaVenta.KeyPress
- If String.IsNullOrEmpty(txtComisionPorcentajeBolsaVenta.Text) Then
- If e.KeyChar = "." Then
- txtComisionPorcentajeBolsaVenta.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtComisionPorcentajeBolsaVenta.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 btnCancelar_Click(sender As Object, e As EventArgs) Handles btnCancelar.Click
- End Sub
- Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles Panel1.Paint
- End Sub
- Private Sub TabPage1_Click(sender As Object, e As EventArgs) Handles TbOperacion.Click
- End Sub
- Private Sub txtGananciaCapitalTotalVenta_TextChanged(sender As Object, e As EventArgs) Handles txtGananciaCapitalTotalVenta.TextChanged
- End Sub
- Private Sub txtDiasDeTenenciaVenta_TextChanged(sender As Object, e As EventArgs) Handles txtDiasDeTenenciaVenta.TextChanged
- End Sub
- Private Sub Label9_Click(sender As Object, e As EventArgs) Handles Label9.Click
- End Sub
- Private Sub Label6_Click(sender As Object, e As EventArgs) Handles Label6.Click
- End Sub
- Private Sub txtIOFCompra_TextChanged(sender As Object, e As EventArgs) Handles txtIOFCompra.TextChanged
- End Sub
- Private Sub txtRentaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtRentaCompra.TextChanged
- End Sub
- Private Sub CalcularDividendos()
- Dim Cantidad As Integer = dgvDividendos.Rows.Count - 2
- For i As Integer = 0 To Cantidad
- If (String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("Dividendo").Value)) Then
- dgvDividendos.Rows(i).Cells("Dividendo").Value = 0
- End If
- If rdbEfectivo.Checked Then
- If (String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("Dividendo").Value)) Then
- dgvDividendos.Rows(i).Cells("Dividendo").Value = 0
- End If
- End If
- Dim Dividendos As Double = dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString.Trim("%")
- Dim Porcentaje As Double = dgvDividendos.Rows(i).Cells("PorcISR").Value
- Dim Valor = dgvDividendos.Rows(i).Cells("CantidadBase").Value
- If rdbEfectivo.Checked Then
- Dim CalculoIB = CalculoIngresoBrutoEfectivo(Valor, Dividendos)
- Dim CalculoRenta = CalculoIB * Porcentaje
- Dim CalculoIN = CalculoIB - CalculoRenta
- dgvDividendos.Rows(i).Cells("IngresoBruto").Value = CalculoIB
- dgvDividendos.Rows(i).Cells("ISR").Value = CalculoRenta
- dgvDividendos.Rows(i).Cells("IngresoNeto").Value = CalculoIN
- Else
- If (dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString.IndexOf("%") = -1) Then
- dgvDividendos.Rows(i).Cells("Dividendo").Value = dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString + "%"
- End If
- Dim Dias As Integer = 0
- Dim FechaInicialCorte As Date = Date.Now.Date
- Dim FechaCorteCorte As Date = Date.Now.Date
- If (dgvDividendos.Rows(i).Cells("FechaInicio").Value IsNot DBNull.Value And dgvDividendos.Rows(i).Cells("FechaCorte").Value IsNot DBNull.Value) Then
- If (Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("FechaInicio").Value) And Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("FechaCorte").Value)) Then
- FechaInicialCorte = dgvDividendos.Rows(i).Cells("FechaInicio").Value
- FechaCorteCorte = dgvDividendos.Rows(i).Cells("FechaCorte").Value
- Dias = DateDiff(DateInterval.Day, FechaInicialCorte, FechaCorteCorte)
- Dias += 1
- Dim CalculoIBP = CalculoIngresoBrutoPorcentaje(Valor, Dividendos, Dias, FechaInicialCorte)
- Dim CalculoRenta = CalculoIBP * Porcentaje
- Dim CalculoIN = CalculoIBP - CalculoRenta
- dgvDividendos.Rows(i).Cells("IngresoBruto").Value = CalculoIBP
- dgvDividendos.Rows(i).Cells("ISR").Value = CalculoRenta
- dgvDividendos.Rows(i).Cells("IngresoNeto").Value = CalculoIN
- End If
- End If
- End If
- Next
- CorrelativoSinBD()
- End Sub
- Public Sub btnActualizar_Click(sender As Object, e As EventArgs) Handles btnActualizar.Click
- AgregarFechaCO()
- CalcularDividendos()
- End Sub
- Private Sub TabPage3_Click(sender As Object, e As EventArgs) Handles TbDividendos.Click
- End Sub
- Sub LimpiarDividendosCambios(ByVal Calculo As Integer)
- Dim Cantidad As Integer = dgvDividendos.Rows.Count - 2
- For i As Integer = 0 To Cantidad
- If (Calculo = 1) Then
- If (Not dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString.IndexOf("%") = -1) Then
- dgvDividendos.Rows(i).Cells("Dividendo").Value = dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString.ToString.Trim("%")
- End If
- Else
- If (dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString.IndexOf("%") = -1) Then
- dgvDividendos.Rows(i).Cells("Dividendo").Value = dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString + "%"
- End If
- End If
- dgvDividendos.Rows(i).Cells("IngresoBruto").Value = 0
- dgvDividendos.Rows(i).Cells("ISR").Value = 0
- dgvDividendos.Rows(i).Cells("IngresoNeto").Value = 0
- Next
- End Sub
- Sub CargarDividendos()
- Dim Codigo As String = Variables.Codigo
- Dim dr = oAccionesDAO.CargarDividendo(Codigo)
- While dr.Read
- dgvDividendos.Rows.Add("", "", dr("Fecha"), dr("Dividendo"), dr("CantidadBase"), dr("IngresoBruto"), dr("PorcISR"), dr("ISR"), dr("IngresoNeto"), "", dr("FechaInicio"), dr("FechaCorte"), dr("NumDiv"))
- End While
- End Sub
- Private Sub btnGenerarAccion_Click(sender As Object, e As EventArgs)
- End Sub
- Private Sub dgvDividendos_CellMouseMove(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgvDividendos.CellMouseMove
- If Cierre Then
- AgregarFechaCO()
- CalcularDividendos()
- Cierre = False
- End If
- End Sub
- Private Sub dgvDividendos_MouseMove(sender As Object, e As MouseEventArgs) Handles dgvDividendos.MouseMove
- If Cierre Then
- AgregarFechaCO()
- CalcularDividendos()
- Cierre = False
- End If
- End Sub
- Private Sub btnQuitar_Click_1(sender As Object, e As EventArgs) Handles btnQuitar.Click
- QuitarFila()
- CorrelativoSinBD()
- End Sub
- Sub QuitarFila()
- Dim result As Integer = MsgBox("¿Está seguro que desea eliminar la fila?", MsgBoxStyle.OkCancel)
- ' Test result.
- Dim codigo As String = Variables.Codigo
- Dim Numero As Integer = dgvDividendos.CurrentRow.Cells("NumDiv").Value
- If result = MsgBoxResult.Ok Then
- Try
- dgvDividendos.Rows.Remove(dgvDividendos.CurrentRow)
- oAccionesDAO.EliminarElemenoInd(codigo, Numero)
- Catch ex As Exception
- MsgBox("No ha seleccionado una fila")
- End Try
- End If
- End Sub
- Private Sub txtPrecioSucioVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioSucioVenta.TextChanged
- End Sub
- Private Sub txtPrecioLimpioCompra_Leave(sender As Object, e As EventArgs) Handles txtPrecioLimpioCompra.Leave
- Formato()
- End Sub
- Private Sub txtComisionPorcentajeCasaCompra_Leave(sender As Object, e As EventArgs) Handles txtComisionPorcentajeCasaCompra.Leave
- Formato()
- End Sub
- Private Sub txtComisionPorcentajeBolsaCompra_Leave(sender As Object, e As EventArgs) Handles txtComisionPorcentajeBolsaCompra.Leave
- Formato()
- End Sub
- Private Sub txtPrecioLimpioVenta_Leave(sender As Object, e As EventArgs) Handles txtPrecioLimpioVenta.Leave
- Formato()
- End Sub
- Private Sub txtUnidadesVenta_Leave(sender As Object, e As EventArgs) Handles txtUnidadesVenta.Leave
- Formato()
- End Sub
- Private Sub txtComisionPorcentajeCasaVenta_Leave(sender As Object, e As EventArgs) Handles txtComisionPorcentajeCasaVenta.Leave
- Formato()
- End Sub
- Private Sub txtComisionPorcentajeBolsaVenta_Leave(sender As Object, e As EventArgs) Handles txtComisionPorcentajeBolsaVenta.Leave
- Formato()
- End Sub
- Private Sub frmAcciones_Resize(sender As Object, e As EventArgs) Handles MyBase.Resize
- Redimencionar()
- End Sub
- Private Sub txtPrecioLimpioCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioLimpioCompra.KeyUp
- If txtPrecioLimpioCompra.Text = "." Then
- txtPrecioLimpioCompra.Text = ".0"
- End If
- End Sub
- Private Sub txtUnidadesCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtUnidadesCompra.KeyUp
- If txtUnidadesCompra.Text = "." Then
- txtUnidadesCompra.Text = ".0"
- End If
- End Sub
- Private Sub txtComisionPorcentajeCasaCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorcentajeCasaCompra.KeyUp
- If txtComisionPorcentajeCasaCompra.Text = "." Then
- txtComisionPorcentajeCasaCompra.Text = ".0"
- End If
- End Sub
- Private Sub txtComisionPorcentajeBolsaCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorcentajeBolsaCompra.KeyUp
- If txtComisionPorcentajeBolsaCompra.Text = "." Then
- txtComisionPorcentajeBolsaCompra.Text = ".0"
- End If
- End Sub
- Private Sub txtPrecioLimpioVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioLimpioVenta.KeyUp
- If txtPrecioLimpioVenta.Text = "." Then
- txtPrecioLimpioVenta.Text = ".0"
- End If
- End Sub
- Private Sub txtUnidadesVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtUnidadesVenta.KeyUp
- If txtUnidadesVenta.Text = "." Then
- txtUnidadesVenta.Text = ".0"
- End If
- End Sub
- Private Sub txtComisionPorcentajeCasaVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorcentajeCasaVenta.KeyUp
- If txtComisionPorcentajeCasaVenta.Text = "." Then
- txtComisionPorcentajeCasaVenta.Text = ".0"
- End If
- End Sub
- Private Sub txtComisionPorcentajeBolsaVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorcentajeBolsaVenta.KeyUp
- If txtComisionPorcentajeBolsaVenta.Text = "." Then
- txtComisionPorcentajeBolsaVenta.Text = ".0"
- End If
- End Sub
- Private Sub btnVenta_Click(sender As Object, e As EventArgs)
- End Sub
- Private Sub txtValorTransadoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtValorTransadoCompra.TextChanged
- 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
- txtPrecioLimpioCompra.Text = Variables.RetPrecio
- txtUnidadesCompra.Text = Variables.RetUnidadesAcciones
- ElseIf TipoTransaccionCompraVenta = "V" Then
- txtPrecioLimpioVenta.Text = Variables.RetPrecio
- txtUnidadesVenta.Text = Variables.RetUnidadesAcciones
- 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"
- Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
- TrasladarDatos = RellenarDatosCMVTA()
- 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.FechaOperacionACC = Operaciones.ConvertirFecha(dtpFechaOperacionCompra.Value.ToString)
- TrasladarDatos.FechaVencimientoACC = Operaciones.ConvertirFecha(dtpFechaVencimientoCompra.Value.ToString)
- TrasladarDatos.PrecioLimpioACC = Operaciones.ConvertirDecimal(txtPrecioLimpioCompra.Text.ToString)
- TrasladarDatos.UnidadesACC = Operaciones.ConvertirEntero(txtUnidadesCompra.Text.ToString)
- TrasladarDatos.PorcentajeBolsaACC = Operaciones.ConvertirDecimal(txtComisionPorcentajeBolsaCompra.Text.ToString)
- TrasladarDatos.PorcentajeCasaACC = Operaciones.ConvertirDecimal(txtComisionPorcentajeCasaCompra.Text.ToString)
- TrasladarDatos.NombreInstrumento = "ACC"
- TrasladarDatos.AgregarCMVTA = True
- Return TrasladarDatos
- End Function
- Private Sub txtValorTransadoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtValorTransadoVenta.TextChanged
- End Sub
- Private Sub txtMontoNetoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtMontoNetoVenta.TextChanged
- End Sub
- Private Sub txtComisionCasaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtComisionCasaCompra.TextChanged
- End Sub
- Private Sub txtComisionCasaVenta_TextChanged(sender As Object, e As EventArgs) Handles txtComisionCasaVenta.TextChanged
- End Sub
- End Class
|