1028 lines
48 KiB
VB.net
1028 lines
48 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports System.IO
|
|
Imports System.IO.Compression
|
|
Imports Extensiones
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
Partial Class Ventas_RepProductosServiciosDetalle
|
|
Inherits ClsPaginas
|
|
|
|
#Region "PROPIEDADES"
|
|
Private Property TmpDT As DataTable
|
|
Get
|
|
Return CType(ViewState("TmpDT"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("TmpDT") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveMoneda As Integer
|
|
Get
|
|
Return CType(ViewState("CveMoneda"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMoneda") = value
|
|
End Set
|
|
End Property
|
|
Private Property TipoCambio As Integer
|
|
Get
|
|
Return CType(ViewState("TipoCambio"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("TipoCambio") = value
|
|
End Set
|
|
End Property
|
|
Private Property TCEspecifico As Double
|
|
Get
|
|
Return CType(ViewState("TCEspecifico"), Double)
|
|
End Get
|
|
Set(value As Double)
|
|
ViewState("TCEspecifico") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtColor As DataTable
|
|
Get
|
|
Return DirectCast(ViewState("DtColor"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtColor") = 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 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
|
|
|
|
#End Region
|
|
|
|
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")
|
|
SetValues()
|
|
CargaParametrosDetalle()
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
|
|
|
|
LblServicioDomicilioFiltro.Visible = True
|
|
DVServicioDomicilio.Visible = True
|
|
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#Region " CARGA DATOS INICIALES "
|
|
|
|
Private Sub CargaGrupo()
|
|
DdlGrupo.Items.Insert(0, New ListItem("Categoria", "3"))
|
|
DdlGrupo.Items.Insert(1, New ListItem("Clasificacion", "4"))
|
|
DdlGrupo.Items.Insert(2, New ListItem("Productos-Servicios", "5"))
|
|
DdlGrupo.Items.Insert(3, New ListItem("Año", "6"))
|
|
DdlGrupo.Items.Insert(4, New ListItem("Mes", "7"))
|
|
DdlGrupo.Items.Insert(5, New ListItem("Año/Mes", "8"))
|
|
DdlGrupo.Items.Insert(6, New ListItem("Fecha", "9"))
|
|
DdlGrupo.Items.Insert(7, New ListItem("Cliente", "10"))
|
|
DdlGrupo.Items.Insert(8, New ListItem("Vendedor", "12"))
|
|
DdlGrupo.Items.Insert(9, New ListItem("Usuario", "13"))
|
|
DdlGrupo.Items.Insert(10, New ListItem("Estatus Fact.", "14"))
|
|
DdlGrupo.Items.Insert(11, New ListItem("Año Ejec.", "15"))
|
|
DdlGrupo.Items.Insert(12, New ListItem("Mes Ejec.", "16"))
|
|
DdlGrupo.Items.Insert(13, New ListItem("Año/Mes Ejec.", "17"))
|
|
DdlGrupo.Items.Insert(14, New ListItem("Fecha Ejec.", "18"))
|
|
DdlGrupo.Items.Insert(15, New ListItem("Cliente - PS", "20"))
|
|
DdlGrupo.Items.Insert(15, New ListItem("Cliente Sucursal", "26"))
|
|
DdlGrupo.DataBind()
|
|
DdlGrupo.SelectedValueExist("8")
|
|
End Sub
|
|
|
|
Private Sub CargaTipoCentroCosto()
|
|
|
|
If UsuarioActual.Empresa.Tipo_CentroCosto = 1 Then
|
|
DdlSubProyecto.Items.Clear()
|
|
DivProyecto.Visible = False
|
|
LblProyecto.Visible = False
|
|
LblSubProyecto.InnerText = "Sucursal:"
|
|
DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1)
|
|
DdlSubProyecto.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
DdlSubProyecto.DataBind()
|
|
|
|
DdlSubProyectoEjecucion.Items.Clear()
|
|
LblSubProyectoEjecucion.InnerText = "Sucursal Ejecución:"
|
|
DdlSubProyectoEjecucion.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1)
|
|
DdlSubProyectoEjecucion.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
DdlSubProyectoEjecucion.DataBind()
|
|
|
|
DdlGrupo.Items.Insert(0, New ListItem("Sucursal", "2"))
|
|
DdlGrupo.Items.Insert(16, New ListItem("Sucursal Ejec.", "19"))
|
|
DdlGrupo.DataBind()
|
|
|
|
ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 2 Then
|
|
DdlSubProyecto.Items.Clear()
|
|
DivProyecto.Visible = False
|
|
LblProyecto.Visible = False
|
|
LblSubProyecto.InnerText = "Proyecto:"
|
|
DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1)
|
|
DdlSubProyecto.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
DdlSubProyecto.DataBind()
|
|
|
|
DdlSubProyectoEjecucion.Items.Clear()
|
|
LblSubProyectoEjecucion.InnerText = "Proyecto Ejecución:"
|
|
DdlSubProyectoEjecucion.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1)
|
|
DdlSubProyectoEjecucion.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
DdlSubProyectoEjecucion.DataBind()
|
|
|
|
DdlGrupo.Items.Insert(0, New ListItem("Proyecto", "2"))
|
|
DdlGrupo.Items.Insert(16, New ListItem("Proyecto Ejec.", "19"))
|
|
DdlGrupo.DataBind()
|
|
ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 3 Then
|
|
DdlGrupo.Items.Insert(0, New ListItem("Proyecto", "1"))
|
|
DdlGrupo.Items.Insert(1, New ListItem("SubProyecto", "2"))
|
|
DdlGrupo.Items.Insert(17, New ListItem("SubProyecto Ejec.", "19"))
|
|
DdlGrupo.DataBind()
|
|
ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 4 Then
|
|
LblProyecto.InnerText = "Sucursal:"
|
|
LblSubProyecto.InnerText = "Proyecto:"
|
|
|
|
LblSubProyectoEjecucion.InnerText = "Proyecto Ejecución:"
|
|
|
|
DdlGrupo.Items.Insert(0, New ListItem("Proyecto", "1"))
|
|
DdlGrupo.Items.Insert(1, New ListItem("SubProyecto", "2"))
|
|
DdlGrupo.Items.Insert(17, New ListItem("SubProyecto Ejec.", "19"))
|
|
DdlGrupo.DataBind()
|
|
|
|
ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 5 Then
|
|
LblProyecto.InnerText = "Proyecto:"
|
|
LblSubProyecto.InnerText = "Sucursal:"
|
|
LblSubProyectoEjecucion.InnerText = "Sucursal Ejecución:"
|
|
|
|
DdlGrupo.Items.Insert(0, New ListItem("Proyecto", "1"))
|
|
DdlGrupo.Items.Insert(1, New ListItem("SubProyecto", "2"))
|
|
DdlGrupo.Items.Insert(17, New ListItem("SubProyecto Ejec.", "19"))
|
|
DdlGrupo.DataBind()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub SetValues()
|
|
txtFechaI.Text = Now.ToShortDateString
|
|
txtFechaF.Text = Now.ToShortDateString
|
|
|
|
'Cargo Proyectos
|
|
DdlProyecto.DataSource = GlobalDTProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1)
|
|
DdlProyecto.DataBind()
|
|
|
|
'Cargo Categorias
|
|
DdlCategoria.DataSource = GlobalDTGralCategorias(UsuarioActual.CveEmpresa)
|
|
DdlCategoria.DataBind()
|
|
|
|
'Cargo Clasificaciones
|
|
DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa)
|
|
DdlClasificacion.DataBind()
|
|
|
|
CargaClientes()
|
|
'Dim ObjClientes As New ClsClientes
|
|
'If ObjClientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
|
|
' DdlClientes.DataSource = ObjClientes.DtResultados
|
|
'Else
|
|
' DdlClientes.DataSource = Nothing
|
|
'End If
|
|
'ObjClientes.Dispose()
|
|
'DdlClientes.DataBind()
|
|
|
|
|
|
'CargaSubProyectos
|
|
DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1)
|
|
DdlSubProyecto.DataBind()
|
|
DdlSubProyectoEjecucion.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1)
|
|
DdlSubProyectoEjecucion.DataBind()
|
|
|
|
'Vendedor
|
|
DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=-1).FiltraParametros("VendedorTipo in (1,4)") 'vendedores y vendedores de piso
|
|
DdlVendedor.DataBind()
|
|
|
|
If UsuarioActual.CveVendedor > 0 AndAlso Not UsuarioActual.TienePermisoProceso(263) Then
|
|
DdlVendedor.SelectedValueExist(UsuarioActual.CveVendedor.ToString())
|
|
DdlVendedor.Attributes.Add("disabled", "disabled")
|
|
DdlVendedor.Enabled = False
|
|
End If
|
|
|
|
'CargaUsuarios
|
|
DdlUsuario.DataSource = GlobalDTUsuarios.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
DdlUsuario.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("Todos", "-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
|
|
|
|
'Carga Clasificacion Cliente
|
|
DdlClienteClasificacion.DataSource = GlobalDTClienteClasificaciones(UsuarioActual.CveEmpresa)
|
|
DdlClienteClasificacion.DataBind()
|
|
DdlClienteClasificacion.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
|
|
If UsuarioActual.CveEmpresa.Contiene(141) Then
|
|
DivDdlTipo.Visible = True
|
|
lblDdlTipoPSDes.Visible = True
|
|
End If
|
|
DdlTipoPSDes.Items.Clear()
|
|
DdlTipoPSDes.DataSource = GlobalDTClasificacionesDetalle(UsuarioActual.CveEmpresa)
|
|
DdlTipoPSDes.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlTipoPSDes.DataBind()
|
|
|
|
CargaGrupo()
|
|
CargaTipoCentroCosto()
|
|
CreaDataTableColor()
|
|
|
|
TCEspecifico = 0
|
|
TipoCambio = 1
|
|
|
|
If UsuarioActual.TienePermisoProceso(339) Then
|
|
GvDatos.Columns(10).Visible = False
|
|
GvDatos.Columns(11).Visible = False
|
|
GvDatos.Columns(12).Visible = False
|
|
GvDatos.Columns(13).Visible = False
|
|
GvDatos.Columns(14).Visible = False
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaSucursales(CveCliente As Integer, CveClienteSucursal As Integer)
|
|
|
|
DdlClienteSucursal.Items.Clear()
|
|
|
|
|
|
|
|
If CveCliente > 0 Then
|
|
|
|
Dim ObjCliente As New ClsClientes
|
|
If ObjCliente.GetSucursales(CveCliente) Then
|
|
If ObjCliente.DtResultados.Rows.Count > 0 Then
|
|
DdlClienteSucursal.DataSource = ObjCliente.DtResultados
|
|
Else
|
|
DdlClienteSucursal.DataSource = Nothing
|
|
End If
|
|
End If
|
|
ObjCliente.Dispose()
|
|
|
|
DdlClienteSucursal.DataBind()
|
|
|
|
End If
|
|
|
|
|
|
DdlClienteSucursal.Items.Insert(0, New ListItem("Todas", "-1"))
|
|
DdlClienteSucursal.Items.Insert(1, New ListItem("Sin Sucursal", "0"))
|
|
|
|
DdlClienteSucursal.SelectedValueExist(CveClienteSucursal)
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaParametrosDetalle()
|
|
Dim CveProyecto, CveSubProyecto, CveCategoria, CveClasificacion, CveClasificacion2, CvePS, FechaI, FechaF, FechaIEjec, FechaFEjec, CveSubProyectoEjecucion, CveEstatus, CveUsuario, Anio, Mes, AnioMes, Fecha, AnioEjec, MesEjec, AnioMesEjec, FechaEjec, GPO, TipoDocto, CveClienteClasificacion As String
|
|
Dim CveCliente As Integer = -1
|
|
Dim CveProveedorCompra As Integer = -1
|
|
Dim CveVendedor As Integer
|
|
Dim CveMarca As Integer = -1
|
|
Dim CveClasificacionDetalle As Integer = -1
|
|
Dim CveClienteSucursal As Integer = -1
|
|
|
|
|
|
GPO = If(Request("Grupo") IsNot Nothing AndAlso Request("Grupo").ToEntero() > 0, Request("Grupo").ToEntero(), -1).ToString
|
|
|
|
CveProyecto = If(Request("CveProyecto") IsNot Nothing AndAlso Request("CveProyecto").ToEntero() > 0, Request("CveProyecto").ToEntero(), -1).ToString
|
|
CveSubProyecto = If(Request("CveSubProyecto") IsNot Nothing AndAlso Request("CveSubProyecto").ToEntero() > 0, Request("CveSubProyecto").ToEntero(), -1).ToString
|
|
CveCategoria = If(Request("CveCategoria") IsNot Nothing AndAlso Request("CveCategoria").ToEntero() > 0, Request("CveCategoria").ToEntero(), -1).ToString
|
|
CveClasificacion = If(Request("CveClasificacion") IsNot Nothing AndAlso Request("CveClasificacion").ToEntero() > 0, Request("CveClasificacion").ToEntero(), -1).ToString
|
|
CvePS = If(Request("CvePS") IsNot Nothing AndAlso Request("CvePS").ToEntero() > 0, Request("CvePS").ToEntero(), -1).ToString
|
|
CveClasificacion2 = If(Request("CveClasificacion2") IsNot Nothing AndAlso Request("CveClasificacion2").ToEntero() > 0, Request("CveClasificacion2").ToEntero(), -1).ToString
|
|
|
|
Anio = If(Request("Anio") IsNot Nothing AndAlso Request("Anio").ToEntero() > 0, Request("Anio").ToEntero(), -1).ToString
|
|
Mes = If(Request("Mes") IsNot Nothing AndAlso Request("Mes").ToEntero() > 0, Request("Mes").ToEntero(), -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 AndAlso Request("AnioEjec").ToEntero() > 0, Request("AnioEjec").ToEntero(), -1).ToString
|
|
MesEjec = If(Request("MesEjec") IsNot Nothing AndAlso Request("MesEjec").ToEntero() > 0, Request("MesEjec").ToEntero(), -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("FechaEI") IsNot Nothing, Request("FechaEI").ToString, "-1").ToString
|
|
FechaFEjec = If(Request("FechaEF") IsNot Nothing, Request("FechaEF").ToString, "-1").ToString
|
|
|
|
CveCliente = If(Request("CveCliente") IsNot Nothing AndAlso Request("CveCliente").ToEntero() > 0, Request("CveCliente").ToEntero(), -1).ToString.ToEntero
|
|
CveSubProyectoEjecucion = If(Request("CveSubProyectoEjecucion") IsNot Nothing AndAlso Request("CveSubProyectoEjecucion").ToEntero() > 0, Request("CveSubProyectoEjecucion").ToEntero(), -1).ToString
|
|
CveVendedor = If(Request("CveVendedor") IsNot Nothing AndAlso Request("CveVendedor").ToEntero() >= 0, Request("CveVendedor").ToEntero(), -1).ToString.ToEntero
|
|
CveEstatus = If(Request("CveEstatus") IsNot Nothing AndAlso Request("CveEstatus").ToEntero() > 0, Request("CveEstatus").ToEntero(), -1).ToString
|
|
CveUsuario = If(Request("CveUsuario") IsNot Nothing AndAlso Request("CveUsuario").ToEntero() > 0, Request("CveUsuario").ToEntero(), -1).ToString
|
|
TipoDocto = If(Request("TipoDocto") IsNot Nothing AndAlso Request("TipoDocto").ToString() <> "-1", Request("TipoDocto").ToString(), "-1").ToString
|
|
TipoCambio = If(Request("TipoCambio") IsNot Nothing AndAlso Request("TipoCambio").ToEntero() <> -1, Request("TipoCambio").ToEntero(), 1).ToEntero
|
|
TCEspecifico = If(Request("TCEspecifico") IsNot Nothing AndAlso Request("TCEspecifico").ToDouble() <> 0, Request("TCEspecifico").ToDouble(), 0).ToString.ToDouble
|
|
CveClienteClasificacion = If(Request("CveClienteClasificacion") IsNot Nothing AndAlso Request("CveClienteClasificacion").ToEntero() > 0, Request("CveClienteClasificacion").ToEntero(), -1).ToString
|
|
CveProveedorCompra = If(Request("CveProveedorCompra") IsNot Nothing AndAlso Request("CveProveedorCompra").ToEntero() > 0, Request("CveProveedorCompra").ToEntero(), -1).ToString.ToEntero
|
|
CveMarca = If(Request("CveMarca") IsNot Nothing AndAlso Request("CveMarca").ToEntero() > 0, Request("CveMarca").ToEntero(), -1).ToString.ToEntero
|
|
CveClasificacionDetalle = If(Request("CveClasificacionDetalle") IsNot Nothing AndAlso Request("CveClasificacionDetalle").ToEntero() > 0, Request("CveClasificacionDetalle").ToEntero(), -1).ToString.ToEntero
|
|
|
|
CveClienteSucursal = If(Request("CveClienteSucursal") IsNot Nothing AndAlso Request("CveClienteSucursal").ToEntero() >= 0, Request("CveClienteSucursal").ToEntero(), -1).ToString.ToEntero
|
|
'CveEstatusFactura = If(Request("CveEstatusFactura") IsNot Nothing AndAlso Request("CveEstatusFactura").ToEntero() > 0, Request("CveEstatusFactura").ToEntero(), -1).ToString.ToEntero
|
|
|
|
DdlGarantia.SelectedValueExist(If(Request("EsGarantia") IsNot Nothing AndAlso Request("EsGarantia").ToEntero() > 0, Request("EsGarantia").ToEntero(), -1).ToString)
|
|
DdlCondicionesPago.SelectedValueExist(If(Request("CveCondicionesPago") IsNot Nothing AndAlso Request("CveCondicionesPago").ToEntero() > 0, Request("CveCondicionesPago").ToEntero(), -1).ToString)
|
|
DdlDistribuidor.SelectedValueExist(If(Request("EsDistribuidor") IsNot Nothing AndAlso Request("EsDistribuidor").ToEntero() > 0, Request("EsDistribuidor").ToEntero(), -1).ToString)
|
|
ChkLitraje.Checked = Request("MostrarLitraje") IsNot Nothing AndAlso Request("MostrarLitraje").ToEntero() > 0
|
|
|
|
TipoCliente = If(Request("TipoCliente") IsNot Nothing, Request("TipoCliente").ToString, "-1").ToString.ToEntero
|
|
|
|
DdlTipoCliente.SelectedValueExist(TipoCliente)
|
|
|
|
DdlServicioDomicilio.SelectedValue = If(Request("ServicioDomicilio") IsNot Nothing, Request("ServicioDomicilio").ToString, "-1").ToString
|
|
|
|
|
|
If Fecha <> "-1" Then
|
|
txtFechaI.Text = Fecha
|
|
txtFechaF.Text = Fecha
|
|
End If
|
|
|
|
If FechaI <> "-1" Then
|
|
txtFechaI.Text = FechaI
|
|
End If
|
|
|
|
If FechaF <> "-1" Then
|
|
txtFechaF.Text = FechaF
|
|
End If
|
|
|
|
If Anio <> "-1" Then
|
|
txtFechaI.Text = String.Format("01/01/{0}", Anio)
|
|
txtFechaF.Text = String.Format("31/12/{0}", Anio)
|
|
End If
|
|
|
|
If AnioMes.Trim.Length > 5 Then
|
|
Dim FechaFtemporal As String = ""
|
|
If AnioMes.Trim.Length = 7 Then
|
|
txtFechaI.Text = If(AnioMes <> "-1", String.Format("01/{0}/{1}", AnioMes.Substring(5, 2).PadLeft(2, "0"c), AnioMes.Substring(0, 4)), txtFechaI.Text)
|
|
FechaFtemporal = $"01/{AnioMes.Substring(5, 2).PadLeft(2, "0"c)}/{AnioMes.Substring(0, 4)}"
|
|
|
|
If FechaF = "-1" Then
|
|
txtFechaF.Text = String.Format("{2}/{0}/{1}", AnioMes.Substring(5, 2).PadLeft(2, "0"c), AnioMes.Substring(0, 4), FechaFtemporal.ToDate.LastDayOfMonth.Day)
|
|
Else
|
|
Dim FechaFRef As DateTime = FechaF.ToDateTime
|
|
Dim FechaFMonth As DateTime = String.Format("{2}/{0}/{1}", AnioMes.Substring(5, 2).PadLeft(2, "0"c), AnioMes.Substring(0, 4), FechaFtemporal.ToDate.LastDayOfMonth.Day).ToDate()
|
|
|
|
If FechaFRef > FechaFMonth Then
|
|
txtFechaF.Text = FechaFMonth.ToString("dd/MM/yyyy")
|
|
Else
|
|
txtFechaF.Text = FechaFRef.ToString("dd/MM/yyyy")
|
|
End If
|
|
|
|
End If
|
|
|
|
Else
|
|
|
|
If FechaI = "-1" Then
|
|
txtFechaI.Text = If(AnioMes <> "-1", String.Format("01/{0}/{1}", AnioMes.Substring(5, 1).PadLeft(2, "0"c), AnioMes.Substring(0, 4)), txtFechaI.Text)
|
|
Else
|
|
txtFechaI.Text = FechaI
|
|
End If
|
|
|
|
FechaFtemporal = $"01/{AnioMes.Substring(5, 1).PadLeft(2, "0"c)}/{AnioMes.Substring(0, 4)}"
|
|
|
|
If FechaF = "-1" Then
|
|
txtFechaF.Text = String.Format("{2}/{0}/{1}", AnioMes.Substring(5, 1).PadLeft(2, "0"c), AnioMes.Substring(0, 4), FechaFtemporal.ToDate.LastDayOfMonth.Day)
|
|
Else
|
|
Dim FechaFRef As DateTime = FechaF.ToDateTime
|
|
Dim FechaFMonth As DateTime = String.Format("{2}/{0}/{1}", AnioMes.Substring(5, 1).PadLeft(2, "0"c), AnioMes.Substring(0, 4), FechaFtemporal.ToDate.LastDayOfMonth.Day).ToDate
|
|
|
|
If FechaFRef > FechaFMonth Then
|
|
txtFechaF.Text = FechaFMonth.ToString("dd/MM/yyyy")
|
|
Else
|
|
txtFechaF.Text = FechaFRef.ToString("dd/MM/yyyy")
|
|
End If
|
|
End If
|
|
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
txtFechaI.Text = If(Mes <> "-1", String.Format("01/{0}/0001", Mes), txtFechaI.Text)
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(531).ToEntero = 1 Then
|
|
DvLitraje.Visible = True
|
|
'garantia
|
|
DdlClasificacion2.DataSource = GlobalDTClasificaciones2(UsuarioActual.CveEmpresa)
|
|
DdlClasificacion2.DataBind()
|
|
divClasif2texto.Visible = True
|
|
divClasif2.Visible = True
|
|
|
|
divgarantia1.Visible = True
|
|
divgarantia2.Visible = True
|
|
divdistribuidor1.Visible = True
|
|
divdistribuidor2.Visible = True
|
|
End If
|
|
|
|
If FechaEjec <> "-1" Then
|
|
TxtFechaIEjec.Text = FechaEjec
|
|
TxtFechaFEjec.Text = FechaEjec
|
|
End If
|
|
If FechaIEjec <> "-1" Then
|
|
TxtFechaIEjec.Text = FechaIEjec
|
|
End If
|
|
If FechaFEjec <> "-1" Then
|
|
TxtFechaFEjec.Text = FechaFEjec
|
|
End If
|
|
|
|
If AnioMesEjec.Trim.Length > 5 Then
|
|
TxtFechaIEjec.Text = If(AnioMesEjec <> "-1", String.Format("01/{0}/{1}", AnioMesEjec.Substring(5, 1).PadLeft(2, "0"c), AnioMesEjec.Substring(0, 4)), TxtFechaIEjec.Text)
|
|
Dim FechaFEjectemporal = $"01/{AnioMesEjec.Substring(5, 1).PadLeft(2, "0"c)}/{AnioMesEjec.Substring(0, 4)}"
|
|
TxtFechaFEjec.Text = String.Format("{2}/{0}/{1}", AnioMesEjec.Substring(5, 1).PadLeft(2, "0"c), AnioMesEjec.Substring(0, 4), FechaFEjectemporal.ToDate.LastDayOfMonth.Day)
|
|
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)
|
|
|
|
Dim ModalidadContable As Boolean = CBool(If(Request("ModalidadContable") IsNot Nothing, Request("ModalidadContable").ToEntero(), 0))
|
|
|
|
ChkLecturaAdmin.Checked = Not ModalidadContable
|
|
|
|
CveMoneda = If(Request("CveMoneda") IsNot Nothing AndAlso Request("CveMoneda").ToEntero() > 0, Request("CveMoneda").ToEntero(), -1).ToEntero
|
|
DdlProyecto.SelectedValueExist(CveProyecto)
|
|
If DivProyecto.Visible Then CargaSubProyecto()
|
|
DdlSubProyecto.SelectedValueExist(CveSubProyecto)
|
|
DdlCategoria.SelectedValueExist(CveCategoria)
|
|
DdlClasificacion.SelectedValueExist(CveClasificacion)
|
|
DdlClasificacion2.SelectedValueExist(CveClasificacion2)
|
|
|
|
If CvePS.ToEntero > 0 Then
|
|
DdlPS.SelectedValue = CvePS
|
|
DdlPS.SelectedText = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS.ToEntero)(0)("PSCodigo").ToString
|
|
End If
|
|
|
|
DdlClienteClasificacion.SelectedValueExist(CveClienteClasificacion)
|
|
CargaClientes(CveCliente)
|
|
|
|
'DdlClientes.SelectedValueExist(CveCliente)
|
|
DdlSubProyectoEjecucion.SelectedValueExist(CveSubProyectoEjecucion)
|
|
If CveVendedor = 0 Then DdlVendedor.Items.Insert(0, New ListItem("Sin Asignar", "0"))
|
|
DdlVendedor.SelectedValueExist(CveVendedor)
|
|
DdlUsuario.SelectedValueExist(CveUsuario)
|
|
DdlTipoComprobante.SelectedValuesIfExistM(TipoDocto)
|
|
CargaEstatus()
|
|
DdlEstatus.SelectedValueExist(CveEstatus)
|
|
DdlGrupo.SelectedValueExist(GPO)
|
|
RblTipoCambio.SelectedValue = TipoCambio.ToString
|
|
If TipoCambio > 1 Then CveMoneda = -1
|
|
CargarMarcas(CveMarca)
|
|
|
|
CargaProvedores(CveProveedorCompra)
|
|
'If CveProveedorCompra.ToEntero > 0 Then DdlProveedor.SelectedValue = CveProveedorCompra
|
|
DdlTipoPSDes.SelectedValueExist(CveClasificacionDetalle)
|
|
|
|
CargaSucursales(DdlClientes.txtValue.Value.ToString.ToEntero, CveClienteSucursal)
|
|
' DdlEstatus.SelectedValueExist(CveEstatusFactura)
|
|
|
|
CargaDatos()
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " CARGA DATOS "
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click
|
|
CargaDatos()
|
|
UPDatos.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaDatos()
|
|
Dim ObjVentas As New ClsVentas()
|
|
Dim FechaI, FechaF, FechaIEjec, FechaFEjec As Date
|
|
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.ToDate, MinFecha)
|
|
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.ToDate, MaxFecha)
|
|
FechaIEjec = If(IsDate(TxtFechaIEjec.Text.Trim()), TxtFechaIEjec.Text.ToDate, MinFecha)
|
|
FechaFEjec = If(IsDate(TxtFechaFEjec.Text.Trim()), TxtFechaFEjec.Text.ToDate, MaxFecha)
|
|
Dim CveProveedorCompra As Integer = If(DdlProveedor.SelectedValue.ToEntero > 0, DdlProveedor.SelectedValue.ToEntero, -1)
|
|
Dim CveCliente As Integer = If(DdlClientes.SelectedValue.ToEntero > 0, DdlClientes.SelectedValue.ToEntero, -1)
|
|
Dim TipoComprobante As String = If(DdlTipoComprobante.GetSelectedValuesM = "", "-1", DdlTipoComprobante.GetSelectedValuesM)
|
|
|
|
If RblTipoCambio.SelectedValue.ToEntero = 3 And TxtEspecifico.Text <> "" Then TCEspecifico = TxtEspecifico.Text.ToDouble Else TCEspecifico = -1
|
|
|
|
If ObjVentas.GetRepProductosServiciosDetalle(DdlProyecto.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlCategoria.SelectedValue.ToEntero, DdlClasificacion.SelectedValue.ToEntero,
|
|
DdlPS.SelectedValue.ToEntero, FechaI, FechaF, -1, FechaIEjec, FechaFEjec, -1, CveCliente,
|
|
DdlSubProyectoEjecucion.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, DdlUsuario.SelectedValue.ToEntero, DdlEstatus.SelectedValue.ToEntero,
|
|
UsuarioActual.CveEmpresa, CveUsuarioConsulta:=UsuarioActual.CveUsuario, TipoDocto:=TipoComprobante, GPO:=DdlGrupo.SelectedValue.ToEntero, CveMoneda:=CveMoneda,
|
|
TipoCambio:=TipoCambio, TCEspecifico:=TCEspecifico, CveClienteClasificacion:=DdlClienteClasificacion.SelectedValue.ToEntero, CveProveedorCompra:=CveProveedorCompra,
|
|
CveMarca:=DdlMarcaPSDes.SelectedValue.ToEntero, CveClasificacionDetalle:=DdlTipoPSDes.SelectedValue.ToEntero(), TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero,
|
|
ModalidadContable:=Not ChkLecturaAdmin.Checked, MostrarLitraje:=ChkLitraje.Checked, EsGarantia:=DdlGarantia.SelectedValue.ToEntero, CveCondicionesPago:=DdlCondicionesPago.SelectedValue.ToEntero,
|
|
EsDistribuidor:=DdlDistribuidor.SelectedValue.ToEntero, CveClienteSucursal:=DdlClienteSucursal.SelectedValue.ToEntero, CveClasificacion2:=DdlClasificacion2.SelectedValue.ToEntero,
|
|
ServicioDomicilio:=DdlServicioDomicilio.SelectedValue.ToEntero) Then
|
|
GvDatos.DataSource = ObjVentas.DtResultados
|
|
TmpDT = ObjVentas.DtResultados
|
|
Else
|
|
GvDatos.DataSource = Nothing
|
|
End If
|
|
|
|
ObjVentas.Dispose()
|
|
GvDatos.DataBind()
|
|
Agrupador = DdlGrupo.SelectedItem.Text
|
|
End Sub
|
|
|
|
Protected Sub BtnTipoCambio_Click(sender As Object, e As EventArgs)
|
|
CargaDatos()
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivTipoCambio"))
|
|
UPDatos.Update()
|
|
End Sub
|
|
Protected Sub CargarMarcas(CveMarca As Integer)
|
|
If UsuarioActual.Empresa.Funcionalidad(130) = "1" Then
|
|
DivMarca.Visible = True
|
|
LblMarca.Visible = True
|
|
|
|
DdlMarcaPSDes.DataSource = GlobalDTGralMarcas(UsuarioActual.CveEmpresa)
|
|
DdlMarcaPSDes.DataBind()
|
|
End If
|
|
DdlMarcaPSDes.Items.Insert(0, New ListItem("Todas", "-1"))
|
|
DdlMarcaPSDes.Items.FindByValue(CStr(CveMarca)).Selected = True
|
|
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 RblTipoCambio.SelectedValue.ToEntero = 3 Then
|
|
Dim TipoCambioM As Double
|
|
LiEspecifico.Visible = True
|
|
TipoCambioM = GlobalTipoCambio(Now)
|
|
TxtEspecifico.Text = TipoCambioM.ToString
|
|
Else
|
|
LiEspecifico.Visible = False
|
|
End If
|
|
UpBodyTipoCambio.Update()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " GV DATOS - PERSONALIZAR "
|
|
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 DdlGrupo.SelectedValue.ToEntero = 20 Then
|
|
|
|
If e.Row.DBCampo("PS").ToString = "" Then
|
|
e.Row.CssClass = "Totales"
|
|
End If
|
|
Else
|
|
If Not e.Row.DBCampo("CveVenta").ToEntero > 0 Then
|
|
|
|
If e.Row.DBCampo("Gpo") = "" Then
|
|
e.Row.Cells(5).Text = e.Row.DBCampo("Moneda").ToString
|
|
e.Row.CssClass = "Totales"
|
|
Else
|
|
e.Row.Cells(5).Text = e.Row.DBCampo("Gpo").ToString
|
|
e.Row.CssClass = "SubTotales"
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
|
|
|
|
'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 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("IVA").ToDouble = 0 Then e.Row.FCLiteral("LtlIVA").Text = ""
|
|
'If e.Row.DBCampo("Total").ToDouble = 0 Then e.Row.FCLiteral("LtlTotal").Text = ""
|
|
'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 BtnPersonalizar_Click(sender As Object, e As System.EventArgs) Handles BtnPersonalizar.Click
|
|
|
|
GvDatos.Columns(2).Visible = ChkSucEjec.Checked
|
|
GvDatos.Columns(3).Visible = ChkSucCob.Checked
|
|
GvDatos.Columns(9).Visible = ChkObs.Checked
|
|
GvDatos.Columns(15).Visible = ChkRFC.Checked
|
|
GvDatos.Columns(16).Visible = ChkMetodoPago.Checked
|
|
GvDatos.Columns(17).Visible = ChkFormaPago.Checked
|
|
GvDatos.Columns(18).Visible = ChkFechaHoraEmision.Checked
|
|
|
|
CargaDatos()
|
|
UPDatos.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " SELECTED INDEX CHANGED"
|
|
|
|
Protected Sub DdlClienteClasificacion_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
CargaClientes()
|
|
End Sub
|
|
|
|
Private Sub CargaClientes(Optional CveCliente As Integer = -1)
|
|
Dim EsWS = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False)
|
|
If EsWS Then
|
|
DdlClientes.setEsWebService(True)
|
|
If CveCliente > 0 Then
|
|
DdlClientes.SelectedValue = CveCliente.ToString
|
|
DdlClientes.SelectedText = GlobalDTCliente(UsuarioActual.CveEmpresa, -1, CveCliente:=CveCliente).FiltroPrimeroValor("Nombre")
|
|
End If
|
|
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"))
|
|
If CveCliente > 0 Then
|
|
DdlClientes.ddl.SelectedValueExist(CveCliente)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaProvedores(Optional CveProveedor As Integer = -1)
|
|
|
|
DdlProveedor.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
|
|
|
|
If DdlProveedor.UsaWebService Then
|
|
DdlProveedor.SelectedValue = CveProveedor.ToString
|
|
DdlProveedor.Attributes.Add("data-metodo", "getproveedores")
|
|
DdlProveedor.SelectedText = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("RazonSocial", String.Format("CveProveedor = {0}", CveProveedor))
|
|
Else
|
|
DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
|
|
DdlProveedor.DataBind()
|
|
DdlProveedor.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
DdlClientes.ddl.SelectedValueExist(CveProveedor)
|
|
End If
|
|
|
|
End Sub
|
|
Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProyecto.SelectedIndexChanged
|
|
CargaSubProyecto()
|
|
End Sub
|
|
|
|
Private Sub CargaSubProyecto()
|
|
DdlSubProyecto.Items.Clear()
|
|
If DdlProyecto.SelectedValue <> "-1" Then
|
|
DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, -1, 1)
|
|
DdlSubProyecto.DataBind()
|
|
End If
|
|
DdlSubProyecto.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
End Sub
|
|
|
|
'Protected Sub DdlCategoria_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCategoria.SelectedIndexChanged
|
|
' DdlClasificacion.Items.Clear()
|
|
' If DdlCategoria.SelectedValue <> "-1" Then
|
|
' Dim ObjClasificaciones As New ClsClasificaciones
|
|
' If ObjClasificaciones.GetClasificacionesExistencias(UsuarioActual.CveEmpresa) Then
|
|
' DdlClasificacion.DataSource = ObjClasificaciones.DtResultados
|
|
' DdlClasificacion.DataBind()
|
|
' End If
|
|
' ObjClasificaciones.Dispose()
|
|
' End If
|
|
' DdlClasificacion.Items.Insert(0, New ListItem("Todas", "-1"))
|
|
'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
|
|
|
|
Protected Sub DdlTipoComprobante_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
CargaEstatus()
|
|
End Sub
|
|
|
|
Private Sub CargaEstatus()
|
|
DdlEstatus.Items.Clear()
|
|
If DdlTipoComprobante.SelectedValue <> "-1" AndAlso DdlTipoComprobante.SelectedValue <> "" 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()
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " EXCEL "
|
|
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
|
|
GvDatos.ExportToExcel("ReporteProductosServicios" & Now.ToShortDateString)
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " PDF "
|
|
Protected Sub ImgImprimir_Click(sender As Object, e As EventArgs) Handles ImgImprimir.Click
|
|
ImprimirReporte()
|
|
End Sub
|
|
|
|
Private Sub ImprimirReporte(Optional Formato As String = "PDF")
|
|
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")
|
|
|
|
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
|
|
|
If TmpDT.Rows.Count > 0 Then
|
|
Dim params As New List(Of ReportParameter)
|
|
|
|
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
|
If Imagen.Exists Then
|
|
params.Add(New ReportParameter("LogoPath", $"file://{Imagen.FullName}"))
|
|
Else
|
|
params.Add(New ReportParameter("LogoPath", ""))
|
|
End If
|
|
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
params.Add(New ReportParameter("FechaImpresion", DateTime.Now.ToString("dd/MM/yyyy")))
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepProductosServiciosDetalle.rdlc", TmpDT, params, "ReportePS")
|
|
'ImprimirPDF(String.Format("{0}Formatos\RepProductosServicios.rdlc", UsuarioActual.Empresa.Ruta), dtPS, params, "ReporteProductosServicios")
|
|
End If
|
|
|
|
ObjVentas.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "GRAFICA"
|
|
|
|
Protected Sub LnkVerGrafica_Click(sender As Object, e As EventArgs)
|
|
If Not TmpDT IsNot Nothing AndAlso TmpDT.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 CreaDataTableColor()
|
|
DtColor = New DataTable
|
|
DtColor.Columns.Add("Color")
|
|
Dim RowColor As DataRow = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#FF0F00"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#FF6600"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#FF9E01"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#FCD202"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#F8FF01"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#B0DE09"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#04D215"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#0D8ECF"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#0D52D1"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#2A0CD0"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#8A0CCF"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#CD0D74"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#754DEB"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#DDDDDD"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#999999"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#333333"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#000000"
|
|
DtColor.Rows.Add(RowColor)
|
|
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 TmpDT.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 = {CveMoneda}").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") = DtColor.Rows(RowColorIndex)("Color").ToString
|
|
Row("Moneda") = GlobalDTMonedas().FiltraParametros($"CveMoneda = {CveMoneda}").Rows(0)("Moneda").ToString
|
|
Dt.Rows.Add(Row)
|
|
RowColorIndex += 1
|
|
If RowColorIndex = 17 Then
|
|
RowColorIndex = 0
|
|
End If
|
|
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 As String = 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
|
|
|
|
#Region " D E S C A R G A S "
|
|
|
|
Private Sub BtnDescargarPDF_Click(sender As Object, e As EventArgs) Handles BtnDescargarZipPDF.Click
|
|
|
|
|
|
'If Not Directory.Exists(AppDomain.CurrentDomain.BaseDirectory & "Temp\" & UsuarioActual.CveUsuario.ToString & "\") Then
|
|
' Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory & "Temp\" & UsuarioActual.CveUsuario.ToString & "\")
|
|
'End If
|
|
|
|
|
|
Dim Archivo As String = String.Empty
|
|
Dim HuboInexistentes As Boolean = False
|
|
Dim SBInexistentes As New StringBuilder : SBInexistentes.Append("No se pudieron anexar los siguientes archivos:<br />")
|
|
|
|
Dim ArchivoDestino As String = String.Format("{0}Temp\{1}.zip", AppDomain.CurrentDomain.BaseDirectory, Now.ToString("yyyyMMddhhmmss") & UsuarioActual.CveUsuario.ToString)
|
|
|
|
Dim archiveZip As ZipArchive = ZipFile.Open(ArchivoDestino, ZipArchiveMode.Create)
|
|
|
|
Dim DTVentas As DataTable = TmpDT.FiltraParametros("", "", {"CveVenta", "TipoDocumento", "Folio", "SerieFolio"})
|
|
|
|
Try
|
|
|
|
For Each Drow As DataRow In DTVentas.Rows
|
|
|
|
Dim SerieFolio As String = Drow("SerieFolio").ToString.Replace("-", "_")
|
|
|
|
If Drow("TipoDocumento").ToString.Trim <> String.Empty Then
|
|
Archivo = String.Format("{0}PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta.Replace("\", "/"), Drow("TipoDocumento").ToString, Drow("SerieFolio").ToString)
|
|
If File.Exists(Archivo) Then
|
|
|
|
archiveZip.CreateEntryFromFile(Archivo, Drow("SerieFolio").ToString & ".pdf")
|
|
|
|
If UsuarioActual.CveRol = 1 Then
|
|
Archivo = String.Format("{0}XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta.Replace("\", "/"), Drow("TipoDocumento").ToString, Drow("SerieFolio").ToString)
|
|
If File.Exists(Archivo) Then
|
|
archiveZip.CreateEntryFromFile(Archivo, Drow("SerieFolio").ToString & ".xml")
|
|
' Exit For
|
|
Else
|
|
HuboInexistentes = True
|
|
SBInexistentes.AppendFormat("Tipo {0}, Folio {1} - {2}<br />", Drow("TipoDocumento").ToString, SerieFolio, Archivo)
|
|
End If
|
|
End If
|
|
|
|
Else
|
|
HuboInexistentes = True
|
|
SBInexistentes.AppendFormat("Tipo {0}, Folio {1} - {2}<br />", Drow("TipoDocumento").ToString, SerieFolio, Archivo)
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
|
|
archiveZip.Dispose()
|
|
|
|
|
|
Response.Clear()
|
|
Response.ContentType = "application/zip"
|
|
Response.AddHeader("content-disposition", $"attachment; filename=facturas{Now.ToString("yyyyMMddhhmmss")}.zip")
|
|
Response.TransmitFile(ArchivoDestino)
|
|
Response.Flush()
|
|
|
|
Try
|
|
File.Delete(ArchivoDestino)
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
|
|
Response.End()
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
Protected Sub DdlClientes_selectedindexchange(sender As Object, e As EventArgs)
|
|
|
|
If DdlClientes.txtValue.Value.ToEntero > 0 Then
|
|
CargaSucursales(DdlClientes.txtValue.Value.ToEntero, -1)
|
|
Else
|
|
CargaSucursales(-1, -1)
|
|
End If
|
|
|
|
|
|
|
|
End Sub
|
|
End Class
|