frmAcciones.vb 86 KB

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