frmDetallesPortafolioGeneralRendimiento.vb 31 KB

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