Merge branch 'master' of http://jperez@192.168.10.111:8383/SIG.git
This commit is contained in:
@@ -1,306 +1,306 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports System.Data
|
||||
Imports System.Data.SqlClient
|
||||
Imports Extensiones
|
||||
Imports System
|
||||
Imports System.Configuration
|
||||
|
||||
Public Class ClsGralFolios
|
||||
Implements IDisposable
|
||||
|
||||
#Region "Campos"
|
||||
|
||||
'SQL
|
||||
Private SqlConexion As SqlConnection
|
||||
Private SqlAdapter As SqlDataAdapter
|
||||
Private SqlCommand As SqlCommand
|
||||
Private SqlTransacc As SqlTransaction
|
||||
Private Data As DataTable
|
||||
|
||||
'Atributos de la clase
|
||||
|
||||
Private _CveFolio As Integer
|
||||
Private _CveEmpresa As Integer
|
||||
Private _CveUsuario As Integer
|
||||
Private _Aprobacion As String
|
||||
Private _CBB As String
|
||||
Private _FInicial As Integer
|
||||
Private _FFinal As Integer
|
||||
Private _FActual As Integer
|
||||
Private _FechaIng As Date
|
||||
|
||||
Private disposedValue As Boolean = False ' Para detectar llamadas redundantes
|
||||
'REGISTRAR CONEXIONES ABIERTAS
|
||||
Private CveConexion As Integer = 0
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Propiedades"
|
||||
|
||||
Public ReadOnly Property DtResultados() As DataTable
|
||||
Get
|
||||
DtResultados = Data
|
||||
End Get
|
||||
End Property
|
||||
#End Region
|
||||
|
||||
Public Function IniciaTransacSQL() As SqlTransaction
|
||||
If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction()
|
||||
Return SqlTransacc
|
||||
End Function
|
||||
|
||||
Public Sub RollBack()
|
||||
SqlTransacc.Rollback()
|
||||
End Sub
|
||||
|
||||
Public Sub Commit()
|
||||
SqlTransacc.Commit()
|
||||
End Sub
|
||||
|
||||
Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing)
|
||||
|
||||
If TransaccionCompartida Is Nothing Then
|
||||
SqlConexion = New SqlConnection
|
||||
SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString
|
||||
Try
|
||||
SqlConexion.Open()
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex)
|
||||
End Try
|
||||
Else
|
||||
SqlConexion = TransaccionCompartida.Connection
|
||||
SqlTransacc = TransaccionCompartida
|
||||
End If
|
||||
|
||||
SqlAdapter = New SqlDataAdapter("", SqlConexion)
|
||||
ConexionAdd()
|
||||
End Sub
|
||||
|
||||
Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure)
|
||||
With SqlAdapter.SelectCommand
|
||||
.Parameters.Clear()
|
||||
.CommandText = pStrSQL
|
||||
.CommandType = TipoComando
|
||||
End With
|
||||
Data = New DataTable
|
||||
If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc
|
||||
End Sub
|
||||
#Region "Conexiones"
|
||||
|
||||
Private Sub ConexionAdd()
|
||||
If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then
|
||||
Try
|
||||
DataAdapter("PA_Sis_RegistrarConexion")
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name
|
||||
.Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}?{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString)
|
||||
.Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output
|
||||
End With
|
||||
SqlAdapter.Fill(Data)
|
||||
CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||
End Try
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ConexionClose()
|
||||
If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then
|
||||
|
||||
DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text)
|
||||
|
||||
Try
|
||||
SqlAdapter.Fill(Data)
|
||||
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||
End Try
|
||||
CveConexion = 0
|
||||
End If
|
||||
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
Public Function GetFolios(Optional TipoDocto As String = "-1", Optional CveEmpresa As Integer = -1) As Boolean
|
||||
Dim Retorno As Boolean = False
|
||||
DataAdapter("PA_Gral_FoliosGet")
|
||||
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto
|
||||
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
||||
.Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue
|
||||
End With
|
||||
|
||||
Try
|
||||
SqlAdapter.Fill(Data)
|
||||
Retorno = True
|
||||
Catch ex As SqlException
|
||||
OnError("Ocurrió un error al consultar los Folios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||
End Try
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
|
||||
Public Function AddFolios(CveSubProyecto As Integer, TipoDocto As String, Serie As String, FInicial As Integer, FActual As Integer, FFinal As Integer, CBB As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean
|
||||
Dim Retorno As Boolean = False
|
||||
DataAdapter("PA_Gral_FoliosAdd")
|
||||
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto
|
||||
.Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto
|
||||
.Add("@Serie", SqlDbType.VarChar).Value = Serie
|
||||
.Add("@FInicial", SqlDbType.Int).Value = FInicial
|
||||
.Add("@FActual", SqlDbType.Int).Value = FActual
|
||||
.Add("@FFinal", SqlDbType.Int).Value = FFinal
|
||||
.Add("@CBB", SqlDbType.VarChar).Value = CBB
|
||||
.Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario
|
||||
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
||||
.Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue
|
||||
End With
|
||||
|
||||
Try
|
||||
SqlAdapter.Fill(Data)
|
||||
_CveFolio = SqlAdapter.SelectCommand.Parameters("@RETURN_VALUE").Value.ToString.ToEntero
|
||||
Retorno = True
|
||||
Catch Ex1 As SqlException
|
||||
If Ex1.Message.Contains("Número: 2627;") Then
|
||||
Me.OnError("Ocurrió un error al guardar el folio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
Else
|
||||
Me.OnError("Ocurrió un error al guardar la nueva Aprobación de Folios.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
End If
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al guardar la nueva Aprobación de Folios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||
End Try
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
Public Function UpdateFolios(CveSubProyecto As Integer, TipoDocto As String, Serie As String, FInicial As Integer, FActual As Integer, FFinal As Integer, CBB As String, Estado As Boolean, CveUsuario As Integer, CveFolio As Integer) As Boolean
|
||||
Dim Retorno As Boolean = False
|
||||
DataAdapter("PA_Gral_FoliosUpdate")
|
||||
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto
|
||||
.Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto
|
||||
.Add("@Serie", SqlDbType.VarChar).Value = Serie
|
||||
.Add("@FInicial", SqlDbType.Int).Value = FInicial
|
||||
.Add("@FActual", SqlDbType.Int).Value = FActual
|
||||
.Add("@FFinal", SqlDbType.Int).Value = FFinal
|
||||
.Add("@CBB", SqlDbType.VarChar).Value = CBB
|
||||
.Add("@Estado", SqlDbType.Bit).Value = Estado
|
||||
.Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario
|
||||
.Add("@CveFolio", SqlDbType.Int).Value = CveFolio
|
||||
End With
|
||||
|
||||
Try
|
||||
SqlAdapter.Fill(Data)
|
||||
Retorno = True
|
||||
Catch Ex1 As SqlException
|
||||
If Ex1.Message.Contains("Número: 2627;") Then
|
||||
Me.OnError("Ocurrió un error al actualizar los folios..", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
Else
|
||||
Me.OnError("Ocurrió un error al actualizar los folios.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
End If
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al guardar los cambios en la Aprobación de Folios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||
End Try
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
Public Function RemoveFolios(CveFolio As Integer) As Boolean
|
||||
Dim Retorno As Boolean = False
|
||||
DataAdapter("PA_Gral_FoliosRemove")
|
||||
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@CveFolio", SqlDbType.Int).Value = CveFolio
|
||||
|
||||
End With
|
||||
|
||||
Try
|
||||
SqlAdapter.Fill(Data)
|
||||
Retorno = True
|
||||
Catch Ex1 As SqlException
|
||||
If Ex1.Message.Contains("Número: 547;") Then
|
||||
Alert("La aprobación de Folios no se pudo eliminar porque está siendo utilizado por otro registro.", TipoMensaje.MsgAdvertencia)
|
||||
Else
|
||||
Me.OnError("Ocurrió un error al eliminar la Aprobación de Folios.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Me.OnError("Ocurrió un error al eliminar la Aprobación de Folios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
End Try
|
||||
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
Public Function UpdateFolioActual(CveSubProyecto As Integer, TipoDocto As String, Estatus As Boolean, CveEmpresa As Integer) As Boolean
|
||||
Dim Retorno As Boolean = False
|
||||
DataAdapter("PA_Gral_FolioActualUpdate")
|
||||
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto
|
||||
.Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto
|
||||
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
||||
.Add("@Estado", SqlDbType.Bit).Value = Estatus
|
||||
End With
|
||||
|
||||
Try
|
||||
SqlAdapter.Fill(Data)
|
||||
Retorno = True
|
||||
Catch Ex1 As SqlException
|
||||
If Ex1.Message.Contains("Número: 547;") Then
|
||||
Alert("La aprobación de Folios no se pudo eliminar porque está siendo utilizado por otro registro.", TipoMensaje.MsgAdvertencia)
|
||||
Else
|
||||
Me.OnError("Ocurrió un error al actualizar la Aprobación de Folios.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Me.OnError("Ocurrió un error al actualizar la Aprobación de Folios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
End Try
|
||||
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
|
||||
#Region "IDisposable Support"
|
||||
|
||||
' IDisposable
|
||||
Protected Overridable Sub Dispose(disposing As Boolean)
|
||||
If Not Me.disposedValue Then
|
||||
If disposing Then
|
||||
' TODO: dispose managed state (managed objects).
|
||||
If Not Data Is Nothing Then Data.Dispose()
|
||||
If Not SqlAdapter Is Nothing Then SqlAdapter.Dispose()
|
||||
If Not SqlCommand Is Nothing Then SqlCommand.Dispose()
|
||||
If SqlConexion.State <> ConnectionState.Closed Then SqlConexion.Close()
|
||||
If Not SqlConexion Is Nothing Then SqlConexion.Dispose()
|
||||
End If
|
||||
|
||||
' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below.
|
||||
' TODO: set large fields to null.
|
||||
End If
|
||||
Me.disposedValue = True
|
||||
End Sub
|
||||
|
||||
' TODO: override Finalize() only if Dispose(disposing As Boolean) above has code to free unmanaged resources.
|
||||
'Protected Overrides Sub Finalize()
|
||||
' ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above.
|
||||
' Dispose(False)
|
||||
' MyBase.Finalize()
|
||||
'End Sub
|
||||
|
||||
' This code added by Visual Basic to correctly implement the disposable pattern.
|
||||
Public Sub Dispose() Implements IDisposable.Dispose
|
||||
' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above.
|
||||
ConexionClose()
|
||||
Dispose(True)
|
||||
GC.SuppressFinalize(Me)
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports System.Data
|
||||
Imports System.Data.SqlClient
|
||||
Imports Extensiones
|
||||
Imports System
|
||||
Imports System.Configuration
|
||||
|
||||
Public Class ClsGralFolios
|
||||
Implements IDisposable
|
||||
|
||||
#Region "Campos"
|
||||
|
||||
'SQL
|
||||
Private SqlConexion As SqlConnection
|
||||
Private SqlAdapter As SqlDataAdapter
|
||||
Private SqlCommand As SqlCommand
|
||||
Private SqlTransacc As SqlTransaction
|
||||
Private Data As DataTable
|
||||
|
||||
'Atributos de la clase
|
||||
|
||||
Private _CveFolio As Integer
|
||||
Private _CveEmpresa As Integer
|
||||
Private _CveUsuario As Integer
|
||||
Private _Aprobacion As String
|
||||
Private _CBB As String
|
||||
Private _FInicial As Integer
|
||||
Private _FFinal As Integer
|
||||
Private _FActual As Integer
|
||||
Private _FechaIng As Date
|
||||
|
||||
Private disposedValue As Boolean = False ' Para detectar llamadas redundantes
|
||||
'REGISTRAR CONEXIONES ABIERTAS
|
||||
Private CveConexion As Integer = 0
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Propiedades"
|
||||
|
||||
Public ReadOnly Property DtResultados() As DataTable
|
||||
Get
|
||||
DtResultados = Data
|
||||
End Get
|
||||
End Property
|
||||
#End Region
|
||||
|
||||
Public Function IniciaTransacSQL() As SqlTransaction
|
||||
If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction()
|
||||
Return SqlTransacc
|
||||
End Function
|
||||
|
||||
Public Sub RollBack()
|
||||
SqlTransacc.Rollback()
|
||||
End Sub
|
||||
|
||||
Public Sub Commit()
|
||||
SqlTransacc.Commit()
|
||||
End Sub
|
||||
|
||||
Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing)
|
||||
|
||||
If TransaccionCompartida Is Nothing Then
|
||||
SqlConexion = New SqlConnection
|
||||
SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString
|
||||
Try
|
||||
SqlConexion.Open()
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex)
|
||||
End Try
|
||||
Else
|
||||
SqlConexion = TransaccionCompartida.Connection
|
||||
SqlTransacc = TransaccionCompartida
|
||||
End If
|
||||
|
||||
SqlAdapter = New SqlDataAdapter("", SqlConexion)
|
||||
ConexionAdd()
|
||||
End Sub
|
||||
|
||||
Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure)
|
||||
With SqlAdapter.SelectCommand
|
||||
.Parameters.Clear()
|
||||
.CommandText = pStrSQL
|
||||
.CommandType = TipoComando
|
||||
End With
|
||||
Data = New DataTable
|
||||
If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc
|
||||
End Sub
|
||||
#Region "Conexiones"
|
||||
|
||||
Private Sub ConexionAdd()
|
||||
If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then
|
||||
Try
|
||||
DataAdapter("PA_Sis_RegistrarConexion")
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name
|
||||
.Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}?{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString)
|
||||
.Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output
|
||||
End With
|
||||
SqlAdapter.Fill(Data)
|
||||
CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||
End Try
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ConexionClose()
|
||||
If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then
|
||||
|
||||
DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text)
|
||||
|
||||
Try
|
||||
SqlAdapter.Fill(Data)
|
||||
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||
End Try
|
||||
CveConexion = 0
|
||||
End If
|
||||
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
Public Function GetFolios(Optional TipoDocto As String = "-1", Optional CveEmpresa As Integer = -1) As Boolean
|
||||
Dim Retorno As Boolean = False
|
||||
DataAdapter("PA_Gral_FoliosGet")
|
||||
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto
|
||||
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
||||
.Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue
|
||||
End With
|
||||
|
||||
Try
|
||||
SqlAdapter.Fill(Data)
|
||||
Retorno = True
|
||||
Catch ex As SqlException
|
||||
OnError("Ocurrió un error al consultar los Folios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||
End Try
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
|
||||
Public Function AddFolios(CveSubProyecto As Integer, TipoDocto As String, Serie As String, FInicial As Integer, FActual As Integer, FFinal As Integer, CBB As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean
|
||||
Dim Retorno As Boolean = False
|
||||
DataAdapter("PA_Gral_FoliosAdd")
|
||||
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto
|
||||
.Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto
|
||||
.Add("@Serie", SqlDbType.VarChar).Value = Serie
|
||||
.Add("@FInicial", SqlDbType.Int).Value = FInicial
|
||||
.Add("@FActual", SqlDbType.Int).Value = FActual
|
||||
.Add("@FFinal", SqlDbType.Int).Value = FFinal
|
||||
.Add("@CBB", SqlDbType.VarChar).Value = CBB
|
||||
.Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario
|
||||
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
||||
.Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue
|
||||
End With
|
||||
|
||||
Try
|
||||
SqlAdapter.Fill(Data)
|
||||
_CveFolio = SqlAdapter.SelectCommand.Parameters("@RETURN_VALUE").Value.ToString.ToEntero
|
||||
Retorno = True
|
||||
Catch Ex1 As SqlException
|
||||
If Ex1.Message.Contains("Número: 2627;") Then
|
||||
Me.OnError("Ocurrió un error al guardar el folio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
Else
|
||||
Me.OnError("Ocurrió un error al guardar la nueva Aprobación de Folios.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
End If
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al guardar la nueva Aprobación de Folios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||
End Try
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
Public Function UpdateFolios(CveSubProyecto As Integer, TipoDocto As String, Serie As String, FInicial As Integer, FActual As Integer, FFinal As Integer, CBB As String, Estado As Boolean, CveUsuario As Integer, CveFolio As Integer) As Boolean
|
||||
Dim Retorno As Boolean = False
|
||||
DataAdapter("PA_Gral_FoliosUpdate")
|
||||
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto
|
||||
.Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto
|
||||
.Add("@Serie", SqlDbType.VarChar).Value = Serie
|
||||
.Add("@FInicial", SqlDbType.Int).Value = FInicial
|
||||
.Add("@FActual", SqlDbType.Int).Value = FActual
|
||||
.Add("@FFinal", SqlDbType.Int).Value = FFinal
|
||||
.Add("@CBB", SqlDbType.VarChar).Value = CBB
|
||||
.Add("@Estado", SqlDbType.Bit).Value = Estado
|
||||
.Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario
|
||||
.Add("@CveFolio", SqlDbType.Int).Value = CveFolio
|
||||
End With
|
||||
|
||||
Try
|
||||
SqlAdapter.Fill(Data)
|
||||
Retorno = True
|
||||
Catch Ex1 As SqlException
|
||||
If Ex1.Message.Contains("Número: 2627;") Then
|
||||
Me.OnError("Ocurrió un error al actualizar los folios..", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
Else
|
||||
Me.OnError("Ocurrió un error al actualizar los folios.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
End If
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al guardar los cambios en la Aprobación de Folios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||
End Try
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
Public Function RemoveFolios(CveFolio As Integer) As Boolean
|
||||
Dim Retorno As Boolean = False
|
||||
DataAdapter("PA_Gral_FoliosRemove")
|
||||
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@CveFolio", SqlDbType.Int).Value = CveFolio
|
||||
|
||||
End With
|
||||
|
||||
Try
|
||||
SqlAdapter.Fill(Data)
|
||||
Retorno = True
|
||||
Catch Ex1 As SqlException
|
||||
If Ex1.Message.Contains("Número: 547;") Then
|
||||
Alert("La aprobación de Folios no se pudo eliminar porque está siendo utilizado por otro registro.", TipoMensaje.MsgAdvertencia)
|
||||
Else
|
||||
Me.OnError("Ocurrió un error al eliminar la Aprobación de Folios.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Me.OnError("Ocurrió un error al eliminar la Aprobación de Folios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
End Try
|
||||
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
Public Function UpdateFolioActual(CveSubProyecto As Integer, TipoDocto As String, Estatus As Boolean, CveEmpresa As Integer) As Boolean
|
||||
Dim Retorno As Boolean = False
|
||||
DataAdapter("PA_Gral_FolioActualUpdate")
|
||||
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto
|
||||
.Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto
|
||||
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
||||
.Add("@Estado", SqlDbType.Bit).Value = Estatus
|
||||
End With
|
||||
|
||||
Try
|
||||
SqlAdapter.Fill(Data)
|
||||
Retorno = True
|
||||
Catch Ex1 As SqlException
|
||||
If Ex1.Message.Contains("Número: 547;") Then
|
||||
Alert("La aprobación de Folios no se pudo eliminar porque está siendo utilizado por otro registro.", TipoMensaje.MsgAdvertencia)
|
||||
Else
|
||||
Me.OnError("Ocurrió un error al actualizar la Aprobación de Folios.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Me.OnError("Ocurrió un error al actualizar la Aprobación de Folios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
End Try
|
||||
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
|
||||
#Region "IDisposable Support"
|
||||
|
||||
' IDisposable
|
||||
Protected Overridable Sub Dispose(disposing As Boolean)
|
||||
If Not Me.disposedValue Then
|
||||
If disposing Then
|
||||
' TODO: dispose managed state (managed objects).
|
||||
If Not Data Is Nothing Then Data.Dispose()
|
||||
If Not SqlAdapter Is Nothing Then SqlAdapter.Dispose()
|
||||
If Not SqlCommand Is Nothing Then SqlCommand.Dispose()
|
||||
If SqlConexion.State <> ConnectionState.Closed Then SqlConexion.Close()
|
||||
If Not SqlConexion Is Nothing Then SqlConexion.Dispose()
|
||||
End If
|
||||
|
||||
' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below.
|
||||
' TODO: set large fields to null.
|
||||
End If
|
||||
Me.disposedValue = True
|
||||
End Sub
|
||||
|
||||
' TODO: override Finalize() only if Dispose(disposing As Boolean) above has code to free unmanaged resources.
|
||||
'Protected Overrides Sub Finalize()
|
||||
' ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above.
|
||||
' Dispose(False)
|
||||
' MyBase.Finalize()
|
||||
'End Sub
|
||||
|
||||
' This code added by Visual Basic to correctly implement the disposable pattern.
|
||||
Public Sub Dispose() Implements IDisposable.Dispose
|
||||
' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above.
|
||||
ConexionClose()
|
||||
Dispose(True)
|
||||
GC.SuppressFinalize(Me)
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,215 +1,215 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports System.Data
|
||||
Imports Extensiones
|
||||
Imports System.IO
|
||||
|
||||
Partial Class CatFolios
|
||||
Inherits ClsPaginas
|
||||
|
||||
#Region "P R O P I E D A D E S"
|
||||
Private Property CveFolio As Integer
|
||||
Get
|
||||
Return ViewState("CveFolio").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveFolio") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
#End Region
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
||||
If Not Page.IsPostBack Then
|
||||
ViewState("Orden") = ""
|
||||
Session("FileUpload") = ""
|
||||
CargaSubProyectos()
|
||||
CargaDdlTipoDocto()
|
||||
CargaDatos()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
#Region "C A R G A S"
|
||||
|
||||
Private Sub CargaDdlTipoDocto()
|
||||
DdlTipoDocto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
If UsuarioActual.Empresa.CvePlataforma = 1 Then
|
||||
DdlTipoDocto.Items.Insert(1, New ListItem("Facturas", "Ing"))
|
||||
DdlTipoDocto.Items.Insert(2, New ListItem("Remisión", "Rem"))
|
||||
DdlTipoDocto.Items.Insert(3, New ListItem("Notas de Crédito", "Egs"))
|
||||
DdlTipoDocto.Items.Insert(4, New ListItem("Devoluciones", "Dev"))
|
||||
DdlTipoDocto.Items.Insert(5, New ListItem("Cotización", "Cot"))
|
||||
DdlTipoDocto.Items.Insert(6, New ListItem("Requisiciones", "Req"))
|
||||
DdlTipoDocto.Items.Insert(7, New ListItem("Orden de Compra", "OC"))
|
||||
DdlTipoDocto.Items.Insert(8, New ListItem("Orden de Servicio", "OS"))
|
||||
DdlTipoDocto.Items.Insert(9, New ListItem("Nomina", "Nom"))
|
||||
DdlTipoDocto.Items.Insert(10, New ListItem("Organización Interna", "OI"))
|
||||
DdlTipoDocto.Items.Insert(11, New ListItem("Vale Gasolina", "VaG"))
|
||||
DdlTipoDocto.Items.Insert(12, New ListItem("Resguardo AF", "AFR"))
|
||||
DdlTipoDocto.Items.Insert(13, New ListItem("Traslado AF", "AFT"))
|
||||
DdlTipoDocto.Items.Insert(14, New ListItem("Acarreo", "Aca"))
|
||||
DdlTipoDocto.Items.Insert(15, New ListItem("Contratos", "Con"))
|
||||
DdlTipoDocto.Items.Insert(16, New ListItem("Pedido", "Ped"))
|
||||
DdlTipoDocto.Items.Insert(17, New ListItem("Devolución de Pedido", "DPe"))
|
||||
DdlTipoDocto.Items.Insert(18, New ListItem("Pedido de Consignación", "PeC"))
|
||||
DdlTipoDocto.Items.Insert(19, New ListItem("Órden de Producción", "OP"))
|
||||
DdlTipoDocto.Items.Insert(20, New ListItem("Órden de Corte", "OCO"))
|
||||
DdlTipoDocto.Items.Insert(21, New ListItem("Entrada de Materia Prima a Empaque", "EME"))
|
||||
DdlTipoDocto.Items.Insert(22, New ListItem("Empaque", "EMP"))
|
||||
DdlTipoDocto.Items.Insert(23, New ListItem("Solicitud de Traslado", "STr"))
|
||||
DdlTipoDocto.Items.Insert(24, New ListItem("Complemento Pago", "CP"))
|
||||
DdlTipoDocto.Items.Insert(24, New ListItem("Fletes", "FLE"))
|
||||
DdlTipoDocto.Items.Insert(25, New ListItem("Activos Fijos", "AF"))
|
||||
DdlTipoDocto.Items.Insert(26, New ListItem("Viaticos", "VIA"))
|
||||
DdlTipoDocto.Items.Insert(27, New ListItem("Remanufactura", "RMF"))
|
||||
DdlTipoDocto.Items.Insert(28, New ListItem("PedidoA", "PA"))
|
||||
DdlTipoDocto.Items.Insert(29, New ListItem("Pedido2", "Pd2"))
|
||||
DdlTipoDocto.Items.Insert(30, New ListItem("Proveedor/Acreedor", "Amb"))
|
||||
DdlTipoDocto.Items.Insert(31, New ListItem("Proveedor", "Pro"))
|
||||
DdlTipoDocto.Items.Insert(32, New ListItem("Acreedor", "Acr"))
|
||||
DdlTipoDocto.Items.Insert(33, New ListItem("Productos/Servicios", "PS"))
|
||||
DdlTipoDocto.Items.Insert(34, New ListItem("NC de Remisión", "RNC"))
|
||||
ElseIf UsuarioActual.Empresa.CvePlataforma = 2 Then
|
||||
DdlTipoDocto.Items.Insert(1, New ListItem("Facturas", "Ing"))
|
||||
DdlTipoDocto.Items.Insert(2, New ListItem("Notas de Crédito", "Egs"))
|
||||
DdlTipoDocto.Items.Insert(3, New ListItem("Cotización", "Cot"))
|
||||
DdlTipoDocto.Items.Insert(4, New ListItem("Remisión", "Rem"))
|
||||
DdlTipoDocto.Items.Insert(5, New ListItem("Orden de Compra", "OC"))
|
||||
End If
|
||||
DdlTipoDocto.DataBind()
|
||||
End Sub
|
||||
Private Sub CargaSubProyectos()
|
||||
DdlSubProyecto.Items.Clear()
|
||||
DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
||||
DdlSubProyecto.DataBind()
|
||||
|
||||
DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
End Sub
|
||||
Public Sub CargaDatos()
|
||||
Dim ObjFolios As New ClsGralFolios
|
||||
If ObjFolios.GetFolios() Then
|
||||
ViewState("DTFolios") = ObjFolios.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
||||
GlobalDTFolios = ObjFolios.DtResultados
|
||||
GvDatos.DataSource = ObjFolios.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
||||
GvDatos.DataBind()
|
||||
Else
|
||||
Me.GvDatos.DataSource = Nothing
|
||||
End If
|
||||
|
||||
ObjFolios.Dispose()
|
||||
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
Public Sub BtnAgregarFolio_Click(sender As Object, e As EventArgs)
|
||||
CveFolio = -1
|
||||
HdnModalidad.Value = "I"
|
||||
ChkEstatus.Checked = True
|
||||
TxtFolioInicial.Text = ""
|
||||
TxtFolioFinal.Text = ""
|
||||
TxtFolioActual.Text = ""
|
||||
txtserie.text = ""
|
||||
DivFactual.Visible = False
|
||||
CargaSubProyectos()
|
||||
|
||||
BtnGuardar.Text = "Agregar"
|
||||
UpAddFolio.Update()
|
||||
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarFolio"))
|
||||
End Sub
|
||||
|
||||
Public Sub Edit_Click(sender As Object, e As EventArgs)
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
CveFolio = (GvRow.DataKey("CveFolio")).ToEntero
|
||||
HdnModalidad.Value = "U"
|
||||
DdlSubProyecto.SelectedValueExist(GvRow.DataKey("CveSubProyecto"))
|
||||
DdlTipoDocto.SelectedValueExist(GvRow.DataKey("TipoDocto"))
|
||||
ChkEstatus.Checked = If(GvRow.DataKey("Estado").ToString = "Activo", True, False)
|
||||
TxtFolioInicial.Text = (GvRow.DataKey("FInicial"))
|
||||
TxtFolioFinal.Text = (GvRow.DataKey("FFinal"))
|
||||
TxtFolioActual.Text = (GvRow.DataKey("FActual"))
|
||||
DivFactual.Visible = True
|
||||
|
||||
|
||||
BtnGuardar.Text = "Actualizar"
|
||||
UpAddFolio.Update()
|
||||
|
||||
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarFolio"))
|
||||
End Sub
|
||||
|
||||
#Region "GV"
|
||||
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
||||
e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right
|
||||
e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right
|
||||
e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right
|
||||
|
||||
End If
|
||||
End Sub
|
||||
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
|
||||
Dim ObjFolios As New ClsGralFolios
|
||||
If ObjFolios.RemoveFolios(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
||||
GvDatos.EditIndex = -1
|
||||
ViewState("DTFolios") = ObjFolios.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
||||
GlobalDTFolios = ObjFolios.DtResultados
|
||||
Alert("La Aprobación de Folios se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
||||
End If
|
||||
ObjFolios.Dispose()
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "G U A R D A R "
|
||||
Private Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
|
||||
Dim ObjFolios As New ClsGralFolios
|
||||
Dim TieneError = False
|
||||
|
||||
|
||||
If HdnModalidad.Value = "I" Then
|
||||
If Not ObjFolios.AddFolios(DdlSubProyecto.SelectedValue.ToEntero, DdlTipoDocto.SelectedValue, TxtFolioInicial.Text.Trim.ToEntero, TxtFolioInicial.Text.Trim.ToEntero,
|
||||
TxtFolioFinal.Text.Trim.Trim.ToEntero, Session("FileUpload").ToString, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
||||
TieneError = True
|
||||
End If
|
||||
Else
|
||||
If Not ObjFolios.UpdateFolios(DdlSubProyecto.SelectedValue.ToEntero, DdlTipoDocto.SelectedValue, TxtFolioInicial.Text.Trim.ToEntero, TxtFolioActual.Text.Trim.ToEntero, TxtFolioFinal.Text.Trim.ToEntero,
|
||||
"", If(ChkEstatus.Checked, True, False), UsuarioActual.CveUsuario, CveFolio) Then
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
|
||||
If TieneError Then
|
||||
Alert("Ocurrio un error al guardar/editar la nueva aprobación de Folios", TipoMensaje.MsgError)
|
||||
Else
|
||||
|
||||
DdlTipoDocto.SelectedIndex = 0
|
||||
TxtFolioInicial.Text = ""
|
||||
TxtFolioActual.Text = ""
|
||||
TxtFolioFinal.Text = ""
|
||||
|
||||
Session("FileUpload") = ""
|
||||
|
||||
Alert("El nuevo Folio se guardó/editó correctamente.", TipoMensaje.MsgInformacion)
|
||||
GlobalDTFolios = ObjFolios.DtResultados
|
||||
ViewState("DTFolios") = ObjFolios.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
||||
|
||||
|
||||
CargaDatos()
|
||||
UpDatos.Update()
|
||||
UpAddFolio.Update()
|
||||
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarFolio"))
|
||||
End If
|
||||
|
||||
|
||||
ObjFolios.Dispose()
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports System.Data
|
||||
Imports Extensiones
|
||||
Imports System.IO
|
||||
|
||||
Partial Class CatFolios
|
||||
Inherits ClsPaginas
|
||||
|
||||
#Region "P R O P I E D A D E S"
|
||||
Private Property CveFolio As Integer
|
||||
Get
|
||||
Return ViewState("CveFolio").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveFolio") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
#End Region
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
||||
If Not Page.IsPostBack Then
|
||||
ViewState("Orden") = ""
|
||||
Session("FileUpload") = ""
|
||||
CargaSubProyectos()
|
||||
CargaDdlTipoDocto()
|
||||
CargaDatos()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
#Region "C A R G A S"
|
||||
|
||||
Private Sub CargaDdlTipoDocto()
|
||||
DdlTipoDocto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
If UsuarioActual.Empresa.CvePlataforma = 1 Then
|
||||
DdlTipoDocto.Items.Insert(1, New ListItem("Facturas", "Ing"))
|
||||
DdlTipoDocto.Items.Insert(2, New ListItem("Remisión", "Rem"))
|
||||
DdlTipoDocto.Items.Insert(3, New ListItem("Notas de Crédito", "Egs"))
|
||||
DdlTipoDocto.Items.Insert(4, New ListItem("Devoluciones", "Dev"))
|
||||
DdlTipoDocto.Items.Insert(5, New ListItem("Cotización", "Cot"))
|
||||
DdlTipoDocto.Items.Insert(6, New ListItem("Requisiciones", "Req"))
|
||||
DdlTipoDocto.Items.Insert(7, New ListItem("Orden de Compra", "OC"))
|
||||
DdlTipoDocto.Items.Insert(8, New ListItem("Orden de Servicio", "OS"))
|
||||
DdlTipoDocto.Items.Insert(9, New ListItem("Nomina", "Nom"))
|
||||
DdlTipoDocto.Items.Insert(10, New ListItem("Organización Interna", "OI"))
|
||||
DdlTipoDocto.Items.Insert(11, New ListItem("Vale Gasolina", "VaG"))
|
||||
DdlTipoDocto.Items.Insert(12, New ListItem("Resguardo AF", "AFR"))
|
||||
DdlTipoDocto.Items.Insert(13, New ListItem("Traslado AF", "AFT"))
|
||||
DdlTipoDocto.Items.Insert(14, New ListItem("Acarreo", "Aca"))
|
||||
DdlTipoDocto.Items.Insert(15, New ListItem("Contratos", "Con"))
|
||||
DdlTipoDocto.Items.Insert(16, New ListItem("Pedido", "Ped"))
|
||||
DdlTipoDocto.Items.Insert(17, New ListItem("Devolución de Pedido", "DPe"))
|
||||
DdlTipoDocto.Items.Insert(18, New ListItem("Pedido de Consignación", "PeC"))
|
||||
DdlTipoDocto.Items.Insert(19, New ListItem("Órden de Producción", "OP"))
|
||||
DdlTipoDocto.Items.Insert(20, New ListItem("Órden de Corte", "OCO"))
|
||||
DdlTipoDocto.Items.Insert(21, New ListItem("Entrada de Materia Prima a Empaque", "EME"))
|
||||
DdlTipoDocto.Items.Insert(22, New ListItem("Empaque", "EMP"))
|
||||
DdlTipoDocto.Items.Insert(23, New ListItem("Solicitud de Traslado", "STr"))
|
||||
DdlTipoDocto.Items.Insert(24, New ListItem("Complemento Pago", "CP"))
|
||||
DdlTipoDocto.Items.Insert(24, New ListItem("Fletes", "FLE"))
|
||||
DdlTipoDocto.Items.Insert(25, New ListItem("Activos Fijos", "AF"))
|
||||
DdlTipoDocto.Items.Insert(26, New ListItem("Viaticos", "VIA"))
|
||||
DdlTipoDocto.Items.Insert(27, New ListItem("Remanufactura", "RMF"))
|
||||
DdlTipoDocto.Items.Insert(28, New ListItem("PedidoA", "PA"))
|
||||
DdlTipoDocto.Items.Insert(29, New ListItem("Pedido2", "Pd2"))
|
||||
DdlTipoDocto.Items.Insert(30, New ListItem("Proveedor/Acreedor", "Amb"))
|
||||
DdlTipoDocto.Items.Insert(31, New ListItem("Proveedor", "Pro"))
|
||||
DdlTipoDocto.Items.Insert(32, New ListItem("Acreedor", "Acr"))
|
||||
DdlTipoDocto.Items.Insert(33, New ListItem("Productos/Servicios", "PS"))
|
||||
DdlTipoDocto.Items.Insert(34, New ListItem("NC de Remisión", "RNC"))
|
||||
ElseIf UsuarioActual.Empresa.CvePlataforma = 2 Then
|
||||
DdlTipoDocto.Items.Insert(1, New ListItem("Facturas", "Ing"))
|
||||
DdlTipoDocto.Items.Insert(2, New ListItem("Notas de Crédito", "Egs"))
|
||||
DdlTipoDocto.Items.Insert(3, New ListItem("Cotización", "Cot"))
|
||||
DdlTipoDocto.Items.Insert(4, New ListItem("Remisión", "Rem"))
|
||||
DdlTipoDocto.Items.Insert(5, New ListItem("Orden de Compra", "OC"))
|
||||
End If
|
||||
DdlTipoDocto.DataBind()
|
||||
End Sub
|
||||
Private Sub CargaSubProyectos()
|
||||
DdlSubProyecto.Items.Clear()
|
||||
DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
||||
DdlSubProyecto.DataBind()
|
||||
|
||||
DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
End Sub
|
||||
Public Sub CargaDatos()
|
||||
Dim ObjFolios As New ClsGralFolios
|
||||
If ObjFolios.GetFolios() Then
|
||||
ViewState("DTFolios") = ObjFolios.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
||||
GlobalDTFolios = ObjFolios.DtResultados
|
||||
GvDatos.DataSource = ObjFolios.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
||||
GvDatos.DataBind()
|
||||
Else
|
||||
Me.GvDatos.DataSource = Nothing
|
||||
End If
|
||||
|
||||
ObjFolios.Dispose()
|
||||
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
Public Sub BtnAgregarFolio_Click(sender As Object, e As EventArgs)
|
||||
CveFolio = -1
|
||||
HdnModalidad.Value = "I"
|
||||
ChkEstatus.Checked = True
|
||||
TxtFolioInicial.Text = ""
|
||||
TxtFolioFinal.Text = ""
|
||||
TxtFolioActual.Text = ""
|
||||
txtserie.text = ""
|
||||
DivFactual.Visible = False
|
||||
CargaSubProyectos()
|
||||
|
||||
BtnGuardar.Text = "Agregar"
|
||||
UpAddFolio.Update()
|
||||
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarFolio"))
|
||||
End Sub
|
||||
|
||||
Public Sub Edit_Click(sender As Object, e As EventArgs)
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
CveFolio = (GvRow.DataKey("CveFolio")).ToEntero
|
||||
HdnModalidad.Value = "U"
|
||||
DdlSubProyecto.SelectedValueExist(GvRow.DataKey("CveSubProyecto"))
|
||||
DdlTipoDocto.SelectedValueExist(GvRow.DataKey("TipoDocto"))
|
||||
ChkEstatus.Checked = If(GvRow.DataKey("Estado").ToString = "Activo", True, False)
|
||||
TxtFolioInicial.Text = (GvRow.DataKey("FInicial"))
|
||||
TxtFolioFinal.Text = (GvRow.DataKey("FFinal"))
|
||||
TxtFolioActual.Text = (GvRow.DataKey("FActual"))
|
||||
DivFactual.Visible = True
|
||||
|
||||
|
||||
BtnGuardar.Text = "Actualizar"
|
||||
UpAddFolio.Update()
|
||||
|
||||
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarFolio"))
|
||||
End Sub
|
||||
|
||||
#Region "GV"
|
||||
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
||||
e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right
|
||||
e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right
|
||||
e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right
|
||||
|
||||
End If
|
||||
End Sub
|
||||
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
|
||||
Dim ObjFolios As New ClsGralFolios
|
||||
If ObjFolios.RemoveFolios(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
||||
GvDatos.EditIndex = -1
|
||||
ViewState("DTFolios") = ObjFolios.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
||||
GlobalDTFolios = ObjFolios.DtResultados
|
||||
Alert("La Aprobación de Folios se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
||||
End If
|
||||
ObjFolios.Dispose()
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "G U A R D A R "
|
||||
Private Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
|
||||
Dim ObjFolios As New ClsGralFolios
|
||||
Dim TieneError = False
|
||||
|
||||
|
||||
If HdnModalidad.Value = "I" Then
|
||||
If Not ObjFolios.AddFolios(DdlSubProyecto.SelectedValue.ToEntero, DdlTipoDocto.SelectedValue, TxtFolioInicial.Text.Trim.ToEntero, TxtFolioInicial.Text.Trim.ToEntero,
|
||||
TxtFolioFinal.Text.Trim.Trim.ToEntero, Session("FileUpload").ToString, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
||||
TieneError = True
|
||||
End If
|
||||
Else
|
||||
If Not ObjFolios.UpdateFolios(DdlSubProyecto.SelectedValue.ToEntero, DdlTipoDocto.SelectedValue, TxtFolioInicial.Text.Trim.ToEntero, TxtFolioActual.Text.Trim.ToEntero, TxtFolioFinal.Text.Trim.ToEntero,
|
||||
"", If(ChkEstatus.Checked, True, False), UsuarioActual.CveUsuario, CveFolio) Then
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
|
||||
If TieneError Then
|
||||
Alert("Ocurrio un error al guardar/editar la nueva aprobación de Folios", TipoMensaje.MsgError)
|
||||
Else
|
||||
|
||||
DdlTipoDocto.SelectedIndex = 0
|
||||
TxtFolioInicial.Text = ""
|
||||
TxtFolioActual.Text = ""
|
||||
TxtFolioFinal.Text = ""
|
||||
|
||||
Session("FileUpload") = ""
|
||||
|
||||
Alert("El nuevo Folio se guardó/editó correctamente.", TipoMensaje.MsgInformacion)
|
||||
GlobalDTFolios = ObjFolios.DtResultados
|
||||
ViewState("DTFolios") = ObjFolios.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
||||
|
||||
|
||||
CargaDatos()
|
||||
UpDatos.Update()
|
||||
UpAddFolio.Update()
|
||||
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarFolio"))
|
||||
End If
|
||||
|
||||
|
||||
ObjFolios.Dispose()
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user