frmReporto.vb 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413
  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. CargarTransladoNuevo()
  384. End Sub
  385. Sub CargarMontoRepoVenta()
  386. If Operaciones.ConvertirDecimal(txtMonto.Text.ToString) > 0 Then
  387. If dgvReportos.Rows(0).Cells("Valor Trasado").Value = 0 Then
  388. dgvReportos.Rows(0).Cells("Valor Trasado").Value = txtMonto.Text
  389. txtMonto.Text = 0
  390. End If
  391. End If
  392. End Sub
  393. Sub OcultarValoresImp()
  394. ChkIOF.Checked = False
  395. ChkRenta.Checked = False
  396. ChkRenta.Visible = False
  397. ChkIOF.Visible = False
  398. End Sub
  399. Function ExisteInversion()
  400. Dim Codigo As String = Variables.Codigo
  401. Dim TablaINV As String = "INV0"
  402. Dim TablaPINV As String = "PIN0"
  403. Dim General As New DAOGeneral
  404. Dim InvPro = Variables.InvPro
  405. If InvPro = "I" Then
  406. Dim INV0 As Boolean = General.ExisteTitulo(Codigo, TablaINV)
  407. If INV0 Then
  408. navNuevo.Visible = True
  409. Return True
  410. Else
  411. navNuevo.Visible = False
  412. Return False
  413. End If
  414. End If
  415. If InvPro = "P" Then
  416. Dim PINV0 As Boolean = General.ExisteTitulo(Codigo, TablaPINV)
  417. If PINV0 Then
  418. navNuevo.Visible = True
  419. Return True
  420. Else
  421. navNuevo.Visible = False
  422. Return False
  423. End If
  424. End If
  425. Return False
  426. End Function
  427. Sub Formato()
  428. If (String.IsNullOrEmpty(txtDias.Text.ToString)) Then
  429. txtDias.Text = 0
  430. End If
  431. If (String.IsNullOrEmpty(txtComisionCasa.Text.ToString.Trim("%"))) Then
  432. txtComisionCasa.Text = "0.2825%"
  433. End If
  434. If (String.IsNullOrEmpty(txtComisionBolsa.Text.ToString.Trim("%"))) Then
  435. txtComisionBolsa.Text = "0.2825%"
  436. End If
  437. If txtComisionBolsa.Text.ToString.IndexOf("%") = -1 Then
  438. txtComisionBolsa.Text = txtComisionBolsa.Text.ToString + "%"
  439. End If
  440. If txtComisionCasa.Text.ToString.IndexOf("%") = -1 Then
  441. txtComisionCasa.Text = txtComisionCasa.Text.ToString + "%"
  442. End If
  443. If cboCasaCorredora.SelectedIndex = -1 Then
  444. Try
  445. cboCasaCorredora.SelectedIndex = 0
  446. Catch ex As Exception
  447. End Try
  448. End If
  449. End Sub
  450. Sub IOFRentaEstado()
  451. Dim CantidadRegistro As Integer = dgvReportos.Rows.Count - 2
  452. Dim EstadoImpIOF As Integer = 0
  453. Dim EstadoImpRenta As Integer = 0
  454. If ChkIOF.Checked Then
  455. EstadoImpIOF = 1
  456. Else
  457. EstadoImpIOF = 0
  458. End If
  459. If ChkRenta.Checked Then
  460. EstadoImpRenta = 1
  461. Else
  462. EstadoImpRenta = 0
  463. End If
  464. Dim i As Integer = 0
  465. While i <= CantidadRegistro
  466. dgvReportos.Rows(i).Cells("EstadoIOF").Value = EstadoImpIOF
  467. dgvReportos.Rows(i).Cells("EstadoRenta").Value = EstadoImpRenta
  468. i += 1
  469. End While
  470. End Sub
  471. Sub Calculos()
  472. Dim Cantidad As Integer = dgvReportos.Rows.Count - 2
  473. Dim Index As Integer = 0
  474. While Index <= Cantidad
  475. Dim FCompra As Date
  476. Dim VComisionCasa As Double = 0
  477. Dim VComisionBolsa As Double = 0
  478. FCompra = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("FCompra").Value.ToString)
  479. VComisionCasa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionCasa").Value.ToString)
  480. VComisionBolsa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionBolsa").Value.ToString)
  481. FechaVen(FCompra, Index)
  482. ComisionCasa(VComisionCasa, Index)
  483. ComisionBolsa(VComisionBolsa, Index)
  484. IOF(Index)
  485. TotalCostos(Index)
  486. MontoLiquidacion(Index)
  487. InteresGenerar(Index)
  488. RendimientoAntes(Index)
  489. ValorRecompra(Index)
  490. Renta(Index)
  491. IngresoNeto(Index)
  492. ValorNeto(Index)
  493. RendimientoDespues(Index)
  494. Index += 1
  495. End While
  496. End Sub
  497. Sub NuevaFila()
  498. Dim i As Integer = dgvReportos.CurrentRow.Index
  499. Dim IndexAnterior As Integer = dgvReportos.CurrentRow.Index - 1
  500. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Codigo").Value)) Then
  501. dgvReportos.Rows(i).Cells("Codigo").Value = Correlativo()
  502. End If
  503. If Not i = 0 Then
  504. If (Not String.IsNullOrEmpty(dgvReportos.Rows(IndexAnterior).Cells("EstadoIOF").Value)) Then
  505. dgvReportos.Rows(i).Cells("EstadoIOF").Value = dgvReportos.Rows(IndexAnterior).Cells("EstadoIOF").Value
  506. Else
  507. dgvReportos.Rows(i).Cells("EstadoIOF").Value = 0
  508. End If
  509. If (Not String.IsNullOrEmpty(dgvReportos.Rows(IndexAnterior).Cells("EstadoRenta").Value)) Then
  510. dgvReportos.Rows(i).Cells("EstadoRenta").Value = dgvReportos.Rows(IndexAnterior).Cells("EstadoRenta").Value
  511. Else
  512. dgvReportos.Rows(IndexAnterior).Cells("EstadoRenta").Value = 0
  513. End If
  514. End If
  515. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Valor Trasado").Value)) Then
  516. dgvReportos.Rows(i).Cells("Valor Trasado").Value = 0
  517. End If
  518. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Dias").Value)) Then
  519. dgvReportos.Rows(i).Cells("Dias").Value = 0
  520. End If
  521. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Fecha de Vencimiento").Value)) Then
  522. Dim FechaVenc As String = Format(Date.Now.Date, "dd/MM/yyyy")
  523. dgvReportos.Rows(i).Cells("Fecha de Vencimiento").Value = FechaVenc
  524. End If
  525. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Rendimiento").Value)) Then
  526. dgvReportos.Rows(i).Cells("Rendimiento").Value = 0
  527. End If
  528. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("IOF").Value)) Then
  529. dgvReportos.Rows(i).Cells("IOF").Value = 0
  530. End If
  531. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Comision CB").Value)) Then
  532. dgvReportos.Rows(i).Cells("Comision CB").Value = 0
  533. End If
  534. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Comision Bolsa").Value)) Then
  535. dgvReportos.Rows(i).Cells("Comision Bolsa").Value = 0
  536. End If
  537. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Otros Costos").Value)) Then
  538. dgvReportos.Rows(i).Cells("Otros Costos").Value = 0
  539. End If
  540. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Total Costos").Value)) Then
  541. dgvReportos.Rows(i).Cells("Total Costos").Value = 0
  542. End If
  543. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Monto a Liquidar").Value)) Then
  544. dgvReportos.Rows(i).Cells("Monto a Liquidar").Value = 0
  545. End If
  546. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Interes a Genrerar").Value)) Then
  547. dgvReportos.Rows(i).Cells("Interes a Genrerar").Value = 0
  548. End If
  549. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Costo de Transferencia").Value)) Then
  550. dgvReportos.Rows(i).Cells("Costo de Transferencia").Value = 0
  551. End If
  552. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("R% Neto (Antes de Impuesto)").Value)) Then
  553. dgvReportos.Rows(i).Cells("R% Neto (Antes de Impuesto)").Value = 0
  554. End If
  555. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Valor de ReCompra").Value)) Then
  556. dgvReportos.Rows(i).Cells("Valor de ReCompra").Value = 0
  557. End If
  558. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Impuesto de Liquidacion").Value)) Then
  559. dgvReportos.Rows(i).Cells("Impuesto de Liquidacion").Value = 0
  560. End If
  561. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Ingreso Neto").Value)) Then
  562. dgvReportos.Rows(i).Cells("Ingreso Neto").Value = 0
  563. End If
  564. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("Valor Neto").Value)) Then
  565. dgvReportos.Rows(i).Cells("Valor Neto").Value = 0
  566. End If
  567. If (String.IsNullOrEmpty(dgvReportos.Rows(i).Cells("R% Neto (Despues de Impuesto)").Value)) Then
  568. dgvReportos.Rows(i).Cells("R% Neto (Despues de Impuesto)").Value = 0
  569. End If
  570. End Sub
  571. Sub QuitarFila()
  572. Dim result As Integer = MsgBox("¿Está seguro que desea eliminar la fila?", MsgBoxStyle.OkCancel)
  573. ' Test result.
  574. Dim codigo As String = Variables.Codigo
  575. Dim Numero As Integer = dgvReportos.CurrentRow.Cells("codigo").Value
  576. If result = MsgBoxResult.Ok Then
  577. Try
  578. dgvReportos.Rows.Remove(dgvReportos.CurrentRow)
  579. ReportoConsula.Eliminar(codigo, Numero, Tabla)
  580. Catch ex As Exception
  581. MsgBox("No ha seleccionado una fila")
  582. End Try
  583. End If
  584. End Sub
  585. Sub FechaVen(ByVal FCompra As Date, ByVal Index As Integer)
  586. Dim FechaCompra As Date = FCompra
  587. Dim Dias As Integer = 0
  588. Dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value.ToString)
  589. dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value = CStr(Format(Reporto.FechaDeVencimiento(FechaCompra, Dias), "dd/MM/yyyy"))
  590. End Sub
  591. Sub CorrelativoSinBD()
  592. Dim Index As Integer = 0
  593. Dim IndexCantidad As Integer = dgvReportos.Rows.Count - 2
  594. Dim NumeroMayor As Integer = 0
  595. While Index <= IndexCantidad
  596. dgvReportos.Rows(Index).Cells("Correlativo").Value = Index + 1
  597. Index += 1
  598. End While
  599. End Sub
  600. Function Correlativo()
  601. Dim Index As Integer = 0
  602. Dim IndexCantidad As Integer = dgvReportos.Rows.Count - 2
  603. Dim NumeroMayor As Integer = 0
  604. While Index <= IndexCantidad
  605. Dim Numero As Integer = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("codigo").Value)
  606. If Numero > NumeroMayor Then
  607. NumeroMayor = Numero
  608. End If
  609. Index += 1
  610. End While
  611. Return NumeroMayor + 1
  612. End Function
  613. Sub CargarReporto(ByVal Tabla As String)
  614. Dim FechaVencimientoFormatoCadena As String
  615. Dim Activo = 0.0, ActivoRenta = 0.0
  616. Dim EstadoIOF, EstadoRenta
  617. Dim dr = ReportoConsula.CargarReporto(Codigo, Tabla)
  618. Dim ValorTransado As Double = 0
  619. Dim Rendimiento As Double = 0
  620. Dim CostoTransferencia As Double = 0
  621. Dim Nombre As String = String.Empty
  622. Dim FechaCompra As Date = Date.Now.Date
  623. Dim CasaCorredora As String = String.Empty
  624. Dim Correlativo As Integer = 0
  625. If (Not dr Is Nothing) Then
  626. While dr.Read
  627. If dr("EstadoIOF") Then
  628. EstadoIOF = 1
  629. ChkIOF.Checked = True
  630. Else
  631. EstadoIOF = 0
  632. ChkIOF.Checked = False
  633. End If
  634. If dr("EstadoRenta") Then
  635. EstadoRenta = 1
  636. ChkRenta.Checked = True
  637. Else
  638. EstadoRenta = 0
  639. ChkRenta.Checked = False
  640. End If
  641. Dim FechaVencimiento As Date = Operaciones.ConvertirFecha(dr("FCompra").ToString)
  642. Dim Dias As Integer = Operaciones.ConvertirEntero(dr("Dias").ToString)
  643. FechaVencimiento = FechaVencimiento.AddDays(Dias)
  644. FechaVencimientoFormatoCadena = Format(FechaVencimiento, "dd/MM/yyyy")
  645. dtpFechaCompra.Value = Operaciones.ConvertirFecha(dr("FCompra").ToString)
  646. If (dr("IOF")) Then
  647. Activo = 1
  648. Else
  649. Activo = 0
  650. End If
  651. If (dr("Renta")) Then
  652. ActivoRenta = 1
  653. Else
  654. ActivoRenta = 0
  655. End If
  656. Dim ComisionCasa As Double = 0
  657. Dim ComisionBolsa As Double = 0
  658. ComisionCasa = Operaciones.ConvertirDecimal(dr("ComisionCasa").ToString)
  659. ComisionBolsa = Operaciones.ConvertirDecimal(dr("ComisionBolsa").ToString)
  660. ValorTransado = Operaciones.ConvertirDecimal(dr("ValTrans").ToString)
  661. CostoTransferencia = Operaciones.ConvertirDecimal(dr("CostoTransfr").ToString)
  662. Nombre = dr("Nombre").ToString
  663. FechaCompra = Operaciones.ConvertirFecha(dr("FCompra").ToString)
  664. CasaCorredora = dr("Casa").ToString
  665. Correlativo = Operaciones.ConvertirEntero(dr("codigo").ToString)
  666. If Tabla = "REP0VENTA" Then
  667. dgvReportos.Rows.Add("", ValorTransado, Dias,
  668. FechaVencimientoFormatoCadena, Rendimiento, 0, 0, 0,
  669. 0, 0, 0, 0, 0, 0, CostoTransferencia, ActivoRenta, "",
  670. "", "", Nombre, FechaCompra, ComisionCasa,
  671. ComisionBolsa, CasaCorredora, Correlativo, "", EstadoIOF, EstadoRenta)
  672. End If
  673. End While
  674. End If
  675. End Sub
  676. Function ObtenerDatos(ByVal Index As Integer)
  677. Dim coleccion As New Collection
  678. Dim Renta, IOF, Nombre, FCompra, ValTrans, Dias, FVenc, Rend, CostoTransfr, codigo, ComisionCasa, ComisionBolsa, Casa, Casa2
  679. Dim EstadoIOF, EstadoRenta
  680. If Variables.Codigo.IndexOf("REPO") > -1 Or Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  681. Dim ComisionCasaValor, ComisionBolsaValor, IOFValor, OtrosCostos, TotalCostos, MontoLiq
  682. Dim IntGenerar, RendAntImp, RendDesImp, ImpLiq, IngrNet, ValorNet
  683. ValorNet = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Neto").Value.ToString)
  684. IngrNet = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Ingreso Neto").Value.ToString)
  685. ImpLiq = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value)
  686. RendDesImp = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("R% Neto (Despues de Impuesto)").Value)
  687. RendAntImp = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("R% Neto (Antes de Impuesto)").Value)
  688. IntGenerar = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Interes a Genrerar").Value)
  689. MontoLiq = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Monto a Liquidar").Value)
  690. TotalCostos = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Total Costos").Value)
  691. OtrosCostos = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Otros Costos").Value)
  692. IOFValor = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("IOF").Value)
  693. ComisionBolsaValor = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision Bolsa").Value)
  694. ComisionCasaValor = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Comision CB").Value)
  695. Nombre = dgvReportos.Rows(Index).Cells("Nombre").Value.ToString
  696. FCompra = Operaciones.ConvertirFechaBaseDatos(dgvReportos.Rows(Index).Cells("FCompra").Value)
  697. ValTrans = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Valor Trasado").Value)
  698. Dias = Operaciones.ConvertirEntero(dgvReportos.Rows(Index).Cells("Dias").Value)
  699. FVenc = Operaciones.ConvertirFecha(dgvReportos.Rows(Index).Cells("Fecha de Vencimiento").Value)
  700. Rend = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Rendimiento").Value)
  701. CostoTransfr = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("Costo de Transferencia").Value)
  702. codigo = dgvReportos.Rows(Index).Cells("Codigo").Value.ToString
  703. ComisionCasa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionCasa").Value)
  704. ComisionBolsa = Operaciones.ConvertirDecimal(dgvReportos.Rows(Index).Cells("ComisionBolsa").Value)
  705. Casa = dgvReportos.Rows(Index).Cells("Casa").Value.ToString
  706. If (Not dgvReportos.Rows(Index).Cells("IOF").Value = 0) Then
  707. IOF = 1
  708. Else
  709. IOF = 0
  710. End If
  711. If (Not dgvReportos.Rows(Index).Cells("Impuesto de Liquidacion").Value = 0) Then
  712. Renta = 1
  713. Else
  714. Renta = 0
  715. End If
  716. If (dgvReportos.Rows(Index).Cells("EstadoIOF").Value = 1) Then
  717. EstadoIOF = 1
  718. Else
  719. EstadoIOF = 0
  720. End If
  721. If (dgvReportos.Rows(Index).Cells("EstadoRenta").Value = 1) Then
  722. EstadoRenta = 1
  723. Else
  724. EstadoRenta = 0
  725. End If
  726. coleccion.Add(Nombre)
  727. coleccion.Add(FCompra)
  728. coleccion.Add(ValTrans)
  729. coleccion.Add(Dias)
  730. coleccion.Add(FVenc)
  731. coleccion.Add(Rend)
  732. coleccion.Add(CostoTransfr)
  733. coleccion.Add(codigo)
  734. coleccion.Add(ComisionCasa)
  735. coleccion.Add(ComisionBolsa)
  736. coleccion.Add(Casa)
  737. coleccion.Add(IOF)
  738. coleccion.Add(Renta)
  739. coleccion.Add(Base)
  740. coleccion.Add(ComisionCasaValor)
  741. coleccion.Add(ComisionBolsaValor)
  742. coleccion.Add(IOFValor)
  743. coleccion.Add(OtrosCostos)
  744. coleccion.Add(TotalCostos)
  745. coleccion.Add(MontoLiq)
  746. coleccion.Add(IntGenerar)
  747. coleccion.Add(RendAntImp)
  748. coleccion.Add(RendDesImp)
  749. coleccion.Add(ImpLiq)
  750. coleccion.Add(IngrNet)
  751. coleccion.Add(ValorNet)
  752. coleccion.Add(EstadoIOF)
  753. coleccion.Add(EstadoRenta)
  754. End If
  755. Return coleccion
  756. End Function
  757. 'GETS
  758. Private Sub dgvReportos_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvReportos.CellEndEdit
  759. CorrelativoSinBD()
  760. Correlativo()
  761. Calculos()
  762. End Sub
  763. Private Sub dtpFechaCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaCompra.ValueChanged
  764. Formato()
  765. IngresarDatos()
  766. Modificado = True
  767. Calculos()
  768. End Sub
  769. Private Sub dgvReportos_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvReportos.CellClick
  770. IOFRentaEstado()
  771. IngresarDatosReves()
  772. NuevaFila()
  773. Dim Index = Operaciones.ConvertirEntero(dgvReportos.CurrentRow.Cells("codigo").Value)
  774. CargarFecha()
  775. Calculos()
  776. Formato()
  777. End Sub
  778. Private Sub dgvReportos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvReportos.CellContentClick
  779. End Sub
  780. Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click
  781. End Sub
  782. Private Sub txtCodigoTitulo_TextChanged(sender As Object, e As EventArgs) Handles txtCodigoTitulo.TextChanged
  783. Modificado = True
  784. End Sub
  785. Private Sub txtIOF_TextChanged(sender As Object, e As EventArgs)
  786. End Sub
  787. Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
  788. btnAccion.Text = "Modificar"
  789. Estado = "M"
  790. End Sub
  791. Sub NuevoIngreso(ByVal AgregarModificar As Boolean, ByVal Cantidad As Integer, ByVal Tabla As String)
  792. Dim i As Integer = 0
  793. Dim Index = dgvReportos.Rows.Count - 2
  794. i = Cantidad
  795. While i <= Index
  796. Dim coleccion = ObtenerDatos(i)
  797. If ReportoConsula.Nuevo(coleccion, Codigo, Tabla) Is Nothing Then
  798. Exit Sub
  799. End If
  800. i += 1
  801. End While
  802. MsgBox("Reportos actualizados")
  803. End Sub
  804. Function NuevoIngresoColeccion()
  805. Dim i As Integer = 0
  806. Dim Index = dgvReportos.Rows.Count - 2
  807. Dim diccionario As New Dictionary(Of String, Collection)
  808. While i <= Index
  809. Dim coleccion = ObtenerDatos(i)
  810. diccionario.Add(i, coleccion)
  811. i += 1
  812. End While
  813. Return diccionario
  814. End Function
  815. Private Sub btnAccion_Click(sender As Object, e As EventArgs) Handles btnAccion.Click
  816. LlenarBase()
  817. Dim Codigo = Variables.Codigo
  818. Dim diccionario As Dictionary(Of String, Collection) = NuevoIngresoColeccion()
  819. If (Estado = "N") Then
  820. ReportoConsula.ProcesoDatos(diccionario, Codigo, Tabla)
  821. ValidarExistencia()
  822. ElseIf Not ExisteValidacion() Then
  823. Variables.ColeccionREPO = diccionario
  824. Me.Close()
  825. ElseIf (Estado = "M") Then
  826. ReportoConsula.ProcesoDatos(diccionario, Codigo, Tabla)
  827. ValidarExistencia()
  828. ElseIf (Estado = "B") Then
  829. QuitarFila()
  830. ValidarExistencia()
  831. End If
  832. End Sub
  833. Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
  834. btnAccion.Text = "Agregar"
  835. Estado = "N"
  836. End Sub
  837. Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
  838. btnAccion.Text = "Eliminar"
  839. Estado = "B"
  840. End Sub
  841. Private Sub Button1_Click(sender As Object, e As EventArgs)
  842. End Sub
  843. Private Sub btnAgregarImpuesto_Click(sender As Object, e As EventArgs)
  844. End Sub
  845. Private Sub dgvImpuestos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
  846. End Sub
  847. Private Sub TabPage3_Click(sender As Object, e As EventArgs) Handles TbImpuestos.Click
  848. End Sub
  849. Private Sub dgvImpuestoAgregado_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
  850. End Sub
  851. Private Sub btnQuitar_Click(sender As Object, e As EventArgs)
  852. End Sub
  853. Private Sub FlpIOF_Click(sender As Object, e As EventArgs) Handles FlpIOF.Click
  854. End Sub
  855. Private Sub FlpIOF_MouseClick(sender As Object, e As MouseEventArgs) Handles FlpIOF.MouseClick
  856. End Sub
  857. Private Sub FlpIOF_ChangeUICues(sender As Object, e As UICuesEventArgs) Handles FlpIOF.ChangeUICues
  858. End Sub
  859. Private Sub FlpIOF_Paint(sender As Object, e As PaintEventArgs) Handles FlpIOF.Paint
  860. End Sub
  861. Private Sub txtComisionCasa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionCasa.KeyPress
  862. If String.IsNullOrEmpty(txtComisionCasa.Text.ToString.Trim("%")) Then
  863. If e.KeyChar = "." Then
  864. txtComisionCasa.Text = "0.0%"
  865. Exit Sub
  866. End If
  867. End If
  868. If (Not txtComisionCasa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  869. Operaciones.ValidarEntrada(sender, e, True)
  870. Else
  871. Operaciones.ValidarEntrada(sender, e, False)
  872. End If
  873. End Sub
  874. Private Sub txtComisionBolsa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionBolsa.KeyPress
  875. If String.IsNullOrEmpty(txtComisionBolsa.Text.ToString.Trim("%")) Then
  876. If e.KeyChar = "." Then
  877. txtComisionBolsa.Text = "0.2825%"
  878. Exit Sub
  879. End If
  880. End If
  881. If (Not txtComisionBolsa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  882. Operaciones.ValidarEntrada(sender, e, True)
  883. Else
  884. Operaciones.ValidarEntrada(sender, e, False)
  885. End If
  886. End Sub
  887. Private Sub BindingNavigator1_RefreshItems(sender As Object, e As EventArgs) Handles BindingNavigator1.RefreshItems
  888. End Sub
  889. Private Sub txtComisionCasa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionCasa.TextChanged
  890. IngresarDatos()
  891. Modificado = True
  892. Calculos()
  893. End Sub
  894. Private Sub txtComisionBolsa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionBolsa.TextChanged
  895. IngresarDatos()
  896. Modificado = True
  897. Calculos()
  898. End Sub
  899. Private Sub txtDias_TextChanged(sender As Object, e As EventArgs) Handles txtDias.TextChanged
  900. IngresarDatos()
  901. Modificado = True
  902. Calculos()
  903. End Sub
  904. Private Sub cboCasaCorredora_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboCasaCorredora.SelectedIndexChanged
  905. Modificado = True
  906. IngresarDatos()
  907. End Sub
  908. Private Sub txtCodigoTitulo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtCodigoTitulo.KeyPress
  909. End Sub
  910. Private Sub txtDias_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtDias.KeyPress
  911. If String.IsNullOrEmpty(txtDias.Text) Then
  912. If e.KeyChar = "." Then
  913. txtDias.Text = "0"
  914. Exit Sub
  915. End If
  916. End If
  917. If (Not txtDias.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  918. Operaciones.ValidarEntrada(sender, e, True)
  919. Else
  920. Operaciones.ValidarEntrada(sender, e, False)
  921. End If
  922. End Sub
  923. Private Sub txtCodigoTitulo_KeyUp(sender As Object, e As KeyEventArgs) Handles txtCodigoTitulo.KeyUp
  924. IngresarDatos()
  925. End Sub
  926. Private Sub txtComisionCasa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionCasa.KeyUp
  927. If txtComisionCasa.Text = "." Then
  928. txtComisionCasa.Text = ".0%"
  929. End If
  930. IngresarDatos()
  931. Calculos()
  932. End Sub
  933. Private Sub txtComisionBolsa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionBolsa.KeyUp
  934. If txtComisionBolsa.Text = "." Then
  935. txtComisionBolsa.Text = ".0%"
  936. End If
  937. IngresarDatos()
  938. Calculos()
  939. End Sub
  940. Sub ValidarExistencia()
  941. Dim General As New DAOGeneral
  942. Dim Codigo As String = Variables.Codigo
  943. Dim Tabla As String = String.Empty
  944. If Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  945. Tabla = "REP0VENTA"
  946. ElseIf Variables.Codigo.IndexOf("REPO") > -1 Then
  947. Tabla = "REP0"
  948. End If
  949. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  950. If (Existe) Then
  951. navNuevo.Enabled = False
  952. navModificar.Enabled = True
  953. navEliminar.Enabled = True
  954. Else
  955. navNuevo.Enabled = True
  956. navModificar.Enabled = False
  957. navEliminar.Enabled = False
  958. End If
  959. Estado = String.Empty
  960. btnAccion.Text = "Aceptar"
  961. End Sub
  962. Function ExisteValidacion()
  963. Dim General As New DAOGeneral
  964. Dim Codigo As String = Variables.Codigo
  965. Dim Tabla As String = String.Empty
  966. If Variables.Codigo.IndexOf("REPOVENTA") > -1 Then
  967. Tabla = "REP0VENTA"
  968. ElseIf Variables.Codigo.IndexOf("REPO") > -1 Then
  969. Tabla = "REP0"
  970. End If
  971. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  972. Return Existe
  973. End Function
  974. Private Sub btnGuardar_Click(sender As Object, e As EventArgs)
  975. End Sub
  976. Private Sub dgvReportos_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) Handles dgvReportos.CellBeginEdit
  977. CorrelativoSinBD()
  978. Correlativo()
  979. End Sub
  980. Private Sub txtDias_KeyUp(sender As Object, e As KeyEventArgs) Handles txtDias.KeyUp
  981. If txtDias.Text = "." Then
  982. txtDias.Text = ".0"
  983. End If
  984. IngresarDatos()
  985. Calculos()
  986. End Sub
  987. Private Sub cboAnioBase_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboAnioBase.SelectedIndexChanged
  988. LlenarBase()
  989. IngresarDatos()
  990. Modificado = True
  991. Calculos()
  992. End Sub
  993. Private Sub txtDias_Leave(sender As Object, e As EventArgs) Handles txtDias.Leave
  994. Formato()
  995. End Sub
  996. Private Sub txtComisionCasa_Leave(sender As Object, e As EventArgs) Handles txtComisionCasa.Leave
  997. Formato()
  998. End Sub
  999. Private Sub txtComisionBolsa_Leave(sender As Object, e As EventArgs) Handles txtComisionBolsa.Leave
  1000. Formato()
  1001. End Sub
  1002. Private Sub frmReporto_Resize(sender As Object, e As EventArgs) Handles MyBase.Resize
  1003. dgvReportos.Width = Me.Width - 10
  1004. dgvReportos.Height = Me.Height - 290
  1005. End Sub
  1006. Private Sub ChkIOF_CheckedChanged(sender As Object, e As EventArgs) Handles ChkIOF.CheckedChanged
  1007. IOFRentaEstado()
  1008. Modificado = True
  1009. IngresarDatos()
  1010. Calculos()
  1011. End Sub
  1012. Private Sub ChkRenta_CheckedChanged(sender As Object, e As EventArgs) Handles ChkRenta.CheckedChanged
  1013. IOFRentaEstado()
  1014. Modificado = True
  1015. IngresarDatos()
  1016. Calculos()
  1017. End Sub
  1018. Private Sub txtCodigoInstrumento_TextChanged(sender As Object, e As EventArgs) Handles txtCodigoInstrumento.TextChanged
  1019. IngresarDatos()
  1020. Modificado = True
  1021. Calculos()
  1022. End Sub
  1023. Sub SeleccionarInstrumento()
  1024. Dim frmInstrumentos As New frmSeleccionTitulosReportos
  1025. frmInstrumentos.Show()
  1026. End Sub
  1027. Private Sub btnSaldoDisponible_Click(sender As Object, e As EventArgs)
  1028. SeleccionarInstrumento()
  1029. End Sub
  1030. Private Sub btnRequisicion_Click(sender As Object, e As EventArgs)
  1031. End Sub
  1032. Sub CargarTransladoNuevo()
  1033. Dim Existe As Boolean = ExisteInversion()
  1034. If Not RetCodigoInversionExiste And Not Existe Then
  1035. If dgvReportos.Rows(0).Cells("Valor Trasado").Value = 0 Then
  1036. dgvReportos.Rows(0).Cells("Valor Trasado").Value = Variables.RetMonto
  1037. End If
  1038. End If
  1039. End Sub
  1040. End Class