Autorizaciones de limite de credito

This commit is contained in:
2021-06-23 11:22:17 -07:00
parent 324744cd95
commit 61685fa0b0
9 changed files with 828 additions and 31 deletions

View File

@@ -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()