-RegistraScript se unifica en una sola clase static/shared y se simplica el código -Alert se vuelve estático -Random() no se manda a crear cada vez que se registra un script (esto tenía un costo alto) -Se corrigieron unos errores en los nombres de funciones -Las clases que ya heredan de Clspaginas, se les quita el this a RegistraScript y a Alert puesto que era innecesario (y además al haberlos vuelto métodos estáticos, NO pueden llamarse de un this)
289 lines
11 KiB
VB.net
289 lines
11 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
|
|
Partial Class CatPS
|
|
Inherits ClsPaginas
|
|
|
|
Private Property DtDatos As DataTable
|
|
Get
|
|
DtDatos = DirectCast(ViewState("DtDatos"), DataTable)
|
|
End Get
|
|
|
|
Set(ByVal value As DataTable)
|
|
ViewState("DtDatos") = value
|
|
End Set
|
|
End Property
|
|
Private Property AplicaVenta As Boolean
|
|
Get
|
|
AplicaVenta = DirectCast(ViewState("AplicaVenta"), Boolean)
|
|
End Get
|
|
|
|
Set(ByVal value As Boolean)
|
|
ViewState("AplicaVenta") = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
AplicaVenta = False
|
|
ViewState("Orden") = ""
|
|
CargaClasificaciones()
|
|
CargaGvBitacora()
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then
|
|
DivCBarras1.Visible = True
|
|
DivCBarras2.Visible = True
|
|
TxtCodigoBarras.Focus()
|
|
End If
|
|
|
|
If UsuarioActual.TienePermisoProceso(122) Then
|
|
LBAgregarPS.Visible = False
|
|
End If
|
|
|
|
If UsuarioActual.CveEmpresa = 119 Then
|
|
DdlEstado.SelectedValue = "-1"
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub CargaClasificaciones()
|
|
Ddlclasificacion.DataSource = GlobalDTClasificaciones.FiltraParametros(String.Format("CveEmpresa = {0} AND (UsoClasificacion = {1} OR {1} = -1)", UsuarioActual.CveEmpresa, DdlTipoClasificacion.SelectedValue.ToEntero))
|
|
Ddlclasificacion.DataBind()
|
|
Ddlclasificacion.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
End Sub
|
|
|
|
Public Sub CargaDatos()
|
|
Dim Codigo As String = ""
|
|
Dim Nombre As String = ""
|
|
Dim CodigoBarras As String = ""
|
|
|
|
If TxtCodigo.Text.Trim = "" Then Codigo = "-1" Else Codigo = TxtCodigo.Text.ToUpper.Trim
|
|
If TxtCodigoBarras.Text.Trim = "" Then CodigoBarras = "-1" Else CodigoBarras = TxtCodigoBarras.Text.Trim
|
|
If TxtNombre.Text.Trim = "" Then Nombre = "-1" Else Nombre = TxtNombre.Text.ToUpper.Trim
|
|
|
|
|
|
Dim ObjPS As New ClsProductosServicios
|
|
If ObjPS.GetPSLite(Ddlclasificacion.SelectedValue.ToEntero, UsuarioActual.Empresa.CveEmpresa, Codigo, CodigoBarras, Nombre, DdlAplicaVenta.SelectedValue.ToEntero, DdlEstado.SelectedValue.ToEntero, DdlCveTipoPS.SelectedValue.ToEntero, DdlTipoClasificacion.SelectedValue.ToEntero) Then
|
|
DtDatos = ObjPS.DtResultados
|
|
GvDatos.DataSource = DtDatos
|
|
Else
|
|
DtDatos = Nothing
|
|
'Me.GvDatos.DataSource = Nothing
|
|
End If
|
|
|
|
ObjPS.Dispose()
|
|
|
|
GvDatos.DataBind()
|
|
GvDatos.UseAccessibleHeader = True
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnFiltrar_Click(sender As Object, e As EventArgs)
|
|
CargaDatos()
|
|
OrdenaDatos()
|
|
UPDatos.Update()
|
|
End Sub
|
|
|
|
Protected Sub DdlTipoClasificacion_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
CargaClasificaciones()
|
|
End Sub
|
|
|
|
#Region "G V D A T O S"
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.DBCampo("Estado") = "Activo" Then
|
|
e.Row.FCLabel("LblEstado").CssClass = "label label-success"
|
|
Else
|
|
e.Row.FCLabel("LblEstado").CssClass = "label label-danger"
|
|
End If
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region "P E R S O N A L I Z A R G V"
|
|
Private Sub BtnPersonalizar_Click(sender As Object, e As EventArgs) Handles BtnPersonalizar.Click
|
|
If ChkAplicaVenta.Checked Then
|
|
GvDatos.Columns(6).Visible = True
|
|
AplicaVenta = True
|
|
Else
|
|
GvDatos.Columns(6).Visible = False
|
|
AplicaVenta = False
|
|
End If
|
|
|
|
GvDatos.Columns(10).Visible = ChkProductosServiciosSAT.Checked
|
|
GvDatos.Columns(11).Visible = ChkClasificacion2.Checked
|
|
GvDatos.Columns(12).Visible = ChkMarca.Checked
|
|
GvDatos.Columns(13).Visible = ChkVentaMinima.Checked
|
|
GvDatos.Columns(14).Visible = ChkCodigoBarras.Checked
|
|
GvDatos.Columns(15).Visible = ChkCompuesto.Checked
|
|
GvDatos.Columns(16).Visible = ChkRSCO.Checked
|
|
|
|
CargaDatos()
|
|
OrdenaDatos()
|
|
UPDatos.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "O R D E N A M I E N T O"
|
|
|
|
Private Sub OrdenaDatos()
|
|
If (GvDatos.Rows.Count > 0) Then
|
|
GvDatos.UseAccessibleHeader = True
|
|
GvDatos.HeaderRow.TableSection = TableRowSection.TableHeader
|
|
RegistraScript("OrdenarGV();")
|
|
'$('#GvD').DataTable({paging:false, 'scrollY':'300px', 'scrollCollapse': true, searching:false, info:false });
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
'Protected Sub LbOrden_Click(ByVal sender As Object, ByVal e As EventArgs)
|
|
' Dim Orden As String = ""
|
|
' Dim Campo As String = ""
|
|
' Dim Literal As Literal = Nothing
|
|
' Const OrdenInicial As String = ""
|
|
' Dim Arg(2) As String
|
|
|
|
' Arg = CType(sender, LinkButton).CommandArgument().ToString.Split(";"c)
|
|
' Campo = Arg(0)
|
|
' Literal = CType(CType(sender, LinkButton).NamingContainer.FindControl("Img" & Campo.Replace(",", "_")), Literal)
|
|
|
|
' If ViewState(String.Format("O{0}", Campo)) IsNot Nothing AndAlso ViewState(String.Format("O{0}", Campo)).ToString = String.Format("{0} DESC", Campo) Then
|
|
' ViewState(String.Format("O{0}", Campo)) = String.Format("{0} ASC", Campo)
|
|
' Literal.Text = String.Format("<i class='fa fa-sort-asc' style='color:#999' ></i>")
|
|
' Else
|
|
' ViewState(String.Format("O{0}", Campo)) = String.Format("{0} DESC", Campo)
|
|
' Literal.Text = String.Format("<i class='fa fa-sort-desc' style='color:#999' ></i>")
|
|
' End If
|
|
' Orden = OrdenInicial & ViewState(String.Format("O{0}", Campo)).ToString
|
|
' ViewState("Orden") = Orden
|
|
' CargaGrid(Orden)
|
|
'End Sub
|
|
|
|
'Private Sub CargaGrid(Orden As String)
|
|
' If Orden <> String.Empty Then
|
|
' Dim DV As New DataView(CType(ViewState("DTPS"), DataTable), "", Orden, DataViewRowState.CurrentRows)
|
|
' GvDatos.DataSource = DV.ToTable().FiltraParametros("RowNum <= 500")
|
|
' DV.Dispose()
|
|
' Else
|
|
' GvDatos.DataSource = CType(ViewState("DTPS"), DataTable).FiltraParametros("RowNum <= 500")
|
|
' End If
|
|
' GvDatos.DataBind()
|
|
'End Sub
|
|
#End Region
|
|
|
|
#Region "Bitacora"
|
|
Private Sub CargaGvBitacora()
|
|
Dim ObjGral As New ClsGenerales
|
|
If ObjGral.GetHistorialBitacoraRemoveGet("PS", UsuarioActual.CveEmpresa) Then
|
|
GvBitacora.DataSource = ObjGral.DtResultados
|
|
ObjGral.Dispose()
|
|
End If
|
|
GvBitacora.DataBind()
|
|
End Sub
|
|
|
|
Private Sub BtnMostrar_Click(sender As Object, e As EventArgs) Handles BtnMostrar.Click
|
|
GvBitacora.Visible = True
|
|
BtnOcultar.Visible = True
|
|
BtnMostrar.Visible = False
|
|
UpBitacora.Update()
|
|
End Sub
|
|
|
|
Private Sub BtnOcultar_Click(sender As Object, e As EventArgs) Handles BtnOcultar.Click
|
|
GvBitacora.Visible = False
|
|
BtnOcultar.Visible = False
|
|
BtnMostrar.Visible = True
|
|
UpBitacora.Update()
|
|
End Sub
|
|
|
|
Private Sub LbImprimirProductos_Click(sender As Object, e As EventArgs) Handles LbImprimirProductos.Click
|
|
Dim ObjPS As New ClsProductosServicios
|
|
If ObjPS.GetProductosServiciosSinSAT(RBLOpcion.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
If ObjPS.DtResultados.Rows.Count > 0 Then
|
|
GvProductos.DataSource = ObjPS.DtResultados
|
|
GvProductos.DataBind()
|
|
GvProductos.ExportToExcelX("Reporte de Producto")
|
|
Else
|
|
Alert("Todos los productos tienen Asignada Clave Producto Servicio SAT.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
End If
|
|
ObjPS.Dispose()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " IMPRESION "
|
|
Protected Sub LBExcel_Click(sender As Object, e As EventArgs) Handles LBExcel.Click
|
|
|
|
If Not IsNothing(DtDatos) Then
|
|
ImprimirReporte("EXCEL")
|
|
Else
|
|
CargaDatos()
|
|
If IsNothing(DtDatos) Then
|
|
Alert("No se encontró información para el reporte.", TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
ImprimirReporte("EXCEL")
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
Protected Sub LBImprimir_Click(sender As Object, e As EventArgs) Handles LBImprimir.Click
|
|
|
|
If Not IsNothing(DtDatos) Then
|
|
ImprimirReporte()
|
|
Else
|
|
CargaDatos()
|
|
If IsNothing(DtDatos) Then
|
|
Alert("No se encontró información para el reporte.", TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
ImprimirReporte()
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
Private Sub ImprimirReporte(Optional Formato As String = "PDF")
|
|
Dim Archivo As New System.IO.FileInfo(String.Format("{0}Empresas/Grales/Formatos/CatPS.rpt", UsuarioActual.Empresa.Ruta))
|
|
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 lista = New List(Of CrystalParametro)
|
|
lista.Add(New CrystalParametro("Empresa", UsuarioActual.Empresa.Empresa))
|
|
lista.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Usuario))
|
|
lista.Add(New CrystalParametro("AplicaVenta", AplicaVenta.ToString))
|
|
'lista.Add(New CrystalParametro("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
|
|
|
|
|
|
If Imagen.Exists Then
|
|
lista.Add(New CrystalParametro("LogoPath", $"file://{Imagen.FullName}"))
|
|
Else
|
|
lista.Add(New CrystalParametro("LogoPath", ""))
|
|
End If
|
|
|
|
|
|
If Archivo.Exists Then
|
|
ImprimirbytesPDF(ImprimirPDFCrystal(Archivo.FullName, DtDatos, lista, "Productos y Servicios", Formato), "Productos y Servicios", Formato)
|
|
Else
|
|
Dim Ruta As String = ModExtensiones.DirectorioBaseEmpresas + $"Empresas\Grales\Formatos\CatPS.rpt"
|
|
ImprimirbytesPDF(ImprimirPDFCrystal(Ruta, DtDatos, lista, "Productos y Servicios", Formato), "Productos y Servicios", Formato)
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Sub LBExcelPersonalizado_Click(Sender As Object, e As EventArgs) Handles LBExcelPersonalizado.Click
|
|
ExportToExcelGembox(GvDatos, "Catálogo de Productos y Servicios", UsuarioActual, "Catálogo de Productos y Servicios")
|
|
End Sub
|
|
|
|
Public Overrides Sub VerifyRenderingInServerForm(control As Control)
|
|
End Sub
|
|
#End Region
|
|
|
|
End Class
|