frmReporto.vb 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405
  1. Public Class frmReporto
  2. Dim oDAOGeneral As New DAOGeneral
  3. Const PorcentajeComisionCasa As Double = 0.2825
  4. Const PorcentajeComisionBolsa As Double = 0.2825
  5. Dim oCEReporto As ReportosCE
  6. Dim oDAOReportos As ReportosDAO
  7. Dim Reporto As New ReportosCE
  8. Dim ReportoConsula As New ReportosDAO
  9. Dim Estado As String = String.Empty
  10. Dim CargarUnaVez As Boolean = True
  11. Dim Operaciones As New Operaciones
  12. Dim Modificado As Boolean = False
  13. Dim InstrumentoFinanciero As String = oDAOGeneral.ObtenerInstrumento(Variables.Codigo)
  14. Dim CodigoRotar As Integer = 0
  15. Private _Modo As String
  16. Private Cargado As Boolean = False
  17. Private Procesado As Boolean = False
  18. Private Tabla As String = String.Empty
  19. Private Base As Integer = 0
  20. Private CodigoProveniente As String = String.Empty
  21. Sub New()
  22. ' Esta llamada es exigida por el diseñador.
  23. InitializeComponent()
  24. ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
  25. End Sub
  26. Public Property Modo As String
  27. Get
  28. Return _Modo
  29. End Get
  30. Set(value As String)
  31. _Modo = value
  32. End Set
  33. End Property
  34. Sub AgregarCampos(ByVal Tipo As Integer)
  35. Dim ValTrans, Dias, FVen, Rend, IOF, ComisionCB, CB, OtrosCostos, TotCostos, MontoLiq, InterGen, codigo As New DataGridViewTextBoxColumn
  36. Dim CostoTransfv, Correlativo, RendNetoAntImp, ValReCompra, ImpLiquidacion, IngrNeto, ValNeto, RendNetoDespImp As New DataGridViewTextBoxColumn
  37. Dim Nombre, FCompra, ComisionCasa, ComisionBolsa, Casa, Base, EstadoIOF, EstadoRenta As New DataGridViewTextBoxColumn
  38. Dim Cantidad As Integer = dgvReportos.ColumnCount
  39. If Cantidad = 0 Then
  40. Correlativo.Name = "Correlativo"
  41. codigo.Name = "Codigo"
  42. codigo.Visible = False
  43. ValTrans.Name = "Valor Trasado"
  44. Dias.Name = "Dias"
  45. FVen.Name = "Fecha de Vencimiento"
  46. Rend.Name = "Rendimiento"
  47. IOF.Name = "IOF"
  48. ComisionCB.Name = "Comision CB"
  49. CB.Name = "Comision Bolsa"
  50. OtrosCostos.Name = "Otros Costos"
  51. TotCostos.Name = "Total Costos"
  52. MontoLiq.Name = "Monto a Liquidar"
  53. InterGen.Name = "Interes a Genrerar"
  54. CostoTransfv.Name = "Costo de Transferencia"
  55. RendNetoAntImp.Name = "R% Neto (Antes de Impuesto)"
  56. ValReCompra.Name = "Valor de ReCompra"
  57. ImpLiquidacion.Name = "Impuesto de Liquidacion"
  58. IngrNeto.Name = "Ingreso Neto"
  59. ValNeto.Name = "Valor Neto"
  60. RendNetoDespImp.Name = "R% Neto (Despues de Impuesto)"
  61. Nombre.Name = "Nombre"
  62. FCompra.Name = "FCompra"
  63. ComisionCasa.Name = "ComisionCasa"
  64. ComisionBolsa.Name = "ComisionBolsa"
  65. Casa.Name = "Casa"
  66. Base.Name = "Base"
  67. EstadoIOF.Name = "EstadoIOF"
  68. EstadoRenta.Name = "EstadoRenta"
  69. Nombre.Visible = False
  70. FCompra.Visible = False
  71. ComisionCasa.Visible = False
  72. ComisionBolsa.Visible = False
  73. Casa.Visible = False
  74. Base.Visible = False
  75. EstadoIOF.Visible = False
  76. EstadoRenta.Visible = False
  77. Dim cod As String = Variables.Codigo
  78. If cod.IndexOf("REPOVENTA") > -1 Then
  79. RendNetoAntImp.HeaderText = "Costo Financiero (Antes de Impuesto)"
  80. RendNetoDespImp.HeaderText = "Costo Financiero (Despues de Impuesto)"
  81. Rend.HeaderText = "Costo Financiero"
  82. TotCostos.HeaderText = "Total a Pagar"
  83. Else
  84. RendNetoAntImp.HeaderText = "R% Neto (Antes de Impuesto)"
  85. RendNetoDespImp.HeaderText = "R% Neto (Despues de Impuesto)"
  86. Rend.HeaderText = "Rendimiento"
  87. TotCostos.HeaderText = "Total Costos"
  88. End If
  89. dgvReportos.Columns.Add(Correlativo)
  90. dgvReportos.Columns.Add(ValTrans)
  91. dgvReportos.Columns.Add(Dias)
  92. dgvReportos.Columns.Add(FVen)
  93. dgvReportos.Columns.Add(Rend)
  94. dgvReportos.Columns.Add(ComisionCB)
  95. dgvReportos.Columns.Add(CB)
  96. dgvReportos.Columns.Add(IOF)
  97. dgvReportos.Columns.Add(OtrosCostos)
  98. dgvReportos.Columns.Add(TotCostos)
  99. dgvReportos.Columns.Add(MontoLiq)
  100. dgvReportos.Columns.Add(InterGen)
  101. dgvReportos.Columns.Add(CostoTransfv)
  102. dgvReportos.Columns.Add(RendNetoAntImp)
  103. dgvReportos.Columns.Add(ValReCompra)
  104. dgvReportos.Columns.Add(ImpLiquidacion)
  105. dgvReportos.Columns.Add(IngrNeto)
  106. dgvReportos.Columns.Add(ValNeto)
  107. dgvReportos.Columns.Add(RendNetoDespImp)
  108. dgvReportos.Columns.Add(Nombre)
  109. dgvReportos.Columns.Add(FCompra)
  110. dgvReportos.Columns.Add(ComisionCasa)
  111. dgvReportos.Columns.Add(ComisionBolsa)
  112. dgvReportos.Columns.Add(Casa)
  113. dgvReportos.Columns.Add(codigo)
  114. dgvReportos.Columns.Add(Base)
  115. dgvReportos.Columns.Add(EstadoIOF)
  116. dgvReportos.Columns.Add(EstadoRenta)
  117. End If
  118. End Sub
  119. Sub LlenarBase()
  120. Dim Index As Integer = dgvReportos.Rows.Count - 2
  121. Base = cboAnioBase.SelectedIndex
  122. Dim i As Integer = 0
  123. While i <= Index
  124. dgvReportos.Rows(i).Cells("Base").Value = Base
  125. i += 1
  126. End While
  127. End Sub
  128. Sub IngresarDatos()
  129. If Cargado Then
  130. If Procesado Then
  131. If Not dgvReportos.CurrentRow Is Nothing Then
  132. Dim Index As Integer = dgvReportos.CurrentRow.Index
  133. dgvReportos.Rows(Index).Cells("Nombre").Value = txtCodigoTitulo.Text.ToString
  134. dgvReportos.Rows(Index).Cells("FCompra").Value = dtpFechaCompra.Value
  135. dgvReportos.Rows(Index).Cells("ComisionCasa").Value = Operaciones.ConvertirDecimal(txtComisionCasa.Text.ToString) / 100
  136. dgvReportos.Rows(Index).Cells("ComisionBolsa").Value = Operaciones.ConvertirDecimal(txtComisionBolsa.Text.ToString) / 100
  137. dgvReportos.Rows(Index).Cells("Casa").Value = cboCasaCorredora.SelectedValue
  138. End If
  139. End If
  140. End If
  141. End Sub
  142. Sub IngresarDatosReves()
  143. Procesado = False
  144. If Cargado Then
  145. If Not dgvReportos.CurrentRow Is Nothing Then
  146. Dim Index As Integer = dgvReportos.CurrentRow.Index
  147. Dim Nombre As String = CStr(dgvReportos.Rows(Index).Cells("Nombre").Value)
  148. Dim FCompra As Date = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value)
  149. Dim ComisionCasa As Double = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionCasa").Value) * 100
  150. Dim ComisionBolsa As Double = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionBolsa").Value) * 100
  151. Dim EstadoIOF As Boolean = Operaciones.ConvertirBoolNum(dgvReportos.Rows(Index).Cells("EstadoIOF").Value)
  152. Dim EstadoRenta As Boolean = Operaciones.ConvertirBoolNum(dgvReportos.Rows(Index).Cells("EstadoRenta").Value)
  153. Dim Casa As String = Operaciones.ConvertirCadena(dgvReportos.Rows(Index).Cells("Casa").Value)
  154. txtCodigoTitulo.Text = Nombre
  155. dtpFechaCompra.Value = FCompra
  156. txtComisionCasa.Text = ComisionCasa
  157. txtComisionBolsa.Text = ComisionBolsa
  158. If Index = 0 Then
  159. ChkIOF.Checked = EstadoIOF
  160. Else
  161. Dim EstadoIOFAnt = Operaciones.ConvertirBoolNum(dgvReportos.Rows(Index - 1).Cells("EstadoIOF").Value)
  162. ChkIOF.Checked = EstadoIOFAnt
  163. End If
  164. If Index = 0 Then
  165. ChkRenta.Checked = EstadoRenta
  166. Else
  167. Dim EstadoRentaAnt = dgvReportos.Rows(Index - 1).Cells("EstadoRenta").Value
  168. ChkRenta.Checked = EstadoRentaAnt
  169. End If
  170. cboCasaCorredora.SelectedValue = Casa
  171. End If
  172. End If
  173. Procesado = True
  174. End Sub
  175. Sub ComisionCasa(ByVal ComisionCasa As Double, ByVal Index As Integer)
  176. Dim ValorTrasado As Double = 0.0
  177. Dim Dias As Integer = 0
  178. Dim por As Double = 0
  179. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  180. Dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString)
  181. por = ComisionCasa
  182. Dim Fecha1 As Date = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString)
  183. Dim Fecha2 As Date = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString)
  184. dgvReportos.Rows(Index).Cells("Comision CB").Value = Operaciones.ConvertirDecimal(Reporto.Comision(ValorTrasado, Dias, por, Fecha1, Fecha2, Base).ToString)
  185. End Sub
  186. Sub ComisionBolsa(ByVal ComisionBolsa As Double, ByVal Index As Integer)
  187. Dim ValorTrasado As Double = 0
  188. Dim Dias As Integer = 0
  189. Dim por As Double = 0
  190. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  191. Dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString)
  192. por = ComisionBolsa
  193. Dim Fecha1 As Date = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString)
  194. Dim Fecha2 As Date = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString)
  195. dgvReportos.Rows(Index).Cells("Comision Bolsa").Value = Operaciones.ConvertirDecimal(Reporto.Comision(ValorTrasado, Dias, por, Fecha1, Fecha2, Base).ToString)
  196. End Sub
  197. Sub IOF(ByVal Index As Integer)
  198. Dim ValorTrasado As Double = 0
  199. Dim ComisionCasa As Double = 0
  200. Dim ComisionBolsa As Double = 0
  201. Dim dias As Integer = 0
  202. Dim Porcentaje As Double = 0.0025
  203. Dim Fecha1 As Date = Date.Now.Date
  204. Dim Fecha2 As Date = Date.Now.Date
  205. If ChkIOF.Checked Then
  206. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  207. ComisionCasa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision CB").Value.ToString)
  208. ComisionBolsa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision Bolsa").Value.ToString)
  209. dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString)
  210. Fecha1 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString)
  211. Fecha2 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString)
  212. dgvReportos.Rows(Index).Cells("IOF").Value = Operaciones.ConvertirDecimal(Reporto.IOF(ValorTrasado, ComisionCasa, ComisionBolsa, dias, Porcentaje, Fecha1, Fecha2, Base).ToString)
  213. Else
  214. dgvReportos.Rows(Index).Cells("IOF").Value = 0
  215. End If
  216. End Sub
  217. Sub TotalCostos(ByVal Index As Integer)
  218. Dim ComisionCasa As Double = 0
  219. Dim ComisionBolsa As Double = 0
  220. Dim IOF As Double = 0
  221. Dim OC As Double = 0
  222. Dim ValorTransado As Double = 0
  223. Dim Instrumento As String = String.Empty
  224. If Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  225. Instrumento = "REPOVENTA"
  226. Else
  227. Instrumento = "REPO"
  228. End If
  229. ComisionCasa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision CB").Value.ToString)
  230. ComisionBolsa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision Bolsa").Value.ToString)
  231. IOF = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("IOF").Value.ToString)
  232. OC = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Otros Costos").Value.ToString)
  233. ValorTransado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  234. dgvReportos.Rows(Index).Cells("Total Costos").Value = Operaciones.ConvertirDecimal(Reporto.TotCostos(ComisionCasa, ComisionBolsa, IOF, OC, ValorTransado, Instrumento).ToString)
  235. End Sub
  236. Sub MontoLiquidacion(ByVal Index As Integer)
  237. Dim ValorTrasado As Double = 0
  238. Dim TotalCosto As Double = 0
  239. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  240. TotalCosto = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Total Costos").Value.ToString)
  241. dgvReportos.Rows(Index).Cells("Monto a Liquidar").Value = Operaciones.ConvertirDecimal(Reporto.MontoLiquidacion(ValorTrasado, TotalCosto).ToString)
  242. End Sub
  243. Sub InteresGenerar(ByVal Index As Integer)
  244. Dim ValorTrasado As Double = 0
  245. Dim rendimiento As Double = 0
  246. Dim dias As Integer = 0
  247. Dim Fecha1 As Date = Date.Now.Date
  248. Dim Fecha2 As Date = Date.Now.Date
  249. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  250. rendimiento = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Rendimiento").Value.ToString)
  251. dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString)
  252. Fecha1 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString)
  253. Fecha2 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString)
  254. dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value = Operaciones.ConvertirDecimal(Reporto.InteresGenerar(ValorTrasado, rendimiento, dias, Fecha1, Fecha2, Base).ToString)
  255. End Sub
  256. Sub RendimientoAntes(ByVal Index As Integer)
  257. Dim ValorTrasado As Double = 0
  258. Dim dias As Integer = 0
  259. Dim InteresGenerar As Double = 0
  260. Dim Totcosto As Double = 0
  261. Dim Fecha1 As Date = Date.Now.Date
  262. Dim Fecha2 As Date = Date.Now.Date
  263. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  264. dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString)
  265. InteresGenerar = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value.ToString)
  266. Totcosto = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Total Costos").Value.ToString)
  267. Fecha1 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString)
  268. Fecha2 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString)
  269. dgvReportos.Rows(Index).Cells("R% Neto (Antes de Impuesto)").Value = Operaciones.ConvertirDecimal(Reporto.RendimientoAntes(InteresGenerar, Totcosto, ValorTrasado, dias, Fecha1, Fecha2, Base, Tabla).ToString)
  270. End Sub
  271. Sub ValorRecompra(ByVal Index As Integer)
  272. Dim ValorTrasado As Double = 0
  273. Dim InteresGenerar As Double = 0
  274. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  275. InteresGenerar = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value.ToString)
  276. dgvReportos.Rows(Index).Cells("Valor de ReCompra").Value = Operaciones.ConvertirDecimal(Reporto.ValorRecompras(ValorTrasado, InteresGenerar).ToString)
  277. End Sub
  278. Sub Renta(ByVal Index As String)
  279. Dim InteresGenerar As Double = 0
  280. If ChkRenta.Checked Then
  281. InteresGenerar = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value.ToString)
  282. dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value = (InteresGenerar * 0.1)
  283. Else
  284. dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value = 0
  285. End If
  286. End Sub
  287. Sub IngresoNeto(ByVal Index As Integer)
  288. Dim InteresGenerar As Double = 0
  289. Dim Renta As Double = 0
  290. InteresGenerar = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value.ToString)
  291. Renta = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value.ToString)
  292. dgvReportos.Rows(Index).Cells("Ingreso Neto").Value = Operaciones.ConvertirDecimal(Reporto.IngresoNet(InteresGenerar, Renta).ToString)
  293. End Sub
  294. Sub ValorNeto(ByVal Index As Integer)
  295. Dim ValorTrasado As Double = 0
  296. Dim IngresoNeto As Double = 0
  297. Dim CostoTrans As Double = 0
  298. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  299. IngresoNeto = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Ingreso Neto").Value.ToString)
  300. CostoTrans = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Costo de Transferencia").Value.ToString)
  301. dgvReportos.Rows(Index).Cells("Valor Neto").Value = Operaciones.ConvertirDecimal(Reporto.ValorNet(ValorTrasado, IngresoNeto, CostoTrans).ToString)
  302. End Sub
  303. Sub RendimientoDespues(ByVal Index As Integer)
  304. Dim ValorTrasado As Double = 0
  305. Dim IngresoNeto As Double = 0
  306. Dim TotalCosto As Double = 0
  307. Dim dias As Integer = 0
  308. Dim Fecha1 As Date = Date.Now.Date
  309. Dim Fecha2 As Date = Date.Now.Date
  310. ValorTrasado = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value.ToString)
  311. IngresoNeto = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Ingreso Neto").Value.ToString)
  312. TotalCosto = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Total Costos").Value.ToString)
  313. dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString)
  314. Fecha1 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString)
  315. Fecha2 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value.ToString)
  316. dgvReportos.Rows(Index).Cells("R% Neto (Despues de Impuesto)").Value = Operaciones.ConvertirDecimal(Reporto.RendimientoDespues(IngresoNeto, TotalCosto, ValorTrasado, dias, Fecha1, Fecha2, Base).ToString)
  317. End Sub
  318. Sub CargarFecha()
  319. Dim Index As Integer = dgvReportos.CurrentRow.Index
  320. Dim Fecha As Date = dtpFechaCompra.Value
  321. Dim Fecha2 As Date = Date.Now.Date
  322. Fecha2 = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value)
  323. End Sub
  324. Private Sub CargarCasaCorredora()
  325. If cboCasaCorredora.Items.Count = 0 Or cboCasaCorredora.Items.Count = 1 Then
  326. Me.cboCasaCorredora.DataSource = oDAOGeneral.ListaTiposImpuesto
  327. Me.cboCasaCorredora.DisplayMember = "Descripcion"
  328. Me.cboCasaCorredora.ValueMember = "Codigo"
  329. Me.cboCasaCorredora.SelectedIndex = 0
  330. End If
  331. End Sub
  332. Sub CargarBase()
  333. If cboAnioBase.Items.Count = 0 Or cboAnioBase.Items.Count = 1 Then
  334. Me.cboAnioBase.DataSource = oDAOGeneral.ListaBase
  335. Me.cboAnioBase.DisplayMember = "Descripcion"
  336. Me.cboAnioBase.ValueMember = "Codigo"
  337. Me.cboAnioBase.SelectedIndex = 0
  338. End If
  339. End Sub
  340. Private Sub frmReporto_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  341. Titulo.TabPages.Remove(TbImpuestos)
  342. Dim CantidadFilas As Integer = dgvReportos.Rows.Count
  343. CargarCasaCorredora()
  344. CargarBase()
  345. If Variables.Codigo.IndexOf("REPO") > -1 And Not Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  346. Tabla = "REP0"
  347. lblReporto.Text = "Reporto de Compra"
  348. Variables.Inicio = True
  349. txtComisionCasa.Text = PorcentajeComisionCasa
  350. txtComisionBolsa.Text = PorcentajeComisionBolsa
  351. If CantidadFilas <= 1 Then
  352. AgregarCampos(1)
  353. CargarReporto(Tabla)
  354. End If
  355. Calculos()
  356. Variables.Inicio = False
  357. Calculos()
  358. CargarUnaVez = False
  359. CodigoRotar = 0
  360. ElseIf Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  361. OcultarValoresImp()
  362. Tabla = "REP0VENTA"
  363. lblReporto.Text = "Reporto de Venta"
  364. lblFechaCompra.Text = "Fecha de Venta"
  365. lblCodigoInstrumento.Visible = True
  366. txtCodigoInstrumento.Visible = True
  367. If Not String.IsNullOrEmpty(CodigoProveniente) Then
  368. txtCodigoInstrumento.Text = CodigoProveniente
  369. End If
  370. If CantidadFilas <= 1 Then
  371. AgregarCampos(2)
  372. CargarReporto(Tabla)
  373. End If
  374. CodigoRotar = 0
  375. Calculos()
  376. CargarMontoRepoVenta()
  377. End If
  378. Cargado = True
  379. CorrelativoSinBD()
  380. ExisteInversion()
  381. ValidarExistencia()
  382. Formato()
  383. End Sub
  384. Sub CargarMontoRepoVenta()
  385. If Operaciones.ConvertirDecimal(txtMonto.Text.ToString) > 0 Then
  386. If dgvReportos.Rows(0).Cells("Valor Trasado").Value = 0 Then
  387. dgvReportos.Rows(0).Cells("Valor Trasado").Value = txtMonto.Text
  388. txtMonto.Text = 0
  389. End If
  390. End If
  391. End Sub
  392. Sub OcultarValoresImp()
  393. ChkIOF.Checked = False
  394. ChkRenta.Checked = False
  395. ChkRenta.Visible = False
  396. ChkIOF.Visible = False
  397. End Sub
  398. Function ExisteInversion()
  399. Dim Codigo As String = Variables.Codigo
  400. Dim TablaINV As String = "INV0"
  401. Dim TablaPINV As String = "PIN0"
  402. Dim General As New DAOGeneral
  403. Dim InvPro = Variables.InvPro
  404. If InvPro = "I" Then
  405. Dim INV0 As Boolean = General.ExisteTitulo(Codigo, TablaINV)
  406. If INV0 Then
  407. navNuevo.Visible = True
  408. Return True
  409. Else
  410. navNuevo.Visible = False
  411. Return False
  412. End If
  413. End If
  414. If InvPro = "P" Then
  415. Dim PINV0 As Boolean = General.ExisteTitulo(Codigo, TablaPINV)
  416. If PINV0 Then
  417. navNuevo.Visible = True
  418. Return True
  419. Else
  420. navNuevo.Visible = False
  421. Return False
  422. End If
  423. End If
  424. Return False
  425. End Function
  426. Sub Formato()
  427. If (String.IsNullOrEmpty(txtDias.Text.ToString)) Then
  428. txtDias.Text = 0
  429. End If
  430. If (String.IsNullOrEmpty(txtComisionCasa.Text.ToString.Trim("%"))) Then
  431. txtComisionCasa.Text = "0.2825%"
  432. End If
  433. If (String.IsNullOrEmpty(txtComisionBolsa.Text.ToString.Trim("%"))) Then
  434. txtComisionBolsa.Text = "0.2825%"
  435. End If
  436. If txtComisionBolsa.Text.ToString.IndexOf("%") = -1 Then
  437. txtComisionBolsa.Text = txtComisionBolsa.Text.ToString + "%"
  438. End If
  439. If txtComisionCasa.Text.ToString.IndexOf("%") = -1 Then
  440. txtComisionCasa.Text = txtComisionCasa.Text.ToString + "%"
  441. End If
  442. If cboCasaCorredora.SelectedIndex = -1 Then
  443. Try
  444. cboCasaCorredora.SelectedIndex = 0
  445. Catch ex As Exception
  446. End Try
  447. End If
  448. End Sub
  449. Sub IOFRentaEstado()
  450. Dim CantidadRegistro As Integer = dgvReportos.Rows.Count - 2
  451. Dim EstadoImpIOF As Integer = 0
  452. Dim EstadoImpRenta As Integer = 0
  453. If ChkIOF.Checked Then
  454. EstadoImpIOF = 1
  455. Else
  456. EstadoImpIOF = 0
  457. End If
  458. If ChkRenta.Checked Then
  459. EstadoImpRenta = 1
  460. Else
  461. EstadoImpRenta = 0
  462. End If
  463. Dim i As Integer = 0
  464. While i <= CantidadRegistro
  465. dgvReportos.Rows(i).Cells("EstadoIOF").Value = EstadoImpIOF
  466. dgvReportos.Rows(i).Cells("EstadoRenta").Value = EstadoImpRenta
  467. i += 1
  468. End While
  469. End Sub
  470. Sub Calculos()
  471. Dim Cantidad As Integer = dgvReportos.Rows.Count - 2
  472. Dim Index As Integer = 0
  473. While Index <= Cantidad
  474. Dim FCompra As Date
  475. Dim VComisionCasa As Double = 0
  476. Dim VComisionBolsa As Double = 0
  477. FCompra = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString)
  478. VComisionCasa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionCasa").Value.ToString)
  479. VComisionBolsa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionBolsa").Value.ToString)
  480. FechaVen(FCompra, Index)
  481. ComisionCasa(VComisionCasa, Index)
  482. ComisionBolsa(VComisionBolsa, Index)
  483. IOF(Index)
  484. TotalCostos(Index)
  485. MontoLiquidacion(Index)
  486. InteresGenerar(Index)
  487. RendimientoAntes(Index)
  488. ValorRecompra(Index)
  489. Renta(Index)
  490. IngresoNeto(Index)
  491. ValorNeto(Index)
  492. RendimientoDespues(Index)
  493. Index += 1
  494. End While
  495. End Sub
  496. Sub NuevaFila()
  497. Dim i As Integer = dgvReportos.CurrentRow.Index
  498. Dim IndexAnterior As Integer = dgvReportos.CurrentRow.Index - 1
  499. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Codigo").Value)) Then
  500. dgvReportos.Rows(i).Cells("Codigo").Value = Correlativo()
  501. End If
  502. If Not i = 0 Then
  503. If (Not String.IsNullOrEmpty(dgvReportos.Rows(IndexAnterior).Cells("EstadoIOF").Value)) Then
  504. dgvReportos.Rows(i).Cells("EstadoIOF").Value = dgvReportos.Rows(IndexAnterior).Cells("EstadoIOF").Value
  505. Else
  506. dgvReportos.Rows(i).Cells("EstadoIOF").Value = 0
  507. End If
  508. If (Not String.IsNullOrEmpty(dgvReportos.Rows(IndexAnterior).Cells("EstadoRenta").Value)) Then
  509. dgvReportos.Rows(i).Cells("EstadoRenta").Value = dgvReportos.Rows(IndexAnterior).Cells("EstadoRenta").Value
  510. Else
  511. dgvReportos.Rows(IndexAnterior).Cells("EstadoRenta").Value = 0
  512. End If
  513. End If
  514. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Valor Trasado").Value)) Then
  515. dgvReportos.Rows(i).Cells("Valor Trasado").Value = 0
  516. End If
  517. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Dias").Value)) Then
  518. dgvReportos.Rows(i).Cells("Dias").Value = 0
  519. End If
  520. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Fecha de Vencimiento").Value)) Then
  521. Dim FechaVenc As String = Format(Date.Now.Date, "dd/MM/yyyy")
  522. dgvReportos.Rows(i).Cells("Fecha de Vencimiento").Value = FechaVenc
  523. End If
  524. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Rendimiento").Value)) Then
  525. dgvReportos.Rows(i).Cells("Rendimiento").Value = 0
  526. End If
  527. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("IOF").Value)) Then
  528. dgvReportos.Rows(i).Cells("IOF").Value = 0
  529. End If
  530. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Comision CB").Value)) Then
  531. dgvReportos.Rows(i).Cells("Comision CB").Value = 0
  532. End If
  533. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Comision Bolsa").Value)) Then
  534. dgvReportos.Rows(i).Cells("Comision Bolsa").Value = 0
  535. End If
  536. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Otros Costos").Value)) Then
  537. dgvReportos.Rows(i).Cells("Otros Costos").Value = 0
  538. End If
  539. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Total Costos").Value)) Then
  540. dgvReportos.Rows(i).Cells("Total Costos").Value = 0
  541. End If
  542. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Monto a Liquidar").Value)) Then
  543. dgvReportos.Rows(i).Cells("Monto a Liquidar").Value = 0
  544. End If
  545. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Interes a Genrerar").Value)) Then
  546. dgvReportos.Rows(i).Cells("Interes a Genrerar").Value = 0
  547. End If
  548. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Costo de Transferencia").Value)) Then
  549. dgvReportos.Rows(i).Cells("Costo de Transferencia").Value = 0
  550. End If
  551. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("R% Neto (Antes de Impuesto)").Value)) Then
  552. dgvReportos.Rows(i).Cells("R% Neto (Antes de Impuesto)").Value = 0
  553. End If
  554. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Valor de ReCompra").Value)) Then
  555. dgvReportos.Rows(i).Cells("Valor de ReCompra").Value = 0
  556. End If
  557. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Impuesto de Liquidacion").Value)) Then
  558. dgvReportos.Rows(i).Cells("Impuesto de Liquidacion").Value = 0
  559. End If
  560. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Ingreso Neto").Value)) Then
  561. dgvReportos.Rows(i).Cells("Ingreso Neto").Value = 0
  562. End If
  563. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Valor Neto").Value)) Then
  564. dgvReportos.Rows(i).Cells("Valor Neto").Value = 0
  565. End If
  566. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("R% Neto (Despues de Impuesto)").Value)) Then
  567. dgvReportos.Rows(i).Cells("R% Neto (Despues de Impuesto)").Value = 0
  568. End If
  569. End Sub
  570. Sub QuitarFila()
  571. Dim result As Integer = MsgBox("¿Está seguro que desea eliminar la fila?", MsgBoxStyle.OkCancel)
  572. ' Test result.
  573. Dim codigo As String = Variables.Codigo
  574. Dim Numero As Integer = dgvReportos.CurrentRow.Cells("codigo").Value
  575. If result = MsgBoxResult.Ok Then
  576. Try
  577. dgvReportos.Rows.Remove(dgvReportos.CurrentRow)
  578. ReportoConsula.Eliminar(codigo, Numero, Tabla)
  579. Catch ex As Exception
  580. MsgBox("No ha seleccionado una fila")
  581. End Try
  582. End If
  583. End Sub
  584. Sub FechaVen(ByVal FCompra As Date, ByVal Index As Integer)
  585. Dim FechaCompra As Date = FCompra
  586. Dim Dias As Integer = 0
  587. Dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString)
  588. dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value = CStr(Format(Reporto.FechaDeVencimiento(FechaCompra, Dias), "dd/MM/yyyy"))
  589. End Sub
  590. Sub CorrelativoSinBD()
  591. Dim Index As Integer = 0
  592. Dim IndexCantidad As Integer = dgvReportos.Rows.Count - 2
  593. Dim NumeroMayor As Integer = 0
  594. While Index <= IndexCantidad
  595. dgvReportos.Rows(Index).Cells("Correlativo").Value = Index + 1
  596. Index += 1
  597. End While
  598. End Sub
  599. Function Correlativo()
  600. Dim Index As Integer = 0
  601. Dim IndexCantidad As Integer = dgvReportos.Rows.Count - 2
  602. Dim NumeroMayor As Integer = 0
  603. While Index <= IndexCantidad
  604. Dim Numero As Integer = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("codigo").Value)
  605. If Numero > NumeroMayor Then
  606. NumeroMayor = Numero
  607. End If
  608. Index += 1
  609. End While
  610. Return NumeroMayor + 1
  611. End Function
  612. Sub CargarReporto(ByVal Tabla As String)
  613. Dim FechaVencimientoFormatoCadena As String
  614. Dim Activo = 0.0, ActivoRenta = 0.0
  615. Dim EstadoIOF, EstadoRenta
  616. Dim dr = ReportoConsula.CargarReporto(Codigo, Tabla)
  617. Dim ValorTransado As Double = 0
  618. Dim Rendimiento As Double = 0
  619. Dim CostoTransferencia As Double = 0
  620. Dim Nombre As String = String.Empty
  621. Dim FechaCompra As Date = Date.Now.Date
  622. Dim CasaCorredora As String = String.Empty
  623. Dim Correlativo As Integer = 0
  624. If (Not dr Is Nothing) Then
  625. While dr.Read
  626. If dr("EstadoIOF") Then
  627. EstadoIOF = 1
  628. ChkIOF.Checked = True
  629. Else
  630. EstadoIOF = 0
  631. ChkIOF.Checked = False
  632. End If
  633. If dr("EstadoRenta") Then
  634. EstadoRenta = 1
  635. ChkRenta.Checked = True
  636. Else
  637. EstadoRenta = 0
  638. ChkRenta.Checked = False
  639. End If
  640. Dim FechaVencimiento As Date = Operaciones.ConvertirFecha(dr("FCompra").ToString)
  641. Dim Dias As Integer = Operaciones.ConvertirEntero(dr("Dias").ToString)
  642. FechaVencimiento = FechaVencimiento.AddDays(Dias)
  643. FechaVencimientoFormatoCadena = Format(FechaVencimiento, "dd/MM/yyyy")
  644. dtpFechaCompra.Value = Operaciones.ConvertirFecha(dr("FCompra").ToString)
  645. If (dr("IOF")) Then
  646. Activo = 1
  647. Else
  648. Activo = 0
  649. End If
  650. If (dr("Renta")) Then
  651. ActivoRenta = 1
  652. Else
  653. ActivoRenta = 0
  654. End If
  655. Dim ComisionCasa As Double = 0
  656. Dim ComisionBolsa As Double = 0
  657. ComisionCasa = Operaciones.ConvertirDecimal(dr("ComisionCasa").ToString)
  658. ComisionBolsa = Operaciones.ConvertirDecimal(dr("ComisionBolsa").ToString)
  659. ValorTransado = Operaciones.ConvertirDecimal(dr("ValTrans").ToString)
  660. CostoTransferencia = Operaciones.ConvertirDecimal(dr("CostoTransfr").ToString)
  661. Nombre = dr("Nombre").ToString
  662. FechaCompra = Operaciones.ConvertirFecha(dr("FCompra").ToString)
  663. CasaCorredora = dr("Casa").ToString
  664. Correlativo = Operaciones.ConvertirEntero(dr("codigo").ToString)
  665. If Tabla = "REP0VENTA" Then
  666. dgvReportos.Rows.Add("", ValorTransado, Dias,
  667. FechaVencimientoFormatoCadena, Rendimiento, 0, 0, 0,
  668. 0, 0, 0, 0, 0, 0, CostoTransferencia, ActivoRenta, "",
  669. "", "", Nombre, FechaCompra, ComisionCasa,
  670. ComisionBolsa, CasaCorredora, Correlativo, "", EstadoIOF, EstadoRenta)
  671. End If
  672. End While
  673. End If
  674. End Sub
  675. Function ObtenerDatos(ByVal Index As Integer)
  676. Dim coleccion As New Collection
  677. Dim Renta, IOF, Nombre, FCompra, ValTrans, Dias, FVenc, Rend, CostoTransfr, codigo, ComisionCasa, ComisionBolsa, Casa, Casa2
  678. Dim EstadoIOF, EstadoRenta
  679. If Variables.Codigo.IndexOf("REPO") > -1 Or Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  680. Dim ComisionCasaValor, ComisionBolsaValor, IOFValor, OtrosCostos, TotalCostos, MontoLiq
  681. Dim IntGenerar, RendAntImp, RendDesImp, ImpLiq, IngrNet, ValorNet
  682. ValorNet = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Neto").Value.ToString)
  683. IngrNet = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Ingreso Neto").Value.ToString)
  684. ImpLiq = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value)
  685. RendDesImp = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("R% Neto (Despues de Impuesto)").Value)
  686. RendAntImp = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("R% Neto (Antes de Impuesto)").Value)
  687. IntGenerar = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value)
  688. MontoLiq = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Monto a Liquidar").Value)
  689. TotalCostos = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Total Costos").Value)
  690. OtrosCostos = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Otros Costos").Value)
  691. IOFValor = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("IOF").Value)
  692. ComisionBolsaValor = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision Bolsa").Value)
  693. ComisionCasaValor = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision CB").Value)
  694. Nombre = dgvReportos.Rows(Index).Cells("Nombre").Value.ToString
  695. FCompra = Operaciones.ConvertirFechaBaseDatos(dgvReportos.Rows(Index).Cells("FCompra").Value)
  696. ValTrans = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value)
  697. Dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value)
  698. FVenc = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value)
  699. Rend = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Rendimiento").Value)
  700. CostoTransfr = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Costo de Transferencia").Value)
  701. codigo = dgvReportos.Rows(Index).Cells("Codigo").Value.ToString
  702. ComisionCasa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionCasa").Value)
  703. ComisionBolsa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionBolsa").Value)
  704. Casa = dgvReportos.Rows(Index).Cells("Casa").Value.ToString
  705. If (Not dgvReportos.Rows(Index).Cells("IOF").Value = 0) Then
  706. IOF = 1
  707. Else
  708. IOF = 0
  709. End If
  710. If (Not dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value = 0) Then
  711. Renta = 1
  712. Else
  713. Renta = 0
  714. End If
  715. If (dgvReportos.Rows(Index).Cells("EstadoIOF").Value = 1) Then
  716. EstadoIOF = 1
  717. Else
  718. EstadoIOF = 0
  719. End If
  720. If (dgvReportos.Rows(Index).Cells("EstadoRenta").Value = 1) Then
  721. EstadoRenta = 1
  722. Else
  723. EstadoRenta = 0
  724. End If
  725. coleccion.Add(Nombre)
  726. coleccion.Add(FCompra)
  727. coleccion.Add(ValTrans)
  728. coleccion.Add(Dias)
  729. coleccion.Add(FVenc)
  730. coleccion.Add(Rend)
  731. coleccion.Add(CostoTransfr)
  732. coleccion.Add(codigo)
  733. coleccion.Add(ComisionCasa)
  734. coleccion.Add(ComisionBolsa)
  735. coleccion.Add(Casa)
  736. coleccion.Add(IOF)
  737. coleccion.Add(Renta)
  738. coleccion.Add(Base)
  739. coleccion.Add(ComisionCasaValor)
  740. coleccion.Add(ComisionBolsaValor)
  741. coleccion.Add(IOFValor)
  742. coleccion.Add(OtrosCostos)
  743. coleccion.Add(TotalCostos)
  744. coleccion.Add(MontoLiq)
  745. coleccion.Add(IntGenerar)
  746. coleccion.Add(RendAntImp)
  747. coleccion.Add(RendDesImp)
  748. coleccion.Add(ImpLiq)
  749. coleccion.Add(IngrNet)
  750. coleccion.Add(ValorNet)
  751. coleccion.Add(EstadoIOF)
  752. coleccion.Add(EstadoRenta)
  753. End If
  754. Return coleccion
  755. End Function
  756. 'GETS
  757. Private Sub dgvReportos_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvReportos.CellEndEdit
  758. CorrelativoSinBD()
  759. Correlativo()
  760. Calculos()
  761. End Sub
  762. Private Sub dtpFechaCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaCompra.ValueChanged
  763. Formato()
  764. IngresarDatos()
  765. Modificado = True
  766. Calculos()
  767. End Sub
  768. Private Sub dgvReportos_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvReportos.CellClick
  769. IOFRentaEstado()
  770. IngresarDatosReves()
  771. NuevaFila()
  772. Dim Index = Operaciones.ConvertirEntero(dgvReportos.CurrentRow.Cells("codigo").Value)
  773. CargarFecha()
  774. Calculos()
  775. Formato()
  776. End Sub
  777. Private Sub dgvReportos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvReportos.CellContentClick
  778. End Sub
  779. Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click
  780. End Sub
  781. Private Sub txtCodigoTitulo_TextChanged(sender As Object, e As EventArgs) Handles txtCodigoTitulo.TextChanged
  782. Modificado = True
  783. End Sub
  784. Private Sub txtIOF_TextChanged(sender As Object, e As EventArgs)
  785. End Sub
  786. Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
  787. btnAccion.Text = "Modificar"
  788. Estado = "M"
  789. End Sub
  790. Sub NuevoIngreso(ByVal AgregarModificar As Boolean, ByVal Cantidad As Integer, ByVal Tabla As String)
  791. Dim i As Integer = 0
  792. Dim Index = dgvReportos.Rows.Count - 2
  793. i = Cantidad
  794. While i <= Index
  795. Dim coleccion = ObtenerDatos(i)
  796. If ReportoConsula.Nuevo(coleccion, Codigo, Tabla) Is Nothing Then
  797. Exit Sub
  798. End If
  799. i += 1
  800. End While
  801. MsgBox("Reportos actualizados")
  802. End Sub
  803. Function NuevoIngresoColeccion()
  804. Dim i As Integer = 0
  805. Dim Index = dgvReportos.Rows.Count - 2
  806. Dim diccionario As New Dictionary(Of String, Collection)
  807. While i <= Index
  808. Dim coleccion = ObtenerDatos(i)
  809. diccionario.Add(i, coleccion)
  810. i += 1
  811. End While
  812. Return diccionario
  813. End Function
  814. Private Sub btnAccion_Click(sender As Object, e As EventArgs) Handles btnAccion.Click
  815. LlenarBase()
  816. Dim Codigo = Variables.Codigo
  817. Dim diccionario As Dictionary(Of String, Collection) = NuevoIngresoColeccion()
  818. If (Estado = "N") Then
  819. ReportoConsula.ProcesoDatos(diccionario, Codigo, Tabla)
  820. ValidarExistencia()
  821. ElseIf Not ExisteValidacion() Then
  822. Variables.ColeccionREPO = diccionario
  823. Me.Close()
  824. ElseIf (Estado = "M") Then
  825. ReportoConsula.ProcesoDatos(diccionario, Codigo, Tabla)
  826. ValidarExistencia()
  827. ElseIf (Estado = "B") Then
  828. QuitarFila()
  829. ValidarExistencia()
  830. End If
  831. End Sub
  832. Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
  833. btnAccion.Text = "Agregar"
  834. Estado = "N"
  835. End Sub
  836. Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
  837. btnAccion.Text = "Eliminar"
  838. Estado = "B"
  839. End Sub
  840. Private Sub Button1_Click(sender As Object, e As EventArgs)
  841. End Sub
  842. Private Sub btnAgregarImpuesto_Click(sender As Object, e As EventArgs)
  843. End Sub
  844. Private Sub dgvImpuestos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
  845. End Sub
  846. Private Sub TabPage3_Click(sender As Object, e As EventArgs) Handles TbImpuestos.Click
  847. End Sub
  848. Private Sub dgvImpuestoAgregado_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
  849. End Sub
  850. Private Sub btnQuitar_Click(sender As Object, e As EventArgs)
  851. End Sub
  852. Private Sub FlpIOF_Click(sender As Object, e As EventArgs) Handles FlpIOF.Click
  853. End Sub
  854. Private Sub FlpIOF_MouseClick(sender As Object, e As MouseEventArgs) Handles FlpIOF.MouseClick
  855. End Sub
  856. Private Sub FlpIOF_ChangeUICues(sender As Object, e As UICuesEventArgs) Handles FlpIOF.ChangeUICues
  857. End Sub
  858. Private Sub FlpIOF_Paint(sender As Object, e As PaintEventArgs) Handles FlpIOF.Paint
  859. End Sub
  860. Private Sub txtComisionCasa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionCasa.KeyPress
  861. If String.IsNullOrEmpty(txtComisionCasa.Text.ToString.Trim("%")) Then
  862. If e.KeyChar = "." Then
  863. txtComisionCasa.Text = "0.0%"
  864. Exit Sub
  865. End If
  866. End If
  867. If (Not txtComisionCasa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  868. Operaciones.ValidarEntrada(sender, e, True)
  869. Else
  870. Operaciones.ValidarEntrada(sender, e, False)
  871. End If
  872. End Sub
  873. Private Sub txtComisionBolsa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionBolsa.KeyPress
  874. If String.IsNullOrEmpty(txtComisionBolsa.Text.ToString.Trim("%")) Then
  875. If e.KeyChar = "." Then
  876. txtComisionBolsa.Text = "0.2825%"
  877. Exit Sub
  878. End If
  879. End If
  880. If (Not txtComisionBolsa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  881. Operaciones.ValidarEntrada(sender, e, True)
  882. Else
  883. Operaciones.ValidarEntrada(sender, e, False)
  884. End If
  885. End Sub
  886. Private Sub BindingNavigator1_RefreshItems(sender As Object, e As EventArgs) Handles BindingNavigator1.RefreshItems
  887. End Sub
  888. Private Sub txtComisionCasa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionCasa.TextChanged
  889. IngresarDatos()
  890. Modificado = True
  891. Calculos()
  892. End Sub
  893. Private Sub txtComisionBolsa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionBolsa.TextChanged
  894. IngresarDatos()
  895. Modificado = True
  896. Calculos()
  897. End Sub
  898. Private Sub txtDias_TextChanged(sender As Object, e As EventArgs) Handles txtDias.TextChanged
  899. IngresarDatos()
  900. Modificado = True
  901. Calculos()
  902. End Sub
  903. Private Sub cboCasaCorredora_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboCasaCorredora.SelectedIndexChanged
  904. Modificado = True
  905. IngresarDatos()
  906. End Sub
  907. Private Sub txtCodigoTitulo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtCodigoTitulo.KeyPress
  908. End Sub
  909. Private Sub txtDias_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtDias.KeyPress
  910. If String.IsNullOrEmpty(txtDias.Text) Then
  911. If e.KeyChar = "." Then
  912. txtDias.Text = "0"
  913. Exit Sub
  914. End If
  915. End If
  916. If (Not txtDias.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  917. Operaciones.ValidarEntrada(sender, e, True)
  918. Else
  919. Operaciones.ValidarEntrada(sender, e, False)
  920. End If
  921. End Sub
  922. Private Sub txtCodigoTitulo_KeyUp(sender As Object, e As KeyEventArgs) Handles txtCodigoTitulo.KeyUp
  923. IngresarDatos()
  924. End Sub
  925. Private Sub txtComisionCasa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionCasa.KeyUp
  926. If txtComisionCasa.Text = "." Then
  927. txtComisionCasa.Text = ".0%"
  928. End If
  929. IngresarDatos()
  930. Calculos()
  931. End Sub
  932. Private Sub txtComisionBolsa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionBolsa.KeyUp
  933. If txtComisionBolsa.Text = "." Then
  934. txtComisionBolsa.Text = ".0%"
  935. End If
  936. IngresarDatos()
  937. Calculos()
  938. End Sub
  939. Sub ValidarExistencia()
  940. Dim General As New DAOGeneral
  941. Dim Codigo As String = Variables.Codigo
  942. Dim Tabla As String = String.Empty
  943. If Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  944. Tabla = "REP0VENTA"
  945. ElseIf Variables.Codigo.IndexOf("REPO") > -1 Then
  946. Tabla = "REP0"
  947. End If
  948. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  949. If (Existe) Then
  950. navNuevo.Enabled = False
  951. navModificar.Enabled = True
  952. navEliminar.Enabled = True
  953. Else
  954. navNuevo.Enabled = True
  955. navModificar.Enabled = False
  956. navEliminar.Enabled = False
  957. End If
  958. Estado = String.Empty
  959. btnAccion.Text = "Aceptar"
  960. End Sub
  961. Function ExisteValidacion()
  962. Dim General As New DAOGeneral
  963. Dim Codigo As String = Variables.Codigo
  964. Dim Tabla As String = String.Empty
  965. If Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  966. Tabla = "REP0VENTA"
  967. ElseIf Variables.Codigo.IndexOf("REPO") > -1 Then
  968. Tabla = "REP0"
  969. End If
  970. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  971. Return Existe
  972. End Function
  973. Private Sub btnGuardar_Click(sender As Object, e As EventArgs)
  974. End Sub
  975. Private Sub dgvReportos_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) Handles dgvReportos.CellBeginEdit
  976. CorrelativoSinBD()
  977. Correlativo()
  978. End Sub
  979. Private Sub txtDias_KeyUp(sender As Object, e As KeyEventArgs) Handles txtDias.KeyUp
  980. If txtDias.Text = "." Then
  981. txtDias.Text = ".0"
  982. End If
  983. IngresarDatos()
  984. Calculos()
  985. End Sub
  986. Private Sub cboAnioBase_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboAnioBase.SelectedIndexChanged
  987. LlenarBase()
  988. IngresarDatos()
  989. Modificado = True
  990. Calculos()
  991. End Sub
  992. Private Sub txtDias_Leave(sender As Object, e As EventArgs) Handles txtDias.Leave
  993. Formato()
  994. End Sub
  995. Private Sub txtComisionCasa_Leave(sender As Object, e As EventArgs) Handles txtComisionCasa.Leave
  996. Formato()
  997. End Sub
  998. Private Sub txtComisionBolsa_Leave(sender As Object, e As EventArgs) Handles txtComisionBolsa.Leave
  999. Formato()
  1000. End Sub
  1001. Private Sub frmReporto_Resize(sender As Object, e As EventArgs) Handles MyBase.Resize
  1002. dgvReportos.Width = Me.Width - 10
  1003. dgvReportos.Height = Me.Height - 290
  1004. End Sub
  1005. Private Sub ChkIOF_CheckedChanged(sender As Object, e As EventArgs) Handles ChkIOF.CheckedChanged
  1006. IOFRentaEstado()
  1007. Modificado = True
  1008. IngresarDatos()
  1009. Calculos()
  1010. End Sub
  1011. Private Sub ChkRenta_CheckedChanged(sender As Object, e As EventArgs) Handles ChkRenta.CheckedChanged
  1012. IOFRentaEstado()
  1013. Modificado = True
  1014. IngresarDatos()
  1015. Calculos()
  1016. End Sub
  1017. Private Sub txtCodigoInstrumento_TextChanged(sender As Object, e As EventArgs) Handles txtCodigoInstrumento.TextChanged
  1018. IngresarDatos()
  1019. Modificado = True
  1020. Calculos()
  1021. End Sub
  1022. Sub SeleccionarInstrumento()
  1023. Dim frmInstrumentos As New frmSeleccionTitulosReportos
  1024. frmInstrumentos.Show()
  1025. End Sub
  1026. Private Sub btnSaldoDisponible_Click(sender As Object, e As EventArgs)
  1027. SeleccionarInstrumento()
  1028. End Sub
  1029. Private Sub btnRequisicion_Click(sender As Object, e As EventArgs)
  1030. End Sub
  1031. End Class