frmAcciones.vb 108 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492
  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 PorcentajeComisionBolsa_Compra As Double = 0.070625
  19. Dim PorcentajeComisionBolsa_Venta As Double = 0.0353125
  20. Dim Cargar As Boolean = True
  21. Dim PorcentajeComisionCasa_Compra As Double = 0.45
  22. Dim PorcentajeComisionCasa_Venta As Double = 0.4
  23. Dim Agregar As Boolean = False
  24. Dim PorcentajeLIOF As Double = 0.25
  25. Dim oAccionesCE As AccionesCE = New AccionesCE
  26. Dim oAccionesDAO As New AccionesDAO
  27. Dim oDAOGeneral As New DAOGeneral
  28. Dim Estado As String = ""
  29. Dim MostrarMensaje As Boolean = False
  30. Dim EditarDividendos As Boolean = False
  31. Dim EditarISR As Boolean = False
  32. Dim CambioCalculo = False
  33. Dim HabilitarBoton As Boolean = False
  34. Dim DobleClick As Boolean = False
  35. Dim Operaciones As New Operaciones
  36. Dim InstrumentoFinanciero As String = oDAOGeneral.ObtenerInstrumento(Variables.Codigo)
  37. 'Dim oAccionesNEG As New AccionesNEG
  38. Dim Cargado As Boolean = False
  39. Dim Cierre As Boolean = False
  40. Dim DatosCargados As Boolean = False
  41. 'Dim dtImpuestosYComisiones As DataTable
  42. 'Dim dtDividendos As DataTable
  43. Private _Modo As String
  44. Private _IdDocumento As Integer
  45. Private _TipoDocumento As String
  46. Private _CodigoInversion As String
  47. Private _TipoTransaccion As String
  48. Public Property TipoTransaccion As String
  49. Get
  50. Return _TipoTransaccion
  51. End Get
  52. Set(value As String)
  53. _TipoTransaccion = value
  54. End Set
  55. End Property
  56. Private Property IdDocumento As Integer
  57. Get
  58. Return _IdDocumento
  59. End Get
  60. Set(value As Integer)
  61. _IdDocumento = value
  62. End Set
  63. End Property
  64. Private Property TipoDocumento As String
  65. Get
  66. Return _TipoDocumento
  67. End Get
  68. Set(value As String)
  69. _TipoDocumento = value
  70. End Set
  71. End Property
  72. Private Property CodigoInversion As String
  73. Get
  74. Return _CodigoInversion
  75. End Get
  76. Set(value As String)
  77. _CodigoInversion = value
  78. End Set
  79. End Property
  80. Sub Instrumento()
  81. If (InstrumentoFinanciero = "ACCNC") Then
  82. lblTitulo.Text = "Acciones Nacionales Comunes"
  83. Me.Text = "Acciones Nacionales Comunes"
  84. ElseIf (InstrumentoFinanciero = "ACCNP") Then
  85. lblTitulo.Text = "Acciones Preferentes Nacionales"
  86. ModificacionesPreferentes()
  87. Me.Text = "Acciones Preferentes Nacionales"
  88. ElseIf (InstrumentoFinanciero = "ACCI") Then
  89. lblTitulo.Text = "Acciones Internacionales"
  90. Me.Text = "Acciones Internacionales"
  91. End If
  92. End Sub
  93. Function ColeccionDatos()
  94. Dim coleccion As New Collection
  95. Dim PrecioLimpioC, FOperC, FLiqC, DiasTC, GCapTotC, GCapUnC, RetAnBrC, RetAnNetC, UnC, ValTransC, MontoNetoC, PrecSucioC
  96. Dim PrecioLimpioV, FOperV, FLiqV, DiasTV, GCapTotV, GCapUnV, RetAnBrV, RetAnNetV, UnV, ValTransV, MontoNetoV, PrecSucioV
  97. Dim ComisionCompraCasa, ComisionCompraBolsa, ComisionVentaCasa, ComisionVentaBolsa As Double
  98. Dim IOF, Renta, Tipo, RetornoBruto, RetornoNeto
  99. Dim ComisionCompraCasaValor, ComisionCompraBolsaValor, ComisionVentaCasaValor, ComisionVentaBolsaValor As Double
  100. PrecioLimpioC = txtPrecioLimpioCompra.Text.Trim("%")
  101. FOperC = dtpFechaOperacionCompra.Value
  102. FLiqC = dtpFechaVencimientoCompra.Value
  103. DiasTC = txtDiasDeTenenciaCompra.Text.Trim("%")
  104. GCapTotC = txtGananciaCapitalTotalCompra.Text.Trim("%")
  105. GCapUnC = txtGananciaCapitalUnitarioCompra.Text.Trim("%")
  106. RetAnNetC = txtRetornoAnualNetoCompra.Text.Trim("%")
  107. UnC = txtUnidadesCompra.Text.Trim("%")
  108. ValTransC = txtValorTransadoCompra.Text.Trim("%")
  109. MontoNetoC = txtMontoNetoCompra.Text.Trim("%")
  110. PrecSucioC = txtPrecioSucioCompra.Text.Trim("%")
  111. PrecioLimpioV = txtPrecioLimpioVenta.Text.Trim("%")
  112. FOperV = dtpFechaOperacionVenta.Value
  113. FLiqV = dtpFechaVencimientoVenta.Value
  114. DiasTV = txtDiasDeTenenciaVenta.Text.Trim("%")
  115. GCapTotV = txtGananciaCapitalTotalVenta.Text.Trim("%")
  116. GCapUnV = txtGananciaCapitalUnitarioVenta.Text.Trim("%")
  117. RetAnBrV = txtRetornoAnualBrutoVenta.Text.Trim("%")
  118. RetAnNetV = txtRetornoAnualNetoVenta.Text.Trim("%")
  119. UnV = txtUnidadesVenta.Text.Trim("%")
  120. ValTransV = txtValorTransadoVenta.Text.Trim("%")
  121. MontoNetoV = txtMontoNetoVenta.Text.Trim("%")
  122. PrecSucioV = txtPrecioSucioVenta.Text.Trim("%")
  123. ComisionCompraCasa = txtComisionPorcentajeCasaCompra.Text.Trim("%") / 100
  124. ComisionCompraBolsa = txtComisionPorcentajeBolsaCompra.Text.Trim("%") / 100
  125. ComisionVentaCasa = txtComisionPorcentajeCasaVenta.Text.Trim("%") / 100
  126. ComisionVentaBolsa = txtComisionPorcentajeBolsaVenta.Text.Trim("%") / 100
  127. ComisionCompraCasaValor = txtComisionCasaCompra.Text
  128. ComisionCompraBolsaValor = txtComisionBolsaCompra.Text
  129. ComisionVentaCasaValor = txtComisionCasaVenta.Text
  130. ComisionVentaBolsaValor = txtComisionBolsaVenta.Text
  131. If (Not String.IsNullOrEmpty(txtRetornoAnualBrutoCompra.Text.ToString.ToString.Trim("%"))) Then
  132. RetornoBruto = txtRetornoAnualBrutoCompra.Text.Trim("%") / 100
  133. Else
  134. RetornoBruto = 0
  135. End If
  136. If (ChkIOF.Checked) Then
  137. IOF = 1
  138. Else
  139. IOF = 0
  140. End If
  141. If (ChkRenta.Checked) Then
  142. Renta = 1
  143. Else
  144. Renta = 0
  145. End If
  146. If rdbPorcentaje.Checked Then
  147. Tipo = "Porcentaje"
  148. Else
  149. Tipo = "Efectivo"
  150. End If
  151. coleccion.Add(PrecioLimpioC)
  152. coleccion.Add(FOperC)
  153. coleccion.Add(FLiqC)
  154. coleccion.Add(DiasTC)
  155. coleccion.Add(GCapTotC)
  156. coleccion.Add(GCapUnC)
  157. coleccion.Add(RetornoBruto)
  158. coleccion.Add(RetAnNetC)
  159. coleccion.Add(UnC)
  160. coleccion.Add(ValTransC)
  161. coleccion.Add(MontoNetoC)
  162. coleccion.Add(PrecSucioC)
  163. coleccion.Add(PrecioLimpioV)
  164. coleccion.Add(FOperV)
  165. coleccion.Add(FLiqV)
  166. coleccion.Add(DiasTV)
  167. coleccion.Add(GCapTotV)
  168. coleccion.Add(GCapUnV)
  169. coleccion.Add(RetAnBrV)
  170. coleccion.Add(RetAnNetV)
  171. coleccion.Add(UnV)
  172. coleccion.Add(ValTransV)
  173. coleccion.Add(MontoNetoV)
  174. coleccion.Add(PrecSucioV)
  175. coleccion.Add(ComisionCompraCasa)
  176. coleccion.Add(ComisionCompraBolsa)
  177. coleccion.Add(ComisionVentaCasa)
  178. coleccion.Add(ComisionVentaBolsa)
  179. coleccion.Add(IOF)
  180. coleccion.Add(Renta)
  181. coleccion.Add(Tipo)
  182. coleccion.Add(ComisionCompraCasaValor)
  183. coleccion.Add(ComisionCompraBolsaValor)
  184. coleccion.Add(ComisionVentaCasaValor)
  185. coleccion.Add(ComisionVentaBolsaValor)
  186. Return coleccion
  187. End Function
  188. Function Correlativo()
  189. Dim Index As Integer = 0
  190. Dim IndexCantidad As Integer = dgvDividendos.Rows.Count - 2
  191. Dim NumeroMayor As Integer = 0
  192. While Index <= IndexCantidad
  193. Dim Numero As Integer = dgvDividendos.Rows(Index).Cells("NumDiv").Value
  194. If Numero > NumeroMayor Then
  195. NumeroMayor = Numero
  196. End If
  197. Index += 1
  198. End While
  199. Return NumeroMayor + 1
  200. End Function
  201. Sub CorrelativoSinBD()
  202. Dim Index As Integer = 0
  203. Dim IndexCantidad As Integer = dgvDividendos.Rows.Count - 2
  204. Dim NumeroMayor As Integer = 0
  205. While Index <= IndexCantidad
  206. dgvDividendos.Rows(Index).Cells("Correlativo").Value = Index + 1
  207. Index += 1
  208. End While
  209. End Sub
  210. Function ColeccionesElementos(ByVal Index As Integer)
  211. Dim coleccion As New Collection
  212. Dim Fecha, Estado, Dividendo, CantidadBase, IngresoBruto, PorcISR, ISR, IngresoNeto, Correlativo, Tipo, FechaInicio, FechaCorte
  213. If rdbPorcentaje.Checked Then
  214. Tipo = "Porcentaje"
  215. Else
  216. Tipo = "Efectivo"
  217. End If
  218. Fecha = CDate(dgvDividendos.Rows(Index).Cells("Fecha").Value)
  219. Dividendo = dgvDividendos.Rows(Index).Cells("Dividendo").Value.ToString.Trim("%")
  220. If (Tipo = "Porcentaje") Then
  221. Dividendo /= 100
  222. End If
  223. CantidadBase = dgvDividendos.Rows(Index).Cells("CantidadBase").Value.ToString.TrimEnd("%")
  224. IngresoBruto = dgvDividendos.Rows(Index).Cells("IngresoBruto").Value.ToString.TrimEnd("%")
  225. PorcISR = dgvDividendos.Rows(Index).Cells("PorcISR").Value.ToString.TrimEnd("%")
  226. ISR = dgvDividendos.Rows(Index).Cells("ISR").Value.ToString.TrimEnd("%")
  227. IngresoNeto = dgvDividendos.Rows(Index).Cells("IngresoNeto").Value.ToString.TrimEnd("%")
  228. Estado = "A"
  229. Correlativo = dgvDividendos.Rows(Index).Cells("NumDiv").Value.ToString.TrimEnd("%")
  230. FechaInicio = dgvDividendos.Rows(Index).Cells("FechaInicio").Value
  231. FechaCorte = dgvDividendos.Rows(Index).Cells("FechaCorte").Value
  232. If (Tipo = "Porcentaje") Then
  233. If FechaInicio Is DBNull.Value Or FechaCorte Is DBNull.Value Then
  234. MsgBox("Verifique las fechas")
  235. Exit Function
  236. Else
  237. If (String.IsNullOrEmpty(FechaInicio) Or String.IsNullOrEmpty(FechaCorte)) Then
  238. MsgBox("Verifique las fechas")
  239. Exit Function
  240. End If
  241. End If
  242. End If
  243. coleccion.Add(Fecha)
  244. coleccion.Add(CDec(Dividendo))
  245. coleccion.Add(CDec(CantidadBase))
  246. coleccion.Add(CDec(IngresoBruto))
  247. coleccion.Add(CDec(PorcISR))
  248. coleccion.Add(CDec(ISR))
  249. coleccion.Add(CDec(IngresoNeto))
  250. coleccion.Add(Estado)
  251. coleccion.Add(CInt(Correlativo))
  252. coleccion.Add(FechaInicio)
  253. coleccion.Add(FechaCorte)
  254. Return coleccion
  255. End Function
  256. Sub NuevoElementoAccion(ByVal AgregarModificar As Boolean, ByVal Cantidad As Integer)
  257. Dim Codigo As String = Variables.Codigo
  258. Dim i As Integer = 0
  259. Dim Index = dgvDividendos.Rows.Count - 2
  260. i = Cantidad
  261. While i <= Index
  262. Dim coleccion = ColeccionesElementos(i)
  263. If (oAccionesDAO.NuevoElementoAccion(Codigo, coleccion) Is Nothing) Then
  264. Exit Sub
  265. End If
  266. i += 1
  267. End While
  268. MsgBox("Registro de ingresos actualizados")
  269. End Sub
  270. Function CanRegistros()
  271. Dim Tabla As String = String.Empty
  272. Tabla = "ACC1"
  273. Dim Codigo = Variables.Codigo
  274. Dim Cantidad As Integer = oDAOGeneral.CantidadRegistros(Codigo, Tabla)
  275. Return Cantidad
  276. End Function
  277. Sub ModificarElementoAccion()
  278. Dim i As Integer = 0
  279. Dim CantidadRegistrosDB = CanRegistros()
  280. While i < CantidadRegistrosDB
  281. Dim coleccion = ColeccionesElementos(i)
  282. If oAccionesDAO.ModificarElementoAccion(Codigo, coleccion) Is Nothing Then
  283. Exit Sub
  284. End If
  285. i += 1
  286. End While
  287. NuevoElementoAccion(True, CantidadRegistrosDB)
  288. End Sub
  289. Function ColeccionNuevo(ByVal codigo As String)
  290. Dim i As Integer = 0
  291. Dim diccionario As New Dictionary(Of String, Collection)
  292. Dim Index = dgvDividendos.Rows.Count - 2
  293. While i <= Index
  294. Dim coleccion = ColeccionesElementos(i)
  295. diccionario.Add(i, coleccion)
  296. i += 1
  297. End While
  298. Return diccionario
  299. End Function
  300. Public Function NuevaAccion()
  301. Dim Coleccion = ColeccionDatos()
  302. 'Dim Codigo = Variables.Codigo
  303. 'oAccionesDAO.NuevaAccion(Codigo, Coleccion)
  304. Return Coleccion
  305. End Function
  306. Public Function NuevaAccionConsulta()
  307. Dim Coleccion = ColeccionDatos()
  308. Dim Codigo = Variables.Codigo
  309. oAccionesDAO.NuevaAccion(Codigo, Coleccion)
  310. Return Coleccion
  311. End Function
  312. Sub ModificarAccion()
  313. Dim Coleccion = ColeccionDatos()
  314. Dim Codigo = Variables.Codigo
  315. oAccionesDAO.ModificarAccion(Codigo, Coleccion)
  316. End Sub
  317. Sub Eliminar()
  318. Dim Codigo = Variables.Codigo
  319. oAccionesDAO.Eliminar(Codigo)
  320. End Sub
  321. 'Sub EliminrElementoAccion()
  322. ' Dim Codigo = Variables.Codigo
  323. ' 'oAccionesDAO.EliminarElemeno(Codigo)
  324. 'End Sub
  325. Sub ModificacionesPreferentes()
  326. GrpVenta.Visible = False
  327. txtRetornoAnualBrutoCompra.Visible = True
  328. txtRetornoAnualBrutoCompra.ReadOnly = False
  329. txtRetornoAnualBrutoCompra.Text = "0.0"
  330. Label19.Visible = False
  331. End Sub
  332. Sub Redimencionar()
  333. dgvDividendos.Width = Me.Width - 10
  334. dgvDividendos.Height = Me.Height - 50
  335. End Sub
  336. Private Sub frmAcciones_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  337. Dim VExisteInversion As Boolean = False
  338. VExisteInversion = ExisteInversion()
  339. If VExisteInversion Then
  340. TipoOperacion = "C"
  341. TipoTransaccion = "C"
  342. Else
  343. TipoOperacion = String.Empty
  344. TipoTransaccion = String.Empty
  345. End If
  346. If Variables.TipoOperacionCMVTA = "C" Then
  347. GrpVenta.Enabled = False
  348. GrpCompra.Enabled = True
  349. Else
  350. GrpVenta.Enabled = True
  351. GrpCompra.Enabled = False
  352. End If
  353. Call Instrumento()
  354. HabilitarBotones()
  355. PrepararTablaDividendos()
  356. If VExisteInversion Then
  357. TipoOperacion = "C"
  358. TipoTransaccion = "C"
  359. Else
  360. TipoOperacion = String.Empty
  361. TipoTransaccion = String.Empty
  362. End If
  363. If TipoTransaccion = "C" Then
  364. Call CargarRegistroBD()
  365. Formato()
  366. ValidarRentaIOF()
  367. CargarDividendos()
  368. End If
  369. ModificarDividendo()
  370. CalcularDividendos()
  371. Cargado = True
  372. ValidarExistencia()
  373. Formato()
  374. DatosCargados = True
  375. CargarTransladoNuevo()
  376. ConfiguracionCMVTA(VExisteInversion)
  377. End Sub
  378. Sub ConfiguracionCMVTA(ByRef VExisteInversion As Boolean)
  379. Dim Codigo As String = Variables.Codigo
  380. Dim ExisteCMVTA As Boolean = oDAOGeneral.ExisteCMVTA(Codigo)
  381. If Not ExisteCMVTA And Variables.InvocadorProInv = "frmINV" Then
  382. btnVenderTitulo.Visible = True
  383. End If
  384. If CantFormAbierto = False And Not VExisteInversion Then
  385. If Not Variables.TrasladarCMVTA Is Nothing Then
  386. dtpFechaOperacionCompra.Value = Variables.TrasladarCMVTA.FechaOperacionACC
  387. dtpFechaVencimientoCompra.Value = Variables.TrasladarCMVTA.FechaVencimientoACC
  388. txtPrecioLimpioCompra.Text = Variables.TrasladarCMVTA.PrecioLimpioACC
  389. txtUnidadesCompra.Text = Variables.TrasladarCMVTA.UnidadesACC
  390. txtComisionPorcentajeCasaCompra.Text = Variables.TrasladarCMVTA.PorcentajeCasaACC
  391. txtComisionPorcentajeBolsaCompra.Text = Variables.TrasladarCMVTA.PorcentajeBolsaACC
  392. End If
  393. End If
  394. End Sub
  395. Function ExisteInversion()
  396. Dim Codigo As String = Variables.Codigo
  397. Dim TablaINV As String = "INV0"
  398. Dim TablaPINV As String = "PIN0"
  399. Dim General As New DAOGeneral
  400. Dim InvPro = Variables.InvPro
  401. If InvPro = "I" Then
  402. Dim INV0 As Boolean = General.ExisteTitulo(Codigo, TablaINV)
  403. If INV0 Then
  404. navNuevo.Visible = True
  405. Return True
  406. Else
  407. navNuevo.Visible = False
  408. Return False
  409. End If
  410. End If
  411. If InvPro = "P" Then
  412. Dim PINV0 As Boolean = General.ExisteTitulo(Codigo, TablaPINV)
  413. If PINV0 Then
  414. navNuevo.Visible = True
  415. Return True
  416. Else
  417. navNuevo.Visible = False
  418. Return False
  419. End If
  420. End If
  421. Return False
  422. End Function
  423. Function ExisteVenta()
  424. Dim Ventas As Boolean = False
  425. Dim General As New DAOGeneral
  426. Dim Codigo As String = Variables.Codigo
  427. Ventas = General.ExisteVenta(Codigo)
  428. Return Ventas
  429. End Function
  430. Sub ModificarDividendo()
  431. Dim Cantidad As Integer = dgvDividendos.Rows.Count - 2
  432. For i As Integer = 0 To Cantidad
  433. If rdbPorcentaje.Checked Then
  434. dgvDividendos.Rows(i).Cells("Dividendo").Value *= 100
  435. End If
  436. Next
  437. End Sub
  438. 'LOAD
  439. 'Sub ActualizarDividendos()
  440. 'Dim vFactorDeDividendo = oAccionesCE.FactorDeDividendo
  441. 'Dim vFechaInicial = oAccionesCE.FechaLiquidacionCompra
  442. 'Dim vFechaLiquidacionVenta = oAccionesCE.FechaLiquidacionVenta
  443. 'Dim vUnidadesVenta = oAccionesCE.CantidadVenta
  444. 'Dim vAccionPreferente = oAccionesCE.AccionPreferente
  445. 'Dim vValorTransadoCompra = oAccionesCE.ValorTransadoCompra
  446. 'Dim Periodos As Integer
  447. 'Dim Periodicidad As String = "A"
  448. 'Dim Filas As DataRow
  449. 'Dim FactorDidivendo As Double = vFactorDeDividendo
  450. 'Dim FechaInicial As Date = vFechaInicial
  451. 'Dim PorcentajeRenta As Double = 0.05
  452. 'Dim IngresoBruto As Double
  453. 'Dim Renta As Double
  454. 'Dim IngresoNeto As Double
  455. 'Dim SumaImgresoBruto As Double
  456. 'Dim SumaImgresoNeto As Double
  457. 'Dim Suma As Object
  458. 'If Periodicidad = "A" Then
  459. ' Periodos = DateDiff(DateInterval.Year, vFechaInicial, vFechaLiquidacionVenta)
  460. 'End If
  461. 'For i As Integer = 1 To Periodos
  462. 'If Periodicidad = "A" Then
  463. ' FechaInicial = FechaInicial.AddYears(1)
  464. 'End If
  465. ' IngresoBruto = FactorDidivendo * vUnidadesVenta
  466. 'If vAccionPreferente = "S" Then
  467. ' IngresoBruto = vValorTransadoCompra * FactorDidivendo
  468. 'End If
  469. ' Renta = IngresoBruto * PorcentajeRenta
  470. ' IngresoNeto = IngresoBruto - Renta
  471. ' Filas = dtDividendos.NewRow()
  472. ' Filas("Fecha") = FechaInicial
  473. ' Filas("Dividendo") = FactorDidivendo
  474. ' Filas("IngresoBruto") = IngresoBruto
  475. ' Filas("Renta") = Renta
  476. 'Filas("IngresoNeto") = IngresoNeto
  477. 'dtDividendos.Rows.Add(Filas)
  478. 'Next
  479. ' SumaImgresoBruto = Dividendos.Compute("SUM(IngresoBruto)", "").ToString
  480. ' Suma = dtDividendos.Compute("SUM(IngresoBruto)", "")
  481. 'If Suma IsNot DBNull.Value Then
  482. ' SumaImgresoBruto = Convert.ToDouble(Suma)
  483. 'End If
  484. ' SumaImgresoNeto = Dividendos.Compute("SUM(IngresoNeto)", "").ToString
  485. ' Suma = dtDividendos.Compute("SUM(IngresoNeto)", "")
  486. 'If Suma IsNot DBNull.Value Then
  487. ' SumaImgresoNeto = Convert.ToDouble(Suma)
  488. 'End If
  489. 'Me.txtIngresoBrutoDividendos_Venta.Text = SumaImgresoBruto.ToString
  490. 'Me.txtIngresoNetoDividendos_Venta.Text = SumaImgresoNeto.ToString
  491. 'Me.dgvDividendos.DataSource = dtDividendos
  492. ' RefrescarRetornoAnualBruto_Venta()
  493. ' RefrescarRetornoAnualNeto_Venta()
  494. 'End Sub
  495. Private Sub chkAccionPreferente_CheckedChanged(sender As Object, e As EventArgs)
  496. ControlChkAccionPreferente()
  497. End Sub
  498. Private Sub btnAceptar_Click(sender As Object, e As EventArgs) Handles btnAceptar.Click
  499. Dim codigo As String = Variables.Codigo
  500. Dim Accion As Collection = NuevaAccion()
  501. Dim ElementosAccion As Dictionary(Of String, Collection) = ColeccionNuevo(codigo)
  502. ''RefrescarClaseEntidad()
  503. 'ModificarElementoAccion()
  504. If (Estado = "N") Then
  505. oAccionesDAO.ProcesoDatos(Accion, codigo, ElementosAccion, "Nuevo")
  506. ElseIf Not ExisteValidacion() Then
  507. Variables.ColeccionACC = NuevaAccion()
  508. Me.Close()
  509. End If
  510. If Estado = "M" Then
  511. oAccionesDAO.ProcesoDatos(Accion, codigo, ElementosAccion, "Modificar")
  512. 'ActualizarRegistro()
  513. 'ModificarAccion()
  514. 'ModificarElementoAccion()
  515. End If
  516. If Estado = "B" Then
  517. 'ActualizarRegistro()
  518. 'EliminarAccion()
  519. Eliminar()
  520. End If
  521. ValidarExistencia()
  522. End Sub
  523. Sub ValidarExistencia()
  524. Dim General As New DAOGeneral
  525. Dim Codigo As String = Variables.Codigo
  526. Dim Tabla As String = String.Empty
  527. Tabla = "ACC0"
  528. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  529. If (Existe) Then
  530. navNuevo.Enabled = False
  531. TbDividendos.Enabled = True
  532. navModificar.Enabled = True
  533. navEliminar.Enabled = True
  534. Else
  535. navNuevo.Enabled = True
  536. TbDividendos.Enabled = False
  537. navModificar.Enabled = False
  538. navEliminar.Enabled = False
  539. DatosCargados = True
  540. End If
  541. TipoTransaccion = String.Empty
  542. btnAceptar.Text = "Aceptar"
  543. End Sub
  544. Function ExisteValidacion()
  545. Dim General As New DAOGeneral
  546. Dim Codigo As String = Variables.Codigo
  547. Dim Tabla As String = String.Empty
  548. Tabla = "ACC0"
  549. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  550. Return Existe
  551. End Function
  552. Public Function RetornarObjeto()
  553. Return oAccionesCE
  554. End Function
  555. Private Sub CargarRegistroBD()
  556. oAccionesCE = Nothing
  557. CodigoInversion = Variables.Codigo
  558. oAccionesCE = oAccionesDAO.CargarRegistro(Me.CodigoInversion)
  559. TipoTransaccion = "C"
  560. RefrescarValorControlesInicial()
  561. End Sub
  562. Public Sub CargarRegistro(vId As Integer, vTipo As String)
  563. TipoTransaccion = "C"
  564. IdDocumento = vId
  565. TipoDocumento = vTipo
  566. End Sub
  567. Public Sub CargarRegistro(ByRef vCodigoInversion As String)
  568. TipoTransaccion = "C"
  569. Me.CodigoInversion = vCodigoInversion
  570. End Sub
  571. Private Sub txtDiasDeTenencia_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtDiasDeTenenciaCompra.TextChanged
  572. End Sub
  573. Private Sub txtGananciaCapitalTotal_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtGananciaCapitalTotalCompra.TextChanged
  574. End Sub
  575. Private Sub txtGananciaCapitalUnitario_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtGananciaCapitalUnitarioCompra.TextChanged
  576. End Sub
  577. Private Sub txtRetornoAnualBruto_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtRetornoAnualBrutoCompra.TextChanged
  578. If (txtRetornoAnualBrutoCompra.ToString.IndexOf("%") = -1) Then
  579. txtRetornoAnualBrutoCompra.Text += "%"
  580. End If
  581. If (String.IsNullOrEmpty(txtRetornoAnualBrutoCompra.Text.ToString.Trim("%"))) Then
  582. txtRetornoAnualBrutoCompra.Text = "0.0%"
  583. End If
  584. End Sub
  585. Private Sub txtRetornoAnualNeto_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtRetornoAnualNetoCompra.TextChanged
  586. End Sub
  587. Private Sub cboCasa_C_SelectedIndexChanged(sender As Object, e As EventArgs)
  588. End Sub
  589. Private Sub txtPrecioSucio_Compra_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioSucioCompra.TextChanged
  590. End Sub
  591. Private Sub txtGananciaCapitalUnitario_Venta_TextChanged(sender As Object, e As EventArgs) Handles txtGananciaCapitalUnitarioVenta.TextChanged
  592. End Sub
  593. Private Sub txtRetornoAnualBruto_Venta_TextChanged(sender As Object, e As EventArgs) Handles txtRetornoAnualBrutoVenta.TextChanged
  594. End Sub
  595. Private Sub txtRetornoAnualNeto_Venta_TextChanged(sender As Object, e As EventArgs) Handles txtRetornoAnualNetoVenta.TextChanged
  596. End Sub
  597. Private Sub cboCasa_V_SelectedIndexChanged(sender As Object, e As EventArgs)
  598. End Sub
  599. Private Sub RefrescarValores()
  600. End Sub
  601. '********** CONTROL DE VALORES **********
  602. 'COMPRA
  603. Private Sub ControlPrecioLimpioCompra()
  604. If DatosCargados Then
  605. Dim valor As Double = 0
  606. If Not Double.TryParse(Me.txtPrecioLimpioCompra.Text, valor) Then
  607. oAccionesCE.PrecioLimpioVenta = "0.0"
  608. Else
  609. oAccionesCE.PrecioLimpioCompra = valor
  610. Me.txtPrecioLimpioCompra.BackColor = Color.White
  611. If (Me.TipoTransaccion = "N") Then
  612. oAccionesCE.PrecioLimpioVenta = oAccionesCE.PrecioLimpioCompra
  613. End If
  614. RefrescarValorControles()
  615. End If
  616. End If
  617. End Sub
  618. Private Sub ControlFechaOperacionCompra()
  619. oAccionesCE.FechaOperacionCompra = Me.dtpFechaOperacionCompra.Value.Date
  620. RefrescarValorControles()
  621. End Sub
  622. Private Sub ControlFechaLiquidacionCompra()
  623. oAccionesCE.FechaVencimientoCompra = Me.dtpFechaVencimientoCompra.Value.Date
  624. RefrescarValorControles()
  625. End Sub
  626. Private Sub ControlCantidadCompra()
  627. Dim valor As Integer = 0
  628. If Not Integer.TryParse(Me.txtUnidadesCompra.Text, valor) Then
  629. oAccionesCE.CantidadCompra = "0"
  630. Else
  631. Me.txtUnidadesCompra.BackColor = Color.White
  632. oAccionesCE.CantidadCompra = valor
  633. If (Me.TipoTransaccion = "N" Or TipoTransaccion = "A") Then
  634. oAccionesCE.CantidadVenta = oAccionesCE.CantidadCompra
  635. End If
  636. RefrescarValorControles()
  637. End If
  638. End Sub
  639. 'VENTA
  640. Private Sub ControlPrecioLimpioVenta()
  641. If DatosCargados Then
  642. Dim valor As Double
  643. If Not Double.TryParse(Me.txtPrecioLimpioVenta.Text, valor) Then
  644. oAccionesCE.PrecioLimpioVenta = "0.0"
  645. Else
  646. Me.txtPrecioLimpioVenta.BackColor = Color.White
  647. oAccionesCE.PrecioLimpioVenta = valor
  648. End If
  649. RefrescarValorControles()
  650. End If
  651. End Sub
  652. Private Sub ControlFechaOperacionVenta()
  653. oAccionesCE.FechaOperacionVenta = dtpFechaOperacionVenta.Value.Date
  654. RefrescarValorControles()
  655. End Sub
  656. Private Sub ControlFechaLiquidacionVenta()
  657. oAccionesCE.FechaVencimientoVenta = dtpFechaVencimientoVenta.Value.Date
  658. RefrescarValorControles()
  659. End Sub
  660. Private Sub ControlCantidadVenta()
  661. Dim valor As Integer
  662. If Not Integer.TryParse(Me.txtUnidadesVenta.Text, valor) Then
  663. Me.txtUnidadesVenta.Text = "0"
  664. oAccionesCE.CantidadVenta = "0"
  665. Else
  666. Me.txtUnidadesVenta.BackColor = Color.White
  667. oAccionesCE.CantidadVenta = valor
  668. End If
  669. RefrescarValorControles()
  670. End Sub
  671. Private Sub ControlChkBolsa()
  672. 'ActivarEdicion()
  673. End Sub
  674. Private Sub ControlChkAccionPreferente()
  675. 'ActivarEdicion()
  676. End Sub
  677. '********** FIN CONTROL DE VALORES **********
  678. '********** EVENTOS DE CONTROLES **********
  679. 'COMPRA
  680. Private Sub txtPrecioLimpioCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioLimpioCompra.TextChanged
  681. 'ControlPrecioLimpioCompra()
  682. 'ActivarEdicion()
  683. ControlPrecioLimpioCompra()
  684. End Sub
  685. Private Sub txtPrecioLimpioCompra_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioLimpioCompra.LostFocus
  686. ControlPrecioLimpioCompra()
  687. End Sub
  688. Private Sub dtpFechaOperacionCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaOperacionCompra.ValueChanged
  689. 'ActivarEdicion()
  690. If DatosCargados Then
  691. ControlFechaOperacionCompra()
  692. RefrescarValorControles()
  693. Formato()
  694. End If
  695. End Sub
  696. Private Sub dtpFechaLiquidacionCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimientoCompra.ValueChanged
  697. 'ActivarEdicion()
  698. If DatosCargados Then
  699. ControlFechaLiquidacionCompra()
  700. RefrescarValorControles()
  701. Formato()
  702. End If
  703. End Sub
  704. Private Sub txtUnidadesCompra_TextChanged(sender As Object, e As EventArgs) Handles txtUnidadesCompra.TextChanged
  705. 'ActivarEdicion()
  706. 'ControlCantidadCompra()
  707. If DatosCargados Then
  708. ControlCantidadCompra()
  709. CopiarDatos()
  710. End If
  711. End Sub
  712. Sub CopiarDatos()
  713. txtUnidadesVenta.Text = txtUnidadesCompra.Text
  714. End Sub
  715. Private Sub txtUnidadesCompra_LostFocus(sender As Object, e As EventArgs) Handles txtUnidadesCompra.LostFocus
  716. ControlCantidadCompra()
  717. End Sub
  718. 'VENTA
  719. Private Sub txtPrecioLimpioVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioLimpioVenta.TextChanged
  720. 'ActivarEdicion()
  721. 'ControlPrecioLimpioVenta()
  722. ControlPrecioLimpioVenta()
  723. End Sub
  724. Private Sub txtPrecioLimpioVenta_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioLimpioVenta.LostFocus
  725. ControlPrecioLimpioVenta()
  726. End Sub
  727. Private Sub dtpFechaOperacionVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaOperacionVenta.ValueChanged
  728. 'ActivarEdicion()
  729. If DatosCargados Then
  730. ControlFechaOperacionVenta()
  731. RefrescarValorControles()
  732. End If
  733. End Sub
  734. Private Sub dtpFechaLiquidacionVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimientoVenta.ValueChanged
  735. 'ActivarEdicion()
  736. If DatosCargados Then
  737. ControlFechaLiquidacionVenta()
  738. RefrescarValorControles()
  739. End If
  740. End Sub
  741. Private Sub txtUnidadesVenta_TextChanged(sender As Object, e As EventArgs) Handles txtUnidadesVenta.TextChanged
  742. 'ActivarEdicion()
  743. 'ControlCantidadVenta()
  744. If DatosCargados Then
  745. ControlCantidadVenta()
  746. MensajeAlerta()
  747. MostrarMensaje = True
  748. End If
  749. End Sub
  750. Sub MensajeAlerta()
  751. If (MostrarMensaje) Then
  752. Dim UnidadesVenta As Integer = 0
  753. Dim UnidadesCompra As Integer = 0
  754. If Not String.IsNullOrEmpty(txtUnidadesVenta.Text) Then
  755. UnidadesVenta = txtUnidadesVenta.Text
  756. End If
  757. If Not String.IsNullOrEmpty(txtUnidadesCompra.Text) Then
  758. UnidadesCompra = txtUnidadesCompra.Text
  759. End If
  760. If (CDec(UnidadesVenta) > CDec(UnidadesCompra)) Then
  761. MsgBox("Esta Tratando de Ingresar más acciones de las compradas, verifique los datos si ha cometido algún error.")
  762. End If
  763. End If
  764. End Sub
  765. Private Sub txtUnidadesVenta_LostFocus(sender As Object, e As EventArgs) Handles txtUnidadesVenta.LostFocus
  766. ControlCantidadVenta()
  767. End Sub
  768. Private Sub chkBolsa_CheckedChanged(sender As Object, e As EventArgs)
  769. ControlChkBolsa()
  770. End Sub
  771. '********** FIN EVENTOS DE CONTROLES **********
  772. '********** FUNCIONES **********
  773. Private Sub RefrescarClaseEntidad()
  774. ControlChkBolsa()
  775. ControlPrecioLimpioCompra()
  776. ControlFechaOperacionCompra()
  777. ControlFechaLiquidacionCompra()
  778. ControlCantidadCompra()
  779. ControlPrecioLimpioVenta()
  780. ControlFechaOperacionVenta()
  781. ControlFechaLiquidacionVenta()
  782. ControlCantidadVenta()
  783. 'RefrescarValorControles()
  784. End Sub
  785. Private Sub Formato()
  786. If DatosCargados Then
  787. If (String.IsNullOrEmpty(Me.txtRetornoAnualBrutoCompra.Text.ToString.Trim("%"))) Then
  788. Me.txtRetornoAnualBrutoCompra.Text = "0.0"
  789. End If
  790. If (String.IsNullOrEmpty(Me.txtComisionPorcentajeCasaCompra.Text.Trim("%"))) Then
  791. Me.txtComisionPorcentajeCasaCompra.Text = "0.0%"
  792. End If
  793. If (String.IsNullOrEmpty(Me.txtComisionPorcentajeBolsaCompra.Text.Trim("%"))) Then
  794. Me.txtComisionPorcentajeBolsaCompra.Text = "0.0%"
  795. End If
  796. If (String.IsNullOrEmpty(Me.txtComisionPorcentajeCasaVenta.Text.Trim("%"))) Then
  797. Me.txtComisionPorcentajeCasaVenta.Text = "0.0%"
  798. End If
  799. If (String.IsNullOrEmpty(Me.txtComisionPorcentajeBolsaVenta.Text.Trim("%"))) Then
  800. Me.txtComisionPorcentajeBolsaVenta.Text = "0.0%"
  801. End If
  802. If (String.IsNullOrEmpty(Me.txtComisionPorcentajeBolsaCompra.Text.Trim("%"))) Then
  803. Me.txtComisionPorcentajeBolsaCompra.Text = "0.0%"
  804. End If
  805. If (String.IsNullOrEmpty(Me.txtComisionPorcentajeBolsaVenta.Text.Trim("%"))) Then
  806. Me.txtComisionPorcentajeBolsaVenta.Text = "0.0%"
  807. End If
  808. If String.IsNullOrEmpty(txtRetornoAnualBrutoVenta.Text.ToString) Then
  809. txtRetornoAnualBrutoVenta.Text = 0
  810. End If
  811. If String.IsNullOrEmpty(txtPrecioLimpioCompra.Text.ToString) Then
  812. txtPrecioLimpioCompra.Text = 0
  813. End If
  814. If String.IsNullOrEmpty(txtPrecioLimpioVenta.Text.ToString) Then
  815. txtPrecioLimpioVenta.Text = 0
  816. End If
  817. If String.IsNullOrEmpty(txtUnidadesCompra.Text.ToString) Then
  818. txtUnidadesCompra.Text = 0
  819. End If
  820. If String.IsNullOrEmpty(txtUnidadesVenta.Text.ToString) Then
  821. txtUnidadesVenta.Text = 0
  822. End If
  823. If (txtComisionPorcentajeCasaVenta.ToString.IndexOf("%") = -1) Then
  824. txtComisionPorcentajeCasaVenta.Text += "%"
  825. End If
  826. If (txtComisionPorcentajeBolsaVenta.ToString.IndexOf("%") = -1) Then
  827. txtComisionPorcentajeBolsaVenta.Text += "%"
  828. End If
  829. If String.IsNullOrEmpty(txtGananciaCapitalUnitarioVenta.Text) Then
  830. txtGananciaCapitalUnitarioVenta.Text = 0
  831. End If
  832. If String.IsNullOrEmpty(txtRetornoAnualNetoVenta.Text) Then
  833. txtRetornoAnualNetoVenta.Text = 0
  834. End If
  835. End If
  836. End Sub
  837. Sub RefrescarValorControlesInicial()
  838. Me.txtRetornoAnualBrutoCompra.Text = oAccionesCE.RetornoBruto * 100
  839. Dim IOF = oAccionesCE.IOF
  840. Dim Renta = oAccionesCE.Renta
  841. If (IOF) Then
  842. ChkIOF.Checked = True
  843. Else
  844. ChkIOF.Checked = False
  845. End If
  846. If (Renta) Then
  847. ChkRenta.Checked = True
  848. Else
  849. ChkRenta.Checked = False
  850. End If
  851. Me.txtComisionPorcentajeCasaCompra.Text = CStr(oAccionesCE.ComisionPorcentajeCompraCasa * 100) + "%"
  852. Me.txtComisionPorcentajeBolsaCompra.Text = CStr(oAccionesCE.ComisionPorcentajeCompraBolsa * 100) + "%"
  853. Me.txtComisionPorcentajeCasaVenta.Text = CStr(oAccionesCE.ComisionPorcentajeVentaCasa * 100) + "%"
  854. Me.txtComisionPorcentajeBolsaVenta.Text = CStr(oAccionesCE.ComisionPorcentajeVentaBolsa * 100) + "%"
  855. Me.txtComisionCasaCompra.Text = oAccionesCE.ComisionCompraCasa
  856. Me.txtComisionBolsaCompra.Text = oAccionesCE.ComisionCompraBolsa
  857. Me.txtComisionCasaVenta.Text = oAccionesCE.ComisionVentaCasa
  858. Me.txtComisionBolsaVenta.Text = oAccionesCE.ComisionVentaBolsa
  859. If (oAccionesCE.Tipo = "Porcentaje") Then
  860. rdbPorcentaje.Checked = True
  861. ElseIf (oAccionesCE.Tipo = "Efectivo") Then
  862. rdbEfectivo.Checked = True
  863. End If
  864. 'COMPRA
  865. Me.txtPrecioLimpioCompra.Text = oAccionesCE.PrecioLimpioCompra.ToString()
  866. dtpFechaOperacionCompra.Value = CDate(oAccionesCE.FechaOperacionCompra)
  867. dtpFechaVencimientoCompra.Value = CDate(oAccionesCE.FechaVencimientoCompra)
  868. Me.txtDiasDeTenenciaCompra.Text = oAccionesCE.DiasDeTenenciaCompra.ToString
  869. Me.txtGananciaCapitalTotalCompra.Text = oAccionesCE.GananciaDeCapitalTotalCompra.ToString
  870. Me.txtGananciaCapitalUnitarioCompra.Text = oAccionesCE.GananciaDeCapitalUnitarioCompra.ToString
  871. Me.txtRetornoAnualNetoCompra.Text = oAccionesCE.RetornoAnualizadoNetoCompra.ToString()
  872. Me.txtUnidadesCompra.Text = oAccionesCE.CantidadCompra.ToString
  873. Me.txtValorTransadoCompra.Text = oAccionesCE.ValorTransadoCompra.ToString()
  874. ' ImpuestosCalculoCompra = CalcularComisionImpuestos(CDec(CalcularImpuesto()), CDec(txtValorTransadoCompra.Text))
  875. Dim ValorIOFCompra = 0.0, ValorRentaCompra = 0.0
  876. Me.txtMontoNetoCompra.Text = oAccionesCE.MontoNetoComprasus
  877. Me.txtPrecioSucioCompra.Text = oAccionesCE.PrecioSucioCompra.ToString()
  878. 'VENTA
  879. Me.txtPrecioLimpioVenta.Text = oAccionesCE.PrecioLimpioVenta.ToString()
  880. Me.dtpFechaOperacionVenta.Value = oAccionesCE.FechaOperacionVenta
  881. Me.dtpFechaVencimientoVenta.Value = oAccionesCE.FechaVencimientoVenta
  882. Me.txtDiasDeTenenciaVenta.Text = oAccionesCE.DiasDeTenenciaVenta.ToString
  883. Me.txtGananciaCapitalTotalVenta.Text = oAccionesCE.GananciaDeCapitalTotalVentasus.ToString()
  884. Me.txtGananciaCapitalUnitarioVenta.Text = oAccionesCE.GananciaDeCapitalUnitarioVenta.ToString
  885. txtRetornoAnualBrutoVenta.Text = oAccionesCE.RetornoAnualizadoBrutoVentasus.ToString
  886. Me.txtRetornoAnualNetoVenta.Text = oAccionesCE.RetornoAnualizadoNetoVenta.ToString()
  887. Me.txtUnidadesVenta.Text = oAccionesCE.CantidadVenta.ToString
  888. Me.txtValorTransadoVenta.Text = oAccionesCE.ValorTransadoVenta.ToString()
  889. Me.txtImpuestosYComisionesVenta.Text = oAccionesCE.SumaImpuestosYComisionesVenta.ToString()
  890. Dim ComisionCasaVenta As Double = 0
  891. Dim ComisionBolsaVenta As Double = 0
  892. Dim ValorTransadoVenta As Double = 0
  893. ' ImpuestosCalculoVenta = CalcularComisionImpuestos(CDec(CalcularImpuesto()), CDec(txtValorTransadoVenta.Text))
  894. Dim ValorIOFVenta = 0.0, ValorRentaVenta = 0.0
  895. Me.txtMontoNetoVenta.Text = oAccionesCE.MontoNetoVentasus.ToString
  896. Me.txtPrecioSucioVenta.Text = oAccionesCE.PrecioSucioVentasus.ToString()
  897. End Sub
  898. Sub RefrescarValorControles()
  899. If DatosCargados Then
  900. If (Cargar) Then
  901. If (String.IsNullOrEmpty(oAccionesCE.RetornoBruto.ToString())) Then
  902. Else
  903. Me.txtRetornoAnualBrutoCompra.Text = oAccionesCE.RetornoBruto * 100
  904. End If
  905. If String.IsNullOrEmpty(txtGananciaCapitalUnitarioVenta.Text) Then
  906. txtGananciaCapitalUnitarioVenta.Text = 0
  907. End If
  908. If String.IsNullOrEmpty(txtRetornoAnualNetoVenta.Text) Then
  909. txtRetornoAnualNetoVenta.Text = 0
  910. End If
  911. Dim IOF = oAccionesCE.IOF
  912. Dim Renta = oAccionesCE.Renta
  913. If (IOF) Then
  914. ChkIOF.Checked = True
  915. Else
  916. ChkIOF.Checked = False
  917. End If
  918. If (Renta) Then
  919. ChkRenta.Checked = True
  920. Else
  921. ChkRenta.Checked = False
  922. End If
  923. If (String.IsNullOrEmpty(Me.txtComisionPorcentajeCasaCompra.Text.TrimEnd("%"))) Then
  924. If (String.IsNullOrEmpty(oAccionesCE.ComisionCompraCasa)) Then
  925. Else
  926. If Not oAccionesCE.ComisionCompraCasa = "0" Then
  927. Me.txtComisionPorcentajeCasaCompra.Text = CStr(oAccionesCE.ComisionCompraCasa * 100) + "%"
  928. End If
  929. End If
  930. End If
  931. If (String.IsNullOrEmpty(Me.txtComisionPorcentajeBolsaCompra.Text.TrimEnd("%"))) Then
  932. If (String.IsNullOrEmpty(oAccionesCE.ComisionCompraBolsa)) Then
  933. Else
  934. If Not oAccionesCE.ComisionCompraBolsa = "0" Then
  935. Me.txtComisionPorcentajeBolsaCompra.Text = CStr(oAccionesCE.ComisionCompraBolsa * 100) + "%"
  936. End If
  937. End If
  938. End If
  939. If (String.IsNullOrEmpty(Me.txtComisionPorcentajeCasaVenta.Text.TrimEnd("%"))) Then
  940. If (String.IsNullOrEmpty(oAccionesCE.ComisionVentaCasa)) Then
  941. End If
  942. If Not oAccionesCE.ComisionVentaCasa = "0" Then
  943. Me.txtComisionPorcentajeCasaVenta.Text = CStr(oAccionesCE.ComisionVentaCasa * 100) + "%"
  944. End If
  945. End If
  946. If (String.IsNullOrEmpty(Me.txtComisionPorcentajeBolsaVenta.Text.TrimEnd("%"))) Then
  947. If (String.IsNullOrEmpty(oAccionesCE.ComisionVentaBolsa)) Then
  948. Else
  949. If Not oAccionesCE.ComisionVentaBolsa = "0" Then
  950. Me.txtComisionPorcentajeBolsaVenta.Text = CStr(oAccionesCE.ComisionVentaBolsa * 100) + "%"
  951. End If
  952. End If
  953. End If
  954. Else
  955. If (oAccionesCE.Tipo = "Porcentaje") Then
  956. rdbPorcentaje.Checked = True
  957. ElseIf (oAccionesCE.Tipo = "Efectivo") Then
  958. rdbEfectivo.Checked = True
  959. End If
  960. End If
  961. 'COMPRA
  962. If (String.IsNullOrEmpty(oAccionesCE.PrecioLimpioCompra.ToString())) Then
  963. Else
  964. If Not oAccionesCE.PrecioLimpioCompra.ToString() = "0" Then
  965. Me.txtPrecioLimpioCompra.Text = oAccionesCE.PrecioLimpioCompra.ToString()
  966. End If
  967. End If
  968. If (String.IsNullOrEmpty(oAccionesCE.FechaOperacionCompra)) Then
  969. Me.dtpFechaOperacionCompra.Value = Date.Now.Date
  970. Else
  971. Me.dtpFechaOperacionCompra.Value = oAccionesCE.FechaOperacionCompra
  972. End If
  973. If (String.IsNullOrEmpty(oAccionesCE.FechaVencimientoCompra)) Then
  974. Me.dtpFechaVencimientoCompra.Value = Date.Now.Date
  975. Else
  976. Me.dtpFechaVencimientoCompra.Value = oAccionesCE.FechaVencimientoCompra
  977. End If
  978. If (String.IsNullOrEmpty(oAccionesCE.DiasDeTenenciaCompra.ToString)) Then
  979. Else
  980. Me.txtDiasDeTenenciaCompra.Text = oAccionesCE.DiasDeTenenciaCompra.ToString
  981. End If
  982. If (String.IsNullOrEmpty(oAccionesCE.GananciaDeCapitalTotalCompra.ToString)) Then
  983. Else
  984. Me.txtGananciaCapitalTotalCompra.Text = oAccionesCE.GananciaDeCapitalTotalCompra.ToString
  985. End If
  986. If (String.IsNullOrEmpty(oAccionesCE.GananciaDeCapitalUnitarioCompra.ToString)) Then
  987. Else
  988. Me.txtGananciaCapitalUnitarioCompra.Text = oAccionesCE.GananciaDeCapitalUnitarioCompra.ToString
  989. End If
  990. If (String.IsNullOrEmpty(oAccionesCE.RetornoAnualizadoNetoCompra.ToString(Configuraciones.CodigoTXTPorcentaje))) Then
  991. Else
  992. Me.txtRetornoAnualNetoCompra.Text = oAccionesCE.RetornoAnualizadoNetoCompra.ToString()
  993. End If
  994. If (String.IsNullOrEmpty(oAccionesCE.CantidadCompra.ToString)) Then
  995. Else
  996. If Not oAccionesCE.CantidadCompra.ToString = "0" Then
  997. Me.txtUnidadesCompra.Text = oAccionesCE.CantidadCompra.ToString
  998. End If
  999. End If
  1000. If (String.IsNullOrEmpty(oAccionesCE.ValorTransadoCompra.ToString(Configuraciones.CodigoTXTMontos))) Then
  1001. Else
  1002. Me.txtValorTransadoCompra.Text = oAccionesCE.ValorTransadoCompra.ToString()
  1003. End If
  1004. Dim ComisionCasaCompra As Double = 0
  1005. Dim ComisionBolsaCompra As Double = 0
  1006. Dim ValorTransadoCompra As Double = 0
  1007. If String.IsNullOrEmpty(txtComisionPorcentajeCasaCompra.Text.TrimEnd("%")) Then
  1008. ComisionCasaCompra = 0
  1009. Else
  1010. ComisionCasaCompra = txtComisionPorcentajeCasaCompra.Text.TrimEnd("%") / 100
  1011. End If
  1012. If String.IsNullOrEmpty(txtComisionPorcentajeBolsaCompra.Text.TrimEnd("%")) Then
  1013. ComisionBolsaCompra = 0
  1014. Else
  1015. ComisionBolsaCompra = txtComisionPorcentajeBolsaCompra.Text.TrimEnd("%") / 100
  1016. End If
  1017. If Not String.IsNullOrEmpty(txtValorTransadoCompra.Text) Then
  1018. ValorTransadoCompra = txtValorTransadoCompra.Text
  1019. End If
  1020. Me.txtComisionCasaCompra.Text = CalcularComisionImpuestos(ComisionCasaCompra, txtValorTransadoCompra.Text)
  1021. Me.txtComisionBolsaCompra.Text = CalcularComisionImpuestos(ComisionBolsaCompra, txtValorTransadoCompra.Text)
  1022. ' ImpuestosCalculoCompra = CalcularComisionImpuestos(CDec(CalcularImpuesto()), CDec(txtValorTransadoCompra.Text))
  1023. If (String.IsNullOrEmpty(oAccionesCE.SumaImpuestosYComisionesCompra.ToString(Configuraciones.CodigoTXTMontos))) Then
  1024. Else
  1025. Me.txtImpuestosYComisionesCompra.Text = oAccionesCE.SumaImpuestosYComisionesCompra.ToString()
  1026. End If
  1027. Dim ValorIOFCompra = 0.0, ValorRentaCompra = 0.0
  1028. If (Not String.IsNullOrEmpty(txtIOFCompra.Text.ToString)) Then
  1029. ValorIOFCompra = txtIOFCompra.Text
  1030. End If
  1031. If (Not String.IsNullOrEmpty(txtRentaCompra.Text.ToString)) Then
  1032. ValorRentaCompra = txtRentaCompra.Text
  1033. End If
  1034. If (String.IsNullOrEmpty(oAccionesCE.PrecioSucioCompra.ToString(Configuraciones.CodigoTXTMontos))) Then
  1035. Else
  1036. Me.txtPrecioSucioCompra.Text = oAccionesCE.PrecioSucioCompra.ToString()
  1037. End If
  1038. 'VENTA
  1039. If (String.IsNullOrEmpty(oAccionesCE.PrecioLimpioVenta.ToString())) Then
  1040. Else
  1041. If Not oAccionesCE.PrecioLimpioVenta = 0 Then
  1042. Me.txtPrecioLimpioVenta.Text = oAccionesCE.PrecioLimpioVenta.ToString()
  1043. End If
  1044. End If
  1045. If (String.IsNullOrEmpty(oAccionesCE.FechaOperacionVenta)) Then
  1046. Me.dtpFechaOperacionVenta.Value = Date.Now.Date
  1047. Else
  1048. Me.dtpFechaOperacionVenta.Value = oAccionesCE.FechaOperacionVenta
  1049. End If
  1050. If (String.IsNullOrEmpty(oAccionesCE.FechaVencimientoVenta)) Then
  1051. Me.dtpFechaVencimientoVenta.Value = Date.Now.Date
  1052. Else
  1053. Me.dtpFechaVencimientoVenta.Value = oAccionesCE.FechaVencimientoVenta
  1054. End If
  1055. If (String.IsNullOrEmpty(oAccionesCE.DiasDeTenenciaVenta.ToString)) Then
  1056. Else
  1057. Me.txtDiasDeTenenciaVenta.Text = oAccionesCE.DiasDeTenenciaVenta.ToString
  1058. End If
  1059. If (String.IsNullOrEmpty(oAccionesCE.GananciaDeCapitalTotalVenta.ToString(Configuraciones.CodigoTXTMontos))) Then
  1060. Else
  1061. Me.txtGananciaCapitalTotalVenta.Text = oAccionesCE.GananciaDeCapitalTotalVenta.ToString()
  1062. End If
  1063. If (String.IsNullOrEmpty(oAccionesCE.GananciaDeCapitalUnitarioVenta.ToString)) Then
  1064. Else
  1065. If Double.IsNaN(oAccionesCE.GananciaDeCapitalUnitarioVenta.ToString) Then
  1066. Else
  1067. Me.txtGananciaCapitalUnitarioVenta.Text = oAccionesCE.GananciaDeCapitalUnitarioVenta.ToString
  1068. End If
  1069. End If
  1070. If String.IsNullOrEmpty(txtRetornoAnualBrutoVenta.Text.ToString) Then
  1071. txtRetornoAnualBrutoVenta.Text = 0
  1072. End If
  1073. Variables.IngresoBruto = CalcularIngresoBruto()
  1074. Variables.IngresoNeto = CalcularIngresoNeto()
  1075. If (rdbEfectivo.Checked) Then
  1076. If (String.IsNullOrEmpty(oAccionesCE.RetornoAnualizadoBrutoVenta.ToString(Configuraciones.CodigoTXTPorcentaje))) Then
  1077. Else
  1078. Me.txtRetornoAnualBrutoVenta.Text = oAccionesCE.RetornoAnualizadoBrutoVenta.ToString()
  1079. End If
  1080. Else
  1081. Dim Existe = dgvDividendos.Rows.Count
  1082. If (Existe >= 1) Then
  1083. If (Not dgvDividendos.Rows(0).Cells("Dividendo").Value Is Nothing) Then
  1084. Dim Valor = dgvDividendos.Rows(0).Cells("Dividendo").Value.ToString.Trim("%")
  1085. If (String.IsNullOrEmpty(Valor)) Then
  1086. Else
  1087. Me.txtRetornoAnualBrutoVenta.Text = CStr((CDec(Valor.ToString.Trim("%")) * 100)) + "%"
  1088. End If
  1089. End If
  1090. End If
  1091. End If
  1092. If (rdbEfectivo.Checked) Then
  1093. If (String.IsNullOrEmpty(oAccionesCE.RetornoAnualizadoNetoVenta.ToString(Configuraciones.CodigoTXTPorcentaje))) Then
  1094. Else
  1095. Me.txtRetornoAnualNetoVenta.Text = oAccionesCE.RetornoAnualizadoNetoVenta.ToString()
  1096. End If
  1097. Else
  1098. Dim Existe = dgvDividendos.Rows.Count
  1099. If (Existe >= 1) Then
  1100. Dim Valor = dgvDividendos.Rows(0).Cells("PorcISR").Value
  1101. If (String.IsNullOrEmpty(Valor)) Then
  1102. Else
  1103. Me.txtRetornoAnualNetoVenta.Text = CStr(CDec(txtRetornoAnualBrutoVenta.Text.Trim("%")) * (1 - Valor)) + "%"
  1104. End If
  1105. End If
  1106. End If
  1107. If (String.IsNullOrEmpty(oAccionesCE.CantidadVenta.ToString)) Then
  1108. Else
  1109. If Not oAccionesCE.CantidadVenta = 0 Then
  1110. Me.txtUnidadesVenta.Text = oAccionesCE.CantidadVenta.ToString
  1111. End If
  1112. End If
  1113. If (String.IsNullOrEmpty(oAccionesCE.ValorTransadoVenta.ToString())) Then
  1114. Else
  1115. Me.txtValorTransadoVenta.Text = oAccionesCE.ValorTransadoVenta.ToString()
  1116. End If
  1117. If (String.IsNullOrEmpty(oAccionesCE.SumaImpuestosYComisionesVenta.ToString())) Then
  1118. Else
  1119. Me.txtImpuestosYComisionesVenta.Text = oAccionesCE.SumaImpuestosYComisionesVenta.ToString()
  1120. End If
  1121. Dim ComisionCasaVenta As Double = 0
  1122. Dim ComisionBolsaVenta As Double = 0
  1123. Dim ValorTransadoVenta As Double = 0
  1124. If Not String.IsNullOrEmpty(txtComisionPorcentajeCasaVenta.Text.TrimEnd("%")) Then
  1125. ComisionCasaVenta = txtComisionPorcentajeCasaVenta.Text.TrimEnd("%") / 100
  1126. End If
  1127. If Not String.IsNullOrEmpty(txtComisionPorcentajeBolsaVenta.Text.TrimEnd("%")) Then
  1128. ComisionBolsaVenta = txtComisionPorcentajeBolsaVenta.Text.TrimEnd("%") / 100
  1129. End If
  1130. If Not String.IsNullOrEmpty(txtValorTransadoVenta.Text) Then
  1131. ValorTransadoVenta = txtValorTransadoVenta.Text
  1132. End If
  1133. Me.txtComisionCasaVenta.Text = CalcularComisionImpuestos(ComisionCasaVenta, ValorTransadoVenta)
  1134. Me.txtComisionBolsaVenta.Text = CalcularComisionImpuestos(ComisionBolsaVenta, ValorTransadoVenta)
  1135. ' ImpuestosCalculoVenta = CalcularComisionImpuestos(CDec(CalcularImpuesto()), CDec(txtValorTransadoVenta.Text))
  1136. txtGananciaCapitalTotalVenta.Text += SumaComisiones()
  1137. Dim ValorIOFVenta = 0.0, ValorRentaVenta = 0.0
  1138. If (Not String.IsNullOrEmpty(txtIOFVenta.Text.ToString)) Then
  1139. ValorIOFVenta = txtIOFVenta.Text
  1140. End If
  1141. If (Not String.IsNullOrEmpty(txtRentaVenta.Text.ToString)) Then
  1142. ValorRentaVenta = txtRentaVenta.Text
  1143. End If
  1144. If (String.IsNullOrEmpty(oAccionesCE.MontoNetoVenta.ToString())) Then
  1145. Else
  1146. Me.txtMontoNetoVenta.Text = CDec(oAccionesCE.MontoNetoVenta.ToString()) - CDec(txtComisionBolsaVenta.Text) - CDec(txtComisionCasaVenta.Text) - ValorIOFVenta - ValorRentaVenta
  1147. End If
  1148. If (String.IsNullOrEmpty(CDec(oAccionesCE.MontoNetoCompra.ToString(Configuraciones.CodigoTXTMontos)))) Or String.IsNullOrEmpty((CDec(txtComisionBolsaCompra.Text)) Or String.IsNullOrEmpty(CDec(txtComisionCasaCompra.Text)) Or String.IsNullOrEmpty(ValorIOFCompra) Or String.IsNullOrEmpty(ValorRentaCompra)) Then
  1149. Else
  1150. Me.txtMontoNetoCompra.Text = (CDec(oAccionesCE.MontoNetoCompra.ToString())) + (CDec(txtComisionBolsaCompra.Text) + CDec(txtComisionCasaCompra.Text) + ValorIOFCompra + ValorRentaCompra)
  1151. End If
  1152. If (String.IsNullOrEmpty(oAccionesCE.PrecioSucioVenta.ToString())) Then
  1153. Me.txtPrecioSucioVenta.Text = "0.0"
  1154. Else
  1155. If Double.IsNaN(oAccionesCE.PrecioSucioVenta.ToString()) Then
  1156. Me.txtPrecioSucioVenta.Text = "0.0"
  1157. Else
  1158. Me.txtPrecioSucioVenta.Text = oAccionesCE.PrecioSucioVenta.ToString()
  1159. End If
  1160. End If
  1161. End If
  1162. End Sub
  1163. Function CalcularIngresoBruto()
  1164. Dim Cantidad = dgvDividendos.Rows.Count - 1
  1165. Dim FechaActual = Date.Now.Date
  1166. Dim ContadorIngreso As Double = 0.0
  1167. For i As Integer = 0 To Cantidad
  1168. Try
  1169. If (Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("Fecha").Value.ToString)) Then
  1170. Dim FechaPrograma As Date = CDate(dgvDividendos.Rows(i).Cells("Fecha").Value.ToString)
  1171. If (FechaActual >= FechaPrograma) Then
  1172. If (Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("IngresoBruto").Value.ToString)) Then
  1173. ContadorIngreso += CDec(dgvDividendos.Rows(i).Cells("IngresoBruto").Value.ToString)
  1174. End If
  1175. End If
  1176. End If
  1177. Catch ex As Exception
  1178. End Try
  1179. Next
  1180. Return ContadorIngreso
  1181. End Function
  1182. Function CalcularIngresoNeto()
  1183. Dim Cantidad = dgvDividendos.Rows.Count - 1
  1184. Dim FechaActual = Date.Now.Date
  1185. Dim ContadorIngreso As Double = 0.0
  1186. For i As Integer = 0 To Cantidad
  1187. Try
  1188. If (Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("Fecha").Value.ToString)) Then
  1189. Dim FechaPrograma As Date = CDate(dgvDividendos.Rows(i).Cells("Fecha").Value.ToString)
  1190. If (FechaActual >= FechaPrograma) Then
  1191. If (Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("IngresoNeto").Value.ToString)) Then
  1192. ContadorIngreso += CDec(dgvDividendos.Rows(i).Cells("IngresoNeto").Value.ToString)
  1193. End If
  1194. End If
  1195. End If
  1196. Catch ex As Exception
  1197. End Try
  1198. Next
  1199. Return ContadorIngreso
  1200. End Function
  1201. Function SumaComisiones()
  1202. Dim ComisionCasaVenta As Double = txtComisionCasaVenta.Text
  1203. Dim ComisionBolsaVenta As Double = txtComisionBolsaVenta.Text
  1204. Dim Total As Double = 0.0
  1205. Total = ComisionCasaVenta + ComisionBolsaVenta
  1206. Return Total
  1207. End Function
  1208. Function CalcularComisionImpuestos(ByVal Comision As Double, ByVal ValorTransado As Double)
  1209. Return Comision * ValorTransado
  1210. End Function
  1211. Private Sub PrepararTablaImpuestosYComisiones()
  1212. Dim oDataGridViewTextBoxColumn As DataGridViewTextBoxColumn
  1213. Dim oDataGridViewComboBoxColumn As DataGridViewComboBoxColumn
  1214. oDataGridViewComboBoxColumn = New DataGridViewComboBoxColumn
  1215. oDataGridViewComboBoxColumn.Name = "CodImp"
  1216. oDataGridViewComboBoxColumn.HeaderText = "Tipo Impuesto"
  1217. oDataGridViewComboBoxColumn.DataSource = oDAOGeneral.ListaTiposImpuesto
  1218. oDataGridViewComboBoxColumn.ValueMember = "Codigo"
  1219. oDataGridViewComboBoxColumn.DisplayMember = "Descripcion"
  1220. oDataGridViewComboBoxColumn.DataPropertyName = "CodImp"
  1221. oDataGridViewComboBoxColumn.DisplayIndex = 0
  1222. ' Me.dgvImpuestosYComisiones.Columns.Add(oDataGridViewComboBoxColumn)
  1223. oDataGridViewComboBoxColumn = New DataGridViewComboBoxColumn
  1224. oDataGridViewComboBoxColumn.Name = "TipoOper"
  1225. oDataGridViewComboBoxColumn.HeaderText = "Tipo Operación"
  1226. oDataGridViewComboBoxColumn.DataSource = oDAOGeneral.ListaTipoOperacion
  1227. oDataGridViewComboBoxColumn.ValueMember = "Codigo"
  1228. oDataGridViewComboBoxColumn.DisplayMember = "Descripcion"
  1229. oDataGridViewComboBoxColumn.DataPropertyName = "TipoOper"
  1230. oDataGridViewComboBoxColumn.DisplayIndex = 1
  1231. ' Me.dgvImpuestosYComisiones.Columns.Add(oDataGridViewComboBoxColumn)
  1232. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1233. oDataGridViewTextBoxColumn.Name = "PorcImp"
  1234. oDataGridViewTextBoxColumn.HeaderText = "Porcentaje"
  1235. oDataGridViewTextBoxColumn.DataPropertyName = "PorcImp"
  1236. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  1237. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTPorcentaje
  1238. oDataGridViewTextBoxColumn.DisplayIndex = 2
  1239. ' Me.dgvImpuestosYComisiones.Columns.Add(oDataGridViewTextBoxColumn)
  1240. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1241. oDataGridViewTextBoxColumn.Name = "MontoSujeto"
  1242. oDataGridViewTextBoxColumn.HeaderText = "Monto Sujeto"
  1243. oDataGridViewTextBoxColumn.DataPropertyName = "MontoSujeto"
  1244. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  1245. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  1246. oDataGridViewTextBoxColumn.ReadOnly = True
  1247. oDataGridViewTextBoxColumn.DisplayIndex = 3
  1248. ' Me.dgvImpuestosYComisiones.Columns.Add(oDataGridViewTextBoxColumn)
  1249. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1250. oDataGridViewTextBoxColumn.Name = "MontoImp"
  1251. oDataGridViewTextBoxColumn.HeaderText = "Monto Impuesto"
  1252. oDataGridViewTextBoxColumn.DataPropertyName = "MontoImp"
  1253. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  1254. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  1255. oDataGridViewTextBoxColumn.DisplayIndex = 4
  1256. oDataGridViewTextBoxColumn.ReadOnly = True
  1257. ' Me.dgvImpuestosYComisiones.Columns.Add(oDataGridViewTextBoxColumn)
  1258. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1259. oDataGridViewTextBoxColumn.Name = "CodInv"
  1260. oDataGridViewTextBoxColumn.DataPropertyName = "CodInv"
  1261. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  1262. oDataGridViewTextBoxColumn.Visible = False
  1263. ' Me.dgvImpuestosYComisiones.Columns.Add(oDataGridViewTextBoxColumn)
  1264. ' Me.dgvImpuestosYComisiones.DataSource = oAccionesCE.ImpuestosYComisiones
  1265. End Sub
  1266. Private Sub PrepararTablaDividendos()
  1267. Dim oDataGridViewTextBoxColumn As DataGridViewTextBoxColumn
  1268. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1269. oDataGridViewTextBoxColumn.Name = "CodInv"
  1270. oDataGridViewTextBoxColumn.DataPropertyName = "CodInv"
  1271. oDataGridViewTextBoxColumn.HeaderText = "Código Inversión"
  1272. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  1273. oDataGridViewTextBoxColumn.Visible = False
  1274. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  1275. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1276. oDataGridViewTextBoxColumn.Name = "Correlativo"
  1277. oDataGridViewTextBoxColumn.DataPropertyName = "Correlativo"
  1278. oDataGridViewTextBoxColumn.HeaderText = "Correlativo"
  1279. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  1280. oDataGridViewTextBoxColumn.Visible = True
  1281. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  1282. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1283. oDataGridViewTextBoxColumn.Name = "Fecha"
  1284. oDataGridViewTextBoxColumn.DataPropertyName = "Fecha"
  1285. oDataGridViewTextBoxColumn.HeaderText = "Fecha"
  1286. oDataGridViewTextBoxColumn.Name = "Fecha"
  1287. oDataGridViewTextBoxColumn.ValueType = GetType(Date)
  1288. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  1289. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1290. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  1291. oDataGridViewTextBoxColumn.Name = "Dividendo"
  1292. oDataGridViewTextBoxColumn.DataPropertyName = "Dividendo"
  1293. oDataGridViewTextBoxColumn.HeaderText = "Dividendo"
  1294. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  1295. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1296. oDataGridViewTextBoxColumn.Name = "CantidadBase"
  1297. oDataGridViewTextBoxColumn.DataPropertyName = "CantidadBase"
  1298. oDataGridViewTextBoxColumn.HeaderText = "Cantidad Base"
  1299. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  1300. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  1301. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  1302. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1303. oDataGridViewTextBoxColumn.Name = "IngresoBruto"
  1304. oDataGridViewTextBoxColumn.DataPropertyName = "IngresoBruto"
  1305. oDataGridViewTextBoxColumn.HeaderText = "Ingreso Bruto"
  1306. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  1307. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  1308. oDataGridViewTextBoxColumn.ReadOnly = True
  1309. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  1310. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1311. oDataGridViewTextBoxColumn.Name = "PorcISR"
  1312. oDataGridViewTextBoxColumn.DataPropertyName = "PorcISR"
  1313. oDataGridViewTextBoxColumn.HeaderText = "% ISR"
  1314. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTPorcentaje
  1315. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  1316. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  1317. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1318. oDataGridViewTextBoxColumn.Name = "ISR"
  1319. oDataGridViewTextBoxColumn.DataPropertyName = "ISR"
  1320. oDataGridViewTextBoxColumn.HeaderText = "ISR"
  1321. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  1322. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  1323. oDataGridViewTextBoxColumn.ReadOnly = True
  1324. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  1325. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1326. oDataGridViewTextBoxColumn.Name = "IngresoNeto"
  1327. oDataGridViewTextBoxColumn.DataPropertyName = "IngresoNeto"
  1328. oDataGridViewTextBoxColumn.HeaderText = "Ingreso Neto"
  1329. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  1330. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  1331. oDataGridViewTextBoxColumn.ReadOnly = True
  1332. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  1333. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1334. oDataGridViewTextBoxColumn.Name = "Estado"
  1335. oDataGridViewTextBoxColumn.DataPropertyName = "Estado"
  1336. oDataGridViewTextBoxColumn.HeaderText = "Estado"
  1337. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  1338. oDataGridViewTextBoxColumn.Visible = False
  1339. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  1340. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1341. oDataGridViewTextBoxColumn.Name = "FechaInicio"
  1342. oDataGridViewTextBoxColumn.DataPropertyName = "FechaInicio"
  1343. oDataGridViewTextBoxColumn.HeaderText = "FechaInicio"
  1344. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  1345. oDataGridViewTextBoxColumn.Visible = False
  1346. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  1347. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1348. oDataGridViewTextBoxColumn.Name = "FechaCorte"
  1349. oDataGridViewTextBoxColumn.DataPropertyName = "FechaCorte"
  1350. oDataGridViewTextBoxColumn.HeaderText = "FechaCorte"
  1351. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  1352. oDataGridViewTextBoxColumn.Visible = False
  1353. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  1354. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1355. oDataGridViewTextBoxColumn.Name = "NumDiv"
  1356. oDataGridViewTextBoxColumn.DataPropertyName = "NumDiv"
  1357. oDataGridViewTextBoxColumn.HeaderText = "NuvDiv"
  1358. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  1359. oDataGridViewTextBoxColumn.Visible = False
  1360. Me.dgvDividendos.Columns.Add(oDataGridViewTextBoxColumn)
  1361. End Sub
  1362. Private Sub GuardarRegistro()
  1363. End Sub
  1364. Private Sub ActualizarRegistro()
  1365. Dim res As Integer
  1366. RefrescarClaseEntidad()
  1367. res = oAccionesDAO.Actualizar(oAccionesCE)
  1368. If res > 0 Then
  1369. MsgBox("Registro Guardado")
  1370. Else
  1371. MsgBox("Algo no salio bien.")
  1372. End If
  1373. End Sub
  1374. 'Private Sub ActivarEdicion()
  1375. ' If TipoTransaccion = "C" Then
  1376. ' Me.TipoTransaccion = "A"
  1377. ' Me.btnAceptar.Text = "Guardar"
  1378. ' End If
  1379. 'End Sub
  1380. Private Function FechaDividendo()
  1381. Dim Index = dgvDividendos.CurrentRow.Index
  1382. Dim IndexAnterior = Index - 1
  1383. Dim FechaInicial = dtpFechaOperacionCompra.Value
  1384. Dim FechaActual = dgvDividendos.Rows(Index).Cells("Fecha").Value
  1385. Dim FechaCalcul As Date = Date.Now.Date
  1386. If (String.IsNullOrEmpty(FechaActual)) Then
  1387. If (Index = 0) Then
  1388. FechaCalcul = Operaciones.Meses(12, FechaInicial, FechaInicial)
  1389. Else
  1390. Dim Fecha = dgvDividendos.Rows(IndexAnterior).Cells("Fecha").Value
  1391. FechaCalcul = Operaciones.Meses(12, Fecha, FechaInicial)
  1392. End If
  1393. Else
  1394. FechaCalcul = FechaActual
  1395. End If
  1396. Return FechaCalcul
  1397. End Function
  1398. Private Sub PrepararCalculoDividendos(ByVal IdFila As Integer)
  1399. Dim vFila As DataGridViewRow = dgvDividendos.Rows(IdFila)
  1400. If (rdbEfectivo.Checked) Then
  1401. If vFila.IsNewRow Then
  1402. vFila.Cells("Fecha").Value = FechaDividendo()
  1403. vFila.Cells("Dividendo").Value = oAccionesCE.FactorDeDividendo
  1404. End If
  1405. If rdbEfectivo.Checked Then
  1406. If (String.IsNullOrEmpty(txtUnidadesCompra.Text)) Then
  1407. vFila.Cells("CantidadBase").Value = 0.0
  1408. Else
  1409. vFila.Cells("CantidadBase").Value = CDec(txtUnidadesCompra.Text)
  1410. End If
  1411. Else
  1412. If (String.IsNullOrEmpty(txtValorTransadoCompra.Text)) Then
  1413. vFila.Cells("CantidadBase").Value = 0.0
  1414. Else
  1415. vFila.Cells("CantidadBase").Value = CDec(txtValorTransadoCompra.Text)
  1416. End If
  1417. End If
  1418. vFila.Cells("IngresoBruto").Value = 0.00
  1419. vFila.Cells("PorcISR").Value = 0.05
  1420. vFila.Cells("ISR").Value = 0.00
  1421. vFila.Cells("IngresoNeto").Value = 0.00
  1422. If dgvDividendos.Rows(IdFila).Cells("NumDiv").Value Is DBNull.Value Then
  1423. dgvDividendos.Rows(IdFila).Cells("NumDiv").Value = Correlativo()
  1424. Else
  1425. If String.IsNullOrEmpty(dgvDividendos.Rows(IdFila).Cells("NumDiv").Value) Then
  1426. dgvDividendos.Rows(IdFila).Cells("NumDiv").Value = Correlativo()
  1427. End If
  1428. End If
  1429. Else
  1430. If vFila.IsNewRow Then
  1431. vFila.Cells("Fecha").Value = FechaDividendo()
  1432. vFila.Cells("Dividendo").Value = oAccionesCE.FactorDeDividendo.ToString + "%"
  1433. If (vFila.Cells("Dividendo").Value.ToString.IndexOf("%") = -1) Then
  1434. vFila.Cells("Dividendo").Value += "%"
  1435. End If
  1436. If rdbEfectivo.Checked Then
  1437. If (String.IsNullOrEmpty(txtUnidadesCompra.Text)) Then
  1438. vFila.Cells("CantidadBase").Value = 0.0
  1439. Else
  1440. vFila.Cells("CantidadBase").Value = CDec(txtUnidadesCompra.Text)
  1441. End If
  1442. Else
  1443. If (String.IsNullOrEmpty(txtValorTransadoCompra.Text)) Then
  1444. vFila.Cells("CantidadBase").Value = 0.0
  1445. Else
  1446. vFila.Cells("CantidadBase").Value = CDec(txtValorTransadoCompra.Text)
  1447. End If
  1448. End If
  1449. vFila.Cells("IngresoBruto").Value = 0.00
  1450. vFila.Cells("PorcISR").Value = 0.05
  1451. vFila.Cells("ISR").Value = 0.00
  1452. vFila.Cells("IngresoNeto").Value = 0.00
  1453. If dgvDividendos.Rows(IdFila).Cells("NumDiv").Value Is DBNull.Value Then
  1454. dgvDividendos.Rows(IdFila).Cells("NumDiv").Value = Correlativo()
  1455. Else
  1456. If String.IsNullOrEmpty(dgvDividendos.Rows(IdFila).Cells("NumDiv").Value) Then
  1457. dgvDividendos.Rows(IdFila).Cells("NumDiv").Value = Correlativo()
  1458. End If
  1459. End If
  1460. End If
  1461. End If
  1462. If (vFila.Cells("Fecha").Value Is DBNull.Value) Then
  1463. vFila.Cells("Fecha").Value = FechaDividendo()
  1464. Else
  1465. If String.IsNullOrEmpty(vFila.Cells("Fecha").Value) Then
  1466. vFila.Cells("Fecha").Value = FechaDividendo()
  1467. End If
  1468. End If
  1469. RefrescarValorControles()
  1470. End Sub
  1471. Sub AgregarFechaCO()
  1472. dgvDividendos.CurrentRow.Cells("FechaInicio").Value = Variables.FechaInicialCorte
  1473. dgvDividendos.CurrentRow.Cells("FechaCorte").Value = Variables.FechaCorteCorte
  1474. End Sub
  1475. Function CalculoIngresoBrutoEfectivo(ByVal CantidadUnidades As Double, ByVal Dividendo As Double)
  1476. Dim Total = CantidadUnidades * (Dividendo)
  1477. Return Total
  1478. End Function
  1479. Function CalculoIngresoBrutoPorcentaje(ByVal ValorTransado As Double, ByVal Dividendo As Double, ByVal Dias As Integer, ByVal Fecha As Date)
  1480. Dim Total As Double = 0
  1481. If (Operaciones.AñoBisiesto(Fecha) = 364) Then
  1482. Total = (ValorTransado * (Dividendo / 100) * Dias) / 365
  1483. End If
  1484. If (Operaciones.AñoBisiesto(Fecha) = 365) Then
  1485. Total = (ValorTransado * (Dividendo / 100) * Dias) / 366
  1486. End If
  1487. Return Total
  1488. End Function
  1489. Function RangoDias(ByVal Fecha As Date, ByVal FechaVen As Date)
  1490. Dim Dias As Integer = DateDiff(DateInterval.Day, Fecha, FechaVen)
  1491. Return Dias
  1492. End Function
  1493. Function CantidadDiasUtimo(ByVal Fecha As Date)
  1494. Dim Año As Integer = Fecha.Year
  1495. Dim FechaCorte As Date = CDate("31/12/" + Año.ToString)
  1496. Dim Dias As Integer = DateDiff(DateInterval.Day, Fecha, FechaCorte)
  1497. Return Dias
  1498. End Function
  1499. Private Sub PrepararImpuestosYComisiones(ByVal IdFila As Integer)
  1500. ' Dim vFila As DataGridViewRow = dgvImpuestosYComisiones.Rows(IdFila)
  1501. ' If vFila.IsNewRow Then
  1502. ' vFila.Cells("TipoOper").Value = "V"
  1503. ' vFila.Cells("PorcImp").Value = 0
  1504. ' vFila.Cells("MontoSujeto").Value = oAccionesCE.ValorTransadoVenta
  1505. ' vFila.Cells("MontoImp").Value = 0.00
  1506. 'End If
  1507. End Sub
  1508. ' Private Sub CalcularImpuestosYComisiones(ByVal IdFila As Integer, ByVal IdCol As Integer)
  1509. ' Dim vFila As DataGridViewRow = dgvImpuestosYComisiones.Rows(IdFila)
  1510. 'Dim vTipoOperacion As String
  1511. 'Dim vCodigoImpuesto As String
  1512. 'Dim vPorcentajeImpuesto As Double
  1513. 'Dim vMontoSujeto As Double
  1514. 'Dim vMontoImpuesto As Double
  1515. '
  1516. 'If Not vFila.IsNewRow Then
  1517. ' vCodigoImpuesto = vFila.Cells("CodImp").Value.ToString
  1518. ' vTipoOperacion = vFila.Cells("TipoOper").Value.ToString
  1519. 'Double.TryParse(vFila.Cells("PorcImp").Value.ToString, vPorcentajeImpuesto)
  1520. 'If IdCol = 3 Then
  1521. ' vPorcentajeImpuesto = vPorcentajeImpuesto / 100
  1522. ' vFila.Cells("PorcImp").Value = vPorcentajeImpuesto
  1523. 'End If
  1524. 'If vTipoOperacion = "C" Then
  1525. ' vMontoSujeto = oAccionesCE.ValorTransadoCompra
  1526. ' vFila.Cells("MontoSujeto").Value = oAccionesCE.ValorTransadoCompra
  1527. 'ElseIf vTipoOperacion = "V" Then
  1528. ' vMontoSujeto = oAccionesCE.ValorTransadoVenta
  1529. ' vFila.Cells("MontoSujeto").Value = oAccionesCE.ValorTransadoVenta
  1530. 'Else
  1531. ' vMontoSujeto = 0
  1532. 'End If
  1533. ' vMontoImpuesto = vMontoSujeto * vPorcentajeImpuesto
  1534. ' vFila.Cells("MontoImp").Value = vMontoImpuesto
  1535. 'End If
  1536. ' RefrescarClaseEntidad()
  1537. ' RefrescarValorControles()
  1538. 'End Sub
  1539. Private Sub dgvDividendos_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) Handles dgvDividendos.CellBeginEdit
  1540. 'ActivarEdicion()
  1541. PrepararCalculoDividendos(e.RowIndex)
  1542. End Sub
  1543. Private Sub dgvDividendos_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvDividendos.CellEndEdit
  1544. ' If (Not dgvDividendos.Rows(0).IsNewRow) Then
  1545. ' If (DobleClick) Then
  1546. ' DobleClick = False
  1547. ' rdbEfectivo.Enabled = True
  1548. ' rdbPorcentaje.Enabled = True
  1549. ' TabControl1.TabPages.Insert(0, TabPage1)
  1550. ' End If
  1551. ' End If
  1552. CalcularDividendos()
  1553. RefrescarValorControles()
  1554. End Sub
  1555. Private Sub dgvDividendos_UserDeletedRow(sender As Object, e As DataGridViewRowEventArgs) Handles dgvDividendos.UserDeletedRow
  1556. 'ActivarEdicion()
  1557. ' oAccionesCE.Dividendos.AcceptChanges()
  1558. End Sub
  1559. Private Sub dgvImpuestosYComisiones_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs)
  1560. 'ActivarEdicion()
  1561. PrepararImpuestosYComisiones(e.RowIndex)
  1562. End Sub
  1563. Private Sub dgvImpuestosYComisiones_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs)
  1564. ' CalcularImpuestosYComisiones(e.RowIndex, e.ColumnIndex)
  1565. End Sub
  1566. Private Sub dgvImpuestosYComisiones_UserDeletedRow(sender As Object, e As DataGridViewRowEventArgs)
  1567. 'ActivarEdicion()
  1568. oAccionesCE.ImpuestosYComisiones.AcceptChanges()
  1569. End Sub
  1570. Private Sub dgvImpuestosYComisiones_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
  1571. End Sub
  1572. Private Sub dgvDividendos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvDividendos.CellContentClick
  1573. End Sub
  1574. Private Sub TabPage2_Click(sender As Object, e As EventArgs)
  1575. End Sub
  1576. Private Sub txtImpuestosYComisionesCompra_TextChanged(sender As Object, e As EventArgs) Handles txtImpuestosYComisionesCompra.TextChanged
  1577. End Sub
  1578. Private Sub TOperacion(ByVal TOperacion As String)
  1579. If (TOperacion = "N") Then
  1580. HabilitarBotones()
  1581. ElseIf (TOperacion = "B") Then
  1582. DeshabilitarBotones()
  1583. End If
  1584. End Sub
  1585. Sub HabilitarBotones()
  1586. txtUnidadesCompra.Enabled = True
  1587. txtUnidadesVenta.Enabled = True
  1588. End Sub
  1589. Sub DeshabilitarBotones()
  1590. txtDiasDeTenenciaCompra.Enabled = False
  1591. txtDiasDeTenenciaVenta.Enabled = False
  1592. txtGananciaCapitalTotalCompra.Enabled = False
  1593. txtGananciaCapitalTotalVenta.Enabled = False
  1594. txtGananciaCapitalUnitarioCompra.Enabled = False
  1595. txtGananciaCapitalUnitarioVenta.Enabled = False
  1596. txtRetornoAnualBrutoCompra.Enabled = False
  1597. txtRetornoAnualBrutoVenta.Enabled = False
  1598. txtRetornoAnualNetoCompra.Enabled = False
  1599. txtRetornoAnualNetoVenta.Enabled = False
  1600. txtUnidadesCompra.Enabled = False
  1601. txtUnidadesVenta.Enabled = False
  1602. txtValorTransadoCompra.Enabled = False
  1603. txtValorTransadoVenta.Enabled = False
  1604. txtImpuestosYComisionesCompra.Enabled = False
  1605. txtImpuestosYComisionesVenta.Enabled = False
  1606. txtMontoNetoCompra.Enabled = False
  1607. txtMontoNetoVenta.Enabled = False
  1608. txtPrecioSucioCompra.Enabled = False
  1609. txtPrecioSucioVenta.Enabled = False
  1610. End Sub
  1611. Private Sub dtgcomisiones_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
  1612. End Sub
  1613. Private Sub TabPage4_Click(sender As Object, e As EventArgs)
  1614. End Sub
  1615. Private Sub dtgcomisiones_CellContentClick_1(sender As Object, e As DataGridViewCellEventArgs)
  1616. End Sub
  1617. Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
  1618. Estado = "N"
  1619. btnAceptar.Text = "Nuevo"
  1620. End Sub
  1621. Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
  1622. Estado = "M"
  1623. btnAceptar.Text = "Modificar"
  1624. End Sub
  1625. Private Sub Button1_Click(sender As Object, e As EventArgs)
  1626. If (Estado = "N") Then
  1627. 'RefrescarClaseEntidad()
  1628. NuevaAccion()
  1629. End If
  1630. If Estado = "M" Then
  1631. 'ActualizarRegistro()
  1632. End If
  1633. End Sub
  1634. Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
  1635. Estado = "B"
  1636. btnAceptar.Text = "Eliminar"
  1637. End Sub
  1638. Private Sub btnAgregar_Click(sender As Object, e As EventArgs)
  1639. End Sub
  1640. Private Sub dgvDividendos_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvDividendos.CellClick
  1641. ModificarFechaCorte()
  1642. PrepararCalculoDividendos(e.RowIndex)
  1643. End Sub
  1644. Sub ModificarFechaCorte()
  1645. If rdbPorcentaje.Checked Then
  1646. Dim Index As Integer = dgvDividendos.CurrentRow.Index
  1647. If dgvDividendos.Rows(Index).Cells("Fecha").ColumnIndex = dgvDividendos.CurrentCell.ColumnIndex Then
  1648. Dim FechaReferencia = dgvDividendos.Rows(Index).Cells("Fecha").Value
  1649. If (Not String.IsNullOrEmpty(FechaReferencia)) Then
  1650. Dim año = FechaReferencia.Year
  1651. Dim PrimeraFecha, SegundaFecha
  1652. If (dgvDividendos.Rows(Index).Cells("FechaInicio").Value Is Nothing) Then
  1653. PrimeraFecha = CDate("1/1/" + año.ToString)
  1654. ElseIf (dgvDividendos.Rows(Index).Cells("FechaInicio").Value Is DBNull.Value) Then
  1655. PrimeraFecha = CDate("1/1/" + año.ToString)
  1656. Else
  1657. PrimeraFecha = dgvDividendos.Rows(Index).Cells("FechaInicio").Value
  1658. End If
  1659. If (dgvDividendos.Rows(Index).Cells("FechaCorte").Value Is Nothing) Then
  1660. SegundaFecha = CDate("31/12/" + año.ToString)
  1661. ElseIf (dgvDividendos.Rows(Index).Cells("FechaCorte").Value Is DBNull.Value) Then
  1662. SegundaFecha = CDate("31/12/" + año.ToString)
  1663. Else
  1664. SegundaFecha = dgvDividendos.Rows(Index).Cells("FechaCorte").Value
  1665. End If
  1666. Variables.FechaInicial = PrimeraFecha
  1667. Variables.FechaCorte = SegundaFecha
  1668. Variables.CorrelativoACC = dgvDividendos.Rows(Index).Cells("NumDiv").Value
  1669. frmFechasAcciones.Show()
  1670. End If
  1671. Cierre = True
  1672. End If
  1673. End If
  1674. End Sub
  1675. Private Sub txtComisionPorcentajeCasaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorcentajeCasaCompra.TextChanged
  1676. RefrescarValorControles()
  1677. End Sub
  1678. Private Sub txtComisionPorcentajeBolsaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorcentajeBolsaCompra.TextChanged
  1679. RefrescarValorControles()
  1680. End Sub
  1681. Private Sub txtComisionPorcentajeCasaVenta_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorcentajeCasaVenta.TextChanged
  1682. RefrescarValorControles()
  1683. End Sub
  1684. Private Sub txtComisionPorcentajeBolsaVenta_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorcentajeBolsaVenta.TextChanged
  1685. RefrescarValorControles()
  1686. End Sub
  1687. Private Sub txtMontoNetoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtMontoNetoCompra.TextChanged
  1688. End Sub
  1689. Private Sub btnAgregarImpuesto_Click(sender As Object, e As EventArgs)
  1690. ' GuardarImpuesto()
  1691. End Sub
  1692. 'Private Sub PrepararTablaImpuestos()
  1693. ' Dim cboColumna As DataGridViewComboBoxColumn
  1694. ' cboColumna = New DataGridViewComboBoxColumn
  1695. ' cboColumna.Name = "Valor"
  1696. ' cboColumna.HeaderText = "CodImp"
  1697. ' cboColumna.DataSource = oDAOGeneral.ListaImpuesto
  1698. 'cboColumna.ValueMember = "CodImp"
  1699. 'cboColumna.DisplayMember = "Descripcion"
  1700. ' cboColumna.DataPropertyName = "CodImp"
  1701. ' cboColumna.DisplayIndex = 1
  1702. ' Me.dgvImpuestos.Columns.Add(cboColumna)
  1703. 'End Sub
  1704. 'Sub GuardarImpuesto()
  1705. 'Dim Impuesto = dgvImpuestos.CurrentRow.Cells(0).Value
  1706. 'Dim CodigoInv = Variables.Codigo
  1707. ' Dim ValorImpuesto = ReportoConsula.TraerImpuesto(Impuesto)
  1708. ' Dim Valor = oDAOGeneral.AgregarImpuesto(CodigoInv, "ACC0", Impuesto, 0)
  1709. ' ActualizarImpuestos(Valor)
  1710. ' RefrescarValorControles()
  1711. 'End Sub
  1712. ' Sub ModificarImpu(ByVal Impuesto As String)
  1713. ' Dim CodigoInv = Variables.Codigo
  1714. ' Dim ValorImpuesto = ReportoConsula.TraerImpuesto(Impuesto)
  1715. ' Dim Valor = oDAOGeneral.AgregarImpuesto(CodigoInv, "ACC0", Impuesto, 1)
  1716. ' ActualizarImpuestos(Valor)
  1717. ' RefrescarValorControles()
  1718. ' End Sub
  1719. ' Sub ActualizarImpuestos(ByVal Valor As Integer)
  1720. 'If (Valor = 1) Then
  1721. ' dgvImpuestoAgregado.Rows.Clear()
  1722. ' CargarImpuestos()
  1723. 'End If
  1724. 'End Sub
  1725. Private Sub dgvImpuestoAgregado_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
  1726. End Sub
  1727. 'Sub CargarImpuestos()
  1728. 'Try
  1729. 'Dim codigo As String = Variables.Codigo
  1730. 'Dim ListaImpuestos As String()
  1731. 'Dim ClaveImpuesto
  1732. 'Dim dr = oDAOGeneral.CargarImpuesto(codigo, "ACC0")
  1733. 'While dr.Read
  1734. 'If (Not String.IsNullOrEmpty(dr("Impuestos").ToString)) Then
  1735. ' ClaveImpuesto = dr("Impuestos")
  1736. ' ListaImpuestos = ClaveImpuesto.split("-")
  1737. 'Else
  1738. ' ClaveImpuesto = String.Empty
  1739. 'End If
  1740. 'End While
  1741. 'For Each i As String In ListaImpuestos
  1742. ' dgvImpuestoAgregado.Rows.Add(i)
  1743. 'Next
  1744. 'Catch ex As Exception
  1745. 'End Try
  1746. 'End Sub
  1747. ' Sub ModificarImpuestos()
  1748. 'Dim Index As Integer = dgvImpuestoAgregado.CurrentRow.Index
  1749. 'Dim Cantidad As Integer = dgvImpuestoAgregado.Rows.Count - 1
  1750. 'Dim Cadena As String = String.Empty
  1751. 'Dim IsNothing As Boolean = False
  1752. ' Cadena = dgvImpuestoAgregado.CurrentRow.Cells(0).Value
  1753. 'If (String.IsNullOrEmpty(Cadena)) Then
  1754. ' MsgBox("No se puede quitar una cadena vacía")
  1755. 'Else
  1756. ' ModificarImpu(Cadena)
  1757. 'End If
  1758. 'End Sub
  1759. Function ObtenerCodigosImpuestos()
  1760. Dim codigo As String = Variables.Codigo
  1761. Dim ListaImpuestos As String()
  1762. Dim ClaveImpuesto
  1763. Dim coleccion As New Collection
  1764. Dim dr = oDAOGeneral.CargarImpuesto(codigo, "ACC0")
  1765. While dr.Read
  1766. If (Not String.IsNullOrEmpty(dr("Impuestos").ToString)) Then
  1767. ClaveImpuesto = dr("Impuestos")
  1768. ListaImpuestos = ClaveImpuesto.split("-")
  1769. Else
  1770. ClaveImpuesto = String.Empty
  1771. End If
  1772. End While
  1773. For Each i As String In ListaImpuestos
  1774. coleccion.Add(i)
  1775. Next
  1776. Return coleccion
  1777. End Function
  1778. ' Sub AgregarCamposImpuestos()
  1779. ' Dim CodImp, code As New DataGridViewTextBoxColumn
  1780. ' CodImp.Name = "CodImp"
  1781. 'dgvImpuestoAgregado.Columns.Add(CodImp)
  1782. ' End Sub
  1783. '********** FIN FUNCIONES **********
  1784. ' Function CalcularImpuesto()
  1785. 'Dim Cargar As New Collection
  1786. 'Dim CantidadFilas = dgvImpuestoAgregado.Rows.Count - 1
  1787. 'Dim Val As String
  1788. 'For i As Integer = 0 To CantidadFilas
  1789. ' Val = dgvImpuestoAgregado.Rows(i).Cells(0).Value
  1790. ' Cargar.Add(Val)
  1791. 'Next
  1792. 'Dim Cantidad As Double = 0
  1793. 'Dim Impuestos As Dictionary(Of String, String) = oDAOGeneral.ObtenerImpuesto()
  1794. 'For Each i In Cargar
  1795. 'For Each valor In Impuestos
  1796. 'If (valor.Key.ToString = i) Then
  1797. ' Cantidad = Cantidad + valor.Value
  1798. 'End If
  1799. 'Next
  1800. 'Next
  1801. 'Return Cantidad
  1802. 'End Function
  1803. Private Sub btnQuitar_Click(sender As Object, e As EventArgs)
  1804. ' ModificarImpuestos()
  1805. End Sub
  1806. Private Sub dgvImpuestoAgregado_CellClick(sender As Object, e As DataGridViewCellEventArgs)
  1807. End Sub
  1808. Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs)
  1809. End Sub
  1810. Private Sub BindingNavigator1_RefreshItems(sender As Object, e As EventArgs) Handles BindingNavigator1.RefreshItems
  1811. End Sub
  1812. Sub ValidarRentaIOF()
  1813. If (ChkIOF.Checked) Then
  1814. CalculosIOF()
  1815. Else
  1816. BloquearIOF()
  1817. End If
  1818. RefrescarValorControles()
  1819. If (ChkRenta.Checked) Then
  1820. CalculosRenta()
  1821. Else
  1822. BloquearRenta()
  1823. End If
  1824. RefrescarValorControles()
  1825. End Sub
  1826. Private Sub ChkIOF_CheckedChanged(sender As Object, e As EventArgs) Handles ChkIOF.CheckedChanged
  1827. If (ChkIOF.Checked) Then
  1828. oAccionesCE.IOF = 1
  1829. CalculosIOF()
  1830. Else
  1831. oAccionesCE.IOF = 0
  1832. BloquearIOF()
  1833. End If
  1834. RefrescarValorControles()
  1835. End Sub
  1836. Sub BloquearIOF()
  1837. lblCompra1.Visible = False
  1838. lblVenta1.Visible = False
  1839. txtIOFCompra.Text = String.Empty
  1840. txtIOFCompra.Visible = False
  1841. txtIOFVenta.Text = String.Empty
  1842. txtIOFVenta.Visible = False
  1843. End Sub
  1844. Sub CalculosIOF()
  1845. If (Not String.IsNullOrEmpty(txtValorTransadoCompra.Text) And Not String.IsNullOrEmpty(txtValorTransadoVenta.Text)) Then
  1846. lblCompra1.Visible = True
  1847. lblVenta1.Visible = True
  1848. txtIOFCompra.Visible = True
  1849. txtIOFVenta.Visible = True
  1850. Dim ValorTransadoCompra = txtValorTransadoCompra.Text
  1851. Dim ValorTransadoVenta = txtValorTransadoVenta.Text
  1852. txtIOFCompra.Text = CalculoImpuestos(ValorTransadoCompra, 0.0025)
  1853. txtIOFVenta.Text = CalculoImpuestos(ValorTransadoVenta, 0.0025)
  1854. End If
  1855. End Sub
  1856. Private Sub ChkRenta_CheckedChanged(sender As Object, e As EventArgs) Handles ChkRenta.CheckedChanged
  1857. If (ChkRenta.Checked) Then
  1858. oAccionesCE.Renta = 1
  1859. CalculosRenta()
  1860. Else
  1861. oAccionesCE.Renta = 0
  1862. BloquearRenta()
  1863. End If
  1864. RefrescarValorControles()
  1865. End Sub
  1866. Sub CalculosRenta()
  1867. If (Not String.IsNullOrEmpty(txtValorTransadoCompra.Text) And Not String.IsNullOrEmpty(txtValorTransadoVenta.Text)) Then
  1868. lblCompra2.Visible = True
  1869. lblVenta2.Visible = True
  1870. txtRentaVenta.Visible = True
  1871. txtRentaCompra.Visible = True
  1872. Dim ValorTransadoCompra = txtValorTransadoCompra.Text
  1873. Dim ValorTransadoVenta = txtValorTransadoVenta.Text
  1874. txtRentaCompra.Text = CalculoImpuestos(ValorTransadoCompra, 0.1)
  1875. txtRentaVenta.Text = CalculoImpuestos(ValorTransadoVenta, 0.1)
  1876. End If
  1877. End Sub
  1878. Sub BloquearRenta()
  1879. lblCompra2.Visible = False
  1880. lblVenta2.Visible = False
  1881. txtRentaCompra.Text = String.Empty
  1882. txtRentaCompra.Visible = False
  1883. txtRentaVenta.Text = String.Empty
  1884. txtRentaVenta.Visible = False
  1885. End Sub
  1886. Function CalculoImpuestos(ByVal ValorTransado As Double, ByVal Impuesto As Double)
  1887. Dim Valor = ValorTransado * Impuesto
  1888. Return Valor
  1889. End Function
  1890. Private Sub rdbEfectivo_CheckedChanged(sender As Object, e As EventArgs) Handles rdbEfectivo.CheckedChanged
  1891. If (rdbEfectivo.Checked) Then
  1892. LimpiarDividendosCambios(1)
  1893. Else
  1894. LimpiarDividendosCambios(2)
  1895. End If
  1896. CambiarBase()
  1897. CambioCalculo = True
  1898. CambioCalculo = False
  1899. If (Cargado) Then
  1900. RefrescarValorControles()
  1901. End If
  1902. End Sub
  1903. Private Sub rdbPorcentaje_CheckedChanged(sender As Object, e As EventArgs) Handles rdbPorcentaje.CheckedChanged
  1904. If (rdbEfectivo.Checked) Then
  1905. LimpiarDividendosCambios(1)
  1906. Else
  1907. LimpiarDividendosCambios(2)
  1908. End If
  1909. CambiarBase()
  1910. CambioCalculo = True
  1911. CambioCalculo = False
  1912. If (Cargado) Then
  1913. RefrescarValorControles()
  1914. End If
  1915. End Sub
  1916. Sub CambiarBase()
  1917. Dim Cantidad As Integer = dgvDividendos.Rows.Count - 1
  1918. For i As Integer = 0 To Cantidad
  1919. If (dgvDividendos.Rows(i).Cells("NumDiv").Value Is DBNull.Value) Then
  1920. Exit For
  1921. Else
  1922. If String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("NumDiv").Value) Then
  1923. Exit For
  1924. End If
  1925. End If
  1926. If rdbEfectivo.Checked Then
  1927. If (String.IsNullOrEmpty(txtUnidadesCompra.Text)) Then
  1928. dgvDividendos.Rows(i).Cells("CantidadBase").Value = 0.0
  1929. Else
  1930. dgvDividendos.Rows(i).Cells("CantidadBase").Value = CDec(txtUnidadesCompra.Text)
  1931. End If
  1932. Else
  1933. If (String.IsNullOrEmpty(txtValorTransadoCompra.Text)) Then
  1934. dgvDividendos.Rows(i).Cells("CantidadBase").Value = 0.0
  1935. Else
  1936. dgvDividendos.Rows(i).Cells("CantidadBase").Value = CDec(txtValorTransadoCompra.Text)
  1937. End If
  1938. End If
  1939. Next
  1940. CalcularDividendos()
  1941. End Sub
  1942. Private Sub dgvDividendos_Click(sender As Object, e As EventArgs) Handles dgvDividendos.Click
  1943. End Sub
  1944. Sub ClonarDatos()
  1945. If (String.IsNullOrEmpty(txtUnidadesVenta.Text.ToString)) Then
  1946. txtUnidadesVenta.Text = txtUnidadesCompra.Text
  1947. End If
  1948. End Sub
  1949. Private Sub txtUnidadesCompra_Leave(sender As Object, e As EventArgs) Handles txtUnidadesCompra.Leave
  1950. ClonarDatos()
  1951. Formato()
  1952. End Sub
  1953. Private Sub rdbEfectivo_Click(sender As Object, e As EventArgs) Handles rdbEfectivo.Click
  1954. End Sub
  1955. Private Sub dgvDividendos_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvDividendos.CellDoubleClick
  1956. 'If (dgvDividendos.Rows.Count = 1) Then
  1957. ' If (dgvDividendos.Rows(0).IsNewRow) Then
  1958. ' DobleClick = True
  1959. ' rdbEfectivo.Enabled = False
  1960. ' rdbPorcentaje.Enabled = False
  1961. ' TabPage1.Parent = Nothing
  1962. ' End If
  1963. 'End If
  1964. End Sub
  1965. Private Sub txtPrecioLimpioCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioLimpioCompra.KeyPress
  1966. If String.IsNullOrEmpty(txtPrecioLimpioCompra.Text) Then
  1967. If e.KeyChar = "." Then
  1968. txtPrecioLimpioCompra.Text = "0"
  1969. Exit Sub
  1970. End If
  1971. End If
  1972. If (Not txtPrecioLimpioCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1973. Operaciones.ValidarEntrada(sender, e, True)
  1974. Else
  1975. Operaciones.ValidarEntrada(sender, e, False)
  1976. End If
  1977. End Sub
  1978. Private Sub txtPrecioLimpioVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioLimpioVenta.KeyPress
  1979. If String.IsNullOrEmpty(txtPrecioLimpioVenta.Text) Then
  1980. If e.KeyChar = "." Then
  1981. txtPrecioLimpioVenta.Text = "0"
  1982. Exit Sub
  1983. End If
  1984. End If
  1985. If (Not txtPrecioLimpioVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1986. Operaciones.ValidarEntrada(sender, e, True)
  1987. Else
  1988. Operaciones.ValidarEntrada(sender, e, False)
  1989. End If
  1990. End Sub
  1991. Private Sub txtUnidadesCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtUnidadesCompra.KeyPress
  1992. If String.IsNullOrEmpty(txtUnidadesCompra.Text) Then
  1993. If e.KeyChar = "." Then
  1994. txtUnidadesCompra.Text = "0"
  1995. Exit Sub
  1996. End If
  1997. End If
  1998. If (Not txtUnidadesCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1999. Operaciones.ValidarEntrada(sender, e, True)
  2000. Else
  2001. Operaciones.ValidarEntrada(sender, e, False)
  2002. End If
  2003. End Sub
  2004. Private Sub txtUnidadesVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtUnidadesVenta.KeyPress
  2005. If String.IsNullOrEmpty(txtUnidadesVenta.Text) Then
  2006. If e.KeyChar = "." Then
  2007. txtUnidadesVenta.Text = "0"
  2008. Exit Sub
  2009. End If
  2010. End If
  2011. If (Not txtUnidadesVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  2012. Operaciones.ValidarEntrada(sender, e, True)
  2013. Else
  2014. Operaciones.ValidarEntrada(sender, e, False)
  2015. End If
  2016. End Sub
  2017. Private Sub txtComisionPorcentajeCasaCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorcentajeCasaCompra.KeyPress
  2018. If String.IsNullOrEmpty(txtComisionPorcentajeCasaCompra.Text) Then
  2019. If e.KeyChar = "." Then
  2020. txtComisionPorcentajeCasaCompra.Text = "0"
  2021. Exit Sub
  2022. End If
  2023. End If
  2024. If (Not txtComisionPorcentajeCasaCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  2025. Operaciones.ValidarEntrada(sender, e, True)
  2026. Else
  2027. Operaciones.ValidarEntrada(sender, e, False)
  2028. End If
  2029. End Sub
  2030. Private Sub txtComisionPorcentajeBolsaCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorcentajeBolsaCompra.KeyPress
  2031. If String.IsNullOrEmpty(txtComisionPorcentajeBolsaCompra.Text) Then
  2032. If e.KeyChar = "." Then
  2033. txtComisionPorcentajeBolsaCompra.Text = "0"
  2034. Exit Sub
  2035. End If
  2036. End If
  2037. If (Not txtComisionPorcentajeBolsaCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  2038. Operaciones.ValidarEntrada(sender, e, True)
  2039. Else
  2040. Operaciones.ValidarEntrada(sender, e, False)
  2041. End If
  2042. End Sub
  2043. Private Sub txtComisionPorcentajeCasaVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorcentajeCasaVenta.KeyPress
  2044. If String.IsNullOrEmpty(txtComisionPorcentajeCasaVenta.Text) Then
  2045. If e.KeyChar = "." Then
  2046. txtComisionPorcentajeCasaVenta.Text = "0"
  2047. Exit Sub
  2048. End If
  2049. End If
  2050. If (Not txtComisionPorcentajeCasaVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  2051. Operaciones.ValidarEntrada(sender, e, True)
  2052. Else
  2053. Operaciones.ValidarEntrada(sender, e, False)
  2054. End If
  2055. End Sub
  2056. Private Sub txtComisionPorcentajeBolsaVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorcentajeBolsaVenta.KeyPress
  2057. If String.IsNullOrEmpty(txtComisionPorcentajeBolsaVenta.Text) Then
  2058. If e.KeyChar = "." Then
  2059. txtComisionPorcentajeBolsaVenta.Text = "0"
  2060. Exit Sub
  2061. End If
  2062. End If
  2063. If (Not txtComisionPorcentajeBolsaVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  2064. Operaciones.ValidarEntrada(sender, e, True)
  2065. Else
  2066. Operaciones.ValidarEntrada(sender, e, False)
  2067. End If
  2068. End Sub
  2069. Private Sub btnCancelar_Click(sender As Object, e As EventArgs) Handles btnCancelar.Click
  2070. End Sub
  2071. Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles Panel1.Paint
  2072. End Sub
  2073. Private Sub TabPage1_Click(sender As Object, e As EventArgs) Handles TbOperacion.Click
  2074. End Sub
  2075. Private Sub txtGananciaCapitalTotalVenta_TextChanged(sender As Object, e As EventArgs) Handles txtGananciaCapitalTotalVenta.TextChanged
  2076. End Sub
  2077. Private Sub txtDiasDeTenenciaVenta_TextChanged(sender As Object, e As EventArgs) Handles txtDiasDeTenenciaVenta.TextChanged
  2078. End Sub
  2079. Private Sub Label9_Click(sender As Object, e As EventArgs) Handles Label9.Click
  2080. End Sub
  2081. Private Sub Label6_Click(sender As Object, e As EventArgs) Handles Label6.Click
  2082. End Sub
  2083. Private Sub txtIOFCompra_TextChanged(sender As Object, e As EventArgs) Handles txtIOFCompra.TextChanged
  2084. End Sub
  2085. Private Sub txtRentaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtRentaCompra.TextChanged
  2086. End Sub
  2087. Private Sub CalcularDividendos()
  2088. Dim Cantidad As Integer = dgvDividendos.Rows.Count - 2
  2089. For i As Integer = 0 To Cantidad
  2090. If (String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("Dividendo").Value)) Then
  2091. dgvDividendos.Rows(i).Cells("Dividendo").Value = 0
  2092. End If
  2093. If rdbEfectivo.Checked Then
  2094. If (String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("Dividendo").Value)) Then
  2095. dgvDividendos.Rows(i).Cells("Dividendo").Value = 0
  2096. End If
  2097. End If
  2098. Dim Dividendos As Double = dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString.Trim("%")
  2099. Dim Porcentaje As Double = dgvDividendos.Rows(i).Cells("PorcISR").Value
  2100. Dim Valor = dgvDividendos.Rows(i).Cells("CantidadBase").Value
  2101. If rdbEfectivo.Checked Then
  2102. Dim CalculoIB = CalculoIngresoBrutoEfectivo(Valor, Dividendos)
  2103. Dim CalculoRenta = CalculoIB * Porcentaje
  2104. Dim CalculoIN = CalculoIB - CalculoRenta
  2105. dgvDividendos.Rows(i).Cells("IngresoBruto").Value = CalculoIB
  2106. dgvDividendos.Rows(i).Cells("ISR").Value = CalculoRenta
  2107. dgvDividendos.Rows(i).Cells("IngresoNeto").Value = CalculoIN
  2108. Else
  2109. If (dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString.IndexOf("%") = -1) Then
  2110. dgvDividendos.Rows(i).Cells("Dividendo").Value = dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString + "%"
  2111. End If
  2112. Dim Dias As Integer = 0
  2113. Dim FechaInicialCorte As Date = Date.Now.Date
  2114. Dim FechaCorteCorte As Date = Date.Now.Date
  2115. If (dgvDividendos.Rows(i).Cells("FechaInicio").Value IsNot DBNull.Value And dgvDividendos.Rows(i).Cells("FechaCorte").Value IsNot DBNull.Value) Then
  2116. If (Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("FechaInicio").Value) And Not String.IsNullOrEmpty(dgvDividendos.Rows(i).Cells("FechaCorte").Value)) Then
  2117. FechaInicialCorte = dgvDividendos.Rows(i).Cells("FechaInicio").Value
  2118. FechaCorteCorte = dgvDividendos.Rows(i).Cells("FechaCorte").Value
  2119. Dias = DateDiff(DateInterval.Day, FechaInicialCorte, FechaCorteCorte)
  2120. Dias += 1
  2121. Dim CalculoIBP = CalculoIngresoBrutoPorcentaje(Valor, Dividendos, Dias, FechaInicialCorte)
  2122. Dim CalculoRenta = CalculoIBP * Porcentaje
  2123. Dim CalculoIN = CalculoIBP - CalculoRenta
  2124. dgvDividendos.Rows(i).Cells("IngresoBruto").Value = CalculoIBP
  2125. dgvDividendos.Rows(i).Cells("ISR").Value = CalculoRenta
  2126. dgvDividendos.Rows(i).Cells("IngresoNeto").Value = CalculoIN
  2127. End If
  2128. End If
  2129. End If
  2130. Next
  2131. CorrelativoSinBD()
  2132. End Sub
  2133. Public Sub btnActualizar_Click(sender As Object, e As EventArgs) Handles btnActualizar.Click
  2134. AgregarFechaCO()
  2135. CalcularDividendos()
  2136. End Sub
  2137. Private Sub TabPage3_Click(sender As Object, e As EventArgs) Handles TbDividendos.Click
  2138. End Sub
  2139. Sub LimpiarDividendosCambios(ByVal Calculo As Integer)
  2140. Dim Cantidad As Integer = dgvDividendos.Rows.Count - 2
  2141. For i As Integer = 0 To Cantidad
  2142. If (Calculo = 1) Then
  2143. If (Not dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString.IndexOf("%") = -1) Then
  2144. dgvDividendos.Rows(i).Cells("Dividendo").Value = dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString.ToString.Trim("%")
  2145. End If
  2146. Else
  2147. If (dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString.IndexOf("%") = -1) Then
  2148. dgvDividendos.Rows(i).Cells("Dividendo").Value = dgvDividendos.Rows(i).Cells("Dividendo").Value.ToString + "%"
  2149. End If
  2150. End If
  2151. dgvDividendos.Rows(i).Cells("IngresoBruto").Value = 0
  2152. dgvDividendos.Rows(i).Cells("ISR").Value = 0
  2153. dgvDividendos.Rows(i).Cells("IngresoNeto").Value = 0
  2154. Next
  2155. End Sub
  2156. Sub CargarDividendos()
  2157. Dim Codigo As String = Variables.Codigo
  2158. Dim dr = oAccionesDAO.CargarDividendo(Codigo)
  2159. While dr.Read
  2160. dgvDividendos.Rows.Add("", "", dr("Fecha"), dr("Dividendo"), dr("CantidadBase"), dr("IngresoBruto"), dr("PorcISR"), dr("ISR"), dr("IngresoNeto"), "", dr("FechaInicio"), dr("FechaCorte"), dr("NumDiv"))
  2161. End While
  2162. End Sub
  2163. Private Sub btnGenerarAccion_Click(sender As Object, e As EventArgs)
  2164. End Sub
  2165. Private Sub dgvDividendos_CellMouseMove(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgvDividendos.CellMouseMove
  2166. If Cierre Then
  2167. AgregarFechaCO()
  2168. CalcularDividendos()
  2169. Cierre = False
  2170. End If
  2171. End Sub
  2172. Private Sub dgvDividendos_MouseMove(sender As Object, e As MouseEventArgs) Handles dgvDividendos.MouseMove
  2173. If Cierre Then
  2174. AgregarFechaCO()
  2175. CalcularDividendos()
  2176. Cierre = False
  2177. End If
  2178. End Sub
  2179. Private Sub btnQuitar_Click_1(sender As Object, e As EventArgs) Handles btnQuitar.Click
  2180. QuitarFila()
  2181. CorrelativoSinBD()
  2182. End Sub
  2183. Sub QuitarFila()
  2184. Dim result As Integer = MsgBox("¿Está seguro que desea eliminar la fila?", MsgBoxStyle.OkCancel)
  2185. ' Test result.
  2186. Dim codigo As String = Variables.Codigo
  2187. Dim Numero As Integer = dgvDividendos.CurrentRow.Cells("NumDiv").Value
  2188. If result = MsgBoxResult.Ok Then
  2189. Try
  2190. dgvDividendos.Rows.Remove(dgvDividendos.CurrentRow)
  2191. oAccionesDAO.EliminarElemenoInd(codigo, Numero)
  2192. Catch ex As Exception
  2193. MsgBox("No ha seleccionado una fila")
  2194. End Try
  2195. End If
  2196. End Sub
  2197. Private Sub txtPrecioSucioVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioSucioVenta.TextChanged
  2198. End Sub
  2199. Private Sub txtPrecioLimpioCompra_Leave(sender As Object, e As EventArgs) Handles txtPrecioLimpioCompra.Leave
  2200. Formato()
  2201. End Sub
  2202. Private Sub txtComisionPorcentajeCasaCompra_Leave(sender As Object, e As EventArgs) Handles txtComisionPorcentajeCasaCompra.Leave
  2203. Formato()
  2204. End Sub
  2205. Private Sub txtComisionPorcentajeBolsaCompra_Leave(sender As Object, e As EventArgs) Handles txtComisionPorcentajeBolsaCompra.Leave
  2206. Formato()
  2207. End Sub
  2208. Private Sub txtPrecioLimpioVenta_Leave(sender As Object, e As EventArgs) Handles txtPrecioLimpioVenta.Leave
  2209. Formato()
  2210. End Sub
  2211. Private Sub txtUnidadesVenta_Leave(sender As Object, e As EventArgs) Handles txtUnidadesVenta.Leave
  2212. Formato()
  2213. End Sub
  2214. Private Sub txtComisionPorcentajeCasaVenta_Leave(sender As Object, e As EventArgs) Handles txtComisionPorcentajeCasaVenta.Leave
  2215. Formato()
  2216. End Sub
  2217. Private Sub txtComisionPorcentajeBolsaVenta_Leave(sender As Object, e As EventArgs) Handles txtComisionPorcentajeBolsaVenta.Leave
  2218. Formato()
  2219. End Sub
  2220. Private Sub frmAcciones_Resize(sender As Object, e As EventArgs) Handles MyBase.Resize
  2221. Redimencionar()
  2222. End Sub
  2223. Private Sub txtPrecioLimpioCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioLimpioCompra.KeyUp
  2224. If txtPrecioLimpioCompra.Text = "." Then
  2225. txtPrecioLimpioCompra.Text = ".0"
  2226. End If
  2227. End Sub
  2228. Private Sub txtUnidadesCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtUnidadesCompra.KeyUp
  2229. If txtUnidadesCompra.Text = "." Then
  2230. txtUnidadesCompra.Text = ".0"
  2231. End If
  2232. End Sub
  2233. Private Sub txtComisionPorcentajeCasaCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorcentajeCasaCompra.KeyUp
  2234. If txtComisionPorcentajeCasaCompra.Text = "." Then
  2235. txtComisionPorcentajeCasaCompra.Text = ".0"
  2236. End If
  2237. End Sub
  2238. Private Sub txtComisionPorcentajeBolsaCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorcentajeBolsaCompra.KeyUp
  2239. If txtComisionPorcentajeBolsaCompra.Text = "." Then
  2240. txtComisionPorcentajeBolsaCompra.Text = ".0"
  2241. End If
  2242. End Sub
  2243. Private Sub txtPrecioLimpioVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioLimpioVenta.KeyUp
  2244. If txtPrecioLimpioVenta.Text = "." Then
  2245. txtPrecioLimpioVenta.Text = ".0"
  2246. End If
  2247. End Sub
  2248. Private Sub txtUnidadesVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtUnidadesVenta.KeyUp
  2249. If txtUnidadesVenta.Text = "." Then
  2250. txtUnidadesVenta.Text = ".0"
  2251. End If
  2252. End Sub
  2253. Private Sub txtComisionPorcentajeCasaVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorcentajeCasaVenta.KeyUp
  2254. If txtComisionPorcentajeCasaVenta.Text = "." Then
  2255. txtComisionPorcentajeCasaVenta.Text = ".0"
  2256. End If
  2257. End Sub
  2258. Private Sub txtComisionPorcentajeBolsaVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorcentajeBolsaVenta.KeyUp
  2259. If txtComisionPorcentajeBolsaVenta.Text = "." Then
  2260. txtComisionPorcentajeBolsaVenta.Text = ".0"
  2261. End If
  2262. End Sub
  2263. Private Sub btnVenta_Click(sender As Object, e As EventArgs)
  2264. End Sub
  2265. Private Sub txtValorTransadoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtValorTransadoCompra.TextChanged
  2266. End Sub
  2267. Sub CargarTransladoNuevo()
  2268. Dim Existe As Boolean = ExisteInversion()
  2269. If CantFormAbierto = False Then
  2270. If Not RetCodigoInversionExiste And Not Existe Then
  2271. Dim TipoTransaccionCompraVenta As String = Variables.TipoTransaccionCompraVenta
  2272. If TipoTransaccionCompraVenta = "C" Then
  2273. txtPrecioLimpioCompra.Text = Variables.RetPrecio
  2274. txtUnidadesCompra.Text = Variables.RetUnidadesAcciones
  2275. ElseIf TipoTransaccionCompraVenta = "V" Then
  2276. txtPrecioLimpioVenta.Text = Variables.RetPrecio
  2277. txtUnidadesVenta.Text = Variables.RetUnidadesAcciones
  2278. End If
  2279. End If
  2280. End If
  2281. End Sub
  2282. Private Sub btnVenderTitulo_Click(sender As Object, e As EventArgs) Handles btnVenderTitulo.Click
  2283. If Variables.InvocadorProInv = "frmINV" Then
  2284. Dim TrasladarDatos As New TrasladarDatosCMVTA
  2285. Dim General As New DAOGeneral
  2286. Dim Codigo = Variables.Codigo
  2287. Dim Tabla As String = "INV0"
  2288. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  2289. TrasladarDatos = RellenarDatosCMVTA()
  2290. If Existe Then
  2291. Dim CodigoInversion As String = Variables.Codigo
  2292. Dim frmPINVCMVTA As New frmPIN("V", CodigoInversion, TrasladarDatos)
  2293. frmINV.Close()
  2294. Me.Close()
  2295. frmPINVCMVTA.ShowDialog()
  2296. End If
  2297. End If
  2298. End Sub
  2299. Function RellenarDatosCMVTA()
  2300. Dim TrasladarDatos As New TrasladarDatosCMVTA
  2301. TrasladarDatos.FechaOperacionACC = Operaciones.ConvertirFecha(dtpFechaOperacionCompra.Value.ToString)
  2302. TrasladarDatos.FechaVencimientoACC = Operaciones.ConvertirFecha(dtpFechaVencimientoCompra.Value.ToString)
  2303. TrasladarDatos.PrecioLimpioACC = Operaciones.ConvertirDecimal(txtPrecioLimpioCompra.Text.ToString)
  2304. TrasladarDatos.UnidadesACC = Operaciones.ConvertirEntero(txtUnidadesCompra.Text.ToString)
  2305. TrasladarDatos.PorcentajeBolsaACC = Operaciones.ConvertirDecimal(txtComisionPorcentajeBolsaCompra.Text.ToString)
  2306. TrasladarDatos.PorcentajeCasaACC = Operaciones.ConvertirDecimal(txtComisionPorcentajeCasaCompra.Text.ToString)
  2307. TrasladarDatos.NombreInstrumento = "ACC"
  2308. TrasladarDatos.AgregarCMVTA = True
  2309. Return TrasladarDatos
  2310. End Function
  2311. Private Sub txtValorTransadoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtValorTransadoVenta.TextChanged
  2312. End Sub
  2313. Private Sub txtMontoNetoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtMontoNetoVenta.TextChanged
  2314. End Sub
  2315. Private Sub txtComisionCasaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtComisionCasaCompra.TextChanged
  2316. End Sub
  2317. Private Sub txtComisionCasaVenta_TextChanged(sender As Object, e As EventArgs) Handles txtComisionCasaVenta.TextChanged
  2318. End Sub
  2319. End Class