1299 lines
55 KiB
VB.net
1299 lines
55 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports Microsoft.Reporting.WebForms
|
|
Imports System.Net.Http
|
|
|
|
Partial Class RepVentaDetalle
|
|
Inherits ClsPaginas
|
|
#Region "P R O P I E D A D E S"
|
|
Private Property CveProyecto As Integer
|
|
Get
|
|
Return ViewState("CveProyecto").ToString.ToEntero
|
|
End Get
|
|
|
|
Set(value As Integer)
|
|
ViewState("CveProyecto") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveSubProyecto() As String
|
|
Get
|
|
Return ViewState("CveSubProyecto").ToString
|
|
End Get
|
|
Set(ByVal value As String)
|
|
ViewState("CveSubProyecto") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtVentas As DataTable
|
|
Get
|
|
If ViewState("DtVentas") Is Nothing Then
|
|
ViewState("DtVentas") = New DataTable
|
|
End If
|
|
Return DirectCast(ViewState("DtVentas"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtVentas") = 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 CveMoneda As Integer
|
|
Get
|
|
Return ViewState("CveMoneda").ToString.ToEntero
|
|
End Get
|
|
|
|
Set(value As Integer)
|
|
ViewState("CveMoneda") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property TipoCliente As Integer
|
|
Get
|
|
If ViewState("TipoCliente") Is Nothing Then
|
|
Return -1
|
|
Else
|
|
Return ViewState("TipoCliente").ToString.ToEntero
|
|
End If
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("TipoCliente") = 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
|
|
Private Property Personalizo As Integer
|
|
Get
|
|
Return ViewState("Personalizo").ToString.ToEntero
|
|
End Get
|
|
|
|
Set(value As Integer)
|
|
ViewState("Personalizo") = value
|
|
End Set
|
|
End Property
|
|
Private Property Agrupador As String
|
|
Get
|
|
Return ViewState("Agrupador").ToString
|
|
End Get
|
|
|
|
Set(value As String)
|
|
ViewState("Agrupador") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Public Property Primeracontsulta As Boolean
|
|
Get
|
|
If ViewState("Primeracontsulta") Is Nothing Then
|
|
ViewState("Primeracontsulta") = True
|
|
End If
|
|
Return Boolean.Parse(ViewState("Primeracontsulta").ToString)
|
|
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("Primeracontsulta") = value
|
|
End Set
|
|
End Property
|
|
|
|
#End Region
|
|
'pRivate ReadOnly Property ColumnasVisibles As
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario.Contiene(77, 21) Then Response.Redirect("/Inicio.aspx")
|
|
Personalizo = 0
|
|
CargaCombos()
|
|
InicializaValores()
|
|
ConfiguraEmpresa()
|
|
CargaDatos()
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
|
|
|
|
LblServicioDomicilioFiltro.Visible = True
|
|
DVServicioDomicilio.Visible = True
|
|
|
|
End If
|
|
PrePersonalizacion()
|
|
CargaPersonalizacion()
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Private Sub InicializaValores()
|
|
Dim Grupo, CveCliente, CveSucursal, CveSubProyectoEjecucion, CveVendedor, CveUsuario, CveEstatusFactura, CveCorte, IVA, TipoDocto, CveClienteClasificacion, CveCondicionesPago, CveTipoRelacion As String
|
|
Dim Anio, Mes, AnioMes, Fecha, FechaI, FechaF As String
|
|
Dim AnioEjec, MesEjec, AnioMesEjec, FechaEjec, FechaIEjec, FechaFEjec As String
|
|
'Dim CveSubProyecto As Integer
|
|
Grupo = If(Request("GPO") IsNot Nothing AndAlso Request("GPO").ToEntero() > 0, Request("GPO").ToEntero(), -1).ToString
|
|
CveCliente = If(Request("CveCliente") IsNot Nothing AndAlso Request("CveCliente").ToEntero() > 0, Request("CveCliente").ToEntero(), -1).ToString
|
|
CveClienteClasificacion = If(Request("CveClienteClasificacion") IsNot Nothing, Request("CveClienteClasificacion").ToEntero(), -1).ToString
|
|
CveSucursal = If(Request("CveSucursal") IsNot Nothing AndAlso Request("CveSucursal").ToEntero() > 0, Request("CveSucursal").ToEntero(), -1).ToString
|
|
CveSubProyectoEjecucion = If(Request("CveSubProyectoEjecucion") IsNot Nothing AndAlso Request("CveSubProyectoEjecucion").ToEntero() > 0, Request("CveSubProyectoEjecucion").ToEntero(), -1).ToString
|
|
|
|
CveUsuario = If(Request("CveUsuario") IsNot Nothing AndAlso Request("CveUsuario").ToEntero() > 0, Request("CveUsuario").ToEntero(), -1).ToString
|
|
|
|
CveCorte = If(Request("CveCorte") IsNot Nothing AndAlso Request("CveCorte").ToEntero() > 0, Request("CveCorte").ToEntero(), -1).ToString
|
|
IVA = If(Request("IVA") IsNot Nothing, Request("IVA").ToString, "-1").ToString
|
|
|
|
|
|
Anio = If(Request("Anio") IsNot Nothing, Request("Anio").ToString, "-1").ToString
|
|
Mes = If(Request("Mes") IsNot Nothing, Request("Mes").ToString, "-1").ToString
|
|
AnioMes = If(Request("AnioMes") IsNot Nothing, Request("AnioMes").ToString, "-1").ToString
|
|
Fecha = If(Request("Fecha") IsNot Nothing, Request("Fecha").ToString, "-1").ToString
|
|
FechaI = If(Request("FechaI") IsNot Nothing, Request("FechaI").ToString, "-1").ToString
|
|
FechaF = If(Request("FechaF") IsNot Nothing, Request("FechaF").ToString, "-1").ToString
|
|
|
|
AnioEjec = If(Request("AnioEjec") IsNot Nothing, Request("AnioEjec").ToString, "-1").ToString
|
|
MesEjec = If(Request("MesEjec") IsNot Nothing, Request("MesEjec").ToString, "-1").ToString
|
|
AnioMesEjec = If(Request("AnioMesEjec") IsNot Nothing, Request("AnioMesEjec").ToString, "-1").ToString
|
|
FechaEjec = If(Request("FechaEjec") IsNot Nothing, Request("FechaEjec").ToString, "-1").ToString
|
|
FechaIEjec = If(Request("FechaIEjec") IsNot Nothing, Request("FechaIEjec").ToString, "-1").ToString
|
|
FechaFEjec = If(Request("FechaFEjec") IsNot Nothing, Request("FechaFEjec").ToString, "-1").ToString
|
|
|
|
CveProyecto = If(Request("CveProyecto") IsNot Nothing, Request("CveProyecto").ToString.ToEntero, -1).ToString.ToEntero
|
|
|
|
TipoCambio = If(Request("TipoCambio") IsNot Nothing, Request("TipoCambio").ToString.ToEntero, -1).ToString.ToEntero
|
|
TCEspecifico = If(Request("TCEspecifico") IsNot Nothing, Request("TCEspecifico").ToString.ToEntero, -1).ToString.ToDecimal
|
|
CveMoneda = If(Request("CveMoneda") IsNot Nothing, Request("CveMoneda").ToString.ToEntero, -1).ToString.ToEntero
|
|
TipoCliente = If(Request("TipoCliente") IsNot Nothing, Request("TipoCliente").ToString.ToEntero, -1).ToString.ToEntero
|
|
|
|
CveTipoRelacion = If(Request("CveTipoRelacion") IsNot Nothing, Request("CveTipoRelacion").ToString, "-1").ToString
|
|
|
|
DdlTipoCliente.SelectedValueExist(TipoCliente)
|
|
|
|
'LISTBOXS
|
|
TipoDocto = If(Request("TipoDocto") IsNot Nothing, Request("TipoDocto").ToString, "-1").ToString
|
|
CveSubProyecto = If(Request("CveSubProyecto") IsNot Nothing, Request("CveSubProyecto").ToString, "-1").ToString
|
|
CveVendedor = If(Request("CveVendedor") IsNot Nothing AndAlso Request("CveVendedor") <> "", Request("CveVendedor"), "-1").ToString
|
|
CveEstatusFactura = If(Request("CveEstatusFactura") IsNot Nothing AndAlso Request("CveEstatusFactura") <> "", Request("CveEstatusFactura"), "-1").ToString
|
|
CveCondicionesPago = If(Request("CveCondicionesPago") IsNot Nothing AndAlso Request("CveCondicionesPago") <> "", Request("CveCondicionesPago"), "-1").ToString
|
|
|
|
DdlTipoComprobante.SelectedValuesIfExistM(TipoDocto)
|
|
|
|
CargaEstatus()
|
|
DdlEstatus.SelectedValuesIfExistM(CveEstatusFactura)
|
|
DdlCondicionesPago.SelectedValueExist(CveCondicionesPago)
|
|
|
|
DdlProyecto.SelectedValueExist(CveProyecto)
|
|
'If DivProyecto.Visible Then CargaSubProyecto()
|
|
DdlSubProyecto.SelectedValuesIfExistM(CveSubProyecto)
|
|
DdlSubProyectoEjecucion.SelectedValueExist(CveSubProyectoEjecucion)
|
|
DdlVendedor.SelectedValuesIfExistM(CveVendedor)
|
|
|
|
DdlClienteClasificacion.SelectedValueExist(CveClienteClasificacion)
|
|
DdlTipoRelacion.SelectedValueExist(CveTipoRelacion)
|
|
|
|
CargaClientes()
|
|
DdlClientes.SelectedValue = CveCliente
|
|
DdlUsuario.SelectedValueExist(CveUsuario)
|
|
DdlGrupo.SelectedValueExist(Grupo)
|
|
|
|
|
|
DdlServicioDomicilio.SelectedValue = If(Request("ServicioDomicilio") IsNot Nothing, Request("ServicioDomicilio").ToString, "-1").ToString
|
|
|
|
UPFiltros.Update()
|
|
|
|
txtFechaI.Text = If(Anio <> "-1", String.Format("01/01/{0}", Anio), txtFechaI.Text)
|
|
txtFechaI.Text = If(Mes <> "-1", String.Format("01/{0}/0001", Mes), txtFechaI.Text)
|
|
|
|
Dim sMes As String
|
|
Dim sAnio As String = If(AnioMes <> "-1", AnioMes.Substring(0, 4), "")
|
|
|
|
If AnioMes.Trim.Length = 7 Then
|
|
sMes = AnioMes.Substring(5, 2).ToEntero.ToString("00")
|
|
Else
|
|
sMes = If(AnioMes <> "-1", AnioMes.Substring(5, 1).ToEntero.ToString("00"), "")
|
|
End If
|
|
|
|
txtFechaI.Text = If(AnioMes <> "-1", String.Format("01/{0}/{1}", sMes, sAnio), txtFechaI.Text)
|
|
|
|
If Anio <> "-1" AndAlso txtFechaF.Text = "" Then
|
|
txtFechaF.Text = String.Format("31/12/{0}", Anio)
|
|
ElseIf Mes <> "-1" AndAlso txtFechaF.Text = "" Then
|
|
txtFechaF.Text = txtFechaI.Text.ToDate.LastDayOfMonth.ToShortDateString
|
|
ElseIf AnioMes <> "-1" AndAlso txtFechaF.Text = "" Then
|
|
txtFechaF.Text = txtFechaI.Text.ToDate.LastDayOfMonth.ToShortDateString
|
|
End If
|
|
|
|
If FechaF <> "-1" Then
|
|
txtFechaF.Text = FechaF
|
|
End If
|
|
If FechaI <> "-1" Then
|
|
txtFechaI.Text = FechaI
|
|
End If
|
|
If Fecha <> "-1" Then
|
|
txtFechaI.Text = Fecha
|
|
txtFechaF.Text = Fecha
|
|
End If
|
|
|
|
TxtFechaIEjec.Text = If(AnioEjec <> "-1", String.Format("01/01/{0}", AnioEjec), TxtFechaIEjec.Text)
|
|
TxtFechaIEjec.Text = If(MesEjec <> "-1", String.Format("01/{0}/0001", MesEjec), TxtFechaIEjec.Text)
|
|
TxtFechaIEjec.Text = If(AnioMesEjec <> "-1", String.Format("01/{0}/{1}", AnioMesEjec.Substring(5, 1).PadLeft(2, "0"c), AnioMesEjec.Substring(0, 4)), TxtFechaIEjec.Text)
|
|
|
|
If AnioEjec <> "-1" Then
|
|
TxtFechaFEjec.Text = String.Format("31/12/{0}", AnioEjec)
|
|
ElseIf MesEjec <> "-1" Then
|
|
TxtFechaFEjec.Text = TxtFechaIEjec.Text.ToDate.LastDayOfMonth.ToShortDateString
|
|
ElseIf AnioMesEjec <> "-1" Then
|
|
TxtFechaFEjec.Text = TxtFechaIEjec.Text.ToDate.LastDayOfMonth.ToShortDateString
|
|
End If
|
|
|
|
If FechaFEjec <> "-1" Then
|
|
TxtFechaFEjec.Text = FechaFEjec
|
|
End If
|
|
If FechaIEjec <> "-1" Then
|
|
TxtFechaIEjec.Text = FechaIEjec
|
|
End If
|
|
If FechaEjec <> "-1" Then
|
|
TxtFechaIEjec.Text = FechaEjec
|
|
TxtFechaFEjec.Text = FechaEjec
|
|
End If
|
|
|
|
If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12) Then
|
|
ImgExcelVSH.Visible = True
|
|
ImgExcel.Visible = False
|
|
End If
|
|
|
|
If UsuarioActual.CveVendedor > 0 AndAlso Not UsuarioActual.TienePermisoProceso(263) Then
|
|
DdlVendedor.SelectedValuesIfExistM(UsuarioActual.CveVendedor.ToString)
|
|
DdlVendedor.Attributes.Add("disabled", "")
|
|
DdlVendedor.Enabled = False
|
|
End If
|
|
|
|
End Sub
|
|
|
|
#Region "CARGA COMBOS"
|
|
Private Sub CargaGrupo()
|
|
DdlGrupo.Items.Insert(0, New ListItem("Año", "1"))
|
|
DdlGrupo.Items.Insert(1, New ListItem("Mes", "2"))
|
|
DdlGrupo.Items.Insert(2, New ListItem("Año/Mes", "3"))
|
|
DdlGrupo.Items.Insert(3, New ListItem("Fecha", "4"))
|
|
DdlGrupo.Items.Insert(4, New ListItem("Cliente", "5"))
|
|
DdlGrupo.Items.Insert(5, New ListItem("Corte", "16"))
|
|
DdlGrupo.Items.Insert(6, New ListItem("Vendedor", "7"))
|
|
DdlGrupo.Items.Insert(7, New ListItem("Usuario", "8"))
|
|
DdlGrupo.Items.Insert(8, New ListItem("Estatus", "9"))
|
|
DdlGrupo.Items.Insert(9, New ListItem("% IVA", "10"))
|
|
DdlGrupo.Items.Insert(10, New ListItem("Año Ejec.", "11"))
|
|
DdlGrupo.Items.Insert(11, New ListItem("Mes Ejec.", "12"))
|
|
DdlGrupo.Items.Insert(12, New ListItem("Año/Mes Ejec.", "13"))
|
|
DdlGrupo.Items.Insert(13, New ListItem("Fecha Ejec.", "14"))
|
|
DdlGrupo.Items.Insert(13, New ListItem("Vendedor/Cliente", "21"))
|
|
DdlGrupo.DataBind()
|
|
End Sub
|
|
|
|
Private Sub CargaCombos()
|
|
CargarCentrosDeCosto(DdlProyecto, DdlSubProyecto, LblProyecto, LblSubProyecto, divProyecto:=DivProyecto)
|
|
CargaClientes()
|
|
|
|
|
|
'DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
txtFechaI.Text = Now.FirstDayOfMonth.ToShortDateString
|
|
txtFechaF.Text = Now.LastDayOfMonth.ToShortDateString
|
|
|
|
'Vendedor
|
|
DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=-1).FiltraParametros("VendedorTipo in (1,4)") 'vendedores y vendedores de piso
|
|
DdlVendedor.DataBind()
|
|
DdlVendedor.Items.Insert(0, New ListItem("Sin Vendedor", "-2"))
|
|
|
|
'CargaUsuarios
|
|
DdlUsuario.DataSource = GlobalDTUsuarios.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
DdlUsuario.DataBind()
|
|
|
|
'CargaEstatus
|
|
DdlEstatus.DataSource = GlobalDTEstatusFactura
|
|
DdlEstatus.DataBind()
|
|
|
|
'Carga Clasificacion Cliente
|
|
DdlClienteClasificacion.DataSource = GlobalDTClienteClasificaciones(UsuarioActual.CveEmpresa)
|
|
DdlClienteClasificacion.DataBind()
|
|
DdlClienteClasificacion.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
DdlClienteClasificacion.Items.Insert(0, New ListItem("Sin Giro", "-2"))
|
|
|
|
|
|
DdlTipoRelacion.DataSource = GlobalDTVtaTiposRelacion
|
|
DdlTipoRelacion.DataBind()
|
|
DdlTipoRelacion.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
|
|
CargaGrupo()
|
|
End Sub
|
|
|
|
Private Sub CargaEstatus()
|
|
DdlEstatus.Items.Clear()
|
|
If DdlTipoComprobante.GetSelectedText <> "" Then
|
|
DdlEstatus.DataSource = GlobalDTEstatusFactura.FiltraParametros(String.Format("TipoDocto IN ({0})", DdlTipoComprobante.GetSelectedValuesM(True).Replace("Ant", "Ing")))
|
|
Else
|
|
DdlEstatus.DataSource = GlobalDTEstatusFactura
|
|
End If
|
|
' DdlEstatus.Items.Add(New ListItem("Todos", "-1"))
|
|
DdlEstatus.DataBind()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "SELECTED INDEX CHANGE"
|
|
Protected Sub DdlTipoComprobante_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
CargaEstatus()
|
|
End Sub
|
|
|
|
Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged
|
|
CargarSubProyecto(DdlSubProyecto, DdlProyecto.SelectedValue)
|
|
End Sub
|
|
|
|
Protected Sub DdlClienteClasificacion_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
CargaClientes()
|
|
End Sub
|
|
|
|
Private Sub CargaClientes()
|
|
Dim EsWS = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False)
|
|
If EsWS Then
|
|
DdlClientes.setEsWebService(True)
|
|
Else
|
|
DdlClientes.setEsWebService(False)
|
|
DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1).FiltraParametros($"CveClienteClasificacion = {DdlClienteClasificacion.SelectedValue.ToEntero} OR {DdlClienteClasificacion.SelectedValue.ToEntero} = -1")
|
|
DdlClientes.DataBind()
|
|
DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
End If
|
|
'DdlClientes.ddl.Items.Clear()
|
|
'DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1).FiltraParametros($"CveClienteClasificacion = {DdlClienteClasificacion.SelectedValue.ToEntero} OR {DdlClienteClasificacion.SelectedValue.ToEntero} = -1")
|
|
'DdlClientes.DataBind()
|
|
'DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "CONSULTAR"
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click
|
|
CargaDatos()
|
|
UPDatos.Update()
|
|
End Sub
|
|
Private Sub CargaDatos()
|
|
|
|
Dim AnioMes = "-1" ' If(Request("AnioMes") IsNot Nothing, Request("AnioMes").ToString, "-1").ToString
|
|
Dim Fecha = If(Request("Fecha") IsNot Nothing, Request("Fecha").ToString, "-1").ToString
|
|
Dim IVA = If(Request("IVA") IsNot Nothing, Request("IVA").ToString, "-1").ToString
|
|
|
|
Dim FechaI, FechaF, FechaIEjec, FechaFEjec As Date
|
|
Dim Anio = If(Request("Anio") IsNot Nothing, Request("Anio").ToString, "-1").ToString
|
|
Dim Mes = If(Request("Mes") IsNot Nothing, Request("Mes").ToString, "-1").ToString
|
|
Dim CveCorte = If(Request("CveCorte") IsNot Nothing AndAlso Request("CveCorte").ToEntero() > 0, Request("CveCorte").ToEntero(), -1).ToString
|
|
|
|
'PARAMETROS DE LOS LISTBOXS
|
|
Dim TipoComprobante As String = If(DdlTipoComprobante.GetSelectedValuesM = "", "-1", DdlTipoComprobante.GetSelectedValuesM)
|
|
Dim Sucursales As String = If(DdlSubProyecto.GetSelectedValuesM = "", "-1", DdlSubProyecto.GetSelectedValuesM)
|
|
Dim Estatus As String = If(DdlEstatus.GetSelectedValuesM = "", "-1", DdlEstatus.GetSelectedValuesM)
|
|
Dim CveCondicionesPago As Integer = If(DdlCondicionesPago.SelectedValue = "", -1, DdlCondicionesPago.SelectedValue.ToEntero)
|
|
Dim Vendedores As String = If(DdlVendedor.GetSelectedValuesM = "", "-1", DdlVendedor.GetSelectedValuesM)
|
|
Dim CveCliente As Integer = If(DdlClientes.SelectedValue = "", -1, DdlClientes.SelectedValue.ToEntero)
|
|
|
|
'Anio = txtFechaI.Text.ToDate.Year.ToString
|
|
'Mes = txtFechaI.Text.ToDate.Month.ToString
|
|
AnioMes = "-1" 'String.Format("{0}/{1}", txtFechaI.Text.ToDate.Year.ToString, txtFechaI.Text.ToDate.Month.ToString)
|
|
|
|
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim.ToDate, MinFecha)
|
|
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim.ToDate, MaxFecha)
|
|
FechaIEjec = If(IsDate(TxtFechaIEjec.Text.Trim()), TxtFechaIEjec.Text.Trim.ToDate, MinFecha)
|
|
FechaFEjec = If(IsDate(TxtFechaFEjec.Text.Trim()), TxtFechaFEjec.Text.Trim.ToDate, MaxFecha)
|
|
|
|
Dim ModalidadContable As Boolean = CBool(If(Request("ModalidadContable") IsNot Nothing, Request("ModalidadContable").ToEntero(), 0))
|
|
|
|
ChkLecturaAdmin.Checked = Not ModalidadContable
|
|
|
|
Dim ObjVentas As New ClsVentas()
|
|
'FechaI, FechaF, -1, UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero
|
|
If ObjVentas.GetRepVentasDetalle(DdlGrupo.SelectedValue.ToEntero, Anio.ToEntero, Mes.ToEntero, AnioMes, Fecha, CveCliente,
|
|
IVA, Vendedores, DdlUsuario.SelectedValue.ToEntero, Estatus, FechaI, FechaF,
|
|
CveCorte.ToEntero, TipoComprobante, DdlSubProyectoEjecucion.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, FechaIEjec, FechaFEjec,
|
|
CveProyecto, Sucursales, TipoCambio, TCEspecifico, CveMoneda, CveUsuarioConsulta:=UsuarioActual.CveUsuario, CveClienteClasificacion:=DdlClienteClasificacion.SelectedValue.ToEntero,
|
|
CveCondicionesPago:=CveCondicionesPago, TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero, ModalidadContable:=Not ChkLecturaAdmin.Checked, CveTipoRelacion:=DdlTipoRelacion.SelectedValue.ToEntero(),
|
|
ServicioDomicilio:=DdlServicioDomicilio.SelectedValue.ToEntero) Then
|
|
DtVentas = AddRows(ObjVentas.DtResultados)
|
|
ImgImprimir.Enabled = True
|
|
GvDatos.DataSource = AddRows(ObjVentas.DtResultados)
|
|
GvVsh.DataSource = ObjVentas.DtResultados.FiltraParametros("CveVenta > 0")
|
|
|
|
If DtVentas.SUMD("Descuento") <= 0 Then
|
|
GvDatos.Columns(5).Visible = False ' se oculta descuentos, si está vac+io
|
|
Else
|
|
If Primeracontsulta Then
|
|
GvDatos.Columns(5).Visible = True
|
|
ChkDescuento.Checked = True
|
|
End If
|
|
End If
|
|
|
|
Else
|
|
GvDatos.DataSource = Nothing
|
|
GvVsh.DataSource = Nothing
|
|
End If
|
|
ObjVentas.Dispose()
|
|
|
|
If DtVentas IsNot Nothing AndAlso DtVentas.Rows.Count > 0 AndAlso DtVentas.SUMD("Descuento") <= 0 Then GvDatos.Columns(5).Visible = False ' se oculta descuentos, si está vac+io
|
|
Agrupador = DdlGrupo.SelectedItem.Text
|
|
|
|
GvDatosDataBind()
|
|
GvVsh.DataBind()
|
|
|
|
Primeracontsulta = False
|
|
|
|
End Sub
|
|
|
|
Private Sub GvDatosDataBind()
|
|
|
|
GvDatos.DataSource = DtVentas
|
|
GvDatos.DataBind()
|
|
UPDatos.Update()
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "GRIDVIEW"
|
|
|
|
Private Function AddRows(ByRef DT As DataTable) As DataTable
|
|
Dim i As Integer = 0
|
|
Dim Ultima As String = String.Empty
|
|
Dim Rows As Integer = 0
|
|
Dim dbRow As DataRow
|
|
|
|
While i < DT.Rows.Count
|
|
If DT.Rows(i)("GPO").ToString <> "" AndAlso DT.Rows(i)("CveVenta").ToString = "" AndAlso Ultima <> DT.Rows(i)("GPO").ToString Then
|
|
dbRow = DT.NewRow()
|
|
dbRow("GPO") = DT.Rows(i)("GPO") : Ultima = DT.Rows(i)("GPO").ToString
|
|
DT.Rows.InsertAt(dbRow, i)
|
|
End If
|
|
i += 1
|
|
End While
|
|
Return DT
|
|
End Function
|
|
|
|
Private Sub ConfiguraEmpresa()
|
|
|
|
If Not UsuarioActual.Empresa.MostrarRetIVA Then GvDatos.Columns(10).Visible = False
|
|
If Not UsuarioActual.Empresa.MostrarRetISR Then GvDatos.Columns(11).Visible = False
|
|
|
|
ChkIEPS.Checked = UsuarioActual.Empresa.Funcionalidad(713) = "1" 'empresa deduce IEPS
|
|
GvDatos.Columns(9).Visible = ChkIEPS.Checked
|
|
|
|
End Sub
|
|
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.RowIndex = 0 Then
|
|
e.Row.CssClass = "Totales"
|
|
End If
|
|
|
|
If e.Row.DBCampo("GPO") <> "" AndAlso e.Row.DBCampo("Cantidad") = "" Then
|
|
For i As Integer = 1 To GvDatos.Columns.Count - 1
|
|
e.Row.Cells(i).Visible = False
|
|
Next
|
|
e.Row.Cells(0).ColumnSpan = GvDatos.Columns.Count
|
|
e.Row.CssClass = "SubTotales2"
|
|
e.Row.FCLiteral("LtlTipo").Text = e.Row.DBCampo("GPO")
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
e.Row.Visible = False
|
|
ElseIf e.Row.DBCampo("CveVenta") = "" Then
|
|
If e.Row.RowIndex > 0 Then e.Row.CssClass = "SubTotales"
|
|
e.Row.FCLiteral("LtlFolio").Text = e.Row.DBCampo("Cantidad")
|
|
e.Row.Cells(3).Text = e.Row.DBCampo("GPO")
|
|
Else
|
|
e.Row.FCLiteral("LtlFolio").Text = "<a class=""Texto"" href=""/Ventas/Ventas.aspx?CveVenta=" & e.Row.DBCampo("CveVenta") & """>" & e.Row.DBCampo("SerieFolio") & "</a>"
|
|
e.Row.FCLiteral("LtlCodCliente").Text = "<a class=""Texto"" href=""/Ventas/Clientes.aspx?CveCliente=" & e.Row.DBCampo("CveCliente") & "&Historial=True"">" & e.Row.DBCampo("Codigo") & "</a>"
|
|
e.Row.FCLiteral("LtlCliente").Text = "<a class=""Texto"" href=""/Ventas/Clientes.aspx?CveCliente=" & e.Row.DBCampo("CveCliente") & "&Historial=True"">" & e.Row.DBCampo("Nombre") & "</a>"
|
|
|
|
e.Row.FCLiteral("LtlFacturaCotizacion").Text = "<a class=""Texto"" href=""/Ventas/Ventas.aspx?CveVenta=" & e.Row.DBCampo("CveVentaPadre") & """>" & e.Row.DBCampo("FolioVenta") & "</a>"
|
|
End If
|
|
|
|
|
|
If e.Row.DBCampo("SubTotal").ToDouble = 0 Then e.Row.FCLiteral("LtlSubTotal").Text = "-"
|
|
If e.Row.DBCampo("Descuento").ToDouble = 0 Then e.Row.FCLiteral("LtlDescuento").Text = "-"
|
|
If e.Row.DBCampo("Amortizacion").ToDouble = 0 Then e.Row.FCLiteral("LtlAmortizacion").Text = "-"
|
|
If e.Row.DBCampo("IVA").ToDouble = 0 Then e.Row.FCLiteral("LtlIVA").Text = "-"
|
|
If e.Row.DBCampo("RetIVA").ToDouble = 0 Then e.Row.FCLiteral("LtlRetIVA").Text = "-"
|
|
If e.Row.DBCampo("RetISR").ToDouble = 0 Then e.Row.FCLiteral("LtlRetISR").Text = "-"
|
|
If e.Row.DBCampo("Total").ToDouble = 0 Then e.Row.FCLiteral("LtlTotal").Text = "-"
|
|
|
|
If e.Row.DBCampo("SubTotal").ToDouble < 0 Then e.Row.Cells(4).ForeColor = Drawing.Color.Red
|
|
If e.Row.DBCampo("Descuento").ToDouble < 0 Then e.Row.Cells(5).ForeColor = Drawing.Color.Red
|
|
If e.Row.DBCampo("Amortizacion").ToDouble < 0 Then e.Row.Cells(7).ForeColor = Drawing.Color.Red
|
|
If e.Row.DBCampo("IVA").ToDouble < 0 Then e.Row.Cells(8).ForeColor = Drawing.Color.Red
|
|
If e.Row.DBCampo("RetIVA").ToDouble < 0 Then e.Row.Cells(9).ForeColor = Drawing.Color.Red
|
|
If e.Row.DBCampo("RetISR").ToDouble < 0 Then e.Row.Cells(10).ForeColor = Drawing.Color.Red
|
|
If e.Row.DBCampo("Total").ToDouble < 0 Then e.Row.Cells(11).ForeColor = Drawing.Color.Red
|
|
If e.Row.DBCampo("Total").ToDouble < 0 Then e.Row.Cells(12).ForeColor = Drawing.Color.Red
|
|
If e.Row.DBCampo("Total").ToDouble < 0 Then e.Row.Cells(13).ForeColor = Drawing.Color.Red
|
|
|
|
|
|
'If e.Row.DBCampo("MAX_SubTotal").ToDouble = 0 Then e.Row.FCLiteral("LtlMaxSubTotal").Text = ""
|
|
'If e.Row.DBCampo("AVG_SubTotal").ToDouble = 0 Then e.Row.FCLiteral("LtlAVGSubTotal").Text = ""
|
|
'If e.Row.DBCampo("MIN_SubTotal").ToDouble = 0 Then e.Row.FCLiteral("LtlMinSubTotal").Text = ""
|
|
'If e.Row.DBCampo("MAX_Total").ToDouble = 0 Then e.Row.FCLiteral("LtlMaxTotal").Text = ""
|
|
'If e.Row.DBCampo("AVG_Total").ToDouble = 0 Then e.Row.FCLiteral("LtlAVGTotal").Text = ""
|
|
'If e.Row.DBCampo("MIN_Total").ToDouble = 0 Then e.Row.FCLiteral("LtlMinTotal").Text = ""
|
|
End If
|
|
End Sub
|
|
Protected Sub GvVsh_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvVsh.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
GvVsh.Caption = String.Format("{0} {1} {2} <br> ** FACTURACION DEL MES **", UsuarioActual.Empresa.Direccion, UsuarioActual.Empresa.NoExt, UsuarioActual.Empresa.NoInt)
|
|
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left
|
|
e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Left
|
|
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left
|
|
e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Left
|
|
e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right
|
|
e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right
|
|
e.Row.Cells(7).HorizontalAlign = HorizontalAlign.Right
|
|
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "PERSONALIZAR COLUMNAS"
|
|
|
|
Private Sub PrePersonalizacion()
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(713) = "1" Then
|
|
ChkIEPS.Visible = True
|
|
Else
|
|
ChkIEPS.Visible = False
|
|
GvDatos.Columns(9).Visible = False
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub PersonalizaDefault()
|
|
|
|
ChkTipoDocto.Checked = True
|
|
ChkFolio.Checked = True
|
|
ChkFecha.Checked = True
|
|
ChkSubTotal.Checked = True
|
|
|
|
If DtVentas.Rows.Count > 0 AndAlso DtVentas.SUMD("Descuento") > 0 Then
|
|
ChkDescuento.Checked = True
|
|
End If
|
|
|
|
ChkIVA.Checked = True
|
|
If UsuarioActual.Empresa.Funcionalidad(713) = "1" Then
|
|
ChkIEPS.Checked = True
|
|
End If
|
|
|
|
ChkTotal.Checked = True
|
|
ChkMoneda.Checked = True
|
|
ChkSucursal.Checked = True
|
|
ChkEstatusFactura.Checked = True
|
|
ChkCliente.Checked = True
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkPersonalizar_Click(sender As Object, e As EventArgs)
|
|
|
|
ChkGuardarPersonalizacion.Checked = False
|
|
RegistraScript("$('#DivPersonalizar').modal('show')")
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnPersonalizar_Click(sender As Object, e As System.EventArgs) Handles BtnPersonalizar.Click
|
|
|
|
If ChkGuardarPersonalizacion.Checked Then
|
|
GuardaPersonalizacion()
|
|
End If
|
|
|
|
Personaliza()
|
|
GvDatosDataBind()
|
|
UPDatos.Update()
|
|
|
|
End Sub
|
|
|
|
Private Sub GuardaPersonalizacion()
|
|
|
|
Dim objUsuario As New ClsSisUsuarios
|
|
Dim ListPersonalizada As New List(Of String)
|
|
|
|
If ChkOrdenCompra.Checked Then
|
|
ListPersonalizada.Add("OrdenCompra")
|
|
End If
|
|
|
|
If ChkFolio.Checked Then
|
|
ListPersonalizada.Add("Folio")
|
|
End If
|
|
|
|
If ChkPedidoContrato.Checked Then
|
|
ListPersonalizada.Add("PedidoContrato")
|
|
End If
|
|
|
|
|
|
If ChkFolio.Checked Then
|
|
ListPersonalizada.Add("Folio")
|
|
End If
|
|
|
|
If ChkFecha.Checked Then
|
|
ListPersonalizada.Add("Fecha")
|
|
End If
|
|
|
|
If ChkCliente.Checked Then
|
|
ListPersonalizada.Add("Cliente")
|
|
End If
|
|
|
|
If ChkSubTotal.Checked Then
|
|
ListPersonalizada.Add("SubTotal")
|
|
End If
|
|
|
|
If ChkDescuento.Checked Then
|
|
ListPersonalizada.Add("Descuento")
|
|
End If
|
|
|
|
If ChlMotivoDescuento.Checked Then
|
|
ListPersonalizada.Add("MotivoDescuento")
|
|
End If
|
|
|
|
If ChkAmortizacion.Checked Then
|
|
ListPersonalizada.Add("Amortizacion")
|
|
End If
|
|
|
|
If ChkIVA.Checked Then
|
|
ListPersonalizada.Add("IVA")
|
|
End If
|
|
|
|
If ChkIEPS.Checked Then
|
|
ListPersonalizada.Add("IEPS")
|
|
End If
|
|
|
|
If ChkRetIVA.Checked Then
|
|
ListPersonalizada.Add("RetIVA")
|
|
End If
|
|
|
|
If ChkRetISR.Checked Then
|
|
ListPersonalizada.Add("RetISR")
|
|
End If
|
|
|
|
If ChkTotalImpuestos.Checked Then
|
|
ListPersonalizada.Add("TotalImpuestos")
|
|
End If
|
|
|
|
If ChkTotal.Checked Then
|
|
ListPersonalizada.Add("Total")
|
|
End If
|
|
|
|
If ChkMoneda.Checked Then
|
|
ListPersonalizada.Add("Moneda")
|
|
End If
|
|
|
|
If ChkSucursal.Checked Then
|
|
ListPersonalizada.Add("Sucursal")
|
|
End If
|
|
|
|
If ChkSucursalEjecucion.Checked Then
|
|
ListPersonalizada.Add("SucursalEjecucion")
|
|
End If
|
|
|
|
If ChkCodigo.Checked Then
|
|
ListPersonalizada.Add("Codigo")
|
|
End If
|
|
|
|
If ChkSucursalCliente.Checked Then
|
|
ListPersonalizada.Add("SucursalCliente")
|
|
End If
|
|
|
|
If ChkSucursalCobranza.Checked Then
|
|
ListPersonalizada.Add("SucursalCobranza")
|
|
End If
|
|
|
|
If ChkVendedor.Checked Then
|
|
ListPersonalizada.Add("Vendedor")
|
|
End If
|
|
|
|
If ChkEstatusFactura.Checked Then
|
|
ListPersonalizada.Add("EstatusFactura")
|
|
End If
|
|
|
|
If ChkMotivoCancelacion.Checked Then
|
|
ListPersonalizada.Add("MotivoCancelacion")
|
|
End If
|
|
|
|
If ChkSeTimbro.Checked Then
|
|
ListPersonalizada.Add("SeTimbro")
|
|
End If
|
|
|
|
If ChkSeEnvioMail.Checked Then
|
|
ListPersonalizada.Add("SeEnvioMail")
|
|
End If
|
|
|
|
If ChkCuentaContable.Checked Then
|
|
ListPersonalizada.Add("CuentaContable")
|
|
End If
|
|
|
|
If ChkUsuario.Checked Then
|
|
ListPersonalizada.Add("Usuario")
|
|
End If
|
|
|
|
If ChkObservaciones.Checked Then
|
|
ListPersonalizada.Add("Observaciones")
|
|
End If
|
|
|
|
If ChkFolioFiscal.Checked Then
|
|
ListPersonalizada.Add("FolioFiscal")
|
|
End If
|
|
|
|
If ChkMailCliente.Checked Then
|
|
ListPersonalizada.Add("MailCliente")
|
|
End If
|
|
|
|
If ChkEstatusFacturacion.Checked Then
|
|
ListPersonalizada.Add("EstatusFacturacion")
|
|
End If
|
|
|
|
If ChkFolioFacturacion.Checked Then
|
|
ListPersonalizada.Add("FolioFacturacion")
|
|
End If
|
|
|
|
If ChkSaldo.Checked Then
|
|
ListPersonalizada.Add("Saldo")
|
|
End If
|
|
|
|
If objUsuario.AddUsuariosPersonalizaciones(UsuarioActual, "RepVentaDetalles.aspx", String.Join("|", ListPersonalizada)) Then
|
|
'Alert("Personalizacion guardada")
|
|
End If
|
|
|
|
objUsuario.Dispose()
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaPersonalizacion()
|
|
|
|
Dim strBasePersonalizacion As String = UsuarioActual.Personalizaciones("RepVentaDetalles.aspx")
|
|
|
|
If strBasePersonalizacion.Trim.Length > 0 Then
|
|
|
|
ChkTipoDocto.Checked = False
|
|
ChkOrdenCompra.Checked = False
|
|
ChkPedidoContrato.Checked = False
|
|
|
|
ChkFolio.Checked = False
|
|
ChkFecha.Checked = False
|
|
ChkCliente.Checked = False
|
|
ChkSubTotal.Checked = False
|
|
ChkDescuento.Checked = False
|
|
ChlMotivoDescuento.Checked = False
|
|
ChkAmortizacion.Checked = False
|
|
ChkIVA.Checked = False
|
|
ChkIEPS.Checked = False
|
|
ChkRetIVA.Checked = False
|
|
ChkRetISR.Checked = False
|
|
ChkTotalImpuestos.Checked = False
|
|
ChkTotal.Checked = False
|
|
ChkMoneda.Checked = False
|
|
ChkSucursal.Checked = False
|
|
ChkSucursalEjecucion.Checked = False
|
|
ChkCodigo.Checked = False
|
|
ChkSucursalCliente.Checked = False
|
|
ChkSucursalCobranza.Checked = False
|
|
ChkSucursalEjecucion.Checked = False
|
|
ChkVendedor.Checked = False
|
|
ChkEstatusFactura.Checked = False
|
|
ChkMotivoCancelacion.Checked = False
|
|
ChkSeTimbro.Checked = False
|
|
ChkSeEnvioMail.Checked = False
|
|
ChkCuentaContable.Checked = False
|
|
ChkUsuario.Checked = False
|
|
ChkObservaciones.Checked = False
|
|
ChkFolioFiscal.Checked = False
|
|
ChkMailCliente.Checked = False
|
|
ChkEstatusFacturacion.Checked = False
|
|
ChkFolioFacturacion.Checked = False
|
|
ChkSaldo.Checked = False
|
|
|
|
Dim Personalizaciones As String() = strBasePersonalizacion.Split("|"c)
|
|
|
|
For Each personalizacion As String In Personalizaciones
|
|
Select Case personalizacion
|
|
Case "TipoDocto"
|
|
ChkTipoDocto.Checked = True
|
|
Exit Select
|
|
Case "OrdenCompra"
|
|
ChkOrdenCompra.Checked = True
|
|
Exit Select
|
|
Case "PedidoContrato"
|
|
ChkPedidoContrato.Checked = True
|
|
Exit Select
|
|
Case "Folio"
|
|
ChkFolio.Checked = True
|
|
Exit Select
|
|
Case "Fecha"
|
|
ChkFecha.Checked = True
|
|
Exit Select
|
|
Case "Cliente"
|
|
ChkCliente.Checked = True
|
|
Exit Select
|
|
Case "SubTotal"
|
|
ChkSubTotal.Checked = True
|
|
Exit Select
|
|
Case "Descuento"
|
|
ChkDescuento.Checked = True
|
|
Exit Select
|
|
Case "MotivoDescuento"
|
|
ChlMotivoDescuento.Checked = True
|
|
Exit Select
|
|
Case "Amortizacion"
|
|
ChkAmortizacion.Checked = True
|
|
Exit Select
|
|
Case "IVA"
|
|
ChkIVA.Checked = True
|
|
Exit Select
|
|
Case "IEPS"
|
|
ChkIEPS.Checked = True
|
|
Exit Select
|
|
Case "RetIVA"
|
|
ChkRetIVA.Checked = True
|
|
Exit Select
|
|
Case "RetISR"
|
|
ChkRetISR.Checked = True
|
|
Exit Select
|
|
Case "TotalImpuestos"
|
|
ChkTotalImpuestos.Checked = True
|
|
Exit Select
|
|
Case "Total"
|
|
ChkTotal.Checked = True
|
|
Exit Select
|
|
Case "Moneda"
|
|
ChkMoneda.Checked = True
|
|
Exit Select
|
|
Case "Sucursal"
|
|
ChkSucursal.Checked = True
|
|
Exit Select
|
|
Case "SucursalEjecucion"
|
|
ChkSucursalEjecucion.Checked = True
|
|
Exit Select
|
|
Case "Codigo"
|
|
ChkCodigo.Checked = True
|
|
Exit Select
|
|
Case "SucursalCliente"
|
|
ChkSucursalCliente.Checked = True
|
|
Exit Select
|
|
Case "SucursalCobranza"
|
|
ChkSucursalCobranza.Checked = True
|
|
Exit Select
|
|
Case "SucursalEjecucion"
|
|
ChkSucursalEjecucion.Checked = True
|
|
Exit Select
|
|
Case "Vendedor"
|
|
ChkVendedor.Checked = True
|
|
Exit Select
|
|
Case "EstatusFactura"
|
|
ChkEstatusFactura.Checked = True
|
|
Exit Select
|
|
Case "MotivoCancelacion"
|
|
ChkMotivoCancelacion.Checked = True
|
|
Exit Select
|
|
Case "SeTimbro"
|
|
ChkSeTimbro.Checked = True
|
|
Exit Select
|
|
Case "SeEnvioMail"
|
|
ChkSeEnvioMail.Checked = True
|
|
Exit Select
|
|
Case "CuentaContable"
|
|
ChkCuentaContable.Checked = True
|
|
Exit Select
|
|
Case "Usuario"
|
|
ChkUsuario.Checked = True
|
|
Exit Select
|
|
Case "Observaciones"
|
|
ChkObservaciones.Checked = True
|
|
Exit Select
|
|
Case "FolioFiscal"
|
|
ChkFolioFiscal.Checked = True
|
|
Exit Select
|
|
Case "MailCliente"
|
|
ChkMailCliente.Checked = True
|
|
Exit Select
|
|
Case "EstatusFacturacion"
|
|
ChkEstatusFacturacion.Checked = True
|
|
Exit Select
|
|
Case "FolioFacturacion"
|
|
ChkFolioFacturacion.Checked = True
|
|
Exit Select
|
|
Case "Saldo"
|
|
ChkSaldo.Checked = True
|
|
Exit Select
|
|
Case Else
|
|
Exit Select
|
|
End Select
|
|
Next
|
|
|
|
Personaliza()
|
|
Else
|
|
PersonalizaDefault()
|
|
End If
|
|
|
|
UPPersonalizar.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub Personaliza()
|
|
|
|
GvDatos.Columns(0).Visible = ChkTipoDocto.Checked
|
|
GvDatos.Columns(1).Visible = ChkFolio.Checked
|
|
GvDatos.Columns(2).Visible = ChkFecha.Checked
|
|
GvDatos.Columns(3).Visible = ChkCliente.Checked
|
|
GvDatos.Columns(4).Visible = ChkSubTotal.Checked
|
|
GvDatos.Columns(5).Visible = ChkDescuento.Checked
|
|
GvDatos.Columns(6).Visible = ChlMotivoDescuento.Checked
|
|
GvDatos.Columns(7).Visible = ChkAmortizacion.Checked
|
|
GvDatos.Columns(8).Visible = ChkIVA.Checked
|
|
GvDatos.Columns(9).Visible = ChkIEPS.Checked
|
|
GvDatos.Columns(10).Visible = ChkRetIVA.Checked
|
|
GvDatos.Columns(11).Visible = ChkRetISR.Checked
|
|
GvDatos.Columns(12).Visible = ChkTotalImpuestos.Checked
|
|
GvDatos.Columns(13).Visible = ChkTotal.Checked
|
|
GvDatos.Columns(14).Visible = ChkMoneda.Checked
|
|
GvDatos.Columns(15).Visible = ChkSucursal.Checked
|
|
GvDatos.Columns(16).Visible = ChkSucursalEjecucion.Checked
|
|
GvDatos.Columns(17).Visible = ChkCodigo.Checked
|
|
GvDatos.Columns(18).Visible = ChkSucursalCliente.Checked
|
|
GvDatos.Columns(19).Visible = ChkSucursalCobranza.Checked
|
|
GvDatos.Columns(20).Visible = ChkSucursalEjecucion.Checked
|
|
GvDatos.Columns(21).Visible = ChkVendedor.Checked
|
|
GvDatos.Columns(22).Visible = ChkEstatusFactura.Checked
|
|
GvDatos.Columns(23).Visible = ChkMotivoCancelacion.Checked
|
|
GvDatos.Columns(24).Visible = ChkSeTimbro.Checked
|
|
GvDatos.Columns(25).Visible = ChkSeEnvioMail.Checked
|
|
GvDatos.Columns(26).Visible = ChkCuentaContable.Checked
|
|
GvDatos.Columns(27).Visible = ChkUsuario.Checked
|
|
GvDatos.Columns(28).Visible = ChkObservaciones.Checked
|
|
GvDatos.Columns(29).Visible = ChkFolioFiscal.Checked
|
|
GvDatos.Columns(30).Visible = ChkMailCliente.Checked
|
|
GvDatos.Columns(31).Visible = ChkEstatusFacturacion.Checked
|
|
GvDatos.Columns(32).Visible = ChkFolioFacturacion.Checked
|
|
GvDatos.Columns(33).Visible = ChkSaldo.Checked
|
|
GvDatos.Columns(34).Visible = ChkOrdenCompra.Checked
|
|
GvDatos.Columns(35).Visible = ChkPedidoContrato.Checked
|
|
|
|
Personalizo = 1
|
|
If Personalizo = 1 Then
|
|
ImgExcelPersonalizado.Visible = True
|
|
Else
|
|
ImgExcelPersonalizado.Visible = False
|
|
End If
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "IMPRESIONES"
|
|
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
|
|
'GvDatos.ExportToExcel("DetalleVentas_" & Now.ToShortDateString)
|
|
GenerarPDF("Excel")
|
|
End Sub
|
|
|
|
Protected Sub ImgExcelVSH_Click(sender As Object, e As EventArgs) Handles ImgExcelVSH.Click
|
|
'GvVsh.Visible = True
|
|
'GvVsh.ExportToExcel("DetalleVentas_" & Now.ToShortDateString)
|
|
'GvVsh.Visible = False
|
|
GvDatos.ExportToExcel("DetalleVentas_" & Now.ToShortDateString)
|
|
End Sub
|
|
Protected Sub ImgExcelPersonalizado_Click(sender As Object, e As EventArgs) Handles ImgExcelPersonalizado.Click
|
|
'GvVsh.Visible = True
|
|
'GvVsh.ExportToExcel("DetalleVentas_" & Now.ToShortDateString)
|
|
'GvVsh.Visible = False
|
|
GvDatos.ExportToExcel("DetalleVentas_" & Now.ToShortDateString & ".xls")
|
|
'GvDatos.ExportToExcelG("DetalleVentas_" & Now.ToShortDateString & ".xlsx")
|
|
End Sub
|
|
Public Overrides Sub VerifyRenderingInServerForm(control As Control)
|
|
|
|
End Sub
|
|
|
|
Private Sub BtnDescargarPDF_Click(sender As Object, e As EventArgs) Handles BtnDescargarPDF.Click
|
|
Dim pathPDF As String
|
|
Dim TipoDocto As String = ""
|
|
'Dim ListaPDF As New List(Of MFacturaDescarga)
|
|
'GENERA FACTURAS QUE NO ESTAN EN LA CARPETA
|
|
For Each gvr As GridViewRow In GvDatos.Rows
|
|
If gvr.DataKey("CveVenta").ToEntero > 0 Then
|
|
|
|
Select Case gvr.DataKey("TipoDocumento").ToString
|
|
Case "Ingreso"
|
|
TipoDocto = "Ing"
|
|
Case = "Cotización"
|
|
TipoDocto = "Cot"
|
|
Case "Remisión"
|
|
TipoDocto = "Rem"
|
|
Case "Pedido"
|
|
TipoDocto = "Ped"
|
|
Case "Anticipo"
|
|
TipoDocto = "Ant"
|
|
Case "Egreso"
|
|
TipoDocto = "Egs"
|
|
Case "Devolucion"
|
|
TipoDocto = "Dev"
|
|
End Select
|
|
|
|
pathPDF = Server.MapPath(String.Format("~/Empresas/{0}/PDF/{1}/{2}.pdf", UsuarioActual.CveEmpresa, TipoDocto, gvr.DataKey("SerieFolio").ToString))
|
|
|
|
If Not IO.File.Exists(pathPDF) Then
|
|
GenerarFacturaVentaDEV(gvr.DataKey("CveVenta").ToEntero, UsuarioActual.CveUsuario)
|
|
'ListaPDF.Add(New MFacturaDescarga() With {.CveVenta = gvr.DataKey("CveVenta").ToEntero, .PDF = GenerarFacturaVentaDEV(gvr.DataKey("CveVenta").ToEntero, 100)})
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
'D E S C A R G A I O N I C !
|
|
Dim DescargaZIP As Ionic.Zip.ZipFile = New Ionic.Zip.ZipFile()
|
|
Using DescargaZIP
|
|
DescargaZIP.UseZip64WhenSaving = Ionic.Zip.Zip64Option.AsNecessary
|
|
|
|
For Each gvr As GridViewRow In GvDatos.Rows
|
|
If gvr.DataKey("CveVenta").ToEntero > 0 Then
|
|
Select Case gvr.DataKey("TipoDocumento").ToString
|
|
Case "Ingreso"
|
|
TipoDocto = "Ing"
|
|
Case = "Cotización"
|
|
TipoDocto = "Cot"
|
|
Case "Remisión"
|
|
TipoDocto = "Rem"
|
|
Case "Pedido"
|
|
TipoDocto = "Ped"
|
|
Case "Anticipo"
|
|
TipoDocto = "Ant"
|
|
Case "Egreso"
|
|
TipoDocto = "Egs"
|
|
Case "Devolucion"
|
|
TipoDocto = "Dev"
|
|
End Select
|
|
|
|
pathPDF = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, TipoDocto, gvr.DataKey("SerieFolio").ToString)
|
|
|
|
If IO.File.Exists(pathPDF) Then
|
|
'NO AGREGAR ARCHIVOS REPETIDOS
|
|
Dim File As New IO.FileInfo(pathPDF)
|
|
If Not DescargaZIP.Any(Function(x) x.FileName.Contains(File.Name)) Then
|
|
DescargaZIP.AddFile(pathPDF, gvr.DataKey("TipoDocumento").ToString)
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
DescargaZIP.Save(Response.OutputStream)
|
|
End Using
|
|
Response.AddHeader("content-Disposition", "attachment; filename=ReporteVentasPDF.zip")
|
|
Response.ContentType = "application/zip"
|
|
Response.End()
|
|
End Sub
|
|
|
|
Private Sub BtnDescargarXML_Click(sender As Object, e As EventArgs) Handles BtnDescargarXML.Click
|
|
Dim pathXML As String
|
|
Dim TipoDocto As String = ""
|
|
|
|
'D E S C A R G A I O N I C !
|
|
Dim DescargaZIP As Ionic.Zip.ZipFile = New Ionic.Zip.ZipFile()
|
|
Using DescargaZIP
|
|
|
|
For Each gvr As GridViewRow In GvDatos.Rows
|
|
If gvr.DataKey("CveVenta").ToEntero > 0 Then
|
|
Select Case gvr.DataKey("TipoDocumento").ToString
|
|
Case "Ingreso"
|
|
TipoDocto = "Ing"
|
|
Case = "Cotización"
|
|
TipoDocto = "Cot"
|
|
Case "Remisión"
|
|
TipoDocto = "Rem"
|
|
Case "Pedido"
|
|
TipoDocto = "Ped"
|
|
Case "Anticipo"
|
|
TipoDocto = "Ant"
|
|
Case "Egreso"
|
|
TipoDocto = "Egs"
|
|
Case "Devolucion"
|
|
TipoDocto = "Dev"
|
|
End Select
|
|
|
|
pathXML = String.Format("{0}XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, TipoDocto, gvr.DataKey("SerieFolio").ToString)
|
|
|
|
If IO.File.Exists(pathXML) Then
|
|
'NO AGREGAR ARCHIVOS REPETIDOS
|
|
Dim File As New IO.FileInfo(pathXML)
|
|
If Not DescargaZIP.Any(Function(x) x.FileName.Contains(File.Name)) Then
|
|
DescargaZIP.AddFile(pathXML, gvr.DataKey("TipoDocumento").ToString)
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
DescargaZIP.Save(Response.OutputStream)
|
|
End Using
|
|
Response.AddHeader("content-Disposition", "attachment; filename=ReporteVentasXML.zip")
|
|
Response.ContentType = "application/zip"
|
|
Response.End()
|
|
End Sub
|
|
Private Function DescargarFactura(CveVenta As Integer, CveEmpresa As Integer, CveUsuarioCreo As Integer) As Byte()
|
|
Dim Url = New Uri(String.Format("{0}Compras/PopUpVerFactura.aspx?P={1}", "https://sig.adssistemas.mx/", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", CveVenta))))
|
|
Dim File As Byte() = Nothing
|
|
Try
|
|
Using httpClient = New HttpClient()
|
|
httpClient.Timeout = New TimeSpan(0, 15, 0)
|
|
Using request = New HttpRequestMessage(HttpMethod.Get, Url)
|
|
request.Headers.Add("ADSToken", Encripta(String.Format("CVEEMPRESA={0}&TICKS={1}&CVEUSUARIO={2}", CveEmpresa, DateTime.UtcNow.Ticks, CveUsuarioCreo)))
|
|
Dim response = httpClient.SendAsync(request).Result
|
|
If response.StatusCode = Net.HttpStatusCode.OK Then
|
|
File = response.Content.ReadAsByteArrayAsync().Result
|
|
End If
|
|
End Using
|
|
End Using
|
|
Catch ex As Exception
|
|
File = Nothing
|
|
OnError("Ocurrió un error al descargar la factura", ex)
|
|
End Try
|
|
|
|
Return File
|
|
End Function
|
|
|
|
Private Sub GenerarPDF(Optional Formato As String = "PDF")
|
|
If DtVentas IsNot Nothing Then
|
|
Dim Grupo, CveCliente, CveSucursal, CveSucursalEjec, Vendedor, CveUsuario, CveEstatusFactura, TipoDocto, CondicionesPago As String
|
|
Dim FechaIEjec, FechaFEjec As String
|
|
|
|
'Dim CveSubProyecto As Integer
|
|
Grupo = DdlGrupo.SelectedItem.Text
|
|
TipoDocto = If(DdlTipoComprobante.GetSelectedText = "", "", $" <b>Tipo Docto:</b> {DdlTipoComprobante.GetSelectedText}")
|
|
Dim FechaIn As String = $" <b>Fecha Inicio:</b> {txtFechaI.Text}"
|
|
Dim FechaFn As String = $" <b>Fecha Fin:</b> {txtFechaF.Text}"
|
|
If txtFechaI.Text = "" Then FechaIn = ""
|
|
If txtFechaF.Text = "" Then FechaFn = ""
|
|
FechaIEjec = $" <b>Fecha Inicio Ejec:</b> {TxtFechaIEjec.Text}"
|
|
FechaFEjec = $" <b>Fecha Fin Ejec:</b> {TxtFechaFEjec.Text}"
|
|
If TxtFechaIEjec.Text = "" Then FechaIEjec = ""
|
|
If TxtFechaFEjec.Text = "" Then FechaFEjec = ""
|
|
|
|
CveCliente = If(DdlClientes.SelectedValue = "-1", "", $" <b>Cliente:</b> {DdlClientes.SelectedText}")
|
|
CveSucursal = If(DdlSubProyecto.GetSelectedText = "", "", $" <b>Sucursal:</b> {DdlSubProyecto.GetSelectedText}")
|
|
CveSucursalEjec = If(DdlSubProyectoEjecucion.SelectedValue = "-1", "", $" <b>Sucursal Ejecución:</b> {DdlSubProyectoEjecucion.SelectedItem.Text}")
|
|
Vendedor = If(DdlVendedor.GetSelectedText = "", "", $" <b>Vendedor:</b> {DdlVendedor.GetSelectedText}")
|
|
CveUsuario = If(DdlUsuario.SelectedValue = "-1", "", $" <b>Usuario:</b> {DdlUsuario.SelectedItem.Text}")
|
|
CveEstatusFactura = If(DdlEstatus.GetSelectedText = "", "", $" <b>Estatus:</b> {DdlEstatus.GetSelectedText}")
|
|
CondicionesPago = If(DdlCondicionesPago.selectedValue = "-1", "", String.Format(" <b>Condiciones Pago</b>: {0}", DdlCondicionesPago.SelectedItem.Text))
|
|
|
|
|
|
Dim RutaFormato = String.Format("{0}Formatos\RepVentaDetalle.rdlc", UsuarioActual.Empresa.Ruta)
|
|
|
|
Dim Archivo As New System.IO.FileInfo(RutaFormato)
|
|
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
|
|
|
|
Dim logouri = String.Format("file://{0}", Imagen.FullName)
|
|
|
|
Dim dt As DataTable = DtVentas.FiltraParametros("(GPO IS NULL AND Cantidad IS NOT NULL) OR (GPO IS NOT NULL AND Cantidad IS NOT NULL)")
|
|
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("FechaInicio", FechaIn))
|
|
params.Add(New ReportParameter("FechaFin", FechaFn))
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString))
|
|
params.Add(New ReportParameter("TipoDocto", TipoDocto))
|
|
params.Add(New ReportParameter("AgrupadoPor", $"<b>Agrupado Por:</b> {Grupo} {TipoDocto} {FechaIn} {FechaFn} {FechaIEjec} {FechaFEjec} {CveCliente} {CveSucursal} {CveSucursalEjec} {Vendedor} {CveUsuario} {CveEstatusFactura} {CondicionesPago} "))
|
|
|
|
params.Add(New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
|
|
|
|
|
|
|
|
If Not Archivo.Exists Then
|
|
RutaFormato = "Empresas/Grales/Formatos/RepVentaDetalle.rdlc"
|
|
End If
|
|
|
|
ImprimirPDF(RutaFormato, dt, params, String.Format("ReporteVentaDetalle-{0}", Now.ToDateTime.ToShortDateString), Formato:=Formato)
|
|
Else
|
|
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Protected Sub ImgImprimir_Click(sender As Object, e As EventArgs) Handles ImgImprimir.Click
|
|
GenerarPDF()
|
|
End Sub
|
|
|
|
Private Function GenerarFacturaVentaDEV(CveVenta As Integer, CveUsuario As Integer) As Byte()
|
|
|
|
Return DescargarFactura(CveVenta, UsuarioActual.CveEmpresa, CveUsuario)
|
|
|
|
End Function
|
|
|
|
#End Region
|
|
|
|
#Region "GRAFICA"
|
|
|
|
Protected Sub LnkVerGrafica_Click(sender As Object, e As EventArgs)
|
|
If Not DtVentas IsNot Nothing AndAlso DtVentas.Rows.Count > 0 Then
|
|
Alert("No hay datos disponibles", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
LblTituloGrafica.Text = $"Agrupado por: {Agrupador}"
|
|
RegistraScript("$('#DivModalGrafica').modal('show')")
|
|
CambioGrafica()
|
|
End Sub
|
|
|
|
Private Sub CambioGrafica()
|
|
Dim Dt As New DataTable()
|
|
Dt.Columns.Add("Texto")
|
|
Dt.Columns.Add("Valor")
|
|
Dt.Columns.Add("Color")
|
|
Dt.Columns.Add("Moneda")
|
|
Dim RowColorIndex As Integer = 0
|
|
For Each Dr As DataRow In DtVentas.FiltraParametros("(GPO IS NULL AND Cantidad IS NOT NULL) OR (GPO IS NOT NULL AND Cantidad IS NOT NULL)").Rows
|
|
If Not Dr("CveVenta").ToString.ToEntero > 0 Then
|
|
Dim Row As DataRow = Nothing
|
|
Row = Dt.NewRow()
|
|
Row("Texto") = $"{Dr("GPO").ToString} {GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}"
|
|
Select Case DdlVer.SelectedValue.ToEntero
|
|
Case 1
|
|
Row("Valor") = Dr("Total").ToString.FormatoNumero
|
|
Case 2
|
|
Row("Valor") = Dr("SubTotal").ToString.FormatoNumero
|
|
Case 3
|
|
Row("Valor") = Dr("IVA").ToString.FormatoNumero
|
|
End Select
|
|
Row("Color") = Colors(RowColorIndex)
|
|
Row("Moneda") = Dr("Moneda").ToString
|
|
Dt.Rows.Add(Row)
|
|
RowColorIndex += 1
|
|
If RowColorIndex >= Colors.Length Then RowColorIndex = 0
|
|
End If
|
|
Next
|
|
|
|
Dim query = From s In Dt.AsEnumerable() Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()}
|
|
Dim json = Newtonsoft.Json.JsonConvert.SerializeObject(query)
|
|
Select Case DdlGrafica.SelectedValue.ToEntero
|
|
Case 1
|
|
RegistraScript($"CargaGraficaBarras({json})", "22")
|
|
Case 2
|
|
RegistraScript($"CargaGraficaPastel({json})", "22")
|
|
End Select
|
|
UPModalProd.Update()
|
|
End Sub
|
|
Protected Sub DdlGrafica_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
CambioGrafica()
|
|
End Sub
|
|
|
|
Protected Sub DdlVer_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
CambioGrafica()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
|
|
End Class
|