| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968 |
- Imports System.Data.SqlClient
- Public Class DepositosAPlazoDAO
- Function Nuevo(ByVal oDAPCE As DepositosAPlazoCE) As Integer
- Dim objCon As New Conexion
- Dim retorno As Integer
- Dim sql As String
- Dim cmd As SqlCommand
- Dim cn As SqlConnection = objCon.Conectar
- If cn.State = ConnectionState.Closed Then
- cn.Open()
- End If
- sql = "INSERT INTO [dbo].[DAP0]
- ([CodInv]
- ,[MontoInv]
- ,[FOper]
- ,[FVenc]
- ,[Tasa]
- ,[Plazo]
- --,[AnBase]
- ,[Periodic])
- VALUES
- (@CodInv
- ,@MontoInv
- ,@FOper
- ,@FVenc
- ,@Tasa
- ,@Plazo
- --,@AnBase
- ,@Periodic)
- "
- cmd = New SqlCommand
- cmd.Connection = cn
- cmd.CommandText = sql
- With cmd.Parameters
- .Add("@CodInv", SqlDbType.VarChar).Value = oDAPCE.CodigoInversion
- .Add("@MontoInv", SqlDbType.Float).Value = oDAPCE.MontoDeInversion
- .Add("@FOper", SqlDbType.Date).Value = oDAPCE.FechaOperacion
- .Add("@FVenc", SqlDbType.Date).Value = oDAPCE.FechaVencimiento
- .Add("@Tasa", SqlDbType.Float).Value = oDAPCE.Tasa
- .Add("@Plazo", SqlDbType.Int).Value = oDAPCE.Plazo
- '.Add("@AnBase",SqlDbType.VarChar).Value = oDAPCE.CodigoInversion
- .Add("@Periodic", SqlDbType.VarChar).Value = oDAPCE.Periodicidad
- End With
- retorno = cmd.ExecuteNonQuery
- cmd.Dispose()
- cn.Dispose()
- GuardaIntereses(oDAPCE.CodigoInversion, oDAPCE.dtIntereses)
- Return retorno
- End Function
- Function Nuevo(ByVal oDAP As DepositosAPlazoCE, DocId As Integer, Tipo As String) As Integer
- Dim objCon As New Conexion
- Dim retorno As Integer = -1
- Dim Transaccion As SqlTransaction
- Dim query As String
- Dim Tabla As String = ""
- Dim cn As SqlConnection = objCon.Conectar
- If cn.State = ConnectionState.Closed Then
- cn.Open()
- End If
- If Tipo = "P" Then
- Tabla = "PDAP0"
- End If
- If Tipo = "I" Then
- Tabla = "IDAP0"
- End If
- Dim cmd As SqlCommand = cn.CreateCommand
- Transaccion = cn.BeginTransaction("NuevoDAP")
- cmd.Connection = cn
- cmd.Transaction = Transaccion
- query = "INSERT INTO [dbo].[" & Tabla & "]
- ([DocId]
- ,[MontoInv]
- ,[FOper]
- ,[FVenc]
- ,[Tasa]
- ,[Plazo]
- ,[AnBase]
- ,[Periodic]
- ,[RendBruto]
- ,[RendNeto]
- ,[IngrBruto]
- ,[Impuestos]
- ,[IngrNeto])
- VALUES
- (@DocId
- ,@MontoInv
- ,@FOper
- ,@FVenc
- ,@Tasa
- ,@Plazo
- ,@AnBase
- ,@Periodic
- ,@RendBruto
- ,@RendNeto
- ,@IngrBruto
- ,@Impuestos
- ,@IngrNeto
- )"
- cmd.CommandText = query
- With cmd.Parameters
- .Add("@DocId", SqlDbType.Int).Value = DocId
- .Add("@MontoInv", SqlDbType.Decimal).Value = oDAP.MontoDeInversion
- .Add("@FOper", SqlDbType.Date).Value = oDAP.FechaOperacion
- .Add("@FVenc", SqlDbType.Date).Value = oDAP.FechaVencimiento
- .Add("@Tasa", SqlDbType.Decimal).Value = oDAP.Tasa
- .Add("@Plazo", SqlDbType.Int).Value = oDAP.Plazo
- .Add("@AnBase", SqlDbType.Int).Value = oDAP.AnioBase
- .Add("@Periodic", SqlDbType.NVarChar).Value = oDAP.Periodicidad
- .Add("@RendBruto", SqlDbType.Decimal).Value = oDAP.RendimientoBruto
- .Add("@RendNeto", SqlDbType.Decimal).Value = oDAP.RendimientoNeto
- .Add("@IngrBruto", SqlDbType.Decimal).Value = oDAP.IngresoBruto
- .Add("@Impuestos", SqlDbType.Decimal).Value = oDAP.Impuestos
- .Add("@IngrNeto", SqlDbType.Decimal).Value = oDAP.IngresoNeto
- End With
- Try
- cmd.ExecuteNonQuery()
- Transaccion.Commit()
- retorno = 0
- Catch ex As Exception
- MsgBox("Error al Guardar DAP : " & ex.GetType.ToString)
- MsgBox("Mensaje: " & ex.Message)
- retorno = 1
- Try
- Transaccion.Rollback()
- retorno = 2
- Catch ex2 As Exception
- MsgBox("Error en Rollback: " & ex2.GetType.ToString)
- MsgBox("Mensaje Rollbak: " & ex2.Message)
- retorno = 3
- End Try
- End Try
- cmd.Dispose()
- cn.Dispose()
- Return retorno
- End Function
- Public Sub CargarRegistro(ByVal oDAP As DepositosAPlazoCE, Tipo As String, IdRegistro As Integer)
- Dim objCon As New Conexion
- Dim drd As SqlDataReader
- Dim cmd As SqlCommand
- Dim sql As String
- Dim Tabla As String
- Dim cn As SqlConnection = objCon.Conectar
- If cn.State = ConnectionState.Closed Then
- cn.Open()
- End If
- If Tipo = "P" Then
- Tabla = "PDAP0"
- End If
- If Tipo = "I" Then
- Tabla = "IDAP0"
- End If
- sql = "SELECT * FROM [dbo].[" & Tabla & "] T0 WHERE T0.[DocId]=@DocId"
- cmd = New SqlCommand
- cmd.CommandText = sql
- cmd.Parameters.Add("@DocId", SqlDbType.Int).Value = IdRegistro
- cmd.Connection = cn
- drd = cmd.ExecuteReader
- If drd.HasRows Then
- 'SE ENCONTRO EL REGISTRO
- If drd.Read Then
- oDAP.MontoDeInversion = drd.Item("MontoInv")
- oDAP.FechaOperacion = drd.Item("FOper")
- oDAP.FechaVencimiento = drd.Item("FVenc")
- oDAP.Tasa = drd.Item("Tasa")
- oDAP.Plazo = drd.Item("Plazo")
- oDAP.AnioBase = drd.Item("AnBase")
- oDAP.Periodicidad = drd.Item("Periodic")
- 'oDAP.RendimientoBruto = drd.Item("RendBruto")
- 'oDAP.RendimientoNeto = drd.Item("RendNeto")
- oDAP.IngresoBruto = drd.Item("IngrBruto")
- oDAP.Impuestos = drd.Item("Impuestos")
- oDAP.IngresoNeto = drd.Item("IngrNeto")
- End If
- Else
- 'NO SE ENCONTRO EL REGISTRO
- End If
- drd.Close()
- cmd.Dispose()
- cn.Dispose()
- End Sub
- Public Function CargarRegistro(ByVal vCodigoInversion As String) As DepositosAPlazoCE
- Dim objCon As New Conexion
- Dim oDAPCE As New DepositosAPlazoCE
- Dim drd As SqlDataReader
- Dim cmd As SqlCommand
- Dim da As SqlDataAdapter
- Dim sql As String
- Dim dtIntereses As New DataTable
- Dim cn As SqlConnection = objCon.Conectar
- If cn.State = ConnectionState.Closed Then
- cn.Open()
- End If
- 'INTERESES
- sql = "SELECT * FROM [dbo].[DAP1] T0 WHERE T0.CodInv=@CodInv"
- da = New SqlDataAdapter(sql, cn)
- da.SelectCommand.Parameters.Add("@CodInv", SqlDbType.VarChar).Value = vCodigoInversion
- da.Fill(dtIntereses)
- oDAPCE.dtIntereses = dtIntereses
- sql = "SELECT * FROM [dbo].[DAP0] T0 WHERE T0.CodInv=@CodInv"
- cmd = New SqlCommand
- cmd.CommandText = sql
- cmd.Parameters.Add("@CodInv", SqlDbType.VarChar).Value = vCodigoInversion
- cmd.Connection = cn
- drd = cmd.ExecuteReader
- If drd.HasRows Then
- 'SE ENCONTRO EL REGISTRO
- If drd.Read Then
- oDAPCE.CodigoInversion = vCodigoInversion.ToString
- oDAPCE.MontoDeInversion = drd.Item("MontoInv").ToString
- oDAPCE.FechaOperacion = drd.Item("FOper").ToString
- oDAPCE.FechaVencimiento = drd.Item("FVenc").ToString
- oDAPCE.Tasa = drd.Item("Tasa").ToString
- oDAPCE.Plazo = drd.Item("Plazo").ToString
- oDAPCE.Periodicidad = drd.Item("Periodic").ToString
- End If
- drd.Close()
- Else
- 'NO ENCONTRO EL REGISTRO
- End If
- cmd.Dispose()
- cn.Dispose()
- Return oDAPCE
- End Function
- Public Function Actualizar(ByVal oDAPCE As DepositosAPlazoCE) As Integer
- Dim objCon As New Conexion
- Dim sql As String
- Dim cmd As SqlCommand
- Dim retorno As Integer
- Dim cn As SqlConnection = objCon.Conectar
- If cn.State = ConnectionState.Closed Then
- cn.Open()
- End If
- sql = "UPDATE [dbo].[DAP0]
- SET [MontoInv] = @MontoInv
- ,[FOper] = @FOper
- ,[FVenc] = @FVenc
- ,[Tasa] = @Tasa
- ,[Plazo] = @Plazo
- --,[AnBase] = @AnBase
- ,[Periodic] = @Periodic
- WHERE [CodInv] = @CodInv"
- cmd = New SqlCommand
- cmd.CommandText = sql
- With cmd.Parameters
- .Add("@MontoInv", SqlDbType.Float).Value = oDAPCE.MontoDeInversion
- .Add("@FOper", SqlDbType.Date).Value = oDAPCE.FechaOperacion
- .Add("@FVenc", SqlDbType.Date).Value = oDAPCE.FechaVencimiento
- .Add("@Tasa", SqlDbType.Float).Value = oDAPCE.Tasa
- .Add("@Plazo", SqlDbType.Int).Value = oDAPCE.Plazo
- .Add("@Periodic", SqlDbType.VarChar).Value = oDAPCE.Periodicidad
- End With
- cmd.Connection = cn
- retorno = cmd.ExecuteNonQuery
- cmd.Dispose()
- cn.Dispose()
- GuardaIntereses(oDAPCE.CodigoInversion, oDAPCE.dtIntereses)
- Return retorno
- End Function
- Private Sub GuardaIntereses(ByVal vCodInversion As String, dt As DataTable)
- Dim objCon As New Conexion
- Dim sql As String
- Dim cmd As SqlCommand
- Dim cn As SqlConnection = objCon.Conectar
- If cn.State = ConnectionState.Closed Then
- cn.Open()
- End If
- Dim res As Integer
- sql = "DELETE FROM [dbo].[DAP1]
- WHERE [CodInv]=@CodInv"
- cmd = New SqlCommand
- cmd.CommandText = sql
- cmd.Parameters.Add("@CodInv", SqlDbType.VarChar).Value = vCodInversion
- cmd.Connection = cn
- res = cmd.ExecuteNonQuery
- sql = String.Empty
- If dt.Rows.Count > 0 Then
- For Each dr In dt.Rows
- cmd = New SqlCommand
- sql = "INSERT INTO [dbo].[DAP1]
- ([CodInv]
- ,[Plazo]
- ,[Fecha]
- ,[IngrBruto]
- ,[PorcImp]
- ,[MontoImp]
- ,[IngrNeto]
- ,[Estado])
- VALUES
- (@CodInv
- ,@Plazo
- ,@Fecha
- ,@IngrBruto
- ,@PorcImp
- ,@MontoImp
- ,@IngrNeto
- ,@Estado)"
- cmd.CommandText = sql
- With cmd.Parameters
- .AddWithValue("@CodInv", vCodInversion)
- .AddWithValue("@Plazo", dr("Plazo"))
- .AddWithValue("@Fecha", dr("Fecha"))
- .AddWithValue("@IngrBruto", dr("IngrBruto"))
- .AddWithValue("@PorcImp", dr("PorcImp"))
- .AddWithValue("@MontoImp", dr("MontoImp"))
- .AddWithValue("@IngrNeto", dr("IngrNeto"))
- .AddWithValue("@Estado", dr("Estado"))
- End With
- cmd.Connection = cn
- res = cmd.ExecuteNonQuery
- Next
- End If
- cmd.Dispose()
- cn.Dispose()
- End Sub
- Public Function NuevoDato(ByVal Coleccion As Collection, ByVal Diccionario As Dictionary(Of String, Collection), ByVal Codigo As String)
- Dim objCon As New Conexion
- Dim retorno As Integer
- Dim sql As String
- Dim cmd As SqlCommand
- Dim myTrans As SqlTransaction
- Dim cn As SqlConnection = objCon.Conectar
- If cn.State = ConnectionState.Closed Then
- cn.Open()
- End If
- myTrans = cn.BeginTransaction()
- Try
- sql = "INSERT INTO [dbo].[DAP0](
- [CodInv]
- ,[MontoInv]
- ,[FOper]
- ,[FVenc]
- ,[Tasa]
- ,[Plazo]
- ,[Periodic]
- ,[RendBr]
- ,[RendNet]
- ,[IngrBrutoTot]
- ,[IngrNetoTot]
- ,[Renta]
- ) VALUES(
- @CodInv
- ,@MontoInv
- ,@FOper
- ,@FVenc
- ,@Tasa
- ,@Plazo
- ,@Periodic
- ,@RendBr
- ,@RendNet
- ,@IngrBrutoTot
- ,@IngrNetoTot
- ,@Renta
- )
- "
- cmd = New SqlCommand
- cmd.CommandText = sql
- cmd.Connection = cn
- cmd.Transaction = myTrans
- With cmd.Parameters
- .Add("@CodInv ", SqlDbType.VarChar).Value = Codigo.ToString
- .Add("@MontoInv", SqlDbType.Decimal).Value = Coleccion(1)
- .Add("@FOper", SqlDbType.DateTime).Value = Coleccion(2)
- .Add("@FVenc", SqlDbType.DateTime).Value = Coleccion(3)
- .Add("@Tasa", SqlDbType.Decimal).Value = Coleccion(4)
- .Add("@Plazo", SqlDbType.Int).Value = Coleccion(5)
- .Add("@Periodic", SqlDbType.VarChar).Value = Coleccion(6)
- .Add("@RendBr", SqlDbType.VarChar).Value = Coleccion(7)
- .Add("@RendNet", SqlDbType.VarChar).Value = Coleccion(8)
- .Add("@IngrBrutoTot", SqlDbType.Float).Value = Coleccion(9)
- .Add("@IngrNetoTot", SqlDbType.Float).Value = Coleccion(10)
- .Add("@Renta", SqlDbType.Float).Value = Coleccion(11)
- End With
- retorno = cmd.ExecuteNonQuery
- sql = "INSERT INTO [dbo].[DAP1](
- [CodInv]
- ,[Correlativo]
- ,[Plazo]
- ,[Fecha]
- ,[IngrBruto]
- ,[PorcImp]
- ,[MontoImp]
- ,[IngrNeto]
- ) VALUES(
- @CodInv
- ,@Correlativo
- ,@Plazo
- ,@Fecha
- ,@IngrBruto
- ,@PorcImp
- ,@MontoImp
- ,@IngrNeto
- )
- "
- If Not Diccionario Is Nothing Then
- For Each DatosDiccionario In Diccionario
- Dim Coleccion2 As Collection = DatosDiccionario.Value
- cmd = New SqlCommand
- cmd.CommandText = sql
- cmd.Connection = cn
- cmd.Transaction = myTrans
- With cmd.Parameters
- .Add("@CodInv ", SqlDbType.VarChar).Value = Codigo.ToString
- .Add("@Correlativo", SqlDbType.Int).Value = Coleccion2(1)
- .Add("@Plazo", SqlDbType.Int).Value = Coleccion2(2)
- .Add("@Fecha", SqlDbType.DateTime).Value = Coleccion2(3)
- .Add("@IngrBruto", SqlDbType.Decimal).Value = Coleccion2(4)
- .Add("@PorcImp", SqlDbType.Decimal).Value = Coleccion2(5)
- .Add("@MontoImp", SqlDbType.Decimal).Value = Coleccion2(6)
- .Add("@IngrNeto", SqlDbType.Decimal).Value = Coleccion2(7)
- End With
- retorno = cmd.ExecuteNonQuery
- Next
- End If
- myTrans.Commit()
- MsgBox("Datos Ingresados")
- Catch ex As Exception
- myTrans.Rollback()
- MsgBox(ex.Message)
- End Try
- cn.Close()
- Return retorno
- End Function
- Public Function NuevoElemento(ByVal Coleccion As Collection, ByVal Codigo As String)
- Dim objCon As New Conexion
- Dim retorno As Integer
- Dim sql As String
- Dim cmd As SqlCommand
- Dim cn As SqlConnection = objCon.Conectar
- If cn.State = ConnectionState.Closed Then
- cn.Open()
- End If
- sql = "INSERT INTO [dbo].[DAP1](
- [CodInv]
- ,[Correlativo]
- ,[Plazo]
- ,[Fecha]
- ,[IngrBruto]
- ,[PorcImp]
- ,[MontoImp]
- ,[IngrNeto]
- ) VALUES(
- @CodInv
- ,@Correlativo
- ,@Plazo
- ,@Fecha
- ,@IngrBruto
- ,@PorcImp
- ,@MontoImp
- ,@IngrNeto
- )
- "
- cmd = New SqlCommand
- cmd.CommandText = sql
- With cmd.Parameters
- .Add("@CodInv ", SqlDbType.VarChar).Value = Codigo.ToString
- .Add("@Correlativo", SqlDbType.Int).Value = Coleccion(1)
- .Add("@Plazo", SqlDbType.Int).Value = Coleccion(2)
- .Add("@Fecha", SqlDbType.DateTime).Value = Coleccion(3)
- .Add("@IngrBruto", SqlDbType.Decimal).Value = Coleccion(4)
- .Add("@PorcImp", SqlDbType.Decimal).Value = Coleccion(5)
- .Add("@MontoImp", SqlDbType.Decimal).Value = Coleccion(6)
- .Add("@IngrNeto", SqlDbType.Decimal).Value = Coleccion(7)
- End With
- cmd.Connection = cn
- retorno = cmd.ExecuteNonQuery
- cn.Close()
- Return retorno
- End Function
- Public Function ModificarElemento(ByVal Coleccion As Collection, ByVal Codigo As String)
- Dim objCon As New Conexion
- Dim retorno As Integer
- Dim sql As String
- Dim cmd As SqlCommand
- Dim cn As SqlConnection = objCon.Conectar
- If cn.State = ConnectionState.Closed Then
- cn.Open()
- End If
- sql = "UPDATE [dbo].[DAP1] SET
- [Plazo]=@Plazo
- ,[Fecha]=@Fecha
- ,[IngrBruto]=@IngrBruto
- ,[PorcImp]=@PorcImp
- ,[MontoImp]=@MontoImp
- ,[IngrNeto]=@IngrNeto
- where [CodInv]=@CodInv AND [Correlativo]=@Correlativo
- "
- cmd = New SqlCommand
- cmd.CommandText = sql
- With cmd.Parameters
- .Add("@CodInv ", SqlDbType.VarChar).Value = Codigo.ToString
- .Add("@Correlativo", SqlDbType.Int).Value = Coleccion(1)
- .Add("@Plazo", SqlDbType.Int).Value = Coleccion(2)
- .Add("@Fecha", SqlDbType.DateTime).Value = Coleccion(3)
- .Add("@IngrBruto", SqlDbType.Decimal).Value = Coleccion(4)
- .Add("@PorcImp", SqlDbType.Decimal).Value = Coleccion(5)
- .Add("@MontoImp", SqlDbType.Decimal).Value = Coleccion(6)
- .Add("@IngrNeto", SqlDbType.Decimal).Value = Coleccion(7)
- End With
- cmd.Connection = cn
- retorno = cmd.ExecuteNonQuery
- cn.Close()
- Return retorno
- End Function
- Public Sub EliminarElemento(ByVal Codigo As String)
- Dim objCon As New Conexion
- Dim sql As String
- Dim cmd As SqlCommand
- Dim res As Integer
- Dim cn As SqlConnection = objCon.Conectar
- If cn.State = ConnectionState.Closed Then
- cn.Open()
- End If
- sql = "DELETE FROM [dbo].[DAP1]
- WHERE [CodInv]=@CodInv "
- cmd = New SqlCommand
- cmd.CommandText = sql
- cmd.Parameters.Add("@CodInv", SqlDbType.VarChar).Value = Codigo
- cmd.Connection = cn
- cn.Close()
- res = cmd.ExecuteNonQuery
- End Sub
- Public Function ModificarDato(ByVal Coleccion As Collection, ByVal Codigo As String, ByVal Diccionario As Dictionary(Of String, Collection))
- Dim objCon As New Conexion
- Dim retorno As Integer
- Dim sql As String
- Dim cmd As SqlCommand
- Dim myTrans As SqlTransaction
- Dim cn As SqlConnection = objCon.Conectar
- If cn.State = ConnectionState.Closed Then
- cn.Open()
- End If
- myTrans = cn.BeginTransaction()
- Try
- sql = "UPDATE [dbo].[DAP0] SET
- [MontoInv]=@MontoInv
- ,[FOper]=@FOper
- ,[FVenc]=@FVenc
- ,[Tasa]=@Tasa
- ,[Plazo]=@Plazo
- ,[Periodic]=@Periodic
- ,[RendBr]=@RendBr
- ,[RendNet]=@RendNet
- ,[IngrBrutoTot]=@IngrBrutoTot
- ,[IngrNetoTot]=@IngrNetoTot
- ,[Renta]=@Renta
- where [CodInv]= @CodInv
- "
- cmd = New SqlCommand
- cmd.CommandText = sql
- cmd.Connection = cn
- cmd.Transaction = myTrans
- With cmd.Parameters
- .Add("@CodInv ", SqlDbType.VarChar).Value = Codigo.ToString
- .Add("@MontoInv", SqlDbType.Decimal).Value = Coleccion(1)
- .Add("@FOper", SqlDbType.DateTime).Value = Coleccion(2)
- .Add("@FVenc", SqlDbType.DateTime).Value = Coleccion(3)
- .Add("@Tasa", SqlDbType.Decimal).Value = Coleccion(4)
- .Add("@Plazo", SqlDbType.Int).Value = Coleccion(5)
- .Add("@Periodic", SqlDbType.VarChar).Value = Coleccion(6)
- .Add("@RendBr", SqlDbType.VarChar).Value = Coleccion(7)
- .Add("@RendNet", SqlDbType.VarChar).Value = Coleccion(8)
- .Add("@IngrBrutoTot", SqlDbType.Float).Value = Coleccion(9)
- .Add("@IngrNetoTot", SqlDbType.Float).Value = Coleccion(10)
- .Add("@Renta", SqlDbType.Float).Value = Coleccion(11)
- End With
- retorno = cmd.ExecuteNonQuery
- sql = "INSERT INTO [dbo].[DAP1](
- [CodInv]
- ,[Correlativo]
- ,[Plazo]
- ,[Fecha]
- ,[IngrBruto]
- ,[PorcImp]
- ,[MontoImp]
- ,[IngrNeto]
- ) VALUES(
- @CodInv
- ,@Correlativo
- ,@Plazo
- ,@Fecha
- ,@IngrBruto
- ,@PorcImp
- ,@MontoImp
- ,@IngrNeto
- )
- "
- sql = "delete from DAP1 Where CodInv='" + Codigo + "'"
- cmd = New SqlCommand
- cmd.CommandText = sql
- cmd.Connection = cn
- cmd.Transaction = myTrans
- retorno = cmd.ExecuteNonQuery
- If Not Diccionario Is Nothing Then
- For Each DatosDiccionario In Diccionario
- Dim Coleccion2 As Collection = DatosDiccionario.Value
- sql = "INSERT INTO [dbo].[DAP1](
- [CodInv]
- ,[Correlativo]
- ,[Plazo]
- ,[Fecha]
- ,[IngrBruto]
- ,[PorcImp]
- ,[MontoImp]
- ,[IngrNeto]
- ) VALUES(
- @CodInv
- ,@Correlativo
- ,@Plazo
- ,@Fecha
- ,@IngrBruto
- ,@PorcImp
- ,@MontoImp
- ,@IngrNeto
- )
- "
- cmd = New SqlCommand
- cmd.CommandText = sql
- cmd.Connection = cn
- cmd.Transaction = myTrans
- With cmd.Parameters
- .Add("@CodInv ", SqlDbType.VarChar).Value = Codigo.ToString
- .Add("@Correlativo", SqlDbType.Int).Value = Coleccion2(1)
- .Add("@Plazo", SqlDbType.Int).Value = Coleccion2(2)
- .Add("@Fecha", SqlDbType.DateTime).Value = Coleccion2(3)
- .Add("@IngrBruto", SqlDbType.Decimal).Value = Coleccion2(4)
- .Add("@PorcImp", SqlDbType.Decimal).Value = Coleccion2(5)
- .Add("@MontoImp", SqlDbType.Decimal).Value = Coleccion2(6)
- .Add("@IngrNeto", SqlDbType.Decimal).Value = Coleccion2(7)
- End With
- retorno = cmd.ExecuteNonQuery
- Next
- End If
- myTrans.Commit()
- MsgBox("Datos Ingresados")
- Catch ex As Exception
- myTrans.Rollback()
- MsgBox(ex.Message)
- End Try
- cn.Close()
- Return retorno
- End Function
- 'Public Sub EliminarDato(ByVal Codigo As String)
- ' Dim sql As String
- ' Dim cmd As SqlCommand
- ' Dim res As Integer
- ' sql = "DELETE FROM [dbo].[DAP0]
- ' WHERE [CodInv]=@CodInv"
- ' cn = objCon.Conectar
- ' If Not cn.State = ConnectionState.Open Then
- ' cn.Open()
- ' End If
- ' cmd = New SqlCommand
- ' cmd.CommandText = sql
- ' cmd.Parameters.Add("@CodInv", SqlDbType.VarChar).Value = Codigo
- ' cmd.Connection = cn
- ' res = cmd.ExecuteNonQuery
- 'End Sub
- Public Sub Eliminar(ByVal Codigo As String)
- Dim objCon As New Conexion
- Dim retorno As Integer
- Dim sql As String
- Dim cmd As SqlCommand
- Dim myTrans As SqlTransaction
- Dim cn As SqlConnection = objCon.Conectar
- If cn.State = ConnectionState.Closed Then
- cn.Open()
- End If
- myTrans = cn.BeginTransaction()
- Try
- sql = "DELETE FROM [dbo].[DAP0]
- WHERE [CodInv]=@CodInv"
- cmd = New SqlCommand
- cmd.CommandText = sql
- cmd.Connection = cn
- cmd.Transaction = myTrans
- cmd.Parameters.Add("@CodInv", SqlDbType.VarChar).Value = Codigo
- retorno = cmd.ExecuteNonQuery
- sql = "DELETE FROM [dbo].[DAP1]
- WHERE [CodInv]=@CodInv"
- cmd = New SqlCommand
- cmd.CommandText = sql
- cmd.Connection = cn
- cmd.Transaction = myTrans
- cmd.Parameters.Add("@CodInv", SqlDbType.VarChar).Value = Codigo
- retorno = cmd.ExecuteNonQuery
- myTrans.Commit()
- MsgBox("Datos Eliminados")
- Catch ex As Exception
- myTrans.Rollback()
- MsgBox(ex.Message)
- End Try
- cn.Close()
- End Sub
- End Class
|