PrestamoPersonalDAO.vb 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929
  1. Imports System.Data.SqlClient
  2. Public Class PrestamoPersonalDAO
  3. Public Function ProcesoDatos(ByVal Coleccion As Collection, ByVal Coleccion2 As Collection, ByVal Codigo As String, ByVal Diccionario As Dictionary(Of String, Collection), ByVal EstadoDeudor As String, ByVal EstadoDetalles As String)
  4. Dim objCon As New Conexion
  5. Dim retorno As Integer
  6. Dim sql As String
  7. Dim cmd As SqlCommand
  8. Dim myTrans As SqlTransaction
  9. Dim cn As SqlConnection = objCon.Conectar
  10. If cn.State = ConnectionState.Closed Then
  11. cn.Open()
  12. End If
  13. myTrans = cn.BeginTransaction()
  14. Try
  15. If EstadoDeudor = "Nuevo" Then
  16. sql = "INSERT INTO [dbo].[PPER0](
  17. [CodInv]
  18. ,[nombredeudor]
  19. ,[numerodeudor]
  20. ,[fechaotorga]
  21. ,[fechapago]
  22. ,[periodogracia]
  23. ) VALUES(
  24. @CodInv
  25. ,@nombredeudor
  26. ,@numerodeudor
  27. ,@fechaotorga
  28. ,@fechapago
  29. ,@periodogracia
  30. )
  31. "
  32. Else
  33. sql = "UPDATE [dbo].[PPER0] SET
  34. [nombredeudor]=@nombredeudor
  35. ,[numerodeudor]=@numerodeudor
  36. ,[fechaotorga]=@fechaotorga
  37. ,[fechapago]=@fechapago
  38. ,[periodogracia]=@periodogracia
  39. where [CodInv]=@CodInv
  40. "
  41. End If
  42. cmd = New SqlCommand
  43. cmd.CommandText = sql
  44. cmd.Connection = cn
  45. cmd.Transaction = myTrans
  46. With cmd.Parameters
  47. .Add("@CodInv", SqlDbType.VarChar).Value = Codigo
  48. .Add("@nombredeudor", SqlDbType.VarChar).Value = Coleccion(1)
  49. .Add("@numerodeudor", SqlDbType.VarChar).Value = Coleccion(2)
  50. .Add("@fechaotorga", SqlDbType.DateTime).Value = CDate(Coleccion(3))
  51. .Add("@fechapago", SqlDbType.DateTime).Value = CDate(Coleccion(4))
  52. .Add("@periodogracia", SqlDbType.Float).Value = CDec(Coleccion(5))
  53. End With
  54. retorno = cmd.ExecuteNonQuery
  55. If EstadoDetalles = "Nuevo" Then
  56. sql = "INSERT INTO [dbo].[PPER1](
  57. [CodInv]
  58. ,[tasainteres]
  59. ,[duracionprestamo]
  60. ,[totalcuotas]
  61. ,[montoprestamo]
  62. ,[seguro]
  63. ,[CuotaSinSeguro]
  64. ,[CuotaReal]
  65. ) VALUES(
  66. @CodInv
  67. ,@tasainteres
  68. ,@duracionprestamo
  69. ,@totalcuotas
  70. ,@montoprestamo
  71. ,@seguro
  72. ,@CuotaSinSeguro
  73. ,@CuotaReal
  74. )
  75. "
  76. Else
  77. sql = "UPDATE [dbo].[PPER1] SET
  78. [tasainteres]=@tasainteres
  79. ,[duracionprestamo]=@duracionprestamo
  80. ,[totalcuotas]=@totalcuotas
  81. ,[montoprestamo]=@montoprestamo
  82. ,[seguro]=@seguro
  83. ,[CuotaSinSeguro]=@CuotaSinSeguro
  84. ,[CuotaReal]=@CuotaReal
  85. where [CodInv]=@CodInv
  86. "
  87. End If
  88. cmd = New SqlCommand
  89. cmd.CommandText = sql
  90. cmd.Connection = cn
  91. cmd.Transaction = myTrans
  92. With cmd.Parameters
  93. .Add("@CodInv", SqlDbType.VarChar).Value = Codigo
  94. .Add("@tasainteres", SqlDbType.Float).Value = CDec(Coleccion2(1))
  95. .Add("@duracionprestamo", SqlDbType.Float).Value = CDec(Coleccion2(2))
  96. .Add("@totalcuotas", SqlDbType.Float).Value = CDec(Coleccion2(3))
  97. .Add("@montoprestamo", SqlDbType.Float).Value = CDec(Coleccion2(4))
  98. .Add("@seguro", SqlDbType.Float).Value = CDec(Coleccion2(5))
  99. .Add("@CuotaSinSeguro", SqlDbType.Float).Value = CDec(Coleccion2(6))
  100. .Add("@CuotaReal", SqlDbType.Float).Value = CDec(Coleccion2(7))
  101. End With
  102. retorno = cmd.ExecuteNonQuery
  103. sql = "DELETE FROM [dbo].[PPER2]
  104. WHERE [CodInv]=@CodInv "
  105. cmd = New SqlCommand
  106. cmd.CommandText = sql
  107. cmd.Connection = cn
  108. cmd.Transaction = myTrans
  109. cmd.Parameters.Add("@CodInv", SqlDbType.VarChar).Value = Codigo
  110. retorno = cmd.ExecuteNonQuery
  111. If Not Diccionario Is Nothing Then
  112. For Each DatosDiccionario In Diccionario
  113. Dim Coleccion3 As Collection = DatosDiccionario.Value
  114. sql = "INSERT INTO [dbo].[PPER2](
  115. [CodInv]
  116. ,[fecha]
  117. ,[Periodo]
  118. ,[saldoinicial]
  119. ,[pagocuota]
  120. ,[pagointeresIVA]
  121. ,[IVAinteres]
  122. ,[pagointeres]
  123. ,[abono]
  124. ,[prestamoremanente]
  125. ,[pagodanos]
  126. ,[pagovivienta]
  127. ,[totalcuota]
  128. ,[totalpagado]
  129. ,[abonoextra]
  130. ,[correlativo]
  131. ,[fechacorte]
  132. ) VALUES(
  133. @CodInv
  134. ,@fecha
  135. ,@Periodo
  136. ,@saldoinicial
  137. ,@pagocuota
  138. ,@pagointeresIVA
  139. ,@IVAinteres
  140. ,@pagointeres
  141. ,@abono
  142. ,@prestamoremanente
  143. ,@pagodanos
  144. ,@pagovivienta
  145. ,@totalcuota
  146. ,@totalpagado
  147. ,@abonoextra
  148. ,@correlativo
  149. ,@fechacorte
  150. )
  151. "
  152. cmd = New SqlCommand
  153. cmd.CommandText = sql
  154. cmd.Connection = cn
  155. cmd.Transaction = myTrans
  156. With cmd.Parameters
  157. .Add("@CodInv", SqlDbType.VarChar).Value = Codigo
  158. .Add("@correlativo", SqlDbType.Int).Value = CInt(Coleccion3(1))
  159. .Add("@fecha", SqlDbType.DateTime).Value = CDate(Coleccion3(2))
  160. .Add("@Periodo", SqlDbType.Int).Value = CInt(Coleccion3(3))
  161. .Add("@saldoinicial", SqlDbType.Float).Value = CDec(Coleccion3(4))
  162. .Add("@pagocuota", SqlDbType.Float).Value = CDec(Coleccion3(5))
  163. .Add("@pagointeresIVA", SqlDbType.Float).Value = CDec(Coleccion3(6))
  164. .Add("@IVAinteres", SqlDbType.Float).Value = CDec(Coleccion3(7))
  165. .Add("@pagointeres", SqlDbType.Float).Value = CDec(Coleccion3(8))
  166. .Add("@abono", SqlDbType.Float).Value = CDec(Coleccion3(9))
  167. .Add("@prestamoremanente", SqlDbType.Float).Value = CDec(Coleccion3(10))
  168. .Add("@pagodanos", SqlDbType.Float).Value = CDec(Coleccion3(11))
  169. .Add("@pagovivienta", SqlDbType.Float).Value = CDec(Coleccion3(12))
  170. .Add("@totalcuota", SqlDbType.Float).Value = CDec(Coleccion3(13))
  171. .Add("@totalpagado", SqlDbType.Float).Value = CDec(Coleccion3(14))
  172. .Add("@abonoextra", SqlDbType.Float).Value = CDec(Coleccion3(15))
  173. If String.IsNullOrEmpty(Coleccion3(16).ToString) Then
  174. .Add("@fechacorte", SqlDbType.Date).Value = DBNull.Value
  175. Else
  176. .Add("@fechacorte", SqlDbType.Date).Value = Coleccion3(16)
  177. End If
  178. End With
  179. retorno = cmd.ExecuteNonQuery
  180. Next
  181. End If
  182. ''''''''''''''''''
  183. myTrans.Commit()
  184. MsgBox("Datos Ingresados")
  185. Catch ex As Exception
  186. myTrans.Rollback()
  187. MsgBox(ex.Message)
  188. End Try
  189. cn.Close()
  190. Return retorno
  191. End Function
  192. Public Function NuevoDeudor(ByVal Coleccion As Collection, ByVal Codigo As String)
  193. Dim objCon As New Conexion
  194. Dim retorno As Integer
  195. Dim sql As String
  196. Dim cmd As SqlCommand
  197. Dim cn As SqlConnection = objCon.Conectar
  198. If cn.State = ConnectionState.Closed Then
  199. cn.Open()
  200. End If
  201. sql = "INSERT INTO [dbo].[PPER0](
  202. [CodInv]
  203. ,[nombredeudor]
  204. ,[numerodeudor]
  205. ,[fechaotorga]
  206. ,[fechapago]
  207. ,[periodogracia]
  208. ) VALUES(
  209. @CodInv
  210. ,@nombredeudor
  211. ,@numerodeudor
  212. ,@fechaotorga
  213. ,@fechapago
  214. ,@periodogracia
  215. )
  216. "
  217. cmd = New SqlCommand
  218. cmd.CommandText = sql
  219. With cmd.Parameters
  220. .Add("@CodInv", SqlDbType.VarChar).Value = Codigo
  221. .Add("@nombredeudor", SqlDbType.VarChar).Value = Coleccion(1)
  222. .Add("@numerodeudor", SqlDbType.VarChar).Value = Coleccion(2)
  223. .Add("@fechaotorga", SqlDbType.DateTime).Value = CDate(Coleccion(3))
  224. .Add("@fechapago", SqlDbType.DateTime).Value = CDate(Coleccion(4))
  225. .Add("@periodogracia", SqlDbType.Float).Value = CDec(Coleccion(5))
  226. End With
  227. cmd.Connection = cn
  228. retorno = cmd.ExecuteNonQuery
  229. cn.Dispose()
  230. cn.Close()
  231. Return retorno
  232. End Function
  233. Public Function ModificarDeudor(ByVal Coleccion As Collection, ByVal Codigo As String)
  234. Dim objCon As New Conexion
  235. Dim retorno As Integer
  236. Dim sql As String
  237. Dim cmd As SqlCommand
  238. Dim cn As SqlConnection = objCon.Conectar
  239. If cn.State = ConnectionState.Closed Then
  240. cn.Open()
  241. End If
  242. sql = "UPDATE [dbo].[PPER0] SET
  243. [nombredeudor]=@nombredeudor
  244. ,[numerodeudor]=@numerodeudor
  245. ,[fechaotorga]=@fechaotorga
  246. ,[fechapago]=@fechapago
  247. ,[periodogracia]=@periodogracia
  248. where [CodInv]=@CodInv
  249. "
  250. cmd = New SqlCommand
  251. cmd.CommandText = sql
  252. With cmd.Parameters
  253. .Add("@CodInv", SqlDbType.VarChar).Value = Codigo
  254. .Add("@nombredeudor", SqlDbType.VarChar).Value = Coleccion(1)
  255. .Add("@numerodeudor", SqlDbType.VarChar).Value = Coleccion(2)
  256. .Add("@fechaotorga", SqlDbType.DateTime).Value = CDate(Coleccion(3))
  257. .Add("@fechapago", SqlDbType.DateTime).Value = CDate(Coleccion(4))
  258. .Add("@periodogracia", SqlDbType.Float).Value = CDec(Coleccion(5))
  259. End With
  260. cmd.Connection = cn
  261. retorno = cmd.ExecuteNonQuery
  262. cn.Dispose()
  263. cn.Close()
  264. Return retorno
  265. End Function
  266. Public Function NuevoDetalle(ByVal Coleccion As Collection, ByVal Codigo As String)
  267. Dim objCon As New Conexion
  268. Dim retorno As Integer
  269. Dim sql As String
  270. Dim cmd As SqlCommand
  271. Dim cn As SqlConnection = objCon.Conectar
  272. If cn.State = ConnectionState.Closed Then
  273. cn.Open()
  274. End If
  275. sql = "INSERT INTO [dbo].[PPER1](
  276. [CodInv]
  277. ,[tasainteres]
  278. ,[duracionprestamo]
  279. ,[totalcuotas]
  280. ,[montoprestamo]
  281. ,[seguro]
  282. ,[CuotaSinSeguro]
  283. ,[CuotaReal]
  284. ) VALUES(
  285. @CodInv
  286. ,@tasainteres
  287. ,@duracionprestamo
  288. ,@totalcuotas
  289. ,@montoprestamo
  290. ,@seguro
  291. ,@CuotaSinSeguro
  292. ,@CuotaReal
  293. )
  294. "
  295. cmd = New SqlCommand
  296. cmd.CommandText = sql
  297. With cmd.Parameters
  298. .Add("@CodInv", SqlDbType.VarChar).Value = Codigo
  299. .Add("@tasainteres", SqlDbType.Float).Value = CDec(Coleccion(1))
  300. .Add("@duracionprestamo", SqlDbType.Float).Value = CDec(Coleccion(2))
  301. .Add("@totalcuotas", SqlDbType.Float).Value = CDec(Coleccion(3))
  302. .Add("@montoprestamo", SqlDbType.Float).Value = CDec(Coleccion(4))
  303. .Add("@seguro", SqlDbType.Float).Value = CDec(Coleccion(5))
  304. .Add("@CuotaSinSeguro", SqlDbType.Float).Value = CDec(Coleccion(6))
  305. .Add("@CuotaReal", SqlDbType.Float).Value = CDec(Coleccion(7))
  306. End With
  307. cmd.Connection = cn
  308. retorno = cmd.ExecuteNonQuery
  309. cn.Dispose()
  310. cn.Close()
  311. Return retorno
  312. End Function
  313. Public Function ModificarDetalle(ByVal Coleccion As Collection, ByVal Codigo As String)
  314. Dim objCon As New Conexion
  315. Dim retorno As Integer
  316. Dim sql As String
  317. Dim cmd As SqlCommand
  318. Dim cn As SqlConnection = objCon.Conectar
  319. If cn.State = ConnectionState.Closed Then
  320. cn.Open()
  321. End If
  322. sql = "UPDATE [dbo].[PPER1] SET
  323. [tasainteres]=@tasainteres
  324. ,[duracionprestamo]=@duracionprestamo
  325. ,[totalcuotas]=@totalcuotas
  326. ,[montoprestamo]=@montoprestamo
  327. ,[seguro]=@seguro
  328. ,[CuotaSinSeguro]=@CuotaSinSeguro
  329. ,[CuotaReal]=@CuotaReal
  330. where [CodInv]=@CodInv
  331. "
  332. cmd = New SqlCommand
  333. cmd.CommandText = sql
  334. With cmd.Parameters
  335. .Add("@CodInv", SqlDbType.VarChar).Value = Codigo
  336. .Add("@tasainteres", SqlDbType.Float).Value = CDec(Coleccion(1))
  337. .Add("@duracionprestamo", SqlDbType.Float).Value = CDec(Coleccion(2))
  338. .Add("@totalcuotas", SqlDbType.Float).Value = CDec(Coleccion(3))
  339. .Add("@montoprestamo", SqlDbType.Float).Value = CDec(Coleccion(4))
  340. .Add("@seguro", SqlDbType.Float).Value = CDec(Coleccion(5))
  341. .Add("@CuotaSinSeguro", SqlDbType.Float).Value = CDec(Coleccion(6))
  342. .Add("@CuotaReal", SqlDbType.Float).Value = CDec(Coleccion(7))
  343. End With
  344. cmd.Connection = cn
  345. retorno = cmd.ExecuteNonQuery
  346. cn.Dispose()
  347. cn.Close()
  348. Return retorno
  349. End Function
  350. Public Function NuevaAmortizacion(ByVal Coleccion As Collection, ByVal Codigo As String)
  351. Dim objCon As New Conexion
  352. Dim retorno As Integer
  353. Dim sql As String
  354. Dim cmd As SqlCommand
  355. Dim cn As SqlConnection = objCon.Conectar
  356. If cn.State = ConnectionState.Closed Then
  357. cn.Open()
  358. End If
  359. sql = "INSERT INTO [dbo].[PPER2](
  360. [CodInv]
  361. ,[fecha]
  362. ,[Periodo]
  363. ,[saldoinicial]
  364. ,[pagocuota]
  365. ,[pagointeresIVA]
  366. ,[IVAinteres]
  367. ,[pagointeres]
  368. ,[abono]
  369. ,[prestamoremanente]
  370. ,[pagodanos]
  371. ,[pagovivienta]
  372. ,[totalcuota]
  373. ,[totalpagado]
  374. ,[abonoextra]
  375. ,[correlativo]
  376. ,[fechacorte]
  377. ) VALUES(
  378. @CodInv
  379. ,@fecha
  380. ,@Periodo
  381. ,@saldoinicial
  382. ,@pagocuota
  383. ,@pagointeresIVA
  384. ,@IVAinteres
  385. ,@pagointeres
  386. ,@abono
  387. ,@prestamoremanente
  388. ,@pagodanos
  389. ,@pagovivienta
  390. ,@totalcuota
  391. ,@totalpagado
  392. ,@abonoextra
  393. ,@correlativo
  394. ,@fechacorte
  395. )
  396. "
  397. cmd = New SqlCommand
  398. cmd.CommandText = sql
  399. With cmd.Parameters
  400. .Add("@CodInv", SqlDbType.VarChar).Value = Codigo
  401. .Add("@correlativo", SqlDbType.Int).Value = CInt(Coleccion(1))
  402. .Add("@fecha", SqlDbType.DateTime).Value = CDate(Coleccion(2))
  403. .Add("@Periodo", SqlDbType.Int).Value = CInt(Coleccion(3))
  404. .Add("@saldoinicial", SqlDbType.Float).Value = CDec(Coleccion(4))
  405. .Add("@pagocuota", SqlDbType.Float).Value = CDec(Coleccion(5))
  406. .Add("@pagointeresIVA", SqlDbType.Float).Value = CDec(Coleccion(6))
  407. .Add("@IVAinteres", SqlDbType.Float).Value = CDec(Coleccion(7))
  408. .Add("@pagointeres", SqlDbType.Float).Value = CDec(Coleccion(8))
  409. .Add("@abono", SqlDbType.Float).Value = CDec(Coleccion(9))
  410. .Add("@prestamoremanente", SqlDbType.Float).Value = CDec(Coleccion(10))
  411. .Add("@pagodanos", SqlDbType.Float).Value = CDec(Coleccion(11))
  412. .Add("@pagovivienta", SqlDbType.Float).Value = CDec(Coleccion(12))
  413. .Add("@totalcuota", SqlDbType.Float).Value = CDec(Coleccion(13))
  414. .Add("@totalpagado", SqlDbType.Float).Value = CDec(Coleccion(14))
  415. .Add("@abonoextra", SqlDbType.Float).Value = CDec(Coleccion(15))
  416. If String.IsNullOrEmpty(Coleccion(16).ToString) Then
  417. .Add("@fechacorte", SqlDbType.Date).Value = DBNull.Value
  418. Else
  419. .Add("@fechacorte", SqlDbType.date).Value = Coleccion(16)
  420. End If
  421. End With
  422. cmd.Connection = cn
  423. retorno = cmd.ExecuteNonQuery
  424. cn.Dispose()
  425. cn.Close()
  426. Return retorno
  427. End Function
  428. Public Function ModificarAmortizacion(ByVal Coleccion As Collection, ByVal Codigo As String)
  429. Dim objCon As New Conexion
  430. Dim retorno As Integer
  431. Dim sql As String
  432. Dim cmd As SqlCommand
  433. Dim cn As SqlConnection = objCon.Conectar
  434. If cn.State = ConnectionState.Closed Then
  435. cn.Open()
  436. End If
  437. sql = "UPDATE [dbo].[PPER2] SET
  438. [fecha]=@fecha
  439. ,[Periodo]=@Periodo
  440. ,[saldoinicial]=@saldoinicial
  441. ,[pagocuota]=@pagocuota
  442. ,[pagointeresIVA]=@pagointeresIVA
  443. ,[IVAinteres]=@IVAinteres
  444. ,[pagointeres]=@pagointeres
  445. ,[abono]=@abono
  446. ,[prestamoremanente]=@prestamoremanente
  447. ,[pagodanos]=@pagodanos
  448. ,[pagovivienta]=@pagovivienta
  449. ,[totalcuota]=@totalcuota
  450. ,[totalpagado]=@totalpagado
  451. ,[abonoextra]=@abonoextra
  452. ,[correlativo]=@correlativo
  453. where [CodInv]=@CodInv
  454. "
  455. cmd = New SqlCommand
  456. cmd.CommandText = sql
  457. With cmd.Parameters
  458. .Add("@CodInv", SqlDbType.VarChar).Value = Codigo
  459. .Add("@fecha", SqlDbType.DateTime).Value = CDate(Coleccion(1))
  460. .Add("@Periodo", SqlDbType.Int).Value = CInt(Coleccion(2))
  461. .Add("@saldoinicial", SqlDbType.Float).Value = CDec(Coleccion(3))
  462. .Add("@pagocuota", SqlDbType.Float).Value = CDec(Coleccion(4))
  463. .Add("@pagointeresIVA", SqlDbType.Float).Value = CDec(Coleccion(5))
  464. .Add("@IVAinteres", SqlDbType.Float).Value = CDec(Coleccion(6))
  465. .Add("@pagointeres", SqlDbType.Float).Value = CDec(Coleccion(7))
  466. .Add("@abono", SqlDbType.Float).Value = CDec(Coleccion(8))
  467. .Add("@prestamoremanente", SqlDbType.Float).Value = CDec(Coleccion(9))
  468. .Add("@pagodanos", SqlDbType.Float).Value = CDec(Coleccion(10))
  469. .Add("@pagovivienta", SqlDbType.Float).Value = CDec(Coleccion(11))
  470. .Add("@totalcuota", SqlDbType.Float).Value = CDec(Coleccion(12))
  471. .Add("@totalpagado", SqlDbType.Float).Value = CDec(Coleccion(13))
  472. .Add("@abonoextra", SqlDbType.Float).Value = CDec(Coleccion(14))
  473. .Add("@correlativo", SqlDbType.Int).Value = CInt(Coleccion(15))
  474. End With
  475. cmd.Connection = cn
  476. retorno = cmd.ExecuteNonQuery
  477. cn.Dispose()
  478. cn.Close()
  479. Return retorno
  480. End Function
  481. Public Function CargarDeudor(ByVal Codigo As String)
  482. Dim objCon As New Conexion
  483. Dim sql As String
  484. Dim cmd As SqlCommand
  485. Dim Coleccion As New Collection
  486. Dim cn As SqlConnection = objCon.Conectar
  487. If cn.State = ConnectionState.Closed Then
  488. cn.Open()
  489. End If
  490. sql = "SELECT * FROM [dbo].[PPER0] WHERE CodInv=@Codigo"
  491. cmd = New SqlCommand
  492. cmd.CommandText = sql
  493. cmd.Parameters.Add("@Codigo", SqlDbType.VarChar).Value = Codigo
  494. cmd.Connection = cn
  495. ' Dim Datos = cmd.ExecuteScalar
  496. Dim Datos = cmd.ExecuteReader
  497. If Datos.HasRows Then
  498. 'SE ENCONTRO EL REGISTRO
  499. If Datos.Read Then
  500. Coleccion.Add(Datos.Item("nombredeudor"))
  501. Coleccion.Add(Datos.Item("numerodeudor"))
  502. Coleccion.Add(Datos.Item("fechaotorga"))
  503. Coleccion.Add(Datos.Item("fechapago"))
  504. Coleccion.Add(Datos.Item("periodogracia"))
  505. cn.Close()
  506. Return Coleccion
  507. End If
  508. End If
  509. cn.Close()
  510. Return False
  511. End Function
  512. Public Function CargarDetalles(ByVal Codigo As String)
  513. Dim objCon As New Conexion
  514. Dim sql As String
  515. Dim cmd As SqlCommand
  516. Dim Coleccion As New Collection
  517. Dim cn As SqlConnection = objCon.Conectar
  518. If cn.State = ConnectionState.Closed Then
  519. cn.Open()
  520. End If
  521. sql = "SELECT * FROM [dbo].[PPER1] WHERE CodInv=@Codigo"
  522. cmd = New SqlCommand
  523. cmd.CommandText = sql
  524. cmd.Parameters.Add("@Codigo", SqlDbType.VarChar).Value = Codigo
  525. cmd.Connection = cn
  526. ' Dim Datos = cmd.ExecuteScalar
  527. Dim Datos = cmd.ExecuteReader
  528. If Datos.HasRows Then
  529. 'SE ENCONTRO EL REGISTRO
  530. If Datos.Read Then
  531. Coleccion.Add(Datos.Item("tasainteres"))
  532. Coleccion.Add(Datos.Item("duracionprestamo"))
  533. Coleccion.Add(Datos.Item("totalcuotas"))
  534. Coleccion.Add(Datos.Item("montoprestamo"))
  535. Coleccion.Add(Datos.Item("seguro"))
  536. cn.Close()
  537. Return Coleccion
  538. End If
  539. End If
  540. cn.Close()
  541. Return False
  542. End Function
  543. Public Function CargarAmortizacion(ByVal codigo As String)
  544. Dim objCon As New Conexion
  545. Dim cn As SqlConnection = objCon.Conectar
  546. If cn.State = ConnectionState.Closed Then
  547. cn.Open()
  548. End If
  549. Dim sql = "select * from PPER2 where CodInv='" + codigo + "' order by Correlativo"
  550. Dim cmd As New SqlCommand(sql, cn)
  551. Dim dr As SqlDataReader
  552. dr = cmd.ExecuteReader
  553. Return dr
  554. End Function
  555. Public Sub Eliminar(ByVal Codigo As String)
  556. Dim objCon As New Conexion
  557. Dim retorno As Integer
  558. Dim sql As String
  559. Dim cmd As SqlCommand
  560. Dim myTrans As SqlTransaction
  561. Dim cn As SqlConnection = objCon.Conectar
  562. If cn.State = ConnectionState.Closed Then
  563. cn.Open()
  564. End If
  565. myTrans = cn.BeginTransaction()
  566. Try
  567. sql = "DELETE FROM [dbo].[PPER0]
  568. WHERE [CodInv]=@CodInv"
  569. cmd = New SqlCommand
  570. cmd.CommandText = sql
  571. cmd.Connection = cn
  572. cmd.Transaction = myTrans
  573. cmd.Parameters.Add("@CodInv", SqlDbType.VarChar).Value = Codigo
  574. retorno = cmd.ExecuteNonQuery
  575. sql = "DELETE FROM [dbo].[PPER1]
  576. WHERE [CodInv]=@CodInv"
  577. cmd = New SqlCommand
  578. cmd.CommandText = sql
  579. cmd.Connection = cn
  580. cmd.Transaction = myTrans
  581. cmd.Parameters.Add("@CodInv", SqlDbType.VarChar).Value = Codigo
  582. retorno = cmd.ExecuteNonQuery
  583. sql = "DELETE FROM [dbo].[PPER2]
  584. WHERE [CodInv]=@CodInv"
  585. cmd = New SqlCommand
  586. cmd.CommandText = sql
  587. cmd.Connection = cn
  588. cmd.Transaction = myTrans
  589. cmd.Parameters.Add("@CodInv", SqlDbType.VarChar).Value = Codigo
  590. retorno = cmd.ExecuteNonQuery
  591. myTrans.Commit()
  592. MsgBox("Datos Eliminados")
  593. Catch ex As Exception
  594. myTrans.Rollback()
  595. MsgBox(ex.Message)
  596. End Try
  597. cn.Close()
  598. End Sub
  599. Public Sub EliminarDetalle(ByVal Codigo As String)
  600. Dim objCon As New Conexion
  601. Dim sql As String
  602. Dim cmd As SqlCommand
  603. Dim res As Integer
  604. Dim cn As SqlConnection = objCon.Conectar
  605. If cn.State = ConnectionState.Closed Then
  606. cn.Open()
  607. End If
  608. sql = "DELETE FROM [dbo].[PPER1]
  609. WHERE [CodInv]=@CodInv"
  610. cmd = New SqlCommand
  611. cmd.CommandText = sql
  612. cmd.Parameters.Add("@CodInv", SqlDbType.VarChar).Value = Codigo
  613. cmd.Connection = cn
  614. res = cmd.ExecuteNonQuery
  615. cn.Close()
  616. End Sub
  617. Public Sub EliminarAmortizacion(ByVal Codigo As String)
  618. Dim objCon As New Conexion
  619. Dim sql As String
  620. Dim cmd As SqlCommand
  621. Dim res As Integer
  622. Dim cn As SqlConnection = objCon.Conectar
  623. If cn.State = ConnectionState.Closed Then
  624. cn.Open()
  625. End If
  626. sql = "DELETE FROM [dbo].[PPER2]
  627. WHERE [CodInv]=@CodInv "
  628. cmd = New SqlCommand
  629. cmd.CommandText = sql
  630. cmd.Parameters.Add("@CodInv", SqlDbType.VarChar).Value = Codigo
  631. cmd.Connection = cn
  632. res = cmd.ExecuteNonQuery
  633. cn.Close()
  634. End Sub
  635. End Class