frmDetallesPortafolioGeneralRendimiento.vb 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  1. Public Class frmDetallesPortafolioGeneralRendimiento
  2. Dim General As New DAOGeneral
  3. Dim Operaciones As New Operaciones
  4. Dim Rendimientos As New Rendimientos
  5. Dim dt As New DataTable
  6. Dim FinCargado As Boolean = False
  7. Dim ContinuarEmpresa As Boolean = True
  8. Dim ContinuarInstrumento As Boolean = True
  9. Dim Tipo As String = String.Empty
  10. Sub New()
  11. ' Esta llamada es exigida por el diseñador.
  12. InitializeComponent()
  13. ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
  14. End Sub
  15. Sub New(Tipo As String)
  16. Me.New
  17. Me.Tipo = Tipo
  18. End Sub
  19. Private Sub frmDetallesPortafolioGeneralRendimiento_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  20. CargarEmpresas()
  21. CargarInstrumento()
  22. CheckEmpresaTodos()
  23. CheckInstrumentoTodos()
  24. OcultarColumnas()
  25. FinCargado = True
  26. End Sub
  27. Sub CargarEmpresas()
  28. Dim dt As New DataTable
  29. dt = General.ListaEmpresas
  30. dt.Rows.Add("Todos", "Todos")
  31. chklEmpresas.DataSource = dt
  32. chklEmpresas.DisplayMember = "Descripcion"
  33. chklEmpresas.ValueMember = "Codigo"
  34. End Sub
  35. Sub CargarInstrumento()
  36. Dim dt As New DataTable
  37. dt = General.ListaInstrumentos("Propuesta")
  38. dt.Rows.Add("Todos", "Todos")
  39. chklInstrumentos.DataSource = dt
  40. chklInstrumentos.DisplayMember = "Descripcion"
  41. chklInstrumentos.ValueMember = "Codigo"
  42. End Sub
  43. Sub CheckEmpresaTodos()
  44. Dim Cantidad As Integer = chklEmpresas.Items.Count - 1
  45. Dim Index As Integer = 0
  46. While Index <= Cantidad
  47. chklEmpresas.SetItemChecked(Index, True)
  48. Index += 1
  49. End While
  50. End Sub
  51. Sub CheckInstrumentoTodos()
  52. Dim Cantidad As Integer = chklInstrumentos.Items.Count - 1
  53. Dim Index As Integer = 0
  54. While Index <= Cantidad
  55. chklInstrumentos.SetItemChecked(Index, True)
  56. Index += 1
  57. End While
  58. End Sub
  59. Sub Calcular(ByRef dtGeneral As DataTable, ByRef dtLista As DataTable, value As String, Index As Integer, e As ItemCheckEventArgs)
  60. If Tipo = "Empresa" Then
  61. Dim TituloCambio As String = String.Empty
  62. For Each Item As DataRowView In chklEmpresas.CheckedItems
  63. Dim valor1 As String = Item.Item(0).ToString
  64. For Each rows As DataRow In dtGeneral.Rows
  65. Dim valor2 As String = rows("CodigoEmpresa").ToString
  66. If Not String.IsNullOrEmpty(valor1) And Not String.IsNullOrEmpty(valor2) Then
  67. If ((valor1 = valor2 And Not (valor1 = value) And Not valor2 = TituloCambio)) Then
  68. dtLista.Rows.Add(rows("CodigoEmpresa").ToString,
  69. rows("Empresa").ToString,
  70. Operaciones.ConvertirDecimal(rows("Rendimiento").ToString),
  71. Operaciones.ConvertirDecimal(rows("Cantidad").ToString),
  72. Operaciones.ConvertirDecimal(rows("Monto").ToString),
  73. Operaciones.ConvertirDecimal(rows("MontoTotal").ToString),
  74. Operaciones.ConvertirDecimal(rows("Peso").ToString))
  75. ElseIf (Not valor1 = valor2 And valor2 = value And e.NewValue = CheckState.Checked) Then
  76. dtLista.Rows.Add(rows("CodigoEmpresa").ToString,
  77. rows("Empresa").ToString,
  78. Operaciones.ConvertirDecimal(rows("Rendimiento").ToString),
  79. Operaciones.ConvertirDecimal(rows("Cantidad").ToString),
  80. Operaciones.ConvertirDecimal(rows("Monto").ToString),
  81. Operaciones.ConvertirDecimal(rows("MontoTotal").ToString),
  82. Operaciones.ConvertirDecimal(rows("Peso").ToString))
  83. TituloCambio = value
  84. value = String.Empty
  85. End If
  86. End If
  87. Next
  88. Next
  89. Dim CantidadCheck As Integer = chklEmpresas.CheckedItems.Count
  90. If CantidadCheck = 0 And e.NewValue = CheckState.Checked Then
  91. For Each rows As DataRow In dtGeneral.Rows
  92. Dim valor3 As String = rows("CodigoEmpresa").ToString
  93. If valor3 = value Then
  94. dtLista.Rows.Add(rows("CodigoEmpresa").ToString,
  95. rows("Empresa").ToString,
  96. Operaciones.ConvertirDecimal(rows("Rendimiento").ToString),
  97. Operaciones.ConvertirDecimal(rows("Cantidad").ToString),
  98. Operaciones.ConvertirDecimal(rows("Monto").ToString),
  99. Operaciones.ConvertirDecimal(rows("MontoTotal").ToString),
  100. Operaciones.ConvertirDecimal(rows("Peso").ToString))
  101. value = String.Empty
  102. End If
  103. Next
  104. End If
  105. ElseIf Tipo = "Instrumento" Then
  106. Dim TituloCambio As String = String.Empty
  107. For Each Item As DataRowView In chklInstrumentos.CheckedItems
  108. Dim valor1 As String = Item.Item(0).ToString
  109. For Each rows As DataRow In dtGeneral.Rows
  110. Dim valor2 As String = rows("CodigoInstrumento").ToString
  111. If Not String.IsNullOrEmpty(valor1) And Not String.IsNullOrEmpty(valor2) Then
  112. If ((valor1 = valor2 And Not (valor1 = value) And Not valor2 = TituloCambio)) Then
  113. dtLista.Rows.Add(rows("CodigoInstrumento").ToString,
  114. rows("Instrumento").ToString,
  115. Operaciones.ConvertirDecimal(rows("Rendimiento").ToString),
  116. Operaciones.ConvertirDecimal(rows("Cantidad").ToString),
  117. Operaciones.ConvertirDecimal(rows("Monto").ToString),
  118. Operaciones.ConvertirDecimal(rows("MontoTotal").ToString),
  119. Operaciones.ConvertirDecimal(rows("Peso").ToString))
  120. ElseIf (Not valor1 = valor2 And valor2 = value And e.NewValue = CheckState.Checked) Then
  121. dtLista.Rows.Add(rows("CodigoInstrumento").ToString,
  122. rows("Instrumento").ToString,
  123. Operaciones.ConvertirDecimal(rows("Rendimiento").ToString),
  124. Operaciones.ConvertirDecimal(rows("Cantidad").ToString),
  125. Operaciones.ConvertirDecimal(rows("Monto").ToString),
  126. Operaciones.ConvertirDecimal(rows("MontoTotal").ToString),
  127. Operaciones.ConvertirDecimal(rows("Peso").ToString))
  128. TituloCambio = value
  129. value = String.Empty
  130. End If
  131. End If
  132. Next
  133. Next
  134. Dim CantidadCheck As Integer = chklInstrumentos.CheckedItems.Count
  135. If CantidadCheck = 0 And e.NewValue = CheckState.Checked Then
  136. For Each rows As DataRow In dtGeneral.Rows
  137. Dim valor3 As String = rows("CodigoInstrumento").ToString
  138. If valor3 = value Then
  139. dtLista.Rows.Add(rows("CodigoInstrumento").ToString,
  140. rows("Instrumento").ToString,
  141. Operaciones.ConvertirDecimal(rows("Rendimiento").ToString),
  142. Operaciones.ConvertirDecimal(rows("Cantidad").ToString),
  143. Operaciones.ConvertirDecimal(rows("Monto").ToString),
  144. Operaciones.ConvertirDecimal(rows("MontoTotal").ToString),
  145. Operaciones.ConvertirDecimal(rows("Peso").ToString))
  146. value = String.Empty
  147. End If
  148. Next
  149. End If
  150. ElseIf Tipo = "DescEmpresa" Then
  151. Dim ContarRepEmpresa As Integer = 0
  152. Dim Espr As Integer = 0
  153. For Each rows As DataRow In dtGeneral.Rows
  154. Dim valor As String = rows("CodigoEmpresa").ToString
  155. If valor = value Then
  156. ContarRepEmpresa += 1
  157. End If
  158. Next
  159. Dim TituloCambio As String = String.Empty
  160. For Each Item As DataRowView In chklEmpresas.CheckedItems
  161. Dim valor1 As String = Item.Item(0).ToString
  162. For Each rows As DataRow In dtGeneral.Rows
  163. Dim valor2 As String = rows("CodigoEmpresa").ToString
  164. If Not String.IsNullOrEmpty(valor1) And Not String.IsNullOrEmpty(valor2) Then
  165. If ((valor1 = valor2 And Not (valor1 = value) And Not valor2 = TituloCambio)) Then
  166. dtLista.Rows.Add(rows("CodigoEmpresa").ToString,
  167. rows("Empresa").ToString,
  168. rows("Instrumento").ToString,
  169. Operaciones.ConvertirDecimal(rows("Rendimiento").ToString),
  170. Operaciones.ConvertirDecimal(rows("Monto").ToString),
  171. rows("CodigoEmpresaTotal").ToString,
  172. rows("RendimientoPromedio").ToString,
  173. Operaciones.ConvertirDecimal(rows("Cantidad").ToString),
  174. Operaciones.ConvertirDecimal(rows("MontoTotal").ToString),
  175. Operaciones.ConvertirDecimal(rows("Peso").ToString))
  176. ElseIf (Not valor1 = valor2 And valor2 = value And e.NewValue = CheckState.Checked) Then
  177. dtLista.Rows.Add(rows("CodigoEmpresa").ToString,
  178. rows("Empresa").ToString,
  179. rows("Instrumento").ToString,
  180. Operaciones.ConvertirDecimal(rows("Rendimiento").ToString),
  181. Operaciones.ConvertirDecimal(rows("Monto").ToString),
  182. rows("CodigoEmpresaTotal").ToString,
  183. rows("RendimientoPromedio").ToString,
  184. Operaciones.ConvertirDecimal(rows("Cantidad").ToString),
  185. Operaciones.ConvertirDecimal(rows("MontoTotal").ToString),
  186. Operaciones.ConvertirDecimal(rows("Peso").ToString))
  187. Espr += 1
  188. If Espr >= ContarRepEmpresa Then
  189. TituloCambio = value
  190. value = String.Empty
  191. End If
  192. End If
  193. End If
  194. Next
  195. Next
  196. Dim CantidadCheck As Integer = chklEmpresas.CheckedItems.Count
  197. If CantidadCheck = 0 And e.NewValue = CheckState.Checked Then
  198. For Each rows As DataRow In dtGeneral.Rows
  199. Dim valor3 As String = rows("CodigoEmpresa").ToString
  200. If valor3 = value Then
  201. dtLista.Rows.Add(rows("CodigoEmpresa").ToString,
  202. rows("Empresa").ToString,
  203. rows("Instrumento").ToString,
  204. Operaciones.ConvertirDecimal(rows("Rendimiento").ToString),
  205. Operaciones.ConvertirDecimal(rows("Monto").ToString),
  206. rows("CodigoEmpresaTotal").ToString,
  207. rows("RendimientoPromedio").ToString,
  208. Operaciones.ConvertirDecimal(rows("Cantidad").ToString),
  209. Operaciones.ConvertirDecimal(rows("MontoTotal").ToString),
  210. Operaciones.ConvertirDecimal(rows("Peso").ToString))
  211. Espr += 1
  212. If Espr >= ContarRepEmpresa Then
  213. value = String.Empty
  214. End If
  215. End If
  216. Next
  217. End If
  218. ElseIf Tipo = "DescInstrumento" Then
  219. Dim ContarRepInstrumento As Integer = 0
  220. Dim Espr As Integer = 0
  221. For Each rows As DataRow In dtGeneral.Rows
  222. Dim valor As String = rows("CodigoInstrumento").ToString
  223. If valor = value Then
  224. ContarRepInstrumento += 1
  225. End If
  226. Next
  227. Dim TituloCambio As String = String.Empty
  228. For Each Item As DataRowView In chklInstrumentos.CheckedItems
  229. Dim valor1 As String = Item.Item(0).ToString
  230. For Each rows As DataRow In dtGeneral.Rows
  231. Dim valor2 As String = rows("CodigoInstrumento").ToString
  232. If Not String.IsNullOrEmpty(valor1) And Not String.IsNullOrEmpty(valor2) Then
  233. If ((valor1 = valor2 And Not (valor1 = value) And Not valor2 = TituloCambio)) Then
  234. dtLista.Rows.Add(rows("CodigoInstrumento").ToString,
  235. rows("Instrumento").ToString,
  236. rows("Empresa").ToString,
  237. Operaciones.ConvertirDecimal(rows("Rendimiento").ToString),
  238. Operaciones.ConvertirDecimal(rows("Monto").ToString),
  239. rows("CodigoInstrumentoTotal").ToString,
  240. rows("RendimientoPromedio").ToString,
  241. Operaciones.ConvertirDecimal(rows("Cantidad").ToString),
  242. Operaciones.ConvertirDecimal(rows("MontoTotal").ToString),
  243. Operaciones.ConvertirDecimal(rows("Peso").ToString))
  244. ElseIf (Not valor1 = valor2 And valor2 = value And e.NewValue = CheckState.Checked) Then
  245. dtLista.Rows.Add(rows("CodigoInstrumento").ToString,
  246. rows("Instrumento").ToString,
  247. rows("Empresa").ToString,
  248. Operaciones.ConvertirDecimal(rows("Rendimiento").ToString),
  249. Operaciones.ConvertirDecimal(rows("Monto").ToString),
  250. rows("CodigoInstrumentoTotal").ToString,
  251. rows("RendimientoPromedio").ToString,
  252. Operaciones.ConvertirDecimal(rows("Cantidad").ToString),
  253. Operaciones.ConvertirDecimal(rows("MontoTotal").ToString),
  254. Operaciones.ConvertirDecimal(rows("Peso").ToString))
  255. Espr += 1
  256. If Espr >= ContarRepInstrumento Then
  257. TituloCambio = value
  258. value = String.Empty
  259. End If
  260. End If
  261. End If
  262. Next
  263. Next
  264. Dim CantidadCheck As Integer = chklInstrumentos.CheckedItems.Count
  265. If CantidadCheck = 0 And e.NewValue = CheckState.Checked Then
  266. For Each rows As DataRow In dtGeneral.Rows
  267. Dim valor3 As String = rows("CodigoInstrumento").ToString
  268. If valor3 = value Then
  269. dtLista.Rows.Add(rows("CodigoInstrumento").ToString,
  270. rows("Instrumento").ToString,
  271. rows("Empresa").ToString,
  272. Operaciones.ConvertirDecimal(rows("Rendimiento").ToString),
  273. Operaciones.ConvertirDecimal(rows("Monto").ToString),
  274. rows("CodigoInstrumentoTotal").ToString,
  275. rows("RendimientoPromedio").ToString,
  276. Operaciones.ConvertirDecimal(rows("Cantidad").ToString),
  277. Operaciones.ConvertirDecimal(rows("MontoTotal").ToString),
  278. Operaciones.ConvertirDecimal(rows("Peso").ToString))
  279. Espr += 1
  280. If Espr >= ContarRepInstrumento Then
  281. value = String.Empty
  282. End If
  283. End If
  284. Next
  285. End If
  286. End If
  287. End Sub
  288. Sub Cargar(Tipo As String, value As String, Index As Integer, e As ItemCheckEventArgs)
  289. Dim MontoTotal As Double = 0
  290. Dim RendimientoPromedio As Double = 0
  291. Dim PesoPromedio As Double = 0
  292. Dim CantidadRegistros As Integer = 0
  293. Dim dtListaEmpresa As New DataTable
  294. If Tipo = "Empresa" Then
  295. dtListaEmpresa.Columns.Add("CodigoEmpresa")
  296. dtListaEmpresa.Columns.Add("Empresa")
  297. dtListaEmpresa.Columns.Add("Rendimiento")
  298. dtListaEmpresa.Columns.Add("Cantidad")
  299. dtListaEmpresa.Columns.Add("Monto")
  300. dtListaEmpresa.Columns.Add("MontoTotal")
  301. dtListaEmpresa.Columns.Add("Peso")
  302. ElseIf Tipo = "Instrumento" Then
  303. dtListaEmpresa.Columns.Add("CodigoInstrumento")
  304. dtListaEmpresa.Columns.Add("Empresa")
  305. dtListaEmpresa.Columns.Add("Rendimiento")
  306. dtListaEmpresa.Columns.Add("Cantidad")
  307. dtListaEmpresa.Columns.Add("Monto")
  308. dtListaEmpresa.Columns.Add("MontoTotal")
  309. dtListaEmpresa.Columns.Add("Peso")
  310. ElseIf Tipo = "DescEmpresa" Then
  311. dtListaEmpresa.Columns.Add("CodigoEmpresa")
  312. dtListaEmpresa.Columns.Add("Empresa")
  313. dtListaEmpresa.Columns.Add("Instrumento")
  314. dtListaEmpresa.Columns.Add("Rendimiento")
  315. dtListaEmpresa.Columns.Add("Monto")
  316. dtListaEmpresa.Columns.Add("CodigoEmpresaTotal")
  317. dtListaEmpresa.Columns.Add("RendimientoPromedio")
  318. dtListaEmpresa.Columns.Add("Cantidad")
  319. dtListaEmpresa.Columns.Add("MontoTotal")
  320. dtListaEmpresa.Columns.Add("Peso")
  321. ElseIf Tipo = "DescInstrumento" Then
  322. dtListaEmpresa.Columns.Add("CodigoInstrumento")
  323. dtListaEmpresa.Columns.Add("Instrumento")
  324. dtListaEmpresa.Columns.Add("Empresa")
  325. dtListaEmpresa.Columns.Add("Rendimiento")
  326. dtListaEmpresa.Columns.Add("Monto")
  327. dtListaEmpresa.Columns.Add("CodigoInstrumentoTotal")
  328. dtListaEmpresa.Columns.Add("RendimientoPromedio")
  329. dtListaEmpresa.Columns.Add("Cantidad")
  330. dtListaEmpresa.Columns.Add("MontoTotal")
  331. dtListaEmpresa.Columns.Add("Peso")
  332. End If
  333. Dim dtGeneral As New DataTable
  334. If String.IsNullOrEmpty(Tipo) Then
  335. MsgBox("Error")
  336. Me.Close()
  337. Else
  338. If Tipo = "Empresa" Then
  339. lblInstrumentos.Visible = False
  340. chklInstrumentos.Visible = False
  341. If dtGeneral.Columns.Count = 0 Then
  342. dt = Rendimientos.CargarPortafolioGeneral(Tipo)
  343. End If
  344. dtGeneral = dt
  345. Calcular(dtGeneral, dtListaEmpresa, value, Index, e)
  346. dtGeneral = dtListaEmpresa
  347. For Each rows As DataRow In dtGeneral.Rows
  348. If Not (rows("Rendimiento")) Is Nothing Then
  349. rows("Rendimiento") = (rows("Rendimiento") * 100).ToString + " %"
  350. End If
  351. If Not (rows("Peso")) Is Nothing Then
  352. rows("Peso") = (rows("Peso") * 100).ToString + " %"
  353. End If
  354. Next
  355. ElseIf Tipo = "Instrumento" Then
  356. lblEmpresa.Visible = False
  357. chklEmpresas.Visible = False
  358. If dtGeneral.Columns.Count = 0 Then
  359. dt = Rendimientos.CargarPortafolioGeneral(Tipo)
  360. End If
  361. dtGeneral = dt
  362. Calcular(dtGeneral, dtListaEmpresa, value, Index, e)
  363. dtGeneral = dtListaEmpresa
  364. For Each rows As DataRow In dtGeneral.Rows
  365. If Not (rows("Rendimiento")) Is Nothing Then
  366. rows("Rendimiento") = (rows("Rendimiento") * 100).ToString + " %"
  367. End If
  368. If Not (rows("Peso")) Is Nothing Then
  369. rows("Peso") = (rows("Peso") * 100).ToString + " %"
  370. End If
  371. Next
  372. ElseIf Tipo = "DescEmpresa" Then
  373. lblInstrumentos.Visible = False
  374. chklInstrumentos.Visible = False
  375. If dtGeneral.Columns.Count = 0 Then
  376. dt = Rendimientos.CargarPortafolioGeneral(Tipo)
  377. End If
  378. dtGeneral = dt
  379. Calcular(dtGeneral, dtListaEmpresa, value, Index, e)
  380. dtGeneral = dtListaEmpresa
  381. For Each rows As DataRow In dtGeneral.Rows
  382. If Not (rows("Rendimiento") Is Nothing) Then
  383. rows("Rendimiento") = (rows("Rendimiento") * 100).ToString + " %"
  384. End If
  385. If Not (rows("Peso")) Is Nothing Then
  386. rows("Peso") = (rows("Peso") * 100).ToString + " %"
  387. End If
  388. If Not (rows("RendimientoPromedio")) Is Nothing Then
  389. rows("RendimientoPromedio") = (rows("RendimientoPromedio") * 100).ToString + " %"
  390. End If
  391. Next
  392. ElseIf Tipo = "DescInstrumento" Then
  393. lblEmpresa.Visible = False
  394. chklEmpresas.Visible = False
  395. If dtGeneral.Columns.Count = 0 Then
  396. dt = Rendimientos.CargarPortafolioGeneral(Tipo)
  397. End If
  398. dtGeneral = dt
  399. Calcular(dtGeneral, dtListaEmpresa, value, Index, e)
  400. dtGeneral = dtListaEmpresa
  401. For Each rows As DataRow In dtGeneral.Rows
  402. If Not (rows("Rendimiento") Is Nothing) Then
  403. rows("Rendimiento") = (rows("Rendimiento") * 100).ToString + " %"
  404. End If
  405. If Not (rows("Peso")) Is Nothing Then
  406. rows("Peso") = (rows("Peso") * 100).ToString + " %"
  407. End If
  408. If Not (rows("RendimientoPromedio")) Is Nothing Then
  409. rows("RendimientoPromedio") = (rows("RendimientoPromedio") * 100).ToString + " %"
  410. End If
  411. Next
  412. End If
  413. End If
  414. dgvPortafolio.DataSource = dtGeneral
  415. For Each rows As DataRow In dtGeneral.Rows
  416. If Not rows("Monto") Is Nothing Then
  417. MontoTotal += Operaciones.ConvertirDecimal(rows("Monto").ToString)
  418. End If
  419. Next
  420. CantidadRegistros = dtGeneral.Rows.Count
  421. For Each rows As DataRow In dtGeneral.Rows
  422. If Not rows("Rendimiento") Is Nothing Then
  423. RendimientoPromedio += (Operaciones.ConvertirDecimal(rows("Rendimiento").ToString) / 100)
  424. End If
  425. Next
  426. For Each rows As DataRow In dtGeneral.Rows
  427. If Not rows("Peso") Is Nothing Then
  428. PesoPromedio += (Operaciones.ConvertirDecimal(rows("Peso").ToString) / 100)
  429. End If
  430. Next
  431. txtMontoTotal.Text = MontoTotal
  432. If Not CantidadRegistros = 0 Then
  433. txtRendimientoPromedio.Text = (RendimientoPromedio / CantidadRegistros * 100).ToString + " %"
  434. txtPesoPromedio.Text = (PesoPromedio / CantidadRegistros * 100).ToString + " %"
  435. Else
  436. txtRendimientoPromedio.Text = 0.ToString + " %"
  437. txtPesoPromedio.Text = 0.ToString + " %"
  438. End If
  439. End Sub
  440. Sub OcultarColumnas()
  441. If Not dgvPortafolio.Columns("MontoTotal") Is Nothing Then
  442. dgvPortafolio.Columns("MontoTotal").Visible = False
  443. End If
  444. If Not dgvPortafolio.Columns("Cantidad") Is Nothing Then
  445. dgvPortafolio.Columns("Cantidad").Visible = False
  446. End If
  447. If Not dgvPortafolio.Columns("CodigoEmpresaTotal") Is Nothing Then
  448. dgvPortafolio.Columns("CodigoEmpresaTotal").Visible = False
  449. End If
  450. If Not dgvPortafolio.Columns("CodigoInstrumentoTotal") Is Nothing Then
  451. dgvPortafolio.Columns("CodigoInstrumentoTotal").Visible = False
  452. End If
  453. If Not dgvPortafolio.Columns("RendimientoTotal") Is Nothing Then
  454. dgvPortafolio.Columns("RendimientoTotal").Visible = False
  455. End If
  456. If Not dgvPortafolio.Columns("CodigoEmpresa") Is Nothing Then
  457. dgvPortafolio.Columns("CodigoEmpresa").Visible = False
  458. End If
  459. If Not dgvPortafolio.Columns("CodigoInstrumento") Is Nothing Then
  460. dgvPortafolio.Columns("CodigoInstrumento").Visible = False
  461. End If
  462. End Sub
  463. Sub QuitarEmpresas(Value As String, Indice As Integer, e As ItemCheckEventArgs)
  464. Dim Cantidad As Integer = chklEmpresas.Items.Count - 1
  465. Dim CantidadSeleccionados = chklEmpresas.CheckedItems.Count - 1
  466. If Value = "Todos" And e.NewValue = CheckState.Checked Then
  467. Dim Index As Integer = 0
  468. While Index <= Cantidad
  469. chklEmpresas.SetItemChecked(Index, True)
  470. Index += 1
  471. End While
  472. ElseIf Value = "Todos" And Not e.NewValue = CheckState.Checked Then
  473. Dim Index As Integer = 0
  474. While Index <= Cantidad
  475. chklEmpresas.SetItemChecked(Index, False)
  476. Index += 1
  477. End While
  478. Else
  479. Dim JIndex As Integer = 0
  480. Dim TodosCheck As Boolean = False
  481. While JIndex <= Cantidad
  482. If chklEmpresas.GetItemText(chklEmpresas.Items(JIndex)) = "Todos" Then
  483. If chklEmpresas.GetItemChecked(JIndex) Then
  484. TodosCheck = True
  485. End If
  486. End If
  487. JIndex += 1
  488. End While
  489. If e.NewValue = CheckState.Unchecked Then
  490. CantidadSeleccionados -= 1
  491. Else
  492. CantidadSeleccionados += 2
  493. End If
  494. If CantidadSeleccionados < Cantidad And TodosCheck Then
  495. Dim Index As Integer = 0
  496. While Index <= Cantidad
  497. If chklEmpresas.GetItemText(chklEmpresas.Items(Index)) = "Todos" Then
  498. chklEmpresas.SetItemChecked(Index, False)
  499. End If
  500. Index += 1
  501. End While
  502. ElseIf CantidadSeleccionados = Cantidad Then
  503. e.NewValue = CheckState.Checked
  504. CheckEmpresaTodos()
  505. End If
  506. End If
  507. End Sub
  508. Sub QuitarInstrumento(Value As String, Indice As Integer, e As ItemCheckEventArgs)
  509. Dim Cantidad As Integer = chklInstrumentos.Items.Count - 1
  510. Dim CantidadSeleccionados = chklInstrumentos.CheckedItems.Count - 1
  511. If Value = "Todos" And e.NewValue = CheckState.Checked Then
  512. Dim Index As Integer = 0
  513. While Index <= Cantidad
  514. chklInstrumentos.SetItemChecked(Index, True)
  515. Index += 1
  516. End While
  517. ElseIf Value = "Todos" And Not e.NewValue = CheckState.Checked Then
  518. Dim Index As Integer = 0
  519. While Index <= Cantidad
  520. chklInstrumentos.SetItemChecked(Index, False)
  521. Index += 1
  522. End While
  523. Else
  524. Dim JIndex As Integer = 0
  525. Dim TodosCheck As Boolean = False
  526. While JIndex <= Cantidad
  527. If chklInstrumentos.GetItemText(chklInstrumentos.Items(JIndex)) = "Todos" Then
  528. If chklInstrumentos.GetItemChecked(JIndex) Then
  529. TodosCheck = True
  530. End If
  531. End If
  532. JIndex += 1
  533. End While
  534. If e.NewValue = CheckState.Unchecked Then
  535. CantidadSeleccionados -= 1
  536. Else
  537. CantidadSeleccionados += 2
  538. End If
  539. If CantidadSeleccionados < Cantidad And TodosCheck Then
  540. Dim Index As Integer = 0
  541. While Index <= Cantidad
  542. If chklInstrumentos.GetItemText(chklInstrumentos.Items(Index)) = "Todos" Then
  543. chklInstrumentos.SetItemChecked(Index, False)
  544. End If
  545. Index += 1
  546. End While
  547. ElseIf CantidadSeleccionados = Cantidad Then
  548. e.NewValue = CheckState.Checked
  549. CheckInstrumentoTodos()
  550. End If
  551. End If
  552. End Sub
  553. Private Sub chklEmpresas_ItemCheck(sender As Object, e As ItemCheckEventArgs) Handles chklEmpresas.ItemCheck
  554. If ContinuarEmpresa Then
  555. ContinuarEmpresa = False
  556. If FinCargado Then
  557. QuitarEmpresas(chklEmpresas.SelectedValue.ToString, chklEmpresas.SelectedIndex, e)
  558. End If
  559. Cargar(Tipo, chklEmpresas.SelectedValue.ToString, chklEmpresas.SelectedIndex, e)
  560. ContinuarEmpresa = True
  561. End If
  562. End Sub
  563. Private Sub chklEmpresas_SelectedIndexChanged(sender As Object, e As EventArgs) Handles chklEmpresas.SelectedIndexChanged
  564. End Sub
  565. Private Sub chklEmpresas_EnabledChanged(sender As Object, e As EventArgs) Handles chklEmpresas.EnabledChanged
  566. End Sub
  567. Private Sub chklEmpresas_MouseCaptureChanged(sender As Object, e As EventArgs) Handles chklEmpresas.MouseCaptureChanged
  568. End Sub
  569. Private Sub chklEmpresas_Click(sender As Object, e As EventArgs) Handles chklEmpresas.Click
  570. End Sub
  571. Private Sub chklEmpresas_RegionChanged(sender As Object, e As EventArgs) Handles chklEmpresas.RegionChanged
  572. End Sub
  573. Private Sub chklEmpresas_SelectedValueChanged(sender As Object, e As EventArgs) Handles chklEmpresas.SelectedValueChanged
  574. End Sub
  575. Private Sub chklEmpresas_CausesValidationChanged(sender As Object, e As EventArgs) Handles chklEmpresas.CausesValidationChanged
  576. End Sub
  577. Private Sub chklEmpresas_BackColorChanged(sender As Object, e As EventArgs)
  578. End Sub
  579. Private Sub chklEmpresas_BindingContextChanged(sender As Object, e As EventArgs)
  580. End Sub
  581. Private Sub chklEmpresas_FormattingEnabledChanged(sender As Object, e As EventArgs)
  582. End Sub
  583. Private Sub chklEmpresas_TabIndexChanged(sender As Object, e As EventArgs) Handles chklEmpresas.TabIndexChanged
  584. End Sub
  585. Private Sub chklInstrumentos_ItemCheck(sender As Object, e As ItemCheckEventArgs) Handles chklInstrumentos.ItemCheck
  586. If ContinuarInstrumento Then
  587. ContinuarInstrumento = False
  588. If FinCargado Then
  589. QuitarInstrumento(chklInstrumentos.SelectedValue.ToString, chklInstrumentos.SelectedIndex, e)
  590. End If
  591. Cargar(Tipo, chklInstrumentos.SelectedValue.ToString, chklInstrumentos.SelectedIndex, e)
  592. ContinuarInstrumento = True
  593. End If
  594. End Sub
  595. Private Sub txtRendimientoPromedio_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoPromedio.TextChanged
  596. End Sub
  597. End Class