frmPrestamoPersonal.vb 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519
  1. Imports System.Reflection
  2. Public Class frmPrestamoPersonal
  3. Dim Prestamo As New PrestamoPersonalCE
  4. Dim PrestamoConsulta As New PrestamoPersonalDAO
  5. Dim EstadoAccion As String = "Nada"
  6. Dim IndexIterable As Boolean = True
  7. Dim Operaciones As New Operaciones
  8. Dim FinCarga As Boolean = False
  9. Dim FechaCorte As Date
  10. Dim IndexCorte As Integer = 0
  11. Private Sub frmPrestamoPersonal_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  12. dgvAmortizacion.Columns.Clear()
  13. AgregarCampos()
  14. CargarColecciones()
  15. CargarAmortizacion()
  16. FinCarga = True
  17. Formato()
  18. Calculos(False)
  19. ' Calculos()
  20. ExisteInversion()
  21. ValidarExistencia()
  22. CargarTransladoNuevo()
  23. End Sub
  24. Function ExisteInversion()
  25. Dim Codigo As String = Variables.Codigo
  26. Dim TablaINV As String = "INV0"
  27. Dim TablaPINV As String = "PIN0"
  28. Dim General As New DAOGeneral
  29. Dim InvPro = Variables.InvPro
  30. If InvPro = "I" Then
  31. Dim INV0 As Boolean = General.ExisteTitulo(Codigo, TablaINV)
  32. If INV0 Then
  33. navNuevo.Visible = True
  34. Return True
  35. Else
  36. navNuevo.Visible = False
  37. Return False
  38. End If
  39. End If
  40. If InvPro = "P" Then
  41. Dim PINV0 As Boolean = General.ExisteTitulo(Codigo, TablaPINV)
  42. If PINV0 Then
  43. navNuevo.Visible = True
  44. Return True
  45. Else
  46. navNuevo.Visible = False
  47. Return False
  48. End If
  49. End If
  50. Return False
  51. End Function
  52. Private Sub LLenarCuotaSinSeguro()
  53. Dim MontoPrestamo As Double = 0
  54. Dim CuotasMensuales As Integer = 0
  55. Dim TasaInteres As Double = 0
  56. If Not String.IsNullOrEmpty(txtMontoPrestamo.Text) Then
  57. MontoPrestamo = txtMontoPrestamo.Text
  58. End If
  59. If Not String.IsNullOrEmpty(txtCuotasMensuales.Text) Then
  60. CuotasMensuales = txtCuotasMensuales.Text
  61. End If
  62. If Not String.IsNullOrEmpty(txtTasaInteres.Text.Trim("%")) Then
  63. TasaInteres = txtTasaInteres.Text.Trim("%")
  64. End If
  65. If (Not MontoPrestamo = 0 And Not CuotasMensuales = 0 And Not TasaInteres = 0) Then
  66. txtCuotaSinSeguro.Text = Prestamo.TIR(MontoPrestamo, CuotasMensuales, TasaInteres / 100)
  67. End If
  68. If Not String.IsNullOrEmpty(txtCuotaSinSeguro.Text) Then
  69. If Double.IsInfinity(txtCuotaSinSeguro.Text) Then
  70. txtCuotaSinSeguro.Text = 0
  71. End If
  72. End If
  73. End Sub
  74. Private Sub txtTasaInteres_KeyUp(sender As Object, e As KeyEventArgs) Handles txtTasaInteres.KeyUp
  75. If txtTasaInteres.Text = "." Then
  76. txtTasaInteres.Text = ".0"
  77. End If
  78. LLenarCuotaSinSeguro()
  79. End Sub
  80. Private Sub txtMontoPrestamo_KeyUp(sender As Object, e As KeyEventArgs) Handles txtMontoPrestamo.KeyUp
  81. If txtMontoPrestamo.Text = "." Then
  82. txtMontoPrestamo.Text = ".0"
  83. End If
  84. LLenarCuotaSinSeguro()
  85. End Sub
  86. Private Sub txtCuotasMensuales_KeyUp(sender As Object, e As KeyEventArgs) Handles txtCuotasMensuales.KeyUp
  87. If txtCuotasMensuales.Text = "." Then
  88. txtCuotasMensuales.Text = ".0"
  89. End If
  90. LLenarCuotaSinSeguro()
  91. End Sub
  92. Private Sub txtSeguro_KeyUp(sender As Object, e As KeyEventArgs) Handles txtSeguro.KeyUp
  93. If txtSeguro.Text = "." Then
  94. txtSeguro.Text = ".0"
  95. End If
  96. Dim CuotaSinSeguro As Double = 0
  97. Dim Seguro As Double = 0
  98. If Not String.IsNullOrEmpty(txtCuotaSinSeguro.Text) Then
  99. CuotaSinSeguro = txtCuotaSinSeguro.Text
  100. End If
  101. If Not String.IsNullOrEmpty(txtSeguro.Text) Then
  102. Seguro = txtSeguro.Text
  103. End If
  104. txtCuotaReal.Text = Prestamo.SumarCuota(CuotaSinSeguro, Seguro)
  105. End Sub
  106. Sub AgregarCampos()
  107. Dim Numero, Periodo, Fecha, FechaCorte, SaldoInicial, PagoCuota, PagoInteresIVA, IVA, PagoInteres, Abono, PrestamoRem, PagoSeguroDaños, PagoSeguroVivienda, TotalCuota, TotalPagado, AbonoExtra As New DataGridViewTextBoxColumn
  108. Numero.Name = "No. Cuota"
  109. Fecha.Name = "Fecha"
  110. FechaCorte.Name = "Fecha de Corte"
  111. Periodo.Name = "Periodo"
  112. SaldoInicial.Name = "Saldo Inicial"
  113. PagoCuota.Name = "Pago Cuota Mensual"
  114. PagoInteresIVA.Name = "Pago Interes(IVA)"
  115. IVA.Name = "IVA de Intereses"
  116. PagoInteres.Name = "Pago de Intereses"
  117. Abono.Name = "Abono a Capital"
  118. PrestamoRem.Name = "Prestamo Remanente"
  119. PagoSeguroDaños.Name = "Pago de Seguro de Daños"
  120. PagoSeguroVivienda.Name = "Pago de Seguro de Vivienda"
  121. TotalCuota.Name = "Total Cuota Mensual"
  122. TotalPagado.Name = "Total Pagado"
  123. AbonoExtra.Name = "Abono Extra a Capital"
  124. dgvAmortizacion.Columns.Add(Numero)
  125. dgvAmortizacion.Columns.Add(FechaCorte)
  126. dgvAmortizacion.Columns.Add(Fecha)
  127. dgvAmortizacion.Columns.Add(Periodo)
  128. dgvAmortizacion.Columns.Add(SaldoInicial)
  129. dgvAmortizacion.Columns.Add(PagoCuota)
  130. dgvAmortizacion.Columns.Add(PagoInteresIVA)
  131. dgvAmortizacion.Columns.Add(IVA)
  132. dgvAmortizacion.Columns.Add(PagoInteres)
  133. dgvAmortizacion.Columns.Add(Abono)
  134. dgvAmortizacion.Columns.Add(PrestamoRem)
  135. dgvAmortizacion.Columns.Add(PagoSeguroDaños)
  136. dgvAmortizacion.Columns.Add(PagoSeguroVivienda)
  137. dgvAmortizacion.Columns.Add(TotalCuota)
  138. dgvAmortizacion.Columns.Add(TotalPagado)
  139. dgvAmortizacion.Columns.Add(AbonoExtra)
  140. End Sub
  141. Sub CargarDatos()
  142. Dim Index As Integer = dgvAmortizacion.CurrentRow.Index
  143. Dim Anterior As Integer = Index - 1
  144. Dim Cantidad As Integer = dgvAmortizacion.Rows.Count
  145. Dim Fecha = Date.Today.Date
  146. Dim strFecha = Format(Fecha, "dd/MM/yyyy")
  147. If (String.IsNullOrEmpty(dgvAmortizacion.Rows(Index).Cells("Fecha").Value)) Then
  148. dgvAmortizacion.Rows(Index).Cells("Fecha").Value = strFecha
  149. End If
  150. End Sub
  151. Sub Formato()
  152. If (String.IsNullOrEmpty(txtCuotasMensuales.Text.ToString)) Then
  153. txtCuotasMensuales.Text = "0.0"
  154. End If
  155. If (String.IsNullOrEmpty(txtTasaInteres.Text.ToString)) Then
  156. txtTasaInteres.Text = "0.0"
  157. End If
  158. If (String.IsNullOrEmpty(txtAñoPrestamo.Text.ToString)) Then
  159. txtAñoPrestamo.Text = 0
  160. End If
  161. If (String.IsNullOrEmpty(txtCuotasMensuales.Text.ToString)) Then
  162. txtCuotasMensuales.Text = "0.0"
  163. End If
  164. If (String.IsNullOrEmpty(txtMontoPrestamo.Text.ToString)) Then
  165. txtMontoPrestamo.Text = "0.0"
  166. End If
  167. If (String.IsNullOrEmpty(txtPeriodo.Text.ToString)) Then
  168. txtPeriodo.Text = 0
  169. End If
  170. If (String.IsNullOrEmpty(txtCuotaSinSeguro.Text.ToString)) Then
  171. txtCuotaSinSeguro.Text = Format(txtCuotaSinSeguro.Text, "0.0")
  172. If Double.IsInfinity(txtCuotaSinSeguro.Text) Then
  173. txtCuotaSinSeguro.Text = Format(txtCuotaSinSeguro.Text, "0.0")
  174. End If
  175. End If
  176. If (String.IsNullOrEmpty(txtSeguro.Text.ToString) Or txtSeguro.Text.ToString = "0") Then
  177. txtSeguro.Text = Format(txtSeguro.Text, "0.0")
  178. End If
  179. If (String.IsNullOrEmpty(txtCuotaReal.Text.ToString) Or txtCuotaReal.Text.ToString = "0") Then
  180. txtCuotaReal.Text = "0.0"
  181. End If
  182. If (txtTasaInteres.Text.ToString.IndexOf("%") = -1) Then
  183. txtTasaInteres.Text = txtTasaInteres.Text.ToString + "%"
  184. End If
  185. End Sub
  186. Sub Calculos(ByVal Corte As Boolean)
  187. If (FinCarga) Then
  188. Dim FechaInicial = dtpFechaOtorgamiento.Value
  189. Dim FechaFinal = dtpFechaOtorgamiento.Value
  190. Dim FechaVencimiento = dtpFechaOtorgamiento.Value
  191. Dim FechaVen = dtpFechaPago.Value
  192. Dim FechaAux = dtpFechaOtorgamiento.Value
  193. Dim Index = 0
  194. Dim Contador As Integer = 1
  195. Dim BaseContador As Integer = 0
  196. If Not String.IsNullOrEmpty(txtCuotasMensuales.Text) Then
  197. BaseContador = txtCuotasMensuales.Text
  198. End If
  199. Dim V_txtTasaInteres As Double = 0.0
  200. If (String.IsNullOrEmpty(txtTasaInteres.Text.Trim("%"))) Then
  201. V_txtTasaInteres = 0
  202. Else
  203. V_txtTasaInteres = txtTasaInteres.Text.TrimEnd("%") / 100
  204. End If
  205. LLenarCuotaSinSeguro()
  206. Dim Cantidad As Integer = dgvAmortizacion.Rows.Count
  207. Dim TipoCalculo As Integer = 0
  208. If (FechaInicial.Day = 31) Then
  209. TipoCalculo = 1
  210. ElseIf (FechaInicial.Day = 30) Then
  211. TipoCalculo = 2
  212. ElseIf (FechaInicial.Day = 29) Then
  213. TipoCalculo = 3
  214. Else
  215. TipoCalculo = 4
  216. End If
  217. Dim Salir As Boolean = False
  218. Dim TotalCuotas As Double = 0
  219. If Not String.IsNullOrEmpty(txtCuotasMensuales.Text) Then
  220. TotalCuotas = txtCuotasMensuales.Text
  221. End If
  222. Dim FechaAnterior As Date = FechaInicial
  223. Dim FechaPrimera = FechaInicial, FechaUltima = FechaInicial
  224. Dim AumentarDia As Boolean = False
  225. Dim DisminuirDia30 As Integer = True
  226. While (True)
  227. Dim Eliminar As Integer = dgvAmortizacion.Rows.Count - 2
  228. Dim CuotasMensuales As Integer = 0
  229. If Not String.IsNullOrEmpty(txtCuotasMensuales.Text) Then
  230. CuotasMensuales = txtCuotasMensuales.Text
  231. End If
  232. If Eliminar > CuotasMensuales Then
  233. While True
  234. If Eliminar >= CuotasMensuales Then
  235. dgvAmortizacion.Rows.Remove(dgvAmortizacion.Rows(Eliminar))
  236. Eliminar -= 1
  237. Else
  238. Exit While
  239. End If
  240. End While
  241. End If
  242. Dim ContadorMes As Integer = 0
  243. Dim Dia As Integer = 0
  244. Dia = FechaInicial.Day
  245. FechaPrimera = FechaInicial
  246. If (TipoCalculo = 1) Then
  247. FechaAnterior = FechaInicial
  248. If (Operaciones.AñoBisiesto(FechaAnterior) = 365) Then
  249. If FechaInicial.Month = 1 Then
  250. FechaUltima = FechaInicial.AddDays(29)
  251. FechaInicial = FechaInicial.AddDays(29)
  252. ElseIf (FechaInicial.Month = 12 Or FechaInicial.Month = 2 Or FechaInicial.Month = 4 Or FechaInicial.Month = 6 Or FechaInicial.Month = 7 Or FechaInicial.Month = 9 Or FechaInicial.Month = 11) Then
  253. FechaUltima = FechaInicial.AddDays(31)
  254. FechaInicial = FechaInicial.AddDays(31)
  255. Else
  256. FechaUltima = FechaInicial.AddDays(30)
  257. FechaInicial = FechaInicial.AddDays(30)
  258. End If
  259. Else
  260. If FechaInicial.Month = 1 Then
  261. FechaUltima = FechaInicial.AddDays(28)
  262. FechaInicial = FechaInicial.AddDays(28)
  263. ElseIf (FechaInicial.Month = 12 Or FechaInicial.Month = 2 Or FechaInicial.Month = 4 Or FechaInicial.Month = 6 Or FechaInicial.Month = 7 Or FechaInicial.Month = 9 Or FechaInicial.Month = 11) Then
  264. FechaUltima = FechaInicial.AddDays(31)
  265. FechaInicial = FechaInicial.AddDays(31)
  266. Else
  267. FechaUltima = FechaInicial.AddDays(30)
  268. FechaInicial = FechaInicial.AddDays(30)
  269. End If
  270. End If
  271. End If
  272. If (TipoCalculo = 3 Or TipoCalculo = 2) Then
  273. 'Fecha Anterior toma el valor de la primera fecha y fecha ultima, como la ultima
  274. If (FechaInicial.Month = 2) Then
  275. FechaAnterior = FechaInicial
  276. If (Operaciones.AñoBisiesto(FechaAnterior) = 365) Then
  277. If (TipoCalculo = 2) Then
  278. If FechaInicial.Month = 1 Then
  279. FechaUltima = FechaInicial.AddDays(29)
  280. FechaInicial = FechaInicial.AddDays(29)
  281. Else
  282. FechaUltima = FechaInicial.AddMonths(1)
  283. FechaInicial = FechaInicial.AddMonths(1)
  284. End If
  285. If (TipoCalculo = 2) Then
  286. DisminuirDia30 = 1
  287. End If
  288. Else
  289. If FechaInicial.Month = 1 Then
  290. FechaUltima = FechaInicial.AddDays(29)
  291. FechaInicial = FechaInicial.AddDays(29)
  292. Else
  293. FechaUltima = FechaInicial.AddMonths(1)
  294. FechaInicial = FechaInicial.AddMonths(1)
  295. End If
  296. If (TipoCalculo = 1) Then
  297. DisminuirDia30 = 1
  298. End If
  299. End If
  300. Else
  301. If (TipoCalculo = 2) Then
  302. If FechaInicial.Month = 1 Then
  303. FechaUltima = FechaInicial.AddDays(29)
  304. FechaInicial = FechaInicial.AddDays(29)
  305. Else
  306. FechaUltima = FechaInicial.AddMonths(1)
  307. FechaInicial = FechaInicial.AddMonths(1)
  308. End If
  309. If (TipoCalculo = 2) Then
  310. DisminuirDia30 = 1
  311. AumentarDia = True
  312. End If
  313. Else
  314. FechaUltima = FechaInicial.AddDays(29)
  315. FechaInicial = FechaInicial.AddDays(29)
  316. If (TipoCalculo = 1) Then
  317. DisminuirDia30 = 2
  318. ElseIf (TipoCalculo = 2) Then
  319. AumentarDia = True
  320. End If
  321. End If
  322. End If
  323. Else
  324. If (AumentarDia) Then
  325. FechaInicial = FechaInicial.AddDays(1)
  326. FechaPrimera = FechaInicial
  327. AumentarDia = False
  328. End If
  329. If (DisminuirDia30 = 1) Then
  330. FechaInicial = FechaInicial.AddDays(1)
  331. FechaPrimera = FechaInicial
  332. DisminuirDia30 = False
  333. ElseIf (DisminuirDia30 = 2) Then
  334. FechaInicial = FechaInicial.AddDays(2)
  335. FechaPrimera = FechaInicial
  336. DisminuirDia30 = False
  337. End If
  338. FechaAnterior = FechaInicial
  339. FechaUltima = FechaInicial.AddMonths(1)
  340. FechaInicial = FechaInicial.AddMonths(1)
  341. End If
  342. End If
  343. If (TipoCalculo = 4) Then
  344. FechaAnterior = FechaInicial
  345. FechaUltima = FechaInicial.AddMonths(1)
  346. FechaInicial = FechaInicial.AddMonths(1)
  347. End If
  348. If (Corte) Then
  349. If (Index >= IndexCorte) Then
  350. While Not FechaUltima.Date <= FechaCorte.Date
  351. FechaUltima = FechaUltima.AddDays(-1)
  352. End While
  353. Salir = True
  354. End If
  355. Else
  356. If (Contador >= TotalCuotas) Then
  357. Salir = True
  358. End If
  359. End If
  360. Dim PeriodoDias As Integer = 0
  361. Dim PagoDeCuotaMensual As Double = 0
  362. Dim PagoIni As Double = 0
  363. Dim PagoIVA As Double = 0
  364. Dim PagoInt As Double = 0
  365. Dim IVAInteres As Double = 0
  366. Dim SegDaños As Double = 0
  367. Dim SegVivienda As Double = 0
  368. Dim TotalPagado As Double = 0
  369. Dim AbonoDinero As Double = 0
  370. Dim PrestRemanente As Double = 0
  371. Dim Agregar As Integer = dgvAmortizacion.Rows.Count - 2
  372. Dim FechaProv As Date = Date.Now.Date
  373. Dim CambioFecha As Boolean = False
  374. If Agregar >= Index Then
  375. If Not (dgvAmortizacion.Rows(Index).Cells("Fecha de Corte").Value) Is DBNull.Value Then
  376. If Not String.IsNullOrEmpty(dgvAmortizacion.Rows(Index).Cells("Fecha de Corte").Value) Then
  377. FechaProv = FechaUltima
  378. FechaUltima = dgvAmortizacion.Rows(Index).Cells("Fecha de Corte").Value
  379. CambioFecha = True
  380. End If
  381. End If
  382. End If
  383. If Index = 0 Then
  384. If CkbPrueba.Checked Then
  385. FechaAnterior = dtpFechaPago.Value
  386. Dim FechaResp As Date = FechaAnterior
  387. Dim Meses As Integer = FechaResp.Month
  388. While Meses = FechaResp.Month
  389. FechaResp = FechaResp.AddDays(1)
  390. End While
  391. FechaUltima = FechaResp.AddDays(-1)
  392. End If
  393. End If
  394. PeriodoDias = Periodo(Index, FechaAnterior, FechaUltima)
  395. If Double.IsInfinity(PeriodoDias) Then
  396. PeriodoDias = 0
  397. End If
  398. PagoDeCuotaMensual = PagoCuotaMensual(Index, PeriodoDias, V_txtTasaInteres)
  399. If Double.IsInfinity(PagoDeCuotaMensual) Or Double.IsNaN(PagoDeCuotaMensual) Then
  400. PagoDeCuotaMensual = 0
  401. End If
  402. PagoIni = PagoInicial(Index)
  403. If Double.IsInfinity(PagoIni) Then
  404. PagoIni = 0
  405. End If
  406. PagoIVA = PagoInteresIVA(Index, PagoIni, PeriodoDias, FechaAnterior, FechaUltima, Contador, V_txtTasaInteres)
  407. If Double.IsInfinity(PagoIVA) Then
  408. PagoIVA = 0
  409. End If
  410. PagoInt = PagoIntereses(Index, PagoIVA)
  411. If Double.IsInfinity(PagoInt) Then
  412. PagoInt = 0
  413. End If
  414. IVAInteres = IVAIntereses(Index, PagoIVA, PagoInt)
  415. If Double.IsInfinity(IVAInteres) Then
  416. IVAInteres = 0
  417. End If
  418. SegDaños = SeguroDaños(Index)
  419. If Double.IsInfinity(SegDaños) Then
  420. SegDaños = 0
  421. End If
  422. SegVivienda = SeguroVivienda(Index)
  423. If Double.IsInfinity(SegVivienda) Then
  424. SegVivienda = 0
  425. End If
  426. TotalPagado = TotalCuota(Index, SegDaños, SegVivienda, PagoDeCuotaMensual)
  427. If Double.IsInfinity(TotalPagado) Then
  428. TotalPagado = 0
  429. End If
  430. AbonoDinero = Abono(Index, TotalPagado, PagoIVA)
  431. If Double.IsInfinity(AbonoDinero) Then
  432. AbonoDinero = 0
  433. End If
  434. PrestRemanente = PrestamoRemanente(Index, AbonoDinero)
  435. If Double.IsInfinity(PrestRemanente) Then
  436. PrestRemanente = 0
  437. End If
  438. Dim CuotaSeguro As Double = 0
  439. Dim Seguro As Double = 0
  440. If Not String.IsNullOrEmpty(txtCuotaSinSeguro.Text) Then
  441. CuotaSeguro = txtCuotaSinSeguro.Text
  442. End If
  443. If Not String.IsNullOrEmpty(txtSeguro.Text) Then
  444. Seguro = txtSeguro.Text
  445. End If
  446. txtCuotaReal.Text = Prestamo.SumarCuota(CuotaSeguro, Seguro)
  447. If Double.IsInfinity(txtCuotaReal.Text) Then
  448. txtCuotaReal.Text = 0
  449. End If
  450. If Agregar >= Index Then
  451. If CambioFecha Then
  452. FechaUltima = FechaProv
  453. CambioFecha = False
  454. End If
  455. End If
  456. Dim FechaCalculo As Date = FechaUltima
  457. Dim FechaRespaldo As Date = FechaUltima
  458. Dim Mes = FechaCalculo.Month
  459. While Mes = FechaCalculo.Month
  460. FechaCalculo = FechaCalculo.AddDays(1)
  461. End While
  462. FechaUltima = FechaCalculo.AddDays(-1)
  463. If Cantidad > 1 Then
  464. If Agregar >= Index Then
  465. dgvAmortizacion.Rows(Index).Cells("Fecha").Value = FechaUltima
  466. dgvAmortizacion.Rows(Index).Cells("Periodo").Value = PeriodoDias
  467. If Double.IsInfinity(PagoIni) Then
  468. PagoIni = 0
  469. End If
  470. dgvAmortizacion.Rows(Index).Cells("Saldo Inicial").Value = PagoIni
  471. If Double.IsInfinity(PagoDeCuotaMensual) Then
  472. PagoDeCuotaMensual = 0
  473. End If
  474. dgvAmortizacion.Rows(Index).Cells("Pago Cuota Mensual").Value = PagoDeCuotaMensual
  475. If Double.IsInfinity(PagoIVA) Then
  476. PagoIVA = 0
  477. End If
  478. dgvAmortizacion.Rows(Index).Cells("Pago Interes(IVA)").Value = PagoIVA
  479. If Double.IsInfinity(IVAInteres) Then
  480. IVAInteres = 0
  481. End If
  482. dgvAmortizacion.Rows(Index).Cells("IVA de Intereses").Value = IVAInteres
  483. If Double.IsInfinity(PagoInt) Then
  484. PagoInt = 0
  485. End If
  486. dgvAmortizacion.Rows(Index).Cells("Pago de Intereses").Value = PagoInt
  487. If Double.IsInfinity(AbonoDinero) Then
  488. AbonoDinero = 0
  489. End If
  490. dgvAmortizacion.Rows(Index).Cells("Abono a Capital").Value = AbonoDinero
  491. If Double.IsInfinity(PrestRemanente) Then
  492. PrestRemanente = 0
  493. End If
  494. dgvAmortizacion.Rows(Index).Cells("Prestamo Remanente").Value = PrestRemanente
  495. If Double.IsInfinity(SegDaños) Then
  496. SegDaños = 0
  497. End If
  498. dgvAmortizacion.Rows(Index).Cells("Pago de Seguro de Daños").Value = SegDaños
  499. If Double.IsInfinity(SegVivienda) Then
  500. SegVivienda = 0
  501. End If
  502. dgvAmortizacion.Rows(Index).Cells("Pago de Seguro de Vivienda").Value = SegVivienda
  503. If Double.IsInfinity(TotalPagado) Then
  504. TotalPagado = 0
  505. End If
  506. dgvAmortizacion.Rows(Index).Cells("Total Pagado").Value = TotalPagado
  507. dgvAmortizacion.Rows(Index).Cells("Total Cuota Mensual").Value = TotalPagado
  508. Else
  509. dgvAmortizacion.Rows.Add(Contador, "", FechaUltima, PeriodoDias, PagoIni, PagoDeCuotaMensual, PagoIVA, IVAInteres, PagoInt, AbonoDinero, PrestRemanente, SegDaños, SegVivienda, TotalPagado, TotalPagado, 0)
  510. End If
  511. Else
  512. dgvAmortizacion.Rows.Add(Contador, "", FechaUltima, PeriodoDias, PagoIni, PagoDeCuotaMensual, PagoIVA, IVAInteres, PagoInt, AbonoDinero, PrestRemanente, SegDaños, SegVivienda, TotalPagado, TotalPagado, 0)
  513. End If
  514. FechaUltima = FechaRespaldo
  515. Contador += 1
  516. If (Salir) Then
  517. Exit While
  518. End If
  519. Index += 1
  520. End While
  521. End If
  522. 'Else
  523. 'Dim Index As Integer = dgvAmortizacion.CurrentRow.Index
  524. 'dgvAmortizacion.Rows(Index).Cells(2).Value = Periodo(Index)
  525. 'dgvAmortizacion.Rows(Index).Cells(4).Value = PagoCuotaMensual(Index)
  526. 'If (String.IsNullOrEmpty(dgvAmortizacion.Rows(Index).Cells(10).Value)) Then
  527. ' dgvAmortizacion.Rows(Index).Cells(10).Value = SeguroDaños(Index)
  528. 'End If
  529. 'If (String.IsNullOrEmpty(dgvAmortizacion.Rows(Index).Cells(11).Value)) Then
  530. ' dgvAmortizacion.Rows(Index).Cells(11).Value = SeguroVivienda(Index)
  531. 'End If
  532. 'dgvAmortizacion.Rows(Index).Cells(12).Value = TotalCuota(Index)
  533. 'dgvAmortizacion.Rows(Index).Cells(13).Value = TotalCuota(Index)
  534. 'If (String.IsNullOrEmpty(dgvAmortizacion.Rows(Index).Cells(14).Value)) Then
  535. ' dgvAmortizacion.Rows(Index).Cells(14).Value = 0
  536. ' End If
  537. ' dgvAmortizacion.Rows(Index).Cells(3).Value = PagoInicial(Index)
  538. ' dgvAmortizacion.Rows(Index).Cells(5).Value = PagoInteresIVA(Index)
  539. ' dgvAmortizacion.Rows(Index).Cells(7).Value = PagoIntereses(Index)
  540. ' dgvAmortizacion.Rows(Index).Cells(6).Value = IVAIntereses(Index)
  541. ' dgvAmortizacion.Rows(Index).Cells(8).Value = Abono(Index)
  542. ' dgvAmortizacion.Rows(Index).Cells(9).Value = PrestamoRemanente(Index)
  543. 'IndexIterable = False
  544. End Sub
  545. Function Periodo(ByVal Index As Integer, ByVal Fech As Date, ByVal Fecha2 As Date)
  546. Dim Valor
  547. Valor = Prestamo.Periodo(Fech, Fecha2)
  548. Return Valor
  549. End Function
  550. Function PagoCuotaMensual(ByVal Index As Integer, ByVal Dias As Integer, ByVal V_txtTasaInteres As Double)
  551. Dim MontoPrestamo As Integer = 0
  552. Dim CuotasMensuales As Integer = 0
  553. If Not String.IsNullOrEmpty(txtMontoPrestamo.Text) Then
  554. MontoPrestamo = txtMontoPrestamo.Text
  555. End If
  556. If Not String.IsNullOrEmpty(txtCuotasMensuales.Text) Then
  557. CuotasMensuales = txtCuotasMensuales.Text
  558. End If
  559. Dim Pago As Double = Prestamo.TIR(MontoPrestamo, CuotasMensuales, V_txtTasaInteres)
  560. Dim Total As Double = 0
  561. If (Index = 0) Then
  562. Total = Pago / 31 * Dias
  563. ElseIf (Index > 0) Then
  564. Total = Pago
  565. End If
  566. Return Total
  567. End Function
  568. Function SeguroDaños(ByVal Index As Integer)
  569. Dim Total As Double = 0
  570. If (Index = 0) Then
  571. Total = 0
  572. ElseIf (Index > 0) Then
  573. Index = Index - 1
  574. Total = dgvAmortizacion.Rows(Index).Cells("Pago de Seguro de Daños").Value
  575. End If
  576. Return Total
  577. End Function
  578. Function SeguroVivienda(ByVal Index As Integer)
  579. Dim Total As Double = 0
  580. If (Index = 0) Then
  581. Total = 0
  582. ElseIf (Index > 0) Then
  583. Index = Index - 1
  584. Total = dgvAmortizacion.Rows(Index).Cells("Pago de Seguro de Vivienda").Value
  585. End If
  586. Return Total
  587. End Function
  588. Function TotalCuota(ByVal Index As Integer, ByVal PagoSeguroDaño As Double, ByVal PagoSeguroVivienda As Double, ByVal PagoCuota As Double)
  589. Dim Total = PagoSeguroDaño + PagoSeguroVivienda + PagoCuota
  590. Return Total
  591. End Function
  592. Function PagoInicial(ByVal Index As Integer)
  593. Dim Total As Double = 0
  594. Dim Anterior As Integer = Index - 1
  595. If (Index = 0) Then
  596. If Not String.IsNullOrEmpty(txtMontoPrestamo.Text) Then
  597. Total = txtMontoPrestamo.Text
  598. End If
  599. ElseIf (Index > 0) Then
  600. Total = dgvAmortizacion.Rows(Anterior).Cells("Prestamo Remanente").Value
  601. End If
  602. Return Total
  603. End Function
  604. Function PagoInteresIVA(ByVal Index As Integer, ByVal SaldoInicial As Double, ByVal Periodo As Integer, ByVal Fechainicial As Date, ByVal FechaFinal As Date, ByVal Contador As Integer, ByVal V_txtTasaInteres As Double)
  605. Fechainicial = Format(Fechainicial, "yyyy/MM/dd")
  606. FechaFinal = Format(FechaFinal, "yyyy/MM/dd")
  607. Dim CambioDeFecha As Integer = Operaciones.CambioBase(Fechainicial, FechaFinal)
  608. Dim TasaInteres As New Double
  609. TasaInteres = V_txtTasaInteres
  610. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase(Fechainicial)
  611. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase(FechaFinal)
  612. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  613. Dim Valor1 = 0.0, Valor2 = 0.0, Valor = 0.0
  614. If (Not CambioDeFecha = 0) Then
  615. If CambioDeFecha = 1 Then
  616. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(Fechainicial, PrimeraFechaUltima, CambioDeFecha)
  617. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  618. Valor1 = SaldoInicial * TasaInteres * DiasPrimeraFecha / 366
  619. Valor2 = SaldoInicial * TasaInteres * DiasSegundaFecha / 365
  620. ElseIf CambioDeFecha = 2 Then
  621. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(Fechainicial, PrimeraFechaUltima, CambioDeFecha)
  622. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  623. Valor1 = SaldoInicial * TasaInteres * DiasPrimeraFecha / 365
  624. Valor2 = SaldoInicial * TasaInteres * DiasSegundaFecha / 366
  625. End If
  626. Valor = Valor1 + Valor2
  627. Else
  628. If (Operaciones.AñoBisiesto(Fechainicial) = 364) Then
  629. Valor = SaldoInicial * TasaInteres * Periodo / 365
  630. End If
  631. If (Operaciones.AñoBisiesto(Fechainicial) = 365) Then
  632. Valor = SaldoInicial * TasaInteres * Periodo / 366
  633. End If
  634. End If
  635. Return Valor
  636. End Function
  637. Function PagoIntereses(ByVal Index As Integer, ByVal PagoIVA As Double)
  638. Dim Total = PagoIVA / 1.13
  639. Return Total
  640. End Function
  641. Function IVAIntereses(ByVal Index As Integer, ByVal PagoIVA As Double, ByVal PagoIVAInt As Double)
  642. Dim Total As Double
  643. Total = PagoIVA - PagoIVAInt
  644. Return Total
  645. End Function
  646. Function Abono(ByVal Index As Integer, ByVal TotalPagado As Double, ByVal PagoInteres As Double)
  647. Dim Total As Double
  648. Total = TotalPagado - PagoInteres
  649. Return Total
  650. End Function
  651. Function PrestamoRemanente(ByVal Index As Integer, ByVal Abono As Double)
  652. Dim Total As Double = 0
  653. Dim Monto As Double = 0
  654. If Not String.IsNullOrEmpty(txtMontoPrestamo.Text) Then
  655. Monto = txtMontoPrestamo.Text
  656. End If
  657. Dim Anterior As Integer = Index - 1
  658. Try
  659. If (Index = 0) Then
  660. Total = CDec(Monto) - CDec(Abono)
  661. ElseIf (Index > 0) Then
  662. Dim AnteriorValor = dgvAmortizacion.Rows(Anterior).Cells("Prestamo Remanente").Value
  663. Total = AnteriorValor - Abono
  664. End If
  665. Catch ex As Exception
  666. Total = 0
  667. End Try
  668. Return Total
  669. End Function
  670. Private Sub dgvAmortizacion_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvAmortizacion.CellContentClick
  671. CargarDatos()
  672. ' Calculos()
  673. End Sub
  674. Private Sub dgvAmortizacion_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvAmortizacion.CellEndEdit
  675. CargarDatos()
  676. Calculos(False)
  677. End Sub
  678. Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
  679. EstadoAccion = "M"
  680. btnAccion.Text = "Modificar"
  681. 'btnagregar.Text = "Modificar"
  682. End Sub
  683. Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
  684. EstadoAccion = "N"
  685. btnAccion.Text = "Nuevo"
  686. ' btnagregar.Text = "Nuevo"
  687. End Sub
  688. Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
  689. EstadoAccion = "B"
  690. btnAccion.Text = "Eliminar"
  691. 'btnagregar.Text = "Eliminar"
  692. End Sub
  693. Sub CargarColecciones()
  694. CargarDeudor()
  695. CargarDetalles()
  696. ' CargarAmortizacion()
  697. End Sub
  698. Sub CargarDeudor()
  699. Dim codigo As String = Variables.Codigo
  700. Dim Retorno = PrestamoConsulta.CargarDeudor(codigo)
  701. Dim coleccion As New Collection
  702. If (TypeOf Retorno Is Boolean) Then
  703. Exit Sub
  704. Else
  705. coleccion = PrestamoConsulta.CargarDeudor(codigo)
  706. End If
  707. txtNombreDeudor.Text = coleccion(1)
  708. txtNumeroDeudor.Text = coleccion(2)
  709. dtpFechaPago.Value = coleccion(3)
  710. dtpFechaOtorgamiento.Value = coleccion(4)
  711. txtPeriodo.Text = coleccion(5)
  712. End Sub
  713. Sub CargarDetalles()
  714. Dim codigo As String = Variables.Codigo
  715. Dim Retorno = PrestamoConsulta.CargarDetalles(codigo)
  716. Dim coleccion As New Collection
  717. If (TypeOf Retorno Is Boolean) Then
  718. Exit Sub
  719. Else
  720. coleccion = PrestamoConsulta.CargarDetalles(codigo)
  721. End If
  722. txtTasaInteres.Text = CDec(coleccion(1)) * 100
  723. txtAñoPrestamo.Text = coleccion(2)
  724. txtCuotasMensuales.Text = coleccion(3)
  725. txtMontoPrestamo.Text = coleccion(4)
  726. txtSeguro.Text = coleccion(5)
  727. End Sub
  728. Sub CargarAmortizacion()
  729. Dim codigo As String = Variables.Codigo
  730. Dim dr = PrestamoConsulta.CargarAmortizacion(codigo)
  731. Dim Iterador As Integer = 0
  732. Dim ConvertirString As String
  733. While dr.Read
  734. ConvertirString = Format(dr("fecha"), "dd/MM/yyyy")
  735. dgvAmortizacion.Rows.Add(dr("correlativo"), dr("fechacorte").ToString, ConvertirString, dr("periodo"), dr("saldoinicial"), dr("pagocuota"), dr("pagointeresIVA"), dr("IVAinteres"), dr("pagointeres"), dr("abono"), dr("prestamoremanente"), dr("pagodanos"), dr("pagovivienta"), dr("totalcuota"), dr("totalpagado"), dr("abonoextra"))
  736. End While
  737. End Sub
  738. Function ValidarDatos()
  739. Dim Continuar = True
  740. If (String.IsNullOrEmpty(txtNombreDeudor.Text)) Then
  741. Continuar = False
  742. MsgBox("Agregue un Nombre")
  743. End If
  744. If (String.IsNullOrEmpty(txtNumeroDeudor.Text)) Then
  745. MsgBox("Agregue un Numero")
  746. Continuar = False
  747. End If
  748. Return Continuar
  749. End Function
  750. Private Sub btnAccion_Click(sender As Object, e As EventArgs) Handles btnAccion.Click
  751. Dim codigo As String = Variables.Codigo
  752. Dim colecciondetalle = ColeccionDetalles()
  753. Dim colecciondeuda = ColeccionDeudor()
  754. Dim diccionarioAmort As Dictionary(Of String, Collection) = NuevoAmortDiccionario()
  755. If (EstadoAccion = "B") Then
  756. PrestamoConsulta.Eliminar(codigo)
  757. 'PrestamoConsulta.EliminarDetalle(codigo)
  758. 'PrestamoConsulta.EliminarAmortizacion(codigo)
  759. ValidarExistencia()
  760. End If
  761. If (EstadoAccion = "M") Then
  762. Dim Validar = ValidarDatos()
  763. If (Validar) Then
  764. PrestamoConsulta.ProcesoDatos(colecciondeuda, colecciondetalle, codigo, diccionarioAmort, "Modificar", "Modificar")
  765. 'PrestamoConsulta.ModificarDetalle(colecciondetalle, codigo)
  766. 'PrestamoConsulta.ModificarDeudor(colecciondeuda, codigo)
  767. 'ModificarAmort(codigo)
  768. ValidarExistencia()
  769. End If
  770. End If
  771. If (EstadoAccion = "N") Then
  772. Dim Validar = ValidarDatos()
  773. If (Validar) Then
  774. PrestamoConsulta.ProcesoDatos(colecciondeuda, colecciondetalle, codigo, diccionarioAmort, "Nuevo", "Nuevo")
  775. 'PrestamoConsulta.NuevoDetalle(colecciondetalle, codigo)
  776. 'PrestamoConsulta.NuevoDeudor(colecciondeuda, codigo)
  777. 'NuevoAmort(codigo)
  778. ValidarExistencia()
  779. End If
  780. ElseIf Not ExisteValidacion() Then
  781. Variables.ColeccionPPERDETALLE = colecciondetalle
  782. Variables.ColeccionPPERDEUDOR = colecciondeuda
  783. Variables.ColeccionPPERAMORTDi = diccionarioAmort
  784. Me.Close()
  785. End If
  786. End Sub
  787. Sub ValidarExistencia()
  788. Dim General As New DAOGeneral
  789. Dim Codigo As String = Variables.Codigo
  790. Dim Tabla As String = String.Empty
  791. Tabla = "PPER0"
  792. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  793. If (Existe) Then
  794. navNuevo.Enabled = False
  795. navModificar.Enabled = True
  796. navEliminar.Enabled = True
  797. Else
  798. navNuevo.Enabled = True
  799. navModificar.Enabled = False
  800. navEliminar.Enabled = False
  801. 'LimpiarCampos()
  802. End If
  803. EstadoAccion = String.Empty
  804. btnAccion.Text = "Aceptar"
  805. End Sub
  806. Function ExisteValidacion()
  807. Dim General As New DAOGeneral
  808. Dim Codigo As String = Variables.Codigo
  809. Dim Tabla As String = String.Empty
  810. Tabla = "PPER0"
  811. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  812. Return Existe
  813. End Function
  814. Sub LimpiarCampos()
  815. dtpFechaOtorgamiento.Value = Date.Now.Date
  816. dtpFechaPago.Value = Date.Now.Date
  817. txtTasaInteres.Text = "0.0%"
  818. txtAñoPrestamo.Text = 0
  819. txtCuotasMensuales.Text = 0
  820. txtMontoPrestamo.Text = 0
  821. txtCuotaSinSeguro.Text = 0
  822. txtSeguro.Text = 0
  823. txtCuotaReal.Text = 0
  824. dgvAmortizacion.Rows.Clear()
  825. End Sub
  826. Function ColeccionDeudor()
  827. Dim coleccion As New Collection
  828. Dim NombreDeudor = txtNombreDeudor.Text
  829. Dim NumeroDeudor = txtNumeroDeudor.Text
  830. Dim fechaotor = dtpFechaOtorgamiento.Value
  831. Dim fechapago = dtpFechaPago.Value
  832. Dim periodogracias = txtPeriodo.Text
  833. coleccion.Add(NombreDeudor)
  834. coleccion.Add(NumeroDeudor)
  835. coleccion.Add(fechapago)
  836. coleccion.Add(fechaotor)
  837. coleccion.Add(periodogracias)
  838. Return coleccion
  839. End Function
  840. Function ColeccionDetalles()
  841. Dim coleccion As New Collection
  842. Dim tasainteres = CDec(txtTasaInteres.Text.ToString.TrimEnd("%")) / 100
  843. Dim duracionprestamo = txtAñoPrestamo.Text
  844. Dim totalcuotas = txtCuotasMensuales.Text
  845. Dim montoprestamo = txtMontoPrestamo.Text
  846. Dim seguro = txtSeguro.Text
  847. Dim CuotaSinSeguro = txtCuotaSinSeguro.Text
  848. Dim CuotaReal = txtCuotaReal.Text
  849. coleccion.Add(tasainteres)
  850. coleccion.Add(duracionprestamo)
  851. coleccion.Add(totalcuotas)
  852. coleccion.Add(montoprestamo)
  853. coleccion.Add(seguro)
  854. coleccion.Add(CuotaSinSeguro)
  855. coleccion.Add(CuotaReal)
  856. Return coleccion
  857. End Function
  858. Function coleccionAmortizacion(ByVal Index As Integer)
  859. Dim coleccion As New Collection
  860. Dim Posicion = dgvAmortizacion.Rows(Index).Cells("No. Cuota").Value
  861. Dim fecha = dgvAmortizacion.Rows(Index).Cells("Fecha").Value
  862. Dim fechaCorte = dgvAmortizacion.Rows(Index).Cells("Fecha de Corte").Value
  863. Dim Periodo = dgvAmortizacion.Rows(Index).Cells("Periodo").Value
  864. Dim saldoinicial = dgvAmortizacion.Rows(Index).Cells("Saldo Inicial").Value
  865. Dim pagocuota = dgvAmortizacion.Rows(Index).Cells("Pago Cuota Mensual").Value
  866. Dim PagoInteresIVA = dgvAmortizacion.Rows(Index).Cells("Pago Interes(IVA)").Value
  867. Dim IVAinteres = dgvAmortizacion.Rows(Index).Cells("IVA de Intereses").Value
  868. Dim pagointeres = dgvAmortizacion.Rows(Index).Cells("Pago de Intereses").Value
  869. Dim Abono = dgvAmortizacion.Rows(Index).Cells("Abono a Capital").Value
  870. Dim PrestamoRemanente = dgvAmortizacion.Rows(Index).Cells("Prestamo Remanente").Value
  871. Dim pagodanos = dgvAmortizacion.Rows(Index).Cells("Pago de Seguro de Daños").Value
  872. Dim pagovivienta = dgvAmortizacion.Rows(Index).Cells("Pago de Seguro de Vivienda").Value
  873. Dim TotalCuota = dgvAmortizacion.Rows(Index).Cells("Total Cuota Mensual").Value
  874. Dim totalpagado = dgvAmortizacion.Rows(Index).Cells("Total Pagado").Value
  875. Dim abonoextra = dgvAmortizacion.Rows(Index).Cells("Abono Extra a Capital").Value
  876. coleccion.Add(Posicion)
  877. coleccion.Add(fecha)
  878. coleccion.Add(Periodo)
  879. coleccion.Add(saldoinicial)
  880. coleccion.Add(pagocuota)
  881. coleccion.Add(PagoInteresIVA)
  882. coleccion.Add(IVAinteres)
  883. coleccion.Add(pagointeres)
  884. coleccion.Add(Abono)
  885. coleccion.Add(PrestamoRemanente)
  886. coleccion.Add(pagodanos)
  887. coleccion.Add(pagovivienta)
  888. coleccion.Add(TotalCuota)
  889. coleccion.Add(totalpagado)
  890. coleccion.Add(abonoextra)
  891. coleccion.Add(fechaCorte)
  892. Return coleccion
  893. End Function
  894. Sub NuevoAmort(ByVal codigo As String)
  895. Dim Index As Integer = dgvAmortizacion.Rows.Count - 2
  896. For i As Integer = 0 To Index
  897. Dim ColeccionAmort = coleccionAmortizacion(i)
  898. PrestamoConsulta.NuevaAmortizacion(ColeccionAmort, codigo)
  899. Next
  900. End Sub
  901. Function NuevoAmortDiccionario()
  902. Dim diccionario As New Dictionary(Of String, Collection)
  903. Dim Index As Integer = dgvAmortizacion.Rows.Count - 2
  904. For i As Integer = 0 To Index
  905. Dim ColeccionAmort = coleccionAmortizacion(i)
  906. diccionario.Add(i, ColeccionAmort)
  907. Next
  908. Return diccionario
  909. End Function
  910. Sub ModificarAmort(ByVal codigo As String)
  911. PrestamoConsulta.EliminarAmortizacion(codigo)
  912. NuevoAmort(codigo)
  913. End Sub
  914. Private Sub txtTasaInteres_TextChanged(sender As Object, e As EventArgs) Handles txtTasaInteres.TextChanged
  915. Calculos(False)
  916. End Sub
  917. Private Sub btnagregar_Click(sender As Object, e As EventArgs)
  918. 'Dim coleccionAmor = coleccionAmortizacion()
  919. 'Dim codigo As String = Variables.Codigo
  920. 'If (EstadoAccion = "N") Then
  921. ' PrestamoConsulta.NuevaAmortizacion(coleccionAmor, codigo)
  922. 'End If
  923. 'If (EstadoAccion = "B") Then
  924. ' Dim Siguiente = dgvAmortizacion.CurrentRow.Cells(0).Value
  925. ' PrestamoConsulta.EliminarAmortizacion(codigo, Siguiente)
  926. 'End If
  927. 'If (EstadoAccion = "M") Then
  928. ' PrestamoConsulta.ModificarAmortizacion(coleccionAmor, codigo)
  929. 'End If
  930. End Sub
  931. Private Sub btnAccion2_Click(sender As Object, e As EventArgs)
  932. End Sub
  933. Private Sub txtSeguro_TextChanged(sender As Object, e As EventArgs) Handles txtSeguro.TextChanged
  934. End Sub
  935. Private Sub Button1_Click(sender As Object, e As EventArgs)
  936. Calculos(False)
  937. End Sub
  938. Private Sub txtAñoPrestamo_TextChanged(sender As Object, e As EventArgs) Handles txtAñoPrestamo.TextChanged
  939. Calculos(False)
  940. End Sub
  941. Private Sub txtCuotasMensuales_TextChanged(sender As Object, e As EventArgs) Handles txtCuotasMensuales.TextChanged
  942. Calculos(False)
  943. End Sub
  944. Private Sub txtMontoPrestamo_TextChanged(sender As Object, e As EventArgs) Handles txtMontoPrestamo.TextChanged
  945. Calculos(False)
  946. End Sub
  947. Private Sub txtAplicacionCodigo_TextChanged(sender As Object, e As EventArgs)
  948. Calculos(False)
  949. End Sub
  950. Private Sub BindingNavigator1_RefreshItems(sender As Object, e As EventArgs) Handles BindingNavigator1.RefreshItems
  951. End Sub
  952. Private Sub txtCuotaSinSeguro_TextChanged(sender As Object, e As EventArgs) Handles txtCuotaSinSeguro.TextChanged
  953. End Sub
  954. Private Sub txtCuotaReal_TextChanged(sender As Object, e As EventArgs) Handles txtCuotaReal.TextChanged
  955. End Sub
  956. Private Sub txtTasaInteres_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtTasaInteres.KeyPress
  957. If String.IsNullOrEmpty(txtTasaInteres.Text) Then
  958. If e.KeyChar = "." Then
  959. txtTasaInteres.Text = "0"
  960. Exit Sub
  961. End If
  962. End If
  963. If (Not txtTasaInteres.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  964. Operaciones.ValidarEntrada(sender, e, True)
  965. Else
  966. Operaciones.ValidarEntrada(sender, e, False)
  967. End If
  968. End Sub
  969. Private Sub txtAñoPrestamo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtAñoPrestamo.KeyPress
  970. If String.IsNullOrEmpty(txtAñoPrestamo.Text) Then
  971. If e.KeyChar = "." Then
  972. txtAñoPrestamo.Text = "0"
  973. Exit Sub
  974. End If
  975. End If
  976. If (Not txtAñoPrestamo.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  977. Operaciones.ValidarEntrada(sender, e, True)
  978. Else
  979. Operaciones.ValidarEntrada(sender, e, False)
  980. End If
  981. End Sub
  982. Private Sub txtCuotasMensuales_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtCuotasMensuales.KeyPress
  983. If String.IsNullOrEmpty(txtCuotasMensuales.Text) Then
  984. If e.KeyChar = "." Then
  985. txtCuotasMensuales.Text = "0"
  986. Exit Sub
  987. End If
  988. End If
  989. If (Not txtCuotasMensuales.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  990. Operaciones.ValidarEntrada(sender, e, True)
  991. Else
  992. Operaciones.ValidarEntrada(sender, e, False)
  993. End If
  994. End Sub
  995. Private Sub txtMontoPrestamo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtMontoPrestamo.KeyPress
  996. If String.IsNullOrEmpty(txtMontoPrestamo.Text) Then
  997. If e.KeyChar = "." Then
  998. txtMontoPrestamo.Text = "0"
  999. Exit Sub
  1000. End If
  1001. End If
  1002. If (Not txtMontoPrestamo.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1003. Operaciones.ValidarEntrada(sender, e, True)
  1004. Else
  1005. Operaciones.ValidarEntrada(sender, e, False)
  1006. End If
  1007. End Sub
  1008. Private Sub txtSeguro_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtSeguro.KeyPress
  1009. If String.IsNullOrEmpty(txtSeguro.Text) Then
  1010. If e.KeyChar = "." Then
  1011. txtSeguro.Text = "0"
  1012. Exit Sub
  1013. End If
  1014. End If
  1015. If (Not txtSeguro.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1016. Operaciones.ValidarEntrada(sender, e, True)
  1017. Else
  1018. Operaciones.ValidarEntrada(sender, e, False)
  1019. End If
  1020. End Sub
  1021. Private Sub txtPeriodo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPeriodo.KeyPress
  1022. If String.IsNullOrEmpty(txtPeriodo.Text) Then
  1023. If e.KeyChar = "." Then
  1024. txtPeriodo.Text = "0"
  1025. Exit Sub
  1026. End If
  1027. End If
  1028. If (Not txtPeriodo.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1029. Operaciones.ValidarEntrada(sender, e, True)
  1030. Else
  1031. Operaciones.ValidarEntrada(sender, e, False)
  1032. End If
  1033. End Sub
  1034. Private Sub btnCancelar_Click(sender As Object, e As EventArgs)
  1035. End Sub
  1036. Private Sub txtPeriodo_TextChanged(sender As Object, e As EventArgs) Handles txtPeriodo.TextChanged
  1037. Calculos(False)
  1038. End Sub
  1039. Private Sub dtpFechaOtorgamiento_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaOtorgamiento.ValueChanged
  1040. Formato()
  1041. Calculos(False)
  1042. End Sub
  1043. Private Sub dtpFechaPago_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaPago.ValueChanged
  1044. Formato()
  1045. Calculos(False)
  1046. End Sub
  1047. Private Sub txtPeriodo_Leave(sender As Object, e As EventArgs) Handles txtPeriodo.Leave
  1048. Formato()
  1049. End Sub
  1050. Private Sub txtTasaInteres_Leave(sender As Object, e As EventArgs) Handles txtTasaInteres.Leave
  1051. Formato()
  1052. End Sub
  1053. Private Sub txtAñoPrestamo_Leave(sender As Object, e As EventArgs) Handles txtAñoPrestamo.Leave
  1054. Formato()
  1055. End Sub
  1056. Private Sub txtCuotasMensuales_Leave(sender As Object, e As EventArgs) Handles txtCuotasMensuales.Leave
  1057. Formato()
  1058. End Sub
  1059. Private Sub txtMontoPrestamo_Leave(sender As Object, e As EventArgs) Handles txtMontoPrestamo.Leave
  1060. Formato()
  1061. End Sub
  1062. Private Sub txtSeguro_Leave(sender As Object, e As EventArgs) Handles txtSeguro.Leave
  1063. Formato()
  1064. End Sub
  1065. Private Sub txtAñoPrestamo_KeyUp(sender As Object, e As KeyEventArgs) Handles txtAñoPrestamo.KeyUp
  1066. If txtAñoPrestamo.Text = "." Then
  1067. txtAñoPrestamo.Text = ".0"
  1068. End If
  1069. End Sub
  1070. Private Sub TabPage2_Click(sender As Object, e As EventArgs) Handles TabPage2.Click
  1071. End Sub
  1072. Sub CargarTransladoNuevo()
  1073. Dim Existe As Boolean = ExisteInversion()
  1074. If Not RetCodigoInversionExiste And Not Existe Then
  1075. txtMontoPrestamo.Text = Variables.RetMonto
  1076. txtTasaInteres.Text = Variables.RetRendimiento
  1077. End If
  1078. End Sub
  1079. End Class