frmPrestamoPersonal.vb 46 KB

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