From 61685fa0b0be19a1aed116959228985cec0b8019 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 23 Jun 2021 11:22:17 -0700 Subject: [PATCH] Autorizaciones de limite de credito --- App_Code/ClsPaginas.vb | 50 ++++-- App_Code/ClsSisUsuarios.vb | 6 +- App_Code/ClsVentas.vb | 202 ++++++++++++++++++++++++ Sistemas/UsuarioDetalle.aspx | 7 + Sistemas/UsuarioDetalle.aspx.vb | 9 +- Ventas/CatAutorizacionLimites.aspx | 156 +++++++++++++++++++ Ventas/CatAutorizacionLimites.aspx.vb | 215 ++++++++++++++++++++++++++ Ventas/Ventas.aspx | 81 ++++++++-- Ventas/Ventas.aspx.vb | 133 +++++++++++++++- 9 files changed, 828 insertions(+), 31 deletions(-) create mode 100644 Ventas/CatAutorizacionLimites.aspx create mode 100644 Ventas/CatAutorizacionLimites.aspx.vb diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 06ea7a8d6..162bf1b97 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -1286,7 +1286,8 @@ Public Class ClsPaginas ObjPS.Dispose() End Get End Property - Public Property GlobalDTPSSimplificado(CveEmpresa As Integer, Optional CveClasificacion As Integer = -1, Optional PSCodigo As String = "-1", Optional Estatus As Integer = 1, Optional AplicaParaVenta As Integer = -1, Optional CvePS As Integer = -1) As DataTable + Public Property GlobalDTPSSimplificado(CveEmpresa As Integer, Optional CveClasificacion As Integer = -1, Optional PSCodigo As String = "-1", Optional Estatus As Integer = 1, + Optional AplicaParaVenta As Integer = -1, Optional CvePS As Integer = -1, Optional Codigo As String = "-1") As DataTable Get Dim AppNombre As String = String.Format("GlobalDTPSSimplificado-{0}", CveEmpresa) If CveEmpresa <> -1 Then @@ -1304,6 +1305,8 @@ Public Class ClsPaginas Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveEmpresa) = CveEmpresa)) If CveClasificacion >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveClasificacion) = CveClasificacion)) If PSCodigo <> "-1" Then Cons = Cons.Where((Function(a) Convert.ToString(a!PSCodigo) = PSCodigo)) + Codigo = Codigo.ToUpper().Trim() + If Codigo <> "-1" Then Cons = Cons.Where((Function(a) Convert.ToString(a!Codigo).ToUpper().Trim() = Codigo)) If Estatus >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveEstado) = Estatus)) If AplicaParaVenta >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!AplicaParaVenta) = AplicaParaVenta)) If CvePS >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CvePS) = CvePS)) @@ -4610,6 +4613,7 @@ Public Class ClsPaginas PaginaDict.Add("/GPS/RepGastos.aspx".ToUpper(), 685) PaginaDict.Add("/GPS/RecursoConfiableTracking.aspx".ToUpper(), 692) PaginaDict.Add("/GPS/KimberlyClarkTracking.aspx".ToUpper(), -1) + PaginaDict.Add("/GPS/RepUnidades.aspx".ToUpper(), 780) #End Region 'INVENTARIOS #Region "Inventarios" @@ -4683,6 +4687,7 @@ Public Class ClsPaginas PaginaDict.Add("/Inventarios/EntregasPorRealizar.aspx".ToUpper(), 728) PaginaDict.Add("/Inventarios/CatAlmacenClasificacionSecciones.aspx".ToUpper(), 764) PaginaDict.Add("/Inventarios/ReconstruirCostos.aspx".ToUpper(), 764) + PaginaDict.Add("/Inventarios/RecepcionDevolucion.aspx".ToUpper(), 696) #End Region @@ -5069,6 +5074,7 @@ Public Class ClsPaginas PaginaDict.Add("/Ventas/MetasVendedores.aspx".ToUpper(), 722) PaginaDict.Add("/Ventas/CatMetasVendedores.aspx".ToUpper(), 723) PaginaDict.Add("/Ventas/RepAuxiliarFacturas.aspx".ToUpper(), 567) + PaginaDict.Add("/Ventas/CatAutorizacionLimites.aspx".ToUpper(), 781) #End Region @@ -5943,6 +5949,19 @@ Public Class ClsPaginas Dim TipoDocumentoRef As String = "" Dim AplicaPagare As String = "1" + Dim RFCReceptor As String = "" + + If String.IsNullOrEmpty(Vta.RFCReceptor) Then + RFCReceptor = Vta.Cliente.RFC + If Vta.FacturarSucursal Then + If Vta.ClienteSucursal IsNot Nothing Then + RFCReceptor = Vta.ClienteSucursal.RFC + End If + End If + Else + RFCReceptor = Vta.RFCReceptor + End If + Dim RutaCBB As String = String.Format("{0}CBB\{1}.jpg", Ruta, Vta.SerieFolio) Dim ImagenCBB As New System.IO.FileInfo(RutaCBB) Dim ImgCBB As String '= String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, Vta.SerieFolio) @@ -6072,7 +6091,7 @@ Public Class ClsPaginas 'Si no tiene CBB, SE GENERA If Not ImagenCBB.Exists Then Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - CBB.GenerarCBB(UsuarioActual.Empresa.RFC, Vta.Cliente.RFC, Vta.Total.ToString.ToDecimal, Vta.FolioFiscal, RutaCBB) + CBB.GenerarCBB(UsuarioActual.Empresa.RFC, RFCReceptor, Vta.Total.ToString.ToDecimal, Vta.FolioFiscal, RutaCBB) End If ImgCBB = String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, Vta.SerieFolio) @@ -6087,7 +6106,7 @@ Public Class ClsPaginas 'CLIENTE params.Add(New CrystalParametro("ClienteCodigo", Vta.Cliente.Codigo)) - params.Add(New CrystalParametro("ClienteNombre", If(Vta.ClienteSucursal.ImprimeNombreSucursal = "True", If(Vta.CveClienteSucursal > 0, Vta.ClienteSucursal.Sucursal, Vta.Cliente.Nombre), If(Vta.AtencionA <> "" AndAlso Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.RFC = "XAXX010101000", $"{Vta.Cliente.Nombre}({Vta.AtencionA})", Vta.Cliente.Nombre)))) + params.Add(New CrystalParametro("ClienteNombre", If(Vta.ClienteSucursal.ImprimeNombreSucursal = "True", If(Vta.CveClienteSucursal > 0, Vta.ClienteSucursal.Sucursal, Vta.Cliente.Nombre), If(Vta.AtencionA <> "" AndAlso Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso RFCReceptor = "XAXX010101000", $"{Vta.Cliente.Nombre}({Vta.AtencionA})", Vta.Cliente.Nombre)))) params.Add(New CrystalParametro("ClienteDireccion", ClienteDireccion)) params.Add(New CrystalParametro("ClienteLugar", ClienteLugar)) @@ -6119,7 +6138,7 @@ Public Class ClsPaginas params.Add(New CrystalParametro("SelloSAT", Vta.SelloSAT)) params.Add(New CrystalParametro("QR", ImgCBB)) - params.Add(New CrystalParametro("ClienteRFC", Vta.Cliente.RFC)) + params.Add(New CrystalParametro("ClienteRFC", RFCReceptor)) params.Add(New CrystalParametro("FormaPago", Vta.FormaPagoText)) params.Add(New CrystalParametro("Moneda", Vta.Moneda)) params.Add(New CrystalParametro("TipoCambio", Vta.TipoCambio.ToString)) @@ -6152,7 +6171,7 @@ Public Class ClsPaginas params.Add(New CrystalParametro("ClienteTelefono", Vta.ClienteSucursal.TelefonoSucursal)) Else params.Add(New CrystalParametro("ClienteContactoMail", Vta.Cliente.MailCotizacion)) - params.Add(New CrystalParametro("ClienteTelefono", If(Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.RFC = "XAXX010101000", Vta.TelefonoGenerico, Vta.Cliente.Telefono))) + params.Add(New CrystalParametro("ClienteTelefono", If(Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.Telefono.Length > 6, Vta.Cliente.Telefono, Vta.TelefonoGenerico))) End If If UsuarioActual.CveEmpresa.Contiene(17) Then @@ -6454,7 +6473,18 @@ Public Class ClsPaginas Dim NombreArchivoDescarga As String = "" Dim TipoDocumento As String = "" Dim TipoDocumentoRef As String = "" + Dim RFCReceptor As String = "" + If String.IsNullOrEmpty(Vta.RFCReceptor) Then + RFCReceptor = Vta.Cliente.RFC + If Vta.FacturarSucursal Then + If Vta.ClienteSucursal IsNot Nothing Then + RFCReceptor = Vta.ClienteSucursal.RFC + End If + End If + Else + RFCReceptor = Vta.RFCReceptor + End If Dim RutaCBB As String = String.Format("{0}CBB\{1}.jpg", Ruta, Vta.SerieFolio) Dim ImagenCBB As New System.IO.FileInfo(RutaCBB) @@ -6609,7 +6639,7 @@ Public Class ClsPaginas 'Si no tiene CBB, SE GENERA If Not ImagenCBB.Exists AndAlso Vta.CveCliente.ToEntero > 0 Then Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - CBB.GenerarCBB(UsuarioActual.Empresa.RFC, Vta.Cliente.RFC, Vta.Total.ToString.ToDecimal, Vta.FolioFiscal, RutaCBB) + CBB.GenerarCBB(UsuarioActual.Empresa.RFC, RFCReceptor, Vta.Total.ToString.ToDecimal, Vta.FolioFiscal, RutaCBB) End If ImgCBB = String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, Vta.SerieFolio) @@ -6627,17 +6657,17 @@ Public Class ClsPaginas 'CLIENTE If Vta.CveCliente.ToEntero > 0 Or Vta.CveEmpresaCRM.ToEntero > 0 Then params.Add(New ReportParameter("ClienteCodigo", Vta.Cliente.Codigo)) - params.Add(New ReportParameter("ClienteNombre", If(Vta.ClienteSucursal.ImprimeNombreSucursal = "True", If(Vta.CveClienteSucursal > 0, Vta.ClienteSucursal.Sucursal, Vta.Cliente.Nombre), If(Vta.AtencionA <> "" AndAlso Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.RFC = "XAXX010101000", $"{Vta.Cliente.Nombre}({Vta.AtencionA})", Vta.Cliente.Nombre)))) + params.Add(New ReportParameter("ClienteNombre", If(Vta.ClienteSucursal.ImprimeNombreSucursal = "True", If(Vta.CveClienteSucursal > 0, Vta.ClienteSucursal.Sucursal, Vta.Cliente.Nombre), If(Vta.AtencionA <> "" AndAlso Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso RFCReceptor = "XAXX010101000", $"{Vta.Cliente.Nombre}({Vta.AtencionA})", Vta.Cliente.Nombre)))) params.Add(New ReportParameter("ClienteDireccion", ClienteDireccion)) params.Add(New ReportParameter("ClienteLugar", ClienteLugar)) - params.Add(New ReportParameter("ClienteRFC", Vta.Cliente.RFC)) + params.Add(New ReportParameter("ClienteRFC", RFCReceptor)) End If If Vta.CveEmpresaCRM.ToEntero > 0 Then params.Add(New ReportParameter("ClienteCodigo", Vta.Cliente.Codigo)) params.Add(New ReportParameter("ClienteNombre", Vta.Cliente.Nombre)) params.Add(New ReportParameter("ClienteDireccion", ClienteDireccion)) params.Add(New ReportParameter("ClienteLugar", ClienteLugar)) - params.Add(New ReportParameter("ClienteRFC", Vta.Cliente.RFC)) + params.Add(New ReportParameter("ClienteRFC", RFCReceptor)) End If 'TOTALES @@ -6720,7 +6750,7 @@ Public Class ClsPaginas params.Add(New ReportParameter("ClienteTelefono", Vta.ClienteSucursal.TelefonoSucursal)) ElseIf Vta.CveCliente.ToEntero > 0 Then params.Add(New ReportParameter("ClienteContactoMail", Vta.Cliente.MailCotizacion)) - params.Add(New ReportParameter("ClienteTelefono", If(Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.Telefono.Length > 6, Vta.TelefonoGenerico, Vta.Cliente.Telefono))) + params.Add(New ReportParameter("ClienteTelefono", If(Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.Telefono.Length > 6, Vta.Cliente.Telefono, Vta.TelefonoGenerico))) End If If UsuarioActual.CveEmpresa.Contiene(17) Then diff --git a/App_Code/ClsSisUsuarios.vb b/App_Code/ClsSisUsuarios.vb index ed02a6324..09896ce69 100644 --- a/App_Code/ClsSisUsuarios.vb +++ b/App_Code/ClsSisUsuarios.vb @@ -821,7 +821,7 @@ Public Class ClsSisUsuarios Public Function AddUsuario(Usuario As String, Contraseña As String, Nombre As String, CveRol As Integer, Correo As String, CvePersonal As Integer, CveVendedor As Integer, CambiarContraseña As Boolean, CveUsuarioIng As Integer, CveEmpresa As Integer, CveSubProyecto As Integer, Optional Rol As String = "-1", Optional CveAlmacenAsignado As Integer = -1, Optional AsignarSubProyecto As Boolean = False, Optional AsignarOC As Boolean = False, - Optional CvePlataforma As Integer = -1, Optional CveClientePlataforma As Integer = -1, Optional CveProveedorPlataforma As Integer = -1, Optional DescuentoAutorizado As Double = 0, Optional CodigoAcceso As String = "-1") As Integer + Optional CvePlataforma As Integer = -1, Optional CveClientePlataforma As Integer = -1, Optional CveProveedorPlataforma As Integer = -1, Optional DescuentoAutorizado As Double = 0, Optional CodigoAcceso As String = "-1", Optional LimiteCreditoAutorizado As Decimal = 0) As Integer Dim Retorno = -1 DataAdapter("PA_Sis_UsuarioAdd") With SqlAdapter.SelectCommand.Parameters @@ -842,6 +842,7 @@ Public Class ClsSisUsuarios .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedorPlataforma .Add("@DescuentoAutorizado", SqlDbType.Float).Value = DescuentoAutorizado .Add("@CodigoAcceso", SqlDbType.VarChar).Value = CodigoAcceso + .Add("@LimiteCreditoAutorizado", SqlDbType.Money).Value = LimiteCreditoAutorizado .Add("@CveUsuario", SqlDbType.Int).Direction = ParameterDirection.Output End With @@ -940,7 +941,7 @@ Public Class ClsSisUsuarios End Function Public Function UpdateUsuario(Usuario As String, Nombre As String, CveRol As Integer, Correo As String, CvePersonal As Integer, CveVendedor As Integer, CambiarContraseña As Boolean, Activo As Boolean, CveEmpresa As Integer, CveUsuario As Integer, CveAlmacenAsignado As Integer, CveSubProyecto As Integer, Optional CveUsuarioModifico As Integer = -1, Optional AsignarSubProyecto As Boolean = False, Optional AsignarOC As Boolean = False, - Optional DescuentoAutorizado As Double = 0, Optional CodigoAcceso As String = "-1") As Boolean + Optional DescuentoAutorizado As Double = 0, Optional CodigoAcceso As String = "-1", Optional LimiteCreditoAutorizado As Decimal = 0) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Sis_UsuarioUpdate") @@ -962,6 +963,7 @@ Public Class ClsSisUsuarios .Add("@AsignarOC", SqlDbType.Bit).Value = AsignarOC .Add("@DescuentoAutorizado", SqlDbType.Float).Value = DescuentoAutorizado .Add("@CodigoAcceso", SqlDbType.VarChar).Value = CodigoAcceso + .Add("@LimiteCreditoAutorizado", SqlDbType.Money).Value = LimiteCreditoAutorizado End With Try diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index f4504bbb3..d73f18d86 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -4388,6 +4388,133 @@ Public Class ClsVentas End Function #End Region +#Region " AUTORIZACION LIMITES " + + Public Function AutorizacionLimitesGet(CveCliente As Integer, CveCveVendedor As Integer, CveEstatus As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_AutorizacionLimitesGet", CommandType.StoredProcedure) + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveCveVendedor", SqlDbType.Int).Value = CveCveVendedor + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + + OnError("Ocurrió un error al obtener las Autorizaciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + + End Try + + Return Retorno + End Function + + Public Function AutorizacionLimitesRemove(CveAutorizacion As Integer, CveCliente As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_AutorizacionLimitesRemove", CommandType.StoredProcedure) + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAutorizacion", SqlDbType.Int).Value = CveAutorizacion + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + + OnError("Ocurrió un error al eliminar la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + + End Try + + Return Retorno + End Function + + Public Function AutorizacionLimitesAdd(CveCliente As Integer, CveVendedor As Integer, Importe As Decimal, CveUsuario As Integer, CveEstatus As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_AutorizacionLimitesAdd", CommandType.StoredProcedure) + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@Importe", SqlDbType.Money).Value = Importe + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + + OnError("Ocurrió un error al agregar la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + + End Try + + Return Retorno + End Function + + Public Function AutorizacionLimitesEstatusUpdate(CveAutorizacion As Integer, CveCliente As Integer, CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_AutorizacionlimitesEstatusUpdate", CommandType.StoredProcedure) + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveAutorizacion", SqlDbType.Int).Value = CveAutorizacion + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + + OnError("Ocurrió un error al actualizar la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + + End Try + + Return Retorno + End Function + + Public Function AutorizacionLimitesUpdate(CveAutorizacion As Integer, CveCliente As Integer, CveVendedor As Integer, Importe As Decimal, CveEstatus As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_AutorizacionLimitesUpdate", CommandType.StoredProcedure) + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveAutorizacion", SqlDbType.Int).Value = CveAutorizacion + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@Importe", SqlDbType.Money).Value = Importe + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + + OnError("Ocurrió un error al actualizar el Estatus de la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + + End Try + + Return Retorno + End Function +#End Region + #Region "CANCELACION REMISION" Public Function UpdateCancelaRemision(CveVenta As Integer, SeCancelaRemision As Boolean) As Boolean @@ -4963,6 +5090,81 @@ Public Class ClsVentas End Function #End Region + + Public Function AddAutorizacionLimite(CveEmpresa As Integer, CveCliente As Integer, CveVendedor As Integer, Importe As Decimal, CveEstatus As Integer, CveUsuario As Integer, TipoAutorizacion As Integer, TipoDocumento As String) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_AutorizacionLimitesAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@Importe", SqlDbType.Money).Value = Importe + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@TipoAutorizacion", SqlDbType.Int).Value = TipoAutorizacion + .Add("@TipoDocumento", SqlDbType.VarChar).Value = TipoDocumento + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los limites.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function GetAutorizacionLimite(CveEmpresa As Integer, CveCliente As Integer, CveVendedor As Integer, Optional CveEstatus As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_AutorizacionLimitesGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los limites.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + + Public Function UpdateAutorizacionLimite(CveAutorizacion As Integer, CveCliente As Integer, CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_AutorizacionlimitesEstatusUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAutorizacion", SqlDbType.Int).Value = CveAutorizacion + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar los limites.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function RemoveAutorizacionLimite(CveAutorizacion As Integer, CveCliente As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_AutorizacionLimitesRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAutorizacion", SqlDbType.Int).Value = CveAutorizacion + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar los limites.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + #Region "IDisposable Support" diff --git a/Sistemas/UsuarioDetalle.aspx b/Sistemas/UsuarioDetalle.aspx index 512355535..182c8df96 100644 --- a/Sistemas/UsuarioDetalle.aspx +++ b/Sistemas/UsuarioDetalle.aspx @@ -307,6 +307,13 @@ + + Límite Cédito Autorizado: + + + + + diff --git a/Sistemas/UsuarioDetalle.aspx.vb b/Sistemas/UsuarioDetalle.aspx.vb index e9948bffc..72683623b 100644 --- a/Sistemas/UsuarioDetalle.aspx.vb +++ b/Sistemas/UsuarioDetalle.aspx.vb @@ -447,6 +447,7 @@ Partial Class Sistemas_UsuarioDetalle If UsuarioActual.Empresa.Funcionalidad(531).ToString = "1" Then TrDescuentoAutorizado.Visible = True + TrLimiteAutorizacion.Visible = True End If If UsuarioActual.Empresa.Funcionalidad(599) = "1" Then @@ -586,8 +587,8 @@ Partial Class Sistemas_UsuarioDetalle LblFechaCaptura.Text = ObjUsuario.Fecha.ToShortDateString LblUsuarioCapturo.Text = ObjUsuario.UsuarioCreo - TxtDescuentoAutorizado.Text = ObjUsuario.DescuentoAutorizado.FormatoNumero - + TxtDescuentoAutorizado.Text = ObjUsuario.DescuentoAutorizado.FormatoNumero + TxtLimiteAutorizado.Text = ObjUsuario.DtResultados.Rows(0)("LimiteCreditoAutorizado").ToString() Else Alert("El Usuario Solicitado no existe, Revise su búsqueda.", TipoMensaje.MsgAdvertencia) BtnGuardar.Enabled = False @@ -831,7 +832,7 @@ Partial Class Sistemas_UsuarioDetalle 'REGISTRA O ACTUALIZA LOS DATOS GENERALES DEL USUARIO If CveUsuario = -1 Then - CveUsuario = ObjUsuarios.AddUsuario(TxtUsuario.Text.Trim, Encripta(ContraseñaPredeterminada), TxtNombre.Text.Trim, DdlRol.SelectedValue.ToEntero, TxtCorreo.Text.Trim, DdlPersonal.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, ChkCambiarContraseña.Checked, UsuarioActual.CveUsuario, DdlEmpresa.SelectedValue.ToEntero, DdlSubProyectos.SelectedValue.ToEntero, CveAlmacenAsignado:=DdlAlmacenGeneral.SelectedValue.ToEntero, AsignarSubProyecto:=ChkAsignarSubProyecto.Checked, AsignarOC:=ChkAsignarOC.Checked, DescuentoAutorizado:=TxtDescuentoAutorizado.Text.ToDouble, CodigoAcceso:=CodigoAcceso) + CveUsuario = ObjUsuarios.AddUsuario(TxtUsuario.Text.Trim, Encripta(ContraseñaPredeterminada), TxtNombre.Text.Trim, DdlRol.SelectedValue.ToEntero, TxtCorreo.Text.Trim, DdlPersonal.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, ChkCambiarContraseña.Checked, UsuarioActual.CveUsuario, DdlEmpresa.SelectedValue.ToEntero, DdlSubProyectos.SelectedValue.ToEntero, CveAlmacenAsignado:=DdlAlmacenGeneral.SelectedValue.ToEntero, AsignarSubProyecto:=ChkAsignarSubProyecto.Checked, AsignarOC:=ChkAsignarOC.Checked, DescuentoAutorizado:=TxtDescuentoAutorizado.Text.ToDouble, CodigoAcceso:=CodigoAcceso, LimiteCreditoAutorizado:=TxtLimiteAutorizado.Text.ToDecimal()) EsNuevoUsuario = True If CveUsuario = -1 Then TieneError = True @@ -843,7 +844,7 @@ Partial Class Sistemas_UsuarioDetalle End If Next Else - If Not ObjUsuarios.UpdateUsuario(TxtUsuario.Text.Trim, TxtNombre.Text.Trim, DdlRol.SelectedValue.ToEntero, TxtCorreo.Text.Trim, DdlPersonal.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, ChkCambiarContraseña.Checked, ChkEstatus.Checked, DdlEmpresa.SelectedValue.ToEntero, CveUsuario, DdlAlmacenGeneral.SelectedValue.ToEntero, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveUsuario, AsignarSubProyecto:=ChkAsignarSubProyecto.Checked, AsignarOC:=ChkAsignarOC.Checked, DescuentoAutorizado:=TxtDescuentoAutorizado.Text.ToDouble, CodigoAcceso:=CodigoAcceso) Then + If Not ObjUsuarios.UpdateUsuario(TxtUsuario.Text.Trim, TxtNombre.Text.Trim, DdlRol.SelectedValue.ToEntero, TxtCorreo.Text.Trim, DdlPersonal.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, ChkCambiarContraseña.Checked, ChkEstatus.Checked, DdlEmpresa.SelectedValue.ToEntero, CveUsuario, DdlAlmacenGeneral.SelectedValue.ToEntero, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveUsuario, AsignarSubProyecto:=ChkAsignarSubProyecto.Checked, AsignarOC:=ChkAsignarOC.Checked, DescuentoAutorizado:=TxtDescuentoAutorizado.Text.ToDouble, CodigoAcceso:=CodigoAcceso, LimiteCreditoAutorizado:=TxtLimiteAutorizado.Text.ToDecimal()) Then TieneError = True End If diff --git a/Ventas/CatAutorizacionLimites.aspx b/Ventas/CatAutorizacionLimites.aspx new file mode 100644 index 000000000..b71f4c61e --- /dev/null +++ b/Ventas/CatAutorizacionLimites.aspx @@ -0,0 +1,156 @@ +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="CatAutorizacionLimites.aspx.vb" Inherits="Ventas_CatAutorizacionLimites" %> + + + + + + + + Catálogo de autorizaciones de límite de crédito + + + + + + +
  • + Agregar autorización
  • +
    +
    +
    + + + + + +
    +
    +
    + +
    +
    +
      +
    • Estatus: + + + + + + + + +
    • +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + diff --git a/Ventas/CatAutorizacionLimites.aspx.vb b/Ventas/CatAutorizacionLimites.aspx.vb new file mode 100644 index 000000000..0b450106d --- /dev/null +++ b/Ventas/CatAutorizacionLimites.aspx.vb @@ -0,0 +1,215 @@ + +Imports Extensiones + +Partial Class Ventas_CatAutorizacionLimites + Inherits ClsPaginas + +#Region "PROPIEDADES" + Private Property CveAutorizacion() As Integer Get + Return If(IsNothing(ViewState("CveAutorizacion")), -1, CInt(ViewState("CveAutorizacion"))) + End Get Set + ViewState("CveAutorizacion") = Value End Set End Property + Private Property Modalidad() As String Get + Return If(IsNothing(ViewState("Modalidad")), "", (ViewState("Modalidad").ToString)) + End Get Set + ViewState("Modalidad") = Value End Set End Property +#End Region + + Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load + If Not IsPostBack Then + CargaCombos() + CargaDatos() + End If + End Sub + +#Region "CARGAS" + Private Sub CargaCombos() + Dim EsWS = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) + If EsWS Then + DdlCliente.setEsWebService(True) + Else + DdlCliente.setEsWebService(False) + DdlCliente.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) + DdlCliente.DataBind() + DdlCliente.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + + DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa) + DdlVendedor.DataBind() + + UpModal.Update() + End Sub + Private Sub CargaDatos() + Dim ObjGral As New ClsVentas + If ObjGral.GetAutorizacionLimite(UsuarioActual.CveEmpresa, -1, -1, CveEstatus:=DdlEstatus.SelectedValue.ToEntero()) Then + GvDatos.DataSource = ObjGral.DtResultados + End If + ObjGral.Dispose() + GvDatos.DataBind() + UpDatos.Update() + End Sub + + Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) + CargaDatos() + End Sub + +#End Region + +#Region "BOTONES" + Protected Sub LnkEliminar_Click(sender As Object, e As EventArgs) + Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + + Dim CveAutorizacion = gvRow.DataKey("CveAutorizacion").ToEntero() + Dim CveCliente = gvRow.DataKey("CveCliente").ToEntero() + + Dim ObjGral As New ClsVentas + If ObjGral.RemoveAutorizacionLimite(CveAutorizacion, CveCliente) Then + Alert("La autorización se elimino correctamente.", TipoMensaje.MsgInformacion) + End If + ObjGral.Dispose() + + CargaDatos() + End Sub + + Protected Sub LnkAgregar_Click(sender As Object, e As EventArgs) + LimpiaModal() + Modalidad = "A" + BtnGuardar.Text = "Agregar" + ltlMotititulo.Text = "Agregar autorización" UpModal.Update() + RegistraScript("$('#DModal').modal()") End Sub + Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) + If DdlTipoDocto.SelectedValue = "Ing" AndAlso DdlTipoAutorizacion.SelectedValue.ToEntero() <= 0 Then + Alert("Debe seleccionar un tipo de autorización", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim CveEstatus As Integer = 1 + Dim TipoDocto As String = DdlTipoDocto.SelectedValue + Dim CveTipoAutorizacion As Integer = -1 + + Select Case TipoDocto + Case "Ing" + CveTipoAutorizacion = DdlTipoAutorizacion.SelectedValue.ToEntero() + Case "Egs" + CveTipoAutorizacion = -1 + End Select + + Dim ObjPS As New ClsVentas + If ObjPS.AddAutorizacionLimite(UsuarioActual.CveEmpresa, DdlCliente.SelectedValue.ToEntero(), DdlVendedor.SelectedValue.ToEntero(), TxtPrecio.Text.ToDecimal(), CveEstatus, UsuarioActual.CveUsuario, CveAutorizacion, TipoDocto) Then + RegistraScript("$('#DModal').modal('hide')") + Alert("La autorización se agregó correctamente.", TipoMensaje.MsgInformacion) + End If + ObjPS.Dispose() + + CargaDatos() + End Sub + +#End Region + +#Region "LIMPIAR" + Protected Sub LimpiaModal() Me.CveAutorizacion = -1 TxtPrecio.Text = "" + + DdlCliente.SelectedValue = "-1" DdlVendedor.SelectedValueExist("-1") End Sub + +#End Region + +#Region "GRIDVIEW" + Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CveEstatus") = "0" Then + e.Row.FCLabel("LblEstatus").CssClass = "badge badge-secondary" + e.Row.FCLinkButton("LnkAutorizar").Visible = True + e.Row.FCLinkButton("LnkRechazar").Visible = True + ElseIf e.Row.DBCampo("CveEstatus") = "1" Then + e.Row.FCLabel("LblEstatus").CssClass = "badge badge-success" + e.Row.FCLinkButton("LnkAutorizar").Visible = False + e.Row.FCLinkButton("LnkRechazar").Visible = True + ElseIf e.Row.DBCampo("CveEstatus") = "2" Then + e.Row.FCLabel("LblEstatus").CssClass = "badge badge-primary" + e.Row.FCLinkButton("LnkAutorizar").Visible = False + e.Row.FCLinkButton("LnkRechazar").Visible = False + ElseIf e.Row.DBCampo("CveEstatus") = "3" Then + e.Row.FCLabel("LblEstatus").CssClass = "badge badge-danger" + e.Row.FCLinkButton("LnkAutorizar").Visible = False + e.Row.FCLinkButton("LnkRechazar").Visible = False + End If + 'If e.Row.DBCampo("Estatus") = "True" Then + ' e.Row.Cells(1).ForeColor = Drawing.Color.Green + ' e.Row.Cells(1).Font.Bold = True + ' e.Row.Cells(1).Text = "Activo" + 'Else + ' e.Row.Cells(1).Text = "Inactivo" + ' e.Row.Cells(1).ForeColor = Drawing.Color.Red + ' e.Row.Cells(1).Font.Bold = True + 'End If + End If + End Sub + +#End Region + + + + Protected Sub LnkAutorizar_Click(sender As Object, e As EventArgs) + Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + + Dim CveAutorizacion = gvRow.DataKey("CveAutorizacion").ToEntero() + Dim CveCliente = gvRow.DataKey("CveCliente").ToEntero() + Dim CveVendedor = gvRow.DataKey("CveVendedor").ToEntero() + Dim Importe = gvRow.DataKey("Importe").ToEntero() + Dim CveEstatusAutorizacion As Integer = 1 + + Dim ObjVentas As New ClsVentas + If ObjVentas.AutorizacionLimitesUpdate(CveAutorizacion, CveCliente, CveVendedor, Importe, CveEstatusAutorizacion) Then + Alert("El límite de crédito fue autorizado.") + End If + ObjVentas.Dispose() + + CargaDatos() + End Sub + + Protected Sub LnkRechazar_Click(sender As Object, e As EventArgs) + Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + + Dim CveAutorizacion = gvRow.DataKey("CveAutorizacion").ToEntero() + Dim CveCliente = gvRow.DataKey("CveCliente").ToEntero() + Dim CveVendedor = gvRow.DataKey("CveVendedor").ToEntero() + Dim Importe = gvRow.DataKey("Importe").ToEntero() + Dim CveEstatusAutorizacion As Integer = 3 + + Dim ObjVentas As New ClsVentas + If ObjVentas.AutorizacionLimitesUpdate(CveAutorizacion, CveCliente, CveVendedor, Importe, CveEstatusAutorizacion) Then + Alert("El límite de crédito fue rechazado.") + End If + ObjVentas.Dispose() + + CargaDatos() + End Sub + Protected Sub DdlTipoAutorizacion_SelectedIndexChanged(sender As Object, e As EventArgs) + DivImporte.Visible = DdlTipoAutorizacion.SelectedValue.ToEntero() = 1 + UpModal.Update() + End Sub + Protected Sub DdlCliente_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim CveCliente As Integer = DdlCliente.SelectedValue.ToEntero() + If CveCliente > 0 Then + Using ObjClientes As New ClsClientes + If ObjClientes.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) AndAlso ObjClientes.DtResultados.Rows.Count > 0 Then + DdlVendedor.SelectedValueExist(ObjClientes.DtResultados.Rows(0)("CveVendedor")) + End If + End Using + End If + + UpModal.Update() + End Sub + Protected Sub DdlTipoDocto_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim TipoDocto As String = DdlTipoDocto.SelectedValue.ToString() + Select Case TipoDocto + Case "Ing" + DivAutorizacion.Visible = True + DivImporte.Visible = True + Case "Egs" + DivAutorizacion.Visible = False + DivImporte.Visible = False + End Select + UpModal.Update() + End Sub +End Class diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 39418049f..e432c9bc9 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -367,6 +367,9 @@
  • Relacionar Facturas
  • +
  • + Solicitar autorización de crédito +
  • @@ -3657,7 +3660,7 @@
    -
    +
    @@ -3765,23 +3768,23 @@ - +
    - +
    - - - + + +
    @@ -6239,7 +6242,7 @@
    -