diff --git a/Acumuladores/RepEntradasUsadosClientes.aspx b/Acumuladores/RepEntradasUsadosClientes.aspx index 7b495acc8..d5b839932 100644 --- a/Acumuladores/RepEntradasUsadosClientes.aspx +++ b/Acumuladores/RepEntradasUsadosClientes.aspx @@ -66,7 +66,10 @@ - +
Cliente:
+
+ +
@@ -124,9 +127,10 @@ - + + - + diff --git a/Acumuladores/RepEntradasUsadosClientes.aspx.vb b/Acumuladores/RepEntradasUsadosClientes.aspx.vb index e83cfdea4..25e180f3d 100644 --- a/Acumuladores/RepEntradasUsadosClientes.aspx.vb +++ b/Acumuladores/RepEntradasUsadosClientes.aspx.vb @@ -19,6 +19,7 @@ Partial Class Acumuladores_RepEntradasUsadosClientes If Not Page.IsPostBack Then CargaCombos() + CargaNombreClientes() End If End Sub @@ -26,8 +27,11 @@ Partial Class Acumuladores_RepEntradasUsadosClientes Private Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click CargaDatos() + End Sub + Private Sub CargaNombreClientes() + DdlNombre.setEsWebService(True) + DdlNombre.Attributes.Add("data-metodo", "getcliente") End Sub - Public Sub CargaCombos() DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 22) DdlAlmacen.DataBind() @@ -44,11 +48,11 @@ Partial Class Acumuladores_RepEntradasUsadosClientes FechaI = If(IsDate(TxtFechaI.Text.Trim()), TxtFechaI.Text.Trim.todate, minfecha) FechaF = If(IsDate(TxtFechaF.Text.Trim()), TxtFechaF.Text.Trim.todate, maxfecha) - Dim CveAlmacen As Integer = If(DdlAlmacen.SelectedValue = "", "-1", DdlAlmacen.SelectedValue).ToString.toentero - + Dim CveAlmacen As Integer = If(DdlAlmacen.SelectedValue = "", "-1", DdlAlmacen.SelectedValue).ToString.ToEntero + Dim CveCliente As Integer = If(DdlNombre.SelectedValue = "", "-1", DdlNombre.SelectedValue).ToString.ToEntero Dim Acum As New ClsAcumuladores - If Acum.EntradasUsadosClientesRep(CveAlmacen, FechaI, FechaF, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + If Acum.EntradasUsadosClientesRep(CveAlmacen, FechaI, FechaF, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCliente) Then GvDatos.DataSource = Acum.DtResultados.FiltraParametros("Codigo_Clientes <> 'Total:'") 'los renglones generados con esta caracteriztica son con un grouping set en la consulta, se pueden quitar DatosEntradasUsadosClientes = Acum.DtResultados.FiltraParametros("Codigo_Clientes <> 'Total:'") End If diff --git a/App_Code/ClsAcumuladores.vb b/App_Code/ClsAcumuladores.vb index a52ab1a98..365c14035 100644 --- a/App_Code/ClsAcumuladores.vb +++ b/App_Code/ClsAcumuladores.vb @@ -1076,7 +1076,7 @@ Public Class ClsAcumuladores Return Retorno End Function - Public Function EntradasUsadosClientesRep(CveAlmacen As Integer, FechaI As Date, FechaF As Date, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Public Function EntradasUsadosClientesRep(CveAlmacen As Integer, FechaI As Date, FechaF As Date, CveUsuario As Integer, CveEmpresa As Integer, Optional CveCliente As Integer = -1) As Boolean Dim Retorno As Boolean = False 'Data = New DataTable @@ -1088,6 +1088,8 @@ Public Class ClsAcumuladores .Add("@FechaFin", SqlDbType.Date).Value = FechaF .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + End With Try diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 4c4d73133..ccb61fddf 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -4802,7 +4802,6 @@ Public Class ClsPaginas #End Region #Region "Planeacion" 'PLANEACIÓN - PaginaDict.Add("/Planeacion/CatSucursales.aspx".ToUpper(), 17) PaginaDict.Add("/Planeacion/Sucursal.aspx".ToUpper(), 17) PaginaDict.Add("/Planeacion/CatProyectos.aspx".ToUpper(), 34) PaginaDict.Add("/Planeacion/CatSubProyectos.aspx".ToUpper(), 35) diff --git a/App_Code/ClsSucursales.vb b/App_Code/ClsSucursales.vb new file mode 100644 index 000000000..b7d3f0f00 --- /dev/null +++ b/App_Code/ClsSucursales.vb @@ -0,0 +1,383 @@ +Option Explicit On +Option Strict On + +Imports System.Data +Imports System.Data.SqlClient +Imports Extensiones +Imports System +Imports System.Configuration + +Public Class ClsSucursales + Implements IDisposable + +#Region "Campos" + + 'SQL + Private SqlConexion As SqlConnection + Private SqlAdapter As SqlDataAdapter + Private SqlTransacc As SqlTransaction + Private SqlCommand As SqlCommand + Private Data As DataTable + + Private disposedValue As Boolean = False + + 'Atributos de la clase + Private _Calle As String + Private _NoExt As String + Private _NoInt As String + Private _Colonia As String + Private _Localidad As String + Private _Municipio As String + Private _Estado As String + Private _Pais As String + Private _CP As Integer + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 +#End Region + +#Region "Propiedades" + Public ReadOnly Property Calle As String + Get + Return _Calle + End Get + End Property + + Public ReadOnly Property NoExt As String + Get + Return _NoExt + End Get + End Property + + Public ReadOnly Property NoInt As String + Get + Return _NoInt + End Get + End Property + + Public ReadOnly Property Colonia As String + Get + Return _Colonia + End Get + End Property + + Public ReadOnly Property Localidad As String + Get + Return _Localidad + End Get + End Property + + Public ReadOnly Property Municipio As String + Get + Return _Municipio + End Get + End Property + + Public ReadOnly Property Estado As String + Get + Return _Estado + End Get + End Property + + Public ReadOnly Property Pais As String + Get + Return _Pais + End Get + End Property + + Public ReadOnly Property CP As Integer + Get + Return _CP + End Get + End Property + + Public ReadOnly Property DtResultados() As DataTable + Get + DtResultados = Data + End Get + End Property +#End Region + + 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 + + SqlCommand = New SqlCommand("", SqlConexion) + SqlAdapter = New SqlDataAdapter("", SqlConexion) + ConexionAdd() + End Sub + Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) + With SqlAdapter.SelectCommand + .Parameters.Clear() + .CommandText = StrSQL + .CommandType = TipoComando + End With + If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc + Data = New DataTable + End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + 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 + Private Sub DataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) + With SqlCommand + .Parameters.Clear() + .CommandText = pStrSQL + .CommandType = TipoComando + End With + + If Not SqlTransacc Is Nothing Then SqlCommand.Transaction = SqlTransacc + + End Sub + Public Function IniciaTransacSQL() As SqlTransaction + If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() + Return SqlTransacc + End Function + + Public Sub RollBack() + If SqlTransacc IsNot Nothing Then SqlTransacc.Rollback() + SqlTransacc = Nothing + End Sub + Public Sub Commit() + If SqlTransacc IsNot Nothing Then SqlTransacc.Commit() + SqlTransacc = Nothing + End Sub + + 'Public Function GetSucursalesEmpresa(CveEmpresa As Integer) As Boolean + ' Dim Retorno As Boolean = False + ' Data = New DataTable + ' SqlAdapter = New SqlDataAdapter("PA_GetSucursalesEmpresa", SqlConexion) + ' SqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure + + ' With SqlAdapter.SelectCommand.Parameters + ' .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + ' End With + + + ' Try + ' SqlAdapter.Fill(Data) + ' Retorno = True + ' Catch ex As SqlException + ' OnError("Ocurrió un error al consultar las Sucursales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + ' End Try + ' SqlAdapter.Dispose() + ' Return Retorno + 'End Function + + + + + Public Function GetSucursales(Optional CveEmpresa As Integer = -1) As Boolean + Dim Retorno As Boolean = False + Data = New DataTable + SqlAdapter = New SqlDataAdapter("PA_SucursalesGet", SqlConexion) + SqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al consultar las Sucursales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + SqlAdapter.Dispose() + Return Retorno + End Function + + + + + Public Function AddSucursal(Sucursal As String, Serie As String, IVA As Double, FormatoFactura As String, CveUsuario As Integer, CveEmpresa As Integer, + Calle As String, NoExt As String, NoInt As String, Colonia As String, Localidad As String, Municipio As String, Estado As String, Pais As String, CP As String, TipoSucursal As Integer) As Integer + Dim Retorno = -1 + + DataAdapter("PA_SucursalAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Sucursal", SqlDbType.VarChar).Value = Sucursal + .Add("@Serie", SqlDbType.VarChar).Value = Serie + .Add("@IVA", SqlDbType.Float).Value = IVA + .Add("@FormatoFactura", SqlDbType.VarChar).Value = FormatoFactura + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + + .Add("@Calle", SqlDbType.VarChar).Value = Calle + .Add("@NoExt", SqlDbType.VarChar).Value = NoExt + .Add("@NoInt", SqlDbType.VarChar).Value = NoInt + .Add("@Colonia", SqlDbType.VarChar).Value = Colonia + .Add("@Localidad", SqlDbType.VarChar).Value = Localidad + .Add("@Municipio", SqlDbType.VarChar).Value = Municipio + .Add("@Estado", SqlDbType.VarChar).Value = Estado + .Add("@Pais", SqlDbType.VarChar).Value = Pais + .Add("@CP", SqlDbType.VarChar).Value = CP + .Add("@TipoSucursal", SqlDbType.Int).Value = TipoSucursal + .Add("@pCveSucursal", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + Retorno = SqlAdapter.SelectCommand.Parameters("@pCveSucursal").Value.ToString.ToEntero + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe una Sucursal con el mismo nombre: " & Sucursal & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar la Sucursal.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Sucursal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + SqlAdapter.Dispose() + Return Retorno + End Function + + Public Function UpdateSucursal(Sucursal As String, Serie As String, IVA As Double, FormatoFactura As String, Estatus As Boolean, CveUsuario As Integer, CveSucursal As Integer, + Calle As String, NoExt As String, NoInt As String, Colonia As String, Localidad As String, Municipio As String, Estado As String, Pais As String, CP As String, TipoSucursal As Integer) As Boolean + Dim Retorno As Boolean = False + Data = New DataTable + SqlAdapter = New SqlDataAdapter("PA_SucursalUpdate", SqlConexion) + SqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure + With SqlAdapter.SelectCommand.Parameters + .Add("@Sucursal", SqlDbType.VarChar).Value = Sucursal + .Add("@Serie", SqlDbType.VarChar).Value = Serie + .Add("@IVA", SqlDbType.Float).Value = IVA + .Add("@FormatoFactura", SqlDbType.VarChar).Value = FormatoFactura + .Add("@Estatus", SqlDbType.Bit).Value = If(Estatus, 1, 0) + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveSucursal", SqlDbType.Int).Value = CveSucursal + .Add("@Calle", SqlDbType.VarChar).Value = Calle + .Add("@NoExt", SqlDbType.VarChar).Value = NoExt + .Add("@NoInt", SqlDbType.VarChar).Value = NoInt + .Add("@Colonia", SqlDbType.VarChar).Value = Colonia + .Add("@Localidad", SqlDbType.VarChar).Value = Localidad + .Add("@Municipio", SqlDbType.VarChar).Value = Municipio + .Add("@Estado", SqlDbType.VarChar).Value = Estado + .Add("@Pais", SqlDbType.VarChar).Value = Pais + .Add("@CP", SqlDbType.VarChar).Value = CP + .Add("@TipoSucursal", SqlDbType.Int).Value = TipoSucursal + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe una Sucursal con el mismo nombre: " & Sucursal & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar los cambios en la Sucursal", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios en la Sucursal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + SqlAdapter.Dispose() + Return Retorno + End Function + + Public Function RemoveSucursal(CveSucursal As Integer) As Boolean + Dim OnError As Boolean = False + SqlAdapter = New SqlDataAdapter("PA_SucursalRemove", SqlConexion) + SqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure + With SqlAdapter.SelectCommand.Parameters + .Add("@CveSucursal", SqlDbType.Int).Value = CveSucursal + End With + Data = New DataTable() + Try + SqlAdapter.Fill(Data) + OnError = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 547;") Then + Alert("La Sucursal no se pudo eliminar por que esta siendo usada por un registro.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al eliminar la Sucursal.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar la Sucursal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + SqlAdapter.Dispose() + Return OnError + 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 diff --git a/Bancos/DepositosCaja.aspx b/Bancos/DepositosCaja.aspx index 445f02eb9..7b5e09dbd 100644 --- a/Bancos/DepositosCaja.aspx +++ b/Bancos/DepositosCaja.aspx @@ -136,7 +136,7 @@ -
+
@@ -144,10 +144,7 @@
- + -