frmPrestamoPersonal.vb 46 KB

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