Imports System.Data.SqlClient
Public Class FechasDAO






    Public Function NuevaFechaACC(ByVal codigo As String, ByVal coleccion As Collection)
        Dim oCon As New Conexion
        Dim retorno As Integer
        Dim sql As String
        Dim cmd As SqlCommand
        Dim cn As SqlConnection = oCon.Conectar
        If cn.State = ConnectionState.Closed Then
            cn.Open()
        End If

        sql = "INSERT INTO [dbo].[FechaACC]
           ([CodInv]
             ,[Correlativo]
             ,[FechaInicio]
             ,[FechaCorte]

        
             
           )
     VALUES
           (@CodInv
             ,@Correlativo
             ,@FechaInicio
             ,@FechaCorte
 
             
          )"


        cmd = New SqlCommand
        cmd.CommandText = sql
        cmd.Connection = cn

        With cmd.Parameters

            .Add("@CodInv", SqlDbType.VarChar).Value = codigo
            .Add("@Correlativo", SqlDbType.Int).Value = coleccion(1)
            .Add("@FechaInicio", SqlDbType.DateTime).Value = coleccion(2)
            .Add("@FechaCorte", SqlDbType.DateTime).Value = coleccion(3)

        End With
        Try


            retorno = cmd.ExecuteNonQuery
            MsgBox("Fechas guardadas correctamente")
        Catch ex As Exception
            MsgBox("Ha ocurrido un error")
        End Try
        cn.Close()
        Return retorno
    End Function
End Class
