frmFOIN.vb 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403
  1. Public Class frmFOIN
  2. Dim oCEFOIN As FondosDeInversionCE = New FondosDeInversionCE
  3. Dim oDAOGeneral As New DAOGeneral
  4. Dim FOIN As New FondoInversionDAO
  5. Dim EstadoBoton As String
  6. Dim Operaciones As New Operaciones
  7. Dim IndexBase As Integer = 0
  8. Dim TipoTransaccion As String = String.Empty
  9. Private Sub frmFOIN_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  10. CargarBase()
  11. CargarPeriodicidad()
  12. AgregarCampos()
  13. CargarRegistroPrincipal()
  14. CargarFilas()
  15. Rellenar()
  16. Calculos()
  17. ExisteInversion()
  18. ValidarExistencia()
  19. CargarTransladoNuevo()
  20. End Sub
  21. Sub ValidarExistencia()
  22. Dim General As New DAOGeneral
  23. Dim Codigo As String = Variables.Codigo
  24. Dim Tabla As String = String.Empty
  25. Tabla = "FINV"
  26. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  27. If (Existe) Then
  28. navNuevo.Enabled = False
  29. navModificar.Enabled = True
  30. navEliminar.Enabled = True
  31. Else
  32. navNuevo.Enabled = True
  33. navModificar.Enabled = False
  34. navEliminar.Enabled = False
  35. 'LimpiarCampos()
  36. End If
  37. End Sub
  38. Function ExisteInversion()
  39. Dim Codigo As String = Variables.Codigo
  40. Dim TablaINV As String = "INV0"
  41. Dim TablaPINV As String = "PIN0"
  42. Dim General As New DAOGeneral
  43. Dim InvPro = Variables.InvPro
  44. If InvPro = "I" Then
  45. Dim INV0 As Boolean = General.ExisteTitulo(Codigo, TablaINV)
  46. If INV0 Then
  47. navNuevo.Visible = True
  48. Return True
  49. Else
  50. navNuevo.Visible = False
  51. Return False
  52. End If
  53. End If
  54. If InvPro = "P" Then
  55. Dim PINV0 As Boolean = General.ExisteTitulo(Codigo, TablaPINV)
  56. If PINV0 Then
  57. navNuevo.Visible = True
  58. Return True
  59. Else
  60. navNuevo.Visible = False
  61. Return False
  62. End If
  63. End If
  64. Return False
  65. End Function
  66. Sub CargarBase()
  67. If Me.cboAnioBase.Items.Count = 0 Or Me.cboAnioBase.Items.Count = 1 Then
  68. Me.cboAnioBase.DataSource = oDAOGeneral.ListaBase
  69. Me.cboAnioBase.DisplayMember = "Descripcion"
  70. Me.cboAnioBase.ValueMember = "Codigo"
  71. Me.cboAnioBase.SelectedIndex = 0
  72. End If
  73. End Sub
  74. Sub Rellenar()
  75. If (String.IsNullOrEmpty(txtValorNominal.Text.ToString)) Then
  76. txtValorNominal.Text = "0.0"
  77. End If
  78. If (String.IsNullOrEmpty(txtCuotasDeParticipacion.Text.ToString)) Then
  79. txtCuotasDeParticipacion.Text = "0.0"
  80. End If
  81. If (String.IsNullOrEmpty(txtValorDeParticipacion.Text.ToString)) Then
  82. txtValorDeParticipacion.Text = "0.0"
  83. End If
  84. If (String.IsNullOrEmpty(txtPorcentajeComisionCasa.Text.ToString.Trim("%"))) Then
  85. txtPorcentajeComisionCasa.Text = "0.0%"
  86. End If
  87. If (String.IsNullOrEmpty(txtPorcentajeComisionBolsa.Text.ToString.Trim("%"))) Then
  88. txtPorcentajeComisionBolsa.Text = "0.0%"
  89. End If
  90. If (String.IsNullOrEmpty(txtComisionCasa.Text.ToString)) Then
  91. txtComisionCasa.Text = "0.0"
  92. End If
  93. If (String.IsNullOrEmpty(txtComisionBolsa.Text.ToString)) Then
  94. txtComisionBolsa.Text = "0.0"
  95. End If
  96. If (String.IsNullOrEmpty(txtValorTransado.Text.ToString)) Then
  97. txtValorTransado.Text = "0.0"
  98. End If
  99. If (String.IsNullOrEmpty(txtDiasLiq.Text.ToString)) Then
  100. txtDiasLiq.Text = "0.0"
  101. End If
  102. If (String.IsNullOrEmpty(txtRendimientoOfrecido.Text.ToString.Trim("%"))) Then
  103. txtRendimientoOfrecido.Text = "0.0%"
  104. End If
  105. If (String.IsNullOrEmpty(txtPlazo.Text.ToString)) Then
  106. txtPlazo.Text = "0.0"
  107. End If
  108. If (String.IsNullOrEmpty(txtDividendo.Text.ToString.Trim("%"))) Then
  109. txtDividendo.Text = "0.0%"
  110. End If
  111. End Sub
  112. Sub CalculoDGT()
  113. End Sub
  114. Function CalcularIngreso(ByVal Index As Integer, ByVal Dividendo As Double, ByVal CuotaParticipacion As Double)
  115. Dim Total
  116. If (Index = 0) Then
  117. Total = ((Dividendo * CuotaParticipacion) / 30) * 11
  118. Else
  119. Total = Dividendo * CuotaParticipacion
  120. End If
  121. Return Total
  122. End Function
  123. Function CalcularRendimieno(ByVal Ingreso As Double, ByVal ValorNominal As Double, ByVal Base As Integer, ByVal Dias As Integer)
  124. Dim Total = Ingreso / ValorNominal * Base / Dias
  125. Return Total
  126. End Function
  127. Sub CargarDatos()
  128. ''Declaracion de Variables'
  129. 'Dim Base As Integer = 0
  130. 'Dim DiaFijo As Integer = 0
  131. 'Dim Periodicidad As String = "M"
  132. 'Dim TipoCalculo As String = String.Empty
  133. ''Seleccion de Tipo de Calculo'
  134. 'If RadioButton1.Checked Then
  135. ' TipoCalculo = "FinMes"
  136. 'Else
  137. ' If RadioButton2.Checked Then
  138. ' TipoCalculo = "Mensual"
  139. ' End If
  140. 'End If
  141. 'If (IndexBase = 0 Or IndexBase = 2) Then
  142. ' Base = 360
  143. ' If TipoCalculo = "FinMes" Then
  144. ' DateTimePicker1.Value = Operaciones.FechaFinMes(DateTimePicker1.Value, Periodicidad, Base)
  145. ' ElseIf TipoCalculo = "Mensual" Then
  146. ' DateTimePicker1.Value = Operaciones.FechaMensual(DateTimePicker1.Value, Periodicidad, TipoCalculo, 0, DiaFijo, Base)
  147. ' End If
  148. 'ElseIf IndexBase = 1 Or IndexBase = 3 Then
  149. ' Base = 365
  150. ' If TipoCalculo = "FinMes" Then
  151. ' DateTimePicker1.Value = Operaciones.FechaFinMes(DateTimePicker1.Value, Periodicidad, Base)
  152. ' ElseIf TipoCalculo = "Mensual" Then
  153. ' DateTimePicker1.Value = Operaciones.FechaMensual(DateTimePicker1.Value, Periodicidad, TipoCalculo, 0, DiaFijo, Base)
  154. ' End If
  155. 'End If
  156. End Sub
  157. Function CalcularFecha(ByVal FechaInicial As Date, ByVal DiaFijo As Integer)
  158. 'Declaracion de Variables'
  159. Dim Base As Integer = 0
  160. Dim Periodicidad As String = cboPeriodicidad.SelectedValue
  161. Dim TipoCalculo As String = String.Empty
  162. Dim FechaFinal As Date = Date.Today.Date
  163. 'Seleccion de Tipo de Calculo'
  164. If RadioButton1.Checked Then
  165. TipoCalculo = "FinMes"
  166. Else
  167. If RadioButton2.Checked Then
  168. TipoCalculo = "Mensual"
  169. End If
  170. End If
  171. IndexBase = cboAnioBase.SelectedIndex
  172. If (IndexBase = 0 Or IndexBase = 2) Then
  173. Base = 360
  174. If TipoCalculo = "FinMes" Then
  175. FechaFinal = Operaciones.FechaFinMes(FechaInicial, Periodicidad, Base)
  176. ElseIf TipoCalculo = "Mensual" Then
  177. FechaFinal = Operaciones.FechaMensual(FechaInicial, Periodicidad, TipoCalculo, 0, DiaFijo, Base)
  178. End If
  179. ElseIf IndexBase = 1 Or IndexBase = 3 Then
  180. Base = 365
  181. If TipoCalculo = "FinMes" Then
  182. FechaFinal = Operaciones.FechaFinMes(FechaInicial, Periodicidad, Base)
  183. ElseIf TipoCalculo = "Mensual" Then
  184. FechaFinal = Operaciones.FechaMensual(FechaInicial, Periodicidad, TipoCalculo, 0, DiaFijo, Base)
  185. End If
  186. End If
  187. Return FechaFinal
  188. End Function
  189. Sub AgregarFecha()
  190. Dim Index As Integer = dgvIngresos.CurrentRow.Index
  191. Dim IndexAnterior As Integer = Index - 1
  192. Dim FechaAnterior As String = String.Empty
  193. Dim FechaActual As String = String.Empty
  194. Dim FechaLiquidacion As Date = dtpFechaLiquidacion.Value
  195. Dim DiaFijo As Integer = FechaLiquidacion.Day
  196. If Index > 0 Then
  197. FechaAnterior = dgvIngresos.Rows(IndexAnterior).Cells("Fecha de Corte").Value.ToString
  198. If String.IsNullOrEmpty(FechaAnterior) Then
  199. MsgBox("Error de Formato en Fecha")
  200. Exit Sub
  201. Else
  202. FechaActual = CalcularFecha(CDate(FechaAnterior), DiaFijo)
  203. End If
  204. If String.IsNullOrEmpty(FechaActual) Then
  205. MsgBox("Error de Formato en Fecha")
  206. Exit Sub
  207. Else
  208. dgvIngresos.Rows(Index).Cells("Fecha de Corte").Value = Format(CDate(FechaActual), "dd/MM/yyyy").ToString
  209. End If
  210. Else
  211. FechaActual = CalcularFecha(CDate(FechaLiquidacion), DiaFijo)
  212. dgvIngresos.Rows(Index).Cells("Fecha de Corte").Value = Format(CDate(FechaActual), "dd/MM/yyyy").ToString
  213. End If
  214. End Sub
  215. Sub AgregarDias()
  216. Dim Index As Integer = dgvIngresos.CurrentRow.Index
  217. Dim IndexAnterior As Integer = Index - 1
  218. Dim FechaAnterior As String = String.Empty
  219. Dim FechaActual As String = String.Empty
  220. Dim FechaLiquidacion As Date = Format(dtpFechaLiquidacion.Value, "dd/MM/yyyy")
  221. Dim BaseIndex As Integer = cboAnioBase.SelectedIndex
  222. Dim BaseCalculo As Integer = 0
  223. Dim Meses As Integer = 0
  224. Dim TipoCalculo As String = String.Empty
  225. Dim DiasFinales As Integer = 0
  226. Dim CantidadDiasNormal360 As Integer = 0
  227. Dim CantidadDias360 As Integer = 0
  228. Dim Periodicidad As String = cboPeriodicidad.SelectedValue
  229. If Periodicidad = "M" Then
  230. Meses = 1
  231. ElseIf Periodicidad = "T" Then
  232. Meses = 3
  233. ElseIf Periodicidad = "S" Then
  234. Meses = 6
  235. ElseIf Periodicidad = "A" Then
  236. Meses = 12
  237. End If
  238. CantidadDiasNormal360 = Meses * 30
  239. If BaseIndex = 0 Or BaseIndex = 2 Then
  240. BaseCalculo = 360
  241. ElseIf BaseIndex = 1 Or BaseIndex = 3 Then
  242. BaseCalculo = 365
  243. End If
  244. If RadioButton1.Checked Then
  245. TipoCalculo = "FinMes"
  246. Else
  247. If RadioButton2.Checked Then
  248. TipoCalculo = "Mensual"
  249. End If
  250. End If
  251. If Index > 0 Then
  252. FechaAnterior = dgvIngresos.Rows(IndexAnterior).Cells("Fecha de Corte").Value.ToString
  253. FechaActual = dgvIngresos.Rows(Index).Cells("Fecha de Corte").Value.ToString
  254. If Not String.IsNullOrEmpty(FechaAnterior) And Not String.IsNullOrEmpty(FechaActual) Then
  255. If BaseCalculo = 360 Then
  256. If TipoCalculo = "FinMes" Then
  257. DiasFinales = Operaciones.Base360(FechaAnterior, FechaActual)
  258. ElseIf TipoCalculo = "Mensual" Then
  259. DiasFinales = CantidadDiasNormal360
  260. End If
  261. ElseIf BaseCalculo = 365 Then
  262. DiasFinales = Operaciones.Base365(FechaAnterior, FechaActual)
  263. End If
  264. End If
  265. Else
  266. 'Primera Fecha'
  267. FechaActual = dgvIngresos.Rows(Index).Cells("Fecha de Corte").Value.ToString
  268. If Not String.IsNullOrEmpty(FechaLiquidacion) And Not String.IsNullOrEmpty(FechaActual) Then
  269. If BaseCalculo = 360 Then
  270. If TipoCalculo = "FinMes" Then
  271. DiasFinales = Operaciones.Base360(FechaLiquidacion, FechaActual)
  272. ElseIf TipoCalculo = "Mensual" Then
  273. DiasFinales = CantidadDiasNormal360
  274. End If
  275. ElseIf BaseCalculo = 365 Then
  276. DiasFinales = Operaciones.Base365(FechaLiquidacion, FechaActual)
  277. End If
  278. End If
  279. End If
  280. dgvIngresos.Rows(Index).Cells("Dias").Value = DiasFinales
  281. End Sub
  282. Sub AgregarDividendo()
  283. Dim Index As Integer = dgvIngresos.CurrentRow.Index
  284. Dim Dividendo As String = String.Empty
  285. Dim DividendoAgregar As String = String.Empty
  286. Dim DividendoTexto As String = txtDividendo.Text.ToString.Trim("%")
  287. Dim NuevaFila As Boolean = False
  288. If dgvIngresos.Rows(Index).Cells("Dividendo").Value Is Nothing Then
  289. NuevaFila = True
  290. Else
  291. Dividendo = dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString
  292. End If
  293. If String.IsNullOrEmpty(Dividendo) Then
  294. If String.IsNullOrEmpty(DividendoTexto) Then
  295. DividendoAgregar = "0"
  296. Else
  297. DividendoAgregar = DividendoTexto
  298. End If
  299. dgvIngresos.Rows(Index).Cells("Dividendo").Value = (DividendoAgregar.ToString + "%")
  300. End If
  301. End Sub
  302. Sub AgregarIngreso()
  303. Dim Index As Integer = dgvIngresos.CurrentRow.Index
  304. Dim CuotasParticipacion As Double = 0
  305. Dim Dividendo As Double = 0
  306. Dim Dias As Integer = 0
  307. Dim Calculo As Double = 0
  308. If Index > 0 Then
  309. If Not String.IsNullOrEmpty(txtCuotasDeParticipacion.Text.ToString) Then
  310. CuotasParticipacion = txtCuotasDeParticipacion.Text
  311. End If
  312. If Not dgvIngresos.Rows(Index).Cells("Dividendo").Value Is Nothing Then
  313. If Not String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString.Trim("%")) Then
  314. Dividendo = dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString.Trim("%")
  315. End If
  316. End If
  317. Calculo = CuotasParticipacion * (Dividendo / 100)
  318. Else
  319. If Not String.IsNullOrEmpty(txtCuotasDeParticipacion.Text.ToString) Then
  320. CuotasParticipacion = txtCuotasDeParticipacion.Text
  321. End If
  322. If Not dgvIngresos.Rows(Index).Cells("Dividendo").Value Is Nothing Then
  323. If Not String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString.Trim("%")) Then
  324. Dividendo = dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString.Trim("%")
  325. End If
  326. End If
  327. If Not dgvIngresos.Rows(Index).Cells("Dias").Value Is Nothing Then
  328. If Not String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("Dias").Value.ToString) Then
  329. Dias = dgvIngresos.Rows(Index).Cells("Dias").Value
  330. End If
  331. End If
  332. If Not Dias = 0 Then
  333. Dim FechaTemporal As Date = dtpFechaLiquidacion.Value.AddDays(1)
  334. If FechaTemporal.Month = dtpFechaLiquidacion.Value.Month Then
  335. Calculo = (((Dividendo / 100) * CuotasParticipacion) / Dias)
  336. Else
  337. Calculo = CuotasParticipacion * (Dividendo / 100)
  338. End If
  339. End If
  340. End If
  341. dgvIngresos.Rows(Index).Cells("Ingresos").Value = Calculo
  342. End Sub
  343. Sub AgregarRendimientos()
  344. Dim Index As Integer = dgvIngresos.CurrentRow.Index
  345. Dim ValorNominal As Double = 0
  346. Dim Dividendo As Double = 0
  347. Dim Dias As Integer = 0
  348. Dim Ingreso As Double = 0
  349. Dim Calculo As Double = 0
  350. Dim IndexBase As Integer = 0
  351. Dim BaseCalculo As Integer = 0
  352. If Not String.IsNullOrEmpty(txtValorNominal.Text.ToString) Then
  353. ValorNominal = txtValorNominal.Text
  354. End If
  355. If Not dgvIngresos.Rows(Index).Cells("Dividendo").Value Is Nothing Then
  356. If Not String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString.Trim("%")) Then
  357. Dividendo = dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString.Trim("%")
  358. End If
  359. End If
  360. If Not dgvIngresos.Rows(Index).Cells("Ingresos").Value Is Nothing Then
  361. If Not String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("Ingresos").Value.ToString) Then
  362. Ingreso = dgvIngresos.Rows(Index).Cells("Ingresos").Value
  363. End If
  364. End If
  365. If Not dgvIngresos.Rows(Index).Cells("Dias").Value Is Nothing Then
  366. If Not String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("Dias").Value.ToString) Then
  367. Dias = dgvIngresos.Rows(Index).Cells("Dias").Value
  368. End If
  369. End If
  370. IndexBase = cboAnioBase.SelectedIndex
  371. If IndexBase = 0 Or IndexBase = 2 Then
  372. BaseCalculo = 360
  373. ElseIf IndexBase = 1 Or IndexBase = 3 Then
  374. BaseCalculo = 365
  375. End If
  376. If Not Dias = 0 And Not ValorNominal = 0 And Not BaseCalculo = 0 Then
  377. Calculo = Ingreso / ValorNominal * BaseCalculo / Dias
  378. End If
  379. dgvIngresos.Rows(Index).Cells("Rendimiento Mensual").Value = (Calculo * 100).ToString + "%"
  380. End Sub
  381. Sub AgregarNumDiv()
  382. Dim Index As Integer = dgvIngresos.CurrentRow.Index
  383. Dim IndexAnterior As Integer = Index - 1
  384. Dim I_NumDivAnterior As Integer = 0
  385. Dim I_NumDivActual As Integer = 0
  386. Dim S_NumDivAnterior As String = String.Empty
  387. Dim S_NumDivActual As String = String.Empty
  388. S_NumDivActual = dgvIngresos.Rows(Index).Cells("NumDiv").Value
  389. I_NumDivActual = Operaciones.ConvertirEntero(S_NumDivActual)
  390. If Index > 0 Then
  391. S_NumDivAnterior = dgvIngresos.Rows(IndexAnterior).Cells("NumDiv").Value
  392. I_NumDivAnterior = Operaciones.ConvertirEntero(S_NumDivAnterior)
  393. If I_NumDivActual = 0 Then
  394. I_NumDivActual = I_NumDivAnterior + 1
  395. dgvIngresos.Rows(Index).Cells("NumDiv").Value = I_NumDivActual
  396. End If
  397. Else
  398. If I_NumDivActual = 0 Then
  399. I_NumDivActual = 1
  400. dgvIngresos.Rows(Index).Cells("NumDiv").Value = I_NumDivActual
  401. End If
  402. End If
  403. End Sub
  404. Sub AgregarCorrelativo()
  405. Dim Cantidad As Integer = dgvIngresos.Rows.Count - 2
  406. Dim Index As Integer = 0
  407. While Index <= Cantidad
  408. Dim Correlativo As Integer = Index + 1
  409. dgvIngresos.Rows(Index).Cells("correlativo").Value = Correlativo
  410. Index += 1
  411. End While
  412. End Sub
  413. Sub CalculosTabla()
  414. AgregarCorrelativo()
  415. AgregarFecha()
  416. AgregarDias()
  417. AgregarDividendo()
  418. AgregarIngreso()
  419. AgregarRendimientos()
  420. AgregarNumDiv()
  421. End Sub
  422. Sub CargarPeriodicidad()
  423. Me.cboPeriodicidad.DataSource = oDAOGeneral.ListaPeriodicidad
  424. Me.cboPeriodicidad.DisplayMember = "Descripcion"
  425. Me.cboPeriodicidad.ValueMember = "Codigo"
  426. ' Me.cboPeriodicidad.SelectedIndex = -1
  427. End Sub
  428. Private Sub Calculos()
  429. Dim SCuotasDeParticipacion As String = String.Empty
  430. Dim SValorParticipacion As String = String.Empty
  431. Dim SValorNominal As String = String.Empty
  432. Dim SValorTransado As String = String.Empty
  433. Dim SDiasPlazo As String = String.Empty
  434. Dim SPorcentajeComisionCasa As String = String.Empty
  435. Dim SPorcentajeComisionBolsa As String = String.Empty
  436. Dim SComisionCasa As String = String.Empty
  437. Dim SComisionBolsa As String = String.Empty
  438. Dim SDiasLiquidos As String = String.Empty
  439. Dim ICuotasDeParticipacion As Double = 0
  440. Dim IValorParticipacion As Double = 0
  441. Dim IValorNominal As Double = 0
  442. Dim IValorTransado As Double = 0
  443. Dim FechaLiquidacion As Date = Date.Today.Date
  444. Dim FechaOperacion As Date = Date.Today.Date
  445. Dim FechaVencimiento As Date = Date.Today.Date
  446. Dim IDiasPlazo As Integer = 0
  447. Dim IPorcentajeComisionCasa As Double = 0
  448. Dim IPorcentajeComisionBolsa As Double = 0
  449. Dim IComisionCasa As Double = 0
  450. Dim IComisionBolsa As Double = 0
  451. Dim IDiasLiquidos As Integer = 0
  452. SDiasPlazo = txtPlazo.Text.ToString
  453. IDiasPlazo = Operaciones.ConvertirEntero(SDiasPlazo)
  454. SDiasLiquidos = txtDiasLiq.Text.ToString
  455. IDiasLiquidos = Operaciones.ConvertirEntero(SDiasLiquidos)
  456. SPorcentajeComisionCasa = txtPorcentajeComisionCasa.Text.ToString
  457. IPorcentajeComisionCasa = Operaciones.ConvertirDecimal(SPorcentajeComisionCasa) / 100
  458. SPorcentajeComisionBolsa = txtPorcentajeComisionBolsa.Text.ToString
  459. IPorcentajeComisionBolsa = Operaciones.ConvertirDecimal(SPorcentajeComisionBolsa) / 100
  460. SCuotasDeParticipacion = txtCuotasDeParticipacion.Text.ToString
  461. ICuotasDeParticipacion = Operaciones.ConvertirDecimal(SCuotasDeParticipacion)
  462. SValorParticipacion = txtValorDeParticipacion.Text.ToString
  463. IValorParticipacion = Operaciones.ConvertirDecimal(SValorParticipacion)
  464. FechaOperacion = dtpFechaOperacion.Value
  465. txtValorNominal.Text = oCEFOIN.CalculoValorNominal(ICuotasDeParticipacion, IValorParticipacion)
  466. SValorNominal = txtValorNominal.Text.ToString
  467. IValorNominal = Operaciones.ConvertirDecimal(SValorNominal)
  468. txtValorTransado.Text = IValorNominal
  469. IValorTransado = IValorNominal
  470. dtpFechaLiquidacion.Value = FechaOperacion
  471. dtpFechaLiquidacion.Value = oCEFOIN.CalculoFechaLiq(FechaOperacion, IDiasLiquidos)
  472. FechaLiquidacion = dtpFechaLiquidacion.Value
  473. txtComisionCasa.Text = CalculoComision(IPorcentajeComisionCasa, IValorTransado)
  474. txtComisionBolsa.Text = CalculoComision(IPorcentajeComisionBolsa, IValorTransado)
  475. IndexBase = cboAnioBase.SelectedIndex
  476. If (IndexBase = 0 Or IndexBase = 2) Then
  477. dtpFechaVencimiento.Value = Operaciones.FechaDias360(FechaLiquidacion, IDiasPlazo)
  478. ElseIf IndexBase = 1 Or IndexBase = 3 Then
  479. dtpFechaVencimiento.Value = FechaLiquidacion.AddDays(IDiasPlazo)
  480. End If
  481. End Sub
  482. Function CalculoComision(ByVal PorcComision As Double, ByVal ValTra As Double)
  483. Return PorcComision * ValTra
  484. End Function
  485. Private Sub txtCuotasDeParticipacion_TextChanged(sender As Object, e As EventArgs) Handles txtCuotasDeParticipacion.TextChanged
  486. If Not Double.TryParse(txtCuotasDeParticipacion.Text, oCEFOIN.CuotasDeParticipacion) Then
  487. lblErrCuotasDeParticipacion.Visible = True
  488. Else
  489. lblErrCuotasDeParticipacion.Visible = False
  490. End If
  491. Calculos()
  492. End Sub
  493. Private Sub txtCuotasDeParticipacion_LostFocus(sender As Object, e As EventArgs) Handles txtCuotasDeParticipacion.LostFocus
  494. If Not Double.TryParse(txtCuotasDeParticipacion.Text, oCEFOIN.CuotasDeParticipacion) Then
  495. lblErrCuotasDeParticipacion.Visible = True
  496. Else
  497. lblErrCuotasDeParticipacion.Visible = False
  498. End If
  499. Me.txtCuotasDeParticipacion.Text = oCEFOIN.CuotasDeParticipacion.ToString()
  500. RefrescarValorControles()
  501. End Sub
  502. Private Sub txtValorDeParticipacion_TextChanged(sender As Object, e As EventArgs) Handles txtValorDeParticipacion.TextChanged
  503. If Not Double.TryParse(txtValorDeParticipacion.Text, oCEFOIN.ValorDeParticipacion) Then
  504. lblErrValorDeParticipacion.Visible = True
  505. Else
  506. lblErrValorDeParticipacion.Visible = False
  507. End If
  508. Calculos()
  509. End Sub
  510. Private Sub txtValorDeParticipacion_LostFocus(sender As Object, e As EventArgs) Handles txtValorDeParticipacion.LostFocus
  511. If Not Double.TryParse(txtValorDeParticipacion.Text, oCEFOIN.ValorDeParticipacion) Then
  512. lblErrValorDeParticipacion.Visible = True
  513. Else
  514. lblErrValorDeParticipacion.Visible = False
  515. End If
  516. Me.txtValorDeParticipacion.Text = oCEFOIN.ValorDeParticipacion.ToString()
  517. RefrescarValorControles()
  518. End Sub
  519. Sub RefrescarValorControles()
  520. Me.txtValorNominal.Text = oCEFOIN.ValorNominal.ToString()
  521. 'Me.txtCuotasDeParticipacion.Text = oCEFOIN.CuotasDeParticipacion.ToString(Configuraciones.CodigoTXTMontos)
  522. 'Me.txtValorDeParticipacion.Text = oCEFOIN.ValorDeParticipacion.ToString(Configuraciones.CodigoTXTMontos)
  523. 'Me.txtPorcentajeComisionCasa.Text = oCEFOIN.PorcentajeComisionCasa.ToString(Configuraciones.CodigoTXTPorcentaje)
  524. Me.txtComisionCasa.Text = oCEFOIN.ComisionCasa.ToString()
  525. 'Me.txtPorcentajeComisionBolsa.Text = oCEFOIN.PorcentajeComisionBolsa.ToString(Configuraciones.CodigoTXTPorcentaje)
  526. Me.txtComisionBolsa.Text = oCEFOIN.ComisionBolsa.ToString()
  527. Me.txtValorTransado.Text = oCEFOIN.ValorTransado.ToString()
  528. 'Me.dtpFechaOperacion.Value = oCEFOIN.FechaOperacion
  529. 'Me.dtpFechaLiquidacion.Value = oCEFOIN.FechaLiquidacion
  530. 'Me.dtpFechaVencimiento.Value = oCEFOIN.FechaVencimiento
  531. 'Me.txtRendimientoOfrecido.Text = oCEFOIN.RendimientoOfrecido.ToString(Configuraciones.CodigoTXTPorcentaje)
  532. 'Me.cboPeriodicidad.SelectedValue = oCEFOIN.Periodicidad
  533. 'Me.cboAnioBase.SelectedValue = oCEFOIN.AnioBase
  534. End Sub
  535. Private Sub txtPorcentajeComisionCasa_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeComisionCasa.TextChanged
  536. Dim valor As Double
  537. If (txtPorcentajeComisionCasa.ToString.IndexOf("%") = -1) Then
  538. txtPorcentajeComisionCasa.Text += "%"
  539. End If
  540. If Not Double.TryParse(Me.txtPorcentajeComisionCasa.Text.Replace("%", ""), valor) Then
  541. lblErrComisionCasa.Visible = True
  542. Else
  543. lblErrComisionCasa.Visible = False
  544. End If
  545. oCEFOIN.PorcentajeComisionCasa = valor / 100
  546. Calculos()
  547. End Sub
  548. Private Sub txtPorcentajeComisionCasa_LostFocus(sender As Object, e As EventArgs) Handles txtPorcentajeComisionCasa.LostFocus
  549. Me.txtPorcentajeComisionCasa.Text = oCEFOIN.PorcentajeComisionCasa.ToString(Configuraciones.CodigoTXTPorcentaje)
  550. RefrescarValorControles()
  551. End Sub
  552. Private Sub txtPorcentajeComisionBolsa_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeComisionBolsa.TextChanged
  553. Dim valor As Double
  554. If (txtPorcentajeComisionBolsa.ToString.IndexOf("%") = -1) Then
  555. txtPorcentajeComisionBolsa.Text += "%"
  556. End If
  557. If Not Double.TryParse(Me.txtPorcentajeComisionBolsa.Text.Replace("%", ""), valor) Then
  558. lblErrComisionBolsa.Visible = True
  559. Else
  560. lblErrComisionBolsa.Visible = False
  561. End If
  562. oCEFOIN.PorcentajeComisionBolsa = valor / 100
  563. Calculos()
  564. End Sub
  565. Private Sub txtPorcentajeComisionBolsa_LostFocus(sender As Object, e As EventArgs) Handles txtPorcentajeComisionBolsa.LostFocus
  566. Me.txtPorcentajeComisionBolsa.Text = oCEFOIN.PorcentajeComisionBolsa.ToString(Configuraciones.CodigoTXTPorcentaje)
  567. RefrescarValorControles()
  568. End Sub
  569. Private Sub dtpFechaOperacion_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaOperacion.ValueChanged
  570. Calculos()
  571. 'oCEFOIN.FechaOperacion = dtpFechaOperacion.Value.Date
  572. End Sub
  573. Private Sub dtpFechaLiquidacion_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaLiquidacion.ValueChanged
  574. oCEFOIN.FechaLiquidacion = dtpFechaLiquidacion.Value.Date
  575. End Sub
  576. Private Sub dtpFechaVencimiento_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimiento.ValueChanged
  577. oCEFOIN.FechaVencimiento = dtpFechaVencimiento.Value.Date
  578. End Sub
  579. Private Sub txtRendimientoOfrecido_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoOfrecido.TextChanged
  580. 'Dim valor As Double
  581. 'If Not Double.TryParse(txtRendimientoOfrecido.Text.Replace("%", ""), valor) Then
  582. 'lblErrRendimientoOfrecido.Visible = True
  583. 'Else
  584. 'lblErrRendimientoOfrecido.Visible = False
  585. 'End If
  586. 'oCEFOIN.RendimientoOfrecido = valor / 100
  587. Calculos()
  588. If (txtRendimientoOfrecido.ToString.IndexOf("%") = -1) Then
  589. txtRendimientoOfrecido.Text += "%"
  590. End If
  591. End Sub
  592. Private Sub txtRendimientoOfrecido_LostFocus(sender As Object, e As EventArgs) Handles txtRendimientoOfrecido.LostFocus
  593. ' txtRendimientoOfrecido.Text = oCEFOIN.RendimientoOfrecido.ToString(Configuraciones.CodigoTXTPorcentaje)
  594. End Sub
  595. Private Sub cboPeriodicidad_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboPeriodicidad.SelectedIndexChanged
  596. If Not TypeOf cboPeriodicidad.SelectedValue Is DataRowView Then
  597. If Not cboPeriodicidad.SelectedValue Is Nothing Then
  598. oCEFOIN.Periodicidad = cboPeriodicidad.SelectedValue.ToString
  599. End If
  600. End If
  601. End Sub
  602. Private Sub cboAnioBase_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboAnioBase.SelectedIndexChanged
  603. If Not TypeOf cboAnioBase.SelectedItem Is DataRowView Then
  604. oCEFOIN.AnioBase = cboAnioBase.SelectedItem
  605. End If
  606. End Sub
  607. Private Sub txtPlazo_TextChanged(sender As Object, e As EventArgs) Handles txtPlazo.TextChanged
  608. Calculos()
  609. End Sub
  610. Private Sub btnRefrescar_Click(sender As Object, e As EventArgs) Handles btnQuitar.Click
  611. 'Dim coleccion = ColeccionFINV1()
  612. 'GuardarData.GuardarDataGrid(coleccion, Variables.Codigo)
  613. QuitarFila()
  614. End Sub
  615. Sub CargarDGVIngresos()
  616. 'Dim FondoInversion As New FondoInversionDAO
  617. 'Dim dr = FondoInversion.CargarData(Variables.Codigo)
  618. 'Dim fecha As String
  619. 'While dr.Read
  620. ' fecha = Format(dr("FechaCorte"), "dd/MM/yyyy").ToString
  621. ' dgvIngresos.Rows.Add(dr("correlativo"), fecha, dr("Dias"), dr("Dividendo"), dr("Ingreso"), dr("RendMensual"))
  622. 'End While
  623. End Sub
  624. Private Sub txtDividendo_TextChanged(sender As Object, e As EventArgs)
  625. 'Dim valor As Double
  626. 'If Not Double.TryParse(Me.txtDividendo.Text.Replace("%", ""), valor) Then
  627. 'lblErrDividendo.Visible = True
  628. 'Else
  629. 'lblErrDividendo.Visible = False
  630. 'End If
  631. 'oCEFOIN.Dividendo = valor / 100
  632. Calculos()
  633. End Sub
  634. Private Sub txtDividendo_LostFocus(sender As Object, e As EventArgs)
  635. 'Me.txtDividendo.Text = oCEFOIN.Dividendo.ToString(Configuraciones.CodigoTXTPorcentaje)
  636. End Sub
  637. Private Sub txtCuotasDeParticipacion_KeyUp(sender As Object, e As KeyEventArgs) Handles txtCuotasDeParticipacion.KeyUp
  638. Calculos()
  639. End Sub
  640. Private Sub txtValorDeParticipacion_KeyUp(sender As Object, e As KeyEventArgs) Handles txtValorDeParticipacion.KeyUp
  641. Calculos()
  642. End Sub
  643. Private Sub txtDiasLiq_KeyUp(sender As Object, e As KeyEventArgs) Handles txtDiasLiq.KeyUp
  644. Calculos()
  645. End Sub
  646. Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
  647. TipoTransaccion = "M"
  648. btnAccion.Text = "Modificar"
  649. End Sub
  650. Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
  651. TipoTransaccion = "N"
  652. btnAccion.Text = "Nuevo"
  653. End Sub
  654. Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
  655. TipoTransaccion = "B"
  656. btnAccion.Text = "Eliminar"
  657. End Sub
  658. Private Sub btnAccion_Click(sender As Object, e As EventArgs) Handles btnAccion.Click
  659. Dim codigo As String = Variables.Codigo
  660. Dim Coleccion As Collection = ColeccionDatos()
  661. Dim Diccionario As Dictionary(Of String, Collection) = NuevoIngresoDiccionario()
  662. If (TipoTransaccion = "N") Then
  663. FOIN.ProcesoDatos(Coleccion, codigo, Diccionario, "Nuevo")
  664. ElseIf (TipoTransaccion = "M") Then
  665. FOIN.ProcesoDatos(Coleccion, codigo, Diccionario, "Modificar")
  666. ElseIf (TipoTransaccion = "B") Then
  667. Eliminar()
  668. ElseIf Not ExisteValidacion() Then
  669. Variables.ColeccionFINV = Coleccion
  670. Variables.ColeccionFINVDi = Diccionario
  671. Me.Close()
  672. End If
  673. End Sub
  674. Sub Eliminar()
  675. Dim codigo As String = Variables.Codigo
  676. FOIN.Eliminar(codigo)
  677. End Sub
  678. Function ExisteValidacion()
  679. Dim General As New DAOGeneral
  680. Dim Codigo As String = Variables.Codigo
  681. Dim Tabla As String = String.Empty
  682. Tabla = "FINV"
  683. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  684. Return Existe
  685. End Function
  686. Private Function NuevoIngresoDiccionario()
  687. Dim Diccionario As New Dictionary(Of String, Collection)
  688. Dim Cantidad As Integer = dgvIngresos.Rows.Count - 2
  689. Dim Index As Integer = 0
  690. While Index <= Cantidad
  691. Dim coleccion As New Collection
  692. Dim FechaCorte, Dias, Dividendo, Ingreso, RendMensual, NumDiv
  693. NumDiv = dgvIngresos.Rows(Index).Cells("NumDiv").Value
  694. FechaCorte = dgvIngresos.Rows(Index).Cells("Fecha de Corte").Value
  695. Dias = dgvIngresos.Rows(Index).Cells("Dias").Value
  696. Dividendo = (CDec(dgvIngresos.Rows(Index).Cells("Dividendo").Value.ToString.Trim("%")) / 100)
  697. Ingreso = dgvIngresos.Rows(Index).Cells("Ingresos").Value
  698. RendMensual = (dgvIngresos.Rows(Index).Cells("Rendimiento Mensual").Value.ToString.Trim("%") / 100)
  699. coleccion.Add(NumDiv)
  700. coleccion.Add(FechaCorte)
  701. coleccion.Add(Dias)
  702. coleccion.Add(Dividendo)
  703. coleccion.Add(Ingreso)
  704. coleccion.Add(RendMensual)
  705. Diccionario.Add(NumDiv, coleccion)
  706. Index += 1
  707. End While
  708. Return Diccionario
  709. End Function
  710. Private Function ColeccionDatos()
  711. Dim Coleccion As New Collection
  712. Dim TipoCalculo As String = Me.TipoCalculo
  713. Coleccion.Add(txtValorNominal.Text)
  714. Coleccion.Add(txtCuotasDeParticipacion.Text)
  715. Coleccion.Add(txtValorDeParticipacion.Text)
  716. Coleccion.Add((txtPorcentajeComisionCasa.Text.ToString.Trim("%")) / 100)
  717. Coleccion.Add((txtPorcentajeComisionBolsa.Text.ToString.Trim("%")) / 100)
  718. Coleccion.Add(txtComisionCasa.Text)
  719. Coleccion.Add(txtComisionBolsa.Text)
  720. Coleccion.Add(txtValorTransado.Text)
  721. Coleccion.Add(dtpFechaOperacion.Value)
  722. Coleccion.Add(dtpFechaLiquidacion.Value)
  723. Coleccion.Add(dtpFechaVencimiento.Value)
  724. Coleccion.Add(txtDiasLiq.Text)
  725. Coleccion.Add(CDec(txtRendimientoOfrecido.Text.ToString.Trim("%")) / 100)
  726. Coleccion.Add(cboPeriodicidad.SelectedValue)
  727. Coleccion.Add(cboAnioBase.SelectedIndex)
  728. Coleccion.Add(txtPlazo.Text)
  729. Coleccion.Add(txtDividendo.Text.ToString.Trim("%") / 100)
  730. Coleccion.Add(TipoCalculo)
  731. Return Coleccion
  732. End Function
  733. Function TipoCalculo()
  734. Dim TipCalculo As String = "FinMes"
  735. If RadioButton1.Checked Then
  736. TipCalculo = "FinMes"
  737. Else
  738. If RadioButton2.Checked Then
  739. TipCalculo = "Mensual"
  740. End If
  741. End If
  742. Return TipCalculo
  743. End Function
  744. Private Sub CargarRegistroPrincipal()
  745. Dim FONV As New FondoInversionDAO
  746. Dim Codigo As String = Variables.Codigo
  747. Dim Coleccion As Collection = FONV.Cargar(Codigo)
  748. Dim TipoOperacion As String = String.Empty
  749. If Not Coleccion.Count = 0 Then
  750. txtValorNominal.Text = Operaciones.ConvertirDecimal(Coleccion(1).ToString)
  751. txtCuotasDeParticipacion.Text = Operaciones.ConvertirDecimal(Coleccion(2).ToString)
  752. txtValorDeParticipacion.Text = Operaciones.ConvertirDecimal(Coleccion(3).ToString)
  753. txtPorcentajeComisionCasa.Text = Operaciones.ConvertirDecimal((Coleccion(4) * 100).ToString)
  754. txtPorcentajeComisionBolsa.Text = Operaciones.ConvertirDecimal((Coleccion(5) * 100).ToString)
  755. txtComisionCasa.Text = Operaciones.ConvertirDecimal(Coleccion(6).ToString)
  756. txtComisionBolsa.Text = Operaciones.ConvertirDecimal(Coleccion(7).ToString)
  757. txtValorTransado.Text = Operaciones.ConvertirDecimal(Coleccion(8).ToString)
  758. dtpFechaOperacion.Value = Operaciones.ConvertirFecha(Coleccion(9).ToString)
  759. dtpFechaLiquidacion.Value = Operaciones.ConvertirFecha(Coleccion(10).ToString)
  760. dtpFechaVencimiento.Value = Operaciones.ConvertirFecha(Coleccion(11))
  761. txtDiasLiq.Text = Operaciones.ConvertirEntero(Coleccion(12).ToString)
  762. txtRendimientoOfrecido.Text = Operaciones.ConvertirDecimal((Coleccion(13) * 100).ToString)
  763. cboPeriodicidad.SelectedValue = Coleccion(14).ToString
  764. cboAnioBase.SelectedIndex = Operaciones.ConvertirEntero(Coleccion(15).ToString)
  765. txtPlazo.Text = Operaciones.ConvertirEntero(Coleccion(16).ToString)
  766. txtDividendo.Text = Operaciones.ConvertirDecimal((Coleccion(17) * 100).ToString)
  767. TipoOperacion = Coleccion(18).ToString
  768. If TipoOperacion = "FinMes" Then
  769. RadioButton1.Checked = True
  770. Else
  771. If TipoOperacion = "Mensual" Then
  772. RadioButton2.Checked = True
  773. End If
  774. End If
  775. End If
  776. End Sub
  777. Sub CargarFilas()
  778. Dim FONV As New FondoInversionDAO
  779. Dim Codigo As String = Variables.Codigo
  780. Dim Tabla As DataTable = FONV.CargarFilas(Codigo)
  781. For Each rows As DataRow In Tabla.Rows
  782. Dim NumDiv As Integer = 0
  783. Dim Fecha As Date = Date.Today.Date
  784. Dim Dias As Integer = 0
  785. Dim Dividendo As String = String.Empty
  786. Dim Ingreso As Double = 0
  787. Dim Rend As String = String.Empty
  788. NumDiv = Operaciones.ConvertirEntero(rows("NumDiv").ToString)
  789. Fecha = Operaciones.ConvertirFecha(rows("Fecha").ToString)
  790. Dias = Operaciones.ConvertirEntero(rows("Dias").ToString)
  791. Dividendo = (Operaciones.ConvertirDecimal(rows("Dividendo").ToString) * 100).ToString + "%"
  792. Ingreso = Operaciones.ConvertirDecimal(rows("Ingreso").ToString)
  793. Rend = (Operaciones.ConvertirDecimal(rows("Rend").ToString) * 100).ToString + "%"
  794. dgvIngresos.Rows.Add("", Fecha, Dias, Dividendo, Ingreso, Rend, NumDiv)
  795. Next
  796. AgregarCorrelativo()
  797. End Sub
  798. Private Sub Button1_Click(sender As Object, e As EventArgs)
  799. End Sub
  800. Sub AgregarCampos()
  801. Dim CantidadColumnas As Integer = dgvIngresos.ColumnCount
  802. If CantidadColumnas = 0 Then
  803. Dim FechaCorte, Dias, Dividendo, Ingreso, RendMensual, correlativo, NumDiv As New DataGridViewTextBoxColumn
  804. correlativo.Name = "correlativo"
  805. FechaCorte.Name = "Fecha de Corte"
  806. Dias.Name = "Dias"
  807. Dividendo.Name = "Dividendo"
  808. Ingreso.Name = "Ingresos"
  809. RendMensual.Name = "Rendimiento Mensual"
  810. NumDiv.Name = "NumDiv"
  811. dgvIngresos.Columns.Add(correlativo)
  812. dgvIngresos.Columns.Add(FechaCorte)
  813. dgvIngresos.Columns.Add(Dias)
  814. dgvIngresos.Columns.Add(Dividendo)
  815. dgvIngresos.Columns.Add(Ingreso)
  816. dgvIngresos.Columns.Add(RendMensual)
  817. dgvIngresos.Columns.Add(NumDiv)
  818. End If
  819. End Sub
  820. Private Sub dgvIngresos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellContentClick
  821. End Sub
  822. Private Sub dgvIngresos_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgvIngresos.CellMouseClick
  823. 'Calculos()
  824. CalculosTabla()
  825. End Sub
  826. Private Sub dgvIngresos_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellEndEdit
  827. CargarDatos()
  828. CalculoDGT()
  829. End Sub
  830. Private Sub txtDiasLiq_TextChanged(sender As Object, e As EventArgs) Handles txtDiasLiq.TextChanged
  831. Rellenar()
  832. Calculos()
  833. End Sub
  834. Private Sub btnModificar_Click(sender As Object, e As EventArgs)
  835. End Sub
  836. Private Sub btnEliminar_Click(sender As Object, e As EventArgs)
  837. End Sub
  838. Private Sub BindingNavigator1_RefreshItems(sender As Object, e As EventArgs) Handles BindingNavigator1.RefreshItems
  839. End Sub
  840. Private Sub btnRescate_Click(sender As Object, e As EventArgs)
  841. 'frmRescate.Show()
  842. End Sub
  843. Private Sub txtCuotasDeParticipacion_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtCuotasDeParticipacion.KeyPress
  844. If String.IsNullOrEmpty(sender.Text) Then
  845. If e.KeyChar = "." Then
  846. sender.Text = "0"
  847. Exit Sub
  848. End If
  849. End If
  850. If (Not sender.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  851. Operaciones.ValidarEntrada(sender, e, True)
  852. Else
  853. Operaciones.ValidarEntrada(sender, e, False)
  854. End If
  855. End Sub
  856. Private Sub txtValorDeParticipacion_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtValorDeParticipacion.KeyPress
  857. If String.IsNullOrEmpty(sender.Text) Then
  858. If e.KeyChar = "." Then
  859. sender.Text = "0"
  860. Exit Sub
  861. End If
  862. End If
  863. If (Not sender.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  864. Operaciones.ValidarEntrada(sender, e, True)
  865. Else
  866. Operaciones.ValidarEntrada(sender, e, False)
  867. End If
  868. End Sub
  869. Private Sub txtPorcentajeComisionCasa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeComisionCasa.KeyPress
  870. If String.IsNullOrEmpty(sender.Text) Then
  871. If e.KeyChar = "." Then
  872. sender.Text = "0"
  873. Exit Sub
  874. End If
  875. End If
  876. If (Not sender.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  877. Operaciones.ValidarEntrada(sender, e, True)
  878. Else
  879. Operaciones.ValidarEntrada(sender, e, False)
  880. End If
  881. End Sub
  882. Private Sub txtPorcentajeComisionBolsa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeComisionBolsa.KeyPress
  883. If String.IsNullOrEmpty(sender.Text) Then
  884. If e.KeyChar = "." Then
  885. sender.Text = "0"
  886. Exit Sub
  887. End If
  888. End If
  889. If (Not sender.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  890. Operaciones.ValidarEntrada(sender, e, True)
  891. Else
  892. Operaciones.ValidarEntrada(sender, e, False)
  893. End If
  894. End Sub
  895. Private Sub txtDiasLiq_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtDiasLiq.KeyPress
  896. If String.IsNullOrEmpty(sender.Text) Then
  897. If e.KeyChar = "." Then
  898. sender.Text = "0"
  899. Exit Sub
  900. End If
  901. End If
  902. If (Not sender.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  903. Operaciones.ValidarEntrada(sender, e, True)
  904. Else
  905. Operaciones.ValidarEntrada(sender, e, False)
  906. End If
  907. End Sub
  908. Private Sub txtRendimientoOfrecido_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtRendimientoOfrecido.KeyPress
  909. If String.IsNullOrEmpty(sender.Text) Then
  910. If e.KeyChar = "." Then
  911. sender.Text = "0"
  912. Exit Sub
  913. End If
  914. End If
  915. If (Not sender.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  916. Operaciones.ValidarEntrada(sender, e, True)
  917. Else
  918. Operaciones.ValidarEntrada(sender, e, False)
  919. End If
  920. End Sub
  921. Private Sub txtPlazo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPlazo.KeyPress
  922. If String.IsNullOrEmpty(sender.Text) Then
  923. If e.KeyChar = "." Then
  924. sender.Text = "0"
  925. Exit Sub
  926. End If
  927. End If
  928. If (Not sender.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  929. Operaciones.ValidarEntrada(sender, e, True)
  930. Else
  931. Operaciones.ValidarEntrada(sender, e, False)
  932. End If
  933. End Sub
  934. Private Sub GroupBox3_Enter(sender As Object, e As EventArgs) Handles GroupBox3.Enter
  935. End Sub
  936. Private Sub GroupBox2_Enter(sender As Object, e As EventArgs) Handles GroupBox2.Enter
  937. End Sub
  938. Private Sub dgvIngresos_Click(sender As Object, e As EventArgs) Handles dgvIngresos.Click
  939. End Sub
  940. Private Sub Button1_Click_1(sender As Object, e As EventArgs)
  941. CargarDatos()
  942. End Sub
  943. Private Sub DateTimePicker1_ValueChanged(sender As Object, e As EventArgs)
  944. End Sub
  945. Private Sub btnCancelat_Click(sender As Object, e As EventArgs) Handles btnCancelat.Click
  946. Me.Close()
  947. End Sub
  948. Sub QuitarFila()
  949. Dim CantidadFilas As Integer = dgvIngresos.Rows.Count - 1
  950. If CantidadFilas > 0 Then
  951. Dim result As Integer = MsgBox("¿Está seguro que desea eliminar la fila?", MsgBoxStyle.OkCancel)
  952. ' Test result.
  953. Dim codigo As String = Variables.Codigo
  954. Dim Numero As Integer = dgvIngresos.CurrentRow.Cells("NumDiv").Value
  955. If result = MsgBoxResult.Ok Then
  956. Try
  957. dgvIngresos.Rows.Remove(dgvIngresos.CurrentRow)
  958. FOIN.EliminarIngreso(codigo, Numero)
  959. Catch ex As Exception
  960. MsgBox("No ha seleccionado una fila")
  961. End Try
  962. End If
  963. Else
  964. MsgBox("Actualmente no tiene registros")
  965. End If
  966. End Sub
  967. Private Sub txtCuotasDeParticipacion_Leave(sender As Object, e As EventArgs) Handles txtCuotasDeParticipacion.Leave
  968. Rellenar()
  969. End Sub
  970. Private Sub txtValorDeParticipacion_Leave(sender As Object, e As EventArgs) Handles txtValorDeParticipacion.Leave
  971. Rellenar()
  972. End Sub
  973. Private Sub txtPorcentajeComisionCasa_Leave(sender As Object, e As EventArgs) Handles txtPorcentajeComisionCasa.Leave
  974. Rellenar()
  975. End Sub
  976. Private Sub txtPorcentajeComisionBolsa_Leave(sender As Object, e As EventArgs) Handles txtPorcentajeComisionBolsa.Leave
  977. Rellenar()
  978. End Sub
  979. Private Sub txtDiasLiq_Leave(sender As Object, e As EventArgs) Handles txtDiasLiq.Leave
  980. Rellenar()
  981. End Sub
  982. Private Sub txtRendimientoOfrecido_Leave(sender As Object, e As EventArgs) Handles txtRendimientoOfrecido.Leave
  983. Rellenar()
  984. End Sub
  985. Private Sub txtPlazo_Leave(sender As Object, e As EventArgs) Handles txtPlazo.Leave
  986. Rellenar()
  987. End Sub
  988. Private Sub txtDividendo_TextChanged_1(sender As Object, e As EventArgs) Handles txtDividendo.TextChanged
  989. If (txtDividendo.ToString.IndexOf("%") = -1) Then
  990. txtDividendo.Text += "%"
  991. End If
  992. Rellenar()
  993. End Sub
  994. Private Sub txtDividendo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtDividendo.KeyPress
  995. If String.IsNullOrEmpty(sender.Text) Then
  996. If e.KeyChar = "." Then
  997. sender.Text = "0"
  998. Exit Sub
  999. End If
  1000. End If
  1001. If (Not sender.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1002. Operaciones.ValidarEntrada(sender, e, True)
  1003. Else
  1004. Operaciones.ValidarEntrada(sender, e, False)
  1005. End If
  1006. End Sub
  1007. Sub CargarTransladoNuevo()
  1008. Dim Existe As Boolean = ExisteInversion()
  1009. If Not RetCodigoInversionExiste And Not Existe Then
  1010. txtRendimientoOfrecido.Text = Variables.RetRendimiento
  1011. txtCuotasDeParticipacion.Text = Variables.RetCuotaParticipacionFINV
  1012. txtValorDeParticipacion.Text = Variables.RetValorParticipacionFINV
  1013. End If
  1014. End Sub
  1015. End Class