frmRendimientoFiltro.vb 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257
  1. Public Class frmRendimientoFiltro
  2. Private Rendimiento As New Rendimientos
  3. Dim Operaciones As New Operaciones
  4. Dim MontoACC As String = String.Empty
  5. Dim MontoLET As String = String.Empty
  6. Dim MontoCET As String = String.Empty
  7. Dim MontoPBUR As String = String.Empty
  8. Dim MontoVCN As String = String.Empty
  9. Dim MontoBON As String = String.Empty
  10. Dim MontoCINV As String = String.Empty
  11. Dim MontoEURB As String = String.Empty
  12. Dim MontoTIT As String = String.Empty
  13. Dim MontoDAP As String = String.Empty
  14. Dim MontoFUT As String = String.Empty
  15. Dim MontoOPC As String = String.Empty
  16. Dim MontoPPER As String = String.Empty
  17. Dim MontoPEMP As String = String.Empty
  18. Dim MontoREP As String = String.Empty
  19. Dim Lista As String = String.Empty
  20. Dim ListaEmpresa As String = String.Empty
  21. Dim ListaInstrumentos As String = String.Empty
  22. Dim ListaNacionalidad As String = String.Empty
  23. Dim ListaEstado As String = String.Empty
  24. Dim ListaVigencia As String = String.Empty
  25. Dim ListaTipoRenta As String = String.Empty
  26. Dim ListaAgrupada As String = String.Empty
  27. Private TipoFecha As String = "N"
  28. Private SoloFecha As Date = Date.Now.Date
  29. Private FechaInicial As Date = Date.Now.Date
  30. Private FechaFinal As Date = Date.Now.Date
  31. Private Portafolio As String = "Activo"
  32. Private chk_PortafolioSinRenta As String = "Activo"
  33. Private rdb_VerRendimiento As String = "Todos"
  34. Private NuevoCheckEmpresa As Boolean = True
  35. Private Sub lblTitulo_Click(sender As Object, e As EventArgs) Handles lblTitulo.Click
  36. End Sub
  37. Private Sub CheckBox6_CheckedChanged(sender As Object, e As EventArgs) Handles chkPortafolioSinRenta.CheckedChanged
  38. If chkPortafolioSinRenta.Checked Then
  39. chk_PortafolioSinRenta = "Activo"
  40. Else
  41. chk_PortafolioSinRenta = "Desactivo"
  42. End If
  43. End Sub
  44. Sub CargarDatos()
  45. Dim dt As New DataTable
  46. ActualizarListas()
  47. dt = Rendimiento.TraerRendimientos(TipoFecha, FechaInicial, FechaFinal, ListaEmpresa, ListaInstrumentos, ListaTipoRenta, ListaNacionalidad, ListaVigencia, ListaEstado, SoloFecha, Lista)
  48. CalcularCamposGenerales(dt)
  49. AgregarPorcentajeRendGeneral(dt)
  50. dgvRendimientos.DataSource = dt
  51. OcultarColumnas()
  52. End Sub
  53. Sub AgregarPorcentajeRendGeneral(ByRef dt As DataTable)
  54. For Each rows As DataRow In dt.Rows
  55. If Not dt.Columns("Rendimientos") Is Nothing Then
  56. rows("Rendimientos") = (Operaciones.ConvertirDecimal(rows("Rendimientos").ToString) * 100).ToString + " %"
  57. End If
  58. If Not dt.Columns("Peso") Is Nothing Then
  59. rows("Peso") = (Operaciones.ConvertirDecimal(rows("Peso").ToString) * 100).ToString + " %"
  60. End If
  61. If Not dt.Columns("RendimientoActual") Is Nothing Then
  62. rows("RendimientoActual") = (Operaciones.ConvertirDecimal(rows("RendimientoActual").ToString) * 100).ToString + " %"
  63. End If
  64. Next
  65. End Sub
  66. Sub CalcularCamposGenerales(ByRef dt As DataTable)
  67. Dim MontoInversion As Double = 0
  68. Dim Rendimiento As Double = 0
  69. Dim Peso As Double = 0
  70. Dim RendimientoSumaProducto As Double = 0
  71. Dim SumaProducto As Double = 0
  72. For Each rows As DataRow In dt.Rows
  73. MontoInversion += Operaciones.ConvertirDecimal(rows("Monto").ToString)
  74. Rendimiento += Operaciones.ConvertirDecimal(rows("Rendimientos").ToString)
  75. RendimientoSumaProducto = Operaciones.ConvertirDecimal(rows("Rendimientos").ToString)
  76. Peso = Operaciones.ConvertirDecimal(rows("Peso").ToString)
  77. SumaProducto += RendimientoSumaProducto * Peso
  78. Next
  79. txtPortTotal.Text = MontoInversion
  80. txtRendimientos.Text = (Rendimiento * 100).ToString + " %"
  81. txtRendSumaProducto.Text = (SumaProducto * 100).ToString + " %"
  82. End Sub
  83. Function EmpresaSeleccionada(ByVal NombreEmpresa As String)
  84. Dim xCheckBox As New Control
  85. Dim Activa As Boolean = False
  86. For Each xCheckBox In Me.flpEmpresa.Controls
  87. If TypeOf xCheckBox Is CheckBox Then
  88. If xCheckBox.Name = NombreEmpresa Then
  89. If xCheckBox.BackColor.Name.ToString = "ffeaeae8" Then
  90. Activa = True
  91. Else
  92. Activa = False
  93. End If
  94. End If
  95. End If
  96. Next
  97. Return Activa
  98. End Function
  99. Function InstrumentosSeleccionados(ByVal NombreInstrumentos As String)
  100. Dim xCheckBox As New Control
  101. Dim Activa As Boolean = False
  102. For Each xCheckBox In Me.flpInstrumento.Controls
  103. If TypeOf xCheckBox Is CheckBox Then
  104. If xCheckBox.Name = NombreInstrumentos Then
  105. If xCheckBox.BackColor.Name.ToString = "ffeaeae8" Then
  106. Activa = True
  107. Else
  108. Activa = False
  109. End If
  110. End If
  111. End If
  112. Next
  113. Return Activa
  114. End Function
  115. Function EstadoInternacionales(ByRef NombrePais As String)
  116. Dim Paises As String = "Todos"
  117. Dim Activo As Boolean = False
  118. If rdbInternacionales.Checked Then
  119. Paises = "Intl"
  120. ElseIf rdbNacionales.Checked Then
  121. Paises = "SV"
  122. Else
  123. Paises = "Todos"
  124. End If
  125. If Paises = "Intl" Then
  126. If NombrePais = "SV" Then
  127. Activo = False
  128. Else
  129. Activo = True
  130. End If
  131. ElseIf Paises = "SV" Then
  132. If NombrePais = "SV" Then
  133. Activo = True
  134. Else
  135. Activo = False
  136. End If
  137. ElseIf Paises = "Todos" Then
  138. Activo = True
  139. End If
  140. Return Activo
  141. End Function
  142. Function CalculoActivo(ByVal MontoValor As Double)
  143. Dim MontoTotal As Double = 0
  144. Dim ValidarMonto As Double = 0
  145. Dim Total As Double = 0
  146. If String.IsNullOrEmpty(txtPortTotal.Text) Then
  147. MontoTotal = txtPortTotal.Text
  148. End If
  149. If String.IsNullOrEmpty(MontoValor) Then
  150. ValidarMonto = MontoValor
  151. End If
  152. Total = MontoTotal + ValidarMonto
  153. Return Total
  154. End Function
  155. Private Sub frmRendimientoTotal_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  156. TipoRendimiento()
  157. AgregarCheckboxEmpresa()
  158. AgregarCheckboxInstrumento()
  159. CargarDatos()
  160. End Sub
  161. Sub AgregarCheckboxEmpresa()
  162. Dim diccionario As New Dictionary(Of String, String)
  163. diccionario = Rendimiento.Empresas
  164. For Each Empresa In diccionario
  165. Dim Empre As New CheckBox
  166. Dim Existe As Boolean = False
  167. Dim NombreEmpresa = Empresa.Value
  168. For Each item As CheckBox In flpEmpresa.Controls
  169. If item.Text.ToString = NombreEmpresa.ToString Then
  170. Existe = True
  171. End If
  172. Next
  173. If Not Existe Then
  174. Empre.Name = Empresa.Key
  175. Empre.Checked = True
  176. Empre.Width = 250
  177. Empre.BackColor = ColorTranslator.FromHtml("#EAEAE8")
  178. Empre.Text = NombreEmpresa
  179. flpEmpresa.Controls.Add(Empre)
  180. AddHandler Empre.Click, AddressOf eventoEmpresa
  181. AddHandler Empre.CheckedChanged, AddressOf ColoreventoEmpresa
  182. End If
  183. Existe = False
  184. Next
  185. Dim Empres As New CheckBox
  186. Empres.Name = "TodosEmpresa"
  187. Empres.Checked = True
  188. Empres.Width = 250
  189. Empres.BackColor = ColorTranslator.FromHtml("#EAEAE8")
  190. Empres.Text = "Todos las Empresas"
  191. flpEmpresa.Controls.Add(Empres)
  192. AddHandler Empres.Click, AddressOf eventoEmpresa
  193. AddHandler Empres.CheckedChanged, AddressOf ColoreventoEmpresa
  194. End Sub
  195. Sub AgregarCheckboxInstrumento()
  196. Dim diccionario As New Dictionary(Of String, String)
  197. diccionario = Rendimiento.Instrumentos
  198. For Each Instrumento In diccionario
  199. Dim Ins As New CheckBox
  200. Dim Existe As Boolean = False
  201. Dim NombreInstrumento = Instrumento.Value
  202. For Each item As CheckBox In flpInstrumento.Controls
  203. If item.Text.ToString = NombreInstrumento.ToString Then
  204. Existe = True
  205. End If
  206. Next
  207. If Not Existe Then
  208. Ins.Name = Instrumento.Key
  209. Ins.Checked = True
  210. Ins.Width = 250
  211. Ins.BackColor = ColorTranslator.FromHtml("#EAEAE8")
  212. Ins.Text = NombreInstrumento
  213. flpInstrumento.Controls.Add(Ins)
  214. AddHandler Ins.Click, AddressOf eventoInstrumento
  215. AddHandler Ins.CheckedChanged, AddressOf ColoreventoInstrumento
  216. End If
  217. Existe = False
  218. Next
  219. Dim Insi As New CheckBox
  220. Insi.Name = "TodosInstrumentos"
  221. Insi.Checked = True
  222. Insi.Width = 250
  223. Insi.BackColor = ColorTranslator.FromHtml("#EAEAE8")
  224. Insi.Text = "Todos los Instrumentos"
  225. flpInstrumento.Controls.Add(Insi)
  226. AddHandler Insi.Click, AddressOf eventoInstrumento
  227. AddHandler Insi.CheckedChanged, AddressOf ColoreventoInstrumento
  228. End Sub
  229. Sub eventoEmpresa(sender As Object, e As EventArgs)
  230. If sender.name = "TodosEmpresa" Then
  231. CambioCheckTodosEmpresa()
  232. Else
  233. TodosCheckEmpresa(sender, e)
  234. End If
  235. End Sub
  236. Sub eventoInstrumento(sender As Object, e As EventArgs)
  237. If sender.name = "TodosInstrumentos" Then
  238. CambioCheckTodosinstrumentos()
  239. Else
  240. TodosCheckInstrumentos(sender, e)
  241. End If
  242. End Sub
  243. Sub ColoreventoEmpresa(sender As Object, e As EventArgs)
  244. If (sender.checked) Then
  245. sender.BackColor = ColorTranslator.FromHtml("#EAEAE8")
  246. Else
  247. sender.BackColor = ColorTranslator.FromHtml("Transparent")
  248. End If
  249. End Sub
  250. Sub ColoreventoInstrumento(sender As Object, e As EventArgs)
  251. If (sender.checked) Then
  252. sender.BackColor = ColorTranslator.FromHtml("#EAEAE8")
  253. Else
  254. sender.BackColor = ColorTranslator.FromHtml("Transparent")
  255. End If
  256. End Sub
  257. Sub CambioCheckTodosEmpresa()
  258. Dim ContadorPrimario As Integer = Me.flpEmpresa.Controls.Count - 1
  259. Dim UltimoCheck As Boolean = True
  260. For Each xCheckBox In Me.flpEmpresa.Controls
  261. If TypeOf xCheckBox Is CheckBox Then
  262. Dim yCheckBox As New CheckBox
  263. yCheckBox = xCheckBox
  264. If xCheckBox.TabIndex = ContadorPrimario Then
  265. If Not yCheckBox.Checked Then
  266. UltimoCheck = False
  267. End If
  268. End If
  269. End If
  270. Next
  271. If UltimoCheck Then
  272. For Each xCheckBox In Me.flpEmpresa.Controls
  273. If TypeOf xCheckBox Is CheckBox Then
  274. Dim yCheckBox As New CheckBox
  275. yCheckBox = xCheckBox
  276. yCheckBox.Checked = True
  277. End If
  278. Next
  279. ElseIf Not UltimoCheck Then
  280. For Each xCheckBox In Me.flpEmpresa.Controls
  281. If TypeOf xCheckBox Is CheckBox Then
  282. Dim yCheckBox As New CheckBox
  283. yCheckBox = xCheckBox
  284. yCheckBox.Checked = False
  285. End If
  286. Next
  287. End If
  288. End Sub
  289. Sub TodosCheckEmpresa(sender As Object, e As EventArgs)
  290. Dim ContadorPrimario As Integer = Me.flpEmpresa.Controls.Count - 1
  291. Dim TodosCheck As Boolean = True
  292. If Not sender.name = "TodosEmpresa" Then
  293. For Each xCheckBox In Me.flpEmpresa.Controls
  294. If TypeOf xCheckBox Is CheckBox Then
  295. Dim yCheckBox As New CheckBox
  296. yCheckBox = xCheckBox
  297. If Not yCheckBox.TabIndex = ContadorPrimario Then
  298. If Not yCheckBox.Checked Then
  299. TodosCheck = False
  300. End If
  301. End If
  302. If yCheckBox.TabIndex = ContadorPrimario Then
  303. If Not TodosCheck Then
  304. yCheckBox.Checked = False
  305. Else
  306. yCheckBox.Checked = True
  307. End If
  308. End If
  309. End If
  310. Next
  311. End If
  312. End Sub
  313. ''''''''Instrumentos ''''''''''
  314. Sub CambioCheckTodosinstrumentos()
  315. Dim ContadorPrimario As Integer = Me.flpInstrumento.Controls.Count - 1
  316. Dim UltimoCheck As Boolean = True
  317. For Each xCheckBox In Me.flpInstrumento.Controls
  318. If TypeOf xCheckBox Is CheckBox Then
  319. Dim yCheckBox As New CheckBox
  320. yCheckBox = xCheckBox
  321. If xCheckBox.TabIndex = ContadorPrimario Then
  322. If Not yCheckBox.Checked Then
  323. UltimoCheck = False
  324. End If
  325. End If
  326. End If
  327. Next
  328. If UltimoCheck Then
  329. For Each xCheckBox In Me.flpInstrumento.Controls
  330. If TypeOf xCheckBox Is CheckBox Then
  331. Dim yCheckBox As New CheckBox
  332. yCheckBox = xCheckBox
  333. yCheckBox.Checked = True
  334. End If
  335. Next
  336. ElseIf Not UltimoCheck Then
  337. For Each xCheckBox In Me.flpInstrumento.Controls
  338. If TypeOf xCheckBox Is CheckBox Then
  339. Dim yCheckBox As New CheckBox
  340. yCheckBox = xCheckBox
  341. yCheckBox.Checked = False
  342. End If
  343. Next
  344. End If
  345. End Sub
  346. Sub TodosCheckInstrumentos(sender As Object, e As EventArgs)
  347. Dim ContadorPrimario As Integer = Me.flpInstrumento.Controls.Count - 1
  348. Dim TodosCheck As Boolean = True
  349. If Not sender.name = "TodosInstrumentos" Then
  350. For Each xCheckBox In Me.flpInstrumento.Controls
  351. If TypeOf xCheckBox Is CheckBox Then
  352. Dim yCheckBox As New CheckBox
  353. yCheckBox = xCheckBox
  354. If Not yCheckBox.TabIndex = ContadorPrimario Then
  355. If Not yCheckBox.Checked Then
  356. TodosCheck = False
  357. End If
  358. End If
  359. If yCheckBox.TabIndex = ContadorPrimario Then
  360. If Not TodosCheck Then
  361. yCheckBox.Checked = False
  362. Else
  363. yCheckBox.Checked = True
  364. End If
  365. End If
  366. End If
  367. Next
  368. End If
  369. End Sub
  370. Private Sub RadioButton3_CheckedChanged(sender As Object, e As EventArgs) Handles rdbAmbosRenta.CheckedChanged
  371. End Sub
  372. Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs)
  373. End Sub
  374. Private Sub rdbFecha_CheckedChanged(sender As Object, e As EventArgs) Handles rdbFecha.CheckedChanged
  375. If rdbFecha.Checked Then
  376. SoloFecha = dtpFecha.Value
  377. TipoFecha = "F"
  378. Else
  379. TipoFecha = "N"
  380. End If
  381. End Sub
  382. Private Sub rdbRangoFechas_CheckedChanged(sender As Object, e As EventArgs) Handles rdbRangoFechas.CheckedChanged
  383. If rdbRangoFechas.Checked Then
  384. TipoFecha = "FR"
  385. FechaInicial = dtpFechaInicial.Value
  386. FechaFinal = dtpFechaFinal.Value
  387. Else
  388. TipoFecha = "N"
  389. End If
  390. End Sub
  391. Private Sub rdbDeshabilitarFecha_CheckedChanged(sender As Object, e As EventArgs) Handles rdbDeshabilitarFecha.CheckedChanged
  392. If rdbDeshabilitarFecha.Checked Then
  393. TipoFecha = "N"
  394. End If
  395. End Sub
  396. Private Sub flpInstrumento_Paint(sender As Object, e As PaintEventArgs) Handles flpInstrumento.Paint
  397. End Sub
  398. Private Sub chkPortafolio_CheckedChanged(sender As Object, e As EventArgs) Handles chkPortafolio.CheckedChanged
  399. If chkPortafolio.Checked Then
  400. Portafolio = "Activo"
  401. Else
  402. Portafolio = "Desactivo"
  403. End If
  404. End Sub
  405. Private Sub chkPortafolioSinLiquidez_CheckedChanged(sender As Object, e As EventArgs) Handles chkPortafolioSinLiquidez.CheckedChanged
  406. End Sub
  407. Private Sub rdbVariable_CheckedChanged(sender As Object, e As EventArgs) Handles rdbVariable.CheckedChanged
  408. End Sub
  409. Private Sub rdbFija_CheckedChanged(sender As Object, e As EventArgs) Handles rdbFija.CheckedChanged
  410. End Sub
  411. Private Sub chkInternacional_CheckedChanged(sender As Object, e As EventArgs)
  412. End Sub
  413. Private Sub chkVigentes_CheckedChanged(sender As Object, e As EventArgs)
  414. End Sub
  415. Private Sub rdbPendientes_CheckedChanged(sender As Object, e As EventArgs) Handles rdbPendientes.CheckedChanged
  416. End Sub
  417. Private Sub rdbAprobado_CheckedChanged(sender As Object, e As EventArgs) Handles rdbAprobado.CheckedChanged
  418. End Sub
  419. Private Sub rdbRechazado_CheckedChanged(sender As Object, e As EventArgs) Handles rdbRechazado.CheckedChanged
  420. End Sub
  421. Private Sub rdbPAR_CheckedChanged(sender As Object, e As EventArgs) Handles rdbTodosEstado.CheckedChanged
  422. End Sub
  423. Private Sub rdbEmpresas_CheckedChanged(sender As Object, e As EventArgs)
  424. End Sub
  425. Private Sub rdbInstrumento_CheckedChanged(sender As Object, e As EventArgs)
  426. End Sub
  427. Private Sub rdbTiempo_CheckedChanged(sender As Object, e As EventArgs)
  428. End Sub
  429. Private Sub rdbTEI_CheckedChanged(sender As Object, e As EventArgs)
  430. End Sub
  431. Private Sub dgvRendimientos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvRendimientos.CellContentClick
  432. End Sub
  433. Private Sub TbRendimientos_Click(sender As Object, e As EventArgs) Handles TbRendimientoGeneral.Click
  434. End Sub
  435. Private Sub TbcRendimiento_TabIndexChanged(sender As Object, e As EventArgs) Handles TbcRendimiento.TabIndexChanged
  436. End Sub
  437. Private Sub TbcRendimiento_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TbcRendimiento.SelectedIndexChanged
  438. If rdbRendimientoGeneral.Checked Then
  439. If TbcRendimiento.SelectedIndex = 1 Then
  440. BloqueoPortafolio()
  441. CargarDatos()
  442. End If
  443. Else
  444. If TbcRendimiento.SelectedIndex = 1 Then
  445. BloqueoPortafolio()
  446. RendimientoMensual()
  447. End If
  448. End If
  449. End Sub
  450. Private Sub BloqueoPortafolio()
  451. If Portafolio = "Desactivo" Then
  452. lblPortTotal.Visible = False
  453. txtPortTotal.Visible = False
  454. Else
  455. lblPortTotal.Visible = True
  456. txtPortTotal.Visible = True
  457. End If
  458. End Sub
  459. Sub RendimientoMensual()
  460. Dim dt As New DataTable
  461. Dim TipoRendimiento As String = "Mensual"
  462. Dim Fecha1 As Date = dtpFechaInicialDiario.Value
  463. Dim Fecha2 As Date = dtpFechaFinalDiario.Value
  464. Dim Agrupado As String = String.Empty
  465. ActualizarListas()
  466. If String.IsNullOrEmpty(ListaAgrupada) Then
  467. Agrupado = "NO"
  468. Else
  469. Agrupado = "SI"
  470. End If
  471. dt = Rendimiento.CargarRendimientoDiario(Fecha1, Fecha2, TipoRendimiento, ListaEmpresa, ListaInstrumentos, ListaNacionalidad, ListaEstado,
  472. ListaVigencia, ListaTipoRenta, ListaAgrupada, Agrupado)
  473. AgregarPorcentajeRend(dt)
  474. dgvRendimientoMensual.DataSource = dt
  475. End Sub
  476. Sub AgregarPorcentajeRend(ByRef dt As DataTable)
  477. For Each rows As DataRow In dt.Rows
  478. rows("RendimientoTotal") = (Operaciones.ConvertirDecimal(rows("RendimientoTotal").ToString) * 100).ToString + " %"
  479. Next
  480. End Sub
  481. Sub AgregarPorcentajeRendDetalles(ByRef dt As DataTable)
  482. For Each rows As DataRow In dt.Rows
  483. If Not dt.Columns("Rendimiento") Is Nothing Then
  484. rows("Rendimiento") = (Operaciones.ConvertirDecimal(rows("Rendimiento").ToString) * 100).ToString + " %"
  485. End If
  486. If Not dt.Columns("RendimientoTotal") Is Nothing Then
  487. rows("RendimientoTotal") = (Operaciones.ConvertirDecimal(rows("RendimientoTotal").ToString) * 100).ToString + " %"
  488. End If
  489. If Not dt.Columns("Peso") Is Nothing Then
  490. rows("Peso") = (Operaciones.ConvertirDecimal(rows("Peso").ToString) * 100).ToString + " %"
  491. End If
  492. If Not dt.Columns("RendimientoPeso") Is Nothing Then
  493. rows("RendimientoPeso") = (Operaciones.ConvertirDecimal(rows("RendimientoPeso").ToString) * 100).ToString + " %"
  494. End If
  495. If Not dt.Columns("RendimientoGrupo") Is Nothing Then
  496. rows("RendimientoGrupo") = (Operaciones.ConvertirDecimal(rows("RendimientoGrupo").ToString) * 100).ToString + " %"
  497. End If
  498. Next
  499. End Sub
  500. Sub RendimientoDetalles()
  501. Dim dt As New DataTable
  502. Dim TipoRendimiento As String = "Detalles"
  503. ActualizarListas()
  504. Dim Fecha1 As Date = Date.Now.Date
  505. Dim Fecha2 As Date = Date.Now.Date
  506. Dim FechaAux As Date = Date.Now.Date
  507. Dim Agrupado As String = String.Empty
  508. Dim FechaInicial As Date = dtpFechaInicialDiario.Value
  509. Dim FechaFinal As Date = dtpFechaFinalDiario.Value
  510. If String.IsNullOrEmpty(ListaAgrupada) Then
  511. Agrupado = "NO"
  512. Else
  513. Agrupado = "SI"
  514. End If
  515. If rdbRendMensual.Checked Then
  516. If Not dgvRendimientoMensual.CurrentRow Is Nothing Then
  517. If String.IsNullOrEmpty(ListaAgrupada) Then
  518. Agrupado = "NO"
  519. Else
  520. Agrupado = "SI"
  521. End If
  522. If Not dgvRendimientoMensual.CurrentRow Is Nothing Then
  523. FechaAux = dgvRendimientoMensual.CurrentRow.Cells("FechaUltima").Value
  524. If FechaInicial.Month = FechaAux.Month And FechaInicial.Year = FechaAux.Year Then
  525. Fecha1 = FechaInicial
  526. Else
  527. Fecha1 = CDate("1/" + FechaAux.Month.ToString + "/" + FechaAux.Year.ToString)
  528. End If
  529. If FechaFinal.Month = FechaAux.Month And FechaFinal.Year = FechaAux.Year Then
  530. Fecha2 = FechaFinal
  531. Else
  532. Fecha2 = FechaAux
  533. End If
  534. End If
  535. dt = Rendimiento.CargarRendimientoDiario(Fecha1, Fecha2, TipoRendimiento, ListaEmpresa, ListaInstrumentos, ListaNacionalidad, ListaEstado,
  536. ListaVigencia, ListaTipoRenta, ListaAgrupada, Agrupado)
  537. AgregarPorcentajeRendDetalles(dt)
  538. dgvRendimientoDetalles.DataSource = dt
  539. Else
  540. MsgBox("Error al Cargar Registros")
  541. End If
  542. Else
  543. If Not dgvRendimientoDiario.CurrentRow Is Nothing Then
  544. FechaAux = dgvRendimientoDiario.CurrentRow.Cells("FechaIterada").Value
  545. Fecha1 = FechaAux
  546. Fecha2 = FechaAux
  547. dt = Rendimiento.CargarRendimientoDiario(Fecha1, Fecha2, TipoRendimiento, ListaEmpresa, ListaInstrumentos, ListaNacionalidad, ListaEstado,
  548. ListaVigencia, ListaTipoRenta, ListaAgrupada, Agrupado)
  549. AgregarPorcentajeRendDetalles(dt)
  550. dgvRendimientoDetalles.DataSource = dt
  551. Else
  552. MsgBox("Error al Cargar Registros")
  553. End If
  554. End If
  555. End Sub
  556. Sub RendimientoDiario()
  557. Dim dt As New DataTable
  558. Dim TipoRendimiento As String = "Diario"
  559. Dim Fecha1 As Date = Date.Now.Date
  560. Dim Fecha2 As Date = Date.Now.Date
  561. Dim FechaAux As Date = Date.Now.Date
  562. Dim Agrupado As String = String.Empty
  563. Dim FechaInicial As Date = dtpFechaInicialDiario.Value
  564. Dim FechaFinal As Date = dtpFechaFinalDiario.Value
  565. If String.IsNullOrEmpty(ListaAgrupada) Then
  566. Agrupado = "NO"
  567. Else
  568. Agrupado = "SI"
  569. End If
  570. If Not dgvRendimientoMensual.CurrentRow Is Nothing Then
  571. FechaAux = dgvRendimientoMensual.CurrentRow.Cells("FechaUltima").Value
  572. If FechaInicial.Month = FechaAux.Month And FechaInicial.Year = FechaAux.Year Then
  573. Fecha1 = FechaInicial
  574. Else
  575. Fecha1 = CDate("1/" + FechaAux.Month.ToString + "/" + FechaAux.Year.ToString)
  576. End If
  577. If FechaFinal.Month = FechaAux.Month And FechaFinal.Year = FechaAux.Year Then
  578. Fecha2 = FechaFinal
  579. Else
  580. Fecha2 = FechaAux
  581. End If
  582. dt = Rendimiento.CargarRendimientoDiario(Fecha1, Fecha2, TipoRendimiento, ListaEmpresa, ListaInstrumentos, ListaNacionalidad, ListaEstado,
  583. ListaVigencia, ListaTipoRenta, ListaAgrupada, Agrupado)
  584. AgregarPorcentajeRend(dt)
  585. dgvRendimientoDiario.DataSource = dt
  586. Else
  587. MsgBox("Error al Cargar Registros")
  588. End If
  589. End Sub
  590. Private Sub dtpFechaInicial_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaInicial.ValueChanged
  591. FechaInicial = dtpFechaInicial.Value
  592. FechaFinal = dtpFechaFinal.Value
  593. End Sub
  594. Private Sub dtpFechaFinal_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaFinal.ValueChanged
  595. FechaInicial = dtpFechaInicial.Value
  596. FechaFinal = dtpFechaFinal.Value
  597. End Sub
  598. Private Sub dtpFecha_ValueChanged(sender As Object, e As EventArgs) Handles dtpFecha.ValueChanged
  599. SoloFecha = dtpFecha.Value
  600. End Sub
  601. Private Sub rdbInternacionales_CheckedChanged(sender As Object, e As EventArgs) Handles rdbInternacionales.CheckedChanged
  602. End Sub
  603. Private Sub rdbVigente_CheckedChanged(sender As Object, e As EventArgs) Handles rdbVigente.CheckedChanged
  604. End Sub
  605. Private Sub rdbVencido_CheckedChanged(sender As Object, e As EventArgs) Handles rdbVencido.CheckedChanged
  606. End Sub
  607. Private Sub rdbVencidoAmbos_CheckedChanged(sender As Object, e As EventArgs) Handles rdbVencidoAmbos.CheckedChanged
  608. End Sub
  609. Private Sub rdbAmbosPais_CheckedChanged(sender As Object, e As EventArgs) Handles rdbAmbosPais.CheckedChanged
  610. End Sub
  611. Private Sub rdbNacionales_CheckedChanged(sender As Object, e As EventArgs) Handles rdbNacionales.CheckedChanged
  612. End Sub
  613. Private Sub txtPortTotal_TextChanged(sender As Object, e As EventArgs) Handles txtPortTotal.TextChanged
  614. End Sub
  615. Private Sub txtRendimientos_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientos.TextChanged
  616. End Sub
  617. Private Sub rdbRevision_CheckedChanged(sender As Object, e As EventArgs) Handles rdbRevision.CheckedChanged
  618. End Sub
  619. Private Sub rdbCancelada_CheckedChanged(sender As Object, e As EventArgs) Handles rdbCancelada.CheckedChanged
  620. End Sub
  621. Sub AgruparSeleccionado()
  622. Dim ListaAgrupada As String = String.Empty
  623. For Each check As CheckBox In grpAgrupamiento.Controls
  624. Dim Valor As String = String.Empty
  625. If check.Checked Then
  626. If check.Text = "Empresa" Then
  627. Valor = "Empresa"
  628. ElseIf check.Text = "Instrumento" Then
  629. Valor = "Instrumento"
  630. ElseIf check.Text = "Nacionalidad" Then
  631. Valor = "Nacionalidad"
  632. ElseIf check.Text = "Estado" Then
  633. Valor = "Estado"
  634. ElseIf check.Text = "Fecha" Then
  635. Valor = "Fecha"
  636. ElseIf check.Text = "TipoRenta" Then
  637. Valor = "TipoRenta"
  638. ElseIf check.Text = "Vigencia" Then
  639. Valor = "Vigencia"
  640. End If
  641. If String.IsNullOrEmpty(ListaAgrupada) Then
  642. ListaAgrupada = Valor
  643. Else
  644. ListaAgrupada += "," + Valor
  645. End If
  646. End If
  647. Next
  648. Lista = ListaAgrupada
  649. End Sub
  650. Private Sub chkEmpresa_CheckedChanged(sender As Object, e As EventArgs) Handles chkEmpresa.CheckedChanged
  651. AgruparSeleccionado()
  652. CargarDatos()
  653. End Sub
  654. Private Sub chkInstrumento_CheckedChanged(sender As Object, e As EventArgs) Handles chkInstrumento.CheckedChanged
  655. AgruparSeleccionado()
  656. CargarDatos()
  657. End Sub
  658. Private Sub chkNacionalidad_CheckedChanged(sender As Object, e As EventArgs) Handles chkNacionalidad.CheckedChanged
  659. AgruparSeleccionado()
  660. CargarDatos()
  661. End Sub
  662. Private Sub chkEstado_CheckedChanged(sender As Object, e As EventArgs) Handles chkEstado.CheckedChanged
  663. AgruparSeleccionado()
  664. CargarDatos()
  665. End Sub
  666. Private Sub chkFecha_CheckedChanged(sender As Object, e As EventArgs) Handles chkFecha.CheckedChanged
  667. AgruparSeleccionado()
  668. CargarDatos()
  669. End Sub
  670. Private Sub chkVigencia_CheckedChanged(sender As Object, e As EventArgs) Handles chkVigencia.CheckedChanged
  671. AgruparSeleccionado()
  672. CargarDatos()
  673. End Sub
  674. Private Sub chkTipoRenta_CheckedChanged(sender As Object, e As EventArgs) Handles chkTipoRenta.CheckedChanged
  675. AgruparSeleccionado()
  676. CargarDatos()
  677. End Sub
  678. Sub TipoRendimiento()
  679. If rdbRendimientoGeneral.Checked Then
  680. grpFechas.Enabled = True
  681. grpVigente.Enabled = True
  682. grpMostrarTotales.Enabled = True
  683. TbRendimientoDiario.Parent = Nothing
  684. TbRendimientoGeneral.Parent = TbcRendimiento
  685. Else
  686. grpFechas.Enabled = False
  687. grpVigente.Enabled = False
  688. grpMostrarTotales.Enabled = False
  689. TbRendimientoGeneral.Parent = Nothing
  690. TbRendimientoDiario.Parent = TbcRendimiento
  691. End If
  692. End Sub
  693. Private Sub rdbRendimientoGeneral_CheckedChanged(sender As Object, e As EventArgs) Handles rdbRendimientoGeneral.CheckedChanged
  694. TipoRendimiento()
  695. End Sub
  696. Private Sub rdbRendimientoDiario_CheckedChanged(sender As Object, e As EventArgs) Handles rdbRendimientoDiario.CheckedChanged
  697. TipoRendimiento()
  698. End Sub
  699. Sub OcultarColumnasRendimientoGenerar()
  700. If Not dgvRendimientoDetalles.Columns("CodigoEmpresa") Is Nothing Then
  701. dgvRendimientoDetalles.Columns("CodigoEmpresa").Visible = False
  702. End If
  703. If Not dgvRendimientoDetalles.Columns("CodigoInstrumento") Is Nothing Then
  704. dgvRendimientoDetalles.Columns("CodigoInstrumento").Visible = False
  705. End If
  706. If Not dgvRendimientoDetalles.Columns("Pais") Is Nothing Then
  707. dgvRendimientoDetalles.Columns("Pais").Visible = False
  708. End If
  709. End Sub
  710. Sub TipoRendimientoFecha()
  711. If rdbFecha.Checked Then
  712. TipoFecha = "F"
  713. ElseIf rdbRangoFechas.Checked Then
  714. TipoFecha = "FR"
  715. Else
  716. TipoFecha = "N"
  717. End If
  718. End Sub
  719. Sub ActualizarListas()
  720. EmpresaRendimientoDiario()
  721. InstrumentoRendimientoDiario()
  722. NacionalidadRendimientoDiario()
  723. EstadoRendimientoDiario()
  724. VigenciaRendimientoDiario()
  725. TipoRentaRendimientoDiario()
  726. AgruparRendimientoDiario()
  727. End Sub
  728. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  729. RendimientoDetalles()
  730. OcultarColumnasRendimientoGenerar()
  731. End Sub
  732. Private Sub btnVer_Click(sender As Object, e As EventArgs) Handles btnVer.Click
  733. RendimientoDiario()
  734. End Sub
  735. Sub EmpresaRendimientoDiario()
  736. Dim ListaAgrupada As String = String.Empty
  737. For Each check As CheckBox In flpEmpresa.Controls
  738. Dim Valor As String = String.Empty
  739. If check.Checked Then
  740. If Not check.Name.ToString = "TodosEmpresa" Then
  741. Valor = check.Name.ToString
  742. If String.IsNullOrEmpty(ListaAgrupada) Then
  743. ListaAgrupada = Valor
  744. Else
  745. ListaAgrupada += "," + Valor
  746. End If
  747. End If
  748. End If
  749. Next
  750. ListaEmpresa = ListaAgrupada
  751. End Sub
  752. Sub InstrumentoRendimientoDiario()
  753. Dim ListaAgrupada As String = String.Empty
  754. For Each check As CheckBox In flpInstrumento.Controls
  755. Dim Valor As String = String.Empty
  756. If check.Checked Then
  757. If Not check.Name.ToString = "TodosInstrumentos" Then
  758. Valor = check.Name.ToString
  759. If String.IsNullOrEmpty(ListaAgrupada) Then
  760. ListaAgrupada = Valor
  761. Else
  762. ListaAgrupada += "," + Valor
  763. End If
  764. End If
  765. End If
  766. Next
  767. ListaInstrumentos = ListaAgrupada
  768. End Sub
  769. Sub NacionalidadRendimientoDiario()
  770. If rdbNacionales.Checked Then
  771. ListaNacionalidad = "Nacional"
  772. ElseIf rdbInternacionales.Checked Then
  773. ListaNacionalidad = "Internacional"
  774. ElseIf rdbAmbosPais.Checked Then
  775. ListaNacionalidad = "Todos"
  776. End If
  777. End Sub
  778. Sub EstadoRendimientoDiario()
  779. If rdbVigente.Checked Then
  780. ListaEstado = "A"
  781. ElseIf rdbVencido.Checked Then
  782. ListaEstado = "C"
  783. ElseIf rdbVencidoAmbos.Checked Then
  784. ListaEstado = "A,C"
  785. End If
  786. End Sub
  787. Sub VigenciaRendimientoDiario()
  788. If rdbPendientes.Checked Then
  789. ListaVigencia = "P"
  790. ElseIf rdbRevision.Checked Then
  791. ListaVigencia = "V"
  792. ElseIf rdbAprobado.Checked Then
  793. ListaVigencia = "A"
  794. ElseIf rdbCancelada.Checked Then
  795. ListaVigencia = "C"
  796. ElseIf rdbRechazado.Checked Then
  797. ListaVigencia = "R"
  798. ElseIf rdbTodosEstado.Checked Then
  799. ListaVigencia = "P,C,V,A,R"
  800. End If
  801. End Sub
  802. Sub TipoRentaRendimientoDiario()
  803. If rdbVariable.Checked Then
  804. ListaTipoRenta = "V"
  805. ElseIf rdbFija.Checked Then
  806. ListaTipoRenta = "F"
  807. ElseIf rdbAmbosRenta.Checked Then
  808. ListaTipoRenta = "V,F"
  809. End If
  810. End Sub
  811. Sub AgruparRendimientoDiario()
  812. Dim ListaAgrupada As String = String.Empty
  813. For Each check As CheckBox In grpAgruparRendDiario.Controls
  814. Dim Valor As String = String.Empty
  815. If check.Checked Then
  816. If check.Text = "Empresa" Then
  817. Valor = "Empresa"
  818. ElseIf check.Text = "Instrumento" Then
  819. Valor = "Instrumento"
  820. ElseIf check.Text = "Nacionalidad" Then
  821. Valor = "Nacionalidad"
  822. ElseIf check.Text = "Estado" Then
  823. Valor = "Estado"
  824. ElseIf check.Text = "Fecha" Then
  825. Valor = "Fecha"
  826. ElseIf check.Text = "TipoRenta" Then
  827. Valor = "TipoRenta"
  828. ElseIf check.Text = "Vigencia" Then
  829. Valor = "Vigencia"
  830. End If
  831. If String.IsNullOrEmpty(ListaAgrupada) Then
  832. ListaAgrupada = Valor
  833. Else
  834. ListaAgrupada += "," + Valor
  835. End If
  836. End If
  837. Next
  838. Me.ListaAgrupada = ListaAgrupada
  839. End Sub
  840. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btnActualizar.Click
  841. ActualizarLimpiar()
  842. End Sub
  843. Private Sub TbRendimientoDiario_Click(sender As Object, e As EventArgs) Handles TbRendimientoDiario.Click
  844. End Sub
  845. Sub ActualizarLimpiar()
  846. dgvRendimientoDetalles.Columns.Clear()
  847. dgvRendimientoDiario.Columns.Clear()
  848. RendimientoMensual()
  849. End Sub
  850. Sub OcultarColumnas()
  851. If Not dgvRendimientos.Columns("CodigoEmpresa") Is Nothing Then
  852. dgvRendimientos.Columns("CodigoEmpresa").Visible = False
  853. End If
  854. If Not dgvRendimientos.Columns("CodigoInstrumento") Is Nothing Then
  855. dgvRendimientos.Columns("CodigoInstrumento").Visible = False
  856. End If
  857. If Not dgvRendimientos.Columns("CodigoPais") Is Nothing Then
  858. dgvRendimientos.Columns("CodigoPais").Visible = False
  859. End If
  860. End Sub
  861. End Class