Files
SIG/Ventas/PopUpBuscarPs.aspx.vb
2020-06-06 14:37:12 -07:00

116 lines
4.5 KiB
VB.net

Option Explicit On
Option Strict On
Imports System.Data
Imports Extensiones
Partial Class PopUpBuscarPs
Inherits ClsPaginas
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
CType(Me.Master, BaseMasterPage).EsPopup = True
CType(Me.Master, BaseMasterPage).PopupWidth = 800
If Not Page.IsPostBack Then
ViewState("Orden") = ""
CargaClasificaciones()
CargarCompuestos()
If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then
tdBarras1.Visible = True
tdBarras2.Visible = True
TxtCodigoBarras.Focus()
End If
End If
End Sub
#Region " INICIALIZA VALORES "
Private Sub CargaClasificaciones()
Ddlclasificacion.DataSource = GlobalDTClasificaciones.FiltraParametros(String.Format("CveEmpresa = {0}", UsuarioActual.CveEmpresa))
Ddlclasificacion.DataBind()
Ddlclasificacion.Items.Insert(0, New ListItem("Todos", "-1"))
End Sub
Private Sub CargarCompuestos()
If UsuarioActual.Empresa.Funcionalidad(143) = "1" Then
TdCompuesto1.Visible = True
TdCompuesto2.Visible = True
Dim PS As New ClsProductosServicios
PS.GetCompuestosActivos(UsuarioActual.CveEmpresa)
DdlCompuesto.DataSource = PS.DtResultados
PS.Dispose()
DdlCompuesto.DataBind()
DdlCompuesto.Items.Insert(0, New ListItem("Todos", "-1"))
End If
DdlCompuesto.Items.Insert(0, New ListItem("Todos", "-1"))
End Sub
#End Region
#Region " CARGA DATOS "
Protected Sub BtnFiltrar_Click(sender As Object, e As EventArgs)
CargaDatos()
UPDatos.Update()
End Sub
Protected Sub lnkBuscar_Click(sender As Object, e As EventArgs) Handles lnkBuscar.Click
CargaDatos()
UPDatos.Update()
End Sub
Public Sub CargaDatos()
Dim Codigo As String = ""
Dim Nombre As String = ""
Dim CodigoBarras As String = ""
If TxtCodigo.Text = "" Then Codigo = "-1" Else Codigo = TxtCodigo.Text.ToUpper.Trim
If TxtCodigoBarras.Text.Trim = "" Then CodigoBarras = "-1" Else CodigoBarras = TxtCodigoBarras.Text.Trim
If TxtNombre.Text = "" Then Nombre = "-1" Else Nombre = TxtNombre.Text.ToUpper
If ValidarUnFiltroSeleccionado() Then
Dim ObjPS As New ClsProductosServicios
If ObjPS.GetPS(-1, Ddlclasificacion.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, Codigo:=Codigo, CodigoBarras:=CodigoBarras, PS:=Nombre,
pEstado:=DdlEstado.SelectedValue.ToEntero, CveTipoPS:=DdlCveTipoPS.SelectedValue.ToEntero, pAplicaParaVenta:=DdlAplicaVenta.SelectedValue.ToEntero,
CveCompuesto:=DdlCompuesto.SelectedValue.ToEntero, TopSelect:=100) Then
GvDatos.DataSource = ObjPS.DtResultados
dvbusqueda.Visible = True
Else
GvDatos.DataSource = Nothing
dvbusqueda.Visible = False
End If
ObjPS.Dispose()
GvDatos.DataBind()
GvDatos.UseAccessibleHeader = True
Else
Alert("Asigne un valor a cualquiera de los filtros", TipoMensaje.MsgAdvertencia)
End If
End Sub
#End Region
#Region " GV DATOS "
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Try
e.Row.FCLiteral("LnkPs").Text = String.Format("<div class='truncate' style='width:200px;'>{0}{1}</a></div>", "<a href='javascript:Ir(""" & e.Row.DBCampo("CvePs") & """);'>", e.Row.DBCampo("Ps"))
Catch ex As Exception
Dim exexex As String = ex.Message
End Try
End If
End Sub
#End Region
Private Function ValidarUnFiltroSeleccionado() As Boolean
If TxtCodigo.Text.Trim <> String.Empty Then Return True
If TxtCodigoBarras.Text.Trim <> String.Empty Then Return True
If TxtNombre.Text.Trim <> String.Empty Then Return True
If DdlCveTipoPS.SelectedValue.ToEntero > 0 Then Return True
If DdlEstado.SelectedValue.ToEntero > 0 Then Return True
If DdlAplicaVenta.SelectedValue.ToEntero > 0 Then Return True
If Ddlclasificacion.SelectedValue.ToEntero > 0 Then Return True
If DdlCompuesto.SelectedValue.ToEntero > 0 Then Return True
Return False
End Function
End Class