frmAcciones.vb 87 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635
  1. 
  2. Imports System.Data.OleDb
  3. Imports System.IO
  4. Public Class frmAcciones
  5. Private TipoOperacion As String
  6. Public Sub New()
  7. ' Esta llamada es exigida por el diseñador.
  8. InitializeComponent()
  9. ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
  10. End Sub
  11. Public Sub New(ByVal ConsTOperacion As String)
  12. ' Esta llamada es exigida por el diseñador.
  13. InitializeComponent()
  14. TOperacion(ConsTOperacion)
  15. TipoOperacion = ConsTOperacion
  16. ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
  17. End Sub
  18. Dim Cargar As Boolean = True
  19. Dim oAccionesCE As AccionesCE = New AccionesCE
  20. Dim oAccionesDAO As New AccionesDAO
  21. Dim oDAOGeneral As New DAOGeneral
  22. Dim Estado As String = ""
  23. Dim MostrarMensaje As Boolean = False
  24. Dim CambioCalculo = False
  25. Dim Operaciones As New Operaciones
  26. Dim InstrumentoFinanciero As String = oDAOGeneral.ObtenerInstrumento(Variables.Codigo)
  27. Dim Cargado As Boolean = False
  28. Dim DatosCargados As Boolean = False
  29. Private _IdDocumento As Integer
  30. Private _TipoDocumento As String
  31. Private _CodigoInversion As String
  32. Private _TipoTransaccion As String
  33. Public Property TipoTransaccion As String
  34. Get
  35. Return _TipoTransaccion
  36. End Get
  37. Set(value As String)
  38. _TipoTransaccion = value
  39. End Set
  40. End Property
  41. Private Property IdDocumento As Integer
  42. Get
  43. Return _IdDocumento
  44. End Get
  45. Set(value As Integer)
  46. _IdDocumento = value
  47. End Set
  48. End Property
  49. Private Property TipoDocumento As String
  50. Get
  51. Return _TipoDocumento
  52. End Get
  53. Set(value As String)
  54. _TipoDocumento = value
  55. End Set
  56. End Property
  57. Private Property CodigoInversion As String
  58. Get
  59. Return _CodigoInversion
  60. End Get
  61. Set(value As String)
  62. _CodigoInversion = value
  63. End Set
  64. End Property
  65. Sub Instrumento()
  66. If (InstrumentoFinanciero = "ACCNC") Then
  67. lblTitulo.Text = "Acciones Nacionales Comunes"
  68. Me.Text = "Acciones Nacionales Comunes"
  69. ElseIf (InstrumentoFinanciero = "ACCNP") Then
  70. lblTitulo.Text = "Acciones Preferentes Nacionales"
  71. ModificacionesPreferentes()
  72. Me.Text = "Acciones Preferentes Nacionales"
  73. ElseIf (InstrumentoFinanciero = "ACCI") Then
  74. lblTitulo.Text = "Acciones Internacionales"
  75. Me.Text = "Acciones Internacionales"
  76. End If
  77. End Sub
  78. Function ColeccionDatos()
  79. Dim coleccion As New Collection
  80. Dim PrecioLimpioC, FOperC, FLiqC, DiasTC, GCapTotC, GCapUnC, RetAnNetC, UnC, ValTransC, MontoNetoC, PrecSucioC
  81. Dim PrecioLimpioV, FOperV, FLiqV, DiasTV, GCapTotV, GCapUnV, RetAnBrV, RetAnNetV, UnV, ValTransV, MontoNetoV, PrecSucioV
  82. Dim ComisionCompraCasa, ComisionCompraBolsa, ComisionVentaCasa, ComisionVentaBolsa As Double
  83. Dim IOF, Renta, Tipo, RetornoBruto
  84. Dim ComisionCompraCasaValor, ComisionCompraBolsaValor, ComisionVentaCasaValor, ComisionVentaBolsaValor As Double
  85. PrecioLimpioC = Operaciones.ConvertirDecimal(txtPrecioLimpioCompra.Text.ToString)
  86. FOperC = Operaciones.ConvertirFecha(dtpFechaOperacionCompra.Value.ToString)
  87. FLiqC = Operaciones.ConvertirFecha(dtpFechaVencimientoCompra.Value.ToString)
  88. DiasTC = Operaciones.ConvertirEntero(txtDiasDeTenenciaCompra.Text.ToString)
  89. GCapTotC = Operaciones.ConvertirDecimal(txtGananciaCapitalTotalCompra.Text.ToString)
  90. GCapUnC = Operaciones.ConvertirDecimal(txtGananciaCapitalUnitarioCompra.Text.ToString)
  91. RetAnNetC = Operaciones.ConvertirDecimal(txtRetornoAnualNetoCompra.Text.ToString)
  92. UnC = Operaciones.ConvertirEntero(txtUnidadesCompra.Text.ToString)
  93. ValTransC = Operaciones.ConvertirDecimal(txtValorTransadoCompra.Text.ToString)
  94. MontoNetoC = Operaciones.ConvertirDecimal(txtMontoNetoCompra.Text.ToString)
  95. PrecSucioC = Operaciones.ConvertirDecimal(txtPrecioSucioCompra.Text.ToString)
  96. PrecioLimpioV = Operaciones.ConvertirDecimal(txtPrecioLimpioVenta.Text.ToString)
  97. FOperV = Operaciones.ConvertirFecha(dtpFechaOperacionVenta.Value.ToString)
  98. FLiqV = Operaciones.ConvertirFecha(dtpFechaVencimientoVenta.Value.ToString)
  99. DiasTV = Operaciones.ConvertirEntero(txtDiasDeTenenciaVenta.Text.ToString)
  100. GCapTotV = Operaciones.ConvertirDecimal(txtGananciaCapitalTotalVenta.Text.ToString)
  101. GCapUnV = Operaciones.ConvertirDecimal(txtGananciaCapitalUnitarioVenta.Text.ToString)
  102. RetAnBrV = Operaciones.ConvertirDecimal(txtRetornoAnualBrutoVenta.Text.ToString)
  103. RetAnNetV = Operaciones.ConvertirDecimal(txtRetornoAnualNetoVenta.Text.ToString)
  104. UnV = Operaciones.ConvertirEntero(txtUnidadesVenta.Text.ToString)
  105. ValTransV = Operaciones.ConvertirDecimal(txtValorTransadoVenta.Text.ToString)
  106. MontoNetoV = Operaciones.ConvertirDecimal(txtMontoNetoVenta.Text.ToString)
  107. PrecSucioV = Operaciones.ConvertirDecimal(txtPrecioSucioVenta.Text.ToString)
  108. ComisionCompraCasa = Operaciones.ConvertirDecimal(txtComisionPorcentajeCasaCompra.Text.ToString) / 100
  109. ComisionCompraBolsa = Operaciones.ConvertirDecimal(txtComisionPorcentajeBolsaCompra.Text.ToString) / 100
  110. ComisionVentaCasa = Operaciones.ConvertirDecimal(txtComisionPorcentajeCasaVenta.Text.ToString) / 100
  111. ComisionVentaBolsa = Operaciones.ConvertirDecimal(txtComisionPorcentajeBolsaVenta.Text.ToString) / 100
  112. ComisionCompraCasaValor = Operaciones.ConvertirDecimal(txtComisionCasaCompra.Text.ToString)
  113. ComisionCompraBolsaValor = Operaciones.ConvertirDecimal(txtComisionBolsaCompra.Text.ToString)
  114. ComisionVentaCasaValor = Operaciones.ConvertirDecimal(txtComisionCasaVenta.Text.ToString)
  115. ComisionVentaBolsaValor = Operaciones.ConvertirDecimal(txtComisionBolsaVenta.Text.ToString)
  116. RetornoBruto = Operaciones.ConvertirDecimal(txtRetornoAnualBrutoCompra.Text.ToString) / 100
  117. If (ChkIOF.Checked) Then
  118. IOF = 1
  119. Else
  120. IOF = 0
  121. End If
  122. If (ChkRenta.Checked) Then
  123. Renta = 1
  124. Else
  125. Renta = 0
  126. End If
  127. If rdbPorcentaje.Checked Then
  128. Tipo = "Porcentaje"
  129. Else
  130. Tipo = "Efectivo"
  131. End If
  132. coleccion.Add(PrecioLimpioC)
  133. coleccion.Add(FOperC)
  134. coleccion.Add(FLiqC)
  135. coleccion.Add(DiasTC)
  136. coleccion.Add(GCapTotC)
  137. coleccion.Add(GCapUnC)
  138. coleccion.Add(RetornoBruto)
  139. coleccion.Add(RetAnNetC)
  140. coleccion.Add(UnC)
  141. coleccion.Add(ValTransC)
  142. coleccion.Add(MontoNetoC)
  143. coleccion.Add(PrecSucioC)
  144. coleccion.Add(PrecioLimpioV)
  145. coleccion.Add(FOperV)
  146. coleccion.Add(FLiqV)
  147. coleccion.Add(DiasTV)
  148. coleccion.Add(GCapTotV)
  149. coleccion.Add(GCapUnV)
  150. coleccion.Add(RetAnBrV)
  151. coleccion.Add(RetAnNetV)
  152. coleccion.Add(UnV)
  153. coleccion.Add(ValTransV)
  154. coleccion.Add(MontoNetoV)
  155. coleccion.Add(PrecSucioV)
  156. coleccion.Add(ComisionCompraCasa)
  157. coleccion.Add(ComisionCompraBolsa)
  158. coleccion.Add(ComisionVentaCasa)
  159. coleccion.Add(ComisionVentaBolsa)
  160. coleccion.Add(IOF)
  161. coleccion.Add(Renta)
  162. coleccion.Add(Tipo)
  163. coleccion.Add(ComisionCompraCasaValor)
  164. coleccion.Add(ComisionCompraBolsaValor)
  165. coleccion.Add(ComisionVentaCasaValor)
  166. coleccion.Add(ComisionVentaBolsaValor)
  167. Return coleccion
  168. End Function
  169. Function Correlativo()
  170. Dim Index As Integer = 0
  171. Dim IndexCantidad As Integer = dgvDividendos.Rows.Count - 2
  172. Dim NumeroMayor As Integer = 0
  173. While Index <= IndexCantidad
  174. Dim Numero As Integer = dgvDividendos.Rows(Index).Cells("NumDiv").Value
  175. If Numero > NumeroMayor Then
  176. NumeroMayor = Numero
  177. End If
  178. Index += 1
  179. End While
  180. Return NumeroMayor + 1
  181. End Function
  182. Sub CorrelativoSinBD()
  183. Dim Index As Integer = 0
  184. Dim IndexCantidad As Integer = dgvDividendos.Rows.Count - 2
  185. Dim NumeroMayor As Integer = 0
  186. While Index <= IndexCantidad
  187. dgvDividendos.Rows(Index).Cells("Correlativo").Value = Index + 1
  188. Index += 1
  189. End While
  190. End Sub
  191. Function ColeccionesElementos(ByVal Index As Integer)
  192. Dim coleccion As New Collection
  193. Dim Fecha, Estado, Dividendo, CantidadBase, IngresoBruto, PorcISR, ISR, IngresoNeto, Correlativo, Tipo, FechaInicio, FechaCorte
  194. If rdbPorcentaje.Checked Then
  195. Tipo = "Porcentaje"
  196. Else
  197. Tipo = "Efectivo"
  198. End If
  199. Fecha = Operaciones.ConvertirFecha(dgvDividendos.Rows(Index).Cells("Fecha").Value.ToString)
  200. Dividendo = Operaciones.ConvertirDecimal(dgvDividendos.Rows(Index).Cells("Dividendo").Value.ToString)
  201. If (Tipo = "Porcentaje") Then
  202. Dividendo /= 100
  203. End If
  204. CantidadBase = Operaciones.ConvertirDecimal(dgvDividendos.Rows(Index).Cells("CantidadBase").Value.ToString)
  205. IngresoBruto = Operaciones.ConvertirDecimal(dgvDividendos.Rows(Index).Cells("IngresoBruto").Value.ToString)
  206. PorcISR = Operaciones.ConvertirDecimal(dgvDividendos.Rows(Index).Cells("PorcISR").Value.ToString)
  207. ISR = Operaciones.ConvertirDecimal(dgvDividendos.Rows(Index).Cells("ISR").Value.ToString)
  208. IngresoNeto = Operaciones.ConvertirDecimal(dgvDividendos.Rows(Index).Cells("IngresoNeto").Value.ToString)
  209. Estado = "A"
  210. Correlativo = Operaciones.ConvertirEntero(dgvDividendos.Rows(Index).Cells("NumDiv").Value.ToString)
  211. FechaInicio = Operaciones.ConvertirFechaBaseDatos(dgvDividendos.Rows(Index).Cells("FechaInicio").Value.ToString)
  212. FechaCorte = Operaciones.ConvertirFechaBaseDatos(dgvDividendos.Rows(Index).Cells("FechaCorte").Value.ToString)
  213. If (Tipo = "Porcentaje") Then
  214. If FechaInicio Is DBNull.Value Or FechaCorte Is DBNull.Value Then
  215. MsgBox("Verifique las fechas")
  216. Return coleccion
  217. Else
  218. If (String.IsNullOrEmpty(FechaInicio) Or String.IsNullOrEmpty(FechaCorte)) Then
  219. MsgBox("Verifique las fechas")
  220. Return coleccion
  221. End If
  222. End If
  223. End If
  224. coleccion.Add(Fecha)
  225. coleccion.Add(Dividendo)
  226. coleccion.Add(CantidadBase)
  227. coleccion.Add(IngresoBruto)
  228. coleccion.Add(PorcISR)
  229. coleccion.Add(ISR)
  230. coleccion.Add(IngresoNeto)
  231. coleccion.Add(Estado)
  232. coleccion.Add(Correlativo)
  233. coleccion.Add(FechaInicio)
  234. coleccion.Add(FechaCorte)
  235. Return coleccion
  236. End Function
  237. Function ColeccionNuevo(ByVal codigo As String)
  238. Dim i As Integer = 0
  239. Dim diccionario As New Dictionary(Of String, Collection)
  240. Dim Index = dgvDividendos.Rows.Count - 2
  241. While i <= Index
  242. Dim coleccion = ColeccionesElementos(i)
  243. diccionario.Add(i, coleccion)
  244. i += 1
  245. End While
  246. Return diccionario
  247. End Function
  248. Public Function NuevaAccion()
  249. Dim Coleccion = ColeccionDatos()
  250. Return Coleccion
  251. End Function
  252. Sub Eliminar()
  253. Dim Codigo = Variables.Codigo
  254. oAccionesDAO.Eliminar(Codigo)
  255. End Sub
  256. Sub ModificacionesPreferentes()
  257. GrpVenta.Visible = False
  258. txtRetornoAnualBrutoCompra.Visible = True
  259. txtRetornoAnualBrutoCompra.ReadOnly = False
  260. txtRetornoAnualBrutoCompra.Text = "0.0"
  261. Label19.Visible = False
  262. End Sub
  263. Sub Redimencionar()
  264. dgvDividendos.Width = Me.Width - 10
  265. dgvDividendos.Height = Me.Height - 50
  266. End Sub
  267. Private Sub frmAcciones_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  268. Dim VExisteInversion As Boolean = False
  269. VExisteInversion = ExisteInversion()
  270. If VExisteInversion Then
  271. TipoOperacion = "C"
  272. TipoTransaccion = "C"
  273. Else
  274. TipoOperacion = String.Empty
  275. TipoTransaccion = String.Empty
  276. End If
  277. If Variables.TipoOperacionCMVTA = "C" Then
  278. GrpVenta.Enabled = False
  279. GrpCompra.Enabled = True
  280. Else
  281. GrpVenta.Enabled = True
  282. GrpCompra.Enabled = False
  283. End If
  284. Call Instrumento()
  285. HabilitarBotones()
  286. PrepararTablaDividendos()
  287. If VExisteInversion Then
  288. TipoOperacion = "C"
  289. TipoTransaccion = "C"
  290. Else
  291. TipoOperacion = String.Empty
  292. TipoTransaccion = String.Empty
  293. End If
  294. If TipoTransaccion = "C" Then
  295. Call CargarRegistroBD()
  296. Formato()
  297. ValidarRentaIOF()
  298. CargarDividendos()
  299. End If
  300. ModificarDividendo()
  301. CalcularDividendos()
  302. Cargado = True
  303. ValidarExistencia()
  304. Formato()
  305. DatosCargados = True
  306. CargarTransladoNuevo()
  307. ConfiguracionCMVTA(VExisteInversion)
  308. End Sub
  309. Sub ConfiguracionCMVTA(ByRef VExisteInversion As Boolean)
  310. Dim Codigo As String = Variables.Codigo
  311. Dim ExisteCMVTA As Boolean = oDAOGeneral.ExisteCMVTA(Codigo)
  312. If Not ExisteCMVTA And Variables.InvocadorProInv = "frmINV" Then
  313. btnVenderTitulo.Visible = True
  314. End If
  315. If CantFormAbierto = False And Not VExisteInversion Then
  316. If Not Variables.TrasladarCMVTA Is Nothing Then
  317. dtpFechaOperacionCompra.Value = Operaciones.ConvertirFecha(Variables.TrasladarCMVTA.FechaOperacionACC.ToString)
  318. dtpFechaVencimientoCompra.Value = Operaciones.ConvertirFecha(Variables.TrasladarCMVTA.FechaVencimientoACC.ToString)
  319. txtPrecioLimpioCompra.Text = Operaciones.ConvertirDecimal(Variables.TrasladarCMVTA.PrecioLimpioACC.ToString)
  320. txtUnidadesCompra.Text = Operaciones.ConvertirEntero(Variables.TrasladarCMVTA.UnidadesACC.ToString)
  321. txtComisionPorcentajeCasaCompra.Text = Operaciones.ConvertirDecimal(Variables.TrasladarCMVTA.PorcentajeCasaACC.ToString)
  322. txtComisionPorcentajeBolsaCompra.Text = Operaciones.ConvertirDecimal(Variables.TrasladarCMVTA.PorcentajeBolsaACC.ToString)
  323. End If
  324. End If
  325. End Sub
  326. Function ExisteInversion()
  327. Dim Codigo As String = Variables.Codigo
  328. Dim TablaINV As String = "INV0"
  329. Dim TablaPINV As String = "PIN0"
  330. Dim General As New DAOGeneral
  331. Dim InvPro = Variables.InvPro
  332. If InvPro = "I" Then
  333. Dim INV0 As Boolean = General.ExisteTitulo(Codigo, TablaINV)
  334. If INV0 Then
  335. navNuevo.Visible = True
  336. Return True
  337. Else
  338. navNuevo.Visible = False
  339. Return False
  340. End If
  341. End If
  342. If InvPro = "P" Then
  343. Dim PINV0 As Boolean = General.ExisteTitulo(Codigo, TablaPINV)
  344. If PINV0 Then
  345. navNuevo.Visible = True
  346. Return True
  347. Else
  348. navNuevo.Visible = False
  349. Return False
  350. End If
  351. End If
  352. Return False
  353. End Function
  354. Sub ModificarDividendo()
  355. Dim Cantidad As Integer = dgvDividendos.Rows.Count - 2
  356. For i As Integer = 0 To Cantidad
  357. If rdbPorcentaje.Checked Then
  358. dgvDividendos.Rows(i).Cells("Dividendo").Value *= 100
  359. End If
  360. Next
  361. End Sub
  362. Private Sub chkAccionPreferente_CheckedChanged(sender As Object, e As EventArgs)
  363. End Sub
  364. Private Sub btnAceptar_Click(sender As Object, e As EventArgs) Handles btnAceptar.Click
  365. Dim codigo As String = Variables.Codigo
  366. Dim Accion As Collection = NuevaAccion()
  367. Dim ElementosAccion As Dictionary(Of String, Collection) = ColeccionNuevo(codigo)
  368. If (Estado = "N") Then
  369. oAccionesDAO.ProcesoDatos(Accion, codigo, ElementosAccion, "Nuevo")
  370. ElseIf Not ExisteValidacion() Then
  371. Variables.ColeccionACC = NuevaAccion()
  372. Me.Close()
  373. End If
  374. If Estado = "M" Then
  375. oAccionesDAO.ProcesoDatos(Accion, codigo, ElementosAccion, "Modificar")
  376. End If
  377. If Estado = "B" Then
  378. Eliminar()
  379. End If
  380. ValidarExistencia()
  381. End Sub
  382. Sub ValidarExistencia()
  383. Dim General As New DAOGeneral
  384. Dim Codigo As String = Variables.Codigo
  385. Dim Tabla As String = String.Empty
  386. Tabla = "ACC0"
  387. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  388. If (Existe) Then
  389. navNuevo.Enabled = False
  390. TbDividendos.Enabled = True
  391. navModificar.Enabled = True
  392. navEliminar.Enabled = True
  393. Else
  394. navNuevo.Enabled = True
  395. TbDividendos.Enabled = False
  396. navModificar.Enabled = False
  397. navEliminar.Enabled = False
  398. DatosCargados = True
  399. End If
  400. TipoTransaccion = String.Empty
  401. btnAceptar.Text = "Aceptar"
  402. End Sub
  403. Function ExisteValidacion()
  404. Dim General As New DAOGeneral
  405. Dim Codigo As String = Variables.Codigo
  406. Dim Tabla As String = String.Empty
  407. Tabla = "ACC0"
  408. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  409. Return Existe
  410. End Function
  411. Public Function RetornarObjeto()
  412. Return oAccionesCE
  413. End Function
  414. Private Sub CargarRegistroBD()
  415. oAccionesCE = Nothing
  416. CodigoInversion = Variables.Codigo
  417. oAccionesCE = oAccionesDAO.CargarRegistro(Me.CodigoInversion)
  418. TipoTransaccion = "C"
  419. RefrescarValorControlesInicial()
  420. End Sub
  421. Public Sub CargarRegistro(vId As Integer, vTipo As String)
  422. TipoTransaccion = "C"
  423. IdDocumento = vId
  424. TipoDocumento = vTipo
  425. End Sub
  426. Public Sub CargarRegistro(ByRef vCodigoInversion As String)
  427. TipoTransaccion = "C"
  428. Me.CodigoInversion = vCodigoInversion
  429. End Sub
  430. Private Sub txtDiasDeTenencia_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtDiasDeTenenciaCompra.TextChanged
  431. End Sub
  432. Private Sub txtGananciaCapitalTotal_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtGananciaCapitalTotalCompra.TextChanged
  433. End Sub
  434. Private Sub txtGananciaCapitalUnitario_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtGananciaCapitalUnitarioCompra.TextChanged
  435. End Sub
  436. Private Sub txtRetornoAnualBruto_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtRetornoAnualBrutoCompra.TextChanged
  437. If (txtRetornoAnualBrutoCompra.ToString.IndexOf("%") = -1) Then
  438. txtRetornoAnualBrutoCompra.Text += "%"
  439. End If
  440. If (String.IsNullOrEmpty(txtRetornoAnualBrutoCompra.Text.ToString.Trim("%"))) Then
  441. txtRetornoAnualBrutoCompra.Text = "0.0%"
  442. End If
  443. End Sub
  444. Private Sub txtRetornoAnualNeto_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtRetornoAnualNetoCompra.TextChanged
  445. End Sub
  446. Private Sub cboCasa_C_SelectedIndexChanged(sender As Object, e As EventArgs)
  447. End Sub
  448. Private Sub txtPrecioSucio_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioSucioCompra.TextChanged
  449. End Sub
  450. Private Sub txtGananciaCapitalUnitario_Venta_TextChanged(sender As Object, e As EventArgs) Handles txtGananciaCapitalUnitarioVenta.TextChanged
  451. End Sub
  452. Private Sub txtRetornoAnualBruto_Venta_TextChanged(sender As Object, e As EventArgs) Handles txtRetornoAnualBrutoVenta.TextChanged
  453. End Sub
  454. Private Sub txtRetornoAnualNeto_Venta_TextChanged(sender As Object, e As EventArgs) Handles txtRetornoAnualNetoVenta.TextChanged
  455. End Sub
  456. Private Sub cboCasa_V_SelectedIndexChanged(sender As Object, e As EventArgs)
  457. End Sub
  458. '********** CONTROL DE VALORES **********
  459. 'COMPRA
  460. Private Sub ControlPrecioLimpioCompra()
  461. If DatosCargados Then
  462. Dim valor As Double = 0
  463. If Not Double.TryParse(Me.txtPrecioLimpioCompra.Text, valor) Then
  464. oAccionesCE.PrecioLimpioVenta = "0.0"
  465. Else
  466. oAccionesCE.PrecioLimpioCompra = valor
  467. Me.txtPrecioLimpioCompra.BackColor = Color.White
  468. If (Me.TipoTransaccion = "N") Then
  469. oAccionesCE.PrecioLimpioVenta = oAccionesCE.PrecioLimpioCompra
  470. End If
  471. RefrescarValorControles()
  472. End If
  473. End If
  474. End Sub
  475. Private Sub ControlFechaOperacionCompra()
  476. oAccionesCE.FechaOperacionCompra = Me.dtpFechaOperacionCompra.Value.Date
  477. RefrescarValorControles()
  478. End Sub
  479. Private Sub ControlFechaLiquidacionCompra()
  480. oAccionesCE.FechaVencimientoCompra = Me.dtpFechaVencimientoCompra.Value.Date
  481. RefrescarValorControles()
  482. End Sub
  483. Private Sub ControlCantidadCompra()
  484. Dim valor As Integer = 0
  485. If Not Integer.TryParse(Me.txtUnidadesCompra.Text, valor) Then
  486. oAccionesCE.CantidadCompra = "0"
  487. Else
  488. Me.txtUnidadesCompra.BackColor = Color.White
  489. oAccionesCE.CantidadCompra = valor
  490. If (Me.TipoTransaccion = "N" Or TipoTransaccion = "A") Then
  491. oAccionesCE.CantidadVenta = oAccionesCE.CantidadCompra
  492. End If
  493. RefrescarValorControles()
  494. End If
  495. End Sub
  496. 'VENTA
  497. Private Sub ControlPrecioLimpioVenta()
  498. If DatosCargados Then
  499. Dim valor As Double
  500. If Not Double.TryParse(Me.txtPrecioLimpioVenta.Text, valor) Then
  501. oAccionesCE.PrecioLimpioVenta = "0.0"
  502. Else
  503. Me.txtPrecioLimpioVenta.BackColor = Color.White
  504. oAccionesCE.PrecioLimpioVenta = valor
  505. End If
  506. RefrescarValorControles()
  507. End If
  508. End Sub
  509. Private Sub ControlFechaOperacionVenta()
  510. oAccionesCE.FechaOperacionVenta = dtpFechaOperacionVenta.Value.Date
  511. RefrescarValorControles()
  512. End Sub
  513. Private Sub ControlFechaLiquidacionVenta()
  514. oAccionesCE.FechaVencimientoVenta = dtpFechaVencimientoVenta.Value.Date
  515. RefrescarValorControles()
  516. End Sub
  517. Private Sub ControlCantidadVenta()
  518. Dim valor As Integer
  519. If Not Integer.TryParse(Me.txtUnidadesVenta.Text, valor) Then
  520. Me.txtUnidadesVenta.Text = "0"
  521. oAccionesCE.CantidadVenta = "0"
  522. Else
  523. Me.txtUnidadesVenta.BackColor = Color.White
  524. oAccionesCE.CantidadVenta = valor
  525. End If
  526. RefrescarValorControles()
  527. End Sub
  528. '********** FIN CONTROL DE VALORES **********
  529. '********** EVENTOS DE CONTROLES **********
  530. 'COMPRA
  531. Private Sub txtPrecioLimpioCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioLimpioCompra.TextChanged
  532. ControlPrecioLimpioCompra()
  533. End Sub
  534. Private Sub txtPrecioLimpioCompra_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioLimpioCompra.LostFocus
  535. ControlPrecioLimpioCompra()
  536. End Sub
  537. Private Sub dtpFechaOperacionCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaOperacionCompra.ValueChanged
  538. If DatosCargados Then
  539. ControlFechaOperacionCompra()
  540. RefrescarValorControles()
  541. Formato()
  542. End If
  543. End Sub
  544. Private Sub dtpFechaLiquidacionCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimientoCompra.ValueChanged
  545. If DatosCargados Then
  546. ControlFechaLiquidacionCompra()
  547. RefrescarValorControles()
  548. Formato()
  549. End If
  550. End Sub
  551. Private Sub txtUnidadesCompra_TextChanged(sender As Object, e As EventArgs) Handles txtUnidadesCompra.TextChanged
  552. If DatosCargados Then
  553. ControlCantidadCompra()
  554. CopiarDatos()
  555. End If
  556. End Sub
  557. Sub CopiarDatos()
  558. txtUnidadesVenta.Text = txtUnidadesCompra.Text
  559. End Sub
  560. Private Sub txtUnidadesCompra_LostFocus(sender As Object, e As EventArgs) Handles txtUnidadesCompra.LostFocus
  561. ControlCantidadCompra()
  562. End Sub
  563. 'VENTA
  564. Private Sub txtPrecioLimpioVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioLimpioVenta.TextChanged
  565. ControlPrecioLimpioVenta()
  566. End Sub
  567. Private Sub txtPrecioLimpioVenta_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioLimpioVenta.LostFocus
  568. ControlPrecioLimpioVenta()
  569. End Sub
  570. Private Sub dtpFechaOperacionVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaOperacionVenta.ValueChanged
  571. If DatosCargados Then
  572. ControlFechaOperacionVenta()
  573. RefrescarValorControles()
  574. End If
  575. End Sub
  576. Private Sub dtpFechaLiquidacionVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimientoVenta.ValueChanged
  577. If DatosCargados Then
  578. ControlFechaLiquidacionVenta()
  579. RefrescarValorControles()
  580. End If
  581. End Sub
  582. Private Sub txtUnidadesVenta_TextChanged(sender As Object, e As EventArgs) Handles txtUnidadesVenta.TextChanged
  583. If DatosCargados Then
  584. ControlCantidadVenta()
  585. MensajeAlerta()
  586. MostrarMensaje = True
  587. End If
  588. End Sub
  589. Sub MensajeAlerta()
  590. If (MostrarMensaje) Then
  591. Dim UnidadesVenta As Integer = 0
  592. Dim UnidadesCompra As Integer = 0
  593. If Not String.IsNullOrEmpty(txtUnidadesVenta.Text) Then
  594. UnidadesVenta = txtUnidadesVenta.Text
  595. End If
  596. If Not String.IsNullOrEmpty(txtUnidadesCompra.Text) Then
  597. UnidadesCompra = txtUnidadesCompra.Text
  598. End If
  599. If (Operaciones.ConvertirDecimal(UnidadesVenta.ToString) > Operaciones.ConvertirDecimal(UnidadesCompra.ToString)) Then
  600. MsgBox("Esta Tratando de Ingresar más acciones de las compradas, verifique los datos si ha cometido algún error.")
  601. End If
  602. End If
  603. End Sub
  604. Private Sub txtUnidadesVenta_LostFocus(sender As Object, e As EventArgs) Handles txtUnidadesVenta.LostFocus
  605. ControlCantidadVenta()
  606. End Sub
  607. Private Sub chkBolsa_CheckedChanged(sender As Object, e As EventArgs)
  608. End Sub
  609. '********** FIN EVENTOS DE CONTROLES **********
  610. '********** FUNCIONES **********
  611. Private Sub Formato()
  612. If DatosCargados Then
  613. Me.txtRetornoAnualBrutoCompra.Text = Operaciones.ConvertirDecimal(Me.txtRetornoAnualBrutoCompra.Text.ToString)
  614. Me.txtComisionPorcentajeCasaCompra.Text = Operaciones.ConvertirDecimal(Me.txtComisionPorcentajeCasaCompra.Text.ToString).ToString + " %"
  615. Me.txtComisionPorcentajeBolsaCompra.Text = Operaciones.ConvertirDecimal(Me.txtComisionPorcentajeBolsaCompra.Text.ToString).ToString + " %"
  616. Me.txtComisionPorcentajeCasaVenta.Text = Operaciones.ConvertirDecimal(Me.txtComisionPorcentajeCasaVenta.Text.ToString).ToString + " %"
  617. Me.txtComisionPorcentajeBolsaVenta.Text = Operaciones.ConvertirDecimal(Me.txtComisionPorcentajeBolsaVenta.Text.ToString).ToString + " %"
  618. Me.txtComisionPorcentajeBolsaCompra.Text = Operaciones.ConvertirDecimal(Me.txtComisionPorcentajeBolsaCompra.Text.ToString).ToString + " %"
  619. Me.txtComisionPorcentajeBolsaVenta.Text = Operaciones.ConvertirDecimal(Me.txtComisionPorcentajeBolsaVenta.Text.ToString).ToString + " %"
  620. txtRetornoAnualBrutoVenta.Text = Operaciones.ConvertirDecimal(txtRetornoAnualBrutoVenta.Text.ToString)
  621. txtPrecioLimpioCompra.Text = Operaciones.ConvertirDecimal(txtPrecioLimpioCompra.Text.ToString)
  622. txtPrecioLimpioVenta.Text = Operaciones.ConvertirDecimal(txtPrecioLimpioVenta.Text.ToString)
  623. txtUnidadesCompra.Text = Operaciones.ConvertirEntero(txtUnidadesCompra.Text.ToString)
  624. txtUnidadesVenta.Text = Operaciones.ConvertirEntero(txtUnidadesVenta.Text.ToString)
  625. If (txtComisionPorcentajeCasaVenta.ToString.IndexOf("%") = -1) Then
  626. txtComisionPorcentajeCasaVenta.Text += "%"
  627. End If
  628. If (txtComisionPorcentajeBolsaVenta.ToString.IndexOf("%") = -1) Then
  629. txtComisionPorcentajeBolsaVenta.Text += "%"
  630. End If
  631. If String.IsNullOrEmpty(txtGananciaCapitalUnitarioVenta.Text) Then
  632. txtGananciaCapitalUnitarioVenta.Text = 0
  633. End If
  634. If String.IsNullOrEmpty(txtRetornoAnualNetoVenta.Text) Then
  635. txtRetornoAnualNetoVenta.Text = 0
  636. End If
  637. End If
  638. End Sub
  639. Sub RefrescarValorControlesInicial()
  640. Me.txtRetornoAnualBrutoCompra.Text = oAccionesCE.RetornoBruto * 100
  641. Dim IOF = oAccionesCE.IOF
  642. Dim Renta = oAccionesCE.Renta
  643. If (IOF) Then
  644. ChkIOF.Checked = True
  645. Else
  646. ChkIOF.Checked = False
  647. End If
  648. If (Renta) Then
  649. ChkRenta.Checked = True
  650. Else
  651. ChkRenta.Checked = False
  652. End If
  653. Me.txtComisionPorcentajeCasaCompra.Text = CStr(oAccionesCE.ComisionPorcentajeCompraCasa * 100) + "%"
  654. Me.txtComisionPorcentajeBolsaCompra.Text = CStr(oAccionesCE.ComisionPorcentajeCompraBolsa * 100) + "%"
  655. Me.txtComisionPorcentajeCasaVenta.Text = CStr(oAccionesCE.ComisionPorcentajeVentaCasa * 100) + "%"
  656. Me.txtComisionPorcentajeBolsaVenta.Text = CStr(oAccionesCE.ComisionPorcentajeVentaBolsa * 100) + "%"
  657. Me.txtComisionCasaCompra.Text = oAccionesCE.ComisionCompraCasa
  658. Me.txtComisionBolsaCompra.Text = oAccionesCE.ComisionCompraBolsa
  659. Me.txtComisionCasaVenta.Text = oAccionesCE.ComisionVentaCasa
  660. Me.txtComisionBolsaVenta.Text = oAccionesCE.ComisionVentaBolsa
  661. If (oAccionesCE.Tipo = "Porcentaje") Then
  662. rdbPorcentaje.Checked = True
  663. ElseIf (oAccionesCE.Tipo = "Efectivo") Then
  664. rdbEfectivo.Checked = True
  665. End If
  666. 'COMPRA
  667. Me.txtPrecioLimpioCompra.Text = oAccionesCE.PrecioLimpioCompra.ToString()
  668. dtpFechaOperacionCompra.Value = CDate(oAccionesCE.FechaOperacionCompra)
  669. dtpFechaVencimientoCompra.Value = CDate(oAccionesCE.FechaVencimientoCompra)
  670. Me.txtDiasDeTenenciaCompra.Text = oAccionesCE.DiasDeTenenciaCompra.ToString
  671. Me.txtGananciaCapitalTotalCompra.Text = oAccionesCE.GananciaDeCapitalTotalCompra.ToString
  672. Me.txtGananciaCapitalUnitarioCompra.Text = oAccionesCE.GananciaDeCapitalUnitarioCompra.ToString
  673. Me.txtRetornoAnualNetoCompra.Text = oAccionesCE.RetornoAnualizadoNetoCompra.ToString()
  674. Me.txtUnidadesCompra.Text = oAccionesCE.CantidadCompra.ToString
  675. Me.txtValorTransadoCompra.Text = oAccionesCE.ValorTransadoCompra.ToString()
  676. Dim ValorIOFCompra = 0.0, ValorRentaCompra = 0.0
  677. Me.txtMontoNetoCompra.Text = oAccionesCE.MontoNetoComprasus
  678. Me.txtPrecioSucioCompra.Text = oAccionesCE.PrecioSucioCompra.ToString()
  679. 'VENTA
  680. Me.txtPrecioLimpioVenta.Text = oAccionesCE.PrecioLimpioVenta.ToString()
  681. Me.dtpFechaOperacionVenta.Value = oAccionesCE.FechaOperacionVenta
  682. Me.dtpFechaVencimientoVenta.Value = oAccionesCE.FechaVencimientoVenta
  683. Me.txtDiasDeTenenciaVenta.Text = oAccionesCE.DiasDeTenenciaVenta.ToString
  684. Me.txtGananciaCapitalTotalVenta.Text = oAccionesCE.GananciaDeCapitalTotalVentasus.ToString()
  685. Me.txtGananciaCapitalUnitarioVenta.Text = oAccionesCE.GananciaDeCapitalUnitarioVenta.ToString
  686. txtRetornoAnualBrutoVenta.Text = oAccionesCE.RetornoAnualizadoBrutoVentasus.ToString
  687. Me.txtRetornoAnualNetoVenta.Text = oAccionesCE.RetornoAnualizadoNetoVenta.ToString()
  688. Me.txtUnidadesVenta.Text = oAccionesCE.CantidadVenta.ToString
  689. Me.txtValorTransadoVenta.Text = oAccionesCE.ValorTransadoVenta.ToString()
  690. Me.txtImpuestosYComisionesVenta.Text = oAccionesCE.SumaImpuestosYComisionesVenta.ToString()
  691. Dim ComisionCasaVenta As Double = 0
  692. Dim ComisionBolsaVenta As Double = 0
  693. Dim ValorTransadoVenta As Double = 0
  694. Dim ValorIOFVenta = 0.0, ValorRentaVenta = 0.0
  695. Me.txtMontoNetoVenta.Text = oAccionesCE.MontoNetoVentasus.ToString
  696. Me.txtPrecioSucioVenta.Text = oAccionesCE.PrecioSucioVentasus.ToString()
  697. End Sub
  698. Sub RefrescarValorControles()
  699. If DatosCargados Then
  700. If (Cargar) Then
  701. Me.txtRetornoAnualBrutoCompra.Text = Operaciones.ConvertirDecimal(oAccionesCE.RetornoBruto.ToString) * 100
  702. txtGananciaCapitalUnitarioVenta.Text = Operaciones.ConvertirDecimal(txtGananciaCapitalUnitarioVenta.Text.ToString)
  703. txtRetornoAnualNetoVenta.Text = Operaciones.ConvertirDecimal(txtRetornoAnualNetoVenta.Text.ToString)
  704. Dim IOF = oAccionesCE.IOF
  705. Dim Renta = oAccionesCE.Renta
  706. If (IOF) Then
  707. ChkIOF.Checked = True
  708. Else
  709. ChkIOF.Checked = False
  710. End If
  711. If (Renta) Then
  712. ChkRenta.Checked = True
  713. Else
  714. ChkRenta.Checked = False
  715. End If
  716. Else
  717. If (oAccionesCE.Tipo = "Porcentaje") Then
  718. rdbPorcentaje.Checked = True
  719. ElseIf (oAccionesCE.Tipo = "Efectivo") Then
  720. rdbEfectivo.Checked = True
  721. End If
  722. End If
  723. 'COMPRA
  724. If (Not String.IsNullOrEmpty(oAccionesCE.PrecioLimpioCompra.ToString())) Then
  725. If Not oAccionesCE.PrecioLimpioCompra.ToString() = "0" Then
  726. Me.txtPrecioLimpioCompra.Text = oAccionesCE.PrecioLimpioCompra.ToString()
  727. End If
  728. End If
  729. If (String.IsNullOrEmpty(oAccionesCE.FechaOperacionCompra)) Then
  730. Me.dtpFechaOperacionCompra.Value = Date.Now.Date
  731. Else
  732. Me.dtpFechaOperacionCompra.Value = oAccionesCE.FechaOperacionCompra
  733. End If
  734. If (String.IsNullOrEmpty(oAccionesCE.FechaVencimientoCompra)) Then
  735. Me.dtpFechaVencimientoCompra.Value = Date.Now.Date
  736. Else
  737. Me.dtpFechaVencimientoCompra.Value = oAccionesCE.FechaVencimientoCompra
  738. End If
  739. If (Not String.IsNullOrEmpty(oAccionesCE.DiasDeTenenciaCompra.ToString)) Then
  740. Me.txtDiasDeTenenciaCompra.Text = oAccionesCE.DiasDeTenenciaCompra.ToString
  741. End If
  742. If (Not String.IsNullOrEmpty(oAccionesCE.GananciaDeCapitalTotalCompra.ToString)) Then
  743. Me.txtGananciaCapitalTotalCompra.Text = oAccionesCE.GananciaDeCapitalTotalCompra.ToString
  744. End If
  745. If (Not String.IsNullOrEmpty(oAccionesCE.GananciaDeCapitalUnitarioCompra.ToString)) Then
  746. Me.txtGananciaCapitalUnitarioCompra.Text = oAccionesCE.GananciaDeCapitalUnitarioCompra.ToString
  747. End If
  748. If (Not String.IsNullOrEmpty(oAccionesCE.RetornoAnualizadoNetoCompra.ToString(Configuraciones.CodigoTXTPorcentaje))) Then
  749. Me.txtRetornoAnualNetoCompra.Text = oAccionesCE.RetornoAnualizadoNetoCompra.ToString()
  750. End If
  751. If (Not String.IsNullOrEmpty(oAccionesCE.CantidadCompra.ToString)) Then
  752. If Not oAccionesCE.CantidadCompra.ToString = "0" Then
  753. Me.txtUnidadesCompra.Text = oAccionesCE.CantidadCompra.ToString
  754. End If
  755. End If
  756. If (Not String.IsNullOrEmpty(oAccionesCE.ValorTransadoCompra.ToString(Configuraciones.CodigoTXTMontos))) Then
  757. Me.txtValorTransadoCompra.Text = oAccionesCE.ValorTransadoCompra.ToString()
  758. End If
  759. Dim ComisionCasaCompra As Double = 0
  760. Dim ComisionBolsaCompra As Double = 0
  761. Dim ValorTransadoCompra As Double = 0
  762. ComisionCasaCompra = Operaciones.ConvertirDecimal(txtComisionPorcentajeCasaCompra.Text.ToString) / 100
  763. ComisionBolsaCompra = Operaciones.ConvertirDecimal(txtComisionPorcentajeBolsaCompra.Text.ToString) / 100
  764. ValorTransadoCompra = Operaciones.ConvertirDecimal(txtValorTransadoCompra.Text.ToString)
  765. Me.txtComisionCasaCompra.Text = CalcularComisionImpuestos(ComisionCasaCompra, txtValorTransadoCompra.Text)
  766. Me.txtComisionBolsaCompra.Text = CalcularComisionImpuestos(ComisionBolsaCompra, txtValorTransadoCompra.Text)
  767. If (Not String.IsNullOrEmpty(oAccionesCE.SumaImpuestosYComisionesCompra.ToString(Configuraciones.CodigoTXTMontos))) Then
  768. Me.txtImpuestosYComisionesCompra.Text = oAccionesCE.SumaImpuestosYComisionesCompra.ToString()
  769. End If
  770. Dim ValorIOFCompra = 0.0, ValorRentaCompra = 0.0
  771. If (Not String.IsNullOrEmpty(txtIOFCompra.Text.ToString)) Then
  772. ValorIOFCompra = txtIOFCompra.Text
  773. End If
  774. If (Not String.IsNullOrEmpty(txtRentaCompra.Text.ToString)) Then
  775. ValorRentaCompra = txtRentaCompra.Text
  776. End If
  777. If (Not String.IsNullOrEmpty(oAccionesCE.PrecioSucioCompra.ToString(Configuraciones.CodigoTXTMontos))) Then
  778. Me.txtPrecioSucioCompra.Text = oAccionesCE.PrecioSucioCompra.ToString()
  779. End If
  780. 'VENTA
  781. If (Not String.IsNullOrEmpty(oAccionesCE.PrecioLimpioVenta.ToString())) Then
  782. If Not oAccionesCE.PrecioLimpioVenta = 0 Then
  783. Me.txtPrecioLimpioVenta.Text = oAccionesCE.PrecioLimpioVenta.ToString()
  784. End If
  785. End If
  786. Me.dtpFechaOperacionVenta.Value = Operaciones.ConvertirFecha(oAccionesCE.FechaOperacionVenta.ToString)
  787. Me.dtpFechaVencimientoVenta.Value = Operaciones.ConvertirFecha(oAccionesCE.FechaVencimientoVenta.ToString)
  788. If (Not String.IsNullOrEmpty(oAccionesCE.DiasDeTenenciaVenta.ToString)) Then
  789. Me.txtDiasDeTenenciaVenta.Text = oAccionesCE.DiasDeTenenciaVenta.ToString
  790. End If
  791. If (Not String.IsNullOrEmpty(oAccionesCE.GananciaDeCapitalTotalVenta.ToString(Configuraciones.CodigoTXTMontos))) Then
  792. Me.txtGananciaCapitalTotalVenta.Text = oAccionesCE.GananciaDeCapitalTotalVenta.ToString()
  793. End If
  794. If (Not String.IsNullOrEmpty(oAccionesCE.GananciaDeCapitalUnitarioVenta.ToString)) Then
  795. If Not Double.IsNaN(oAccionesCE.GananciaDeCapitalUnitarioVenta.ToString) Then
  796. Me.txtGananciaCapitalUnitarioVenta.Text = oAccionesCE.GananciaDeCapitalUnitarioVenta.ToString
  797. End If
  798. End If
  799. If String.IsNullOrEmpty(txtRetornoAnualBrutoVenta.Text.ToString) Then
  800. txtRetornoAnualBrutoVenta.Text = 0
  801. End If
  802. Variables.IngresoBruto = CalcularIngresoBruto()
  803. Variables.IngresoNeto = CalcularIngresoNeto()
  804. If (rdbEfectivo.Checked) Then
  805. If (Not String.IsNullOrEmpty(oAccionesCE.RetornoAnualizadoBrutoVenta.ToString(Configuraciones.CodigoTXTPorcentaje))) Then
  806. Me.txtRetornoAnualBrutoVenta.Text = oAccionesCE.RetornoAnualizadoBrutoVenta.ToString()
  807. End If
  808. Else
  809. Dim Existe = dgvDividendos.Rows.Count
  810. If (Existe >= 1) Then
  811. If (Not dgvDividendos.Rows(0).Cells("Dividendo").Value Is Nothing) Then
  812. Dim Valor = dgvDividendos.Rows(0).Cells("Dividendo").Value.ToString.Trim("%")
  813. If (Not String.IsNullOrEmpty(Valor)) Then
  814. Me.txtRetornoAnualBrutoVenta.Text = CStr((CDec(Valor.ToString.Trim("%")) * 100)) + "%"
  815. End If
  816. End If
  817. End If
  818. End If
  819. If (rdbEfectivo.Checked) Then
  820. If (Not String.IsNullOrEmpty(oAccionesCE.RetornoAnualizadoNetoVenta.ToString(Configuraciones.CodigoTXTPorcentaje))) Then
  821. Me.txtRetornoAnualNetoVenta.Text = oAccionesCE.RetornoAnualizadoNetoVenta.ToString()
  822. End If
  823. Else
  824. Dim Existe = dgvDividendos.Rows.Count
  825. If (Existe >= 1) Then
  826. Dim Valor = dgvDividendos.Rows(0).Cells("PorcISR").Value
  827. If (Not String.IsNullOrEmpty(Valor)) Then
  828. Me.txtRetornoAnualNetoVenta.Text = CStr(CDec(txtRetornoAnualBrutoVenta.Text.Trim("%")) * (1 - Valor)) + "%"
  829. End If
  830. End If
  831. End If
  832. If (Not String.IsNullOrEmpty(oAccionesCE.CantidadVenta.ToString)) Then
  833. If Not oAccionesCE.CantidadVenta = 0 Then
  834. Me.txtUnidadesVenta.Text = oAccionesCE.CantidadVenta.ToString
  835. End If
  836. End If
  837. If (Not String.IsNullOrEmpty(oAccionesCE.ValorTransadoVenta.ToString())) Then
  838. Me.txtValorTransadoVenta.Text = oAccionesCE.ValorTransadoVenta.ToString()
  839. End If
  840. If (Not String.IsNullOrEmpty(oAccionesCE.SumaImpuestosYComisionesVenta.ToString())) Then
  841. Me.txtImpuestosYComisionesVenta.Text = oAccionesCE.SumaImpuestosYComisionesVenta.ToString()
  842. End If
  843. Dim ComisionCasaVenta As Double = 0
  844. Dim ComisionBolsaVenta As Double = 0
  845. Dim ValorTransadoVenta As Double = 0
  846. ComisionCasaVenta = Operaciones.ConvertirDecimal(txtComisionPorcentajeCasaVenta.Text.ToString) / 100
  847. ComisionBolsaVenta = Operaciones.ConvertirDecimal(txtComisionPorcentajeBolsaVenta.Text.ToString) / 100
  848. ValorTransadoVenta = Operaciones.ConvertirDecimal(txtValorTransadoVenta.Text.ToString)
  849. Me.txtComisionCasaVenta.Text = CalcularComisionImpuestos(ComisionCasaVenta, ValorTransadoVenta)
  850. Me.txtComisionBolsaVenta.Text = CalcularComisionImpuestos(ComisionBolsaVenta, ValorTransadoVenta)
  851. txtGananciaCapitalTotalVenta.Text += SumaComisiones()
  852. Dim ValorIOFVenta = 0.0, ValorRentaVenta = 0.0
  853. If (Not String.IsNullOrEmpty(txtIOFVenta.Text.ToString)) Then
  854. ValorIOFVenta = txtIOFVenta.Text
  855. End If
  856. If (Not String.IsNullOrEmpty(txtRentaVenta.Text.ToString)) Then
  857. ValorRentaVenta = txtRentaVenta.Text
  858. End If
  859. Me.txtMontoNetoVenta.Text = Operaciones.ConvertirDecimal(oAccionesCE.MontoNetoVenta.ToString()) - Operaciones.ConvertirDecimal(txtComisionBolsaVenta.Text) - Operaciones.ConvertirDecimal(txtComisionCasaVenta.Text) - ValorIOFVenta - ValorRentaVenta
  860. Me.txtMontoNetoCompra.Text = (Operaciones.ConvertirDecimal(oAccionesCE.MontoNetoCompra.ToString())) + (Operaciones.ConvertirDecimal(txtComisionBolsaCompra.Text) + Operaciones.ConvertirDecimal(txtComisionCasaCompra.Text) + ValorIOFCompra + ValorRentaCompra)
  861. If (String.IsNullOrEmpty(oAccionesCE.PrecioSucioVenta.ToString())) Then
  862. Me.txtPrecioSucioVenta.Text = "0.0"
  863. Else
  864. If Double.IsNaN(oAccionesCE.PrecioSucioVenta.ToString()) Then
  865. Me.txtPrecioSucioVenta.Text = "0.0"
  866. Else
  867. Me.txtPrecioSucioVenta.Text = oAccionesCE.PrecioSucioVenta.ToString()
  868. End If
  869. End If
  870. End If
  871. End Sub
  872. Function CalcularIngresoBruto()
  873. Dim Cantidad = dgvDividendos.Rows.Count - 1
  874. Dim FechaActual = Date.Now.Date
  875. Dim ContadorIngreso As Double = 0.0
  876. For i As Integer = 0 To Cantidad
  877. Try
  878. If (Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("Fecha").Value.ToString)) Then
  879. Dim FechaPrograma As Date = Operaciones.ConvertirFecha(dgvDividendos.Rows(i).Cells("Fecha").Value.ToString)
  880. If (FechaActual >= FechaPrograma) Then
  881. If (Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("IngresoBruto").Value.ToString)) Then
  882. ContadorIngreso += Operaciones.ConvertirDecimal(dgvDividendos.Rows(i).Cells("IngresoBruto").Value.ToString)
  883. End If
  884. End If
  885. End If
  886. Catch ex As Exception
  887. End Try
  888. Next
  889. Return ContadorIngreso
  890. End Function
  891. Function CalcularIngresoNeto()
  892. Dim Cantidad = dgvDividendos.Rows.Count - 1
  893. Dim FechaActual = Date.Now.Date
  894. Dim ContadorIngreso As Double = 0.0
  895. For i As Integer = 0 To Cantidad
  896. Try
  897. If (Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("Fecha").Value.ToString)) Then
  898. Dim FechaPrograma As Date = Operaciones.ConvertirFecha(dgvDividendos.Rows(i).Cells("Fecha").Value.ToString)
  899. If (FechaActual >= FechaPrograma) Then
  900. If (Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("IngresoNeto").Value.ToString)) Then
  901. ContadorIngreso += Operaciones.ConvertirDecimal(dgvDividendos.Rows(i).Cells("IngresoNeto").Value.ToString)
  902. End If
  903. End If
  904. End If
  905. Catch ex As Exception
  906. End Try
  907. Next
  908. Return ContadorIngreso
  909. End Function
  910. Function SumaComisiones()
  911. Dim ComisionCasaVenta As Double = Operaciones.ConvertirDecimal(txtComisionCasaVenta.Text.ToString)
  912. Dim ComisionBolsaVenta As Double = Operaciones.ConvertirDecimal(txtComisionBolsaVenta.Text.ToString)
  913. Dim Total As Double = 0.0
  914. Total = ComisionCasaVenta + ComisionBolsaVenta
  915. Return Total
  916. End Function
  917. Function CalcularComisionImpuestos(ByVal Comision As Double, ByVal ValorTransado As Double)
  918. Return Comision * ValorTransado
  919. End Function
  920. Private Sub PrepararTablaDividendos()
  921. Dim oDataGridViewTextBoxColumn As DataGridViewTextBoxColumn
  922. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  923. oDataGridViewTextBoxColumn.Name = "CodInv"
  924. oDataGridViewTextBoxColumn.DataPropertyName = "CodInv"
  925. oDataGridViewTextBoxColumn.HeaderText = "Código Inversión"
  926. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  927. oDataGridViewTextBoxColumn.Visible = False
  928. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  929. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  930. oDataGridViewTextBoxColumn.Name = "Correlativo"
  931. oDataGridViewTextBoxColumn.DataPropertyName = "Correlativo"
  932. oDataGridViewTextBoxColumn.HeaderText = "Correlativo"
  933. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  934. oDataGridViewTextBoxColumn.Visible = True
  935. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  936. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  937. oDataGridViewTextBoxColumn.Name = "Fecha"
  938. oDataGridViewTextBoxColumn.DataPropertyName = "Fecha"
  939. oDataGridViewTextBoxColumn.HeaderText = "Fecha"
  940. oDataGridViewTextBoxColumn.Name = "Fecha"
  941. oDataGridViewTextBoxColumn.ValueType = GetType(Date)
  942. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  943. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  944. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  945. oDataGridViewTextBoxColumn.Name = "Dividendo"
  946. oDataGridViewTextBoxColumn.DataPropertyName = "Dividendo"
  947. oDataGridViewTextBoxColumn.HeaderText = "Dividendo"
  948. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  949. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  950. oDataGridViewTextBoxColumn.Name = "CantidadBase"
  951. oDataGridViewTextBoxColumn.DataPropertyName = "CantidadBase"
  952. oDataGridViewTextBoxColumn.HeaderText = "Cantidad Base"
  953. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  954. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  955. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  956. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  957. oDataGridViewTextBoxColumn.Name = "IngresoBruto"
  958. oDataGridViewTextBoxColumn.DataPropertyName = "IngresoBruto"
  959. oDataGridViewTextBoxColumn.HeaderText = "Ingreso Bruto"
  960. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  961. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  962. oDataGridViewTextBoxColumn.ReadOnly = True
  963. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  964. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  965. oDataGridViewTextBoxColumn.Name = "PorcISR"
  966. oDataGridViewTextBoxColumn.DataPropertyName = "PorcISR"
  967. oDataGridViewTextBoxColumn.HeaderText = "% ISR"
  968. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTPorcentaje
  969. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  970. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  971. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  972. oDataGridViewTextBoxColumn.Name = "ISR"
  973. oDataGridViewTextBoxColumn.DataPropertyName = "ISR"
  974. oDataGridViewTextBoxColumn.HeaderText = "ISR"
  975. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  976. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  977. oDataGridViewTextBoxColumn.ReadOnly = True
  978. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  979. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  980. oDataGridViewTextBoxColumn.Name = "IngresoNeto"
  981. oDataGridViewTextBoxColumn.DataPropertyName = "IngresoNeto"
  982. oDataGridViewTextBoxColumn.HeaderText = "Ingreso Neto"
  983. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  984. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  985. oDataGridViewTextBoxColumn.ReadOnly = True
  986. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  987. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  988. oDataGridViewTextBoxColumn.Name = "Estado"
  989. oDataGridViewTextBoxColumn.DataPropertyName = "Estado"
  990. oDataGridViewTextBoxColumn.HeaderText = "Estado"
  991. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  992. oDataGridViewTextBoxColumn.Visible = False
  993. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  994. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  995. oDataGridViewTextBoxColumn.Name = "FechaInicio"
  996. oDataGridViewTextBoxColumn.DataPropertyName = "FechaInicio"
  997. oDataGridViewTextBoxColumn.HeaderText = "FechaInicio"
  998. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  999. oDataGridViewTextBoxColumn.Visible = False
  1000. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  1001. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1002. oDataGridViewTextBoxColumn.Name = "FechaCorte"
  1003. oDataGridViewTextBoxColumn.DataPropertyName = "FechaCorte"
  1004. oDataGridViewTextBoxColumn.HeaderText = "FechaCorte"
  1005. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  1006. oDataGridViewTextBoxColumn.Visible = False
  1007. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  1008. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1009. oDataGridViewTextBoxColumn.Name = "NumDiv"
  1010. oDataGridViewTextBoxColumn.DataPropertyName = "NumDiv"
  1011. oDataGridViewTextBoxColumn.HeaderText = "NuvDiv"
  1012. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  1013. oDataGridViewTextBoxColumn.Visible = False
  1014. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  1015. End Sub
  1016. Private Function FechaDividendo()
  1017. Dim Index = dgvDividendos.CurrentRow.Index
  1018. Dim IndexAnterior = Index - 1
  1019. Dim FechaInicial = dtpFechaOperacionCompra.Value
  1020. Dim FechaActual = Operaciones.ConvertirFecha(dgvDividendos.Rows(Index).Cells("Fecha").Value)
  1021. Dim FechaCalcul As Date = Date.Now.Date
  1022. If (String.IsNullOrEmpty(FechaActual)) Then
  1023. If (Index = 0) Then
  1024. FechaCalcul = Operaciones.Meses(12, FechaInicial, FechaInicial)
  1025. Else
  1026. Dim Fecha = Operaciones.ConvertirFecha(dgvDividendos.Rows(IndexAnterior).Cells("Fecha").Value.ToString)
  1027. FechaCalcul = Operaciones.Meses(12, Fecha, FechaInicial)
  1028. End If
  1029. Else
  1030. FechaCalcul = FechaActual
  1031. End If
  1032. Return FechaCalcul
  1033. End Function
  1034. Private Sub PrepararCalculoDividendos(ByVal IdFila As Integer)
  1035. Dim vFila As DataGridViewRow = dgvDividendos.Rows(IdFila)
  1036. If (rdbEfectivo.Checked) Then
  1037. If vFila.IsNewRow Then
  1038. vFila.Cells("Fecha").Value = FechaDividendo()
  1039. vFila.Cells("Dividendo").Value = oAccionesCE.FactorDeDividendo
  1040. End If
  1041. If rdbEfectivo.Checked Then
  1042. vFila.Cells("CantidadBase").Value = Operaciones.ConvertirDecimal(txtUnidadesCompra.Text.ToString)
  1043. Else
  1044. vFila.Cells("CantidadBase").Value = Operaciones.ConvertirDecimal(txtValorTransadoCompra.Text)
  1045. End If
  1046. vFila.Cells("IngresoBruto").Value = 0.00
  1047. vFila.Cells("PorcISR").Value = 0.05
  1048. vFila.Cells("ISR").Value = 0.00
  1049. vFila.Cells("IngresoNeto").Value = 0.00
  1050. If dgvDividendos.Rows(IdFila).Cells("NumDiv").Value Is DBNull.Value Then
  1051. dgvDividendos.Rows(IdFila).Cells("NumDiv").Value = Correlativo()
  1052. Else
  1053. If String.IsNullOrEmpty(dgvDividendos.Rows(IdFila).Cells("NumDiv").Value) Then
  1054. dgvDividendos.Rows(IdFila).Cells("NumDiv").Value = Correlativo()
  1055. End If
  1056. End If
  1057. Else
  1058. If vFila.IsNewRow Then
  1059. vFila.Cells("Fecha").Value = FechaDividendo()
  1060. vFila.Cells("Dividendo").Value = oAccionesCE.FactorDeDividendo.ToString + "%"
  1061. If (vFila.Cells("Dividendo").Value.ToString.IndexOf("%") = -1) Then
  1062. vFila.Cells("Dividendo").Value += "%"
  1063. End If
  1064. If rdbEfectivo.Checked Then
  1065. vFila.Cells("CantidadBase").Value = Operaciones.ConvertirDecimal(txtUnidadesCompra.Text.ToString)
  1066. Else
  1067. vFila.Cells("CantidadBase").Value = Operaciones.ConvertirDecimal(txtValorTransadoCompra.Text.ToString)
  1068. End If
  1069. vFila.Cells("IngresoBruto").Value = 0.00
  1070. vFila.Cells("PorcISR").Value = 0.05
  1071. vFila.Cells("ISR").Value = 0.00
  1072. vFila.Cells("IngresoNeto").Value = 0.00
  1073. If dgvDividendos.Rows(IdFila).Cells("NumDiv").Value Is DBNull.Value Then
  1074. dgvDividendos.Rows(IdFila).Cells("NumDiv").Value = Correlativo()
  1075. Else
  1076. If String.IsNullOrEmpty(dgvDividendos.Rows(IdFila).Cells("NumDiv").Value) Then
  1077. dgvDividendos.Rows(IdFila).Cells("NumDiv").Value = Correlativo()
  1078. End If
  1079. End If
  1080. End If
  1081. End If
  1082. If (vFila.Cells("Fecha").Value Is DBNull.Value) Then
  1083. vFila.Cells("Fecha").Value = FechaDividendo()
  1084. Else
  1085. If String.IsNullOrEmpty(vFila.Cells("Fecha").Value) Then
  1086. vFila.Cells("Fecha").Value = FechaDividendo()
  1087. End If
  1088. End If
  1089. RefrescarValorControles()
  1090. End Sub
  1091. Sub AgregarFechaCO()
  1092. dgvDividendos.CurrentRow.Cells("FechaInicio").Value = Operaciones.ConvertirFechaBaseDatos(Variables.FechaInicialCorte.ToString)
  1093. dgvDividendos.CurrentRow.Cells("FechaCorte").Value = Operaciones.ConvertirFechaBaseDatos(Variables.FechaCorteCorte.ToString)
  1094. End Sub
  1095. Function CalculoIngresoBrutoEfectivo(ByVal CantidadUnidades As Double, ByVal Dividendo As Double)
  1096. Dim Total = CantidadUnidades * (Dividendo)
  1097. Return Total
  1098. End Function
  1099. Function CalculoIngresoBrutoPorcentaje(ByVal ValorTransado As Double, ByVal Dividendo As Double, ByVal Dias As Integer, ByVal Fecha As Date)
  1100. Dim Total As Double = 0
  1101. If (Operaciones.AñoBisiesto(Fecha) = 364) Then
  1102. Total = (ValorTransado * (Dividendo / 100) * Dias) / 365
  1103. End If
  1104. If (Operaciones.AñoBisiesto(Fecha) = 365) Then
  1105. Total = (ValorTransado * (Dividendo / 100) * Dias) / 366
  1106. End If
  1107. Return Total
  1108. End Function
  1109. Private Sub dgvDividendos_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) Handles dgvDividendos.CellBeginEdit
  1110. PrepararCalculoDividendos(e.RowIndex)
  1111. End Sub
  1112. Private Sub dgvDividendos_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvDividendos.CellEndEdit
  1113. CalcularDividendos()
  1114. RefrescarValorControles()
  1115. End Sub
  1116. Private Sub dgvDividendos_UserDeletedRow(sender As Object, e As DataGridViewRowEventArgs) Handles dgvDividendos.UserDeletedRow
  1117. End Sub
  1118. Private Sub dgvImpuestosYComisiones_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs)
  1119. End Sub
  1120. Private Sub dgvImpuestosYComisiones_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs)
  1121. End Sub
  1122. Private Sub dgvImpuestosYComisiones_UserDeletedRow(sender As Object, e As DataGridViewRowEventArgs)
  1123. oAccionesCE.ImpuestosYComisiones.AcceptChanges()
  1124. End Sub
  1125. Private Sub dgvImpuestosYComisiones_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
  1126. End Sub
  1127. Private Sub dgvDividendos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvDividendos.CellContentClick
  1128. End Sub
  1129. Private Sub TabPage2_Click(sender As Object, e As EventArgs)
  1130. End Sub
  1131. Private Sub txtImpuestosYComisionesCompra_TextChanged(sender As Object, e As EventArgs) Handles txtImpuestosYComisionesCompra.TextChanged
  1132. End Sub
  1133. Private Sub TOperacion(ByVal TOperacion As String)
  1134. If (TOperacion = "N") Then
  1135. HabilitarBotones()
  1136. ElseIf (TOperacion = "B") Then
  1137. DeshabilitarBotones()
  1138. End If
  1139. End Sub
  1140. Sub HabilitarBotones()
  1141. txtUnidadesCompra.Enabled = True
  1142. txtUnidadesVenta.Enabled = True
  1143. End Sub
  1144. Sub DeshabilitarBotones()
  1145. txtDiasDeTenenciaCompra.Enabled = False
  1146. txtDiasDeTenenciaVenta.Enabled = False
  1147. txtGananciaCapitalTotalCompra.Enabled = False
  1148. txtGananciaCapitalTotalVenta.Enabled = False
  1149. txtGananciaCapitalUnitarioCompra.Enabled = False
  1150. txtGananciaCapitalUnitarioVenta.Enabled = False
  1151. txtRetornoAnualBrutoCompra.Enabled = False
  1152. txtRetornoAnualBrutoVenta.Enabled = False
  1153. txtRetornoAnualNetoCompra.Enabled = False
  1154. txtRetornoAnualNetoVenta.Enabled = False
  1155. txtUnidadesCompra.Enabled = False
  1156. txtUnidadesVenta.Enabled = False
  1157. txtValorTransadoCompra.Enabled = False
  1158. txtValorTransadoVenta.Enabled = False
  1159. txtImpuestosYComisionesCompra.Enabled = False
  1160. txtImpuestosYComisionesVenta.Enabled = False
  1161. txtMontoNetoCompra.Enabled = False
  1162. txtMontoNetoVenta.Enabled = False
  1163. txtPrecioSucioCompra.Enabled = False
  1164. txtPrecioSucioVenta.Enabled = False
  1165. End Sub
  1166. Private Sub dtgcomisiones_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
  1167. End Sub
  1168. Private Sub TabPage4_Click(sender As Object, e As EventArgs)
  1169. End Sub
  1170. Private Sub dtgcomisiones_CellContentClick_1(sender As Object, e As DataGridViewCellEventArgs)
  1171. End Sub
  1172. Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
  1173. Estado = "N"
  1174. btnAceptar.Text = "Nuevo"
  1175. End Sub
  1176. Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
  1177. Estado = "M"
  1178. btnAceptar.Text = "Modificar"
  1179. End Sub
  1180. Private Sub Button1_Click(sender As Object, e As EventArgs)
  1181. If (Estado = "N") Then
  1182. NuevaAccion()
  1183. End If
  1184. End Sub
  1185. Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
  1186. Estado = "B"
  1187. btnAceptar.Text = "Eliminar"
  1188. End Sub
  1189. Private Sub btnAgregar_Click(sender As Object, e As EventArgs)
  1190. End Sub
  1191. Private Sub dgvDividendos_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvDividendos.CellClick
  1192. ModificarFechaCorte()
  1193. PrepararCalculoDividendos(e.RowIndex)
  1194. End Sub
  1195. Sub ModificarFechaCorte()
  1196. If rdbPorcentaje.Checked Then
  1197. Dim Index As Integer = dgvDividendos.CurrentRow.Index
  1198. If dgvDividendos.Rows(Index).Cells("Fecha").ColumnIndex = dgvDividendos.CurrentCell.ColumnIndex Then
  1199. Dim FechaReferencia = Operaciones.ConvertirFecha(dgvDividendos.Rows(Index).Cells("Fecha").Value)
  1200. If (Not String.IsNullOrEmpty(FechaReferencia)) Then
  1201. Dim año = FechaReferencia.Year
  1202. Dim PrimeraFecha, SegundaFecha
  1203. If (dgvDividendos.Rows(Index).Cells("FechaInicio").Value Is Nothing) Then
  1204. PrimeraFecha = Operaciones.ConvertirFecha("1/1/" + año.ToString)
  1205. ElseIf (dgvDividendos.Rows(Index).Cells("FechaInicio").Value Is DBNull.Value) Then
  1206. PrimeraFecha = Operaciones.ConvertirFecha("1/1/" + año.ToString)
  1207. Else
  1208. PrimeraFecha = Operaciones.ConvertirFecha(dgvDividendos.Rows(Index).Cells("FechaInicio").Value)
  1209. End If
  1210. If (dgvDividendos.Rows(Index).Cells("FechaCorte").Value Is Nothing) Then
  1211. SegundaFecha = Operaciones.ConvertirFecha("31/12/" + año.ToString)
  1212. ElseIf (dgvDividendos.Rows(Index).Cells("FechaCorte").Value Is DBNull.Value) Then
  1213. SegundaFecha = Operaciones.ConvertirFecha("31/12/" + año.ToString)
  1214. Else
  1215. SegundaFecha = dgvDividendos.Rows(Index).Cells("FechaCorte").Value
  1216. End If
  1217. Variables.FechaInicial = PrimeraFecha
  1218. Variables.FechaCorte = SegundaFecha
  1219. Variables.CorrelativoACC = dgvDividendos.Rows(Index).Cells("NumDiv").Value
  1220. frmFechasAcciones.Show()
  1221. End If
  1222. Cierre = True
  1223. End If
  1224. End If
  1225. End Sub
  1226. Private Sub txtComisionPorcentajeCasaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorcentajeCasaCompra.TextChanged
  1227. RefrescarValorControles()
  1228. End Sub
  1229. Private Sub txtComisionPorcentajeBolsaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorcentajeBolsaCompra.TextChanged
  1230. RefrescarValorControles()
  1231. End Sub
  1232. Private Sub txtComisionPorcentajeCasaVenta_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorcentajeCasaVenta.TextChanged
  1233. RefrescarValorControles()
  1234. End Sub
  1235. Private Sub txtComisionPorcentajeBolsaVenta_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorcentajeBolsaVenta.TextChanged
  1236. RefrescarValorControles()
  1237. End Sub
  1238. Private Sub txtMontoNetoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtMontoNetoCompra.TextChanged
  1239. End Sub
  1240. Private Sub btnAgregarImpuesto_Click(sender As Object, e As EventArgs)
  1241. End Sub
  1242. Private Sub dgvImpuestoAgregado_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
  1243. End Sub
  1244. Private Sub btnQuitar_Click(sender As Object, e As EventArgs)
  1245. End Sub
  1246. Private Sub dgvImpuestoAgregado_CellClick(sender As Object, e As DataGridViewCellEventArgs)
  1247. End Sub
  1248. Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs)
  1249. End Sub
  1250. Private Sub BindingNavigator1_RefreshItems(sender As Object, e As EventArgs) Handles BindingNavigator1.RefreshItems
  1251. End Sub
  1252. Sub ValidarRentaIOF()
  1253. If (ChkIOF.Checked) Then
  1254. CalculosIOF()
  1255. Else
  1256. BloquearIOF()
  1257. End If
  1258. RefrescarValorControles()
  1259. If (ChkRenta.Checked) Then
  1260. CalculosRenta()
  1261. Else
  1262. BloquearRenta()
  1263. End If
  1264. RefrescarValorControles()
  1265. End Sub
  1266. Private Sub ChkIOF_CheckedChanged(sender As Object, e As EventArgs) Handles ChkIOF.CheckedChanged
  1267. If (ChkIOF.Checked) Then
  1268. oAccionesCE.IOF = 1
  1269. CalculosIOF()
  1270. Else
  1271. oAccionesCE.IOF = 0
  1272. BloquearIOF()
  1273. End If
  1274. RefrescarValorControles()
  1275. End Sub
  1276. Sub BloquearIOF()
  1277. lblCompra1.Visible = False
  1278. lblVenta1.Visible = False
  1279. txtIOFCompra.Text = String.Empty
  1280. txtIOFCompra.Visible = False
  1281. txtIOFVenta.Text = String.Empty
  1282. txtIOFVenta.Visible = False
  1283. End Sub
  1284. Sub CalculosIOF()
  1285. If (Not String.IsNullOrEmpty(txtValorTransadoCompra.Text) And Not String.IsNullOrEmpty(txtValorTransadoVenta.Text)) Then
  1286. lblCompra1.Visible = True
  1287. lblVenta1.Visible = True
  1288. txtIOFCompra.Visible = True
  1289. txtIOFVenta.Visible = True
  1290. Dim ValorTransadoCompra = txtValorTransadoCompra.Text
  1291. Dim ValorTransadoVenta = txtValorTransadoVenta.Text
  1292. txtIOFCompra.Text = CalculoImpuestos(ValorTransadoCompra, 0.0025)
  1293. txtIOFVenta.Text = CalculoImpuestos(ValorTransadoVenta, 0.0025)
  1294. End If
  1295. End Sub
  1296. Private Sub ChkRenta_CheckedChanged(sender As Object, e As EventArgs) Handles ChkRenta.CheckedChanged
  1297. If (ChkRenta.Checked) Then
  1298. oAccionesCE.Renta = 1
  1299. CalculosRenta()
  1300. Else
  1301. oAccionesCE.Renta = 0
  1302. BloquearRenta()
  1303. End If
  1304. RefrescarValorControles()
  1305. End Sub
  1306. Sub CalculosRenta()
  1307. If (Not String.IsNullOrEmpty(txtValorTransadoCompra.Text) And Not String.IsNullOrEmpty(txtValorTransadoVenta.Text)) Then
  1308. lblCompra2.Visible = True
  1309. lblVenta2.Visible = True
  1310. txtRentaVenta.Visible = True
  1311. txtRentaCompra.Visible = True
  1312. Dim ValorTransadoCompra = txtValorTransadoCompra.Text
  1313. Dim ValorTransadoVenta = txtValorTransadoVenta.Text
  1314. txtRentaCompra.Text = CalculoImpuestos(ValorTransadoCompra, 0.1)
  1315. txtRentaVenta.Text = CalculoImpuestos(ValorTransadoVenta, 0.1)
  1316. End If
  1317. End Sub
  1318. Sub BloquearRenta()
  1319. lblCompra2.Visible = False
  1320. lblVenta2.Visible = False
  1321. txtRentaCompra.Text = String.Empty
  1322. txtRentaCompra.Visible = False
  1323. txtRentaVenta.Text = String.Empty
  1324. txtRentaVenta.Visible = False
  1325. End Sub
  1326. Function CalculoImpuestos(ByVal ValorTransado As Double, ByVal Impuesto As Double)
  1327. Dim Valor = ValorTransado * Impuesto
  1328. Return Valor
  1329. End Function
  1330. Private Sub rdbEfectivo_CheckedChanged(sender As Object, e As EventArgs) Handles rdbEfectivo.CheckedChanged
  1331. If (rdbEfectivo.Checked) Then
  1332. LimpiarDividendosCambios(1)
  1333. Else
  1334. LimpiarDividendosCambios(2)
  1335. End If
  1336. CambiarBase()
  1337. CambioCalculo = True
  1338. CambioCalculo = False
  1339. If (Cargado) Then
  1340. RefrescarValorControles()
  1341. End If
  1342. End Sub
  1343. Private Sub rdbPorcentaje_CheckedChanged(sender As Object, e As EventArgs) Handles rdbPorcentaje.CheckedChanged
  1344. If (rdbEfectivo.Checked) Then
  1345. LimpiarDividendosCambios(1)
  1346. Else
  1347. LimpiarDividendosCambios(2)
  1348. End If
  1349. CambiarBase()
  1350. CambioCalculo = True
  1351. CambioCalculo = False
  1352. If (Cargado) Then
  1353. RefrescarValorControles()
  1354. End If
  1355. End Sub
  1356. Sub CambiarBase()
  1357. Dim Cantidad As Integer = dgvDividendos.Rows.Count - 1
  1358. For i As Integer = 0 To Cantidad
  1359. If (dgvDividendos.Rows(i).Cells("NumDiv").Value Is DBNull.Value) Then
  1360. Exit For
  1361. Else
  1362. If String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("NumDiv").Value) Then
  1363. Exit For
  1364. End If
  1365. End If
  1366. If rdbEfectivo.Checked Then
  1367. dgvDividendos.Rows(i).Cells("CantidadBase").Value = Operaciones.ConvertirDecimal(txtUnidadesCompra.Text.ToString)
  1368. Else
  1369. dgvDividendos.Rows(i).Cells("CantidadBase").Value = Operaciones.ConvertirDecimal(txtValorTransadoCompra.Text.ToString)
  1370. End If
  1371. Next
  1372. CalcularDividendos()
  1373. End Sub
  1374. Private Sub dgvDividendos_Click(sender As Object, e As EventArgs) Handles dgvDividendos.Click
  1375. End Sub
  1376. Sub ClonarDatos()
  1377. If (String.IsNullOrEmpty(txtUnidadesVenta.Text.ToString)) Then
  1378. txtUnidadesVenta.Text = txtUnidadesCompra.Text
  1379. End If
  1380. End Sub
  1381. Private Sub txtUnidadesCompra_Leave(sender As Object, e As EventArgs) Handles txtUnidadesCompra.Leave
  1382. ClonarDatos()
  1383. Formato()
  1384. End Sub
  1385. Private Sub rdbEfectivo_Click(sender As Object, e As EventArgs) Handles rdbEfectivo.Click
  1386. End Sub
  1387. Private Sub dgvDividendos_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvDividendos.CellDoubleClick
  1388. End Sub
  1389. Private Sub txtPrecioLimpioCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioLimpioCompra.KeyPress
  1390. If String.IsNullOrEmpty(txtPrecioLimpioCompra.Text) Then
  1391. If e.KeyChar = "." Then
  1392. txtPrecioLimpioCompra.Text = "0"
  1393. Exit Sub
  1394. End If
  1395. End If
  1396. If (Not txtPrecioLimpioCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1397. Operaciones.ValidarEntrada(sender, e, True)
  1398. Else
  1399. Operaciones.ValidarEntrada(sender, e, False)
  1400. End If
  1401. End Sub
  1402. Private Sub txtPrecioLimpioVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioLimpioVenta.KeyPress
  1403. If String.IsNullOrEmpty(txtPrecioLimpioVenta.Text) Then
  1404. If e.KeyChar = "." Then
  1405. txtPrecioLimpioVenta.Text = "0"
  1406. Exit Sub
  1407. End If
  1408. End If
  1409. If (Not txtPrecioLimpioVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1410. Operaciones.ValidarEntrada(sender, e, True)
  1411. Else
  1412. Operaciones.ValidarEntrada(sender, e, False)
  1413. End If
  1414. End Sub
  1415. Private Sub txtUnidadesCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtUnidadesCompra.KeyPress
  1416. If String.IsNullOrEmpty(txtUnidadesCompra.Text) Then
  1417. If e.KeyChar = "." Then
  1418. txtUnidadesCompra.Text = "0"
  1419. Exit Sub
  1420. End If
  1421. End If
  1422. If (Not txtUnidadesCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1423. Operaciones.ValidarEntrada(sender, e, True)
  1424. Else
  1425. Operaciones.ValidarEntrada(sender, e, False)
  1426. End If
  1427. End Sub
  1428. Private Sub txtUnidadesVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtUnidadesVenta.KeyPress
  1429. If String.IsNullOrEmpty(txtUnidadesVenta.Text) Then
  1430. If e.KeyChar = "." Then
  1431. txtUnidadesVenta.Text = "0"
  1432. Exit Sub
  1433. End If
  1434. End If
  1435. If (Not txtUnidadesVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1436. Operaciones.ValidarEntrada(sender, e, True)
  1437. Else
  1438. Operaciones.ValidarEntrada(sender, e, False)
  1439. End If
  1440. End Sub
  1441. Private Sub txtComisionPorcentajeCasaCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorcentajeCasaCompra.KeyPress
  1442. If String.IsNullOrEmpty(txtComisionPorcentajeCasaCompra.Text) Then
  1443. If e.KeyChar = "." Then
  1444. txtComisionPorcentajeCasaCompra.Text = "0"
  1445. Exit Sub
  1446. End If
  1447. End If
  1448. If (Not txtComisionPorcentajeCasaCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1449. Operaciones.ValidarEntrada(sender, e, True)
  1450. Else
  1451. Operaciones.ValidarEntrada(sender, e, False)
  1452. End If
  1453. End Sub
  1454. Private Sub txtComisionPorcentajeBolsaCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorcentajeBolsaCompra.KeyPress
  1455. If String.IsNullOrEmpty(txtComisionPorcentajeBolsaCompra.Text) Then
  1456. If e.KeyChar = "." Then
  1457. txtComisionPorcentajeBolsaCompra.Text = "0"
  1458. Exit Sub
  1459. End If
  1460. End If
  1461. If (Not txtComisionPorcentajeBolsaCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1462. Operaciones.ValidarEntrada(sender, e, True)
  1463. Else
  1464. Operaciones.ValidarEntrada(sender, e, False)
  1465. End If
  1466. End Sub
  1467. Private Sub txtComisionPorcentajeCasaVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorcentajeCasaVenta.KeyPress
  1468. If String.IsNullOrEmpty(txtComisionPorcentajeCasaVenta.Text) Then
  1469. If e.KeyChar = "." Then
  1470. txtComisionPorcentajeCasaVenta.Text = "0"
  1471. Exit Sub
  1472. End If
  1473. End If
  1474. If (Not txtComisionPorcentajeCasaVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1475. Operaciones.ValidarEntrada(sender, e, True)
  1476. Else
  1477. Operaciones.ValidarEntrada(sender, e, False)
  1478. End If
  1479. End Sub
  1480. Private Sub txtComisionPorcentajeBolsaVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorcentajeBolsaVenta.KeyPress
  1481. If String.IsNullOrEmpty(txtComisionPorcentajeBolsaVenta.Text) Then
  1482. If e.KeyChar = "." Then
  1483. txtComisionPorcentajeBolsaVenta.Text = "0"
  1484. Exit Sub
  1485. End If
  1486. End If
  1487. If (Not txtComisionPorcentajeBolsaVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1488. Operaciones.ValidarEntrada(sender, e, True)
  1489. Else
  1490. Operaciones.ValidarEntrada(sender, e, False)
  1491. End If
  1492. End Sub
  1493. Private Sub btnCancelar_Click(sender As Object, e As EventArgs) Handles btnCancelar.Click
  1494. End Sub
  1495. Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles Panel1.Paint
  1496. End Sub
  1497. Private Sub TabPage1_Click(sender As Object, e As EventArgs) Handles TbOperacion.Click
  1498. End Sub
  1499. Private Sub txtGananciaCapitalTotalVenta_TextChanged(sender As Object, e As EventArgs) Handles txtGananciaCapitalTotalVenta.TextChanged
  1500. End Sub
  1501. Private Sub txtDiasDeTenenciaVenta_TextChanged(sender As Object, e As EventArgs) Handles txtDiasDeTenenciaVenta.TextChanged
  1502. End Sub
  1503. Private Sub Label9_Click(sender As Object, e As EventArgs) Handles Label9.Click
  1504. End Sub
  1505. Private Sub Label6_Click(sender As Object, e As EventArgs) Handles Label6.Click
  1506. End Sub
  1507. Private Sub txtIOFCompra_TextChanged(sender As Object, e As EventArgs) Handles txtIOFCompra.TextChanged
  1508. End Sub
  1509. Private Sub txtRentaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtRentaCompra.TextChanged
  1510. End Sub
  1511. Private Sub CalcularDividendos()
  1512. Dim Cantidad As Integer = dgvDividendos.Rows.Count - 2
  1513. For i As Integer = 0 To Cantidad
  1514. If (String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("Dividendo").Value)) Then
  1515. dgvDividendos.Rows(i).Cells("Dividendo").Value = 0
  1516. End If
  1517. If rdbEfectivo.Checked Then
  1518. If (String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("Dividendo").Value)) Then
  1519. dgvDividendos.Rows(i).Cells("Dividendo").Value = 0
  1520. End If
  1521. End If
  1522. Dim Dividendos As Double = dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString.Trim("%")
  1523. Dim Porcentaje As Double = dgvDividendos.Rows(i).Cells("PorcISR").Value
  1524. Dim Valor = dgvDividendos.Rows(i).Cells("CantidadBase").Value
  1525. If rdbEfectivo.Checked Then
  1526. Dim CalculoIB = CalculoIngresoBrutoEfectivo(Valor, Dividendos)
  1527. Dim CalculoRenta = CalculoIB * Porcentaje
  1528. Dim CalculoIN = CalculoIB - CalculoRenta
  1529. dgvDividendos.Rows(i).Cells("IngresoBruto").Value = CalculoIB
  1530. dgvDividendos.Rows(i).Cells("ISR").Value = CalculoRenta
  1531. dgvDividendos.Rows(i).Cells("IngresoNeto").Value = CalculoIN
  1532. Else
  1533. If (dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString.IndexOf("%") = -1) Then
  1534. dgvDividendos.Rows(i).Cells("Dividendo").Value = dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString + "%"
  1535. End If
  1536. Dim Dias As Integer = 0
  1537. Dim FechaInicialCorte As Date = Date.Now.Date
  1538. Dim FechaCorteCorte As Date = Date.Now.Date
  1539. If (dgvDividendos.Rows(i).Cells("FechaInicio").Value IsNot DBNull.Value And dgvDividendos.Rows(i).Cells("FechaCorte").Value IsNot DBNull.Value) Then
  1540. If (Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("FechaInicio").Value) And Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("FechaCorte").Value)) Then
  1541. FechaInicialCorte = dgvDividendos.Rows(i).Cells("FechaInicio").Value
  1542. FechaCorteCorte = dgvDividendos.Rows(i).Cells("FechaCorte").Value
  1543. Dias = DateDiff(DateInterval.Day, FechaInicialCorte, FechaCorteCorte)
  1544. Dias += 1
  1545. Dim CalculoIBP = CalculoIngresoBrutoPorcentaje(Valor, Dividendos, Dias, FechaInicialCorte)
  1546. Dim CalculoRenta = CalculoIBP * Porcentaje
  1547. Dim CalculoIN = CalculoIBP - CalculoRenta
  1548. dgvDividendos.Rows(i).Cells("IngresoBruto").Value = CalculoIBP
  1549. dgvDividendos.Rows(i).Cells("ISR").Value = CalculoRenta
  1550. dgvDividendos.Rows(i).Cells("IngresoNeto").Value = CalculoIN
  1551. End If
  1552. End If
  1553. End If
  1554. Next
  1555. CorrelativoSinBD()
  1556. End Sub
  1557. Public Sub btnActualizar_Click(sender As Object, e As EventArgs) Handles btnActualizar.Click
  1558. AgregarFechaCO()
  1559. CalcularDividendos()
  1560. End Sub
  1561. Private Sub TabPage3_Click(sender As Object, e As EventArgs) Handles TbDividendos.Click
  1562. End Sub
  1563. Sub LimpiarDividendosCambios(ByVal Calculo As Integer)
  1564. Dim Cantidad As Integer = dgvDividendos.Rows.Count - 2
  1565. For i As Integer = 0 To Cantidad
  1566. If (Calculo = 1) Then
  1567. If (Not dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString.IndexOf("%") = -1) Then
  1568. dgvDividendos.Rows(i).Cells("Dividendo").Value = dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString.ToString.Trim("%")
  1569. End If
  1570. Else
  1571. If (dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString.IndexOf("%") = -1) Then
  1572. dgvDividendos.Rows(i).Cells("Dividendo").Value = dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString + "%"
  1573. End If
  1574. End If
  1575. dgvDividendos.Rows(i).Cells("IngresoBruto").Value = 0
  1576. dgvDividendos.Rows(i).Cells("ISR").Value = 0
  1577. dgvDividendos.Rows(i).Cells("IngresoNeto").Value = 0
  1578. Next
  1579. End Sub
  1580. Sub CargarDividendos()
  1581. Dim Codigo As String = Variables.Codigo
  1582. Dim dr = oAccionesDAO.CargarDividendo(Codigo)
  1583. While dr.Read
  1584. dgvDividendos.Rows.Add("", "", dr("Fecha"), dr("Dividendo"), dr("CantidadBase"), dr("IngresoBruto"), dr("PorcISR"), dr("ISR"), dr("IngresoNeto"), "", dr("FechaInicio"), dr("FechaCorte"), dr("NumDiv"))
  1585. End While
  1586. End Sub
  1587. Private Sub btnGenerarAccion_Click(sender As Object, e As EventArgs)
  1588. End Sub
  1589. Private Sub dgvDividendos_CellMouseMove(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgvDividendos.CellMouseMove
  1590. If Cierre Then
  1591. AgregarFechaCO()
  1592. CalcularDividendos()
  1593. Cierre = False
  1594. End If
  1595. End Sub
  1596. Private Sub dgvDividendos_MouseMove(sender As Object, e As MouseEventArgs) Handles dgvDividendos.MouseMove
  1597. If Cierre Then
  1598. AgregarFechaCO()
  1599. CalcularDividendos()
  1600. Cierre = False
  1601. End If
  1602. End Sub
  1603. Private Sub btnQuitar_Click_1(sender As Object, e As EventArgs) Handles btnQuitar.Click
  1604. QuitarFila()
  1605. CorrelativoSinBD()
  1606. End Sub
  1607. Sub QuitarFila()
  1608. Dim result As Integer = MsgBox("¿Está seguro que desea eliminar la fila?", MsgBoxStyle.OkCancel)
  1609. ' Test result.
  1610. Dim codigo As String = Variables.Codigo
  1611. Dim Numero As Integer = dgvDividendos.CurrentRow.Cells("NumDiv").Value
  1612. If result = MsgBoxResult.Ok Then
  1613. Try
  1614. dgvDividendos.Rows.Remove(dgvDividendos.CurrentRow)
  1615. oAccionesDAO.EliminarElemenoInd(codigo, Numero)
  1616. Catch ex As Exception
  1617. MsgBox("No ha seleccionado una fila")
  1618. End Try
  1619. End If
  1620. End Sub
  1621. Private Sub txtPrecioSucioVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioSucioVenta.TextChanged
  1622. End Sub
  1623. Private Sub txtPrecioLimpioCompra_Leave(sender As Object, e As EventArgs) Handles txtPrecioLimpioCompra.Leave
  1624. Formato()
  1625. End Sub
  1626. Private Sub txtComisionPorcentajeCasaCompra_Leave(sender As Object, e As EventArgs) Handles txtComisionPorcentajeCasaCompra.Leave
  1627. Formato()
  1628. End Sub
  1629. Private Sub txtComisionPorcentajeBolsaCompra_Leave(sender As Object, e As EventArgs) Handles txtComisionPorcentajeBolsaCompra.Leave
  1630. Formato()
  1631. End Sub
  1632. Private Sub txtPrecioLimpioVenta_Leave(sender As Object, e As EventArgs) Handles txtPrecioLimpioVenta.Leave
  1633. Formato()
  1634. End Sub
  1635. Private Sub txtUnidadesVenta_Leave(sender As Object, e As EventArgs) Handles txtUnidadesVenta.Leave
  1636. Formato()
  1637. End Sub
  1638. Private Sub txtComisionPorcentajeCasaVenta_Leave(sender As Object, e As EventArgs) Handles txtComisionPorcentajeCasaVenta.Leave
  1639. Formato()
  1640. End Sub
  1641. Private Sub txtComisionPorcentajeBolsaVenta_Leave(sender As Object, e As EventArgs) Handles txtComisionPorcentajeBolsaVenta.Leave
  1642. Formato()
  1643. End Sub
  1644. Private Sub frmAcciones_Resize(sender As Object, e As EventArgs) Handles MyBase.Resize
  1645. Redimencionar()
  1646. End Sub
  1647. Private Sub txtPrecioLimpioCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioLimpioCompra.KeyUp
  1648. If txtPrecioLimpioCompra.Text = "." Then
  1649. txtPrecioLimpioCompra.Text = ".0"
  1650. End If
  1651. End Sub
  1652. Private Sub txtUnidadesCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtUnidadesCompra.KeyUp
  1653. If txtUnidadesCompra.Text = "." Then
  1654. txtUnidadesCompra.Text = ".0"
  1655. End If
  1656. End Sub
  1657. Private Sub txtComisionPorcentajeCasaCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorcentajeCasaCompra.KeyUp
  1658. If txtComisionPorcentajeCasaCompra.Text = "." Then
  1659. txtComisionPorcentajeCasaCompra.Text = ".0"
  1660. End If
  1661. End Sub
  1662. Private Sub txtComisionPorcentajeBolsaCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorcentajeBolsaCompra.KeyUp
  1663. If txtComisionPorcentajeBolsaCompra.Text = "." Then
  1664. txtComisionPorcentajeBolsaCompra.Text = ".0"
  1665. End If
  1666. End Sub
  1667. Private Sub txtPrecioLimpioVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioLimpioVenta.KeyUp
  1668. If txtPrecioLimpioVenta.Text = "." Then
  1669. txtPrecioLimpioVenta.Text = ".0"
  1670. End If
  1671. End Sub
  1672. Private Sub txtUnidadesVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtUnidadesVenta.KeyUp
  1673. If txtUnidadesVenta.Text = "." Then
  1674. txtUnidadesVenta.Text = ".0"
  1675. End If
  1676. End Sub
  1677. Private Sub txtComisionPorcentajeCasaVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorcentajeCasaVenta.KeyUp
  1678. If txtComisionPorcentajeCasaVenta.Text = "." Then
  1679. txtComisionPorcentajeCasaVenta.Text = ".0"
  1680. End If
  1681. End Sub
  1682. Private Sub txtComisionPorcentajeBolsaVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorcentajeBolsaVenta.KeyUp
  1683. If txtComisionPorcentajeBolsaVenta.Text = "." Then
  1684. txtComisionPorcentajeBolsaVenta.Text = ".0"
  1685. End If
  1686. End Sub
  1687. Private Sub btnVenta_Click(sender As Object, e As EventArgs)
  1688. End Sub
  1689. Private Sub txtValorTransadoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtValorTransadoCompra.TextChanged
  1690. End Sub
  1691. Sub CargarTransladoNuevo()
  1692. Dim Existe As Boolean = ExisteInversion()
  1693. If CantFormAbierto = False Then
  1694. If Not RetCodigoInversionExiste And Not Existe Then
  1695. Dim TipoTransaccionCompraVenta As String = Variables.TipoTransaccionCompraVenta
  1696. If TipoTransaccionCompraVenta = "C" Then
  1697. txtPrecioLimpioCompra.Text = Variables.RetPrecio
  1698. txtUnidadesCompra.Text = Variables.RetUnidadesAcciones
  1699. ElseIf TipoTransaccionCompraVenta = "V" Then
  1700. txtPrecioLimpioVenta.Text = Variables.RetPrecio
  1701. txtUnidadesVenta.Text = Variables.RetUnidadesAcciones
  1702. End If
  1703. End If
  1704. End If
  1705. End Sub
  1706. Private Sub btnVenderTitulo_Click(sender As Object, e As EventArgs) Handles btnVenderTitulo.Click
  1707. If Variables.InvocadorProInv = "frmINV" Then
  1708. Dim TrasladarDatos As New TrasladarDatosCMVTA
  1709. Dim General As New DAOGeneral
  1710. Dim Codigo = Variables.Codigo
  1711. Dim Tabla As String = "INV0"
  1712. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  1713. TrasladarDatos = RellenarDatosCMVTA()
  1714. If Existe Then
  1715. Dim CodigoInversion As String = Variables.Codigo
  1716. Dim frmPINVCMVTA As New frmPIN("V", CodigoInversion, TrasladarDatos)
  1717. frmINV.Close()
  1718. Me.Close()
  1719. frmPINVCMVTA.ShowDialog()
  1720. End If
  1721. End If
  1722. End Sub
  1723. Function RellenarDatosCMVTA()
  1724. Dim TrasladarDatos As New TrasladarDatosCMVTA
  1725. TrasladarDatos.FechaOperacionACC = Operaciones.ConvertirFecha(dtpFechaOperacionCompra.Value.ToString)
  1726. TrasladarDatos.FechaVencimientoACC = Operaciones.ConvertirFecha(dtpFechaVencimientoCompra.Value.ToString)
  1727. TrasladarDatos.PrecioLimpioACC = Operaciones.ConvertirDecimal(txtPrecioLimpioCompra.Text.ToString)
  1728. TrasladarDatos.UnidadesACC = Operaciones.ConvertirEntero(txtUnidadesCompra.Text.ToString)
  1729. TrasladarDatos.PorcentajeBolsaACC = Operaciones.ConvertirDecimal(txtComisionPorcentajeBolsaCompra.Text.ToString)
  1730. TrasladarDatos.PorcentajeCasaACC = Operaciones.ConvertirDecimal(txtComisionPorcentajeCasaCompra.Text.ToString)
  1731. TrasladarDatos.NombreInstrumento = "ACC"
  1732. TrasladarDatos.AgregarCMVTA = True
  1733. Return TrasladarDatos
  1734. End Function
  1735. Private Sub txtValorTransadoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtValorTransadoVenta.TextChanged
  1736. End Sub
  1737. Private Sub txtMontoNetoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtMontoNetoVenta.TextChanged
  1738. End Sub
  1739. Private Sub txtComisionCasaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtComisionCasaCompra.TextChanged
  1740. End Sub
  1741. Private Sub txtComisionCasaVenta_TextChanged(sender As Object, e As EventArgs) Handles txtComisionCasaVenta.TextChanged
  1742. End Sub
  1743. End Class