Commit inicial Ventas Productivo
This commit is contained in:
249
CxC/GestionCobranza.aspx.vb
Normal file
249
CxC/GestionCobranza.aspx.vb
Normal file
@@ -0,0 +1,249 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
|
||||
Imports System.Data
|
||||
Imports Extensiones
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
Partial Class Ventas_GestionCobranza
|
||||
Inherits ClsPaginas
|
||||
|
||||
#Region "P R O P I E D A D E S "
|
||||
Private Property DtDatos As DataTable
|
||||
Get
|
||||
Return DirectCast(ViewState("DtDatos"), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DtDatos") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property TipoCambio As Integer
|
||||
Get
|
||||
Return ViewState("TipoCambio").ToString.ToEntero
|
||||
End Get
|
||||
|
||||
Set(value As Integer)
|
||||
ViewState("TipoCambio") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property TCEspecifico As Decimal
|
||||
Get
|
||||
Return ViewState("TCEspecifico").ToString.ToDecimal
|
||||
End Get
|
||||
|
||||
Set(value As Decimal)
|
||||
ViewState("TCEspecifico") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
#End Region
|
||||
Private Sub Ventas_GestionCobranza_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
If Not IsPostBack Then
|
||||
TipoCambio = 1
|
||||
TCEspecifico = -1
|
||||
CargaFiltrosrCobranza()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#Region "C A R G A C O M B O S "
|
||||
Private Sub CargaFiltrosrCobranza()
|
||||
Dim ObjVentas As New ClsVentas
|
||||
|
||||
DdlUsuarioCobranza.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa)
|
||||
DdlUsuarioCobranza.DataBind()
|
||||
DdlUsuarioCobranza.Items.Insert(0, New ListItem("Todos", "-1"))
|
||||
|
||||
DdlResponsableCobranza.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa)
|
||||
DdlResponsableCobranza.DataBind()
|
||||
DdlResponsableCobranza.Items.Insert(0, New ListItem("Todos", "-1"))
|
||||
|
||||
DdlCobranzaEstatus.DataSource = GlobalDTCobranzaEstatus(UsuarioActual.CveEmpresa)
|
||||
DdlCobranzaEstatus.DataBind()
|
||||
DdlCobranzaEstatus.Items.Insert(0, New ListItem("Todos", "-1"))
|
||||
|
||||
DdlCobranzaEstatusEdit.DataSource = GlobalDTCobranzaEstatus(UsuarioActual.CveEmpresa)
|
||||
DdlCobranzaEstatusEdit.DataBind()
|
||||
|
||||
If ObjVentas.GetCobranzaTurnoEstatus(-1, UsuarioActual.CveEmpresa) Then
|
||||
DdlTurnoCobranza.DataSource = ObjVentas.DtResultados
|
||||
DdlTurnoCobranza.DataBind()
|
||||
|
||||
DdlTurnos.DataSource = ObjVentas.DtResultados
|
||||
DdlTurnos.DataBind()
|
||||
DdlTurnos.Items.Insert(0, New ListItem("Todos", "-1"))
|
||||
End If
|
||||
|
||||
|
||||
ObjVentas.Dispose()
|
||||
End Sub
|
||||
Private Sub CargaDatos()
|
||||
Dim ObjVentas As New ClsVentas
|
||||
Dim FechaI, FechaF As String
|
||||
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1")
|
||||
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1")
|
||||
|
||||
If TipoCambio = 3 And TxtEspecifico.Text <> "" Then TCEspecifico = TxtEspecifico.Text.ToDecimal Else TCEspecifico = -1
|
||||
|
||||
If ObjVentas.GetGestionCobranza(DdlCobranzaEstatus.SelectedValue.ToEntero, DdlUsuarioCobranza.SelectedValue.ToEntero, DdlResponsableCobranza.SelectedValue.ToEntero, DdlTurnos.SelectedValue.ToEntero, DdlTipoPago.SelectedValue, FechaI, FechaF, UsuarioActual.CveEmpresa, TipoCambio, TCEspecifico) Then
|
||||
DtDatos = ObjVentas.DtResultados
|
||||
GvDatos.DataSource = ObjVentas.DtResultados
|
||||
GvDatos.DataBind()
|
||||
End If
|
||||
|
||||
ObjVentas.Dispose()
|
||||
UpDatos.Update()
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "BTN"
|
||||
Private Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
|
||||
CargaDatos()
|
||||
End Sub
|
||||
Private Sub BtnActualizarDatosDeCobranza_Click(sender As Object, e As EventArgs) Handles BtnActualizarDatosDeCobranza.Click
|
||||
Dim ObjVentas As New ClsVentas
|
||||
Dim time As DateTime
|
||||
Dim TieneError = False
|
||||
time = DateTime.Parse(String.Format("{0} {1}:{2} {3}", TxtFechaCobranza.Text, TimeSelector.Hour, TimeSelector.Minute, TimeSelector.AmPm))
|
||||
|
||||
ObjVentas.IniciaTransacSQL()
|
||||
|
||||
'Actualizo datos de cobranza
|
||||
If Not ObjVentas.UpdateVentaCobranza(HdnID.Value.ToEntero, DdlCobranzaEstatusEdit.SelectedValue.ToEntero, DdlTurnoCobranza.SelectedValue.ToEntero, time, TxtObservacionCobranza.Text) Then
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
'AGREGO A VISITAS DE COBRANZA
|
||||
If Not TieneError Then
|
||||
If Not ObjVentas.AddVisitaCobranza(HdnID.Value.ToEntero, HdnCveUsuarioCobranza.Value.ToEntero, TxtFechaCobranza.Text.ToDate, TxtObservacionCobranza.Text) Then
|
||||
TieneError = True
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not TieneError Then
|
||||
ObjVentas.Commit()
|
||||
Alert("Se ha actualizado los datos de cobranza", TipoMensaje.MsgInformacion)
|
||||
Else
|
||||
ObjVentas.RollBack()
|
||||
Alert("Ha ocurrido un error al actualizar los datos de cobranza", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
ObjVentas.Dispose()
|
||||
CargaDatos()
|
||||
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivPopUpCobranza"))
|
||||
End Sub
|
||||
Public Sub Edit_Click(sender As Object, e As EventArgs)
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
TxtFechaCobranza.Text = GvRow.DataKey("FechaCobranza")
|
||||
DdlCobranzaEstatusEdit.SelectedValueExist(GvRow.DataKey("CveCobranzaEstatus"))
|
||||
DdlTurnoCobranza.SelectedValueExist(GvRow.DataKey("CveCobranzaEstatusTurno"))
|
||||
TxtObservacionCobranza.Text = GvRow.DataKey("CobranzaObservacion")
|
||||
HdnID.Value = GvRow.DataKey("CveVenta")
|
||||
HdnCveUsuarioCobranza.Value = GvRow.DataKey("CveUsuarioCobranza")
|
||||
UpAddVisitaCobranza.Update()
|
||||
RegistraScript(String.Format("$('#{0}').modal();", "DivPopUpCobranza"))
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "GV"
|
||||
Private Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
|
||||
If e.Row.DBCampo("NIVEL").ToEntero = 1 Then
|
||||
e.Row.CssClass = "Totales"
|
||||
e.Row.Cells(0).Text = e.Row.DBCampo("Moneda").ToString
|
||||
e.Row.FCLinkButton("imgE").Visible = False
|
||||
e.Row.FCImageButton("ImgBtnAbonar").Visible = False
|
||||
End If
|
||||
|
||||
If e.Row.DBCampo("NIVEL").ToEntero = 2 Then
|
||||
e.Row.Cells(0).Text = e.Row.DBCampo("CobranzaEstatusTurno")
|
||||
e.Row.CssClass = "SubTotales2"
|
||||
e.Row.FCLinkButton("imgE").Visible = False
|
||||
e.Row.FCImageButton("ImgBtnAbonar").Visible = False
|
||||
End If
|
||||
|
||||
If e.Row.DBCampo("NIVEL").ToEntero = 3 Then
|
||||
e.Row.CssClass = "SubTotales"
|
||||
e.Row.Attributes.Add("style", "background: #CCCCCC !important")
|
||||
e.Row.FCImageButton("ImgBtnAbonar").Visible = False
|
||||
e.Row.FCLinkButton("imgE").Visible = False
|
||||
e.Row.FCLabel("LtNombreCliente").Text = String.Format("<a class=""Texto"" target=""_blank"" href=""/Ventas/Clientes.aspx?CveCliente={0}&Opt=3"" > {1}</a>", e.Row.DBCampo("CveCliente"), e.Row.DBCampo("NombreCliente"))
|
||||
End If
|
||||
|
||||
If e.Row.DBCampo("NIVEL").ToEntero = 4 Then
|
||||
e.Row.FCLabel("LtSerieFolio").Text = String.Format("<a class=""Texto"" target=""_blank"" href=""/Ventas/Ventas.aspx?CveVenta={0}"">{1}</a>", e.Row.DBCampo("CveVenta"), e.Row.DBCampo("SerieFolio"))
|
||||
e.Row.FCImageButton("ImgBtnAbonar").OnClientClick = String.Format("AbrirVentana('/Bancos/PopIEVentas.aspx?CveVenta={0}&Masterimpoup=true',700,550,'S'); return false;", e.Row.DBCampo("CveVenta"))
|
||||
e.Row.FCLabel("LtNombreCliente").Text = String.Format("<a class=""Texto"" target=""_blank"" href=""/Ventas/Clientes.aspx?CveCliente={0}&Opt=3"" > {1}</a>", e.Row.DBCampo("CveCliente"), e.Row.DBCampo("NombreCliente"))
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "PDF"
|
||||
Private Sub ImgImprimir_Click(sender As Object, e As EventArgs) Handles ImgImprimir.Click
|
||||
If DtDatos.Rows.Count > 0 Then
|
||||
Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/GestionCobranza.rdlc", UsuarioActual.Empresa.Ruta))
|
||||
Dim params As New List(Of ReportParameter)
|
||||
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
||||
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
||||
|
||||
Dim Cobrador = If(DdlUsuarioCobranza.SelectedValue = "-1", "", $" <b>Cobrador:</b> {DdlUsuarioCobranza.SelectedItem.Text}")
|
||||
Dim Estatus = If(DdlCobranzaEstatus.SelectedValue = "-1", "", $" <b>Estatus:</b> {DdlCobranzaEstatus.SelectedItem.Text}")
|
||||
Dim Responsable = If(DdlResponsableCobranza.SelectedValue = "-1", "", $" <b>Responsable:</b> {DdlResponsableCobranza.SelectedItem.Text}")
|
||||
Dim Turno = If(DdlTurnos.SelectedValue = "-1", "", $" <b>Turno:</b> {DdlTurnos.SelectedItem.Text}")
|
||||
Dim TipoPago = If(DdlTipoPago.SelectedValue = "-1", "", $" <b>Tipo de Pago:</b> {DdlTipoPago.SelectedItem.Text}")
|
||||
|
||||
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
||||
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
||||
params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString))
|
||||
params.Add(New ReportParameter("FechaInicio", If(txtFechaI.Text = "", "", txtFechaI.Text)))
|
||||
params.Add(New ReportParameter("FechaFin", If(txtFechaF.Text = "", "", txtFechaF.Text)))
|
||||
'params.Add(New ReportParameter("Cobrador", DdlUsuarioCobranza.SelectedItem.Text))
|
||||
params.Add(New ReportParameter("Filtros", $"{Cobrador}{Estatus}{Responsable}{Turno}{TipoPago}"))
|
||||
|
||||
If Imagen.Exists Then
|
||||
params.Add(New ReportParameter("LogoPath", logouri))
|
||||
Else
|
||||
params.Add(New ReportParameter("LogoPath", ""))
|
||||
End If
|
||||
|
||||
If Archivo.Exists Then
|
||||
ImprimirPDF(String.Format("{0}Formatos/GestionCobranza.rdlc", UsuarioActual.Empresa.Ruta), DtDatos, params, NombreArchivo:="Gestión de Cobranza")
|
||||
Else
|
||||
ImprimirPDF("Empresas/Grales/Formatos/GestionCobranza.rdlc", DtDatos, params, NombreArchivo:="Gestión de Cobranza")
|
||||
End If
|
||||
|
||||
|
||||
Else
|
||||
Alert("No ha generado datos para la impresion", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
#Region "TIPO CAMBIO"
|
||||
|
||||
Private Sub RblTipoCambio_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RblTipoCambio.SelectedIndexChanged
|
||||
TipoCambio = RblTipoCambio.SelectedValue.ToEntero
|
||||
If TipoCambio = 3 Then
|
||||
LiEspecifico.Visible = True
|
||||
TCEspecifico = GlobalTipoCambio(Now).ToDecimal
|
||||
TxtEspecifico.Text = TCEspecifico.ToString
|
||||
Else
|
||||
LiEspecifico.Visible = False
|
||||
End If
|
||||
UpBodyTipoCambio.Update()
|
||||
End Sub
|
||||
|
||||
Private Sub BtnTipoCambio_Click(sender As Object, e As EventArgs) Handles BtnTipoCambio.Click
|
||||
CargaDatos()
|
||||
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivTipoCambio"))
|
||||
UpDatos.Update()
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user