Files
SIG/Ventas/PopUpBuscarClientes.aspx.vb

164 lines
7.3 KiB
VB.net

Option Explicit On
Option Strict On
Imports Extensiones
Imports Microsoft.Owin.Security.Provider
Partial Class PopUpBuscarClientes
Inherits ClsPaginas
Private ReadOnly Property OpcionBusqueda As String
Get
Return ViewState("Opt").ToString
End Get
End Property
Private Property TipoCliente As Integer
Get
Return ViewState("TipoCliente").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("TipoCliente") = value
End Set
End Property
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
CType(Me.Master, BaseMasterPage).EsPopup = True
'CType(Me.Master, BaseMasterPage).PopupWidth = 800
RegistraScript("if($get('tdContenido')){$get('tdContenido').style.height='520px';}")
CargaSubProyectos()
If Request("Opt") = "Fact" Then
ViewState("Opt") = "Factura"
Else
ViewState("Opt") = "Expediente"
End If
If Request("TipoCliente") IsNot Nothing AndAlso Request("TipoCliente").ToEntero > 0 Then
ViewState("TipoCliente") = Request("TipoCliente")
Else
ViewState("TipoCliente") = -1
End If
If Not Request("EsThickbox") Is Nothing Then
hdnEsThickbox.Value = Request("EsThickbox")
Else
hdnEsThickbox.Value = "N"
End If
End If
End Sub
Private Sub CargaSubProyectos()
DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1).FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
DdlSubProyecto.DataBind()
End Sub
Protected Sub BtnBuscar_Click(sender As Object, e As System.EventArgs) Handles BtnBuscar.Click
Dim Nombre As String = "-1"
Dim Codigo As String = "-1"
Dim NombreCorto As String = "-1"
Dim RFC As String = "-1"
Dim Telefono As String = "-1"
Dim Mail As String = "-1"
If TxtNombre.Text.Trim <> String.Empty Then Nombre = TxtNombre.Text.Trim
If TxtCodigo.Text.Trim <> String.Empty Then Codigo = TxtCodigo.Text.Trim
If TxtNombreCorto.Text.Trim <> String.Empty Then NombreCorto = TxtNombreCorto.Text.Trim
If TxtRFC.Text.Trim <> String.Empty Then RFC = TxtRFC.Text.Trim
If TxtTelefono.Text.Trim <> String.Empty Then Telefono = TxtTelefono.Text.Trim
If TxtMail.Text.Trim <> String.Empty Then Mail = TxtMail.Text.Trim
If ValidarUnFiltroSeleccionado() Then
Dim ObjClientes As New ClsClientes()
Dim CveUsuarioConsulta As Integer
Dim Cuenta As String = If(TxtCuenta.Text = "", "-1", TxtCuenta.Text)
If UsuarioActual.TienePermisoProceso(322) Then
CveUsuarioConsulta = UsuarioActual.CveVendedor
Else
CveUsuarioConsulta = -1
End If
If ObjClientes.GetClientes(-1, Nombre, Codigo, NombreCorto, RFC, Telefono, Mail, DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa,
DdlEstatus.SelectedValue.ToEntero, TipoCliente:=TipoCliente, TopSelect:=100, CveUsuarioConsulta:=CveUsuarioConsulta, Cuenta:=Cuenta) Then
If ObjClientes.DtResultados.Rows.Count > 0 Then
LtlTotalRegistros.Text = ObjClientes.DtResultados.Rows.Count.ToString.FormatoNumero(0)
GV.DataSource = ObjClientes.DtResultados
If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 77 Then
GV.DataSource = ObjClientes.DtResultados.FiltraParametros("CveCliente IN (10450, 10460, 10458)")
LtlTotalRegistros.Text = "0"
ElseIf UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 21 Then
GV.DataSource = ObjClientes.DtResultados.FiltraParametros("CveCliente IN (27448)")
LtlTotalRegistros.Text = "0"
End If
Else
LtlTotalRegistros.Text = "0"
GV.DataSource = Nothing
Alert("No se encontraron registros con los parámetros solicitados.", Extensiones.TipoMensaje.MsgAdvertencia)
End If
End If
ObjClientes.Dispose()
GV.DataBind()
UPDatos.Update()
TblBusqueda.Visible = True
Else
Alert("Asigne un valor a cualquiera de los filtros", TipoMensaje.MsgAdvertencia)
End If
End Sub
Protected Sub GV_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GV.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowIndex = 0 Then
'e.Row.Cells(0).Width = Unit.Pixel(350)
'e.Row.Cells(1).Width = Unit.Pixel(80)
'e.Row.Cells(2).Width = Unit.Pixel(200)
'e.Row.Cells(3).Width = Unit.Pixel(80)
'e.Row.Cells(4).Width = Unit.Pixel(100)
End If
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
Dim Liga As String = String.Empty
If OpcionBusqueda = "Factura" Then
Liga = "<a href='javascript:Ir2(""" & e.Row.DBCampo("CveCliente") & """);'>"
Else
If UsuarioActual.CveEmpresa = 43 Then
Liga = String.Format("<a href='javascript:Ir3(""{0}"");'>", e.Row.DBCampo("CveCliente"))
Else
Liga = String.Format("<a href='javascript:Ir(""{0}"");'>", e.Row.DBCampo("CveCliente"))
End If
End If
e.Row.FCLiteral("LtlCodigo").Text = String.Format("<div class='truncate' style='width:60px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("Codigo"))
e.Row.FCLiteral("LtlNombre").Text = String.Format("<div class='truncate' style='width:190px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("NombreComercial"))
e.Row.FCLiteral("LtlRFC").Text = String.Format("<div class='truncate' style='width:100px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("RFC"))
e.Row.FCLiteral("LtlDireccion").Text = String.Format("<div class='truncate' style='width:165px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("Direccion"))
e.Row.FCLiteral("LtlCiudad").Text = String.Format("<div class='truncate' style='width:90px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("Ciudad"))
e.Row.FCLiteral("LtlMail").Text = String.Format("<div class='truncate' style='width:100px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("Mail"))
End If
End Sub
Private Function ValidarUnFiltroSeleccionado() As Boolean
If TxtNombre.Text.Trim <> String.Empty Then Return True
If TxtCodigo.Text.Trim <> String.Empty Then Return True
If TxtNombreCorto.Text.Trim <> String.Empty Then Return True
If TxtRFC.Text.Trim <> String.Empty Then Return True
If TxtTelefono.Text.Trim <> String.Empty Then Return True
If TxtMail.Text.Trim <> String.Empty Then Return True
If DdlSubProyecto.SelectedValue.ToEntero > 0 Then Return True
If DdlEstatus.SelectedValue.ToEntero > 0 Then Return True
If TxtCuenta.Text.Trim.Length > 0 Then Return True
Return False
End Function
End Class