frmReporto.vb 106 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226
  1. Public Class frmReporto
  2. Dim oDAOGeneral As New DAOGeneral
  3. Dim Aniobase As Integer = 365
  4. Const PorcentajeComisionCasa As Double = 0.2825
  5. Const PorcentajeComisionBolsa As Double = 0.2825
  6. Const PorcentajeComisionIOF As Double = 0.25
  7. Dim PorcentajeISR As Double = 10
  8. Dim oCEReporto As ReportosCE
  9. Dim oDAOReportos As ReportosDAO
  10. Dim Reporto As New ReportosCE
  11. Dim ReportoConsula As New ReportosDAO
  12. Private CodigoInversion As String
  13. Dim Estado As String = String.Empty
  14. Dim CargarUnaVez As Boolean = True
  15. Dim Operaciones As New Operaciones
  16. Dim NombreTitulo As New Dictionary(Of String, String)
  17. Dim Modificado As Boolean = False
  18. Dim InstrumentoFinanciero As String = oDAOGeneral.ObtenerInstrumento(Variables.Codigo)
  19. Dim CodigoRotar As Integer = 0
  20. Private _Modo As String
  21. Private _IdDocumento As Integer
  22. Private _TipoDocumento As String
  23. Private Cargado As Boolean = False
  24. Private Procesado As Boolean = False
  25. Private Tabla As String = String.Empty
  26. Private Base As Integer = 0
  27. Private IOFEstado As Integer = 0
  28. Private RentaEstado As Integer = 0
  29. Private TipoOperacionRepo As String = String.Empty
  30. Private CodigoRepo As String = String.Empty
  31. Private CodigoProveniente As String = String.Empty
  32. Dim CodigoCheque As String = String.Empty
  33. Sub New()
  34. ' Esta llamada es exigida por el diseñador.
  35. InitializeComponent()
  36. ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
  37. End Sub
  38. Public Property Modo As String
  39. Get
  40. Return _Modo
  41. End Get
  42. Set(value As String)
  43. _Modo = value
  44. End Set
  45. End Property
  46. Private Property IdDocumento As Integer
  47. Get
  48. Return _IdDocumento
  49. End Get
  50. Set(value As Integer)
  51. _IdDocumento = value
  52. End Set
  53. End Property
  54. Private Property TipoDocumento As String
  55. Get
  56. Return _TipoDocumento
  57. End Get
  58. Set(value As String)
  59. _TipoDocumento = value
  60. End Set
  61. End Property
  62. Sub AgregarCamposRepoVenta()
  63. Dim Correlativo, Base, Dias, Casa2, Nombre, FCompra, ComisionBolsa, ComisionCasa, codigo, FechaVenta, Monto, FechaVen, CostoFinanciero, Interes, Casa, Bolsa, TotalPagar As New DataGridViewTextBoxColumn
  64. Correlativo.Name = "Correlativo"
  65. codigo.Name = "codigo"
  66. codigo.Visible = False
  67. Monto.Name = "Monto"
  68. FechaVen.Name = "Fecha de Vencimiento"
  69. CostoFinanciero.Name = "Costos Financieros"
  70. Interes.Name = "Intereses"
  71. Casa.Name = "Casa"
  72. Bolsa.Name = "Bolsa"
  73. TotalPagar.Name = "Total a Pagar"
  74. dgvReportos.Columns.Add(Correlativo)
  75. dgvReportos.Columns.Add(Monto)
  76. dgvReportos.Columns.Add(FechaVen)
  77. dgvReportos.Columns.Add(CostoFinanciero)
  78. dgvReportos.Columns.Add(Interes)
  79. dgvReportos.Columns.Add(Casa)
  80. dgvReportos.Columns.Add(Bolsa)
  81. dgvReportos.Columns.Add(TotalPagar)
  82. Nombre.Name = "Nombre"
  83. FCompra.Name = "FCompra"
  84. ComisionCasa.Name = "ComisionCasa"
  85. ComisionBolsa.Name = "ComisionBolsa"
  86. Casa2.Name = "Casa2"
  87. Dias.Name = "Dias"
  88. Base.Name = "Base"
  89. Nombre.Visible = False
  90. FCompra.Visible = False
  91. ComisionCasa.Visible = False
  92. ComisionBolsa.Visible = False
  93. Casa2.Visible = False
  94. Base.Visible = False
  95. dgvReportos.Columns.Add(Nombre)
  96. dgvReportos.Columns.Add(FCompra)
  97. dgvReportos.Columns.Add(ComisionCasa)
  98. dgvReportos.Columns.Add(ComisionBolsa)
  99. dgvReportos.Columns.Add(Casa2)
  100. dgvReportos.Columns.Add(Dias)
  101. dgvReportos.Columns.Add(codigo)
  102. dgvReportos.Columns.Add(Base)
  103. End Sub
  104. Sub AgregarCampos(ByVal Tipo As Integer)
  105. Dim ValTrans, Dias, FVen, Rend, IOF, ComisionCB, CB, OtrosCostos, TotCostos, MontoLiq, InterGen, codigo As New DataGridViewTextBoxColumn
  106. Dim CostoTransfv, Correlativo, RendNetoAntImp, ValReCompra, ImpLiquidacion, IngrNeto, ValNeto, RendNetoDespImp As New DataGridViewTextBoxColumn
  107. Dim Nombre, FCompra, ComisionCasa, ComisionBolsa, Casa, Base, EstadoIOF, EstadoRenta As New DataGridViewTextBoxColumn
  108. Dim Cantidad As Integer = dgvReportos.ColumnCount
  109. If Cantidad = 0 Then
  110. Correlativo.Name = "Correlativo"
  111. codigo.Name = "Codigo"
  112. codigo.Visible = False
  113. ValTrans.Name = "Valor Trasado"
  114. Dias.Name = "Dias"
  115. FVen.Name = "Fecha de Vencimiento"
  116. Rend.Name = "Rendimiento"
  117. IOF.Name = "IOF"
  118. ComisionCB.Name = "Comision CB"
  119. CB.Name = "Comision Bolsa"
  120. OtrosCostos.Name = "Otros Costos"
  121. TotCostos.Name = "Total Costos"
  122. MontoLiq.Name = "Monto a Liquidar"
  123. InterGen.Name = "Interes a Genrerar"
  124. CostoTransfv.Name = "Costo de Transferencia"
  125. RendNetoAntImp.Name = "R% Neto (Antes de Impuesto)"
  126. ValReCompra.Name = "Valor de ReCompra"
  127. ImpLiquidacion.Name = "Impuesto de Liquidacion"
  128. IngrNeto.Name = "Ingreso Neto"
  129. ValNeto.Name = "Valor Neto"
  130. RendNetoDespImp.Name = "R% Neto (Despues de Impuesto)"
  131. Nombre.Name = "Nombre"
  132. FCompra.Name = "FCompra"
  133. ComisionCasa.Name = "ComisionCasa"
  134. ComisionBolsa.Name = "ComisionBolsa"
  135. Casa.Name = "Casa"
  136. Base.Name = "Base"
  137. EstadoIOF.Name = "EstadoIOF"
  138. EstadoRenta.Name = "EstadoRenta"
  139. Nombre.Visible = False
  140. FCompra.Visible = False
  141. ComisionCasa.Visible = False
  142. ComisionBolsa.Visible = False
  143. Casa.Visible = False
  144. Base.Visible = False
  145. EstadoIOF.Visible = False
  146. EstadoRenta.Visible = False
  147. Dim cod As String = Variables.Codigo
  148. If cod.IndexOf("REPOVENTA") > -1 Then
  149. RendNetoAntImp.HeaderText = "Costo Financiero (Antes de Impuesto)"
  150. RendNetoDespImp.HeaderText = "Costo Financiero (Despues de Impuesto)"
  151. Rend.HeaderText = "Costo Financiero"
  152. TotCostos.HeaderText = "Total a Pagar"
  153. Else
  154. RendNetoAntImp.HeaderText = "R% Neto (Antes de Impuesto)"
  155. RendNetoDespImp.HeaderText = "R% Neto (Despues de Impuesto)"
  156. Rend.HeaderText = "Rendimiento"
  157. TotCostos.HeaderText = "Total Costos"
  158. End If
  159. dgvReportos.Columns.Add(Correlativo)
  160. dgvReportos.Columns.Add(ValTrans)
  161. dgvReportos.Columns.Add(Dias)
  162. dgvReportos.Columns.Add(FVen)
  163. dgvReportos.Columns.Add(Rend)
  164. dgvReportos.Columns.Add(ComisionCB)
  165. dgvReportos.Columns.Add(CB)
  166. dgvReportos.Columns.Add(IOF)
  167. dgvReportos.Columns.Add(OtrosCostos)
  168. dgvReportos.Columns.Add(TotCostos)
  169. dgvReportos.Columns.Add(MontoLiq)
  170. dgvReportos.Columns.Add(InterGen)
  171. dgvReportos.Columns.Add(CostoTransfv)
  172. dgvReportos.Columns.Add(RendNetoAntImp)
  173. dgvReportos.Columns.Add(ValReCompra)
  174. dgvReportos.Columns.Add(ImpLiquidacion)
  175. dgvReportos.Columns.Add(IngrNeto)
  176. dgvReportos.Columns.Add(ValNeto)
  177. dgvReportos.Columns.Add(RendNetoDespImp)
  178. dgvReportos.Columns.Add(Nombre)
  179. dgvReportos.Columns.Add(FCompra)
  180. dgvReportos.Columns.Add(ComisionCasa)
  181. dgvReportos.Columns.Add(ComisionBolsa)
  182. dgvReportos.Columns.Add(Casa)
  183. dgvReportos.Columns.Add(codigo)
  184. dgvReportos.Columns.Add(Base)
  185. dgvReportos.Columns.Add(EstadoIOF)
  186. dgvReportos.Columns.Add(EstadoRenta)
  187. Dim CodImp, code As New DataGridViewTextBoxColumn
  188. CodImp.Name = "CodImp"
  189. code.Name = "codigo"
  190. ' dgvImpuestoAgregado.Columns.Add(CodImp)
  191. ' dgvImpuestoAgregado.Columns.Add(code)
  192. End If
  193. End Sub
  194. Sub LlenarBase()
  195. Dim Index As Integer = dgvReportos.Rows.Count - 2
  196. Base = cboAnioBase.SelectedIndex
  197. Dim i As Integer = 0
  198. While i <= Index
  199. dgvReportos.Rows(i).Cells("Base").Value = Base
  200. i += 1
  201. End While
  202. End Sub
  203. Sub IngresarDatos()
  204. If Cargado Then
  205. If Procesado Then
  206. If Not dgvReportos.CurrentRow Is Nothing Then
  207. Dim Index As Integer = dgvReportos.CurrentRow.Index
  208. dgvReportos.Rows(Index).Cells("Nombre").Value = txtCodigoTitulo.Text
  209. dgvReportos.Rows(Index).Cells("FCompra").Value = dtpFechaCompra.Value
  210. If txtComisionCasa.Text.ToString.Trim("%") = 0 Then
  211. dgvReportos.Rows(Index).Cells("ComisionCasa").Value = "0.0"
  212. Else
  213. dgvReportos.Rows(Index).Cells("ComisionCasa").Value = CDec(txtComisionCasa.Text.ToString.Trim("%")) / 100
  214. End If
  215. If txtComisionBolsa.Text.ToString.Trim("%") = 0 Then
  216. dgvReportos.Rows(Index).Cells("ComisionBolsa").Value = "0.0"
  217. Else
  218. dgvReportos.Rows(Index).Cells("ComisionBolsa").Value = CDec(txtComisionBolsa.Text.ToString.Trim("%")) / 100
  219. End If
  220. 'If ChkIOF.Checked Then
  221. ' dgvReportos.Rows(Index).Cells("EstadoIOF").Value = 1
  222. 'Else
  223. ' dgvReportos.Rows(Index).Cells("EstadoIOF").Value = 0
  224. 'End If
  225. 'If ChkRenta.Checked Then
  226. ' dgvReportos.Rows(Index).Cells("EstadoRenta").Value = 1
  227. 'Else
  228. ' dgvReportos.Rows(Index).Cells("EstadoRenta").Value = 0
  229. 'End If
  230. If Variables.Codigo.IndexOf("REPO") > -1 Or Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  231. dgvReportos.Rows(Index).Cells("Casa").Value = cboCasaCorredora.SelectedValue
  232. 'Else
  233. ' dgvReportos.Rows(Index).Cells("Casa2").Value = cboCasaCorredora.SelectedValue
  234. ' dgvReportos.Rows(Index).Cells("Dias").Value = txtDias.Text
  235. End If
  236. End If
  237. End If
  238. End If
  239. End Sub
  240. Sub IngresarDatosReves()
  241. Procesado = False
  242. If Cargado Then
  243. If Not dgvReportos.CurrentRow Is Nothing Then
  244. Dim Index As Integer = dgvReportos.CurrentRow.Index
  245. Dim Nombre = dgvReportos.Rows(Index).Cells("Nombre").Value
  246. Dim FCompra = dgvReportos.Rows(Index).Cells("FCompra").Value
  247. Dim ComisionCasa = dgvReportos.Rows(Index).Cells("ComisionCasa").Value
  248. Dim ComisionBolsa = dgvReportos.Rows(Index).Cells("ComisionBolsa").Value
  249. Dim EstadoIOF = dgvReportos.Rows(Index).Cells("EstadoIOF").Value
  250. Dim EstadoRenta = dgvReportos.Rows(Index).Cells("EstadoRenta").Value
  251. Dim Casa = dgvReportos.Rows(Index).Cells("Casa").Value
  252. If Not Nombre Is DBNull.Value Then
  253. If Not Nombre Is Nothing Then
  254. If Not String.IsNullOrEmpty(Nombre) Then
  255. txtCodigoTitulo.Text = Nombre
  256. Else
  257. txtCodigoTitulo.Text = String.Empty
  258. End If
  259. Else
  260. txtCodigoTitulo.Text = String.Empty
  261. End If
  262. Else
  263. txtCodigoTitulo.Text = String.Empty
  264. End If
  265. If Not FCompra Is DBNull.Value Then
  266. If Not FCompra Is Nothing Then
  267. If Not String.IsNullOrEmpty(FCompra) Then
  268. dtpFechaCompra.Value = FCompra
  269. Else
  270. dtpFechaCompra.Value = Date.Now.Date
  271. End If
  272. Else
  273. dtpFechaCompra.Value = Date.Now.Date
  274. End If
  275. Else
  276. dtpFechaCompra.Value = Date.Now.Date
  277. End If
  278. If Not ComisionCasa Is DBNull.Value Then
  279. If Not ComisionCasa Is Nothing Then
  280. If Not String.IsNullOrEmpty(ComisionCasa.ToString.Trim("%")) Then
  281. txtComisionCasa.Text = ComisionCasa.ToString.Trim("%") * 100
  282. Else
  283. txtComisionCasa.Text = "0.2825%"
  284. End If
  285. Else
  286. txtComisionCasa.Text = "0.2825%"
  287. End If
  288. Else
  289. txtComisionCasa.Text = "0.2825%"
  290. End If
  291. If Not ComisionBolsa Is DBNull.Value Then
  292. If Not ComisionBolsa Is Nothing Then
  293. If Not String.IsNullOrEmpty(ComisionBolsa.ToString.Trim("%")) Then
  294. txtComisionBolsa.Text = ComisionBolsa.ToString.Trim("%") * 100
  295. Else
  296. txtComisionBolsa.Text = "0.2825%"
  297. End If
  298. Else
  299. txtComisionBolsa.Text = "0.2825%"
  300. End If
  301. Else
  302. txtComisionBolsa.Text = "0.2825%"
  303. End If
  304. If Not EstadoIOF Is DBNull.Value Then
  305. If Not EstadoIOF Is Nothing Then
  306. If Not String.IsNullOrEmpty(EstadoIOF) Then
  307. If Index = 0 Then
  308. If EstadoIOF = 1 Then
  309. ChkIOF.Checked = True
  310. Else
  311. ChkIOF.Checked = False
  312. End If
  313. Else
  314. Dim EstadoIOFAnt = dgvReportos.Rows(Index - 1).Cells("EstadoIOF").Value
  315. If EstadoIOFAnt = 1 Then
  316. ChkIOF.Checked = True
  317. Else
  318. ChkIOF.Checked = False
  319. End If
  320. End If
  321. Else
  322. If Not Index = 0 Then
  323. Dim EstadoIOFAnt = dgvReportos.Rows(Index - 1).Cells("EstadoIOF").Value
  324. If EstadoIOFAnt = 1 Then
  325. ChkIOF.Checked = True
  326. Else
  327. ChkIOF.Checked = False
  328. End If
  329. End If
  330. End If
  331. Else
  332. If Not Index = 0 Then
  333. Dim EstadoIOFAnt = dgvReportos.Rows(Index - 1).Cells("EstadoIOF").Value
  334. If EstadoIOFAnt = 1 Then
  335. ChkIOF.Checked = True
  336. Else
  337. ChkIOF.Checked = False
  338. End If
  339. End If
  340. End If
  341. Else
  342. If Not Index = 0 Then
  343. Dim EstadoIOFAnt = dgvReportos.Rows(Index - 1).Cells("EstadoIOF").Value
  344. If EstadoIOFAnt = 1 Then
  345. ChkIOF.Checked = True
  346. Else
  347. ChkIOF.Checked = False
  348. End If
  349. End If
  350. End If
  351. If Not EstadoRenta Is DBNull.Value Then
  352. If Not EstadoRenta Is Nothing Then
  353. If Not String.IsNullOrEmpty(EstadoRenta) Then
  354. If Index = 0 Then
  355. If EstadoRenta = 1 Then
  356. ChkRenta.Checked = True
  357. Else
  358. ChkRenta.Checked = False
  359. End If
  360. Else
  361. Dim EstadoRentaAnt = dgvReportos.Rows(Index - 1).Cells("EstadoRenta").Value
  362. If EstadoRentaAnt = 1 Then
  363. ChkRenta.Checked = True
  364. Else
  365. ChkRenta.Checked = False
  366. End If
  367. End If
  368. Else
  369. If Not Index = 0 Then
  370. Dim EstadoRentaAnt = dgvReportos.Rows(Index - 1).Cells("EstadoRenta").Value
  371. If EstadoRentaAnt = 1 Then
  372. ChkRenta.Checked = True
  373. Else
  374. ChkRenta.Checked = False
  375. End If
  376. End If
  377. End If
  378. Else
  379. If Not Index = 0 Then
  380. Dim EstadoRentaAnt = dgvReportos.Rows(Index - 1).Cells("EstadoRenta").Value
  381. If EstadoRentaAnt = 1 Then
  382. ChkRenta.Checked = True
  383. Else
  384. ChkRenta.Checked = False
  385. End If
  386. End If
  387. End If
  388. Else
  389. If Not Index = 0 Then
  390. Dim EstadoRentaAnt = dgvReportos.Rows(Index - 1).Cells("EstadoRenta").Value
  391. If EstadoRentaAnt = 1 Then
  392. ChkRenta.Checked = True
  393. Else
  394. ChkRenta.Checked = False
  395. End If
  396. End If
  397. End If
  398. 'If (InStr(Variables.Codigo, "REPO") > 0) Or (InStr(Variables.Codigo, "REPOVENTA") > 0) Then
  399. If Not Casa Is DBNull.Value Then
  400. If Not Casa Is Nothing Then
  401. If Not String.IsNullOrEmpty(Casa) Then
  402. cboCasaCorredora.SelectedValue = Casa
  403. Else
  404. cboCasaCorredora.SelectedIndex = -1
  405. End If
  406. Else
  407. cboCasaCorredora.SelectedIndex = -1
  408. End If
  409. Else
  410. cboCasaCorredora.SelectedIndex = -1
  411. End If
  412. End If
  413. End If
  414. Procesado = True
  415. End Sub
  416. Sub ComisionCasa(ByVal ComisionCasa As Double, ByVal Index As Integer)
  417. Dim ValorTrasado As Double = 0.0
  418. Dim Dias As Integer = 0
  419. Dim por As Double = 0
  420. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  421. Dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString)
  422. por = ComisionCasa
  423. Dim Fecha1 As Date = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString)
  424. Dim Fecha2 As Date = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString)
  425. dgvReportos.Rows(Index).Cells("Comision CB").Value = Operaciones.ConvertirDecimal(Reporto.Comision(ValorTrasado, Dias, por, Fecha1, Fecha2, Base).ToString)
  426. End Sub
  427. Function ComisionCasaCargar(ByVal Index As Integer)
  428. Dim ValorTrasado As Double = 0
  429. Dim Dias As Integer = 0
  430. Dim por As Double = 0
  431. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Valor Trasado").Value) Then
  432. ValorTrasado = dgvReportos.Rows(Index).Cells("Valor Trasado").Value
  433. End If
  434. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value) Then
  435. Dias = dgvReportos.Rows(Index).Cells("Dias").Value
  436. End If
  437. If (String.IsNullOrEmpty(txtComisionCasa.Text.ToString.Trim("%"))) Then
  438. txtComisionCasa.Text = "0.2825%"
  439. Else
  440. por = CDec(txtComisionCasa.Text.ToString.Trim("%")) / 100
  441. End If
  442. Dim Fecha1 As Date = dgvReportos.Rows(Index).Cells("FCompra").Value
  443. Dim Fecha2 As Date = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value
  444. Dim Com = Reporto.Comision(ValorTrasado, Dias, por, Fecha1, Fecha2, Base)
  445. dgvReportos.Rows(Index).Cells("Comision CB").Value = Com
  446. Return Com
  447. End Function
  448. Sub ComisionBolsa(ByVal ComisionBolsa As Double, ByVal Index As Integer)
  449. Dim ValorTrasado As Double = 0
  450. Dim Dias As Integer = 0
  451. Dim por As Double = 0
  452. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  453. Dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString)
  454. por = ComisionBolsa
  455. Dim Fecha1 As Date = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString)
  456. Dim Fecha2 As Date = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString)
  457. dgvReportos.Rows(Index).Cells("Comision Bolsa").Value = Operaciones.ConvertirDecimal(Reporto.Comision(ValorTrasado, Dias, por, Fecha1, Fecha2, Base).ToString)
  458. End Sub
  459. Function ComisionBolsaCargar(ByVal Index As Integer)
  460. Dim ValorTrasado As Double = 0
  461. Dim Dias As Integer = 0
  462. Dim por As Double = 0
  463. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Valor Trasado").Value) Then
  464. ValorTrasado = dgvReportos.Rows(Index).Cells("Valor Trasado").Value
  465. End If
  466. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value) Then
  467. Dias = dgvReportos.Rows(Index).Cells("Dias").Value
  468. End If
  469. If Not String.IsNullOrEmpty(txtComisionBolsa.Text.ToString.ToString.Trim("%")) Then
  470. por = txtComisionBolsa.Text.ToString.Trim("%")
  471. End If
  472. Dim Fecha1 As Date = dgvReportos.Rows(Index).Cells("FCompra").Value
  473. Dim Fecha2 As Date = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value
  474. Dim Com = Reporto.Comision(ValorTrasado, Dias, por, Fecha1, Fecha2, Base)
  475. dgvReportos.Rows(Index).Cells("Comision Bolsa").Value = Com
  476. Return Com
  477. End Function
  478. Sub IOF(ByVal Index As Integer)
  479. Dim ValorTrasado As Double = 0
  480. Dim ComisionCasa As Double = 0
  481. Dim ComisionBolsa As Double = 0
  482. Dim dias As Integer = 0
  483. Dim Porcentaje As Double = 0.0025
  484. Dim Fecha1 As Date = Date.Now.Date
  485. Dim Fecha2 As Date = Date.Now.Date
  486. If ChkIOF.Checked Then
  487. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  488. ComisionCasa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision CB").Value.ToString)
  489. ComisionBolsa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision Bolsa").Value.ToString)
  490. dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString)
  491. Fecha1 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString)
  492. Fecha2 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString)
  493. dgvReportos.Rows(Index).Cells("IOF").Value = Operaciones.ConvertirDecimal(Reporto.IOF(ValorTrasado, ComisionCasa, ComisionBolsa, dias, Porcentaje, Fecha1, Fecha2, Base).ToString)
  494. Else
  495. dgvReportos.Rows(Index).Cells("IOF").Value = 0
  496. End If
  497. End Sub
  498. ' Sub IOF()
  499. ' Dim Index As Integer = dgvReportos.CurrentRow.Index
  500. ' Dim ValorTrasado As Double = dgvReportos.Rows(Index).Cells(0).Value
  501. ' Dim CantidadRegistrosImpuestos = dgvImpuestoAgregado.Rows.Count - 1
  502. 'Dim CodeReg = dgvReportos.Rows(Index).Cells(18).Value
  503. 'Dim ComisionCasa As Double = dgvReportos.Rows(Index).Cells(4).Value
  504. 'Dim ComisionBolsa As Double = dgvReportos.Rows(Index).Cells(5).Value
  505. 'Dim dias As Integer = dgvReportos.Rows(Index).Cells(1).Value
  506. 'Dim Porcentaje As Double = 0.0
  507. 'For i As Integer = 0 To CantidadRegistrosImpuestos
  508. 'For j As Integer = 0 To CantidadRegistrosImpuestos
  509. 'If (dgvImpuestoAgregado.Rows(j).Cells(0).Value = "IOF" And dgvImpuestoAgregado.Rows(j).Cells(1).Value = CodeReg) Then
  510. ' Porcentaje = 0.0025
  511. 'Exit For
  512. 'Else
  513. ' Porcentaje = 0
  514. ' End If
  515. 'Next
  516. 'Next
  517. ' dgvReportos.Rows(Index).Cells(6).Value = Reporto.IOF(ValorTrasado, ComisionCasa, ComisionBolsa, dias, Porcentaje)
  518. ' End Sub
  519. 'Sub IOFCargar(ByVal Index As Integer)
  520. 'Dim ValorTrasado As Double = dgvReportos.Rows(Index).Cells(0).Value
  521. 'Dim CantidadRegistrosImpuestos = dgvImpuestoAgregado.Rows.Count - 1
  522. 'Dim CodeReg = dgvReportos.Rows(Index).Cells(18).Value
  523. 'Dim ComisionCasa As Double = dgvReportos.Rows(Index).Cells(4).Value
  524. 'Dim ComisionBolsa As Double = dgvReportos.Rows(Index).Cells(5).Value
  525. 'Dim dias As Integer = dgvReportos.Rows(Index).Cells(1).Value
  526. 'Dim Porcentaje As Double = 0.0
  527. 'For i As Integer = 0 To CantidadRegistrosImpuestos
  528. 'For j As Integer = 0 To CantidadRegistrosImpuestos
  529. 'If (dgvImpuestoAgregado.Rows(j).Cells(0).Value = "IOF" And dgvImpuestoAgregado.Rows(j).Cells(1).Value = CodeReg) Then
  530. ' Porcentaje = 0.0025
  531. 'Exit For
  532. 'Else
  533. ' Porcentaje = 0
  534. 'End If
  535. 'Next
  536. 'Next
  537. ' dgvReportos.Rows(Index).Cells(6).Value = Reporto.IOF(ValorTrasado, ComisionCasa, ComisionBolsa, dias, Porcentaje)
  538. 'End Sub
  539. Sub TotalCostos(ByVal Index As Integer)
  540. Dim ComisionCasa As Double = 0
  541. Dim ComisionBolsa As Double = 0
  542. Dim IOF As Double = 0
  543. Dim OC As Double = 0
  544. Dim ValorTransado As Double = 0
  545. Dim Instrumento As String = String.Empty
  546. If Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  547. Instrumento = "REPOVENTA"
  548. Else
  549. Instrumento = "REPO"
  550. End If
  551. ComisionCasa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision CB").Value.ToString)
  552. ComisionBolsa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision Bolsa").Value.ToString)
  553. IOF = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("IOF").Value.ToString)
  554. OC = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Otros Costos").Value.ToString)
  555. ValorTransado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  556. dgvReportos.Rows(Index).Cells("Total Costos").Value = Operaciones.ConvertirDecimal(Reporto.TotCostos(ComisionCasa, ComisionBolsa, IOF, OC, ValorTransado, Instrumento).ToString)
  557. End Sub
  558. Function TotalCostosCargar(ByVal Index As Integer)
  559. Dim ComisionCasa As Double = 0
  560. Dim ComisionBolsa As Double = 0
  561. Dim IOF As Double = 0
  562. Dim OC As Double = 0
  563. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Comision CB").Value) Then
  564. ComisionCasa = dgvReportos.Rows(Index).Cells("Comision CB").Value
  565. End If
  566. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Comision Bolsa").Value) Then
  567. ComisionBolsa = dgvReportos.Rows(Index).Cells("Comision Bolsa").Value
  568. End If
  569. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("IOF").Value) Then
  570. IOF = dgvReportos.Rows(Index).Cells("IOF").Value
  571. End If
  572. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Otros Costos").Value) Then
  573. OC = dgvReportos.Rows(Index).Cells("Otros Costos").Value
  574. End If
  575. 'Dim Costos = Reporto.TotCostos(ComisionCasa, ComisionBolsa, IOF, OC)
  576. 'dgvReportos.Rows(Index).Cells("Total Costos").Value = Costos
  577. 'Return Costos
  578. End Function
  579. Sub MontoLiquidacion(ByVal Index As Integer)
  580. Dim ValorTrasado As Double = 0
  581. Dim TotalCosto As Double = 0
  582. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  583. TotalCosto = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Total Costos").Value.ToString)
  584. dgvReportos.Rows(Index).Cells("Monto a Liquidar").Value = Operaciones.ConvertirDecimal(Reporto.MontoLiquidacion(ValorTrasado, TotalCosto).ToString)
  585. End Sub
  586. Function MontoLiquidacionCargar(ByVal Index As Integer)
  587. Dim ValorTrasado As Double = 0
  588. Dim TotalCosto As Double = 0
  589. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Valor Trasado").Value) Then
  590. ValorTrasado = dgvReportos.Rows(Index).Cells("Valor Trasado").Value
  591. End If
  592. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Total Costos").Value) Then
  593. TotalCosto = dgvReportos.Rows(Index).Cells("Total Costos").Value
  594. End If
  595. Dim MontoLiq = Reporto.MontoLiquidacion(ValorTrasado, TotalCosto)
  596. dgvReportos.Rows(Index).Cells("Monto a Liquidar").Value = MontoLiq
  597. Return MontoLiq
  598. End Function
  599. Sub InteresGenerar(ByVal Index As Integer)
  600. Dim ValorTrasado As Double = 0
  601. Dim rendimiento As Double = 0
  602. Dim dias As Integer = 0
  603. Dim Fecha1 As Date = Date.Now.Date
  604. Dim Fecha2 As Date = Date.Now.Date
  605. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  606. rendimiento = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Rendimiento").Value.ToString)
  607. dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString)
  608. Fecha1 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString)
  609. Fecha2 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString)
  610. dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value = Operaciones.ConvertirDecimal(Reporto.InteresGenerar(ValorTrasado, rendimiento, dias, Fecha1, Fecha2, Base).ToString)
  611. End Sub
  612. Function InteresGenerarCargar(ByVal Index As Integer)
  613. Dim ValorTrasado As Double = 0
  614. Dim rendimiento As Double = 0
  615. Dim dias As Integer = 0
  616. Dim Fecha1 As Date = Date.Now.Date
  617. Dim Fecha2 As Date = Date.Now.Date
  618. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Valor Trasado").Value) Then
  619. ValorTrasado = dgvReportos.Rows(Index).Cells("Valor Trasado").Value
  620. End If
  621. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Rendimiento").Value) Then
  622. rendimiento = dgvReportos.Rows(Index).Cells("Rendimiento").Value
  623. End If
  624. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value) Then
  625. dias = dgvReportos.Rows(Index).Cells("Dias").Value
  626. End If
  627. Fecha1 = dgvReportos.Rows(Index).Cells("FCompra").Value
  628. Fecha2 = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value
  629. Dim Interes = Reporto.InteresGenerar(ValorTrasado, rendimiento, dias, Fecha1, Fecha2, Base)
  630. dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value = Interes
  631. Return Interes
  632. End Function
  633. Sub RendimientoAntes(ByVal Index As Integer)
  634. Dim ValorTrasado As Double = 0
  635. Dim dias As Integer = 0
  636. Dim InteresGenerar As Double = 0
  637. Dim Totcosto As Double = 0
  638. Dim Fecha1 As Date = Date.Now.Date
  639. Dim Fecha2 As Date = Date.Now.Date
  640. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  641. dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString)
  642. InteresGenerar = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value.ToString)
  643. Totcosto = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Total Costos").Value.ToString)
  644. Fecha1 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString)
  645. Fecha2 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString)
  646. dgvReportos.Rows(Index).Cells("R% Neto (Antes de Impuesto)").Value = Operaciones.ConvertirDecimal(Reporto.RendimientoAntes(InteresGenerar, Totcosto, ValorTrasado, dias, Fecha1, Fecha2, Base, Tabla).ToString)
  647. End Sub
  648. Function RendimientoAntesCargar(ByVal Index As Integer)
  649. Dim ValorTrasado As Double = 0
  650. Dim dias As Integer = 0
  651. Dim InteresGenerar As Double = 0
  652. Dim Totcosto As Double = 0
  653. Dim Rendimiento As Double = 0
  654. Dim Fecha1 As Date = Date.Now.Date
  655. Dim Fecha2 As Date = Date.Now.Date
  656. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Valor Trasado").Value) Then
  657. ValorTrasado = dgvReportos.Rows(Index).Cells("Valor Trasado").Value
  658. End If
  659. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value) Then
  660. dias = dgvReportos.Rows(Index).Cells("Dias").Value
  661. End If
  662. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value) Then
  663. InteresGenerar = dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value
  664. End If
  665. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Total Costos").Value) Then
  666. Totcosto = dgvReportos.Rows(Index).Cells("Total Costos").Value
  667. End If
  668. Fecha1 = dgvReportos.Rows(Index).Cells("FCompra").Value
  669. Fecha2 = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value
  670. Rendimiento = Reporto.RendimientoAntes(InteresGenerar, Totcosto, ValorTrasado, dias, Fecha1, Fecha2, Base, Tabla)
  671. dgvReportos.Rows(Index).Cells("R% Neto (Antes de Impuesto)").Value = Rendimiento
  672. Return Rendimiento
  673. End Function
  674. Sub ValorRecompra(ByVal Index As Integer)
  675. Dim ValorTrasado As Double = 0
  676. Dim InteresGenerar As Double = 0
  677. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  678. InteresGenerar = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value.ToString)
  679. dgvReportos.Rows(Index).Cells("Valor de ReCompra").Value = Operaciones.ConvertirDecimal(Reporto.ValorRecompras(ValorTrasado, InteresGenerar).ToString)
  680. End Sub
  681. Function ValorRecompraCargar(ByVal Index As Integer)
  682. Dim ValorTrasado As Double = 0
  683. Dim InteresGenerar As Double = 0
  684. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Valor Trasado").Value) Then
  685. ValorTrasado = dgvReportos.Rows(Index).Cells("Valor Trasado").Value
  686. End If
  687. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value) Then
  688. InteresGenerar = dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value
  689. End If
  690. Dim ReCompra = Reporto.ValorRecompras(ValorTrasado, InteresGenerar)
  691. dgvReportos.Rows(Index).Cells("Valor de ReCompra").Value = ReCompra
  692. Return ReCompra
  693. End Function
  694. Sub Renta(ByVal Index As String)
  695. Dim InteresGenerar As Double = 0
  696. If ChkRenta.Checked Then
  697. InteresGenerar = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value.ToString)
  698. dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value = (InteresGenerar * 0.1)
  699. Else
  700. dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value = 0
  701. End If
  702. End Sub
  703. ' Sub Renta()
  704. 'Dim Index = dgvReportos.CurrentRow.Index
  705. 'Dim InteresGenerar As Double = dgvReportos.Rows(Index).Cells(10).Value
  706. 'Dim CantidadRegistrosImpuestos = dgvImpuestoAgregado.Rows.Count - 1
  707. 'Dim CodeReg = dgvReportos.Rows(Index).Cells(18).Value
  708. 'Dim Porcentaje = 0.0
  709. 'For i As Integer = 0 To CantidadRegistrosImpuestos
  710. 'For j As Integer = 0 To CantidadRegistrosImpuestos
  711. 'If (dgvImpuestoAgregado.Rows(j).Cells(0).Value = "ISR" And dgvImpuestoAgregado.Rows(j).Cells(1).Value = CodeReg) Then
  712. ' Porcentaje = 0.1
  713. 'Exit For
  714. 'Else
  715. ' Porcentaje = 0
  716. 'End If
  717. 'Next
  718. 'Next
  719. ' dgvReportos.Rows(Index).Cells(14).Value = Reporto.Renta(InteresGenerar, Porcentaje)
  720. 'End Sub
  721. ' Sub RentaCargar(ByVal Index As Integer)
  722. 'Dim InteresGenerar As Double = dgvReportos.Rows(Index).Cells(10).Value
  723. 'Dim CantidadRegistrosImpuestos = dgvImpuestoAgregado.Rows.Count - 1
  724. 'Dim CodeReg = dgvReportos.Rows(Index).Cells(18).Value
  725. 'Dim Porcentaje = 0.0
  726. 'For i As Integer = 0 To CantidadRegistrosImpuestos
  727. 'For j As Integer = 0 To CantidadRegistrosImpuestos
  728. ' If (dgvImpuestoAgregado.Rows(j).Cells(0).Value = "ISR" And dgvImpuestoAgregado.Rows(j).Cells(1).Value = CodeReg) Then
  729. ' Porcentaje = 0.1
  730. 'Exit For
  731. 'Else
  732. ' Porcentaje = 0
  733. 'End If
  734. 'Next
  735. 'Next
  736. ' dgvReportos.Rows(Index).Cells(14).Value = Reporto.Renta(InteresGenerar, Porcentaje)
  737. 'End Sub
  738. Sub IngresoNeto(ByVal Index As Integer)
  739. Dim InteresGenerar As Double = 0
  740. Dim Renta As Double = 0
  741. InteresGenerar = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value.ToString)
  742. Renta = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value.ToString)
  743. dgvReportos.Rows(Index).Cells("Ingreso Neto").Value = Operaciones.ConvertirDecimal(Reporto.IngresoNet(InteresGenerar, Renta).ToString)
  744. End Sub
  745. Function IngresoNetoCargar(ByVal Index As Integer)
  746. Dim Renta As Double = 0
  747. Dim InteresGenerar As Double = 0
  748. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value) Then
  749. InteresGenerar = dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value
  750. End If
  751. If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value)) Then
  752. dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value = 0
  753. Renta = 0
  754. Else
  755. Renta = dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value
  756. End If
  757. Dim ING = Reporto.IngresoNet(InteresGenerar, Renta)
  758. dgvReportos.Rows(Index).Cells("Ingreso Neto").Value = ING
  759. Return ING
  760. End Function
  761. Sub ValorNeto(ByVal Index As Integer)
  762. Dim ValorTrasado As Double = 0
  763. Dim IngresoNeto As Double = 0
  764. Dim CostoTrans As Double = 0
  765. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  766. IngresoNeto = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Ingreso Neto").Value.ToString)
  767. CostoTrans = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Costo de Transferencia").Value.ToString)
  768. dgvReportos.Rows(Index).Cells("Valor Neto").Value = Operaciones.ConvertirDecimal(Reporto.ValorNet(ValorTrasado, IngresoNeto, CostoTrans).ToString)
  769. End Sub
  770. Function ValorNetoCargar(ByVal Index As Integer)
  771. Dim ValorTrasado As Double = 0
  772. Dim IngresoNeto As Double = 0
  773. Dim CostoTrans As Double = 0
  774. If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Valor Trasado").Value)) Then
  775. ValorTrasado = dgvReportos.Rows(Index).Cells("Valor Trasado").Value
  776. End If
  777. If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Ingreso Neto").Value)) Then
  778. dgvReportos.Rows(Index).Cells("Ingreso Neto").Value = 0
  779. Else
  780. IngresoNeto = dgvReportos.Rows(Index).Cells("Ingreso Neto").Value
  781. End If
  782. If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Costo de Transferencia").Value)) Then
  783. dgvReportos.Rows(Index).Cells("Costo de Transferencia").Value = 0
  784. Else
  785. CostoTrans = dgvReportos.Rows(Index).Cells("Costo de Transferencia").Value
  786. End If
  787. Dim VN = Reporto.ValorNet(ValorTrasado, IngresoNeto, CostoTrans)
  788. dgvReportos.Rows(Index).Cells("Valor Neto").Value = VN
  789. Return VN
  790. End Function
  791. Sub RendimientoDespues(ByVal Index As Integer)
  792. Dim ValorTrasado As Double = 0
  793. Dim IngresoNeto As Double = 0
  794. Dim TotalCosto As Double = 0
  795. Dim dias As Integer = 0
  796. Dim Fecha1 As Date = Date.Now.Date
  797. Dim Fecha2 As Date = Date.Now.Date
  798. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  799. IngresoNeto = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Ingreso Neto").Value.ToString)
  800. TotalCosto = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Total Costos").Value.ToString)
  801. dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString)
  802. Fecha1 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString)
  803. Fecha2 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString)
  804. dgvReportos.Rows(Index).Cells("R% Neto (Despues de Impuesto)").Value = Operaciones.ConvertirDecimal(Reporto.RendimientoDespues(IngresoNeto, TotalCosto, ValorTrasado, dias, Fecha1, Fecha2, Base).ToString)
  805. End Sub
  806. Function RendimientoDespuesCargar(ByVal Index As Integer)
  807. Dim ValorTrasado As Double = 0
  808. Dim IngresoNeto As Double = 0
  809. Dim TotalCosto As Double = 0
  810. Dim dias As Integer = 0
  811. Dim Fecha1 As Date = Date.Now.Date
  812. Dim Fecha2 As Date = Date.Now.Date
  813. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Valor Trasado").Value) Then
  814. ValorTrasado = dgvReportos.Rows(Index).Cells("Valor Trasado").Value
  815. End If
  816. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Ingreso Neto").Value) Then
  817. IngresoNeto = dgvReportos.Rows(Index).Cells("Ingreso Neto").Value
  818. End If
  819. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Total Costos").Value) Then
  820. TotalCosto = dgvReportos.Rows(Index).Cells("Total Costos").Value
  821. End If
  822. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value) Then
  823. dias = dgvReportos.Rows(Index).Cells("Dias").Value
  824. End If
  825. Fecha1 = dgvReportos.Rows(Index).Cells("FCompra").Value
  826. Fecha2 = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value
  827. Dim Rend = Reporto.RendimientoDespues(IngresoNeto, TotalCosto, ValorTrasado, dias, Fecha1, Fecha2, Base)
  828. dgvReportos.Rows(Index).Cells("R% Neto (Despues de Impuesto)").Value = Rend
  829. Return Rend
  830. End Function
  831. Sub CargarFecha()
  832. Dim Index As Integer = dgvReportos.CurrentRow.Index
  833. Dim Fecha As Date = dtpFechaCompra.Value
  834. Dim Fecha2 As Date = Date.Now.Date
  835. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value) Then
  836. Fecha2 = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value
  837. End If
  838. End Sub
  839. Private Sub CargarCasaCorredora()
  840. If cboCasaCorredora.Items.Count = 0 Or cboCasaCorredora.Items.Count = 1 Then
  841. Me.cboCasaCorredora.DataSource = oDAOGeneral.ListaTiposImpuesto
  842. Me.cboCasaCorredora.DisplayMember = "Descripcion"
  843. Me.cboCasaCorredora.ValueMember = "Codigo"
  844. Me.cboCasaCorredora.SelectedIndex = 0
  845. End If
  846. End Sub
  847. 'Private Sub PrepararTablaImpuestos()
  848. ' Dim cboColumna, cboCodigoInv As DataGridViewComboBoxColumn
  849. ' cboColumna = New DataGridViewComboBoxColumn
  850. ' cboColumna.Name = "Valor"
  851. ' cboColumna.HeaderText = "CodImp"
  852. ' cboColumna.DataSource = oDAOGeneral.ListaImpuesto
  853. ' cboColumna.ValueMember = "CodImp"
  854. ' cboColumna.DisplayMember = "Descripcion"
  855. ' cboColumna.DataPropertyName = "CodImp"
  856. ' cboColumna.DisplayIndex = 1
  857. 'Me.dgvImpuestos.Columns.Add(cboColumna)
  858. ' cboCodigoInv = New DataGridViewComboBoxColumn
  859. ' cboCodigoInv.Name = "Codigo"
  860. ' cboCodigoInv.HeaderText = "Codigo"
  861. 'cboCodigoInv.DataSource = oDAOGeneral.ListaInversion(Variables.Codigo)
  862. ' cboCodigoInv.DisplayMember = "Descripcion"
  863. ' cboCodigoInv.DataPropertyName = "Codigo"
  864. ' cboCodigoInv.DisplayIndex = 2
  865. 'Me.dgvImpuestos.Columns.Add(cboCodigoInv)
  866. 'End Sub
  867. Sub CargarBase()
  868. If cboAnioBase.Items.Count = 0 Or cboAnioBase.Items.Count = 1 Then
  869. Me.cboAnioBase.DataSource = oDAOGeneral.ListaBase
  870. Me.cboAnioBase.DisplayMember = "Descripcion"
  871. Me.cboAnioBase.ValueMember = "Codigo"
  872. Me.cboAnioBase.SelectedIndex = 0
  873. End If
  874. End Sub
  875. Private Sub frmReporto_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  876. Titulo.TabPages.Remove(TbImpuestos)
  877. Dim CantidadFilas As Integer = dgvReportos.Rows.Count
  878. CargarCasaCorredora()
  879. CargarBase()
  880. If Variables.Codigo.IndexOf("REPO") > -1 And Not Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  881. Tabla = "REP0"
  882. lblReporto.Text = "Reporto de Compra"
  883. Variables.Inicio = True
  884. 'Call CargarRegistroBD
  885. txtComisionCasa.Text = PorcentajeComisionCasa
  886. txtComisionBolsa.Text = PorcentajeComisionBolsa
  887. ' txtIOF.Text = PorcentajeComisionIOF
  888. If CantidadFilas <= 1 Then
  889. AgregarCampos(1)
  890. ' PrepararTablaImpuestos()
  891. CargarReporto(Tabla)
  892. End If
  893. Calculos()
  894. Variables.Inicio = False
  895. 'AgregarCheckbox()
  896. 'CalcularCheckbox()
  897. Calculos()
  898. CargarUnaVez = False
  899. CodigoRotar = 0
  900. ElseIf Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  901. OcultarValoresImp()
  902. Tabla = "REP0VENTA"
  903. lblReporto.Text = "Reporto de Venta"
  904. lblFechaCompra.Text = "Fecha de Venta"
  905. lblCodigoInstrumento.Visible = True
  906. txtCodigoInstrumento.Visible = True
  907. If Not String.IsNullOrEmpty(CodigoProveniente) Then
  908. txtCodigoInstrumento.Text = CodigoProveniente
  909. End If
  910. If CantidadFilas <= 1 Then
  911. AgregarCampos(2)
  912. ' PrepararTablaImpuestos()
  913. CargarReporto(Tabla)
  914. End If
  915. CodigoRotar = 0
  916. Calculos()
  917. CargarMontoRepoVenta()
  918. End If
  919. Cargado = True
  920. CorrelativoSinBD()
  921. ExisteInversion()
  922. ValidarExistencia()
  923. Formato()
  924. CargarTransladoNuevo()
  925. End Sub
  926. Sub CargarMontoRepoVenta()
  927. If Operaciones.ConvertirDecimal(txtMonto.Text.ToString) > 0 Then
  928. If dgvReportos.Rows(0).Cells("Valor Trasado").Value = 0 Then
  929. dgvReportos.Rows(0).Cells("Valor Trasado").Value = txtMonto.Text
  930. txtMonto.Text = 0
  931. End If
  932. End If
  933. End Sub
  934. Sub OcultarValoresImp()
  935. ChkIOF.Checked = False
  936. ChkRenta.Checked = False
  937. ChkRenta.Visible = False
  938. ChkIOF.Visible = False
  939. End Sub
  940. Function ExisteInversion()
  941. Dim Codigo As String = Variables.Codigo
  942. Dim TablaINV As String = "INV0"
  943. Dim TablaPINV As String = "PIN0"
  944. Dim General As New DAOGeneral
  945. Dim InvPro = Variables.InvPro
  946. If InvPro = "I" Then
  947. Dim INV0 As Boolean = General.ExisteTitulo(Codigo, TablaINV)
  948. If INV0 Then
  949. navNuevo.Visible = True
  950. Return True
  951. Else
  952. navNuevo.Visible = False
  953. Return False
  954. End If
  955. End If
  956. If InvPro = "P" Then
  957. Dim PINV0 As Boolean = General.ExisteTitulo(Codigo, TablaPINV)
  958. If PINV0 Then
  959. navNuevo.Visible = True
  960. Return True
  961. Else
  962. navNuevo.Visible = False
  963. Return False
  964. End If
  965. End If
  966. Return False
  967. End Function
  968. Sub Formato()
  969. If (String.IsNullOrEmpty(txtDias.Text.ToString)) Then
  970. txtDias.Text = 0
  971. End If
  972. If (String.IsNullOrEmpty(txtComisionCasa.Text.ToString.Trim("%"))) Then
  973. txtComisionCasa.Text = "0.2825%"
  974. End If
  975. If (String.IsNullOrEmpty(txtComisionBolsa.Text.ToString.Trim("%"))) Then
  976. txtComisionBolsa.Text = "0.2825%"
  977. End If
  978. If txtComisionBolsa.Text.ToString.IndexOf("%") = -1 Then
  979. txtComisionBolsa.Text = txtComisionBolsa.Text.ToString + "%"
  980. End If
  981. If txtComisionCasa.Text.ToString.IndexOf("%") = -1 Then
  982. txtComisionCasa.Text = txtComisionCasa.Text.ToString + "%"
  983. End If
  984. If cboCasaCorredora.SelectedIndex = -1 Then
  985. Try
  986. cboCasaCorredora.SelectedIndex = 0
  987. Catch ex As Exception
  988. End Try
  989. End If
  990. End Sub
  991. Sub IOFRentaEstado()
  992. Dim CantidadRegistro As Integer = dgvReportos.Rows.Count - 2
  993. Dim EstadoImpIOF As Integer = 0
  994. Dim EstadoImpRenta As Integer = 0
  995. 'Dim Index As Integer = dgvReportos.CurrentRow.Index
  996. 'If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("EstadoIOF").Value) Then
  997. ' EstadoImpIOF = dgvReportos.Rows(Index).Cells("EstadoIOF").Value
  998. 'End If
  999. 'If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("EstadoRenta").Value) Then
  1000. ' EstadoImpRenta = dgvReportos.Rows(Index).Cells("EstadoRenta").Value
  1001. 'End If
  1002. If ChkIOF.Checked Then
  1003. EstadoImpIOF = 1
  1004. Else
  1005. EstadoImpIOF = 0
  1006. End If
  1007. If ChkRenta.Checked Then
  1008. EstadoImpRenta = 1
  1009. Else
  1010. EstadoImpRenta = 0
  1011. End If
  1012. Dim i As Integer = 0
  1013. While i <= CantidadRegistro
  1014. dgvReportos.Rows(i).Cells("EstadoIOF").Value = EstadoImpIOF
  1015. dgvReportos.Rows(i).Cells("EstadoRenta").Value = EstadoImpRenta
  1016. i += 1
  1017. End While
  1018. End Sub
  1019. Sub AgregarCheckbox()
  1020. If Variables.Codigo.IndexOf("REPO") > -1 Or Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  1021. Dim Cantidad As Integer = dgvReportos.Rows.Count - 2
  1022. For i As Integer = 0 To Cantidad
  1023. Dim IOF As New CheckBox
  1024. Dim Renta As New CheckBox
  1025. Dim Existe As Boolean = False
  1026. Dim Codigo = dgvReportos.Rows(i).Cells("Codigo").Value
  1027. For Each item As CheckBox In FlpIOF.Controls
  1028. If item.Text.ToString = Codigo.ToString Then
  1029. Existe = True
  1030. End If
  1031. Next
  1032. If Not Existe Then
  1033. If (Not dgvReportos.Rows(i).Cells("IOF").Value = 0) Then
  1034. IOF.Name = Codigo.ToString + "ffeaeae8"
  1035. IOF.Checked = True
  1036. IOF.BackColor = ColorTranslator.FromHtml("#EAEAE8")
  1037. Else
  1038. IOF.Checked = False
  1039. End If
  1040. If (Not dgvReportos.Rows(i).Cells("Impuesto de Liquidacion").Value = 0) Then
  1041. Renta.Name = CStr(Codigo) + "ffeaeae8"
  1042. Renta.Checked = True
  1043. Renta.BackColor = ColorTranslator.FromHtml("#EAEAE8")
  1044. Else
  1045. Renta.Checked = False
  1046. End If
  1047. IOF.Text = Codigo
  1048. Renta.Text = Codigo
  1049. AddHandler IOF.CheckedChanged, AddressOf eventoIOF
  1050. AddHandler Renta.CheckedChanged, AddressOf eventoRenta
  1051. FlpIOF.Controls.Add(IOF)
  1052. FlpRenta.Controls.Add(Renta)
  1053. End If
  1054. Existe = False
  1055. Next
  1056. End If
  1057. End Sub
  1058. Sub eventoIOF(sender As Object, e As EventArgs)
  1059. If (sender.checked) Then
  1060. sender.BackColor = ColorTranslator.FromHtml("#EAEAE8")
  1061. Else
  1062. sender.BackColor = ColorTranslator.FromHtml("Transparent")
  1063. End If
  1064. CalcularCheckbox()
  1065. Calculos()
  1066. End Sub
  1067. Sub eventoRenta(sender As Object, e As EventArgs)
  1068. If (sender.checked) Then
  1069. sender.BackColor = ColorTranslator.FromHtml("#EAEAE8")
  1070. Else
  1071. sender.BackColor = ColorTranslator.FromHtml("Transparent")
  1072. End If
  1073. CalcularCheckbox()
  1074. Calculos()
  1075. End Sub
  1076. Sub CalcularCheckbox()
  1077. Dim xCheckBox As New Control
  1078. For Each xCheckBox In Me.FlpIOF.Controls
  1079. If TypeOf xCheckBox Is CheckBox Then
  1080. Dim Index = xCheckBox.TabIndex
  1081. Try
  1082. Dim codigo = dgvReportos.Rows(Index).Cells("Codigo").Value
  1083. If Not String.IsNullOrEmpty(codigo) Then
  1084. Dim ColorCodigo = CStr(codigo) + xCheckBox.BackColor.Name.ToString
  1085. If (ColorCodigo = (codigo + "ffeaeae8")) Then
  1086. Dim codigoText = xCheckBox.Text
  1087. If (codigo = codigoText) Then
  1088. IOF(Index)
  1089. End If
  1090. Else
  1091. dgvReportos.Rows(Index).Cells("IOF").Value = 0
  1092. End If
  1093. End If
  1094. Catch ex As Exception
  1095. End Try
  1096. End If
  1097. Next
  1098. Dim xCheckBo As New Control
  1099. For Each xCheckBo In Me.FlpRenta.Controls
  1100. If TypeOf xCheckBo Is CheckBox Then
  1101. Dim Index = xCheckBo.TabIndex
  1102. Try
  1103. Dim codigo = dgvReportos.Rows(Index).Cells("Codigo").Value
  1104. If Not String.IsNullOrEmpty(codigo) Then
  1105. Dim ColorCodigo = CStr(codigo) + xCheckBo.BackColor.Name.ToString
  1106. If (ColorCodigo = (codigo + "ffeaeae8")) Then
  1107. Dim codigoText = xCheckBo.Text
  1108. If (codigo = codigoText) Then
  1109. Renta(Index)
  1110. End If
  1111. Else
  1112. dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value = 0
  1113. End If
  1114. End If
  1115. Catch ex As Exception
  1116. End Try
  1117. End If
  1118. Next
  1119. End Sub
  1120. Sub ActualizarImpuestos(ByVal Valor As Integer)
  1121. CargarReporto(Tabla)
  1122. End Sub
  1123. Sub RotarValores(ByVal Codigo As String)
  1124. End Sub
  1125. Sub CalculosRepoVentas(ByVal Index As Integer)
  1126. End Sub
  1127. Sub PrepararRepoVentas()
  1128. Dim Cantidad As Integer = dgvReportos.Rows.Count - 2
  1129. Dim Index As Integer = 0
  1130. While Index <= Cantidad
  1131. Dim IndexAnterior As Integer = 0
  1132. DefinirCorrelativo(Index)
  1133. dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value = CalcularFechaVencimiento(Index)
  1134. PrepararMonto(Index)
  1135. PrepararCostosFinancieros(Index)
  1136. dgvReportos.Rows(Index).Cells("Intereses").Value = CalcularInteres(Index, Base)
  1137. dgvReportos.Rows(Index).Cells("Casa").Value = CalcularComisionCasa(Index, Base)
  1138. dgvReportos.Rows(Index).Cells("Bolsa").Value = CalcularComisionBolsa(Index, Base)
  1139. dgvReportos.Rows(Index).Cells("Total a Pagar").Value = TotalPagarSumaComisiones(Index)
  1140. Index += 1
  1141. End While
  1142. End Sub
  1143. Sub DefinirCorrelativo(ByVal Index As Integer)
  1144. 'Dim CorrelavivoAnterior As Integer = 0
  1145. 'If (Index = 0) Then
  1146. ' If (dgvReportos.Rows(Index).Cells("Correlativo").Value Is Nothing) Then
  1147. ' dgvReportos.Rows(Index).Cells("Correlativo").Value = 1
  1148. ' End If
  1149. 'Else
  1150. ' CorrelavivoAnterior = dgvReportos.Rows(Index - 1).Cells("Correlativo").Value
  1151. ' dgvReportos.Rows(Index).Cells("Correlativo").Value = CorrelavivoAnterior + 1
  1152. 'End If
  1153. End Sub
  1154. Function TotalPagarSumaComisiones(ByVal Index As Integer)
  1155. Dim ComisionCasa = 0.0, ComisionBolsa = 0.0, SumaComisiones = 0.0
  1156. If (Not dgvReportos.Rows(Index).Cells("Casa").Value Is Nothing) Then
  1157. ComisionCasa = dgvReportos.Rows(Index).Cells("Casa").Value
  1158. End If
  1159. If (Not dgvReportos.Rows(Index).Cells("Bolsa").Value Is Nothing) Then
  1160. ComisionBolsa = dgvReportos.Rows(Index).Cells("Bolsa").Value
  1161. End If
  1162. SumaComisiones = ComisionCasa + ComisionBolsa
  1163. Return SumaComisiones
  1164. End Function
  1165. Function CalcularComisionBolsa(ByVal Index As Integer, ByVal IndexBase As Integer)
  1166. Dim Monto = 0.0, Porcentaje = 0.0, Dias = 0, Comision = 0.0, Fecha1 = Date.Now.Date, Fecha2 = Date.Now.Date
  1167. If (Not dgvReportos.Rows(Index).Cells("Monto").Value Is Nothing) Then
  1168. Monto = dgvReportos.Rows(Index).Cells("Monto").Value
  1169. End If
  1170. If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("ComisionBolsa").Value)) Then
  1171. Porcentaje = dgvReportos.Rows(Index).Cells("ComisionBolsa").Value
  1172. End If
  1173. If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value)) Then
  1174. If String.IsNullOrEmpty(txtDias.Text) Then
  1175. Dias = 0
  1176. Else
  1177. Dias = txtDias.Text
  1178. End If
  1179. End If
  1180. Dim Valor As Double = 0
  1181. Valor = (Monto * Porcentaje) * Dias / 365
  1182. Return Valor
  1183. 'If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("FCompra").Value)) Then
  1184. ' Fecha1 = dgvReportos.Rows(Index).Cells("FCompra").Value
  1185. 'End If
  1186. 'If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value)) Then
  1187. ' Fecha2 = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value
  1188. 'End If
  1189. 'Dim Valor As Double = 0
  1190. 'If (IndexBase = 0) Then
  1191. ' Valor = (Monto * Porcentaje) * Dias / 360
  1192. ' Return Valor
  1193. 'ElseIf (IndexBase = 1) Then
  1194. ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1195. ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1196. ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1197. ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1198. ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1199. ' PrOpc1 = (Monto * Porcentaje) * DiasPrimeraFecha / 366
  1200. ' PrOpc2 = (Monto * Porcentaje) * DiasSegundaFecha / 365
  1201. ' Valor = PrOpc1 + PrOpc2
  1202. ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1203. ' Valor = (Monto * Porcentaje) * DiasSegundaFecha / 365
  1204. ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1205. ' Valor = (Monto * Porcentaje) * DiasPrimeraFecha / 366
  1206. ' Else
  1207. ' Valor = 0
  1208. ' End If
  1209. ' Return Valor
  1210. 'ElseIf (IndexBase = 2) Then
  1211. ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1212. ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1213. ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
  1214. ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
  1215. ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1216. ' PrOpc1 = (Monto * Porcentaje) * DiasPrimeraFecha / 366
  1217. ' PrOpc2 = (Monto * Porcentaje) * DiasSegundaFecha / 365
  1218. ' Valor = PrOpc1 + PrOpc2
  1219. ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1220. ' Valor = (Monto * Porcentaje) * DiasSegundaFecha / 365
  1221. ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1222. ' Valor = (Monto * Porcentaje) * DiasPrimeraFecha / 366
  1223. ' Else
  1224. ' Valor = 0
  1225. ' End If
  1226. ' Return Valor
  1227. 'Else
  1228. ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1229. ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1230. ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1231. ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1232. ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1233. ' PrOpc1 = (Monto * Porcentaje) * DiasPrimeraFecha / 360
  1234. ' PrOpc2 = (Monto * Porcentaje) * DiasSegundaFecha / 360
  1235. ' Valor = PrOpc1 + PrOpc2
  1236. ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1237. ' Valor = (Monto * Porcentaje) * DiasSegundaFecha / 360
  1238. ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1239. ' Valor = (Monto * Porcentaje) * DiasPrimeraFecha / 360
  1240. ' Else
  1241. ' Valor = 0
  1242. ' End If
  1243. ' Return Valor
  1244. 'End If
  1245. 'Return Valor
  1246. End Function
  1247. Function CalcularComisionCasa(ByVal Index As Integer, ByVal IndexBase As Integer)
  1248. Dim Monto = 0.0, Porcentaje = 0.0, Dias = 0, Comision = 0.0, Fecha1 = Date.Now.Date, Fecha2 = Date.Now.Date
  1249. If (Not dgvReportos.Rows(Index).Cells("Monto").Value Is Nothing) Then
  1250. Monto = dgvReportos.Rows(Index).Cells("Monto").Value
  1251. End If
  1252. If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("ComisionCasa").Value)) Then
  1253. Porcentaje = dgvReportos.Rows(Index).Cells("ComisionCasa").Value
  1254. End If
  1255. If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value)) Then
  1256. Dias = dgvReportos.Rows(Index).Cells("Dias").Value
  1257. End If
  1258. If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("FCompra").Value)) Then
  1259. Fecha1 = dgvReportos.Rows(Index).Cells("FCompra").Value
  1260. End If
  1261. If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value)) Then
  1262. Fecha2 = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value
  1263. End If
  1264. ''''''''''''''''''''''''''''''''''''''''
  1265. Dim Valor As Double = 0
  1266. Valor = (Monto * Porcentaje) * Dias / 365
  1267. 'If (IndexBase = 0) Then
  1268. ' Valor = (Monto * Porcentaje) * Dias / 360
  1269. ' Return Valor
  1270. 'ElseIf (IndexBase = 1) Then
  1271. ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1272. ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1273. ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1274. ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1275. ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1276. ' PrOpc1 = (Monto * Porcentaje) * DiasPrimeraFecha / 366
  1277. ' PrOpc2 = (Monto * Porcentaje) * DiasSegundaFecha / 365
  1278. ' Valor = PrOpc1 + PrOpc2
  1279. ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1280. ' Valor = (Monto * Porcentaje) * DiasSegundaFecha / 365
  1281. ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1282. ' Valor = (Monto * Porcentaje) * DiasPrimeraFecha / 366
  1283. ' Else
  1284. ' Valor = 0
  1285. ' End If
  1286. ' Return Valor
  1287. 'ElseIf (IndexBase = 2) Then
  1288. ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1289. ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1290. ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
  1291. ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
  1292. ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1293. ' PrOpc1 = (Monto * Porcentaje) * DiasPrimeraFecha / 366
  1294. ' PrOpc2 = (Monto * Porcentaje) * DiasSegundaFecha / 365
  1295. ' Valor = PrOpc1 + PrOpc2
  1296. ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1297. ' Valor = (Monto * Porcentaje) * DiasSegundaFecha / 365
  1298. ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1299. ' Valor = (Monto * Porcentaje) * DiasPrimeraFecha / 366
  1300. ' Else
  1301. ' Valor = 0
  1302. ' End If
  1303. ' Return Valor
  1304. 'Else
  1305. ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1306. ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1307. ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1308. ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1309. ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1310. ' PrOpc1 = (Monto * Porcentaje) * DiasPrimeraFecha / 360
  1311. ' PrOpc2 = (Monto * Porcentaje) * DiasSegundaFecha / 360
  1312. ' Valor = PrOpc1 + PrOpc2
  1313. ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1314. ' Valor = (Monto * Porcentaje) * DiasSegundaFecha / 360
  1315. ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1316. ' Valor = (Monto * Porcentaje) * DiasPrimeraFecha / 360
  1317. ' Else
  1318. ' Valor = 0
  1319. ' End If
  1320. ' Return Valor
  1321. 'End If
  1322. Return Valor
  1323. End Function
  1324. Function CalcularInteres(ByVal Index As Integer, ByVal IndexBase As Integer)
  1325. Dim Monto = 0.0, CostoFinanciero = 0.0, Dias = 0, Interes = 0.0, Fecha1 = Date.Now.Date, Fecha2 = Date.Now.Date
  1326. If (Not dgvReportos.Rows(Index).Cells("Monto").Value Is Nothing) Then
  1327. Monto = dgvReportos.Rows(Index).Cells("Monto").Value
  1328. End If
  1329. If (Not dgvReportos.Rows(Index).Cells("Costos Financieros").Value Is Nothing) Then
  1330. CostoFinanciero = dgvReportos.Rows(Index).Cells("Costos Financieros").Value
  1331. End If
  1332. If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value)) Then
  1333. Dias = dgvReportos.Rows(Index).Cells("Dias").Value
  1334. End If
  1335. If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("FCompra").Value)) Then
  1336. Fecha1 = dgvReportos.Rows(Index).Cells("FCompra").Value
  1337. End If
  1338. If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value)) Then
  1339. Fecha2 = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value
  1340. End If
  1341. ''''''''''''''''''''''''''''''''''''''''''''''''
  1342. Dim Valor As Double = 0
  1343. Valor = (Monto * CostoFinanciero) * Dias / 365
  1344. Return Valor
  1345. 'If (IndexBase = 0) Then
  1346. ' Valor = (Monto * CostoFinanciero) * Dias / 360
  1347. ' Return Valor
  1348. 'ElseIf (IndexBase = 1) Then
  1349. ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1350. ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1351. ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1352. ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1353. ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1354. ' PrOpc1 = (Monto * CostoFinanciero) * DiasPrimeraFecha / 366
  1355. ' PrOpc2 = (Monto * CostoFinanciero) * DiasSegundaFecha / 365
  1356. ' Valor = PrOpc1 + PrOpc2
  1357. ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1358. ' Valor = (Monto * CostoFinanciero) * DiasSegundaFecha / 365
  1359. ' MsgBox(Monto)
  1360. ' MsgBox(CostoFinanciero)
  1361. ' MsgBox(DiasSegundaFecha)
  1362. ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1363. ' Valor = (Monto * CostoFinanciero) * DiasPrimeraFecha / 366
  1364. ' Else
  1365. ' Valor = 0
  1366. ' End If
  1367. ' Return Valor
  1368. 'ElseIf (IndexBase = 2) Then
  1369. ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1370. ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1371. ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
  1372. ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
  1373. ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1374. ' PrOpc1 = (Monto * CostoFinanciero) * DiasPrimeraFecha / 366
  1375. ' PrOpc2 = (Monto * CostoFinanciero) * DiasSegundaFecha / 365
  1376. ' Valor = PrOpc1 + PrOpc2
  1377. ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1378. ' Valor = (Monto * CostoFinanciero) * DiasSegundaFecha / 365
  1379. ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1380. ' Valor = (Monto * CostoFinanciero) * DiasPrimeraFecha / 366
  1381. ' Else
  1382. ' Valor = 0
  1383. ' End If
  1384. ' Return Valor
  1385. 'Else
  1386. ' Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1387. ' Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1388. ' DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1389. ' DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1390. ' If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1391. ' PrOpc1 = (Monto * CostoFinanciero) * DiasPrimeraFecha / 360
  1392. ' PrOpc2 = (Monto * CostoFinanciero) * DiasSegundaFecha / 360
  1393. ' Valor = PrOpc1 + PrOpc2
  1394. ' ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1395. ' Valor = (Monto * CostoFinanciero) * DiasSegundaFecha / 360
  1396. ' ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1397. ' Valor = (Monto * CostoFinanciero) * DiasPrimeraFecha / 360
  1398. ' Else
  1399. ' Valor = 0
  1400. ' End If
  1401. ' Return Valor
  1402. 'End If
  1403. 'Return Valor
  1404. End Function
  1405. Sub PrepararCostosFinancieros(ByVal Index As Integer)
  1406. If (dgvReportos.Rows(Index).Cells("Costos Financieros").Value Is Nothing) Then
  1407. dgvReportos.Rows(Index).Cells("Costos Financieros").Value = 0
  1408. End If
  1409. End Sub
  1410. Sub PrepararMonto(ByVal Index As Integer)
  1411. If (dgvReportos.Rows(Index).Cells("Monto").Value Is Nothing) Then
  1412. dgvReportos.Rows(Index).Cells("Monto").Value = 0
  1413. Else
  1414. If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Monto").Value.ToString)) Then
  1415. dgvReportos.Rows(Index).Cells("Monto").Value = 0
  1416. End If
  1417. End If
  1418. End Sub
  1419. Sub RellenarTxt()
  1420. 'If (InStr(Variables.Codigo, "REPOVENTA") > 0) Then
  1421. ' If (String.IsNullOrEmpty(txtDias.Text.ToString)) Then
  1422. ' txtDias.Text = "0"
  1423. ' End If
  1424. 'End If
  1425. End Sub
  1426. Sub RellenarDatos()
  1427. Dim Index = dgvReportos.CurrentRow.Index
  1428. 'If (Not dgvReportos.Rows(Index).IsNewRow) Then
  1429. If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Monto").Value)) Then
  1430. dgvReportos.Rows(Index).Cells("Monto").Value = 0
  1431. End If
  1432. If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value)) Then
  1433. dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value = Date.Now.Date
  1434. End If
  1435. If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Costos Financieros").Value)) Then
  1436. dgvReportos.Rows(Index).Cells("Costos Financieros").Value = 0
  1437. End If
  1438. If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Intereses").Value)) Then
  1439. dgvReportos.Rows(Index).Cells("Intereses").Value = 0
  1440. End If
  1441. If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Casa").Value)) Then
  1442. dgvReportos.Rows(Index).Cells("Casa").Value = 0
  1443. End If
  1444. If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Bolsa").Value)) Then
  1445. dgvReportos.Rows(Index).Cells("Bolsa").Value = 0
  1446. End If
  1447. If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Total a Pagar").Value)) Then
  1448. dgvReportos.Rows(Index).Cells("Total a Pagar").Value = 0
  1449. End If
  1450. If (String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Codigo").Value)) Then
  1451. dgvReportos.Rows(Index).Cells("Codigo").Value = Correlativo()
  1452. End If
  1453. 'End If
  1454. End Sub
  1455. Function CalcularFechaVencimiento(ByVal Index As Integer)
  1456. Dim Dias = 0, FechaVenta = Date.Now.Date, FechaVencimiento = Date.Now.Date
  1457. IngresarDatos()
  1458. If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("FCompra").Value)) Then
  1459. FechaVenta = dgvReportos.Rows(Index).Cells("FCompra").Value
  1460. End If
  1461. If (Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value)) Then
  1462. Dias = dgvReportos.Rows(Index).Cells("Dias").Value
  1463. End If
  1464. FechaVencimiento = FechaVenta.AddDays(Dias)
  1465. Return FechaVencimiento
  1466. End Function
  1467. Function CalcularFechaVenta(ByVal Index As Integer, ByVal IndexAnterior As Integer)
  1468. Dim FechaVenta As Date
  1469. If (Not Index = 0) Then
  1470. IndexAnterior = Index - 1
  1471. Dim FVencimiento = dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString
  1472. If (String.IsNullOrEmpty(FVencimiento)) Then
  1473. FechaVenta = Date.Now.Date
  1474. Else
  1475. FechaVenta = FVencimiento
  1476. End If
  1477. Else
  1478. FechaVenta = Date.Now.Date
  1479. End If
  1480. Return FechaVenta
  1481. End Function
  1482. Sub Calculos()
  1483. If Variables.Codigo.IndexOf("REPO") > -1 Or Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  1484. Dim Cantidad As Integer = dgvReportos.Rows.Count - 2
  1485. Dim Index As Integer = 0
  1486. While Index <= Cantidad
  1487. Dim FCompra As Date
  1488. Dim VComisionCasa As Double = 0
  1489. Dim VComisionBolsa As Double = 0
  1490. FCompra = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString)
  1491. VComisionCasa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionCasa").Value.ToString)
  1492. VComisionBolsa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionBolsa").Value.ToString)
  1493. FechaVen(FCompra, Index)
  1494. ComisionCasa(VComisionCasa, Index)
  1495. ComisionBolsa(VComisionBolsa, Index)
  1496. IOF(Index)
  1497. TotalCostos(Index)
  1498. MontoLiquidacion(Index)
  1499. InteresGenerar(Index)
  1500. RendimientoAntes(Index)
  1501. ValorRecompra(Index)
  1502. Renta(Index)
  1503. IngresoNeto(Index)
  1504. ValorNeto(Index)
  1505. RendimientoDespues(Index)
  1506. Index += 1
  1507. End While
  1508. Else
  1509. 'PrepararRepoVentas()
  1510. End If
  1511. End Sub
  1512. Sub NuevaFila()
  1513. If Variables.Codigo.IndexOf("REPO") > -1 Or Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  1514. Dim i As Integer = dgvReportos.CurrentRow.Index
  1515. Dim IndexAnterior As Integer = dgvReportos.CurrentRow.Index - 1
  1516. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Codigo").Value)) Then
  1517. dgvReportos.Rows(i).Cells("Codigo").Value = Correlativo()
  1518. End If
  1519. If Not i = 0 Then
  1520. If (Not String.IsNullOrEmpty(dgvReportos.Rows(IndexAnterior).Cells("EstadoIOF").Value)) Then
  1521. dgvReportos.Rows(i).Cells("EstadoIOF").Value = dgvReportos.Rows(IndexAnterior).Cells("EstadoIOF").Value
  1522. Else
  1523. dgvReportos.Rows(i).Cells("EstadoIOF").Value = 0
  1524. End If
  1525. If (Not String.IsNullOrEmpty(dgvReportos.Rows(IndexAnterior).Cells("EstadoRenta").Value)) Then
  1526. dgvReportos.Rows(i).Cells("EstadoRenta").Value = dgvReportos.Rows(IndexAnterior).Cells("EstadoRenta").Value
  1527. Else
  1528. dgvReportos.Rows(IndexAnterior).Cells("EstadoRenta").Value = 0
  1529. End If
  1530. End If
  1531. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Valor Trasado").Value)) Then
  1532. dgvReportos.Rows(i).Cells("Valor Trasado").Value = 0
  1533. End If
  1534. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Dias").Value)) Then
  1535. dgvReportos.Rows(i).Cells("Dias").Value = 0
  1536. End If
  1537. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Fecha de Vencimiento").Value)) Then
  1538. Dim FechaVenc As String = Format(Date.Now.Date, "dd/MM/yyyy")
  1539. dgvReportos.Rows(i).Cells("Fecha de Vencimiento").Value = FechaVenc
  1540. End If
  1541. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Rendimiento").Value)) Then
  1542. dgvReportos.Rows(i).Cells("Rendimiento").Value = 0
  1543. End If
  1544. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("IOF").Value)) Then
  1545. dgvReportos.Rows(i).Cells("IOF").Value = 0
  1546. End If
  1547. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Comision CB").Value)) Then
  1548. dgvReportos.Rows(i).Cells("Comision CB").Value = 0
  1549. End If
  1550. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Comision Bolsa").Value)) Then
  1551. dgvReportos.Rows(i).Cells("Comision Bolsa").Value = 0
  1552. End If
  1553. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Otros Costos").Value)) Then
  1554. dgvReportos.Rows(i).Cells("Otros Costos").Value = 0
  1555. End If
  1556. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Total Costos").Value)) Then
  1557. dgvReportos.Rows(i).Cells("Total Costos").Value = 0
  1558. End If
  1559. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Monto a Liquidar").Value)) Then
  1560. dgvReportos.Rows(i).Cells("Monto a Liquidar").Value = 0
  1561. End If
  1562. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Interes a Genrerar").Value)) Then
  1563. dgvReportos.Rows(i).Cells("Interes a Genrerar").Value = 0
  1564. End If
  1565. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Costo de Transferencia").Value)) Then
  1566. dgvReportos.Rows(i).Cells("Costo de Transferencia").Value = 0
  1567. End If
  1568. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("R% Neto (Antes de Impuesto)").Value)) Then
  1569. dgvReportos.Rows(i).Cells("R% Neto (Antes de Impuesto)").Value = 0
  1570. End If
  1571. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Valor de ReCompra").Value)) Then
  1572. dgvReportos.Rows(i).Cells("Valor de ReCompra").Value = 0
  1573. End If
  1574. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Impuesto de Liquidacion").Value)) Then
  1575. dgvReportos.Rows(i).Cells("Impuesto de Liquidacion").Value = 0
  1576. End If
  1577. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Ingreso Neto").Value)) Then
  1578. dgvReportos.Rows(i).Cells("Ingreso Neto").Value = 0
  1579. End If
  1580. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Valor Neto").Value)) Then
  1581. dgvReportos.Rows(i).Cells("Valor Neto").Value = 0
  1582. End If
  1583. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("R% Neto (Despues de Impuesto)").Value)) Then
  1584. dgvReportos.Rows(i).Cells("R% Neto (Despues de Impuesto)").Value = 0
  1585. End If
  1586. End If
  1587. End Sub
  1588. Sub QuitarFila()
  1589. Dim result As Integer = MsgBox("¿Está seguro que desea eliminar la fila?", MsgBoxStyle.OkCancel)
  1590. ' Test result.
  1591. Dim codigo As String = Variables.Codigo
  1592. Dim Numero As Integer = dgvReportos.CurrentRow.Cells("codigo").Value
  1593. If result = MsgBoxResult.Ok Then
  1594. Try
  1595. dgvReportos.Rows.Remove(dgvReportos.CurrentRow)
  1596. ReportoConsula.Eliminar(codigo, Numero, Tabla)
  1597. Catch ex As Exception
  1598. MsgBox("No ha seleccionado una fila")
  1599. End Try
  1600. End If
  1601. End Sub
  1602. Sub FechaVen(ByVal FCompra As Date, ByVal Index As Integer)
  1603. Dim FechaCompra As Date = FCompra
  1604. Dim Dias As Integer = 0
  1605. Dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString)
  1606. dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value = CStr(Format(Reporto.FechaDeVencimiento(FechaCompra, Dias), "dd/MM/yyyy"))
  1607. End Sub
  1608. Function FechaVenCargar(ByVal Index As Integer)
  1609. Dim FechaCompra As Date = dtpFechaCompra.Value
  1610. Dim Dias As Integer = 0
  1611. If Not String.IsNullOrEmpty(dgvReportos.Rows(Index).Cells("Dias").Value) Then
  1612. Dias = dgvReportos.Rows(Index).Cells("Dias").Value
  1613. End If
  1614. Dim FechaVencimiento = CStr(Format(Reporto.FechaDeVencimiento(FechaCompra, Dias), "dd/MM/yyyy"))
  1615. dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value = FechaVencimiento
  1616. Return FechaVencimiento
  1617. End Function
  1618. Sub CorrelativoSinBD()
  1619. Dim Index As Integer = 0
  1620. Dim IndexCantidad As Integer = dgvReportos.Rows.Count - 2
  1621. Dim NumeroMayor As Integer = 0
  1622. While Index <= IndexCantidad
  1623. dgvReportos.Rows(Index).Cells("Correlativo").Value = Index + 1
  1624. Index += 1
  1625. End While
  1626. End Sub
  1627. Function Correlativo()
  1628. Dim Index As Integer = 0
  1629. Dim IndexCantidad As Integer = dgvReportos.Rows.Count - 2
  1630. Dim NumeroMayor As Integer = 0
  1631. While Index <= IndexCantidad
  1632. Dim Numero As Integer = dgvReportos.Rows(Index).Cells("codigo").Value
  1633. If Numero > NumeroMayor Then
  1634. NumeroMayor = Numero
  1635. End If
  1636. Index += 1
  1637. End While
  1638. Return NumeroMayor + 1
  1639. End Function
  1640. Sub CargarReporto(ByVal Tabla As String)
  1641. Dim ConvertirString As String
  1642. Dim Activo = 0.0, ActivoRenta = 0.0
  1643. Dim EstadoIOF, EstadoRenta
  1644. Dim dr = ReportoConsula.CargarReporto(Codigo, Tabla)
  1645. If Tabla = "REP0" Or Tabla = "REP0VENTA" Then
  1646. If (Not dr Is Nothing) Then
  1647. While dr.Read
  1648. If dr("EstadoIOF") Then
  1649. EstadoIOF = 1
  1650. ChkIOF.Checked = True
  1651. Else
  1652. EstadoIOF = 0
  1653. ChkIOF.Checked = False
  1654. End If
  1655. If dr("EstadoRenta") Then
  1656. EstadoRenta = 1
  1657. ChkRenta.Checked = True
  1658. Else
  1659. EstadoRenta = 0
  1660. ChkRenta.Checked = False
  1661. End If
  1662. Dim FechaVencimiento As Date = dr("FCompra")
  1663. Dim Dias As Integer = dr("Dias")
  1664. FechaVencimiento = FechaVencimiento.AddDays(Dias)
  1665. ConvertirString = Format(FechaVencimiento, "dd/MM/yyyy")
  1666. dtpFechaCompra.Value = dr("FCompra")
  1667. If (dr("IOF")) Then
  1668. Activo = 1
  1669. Else
  1670. Activo = 0
  1671. End If
  1672. If (dr("Renta")) Then
  1673. ActivoRenta = 1
  1674. Else
  1675. ActivoRenta = 0
  1676. End If
  1677. Dim ComisionCasa As Double = 0
  1678. Dim ComisionBolsa As Double = 0
  1679. If Not String.IsNullOrEmpty(dr("ComisionCasa").ToString) Then
  1680. ComisionCasa = dr("ComisionCasa")
  1681. End If
  1682. If Not String.IsNullOrEmpty(dr("ComisionBolsa").ToString) Then
  1683. ComisionBolsa = dr("ComisionBolsa")
  1684. End If
  1685. If Tabla = "REP0VENTA" Then
  1686. dgvReportos.Rows.Add("", dr("ValTrans"), dr("Dias"), ConvertirString, (dr("Rend")), 0, 0, 0, 0, 0, 0, 0, 0, 0, dr("CostoTransfr"), ActivoRenta, "", "", "", dr("Nombre"), dr("FCompra"), ComisionCasa, ComisionBolsa, dr("Casa"), dr("codigo"), "", EstadoIOF, EstadoRenta)
  1687. End If
  1688. End While
  1689. End If
  1690. Else
  1691. 'If (Not dr Is Nothing) Then
  1692. ' While dr.Read
  1693. ' Dim Monto As Double = 0
  1694. ' Dim FVenc As Date = Date.Now.Date
  1695. ' Dim CostFinanciero As Double = 0
  1696. ' Dim Nombre As String = String.Empty
  1697. ' Dim FCompra As Date = Date.Now.Date
  1698. ' Dim ComisionCasa As Double = 0
  1699. ' Dim ComisionBolsa As Double = 0
  1700. ' Dim Dias As Integer =0
  1701. ' Dim codigo As Integer = 0
  1702. ' Dim Casa2 As String = String.Empty
  1703. ' If (Not String.IsNullOrEmpty(dr("Monto").ToString)) Then
  1704. ' Monto = dr("Monto")
  1705. ' End If
  1706. ' If (Not String.IsNullOrEmpty(dr("FVenc").ToString)) Then
  1707. ' FVenc = dr("FVenc")
  1708. ' End If
  1709. ' If (Not String.IsNullOrEmpty(dr("CostoFinanciero").ToString)) Then
  1710. ' CostFinanciero = dr("CostoFinanciero")
  1711. ' End If
  1712. ' If (Not String.IsNullOrEmpty(dr("Nombre").ToString)) Then
  1713. ' Nombre = dr("Nombre")
  1714. ' End If
  1715. ' If (Not String.IsNullOrEmpty(dr("FCompra").ToString)) Then
  1716. ' FCompra = dr("FCompra")
  1717. ' End If
  1718. ' If (Not String.IsNullOrEmpty(dr("ComisionCasa").ToString)) Then
  1719. ' ComisionCasa = dr("ComisionCasa")
  1720. ' End If
  1721. ' If (Not String.IsNullOrEmpty(dr("ComisionBolsa").ToString)) Then
  1722. ' ComisionBolsa = dr("ComisionBolsa")
  1723. ' End If
  1724. ' If (Not String.IsNullOrEmpty(dr("Dias").ToString)) Then
  1725. ' Dias = dr("Dias")
  1726. ' End If
  1727. ' If (Not String.IsNullOrEmpty(dr("codigo").ToString)) Then
  1728. ' codigo = dr("codigo")
  1729. ' End If
  1730. ' If (Not String.IsNullOrEmpty(dr("Casa2").ToString)) Then
  1731. ' Casa2 = dr("Casa2")
  1732. ' End If
  1733. ' 'cboAnioBase.SelectedIndex = dr("Base")
  1734. ' Dim FechaVenFiltro As String = Format(FVenc, "dd/MM/yyyy")
  1735. ' dgvReportos.Rows.Add("", Monto, FechaVenFiltro, CostFinanciero, 0, 0, 0, 0, Nombre, FCompra, ComisionCasa, ComisionBolsa, Casa2, Dias, codigo)
  1736. ' End While
  1737. 'End If
  1738. End If
  1739. End Sub
  1740. Function ObtenerDatos(ByVal Index As Integer)
  1741. Dim coleccion As New Collection
  1742. Dim Renta, IOF, Nombre, FCompra, ValTrans, Dias, FVenc, Rend, CostoTransfr, codigo, ComisionCasa, ComisionBolsa, Casa, Casa2
  1743. Dim EstadoIOF, EstadoRenta
  1744. If Variables.Codigo.IndexOf("REPO") > -1 Or Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  1745. Dim ComisionCasaValor, ComisionBolsaValor, IOFValor, OtrosCostos, TotalCostos, MontoLiq
  1746. Dim IntGenerar, RendAntImp, RendDesImp, ImpLiq, IngrNet, ValorNet
  1747. ValorNet = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Neto").Value.ToString)
  1748. IngrNet = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Ingreso Neto").Value.ToString)
  1749. ImpLiq = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value)
  1750. RendDesImp = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("R% Neto (Despues de Impuesto)").Value)
  1751. RendAntImp = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("R% Neto (Antes de Impuesto)").Value)
  1752. IntGenerar = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value)
  1753. MontoLiq = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Monto a Liquidar").Value)
  1754. TotalCostos = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Total Costos").Value)
  1755. OtrosCostos = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Otros Costos").Value)
  1756. IOFValor = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("IOF").Value)
  1757. ComisionBolsaValor = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision Bolsa").Value)
  1758. ComisionCasaValor = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision CB").Value)
  1759. Nombre = dgvReportos.Rows(Index).Cells("Nombre").Value.ToString
  1760. FCompra = Operaciones.ConvertirFechaBaseDatos(dgvReportos.Rows(Index).Cells("FCompra").Value)
  1761. ValTrans = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value)
  1762. Dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value)
  1763. FVenc = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value)
  1764. Rend = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Rendimiento").Value)
  1765. CostoTransfr = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Costo de Transferencia").Value)
  1766. codigo = dgvReportos.Rows(Index).Cells("Codigo").Value.ToString
  1767. ComisionCasa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionCasa").Value)
  1768. ComisionBolsa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionBolsa").Value)
  1769. Casa = dgvReportos.Rows(Index).Cells("Casa").Value.ToString
  1770. If (Not dgvReportos.Rows(Index).Cells("IOF").Value = 0) Then
  1771. IOF = 1
  1772. Else
  1773. IOF = 0
  1774. End If
  1775. If (Not dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value = 0) Then
  1776. Renta = 1
  1777. Else
  1778. Renta = 0
  1779. End If
  1780. If (dgvReportos.Rows(Index).Cells("EstadoIOF").Value = 1) Then
  1781. EstadoIOF = 1
  1782. Else
  1783. EstadoIOF = 0
  1784. End If
  1785. If (dgvReportos.Rows(Index).Cells("EstadoRenta").Value = 1) Then
  1786. EstadoRenta = 1
  1787. Else
  1788. EstadoRenta = 0
  1789. End If
  1790. coleccion.Add(Nombre)
  1791. coleccion.Add(CDate(FCompra))
  1792. coleccion.Add(CDec(ValTrans))
  1793. coleccion.Add(CInt(Dias))
  1794. coleccion.Add(CDate(FVenc))
  1795. coleccion.Add(CDec(Rend))
  1796. coleccion.Add(CDec(CostoTransfr))
  1797. coleccion.Add(codigo)
  1798. coleccion.Add(ComisionCasa)
  1799. coleccion.Add(ComisionBolsa)
  1800. coleccion.Add(Casa)
  1801. coleccion.Add(IOF)
  1802. coleccion.Add(Renta)
  1803. coleccion.Add(Base)
  1804. coleccion.Add(ComisionCasaValor)
  1805. coleccion.Add(ComisionBolsaValor)
  1806. coleccion.Add(IOFValor)
  1807. coleccion.Add(OtrosCostos)
  1808. coleccion.Add(TotalCostos)
  1809. coleccion.Add(MontoLiq)
  1810. coleccion.Add(IntGenerar)
  1811. coleccion.Add(RendAntImp)
  1812. coleccion.Add(RendDesImp)
  1813. coleccion.Add(ImpLiq)
  1814. coleccion.Add(IngrNet)
  1815. coleccion.Add(ValorNet)
  1816. coleccion.Add(EstadoIOF)
  1817. coleccion.Add(EstadoRenta)
  1818. End If
  1819. Return coleccion
  1820. End Function
  1821. 'GETS
  1822. Function GetFechaCompra() As Date
  1823. Dim valor As Date
  1824. valor = dtpFechaCompra.Value
  1825. Return valor
  1826. End Function
  1827. Private Sub dgvReportos_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvReportos.CellEndEdit
  1828. 'If (InStr(Variables.Codigo, "REPOVENTA") > 0) Then
  1829. ' RellenarDatos()
  1830. 'End If
  1831. CorrelativoSinBD()
  1832. Correlativo()
  1833. Calculos()
  1834. End Sub
  1835. Private Sub dtpFechaCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaCompra.ValueChanged
  1836. Formato()
  1837. IngresarDatos()
  1838. If Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  1839. End If
  1840. Modificado = True
  1841. Calculos()
  1842. End Sub
  1843. Private Sub dgvReportos_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvReportos.CellClick
  1844. IOFRentaEstado()
  1845. IngresarDatosReves()
  1846. NuevaFila()
  1847. If Variables.Codigo.IndexOf("REPO") > -1 Or Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  1848. Dim Index = dgvReportos.CurrentRow.Cells("codigo").Value
  1849. CargarFecha()
  1850. RotarValores(Index)
  1851. Calculos()
  1852. 'AgregarCheckbox()
  1853. 'CalcularCheckbox()
  1854. 'ElseIf (InStr(Variables.Codigo, "REPOVENTA") > 0) Then
  1855. ' RellenarDatos()
  1856. ' PrepararRepoVentas()
  1857. End If
  1858. Formato()
  1859. End Sub
  1860. Private Sub dgvReportos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvReportos.CellContentClick
  1861. End Sub
  1862. Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click
  1863. End Sub
  1864. Private Sub txtCodigoTitulo_TextChanged(sender As Object, e As EventArgs) Handles txtCodigoTitulo.TextChanged
  1865. Modificado = True
  1866. End Sub
  1867. Private Sub txtIOF_TextChanged(sender As Object, e As EventArgs)
  1868. End Sub
  1869. Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
  1870. btnAccion.Text = "Modificar"
  1871. 'btnAgregarImpuesto.Text = "Modificar"
  1872. Estado = "M"
  1873. End Sub
  1874. Sub NuevoIngreso(ByVal AgregarModificar As Boolean, ByVal Cantidad As Integer, ByVal Tabla As String)
  1875. Dim i As Integer = 0
  1876. Dim Index = dgvReportos.Rows.Count - 2
  1877. i = Cantidad
  1878. While i <= Index
  1879. Dim coleccion = ObtenerDatos(i)
  1880. If ReportoConsula.Nuevo(coleccion, Codigo, Tabla) Is Nothing Then
  1881. Exit Sub
  1882. End If
  1883. i += 1
  1884. End While
  1885. MsgBox("Reportos actualizados")
  1886. End Sub
  1887. Function NuevoIngresoColeccion()
  1888. Dim i As Integer = 0
  1889. Dim Index = dgvReportos.Rows.Count - 2
  1890. Dim diccionario As New Dictionary(Of String, Collection)
  1891. While i <= Index
  1892. Dim coleccion = ObtenerDatos(i)
  1893. diccionario.Add(i, coleccion)
  1894. i += 1
  1895. End While
  1896. Return diccionario
  1897. End Function
  1898. Function CanRegistros(ByVal Tabla As String)
  1899. Dim Codigo = Variables.Codigo
  1900. Dim Cantidad As Integer = oDAOGeneral.CantidadRegistros(Codigo, Tabla)
  1901. Return Cantidad
  1902. End Function
  1903. Sub ModificarIngreso()
  1904. Dim i As Integer = 0
  1905. Dim CantidadRegistrosDB = CanRegistros(Tabla)
  1906. While i < CantidadRegistrosDB
  1907. Dim coleccion = ObtenerDatos(i)
  1908. If ReportoConsula.Modificar(coleccion, Codigo, Tabla) Is Nothing Then
  1909. Exit Sub
  1910. End If
  1911. i += 1
  1912. End While
  1913. NuevoIngreso(True, CantidadRegistrosDB, Tabla)
  1914. End Sub
  1915. Private Sub btnAccion_Click(sender As Object, e As EventArgs) Handles btnAccion.Click
  1916. LlenarBase()
  1917. Dim Codigo = Variables.Codigo
  1918. Dim diccionario As Dictionary(Of String, Collection) = NuevoIngresoColeccion()
  1919. If (Estado = "N") Then
  1920. ReportoConsula.ProcesoDatos(diccionario, Codigo, Tabla)
  1921. 'ModificarIngreso()
  1922. ValidarExistencia()
  1923. ElseIf Not ExisteValidacion() Then
  1924. Variables.ColeccionREPO = diccionario
  1925. Me.Close()
  1926. ElseIf (Estado = "M") Then
  1927. 'ModificarIngreso()
  1928. ReportoConsula.ProcesoDatos(diccionario, Codigo, Tabla)
  1929. ValidarExistencia()
  1930. ElseIf (Estado = "B") Then
  1931. QuitarFila()
  1932. ValidarExistencia()
  1933. End If
  1934. End Sub
  1935. Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
  1936. btnAccion.Text = "Agregar"
  1937. 'btnAgregarImpuesto.Text = "Agregar"
  1938. Estado = "N"
  1939. End Sub
  1940. Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
  1941. btnAccion.Text = "Eliminar"
  1942. ' btnAgregarImpuesto.Text = "Eliminar"
  1943. Estado = "B"
  1944. End Sub
  1945. Private Sub Button1_Click(sender As Object, e As EventArgs)
  1946. End Sub
  1947. Sub GuardarImpuesto()
  1948. ' Dim Impuesto = dgvImpuestos.CurrentRow.Cells(0).Value
  1949. ' Dim CodigoInv = Variables.Codigo
  1950. ' Dim codigo = dgvImpuestos.CurrentRow.Cells(1).Value
  1951. ' Dim ValorImpuesto = ReportoConsula.TraerImpuesto(Impuesto)
  1952. ' Dim Valor = ReportoConsula.AgregarImpuesto(CodigoInv, codigo, Impuesto, 0)
  1953. ' ActualizarImpuestos(Valor)
  1954. End Sub
  1955. Private Sub btnAgregarImpuesto_Click(sender As Object, e As EventArgs)
  1956. GuardarImpuesto()
  1957. End Sub
  1958. Private Sub dgvImpuestos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
  1959. End Sub
  1960. Private Sub TabPage3_Click(sender As Object, e As EventArgs) Handles TbImpuestos.Click
  1961. End Sub
  1962. Private Sub dgvImpuestoAgregado_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
  1963. End Sub
  1964. Private Sub btnQuitar_Click(sender As Object, e As EventArgs)
  1965. ModificarImpuestos()
  1966. End Sub
  1967. Sub ModificarImpuestos()
  1968. 'Dim Index As Integer = dgvImpuestoAgregado.CurrentRow.Index
  1969. 'Dim Cantidad As Integer = dgvImpuestoAgregado.Rows.Count - 1
  1970. 'Dim Cadena As String = String.Empty
  1971. 'Dim IsNothing As Boolean = False
  1972. 'Dim Codigo
  1973. 'Cadena = dgvImpuestoAgregado.CurrentRow.Cells(0).Value
  1974. 'Codigo = dgvImpuestoAgregado.CurrentRow.Cells(1).Value
  1975. 'If (String.IsNullOrEmpty(Cadena) Or String.IsNullOrEmpty(Codigo)) Then
  1976. 'MsgBox("No se puede quitar una cadena vacía")
  1977. 'Else
  1978. 'ModificarImpu(Cadena, Codigo)
  1979. 'End If
  1980. End Sub
  1981. Sub ModificarImpu(ByVal Impuesto As String, ByVal Codigo As Integer)
  1982. Dim CodigoInv = Variables.Codigo
  1983. 'Dim ValorImpuesto = ReportoConsula.TraerImpuesto(Impuesto)
  1984. Dim Valor = ReportoConsula.AgregarImpuesto(CodigoInv, Codigo, Impuesto, 1)
  1985. ActualizarImpuestos(Valor)
  1986. 'ActualizarImpuestos(Valor)
  1987. 'RefrescarValorControles()
  1988. End Sub
  1989. Private Sub FlpIOF_Click(sender As Object, e As EventArgs) Handles FlpIOF.Click
  1990. End Sub
  1991. Private Sub FlpIOF_MouseClick(sender As Object, e As MouseEventArgs) Handles FlpIOF.MouseClick
  1992. End Sub
  1993. Private Sub FlpIOF_ChangeUICues(sender As Object, e As UICuesEventArgs) Handles FlpIOF.ChangeUICues
  1994. End Sub
  1995. Private Sub FlpIOF_Paint(sender As Object, e As PaintEventArgs) Handles FlpIOF.Paint
  1996. End Sub
  1997. Private Sub txtComisionCasa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionCasa.KeyPress
  1998. If String.IsNullOrEmpty(txtComisionCasa.Text.ToString.Trim("%")) Then
  1999. If e.KeyChar = "." Then
  2000. txtComisionCasa.Text = "0.0%"
  2001. Exit Sub
  2002. End If
  2003. End If
  2004. If (Not txtComisionCasa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  2005. Operaciones.ValidarEntrada(sender, e, True)
  2006. Else
  2007. Operaciones.ValidarEntrada(sender, e, False)
  2008. End If
  2009. End Sub
  2010. Private Sub txtComisionBolsa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionBolsa.KeyPress
  2011. If String.IsNullOrEmpty(txtComisionBolsa.Text.ToString.Trim("%")) Then
  2012. If e.KeyChar = "." Then
  2013. txtComisionBolsa.Text = "0.2825%"
  2014. Exit Sub
  2015. End If
  2016. End If
  2017. If (Not txtComisionBolsa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  2018. Operaciones.ValidarEntrada(sender, e, True)
  2019. Else
  2020. Operaciones.ValidarEntrada(sender, e, False)
  2021. End If
  2022. End Sub
  2023. Private Sub BindingNavigator1_RefreshItems(sender As Object, e As EventArgs) Handles BindingNavigator1.RefreshItems
  2024. End Sub
  2025. Private Sub txtComisionCasa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionCasa.TextChanged
  2026. IngresarDatos()
  2027. Modificado = True
  2028. Calculos()
  2029. End Sub
  2030. Private Sub txtComisionBolsa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionBolsa.TextChanged
  2031. IngresarDatos()
  2032. If (InstrumentoFinanciero = "REPOVENTA") Then
  2033. End If
  2034. Modificado = True
  2035. Calculos()
  2036. End Sub
  2037. Private Sub txtDias_TextChanged(sender As Object, e As EventArgs) Handles txtDias.TextChanged
  2038. IngresarDatos()
  2039. If (InstrumentoFinanciero = "REPOVENTA") Then
  2040. End If
  2041. Modificado = True
  2042. Calculos()
  2043. End Sub
  2044. Private Sub cboCasaCorredora_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboCasaCorredora.SelectedIndexChanged
  2045. Modificado = True
  2046. IngresarDatos()
  2047. End Sub
  2048. Private Sub txtCodigoTitulo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtCodigoTitulo.KeyPress
  2049. End Sub
  2050. Private Sub txtDias_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtDias.KeyPress
  2051. If String.IsNullOrEmpty(txtDias.Text) Then
  2052. If e.KeyChar = "." Then
  2053. txtDias.Text = "0"
  2054. Exit Sub
  2055. End If
  2056. End If
  2057. If (Not txtDias.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  2058. Operaciones.ValidarEntrada(sender, e, True)
  2059. Else
  2060. Operaciones.ValidarEntrada(sender, e, False)
  2061. End If
  2062. End Sub
  2063. Private Sub txtCodigoTitulo_KeyUp(sender As Object, e As KeyEventArgs) Handles txtCodigoTitulo.KeyUp
  2064. IngresarDatos()
  2065. End Sub
  2066. Private Sub txtComisionCasa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionCasa.KeyUp
  2067. If txtComisionCasa.Text = "." Then
  2068. txtComisionCasa.Text = ".0%"
  2069. End If
  2070. IngresarDatos()
  2071. Calculos()
  2072. End Sub
  2073. Private Sub txtComisionBolsa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionBolsa.KeyUp
  2074. If txtComisionBolsa.Text = "." Then
  2075. txtComisionBolsa.Text = ".0%"
  2076. End If
  2077. IngresarDatos()
  2078. Calculos()
  2079. End Sub
  2080. Sub ValidarExistencia()
  2081. Dim General As New DAOGeneral
  2082. Dim Codigo As String = Variables.Codigo
  2083. Dim Tabla As String = String.Empty
  2084. If Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  2085. Tabla = "REP0VENTA"
  2086. ElseIf Variables.Codigo.IndexOf("REPO") > -1 Then
  2087. Tabla = "REP0"
  2088. End If
  2089. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  2090. If (Existe) Then
  2091. navNuevo.Enabled = False
  2092. navModificar.Enabled = True
  2093. navEliminar.Enabled = True
  2094. Else
  2095. navNuevo.Enabled = True
  2096. navModificar.Enabled = False
  2097. navEliminar.Enabled = False
  2098. End If
  2099. Estado = String.Empty
  2100. btnAccion.Text = "Aceptar"
  2101. End Sub
  2102. Function ExisteValidacion()
  2103. Dim General As New DAOGeneral
  2104. Dim Codigo As String = Variables.Codigo
  2105. Dim Tabla As String = String.Empty
  2106. If Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  2107. Tabla = "REP0VENTA"
  2108. ElseIf Variables.Codigo.IndexOf("REPO") > -1 Then
  2109. Tabla = "REP0"
  2110. End If
  2111. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  2112. Return Existe
  2113. End Function
  2114. Private Sub btnGuardar_Click(sender As Object, e As EventArgs)
  2115. End Sub
  2116. Private Sub dgvReportos_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) Handles dgvReportos.CellBeginEdit
  2117. CorrelativoSinBD()
  2118. Correlativo()
  2119. End Sub
  2120. Private Sub txtDias_KeyUp(sender As Object, e As KeyEventArgs) Handles txtDias.KeyUp
  2121. If txtDias.Text = "." Then
  2122. txtDias.Text = ".0"
  2123. End If
  2124. IngresarDatos()
  2125. Calculos()
  2126. End Sub
  2127. Private Sub cboAnioBase_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboAnioBase.SelectedIndexChanged
  2128. LlenarBase()
  2129. IngresarDatos()
  2130. If (InstrumentoFinanciero = "REPOVENTA") Then
  2131. End If
  2132. Modificado = True
  2133. Calculos()
  2134. End Sub
  2135. Private Sub txtDias_Leave(sender As Object, e As EventArgs) Handles txtDias.Leave
  2136. RellenarTxt()
  2137. Formato()
  2138. End Sub
  2139. Private Sub txtComisionCasa_Leave(sender As Object, e As EventArgs) Handles txtComisionCasa.Leave
  2140. Formato()
  2141. End Sub
  2142. Private Sub txtComisionBolsa_Leave(sender As Object, e As EventArgs) Handles txtComisionBolsa.Leave
  2143. Formato()
  2144. End Sub
  2145. Private Sub frmReporto_Resize(sender As Object, e As EventArgs) Handles MyBase.Resize
  2146. dgvReportos.Width = Me.Width - 10
  2147. dgvReportos.Height = Me.Height - 290
  2148. End Sub
  2149. Private Sub ChkIOF_CheckedChanged(sender As Object, e As EventArgs) Handles ChkIOF.CheckedChanged
  2150. IOFRentaEstado()
  2151. Modificado = True
  2152. IngresarDatos()
  2153. Calculos()
  2154. End Sub
  2155. Private Sub ChkRenta_CheckedChanged(sender As Object, e As EventArgs) Handles ChkRenta.CheckedChanged
  2156. IOFRentaEstado()
  2157. Modificado = True
  2158. IngresarDatos()
  2159. Calculos()
  2160. End Sub
  2161. Private Sub txtCodigoInstrumento_TextChanged(sender As Object, e As EventArgs) Handles txtCodigoInstrumento.TextChanged
  2162. IngresarDatos()
  2163. Modificado = True
  2164. Calculos()
  2165. End Sub
  2166. Sub SeleccionarInstrumento()
  2167. Dim frmInstrumentos As New frmSeleccionTitulosReportos
  2168. frmInstrumentos.Show()
  2169. End Sub
  2170. Private Sub btnSaldoDisponible_Click(sender As Object, e As EventArgs)
  2171. SeleccionarInstrumento()
  2172. End Sub
  2173. Private Sub btnRequisicion_Click(sender As Object, e As EventArgs)
  2174. End Sub
  2175. Sub CargarTransladoNuevo()
  2176. Dim Existe As Boolean = ExisteInversion()
  2177. If Not RetCodigoInversionExiste And Not Existe Then
  2178. If dgvReportos.Rows(0).Cells("Valor Trasado").Value = 0 Then
  2179. dgvReportos.Rows(0).Cells("Valor Trasado").Value = Variables.RetMonto
  2180. End If
  2181. End If
  2182. End Sub
  2183. End Class