frmPrestamoPersonal.vb 46 KB

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