245 lines
10 KiB
VB.net
245 lines
10 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports Extensiones
|
|
Imports Microsoft.Reporting.WebForms
|
|
Imports System.Data
|
|
|
|
|
|
Partial Class Ventas_RepAuxiliarFacturas
|
|
Inherits ClsPaginas
|
|
#Region "P R O P I E D A D E S"
|
|
|
|
Private Property DtVentas As DataTable
|
|
Get
|
|
Return DirectCast(ViewState("DtVentas"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtVentas") = 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
|
|
Private Property TCEspecifico As Double
|
|
Get
|
|
Return ViewState("TCEspecifico").ToString.ToDouble
|
|
End Get
|
|
|
|
Set(value As Double)
|
|
ViewState("TCEspecifico") = 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
|
|
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
txtFechaI.Text = String.Format("01{0:/MM/yyyy}", NowADS())
|
|
CargaCombos()
|
|
End If
|
|
End Sub
|
|
|
|
#Region "C A R G A - C O M B O S"
|
|
'Private Sub CargaClientes()
|
|
|
|
' DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
'End Sub
|
|
|
|
Protected Sub DdlTipoComprobante_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
DdlEstatus.Items.Clear()
|
|
If DdlTipoComprobante.SelectedValue <> "-1" Then
|
|
DdlEstatus.DataSource = GlobalDTEstatusFactura.FiltraParametros(String.Format("TipoDocto = '{0}'", DdlTipoComprobante.SelectedValue))
|
|
Else
|
|
DdlEstatus.DataSource = GlobalDTEstatusFactura
|
|
|
|
End If
|
|
DdlEstatus.Items.Add(New ListItem("Todos", "-1"))
|
|
DdlEstatus.DataBind()
|
|
DdlEstatus.SelectedValueExist("3")
|
|
End Sub
|
|
|
|
Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProyecto.SelectedIndexChanged
|
|
CargarSubProyecto(DdlSubProyecto, DdlProyecto.SelectedValue)
|
|
End Sub
|
|
|
|
Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlClasificacion.SelectedIndexChanged
|
|
If UsuarioActual.Empresa.Funcionalidad(105) = "" Then
|
|
DdlPS.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero)
|
|
DdlPS.DataBind()
|
|
DdlPS.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
Else
|
|
DdlPS.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue)
|
|
DdlPS.SelectedText = "Todos"
|
|
DdlPS.SelectedValue = "-1"
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaCombos()
|
|
'Cargo Clientes
|
|
'CargaClientes()
|
|
|
|
'Cargo Clasificaciones
|
|
DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa)
|
|
DdlClasificacion.DataBind()
|
|
|
|
'Vendedor
|
|
DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa)
|
|
DdlVendedor.DataBind()
|
|
|
|
|
|
'Carga Productos
|
|
DdlPS.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then
|
|
DdlPS.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue)
|
|
DdlPS.SelectedText = ""
|
|
DdlPS.SelectedValue = "-1"
|
|
Else
|
|
DdlPS.ddl.Items.Clear()
|
|
DdlPS.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero)
|
|
DdlPS.ddl.DataBind()
|
|
DdlPS.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1"))
|
|
End If
|
|
|
|
'CargaEstatus
|
|
DdlEstatus.DataSource = GlobalDTEstatusFactura.FiltraParametros(" CveEstatusFactura NOT IN (1, 4, 5) ")
|
|
DdlEstatus.DataBind()
|
|
DdlEstatus.Items.Add(New ListItem("Canceladas", "4"))
|
|
If UsuarioActual.Empresa.TipoFacturacion = "CFDi" Then
|
|
DdlEstatus.SelectedIndex = 2
|
|
Else
|
|
DdlEstatus.SelectedIndex = 1
|
|
End If
|
|
|
|
CargarCentrosDeCosto(DdlProyecto, DdlSubProyecto, LblProyecto, LblSubProyecto, divProyecto:=DivProyecto)
|
|
|
|
TipoCambio = 1
|
|
TCEspecifico = 0
|
|
|
|
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)
|
|
DdlClientes.DataBind()
|
|
DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "C A R G A - D A T O S"
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click
|
|
CargaDatos()
|
|
UPDatos.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaDatos()
|
|
Dim TipoComprobante As String = If(DdlTipoComprobante.GetSelectedValuesM = "", "-1", DdlTipoComprobante.GetSelectedValuesM)
|
|
Dim FechaI, FechaF As Date
|
|
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.ToDate, MinFecha)
|
|
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.ToDate, MaxFecha)
|
|
|
|
If RblTipoCambio.SelectedValue.ToEntero = 3 And TxtEspecifico.Text <> "" Then TCEspecifico = TxtEspecifico.Text.ToDouble Else TCEspecifico = -1
|
|
|
|
Dim CveCliente As Integer = If(DdlClientes.SelectedValue.ToEntero > 0, DdlClientes.SelectedValue.ToEntero, -1)
|
|
|
|
Dim ObjVentas As New ClsVentas()
|
|
If ObjVentas.GetRepAuxliarFacturas(DdlProyecto.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlClasificacion.SelectedValue.ToEntero, DdlPS.SelectedValue.ToEntero,
|
|
FechaI, FechaF, CveCliente, DdlVendedor.SelectedValue.ToEntero, -1, DdlEstatus.SelectedValue.ToEntero, UsuarioActual.CveEmpresa,
|
|
CveUsuarioConsulta:=UsuarioActual.CveUsuario, TipoDocto:=TipoComprobante, TipoCambio:=TipoCambio, TCEspecifico:=TCEspecifico) Then
|
|
DtVentas = ObjVentas.DtResultados.Copy()
|
|
End If
|
|
ObjVentas.Dispose()
|
|
|
|
GvDatos.DataSource = DtVentas
|
|
GvDatos.DataBind()
|
|
End Sub
|
|
|
|
Protected Sub BtnTipoCambio_Click1(sender As Object, e As EventArgs)
|
|
CargaDatos()
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivTipoCambio"))
|
|
UPDatos.Update()
|
|
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
|
|
Select Case e.Row.DBCampo("TipoFila")
|
|
Case "1"
|
|
e.Row.CssClass = "Totales"
|
|
Case "2"
|
|
e.Row.CssClass = "SubTotales"
|
|
e.Row.FCLiteral("LtlGrupo").Text = String.Format("<a target=""_blank"" Class=""{0}"" href=""{1}"">{2}</a>", "SubTotales", String.Format("/Ventas/Ventas.aspx?CveVenta={0}", e.Row.DBCampo("CveVenta")), e.Row.DBCampo("Gpo"))
|
|
End Select
|
|
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
|
|
GvDatos.ExportToExcel("RepAuxiliarFacturas" & NowADS().ToShortDateString)
|
|
End Sub
|
|
|
|
Protected Sub LnkPdf_Click(sender As Object, e As EventArgs) Handles LnkPdf.Click
|
|
If GvDatos.Rows.Count > 0 Then
|
|
GenerarPDF()
|
|
Else
|
|
Alert("No hay datos para imprimir")
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub GenerarPDF()
|
|
Dim FechaI, FechaF As Date
|
|
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.ToDate, MinFecha)
|
|
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.ToDate, MaxFecha)
|
|
|
|
Dim Cliente = If(DdlClientes.SelectedText = "", "", $" <b>Cliente:</b> {DdlClientes.SelectedText}")
|
|
Dim FechaInicio = If(txtFechaI.Text = "", "", $" <b>Fecha Inicio:</b> {txtFechaI.Text}")
|
|
Dim FechaFin = If(txtFechaF.Text = "", "", $" <b>Fecha Fin:</b> {txtFechaF.Text}")
|
|
Dim Clasificacion = If(DdlClasificacion.SelectedValue = "-1", "", $" <b>Clasificación:</b> {DdlClasificacion.SelectedItem.Text}")
|
|
Dim PS = If(DdlPS.SelectedValue = "-1", "", $" <b>P.S.:</b> {DdlPS.SelectedText}")
|
|
Dim Proyecto = If(DdlSubProyecto.SelectedValue = "-1", "", $" <b>Proyecto:</b> {DdlSubProyecto.SelectedItem.Text}")
|
|
Dim Estatus = If(DdlEstatus.SelectedValue = "-1", "", $" <b>Estatus:</b> {DdlEstatus.SelectedItem.Text}")
|
|
|
|
|
|
If DtVentas IsNot Nothing AndAlso DtVentas.Rows.Count > 0 Then
|
|
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
|
|
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("FechaInicio", If(txtFechaI.Text <> "", FechaI.ToShortDateString, "")))
|
|
params.Add(New ReportParameter("FechaFin", If(txtFechaF.Text <> "", FechaF.ToShortDateString, "")))
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
params.Add(New ReportParameter("FechaImpresion", NowADS().ToDateTime.ToShortDateString))
|
|
params.Add(New ReportParameter("Filtros", $"{Cliente}{FechaInicio}{FechaFin}{Clasificacion}{PS}{Proyecto}{Estatus}"))
|
|
params.Add(New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepAuxiliarFacturas.rdlc", DtVentas, params, "ReporteAuxiliarFacturas")
|
|
Else
|
|
Alert("No hay información para mostrar.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
End Class
|