Option Explicit On
Option Strict On
Imports Extensiones
Partial Class Compras_PopUpBuscarFolioC
Inherits ClsPaginas
Private ReadOnly Property OpcionBusqueda As String
Get
Return ViewState("Opt").ToString
End Get
End Property
Private Property Opcion As String
Get
Return ViewState("Opcion").ToString
End Get
Set(value As String)
ViewState("Opcion") = 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 = 900
'RegistraScript("$get('tdContenido').style.height='470px'")
CargaProveedor()
txtFechaI.Text = NowADS().AddDays(-30).ToShortDateString
txtFechaI.Text = NowADS().AddYears(-1).ToShortDateString
If Request("Opt") = "Fact" Then
ViewState("Opt") = "MandaCveCompra"
ElseIf Request("Opt") = "ComplementosTraslado" Then
ViewState("Opt") = "ComplementosTraslado"
Else
ViewState("Opt") = "RecargaCompra"
End If
End If
End Sub
Protected Sub CargaProveedor()
'DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
'DdlProveedor.DataBind()
'DdlProveedor.Items.Insert(0, New ListItem("Todos", "-1"))
End Sub
Protected Sub BtnBuscar_Click(sender As Object, e As System.EventArgs) Handles BtnBuscar.Click
Dim Folio As String = "-1"
Dim FolioFiscal As String = "-1"
Dim Codigo As String = "-1"
Dim Proveedor As String = "-1"
Dim FechaI As String = "-1"
Dim FechaF As String = "-1"
Dim Descripcion, Obs As String
Folio = If(TxtFolio.Text.Trim.Length = 0, "-1", TxtFolio.Text.Trim)
FolioFiscal = If(TxtFolioFiscal.Text.Trim.Length = 0, "-1", TxtFolioFiscal.Text.Trim)
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1")
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1")
Descripcion = If(TxtDescripcion.Text.Trim = "", "-1", TxtDescripcion.Text.Trim)
Obs = If(TxtObservaciones.Text.Trim = "", "-1", TxtObservaciones.Text.Trim)
If ValidarUnFiltroSeleccionado() Then
Dim ObjCompras As New ClsCompras()
If ObjCompras.GetCompras(UsuarioActual.CveEmpresa, DdlTipoDocto.SelectedValue, Folio, FolioFiscal, Codigo, Proveedor, FechaI, FechaF, Descripcion, Obs,
CveProveedor:=DdlProveedores.SelectedValue.ToEntero, TopSelect:=100) Then
If ObjCompras.DtResultados.Rows.Count > 0 Then
LtlTotalRegistros.Text = ObjCompras.DtResultados.Rows.Count.ToString.FormatoNumero(0)
GV.DataSource = ObjCompras.DtResultados
Else
LtlTotalRegistros.Text = "0"
GV.DataSource = Nothing
Alert("No se encontraron registros con los parámetros solicitados.", Extensiones.TipoMensaje.MsgAdvertencia)
End If
End If
ObjCompras.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
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left
Dim Liga As String = String.Empty
Select Case Request("Opt")
Case "Fact"
Liga = String.Format("", e.Row.DBCampo("CveCompra"))
Case "FactImp"
Liga = String.Format("", e.Row.DBCampo("CveCompra"))
Case "FactFlete"
Liga = String.Format("", e.Row.DBCampo("CveCompra"))
Case "ComplementosTraslado"
Liga = String.Format("", e.Row.DBCampo("CveCompra"), e.Row.DBCampo("SerieFolio"))
Case Else
Liga = String.Format("", e.Row.DBCampo("CveCompra"))
End Select
e.Row.FCLiteral("LtlTipo").Text = String.Format("{0}{1}
", Liga, e.Row.DBCampo("TipoDocto"))
e.Row.FCLiteral("LtlFolio").Text = String.Format("{0}{1}
", Liga, e.Row.DBCampo("SerieFolio"))
e.Row.FCLiteral("LtlFecha").Text = String.Format("{0}{1}
", Liga, e.Row.DBCampo("Fecha").ToDate.ToShortDateString)
e.Row.FCLiteral("LtlNombre").Text = String.Format("{0}{1}
", Liga, e.Row.DBCampo("RazonSocial"))
e.Row.FCLiteral("LtlTotal").Text = String.Format("{0}{1}
", Liga, e.Row.DBCampo("Total").FormatoNumero)
e.Row.FCLiteral("LtlMoneda").Text = String.Format("{0}{1}
", Liga, e.Row.DBCampo("Abreviatura"))
End If
End Sub
Private Function ValidarUnFiltroSeleccionado() As Boolean
If TxtFolio.Text.Trim.Length > 0 Then Return True
If TxtFolioFiscal.Text.Trim.Length > 0 Then Return True
If TxtDescripcion.Text.Trim.Length > 0 Then Return True
If TxtObservaciones.Text.Trim.Length > 0 Then Return True
If DdlTipoDocto.SelectedValue <> "-1" Then Return True
If DdlProveedores.SelectedValue.ToEntero <> 0 Then Return True
Return False
End Function
End Class