Option Explicit On Option Strict On Imports System.Data Imports Extensiones Partial Class Compras_RepBeneficiariosDetalle Inherits ClsPaginas #Region "PROPIEDADES" Private Property DtDatos As DataTable Get DtDatos = CType(ViewState("DtDatos"), DataTable) End Get Set(value As DataTable) ViewState("DtDatos") = value End Set End Property Private Property CveProveedor As Integer Get CveProveedor = ViewState("CveProveedor").ToString.ToEntero End Get Set(value As Integer) ViewState("CveProveedor") = value End Set End Property Private Property Tipo As Integer Get Tipo = ViewState("Tipo").ToString.ToEntero End Get Set(value As Integer) ViewState("Tipo") = value End Set End Property #End Region Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then If Request("CVEP") IsNot Nothing AndAlso Request("CVEP").ToEntero() > 0 Then If Request("T") IsNot Nothing AndAlso Request("T").ToEntero() > 0 Then CveProveedor = Request("CVEP").ToEntero() Tipo = Request("T").ToEntero() CargaDatos() Else Alert("Ocurrió un error al recibir los parametros especificados", TipoMensaje.MsgError) End If Else Alert("Ocurrió un error al recibir los parametros especificados", TipoMensaje.MsgError) End If End If End Sub Private Sub CargaDatos() Dim ObjCompras As New ClsCompras If ObjCompras.GetBeneficiariosDetalle(CveProveedor, Tipo, UsuarioActual.CveEmpresa) Then DtDatos = ObjCompras.DtResultados CargaGrid("") Else Alert("Ocurrió un error al obtener el Detalle de Beneficiarios", Extensiones.TipoMensaje.MsgError) End If ObjCompras.Dispose() End Sub Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.DBCampo("CveIE") = "" Then e.Row.FCHyperLink("HLFolio").NavigateUrl = String.Format("Compras.aspx?CveCompra={0}", e.Row.DBCampo("CveCompra")) Else e.Row.FCHyperLink("HLFolioIE").NavigateUrl = String.Format("/Bancos/IE.aspx?CveIE={0}", e.Row.DBCampo("CveIE")) End If End If End Sub #Region "O R D E N A M I E N T O" 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("") Else ViewState(String.Format("O{0}", Campo)) = String.Format("{0} DESC", Campo) Literal.Text = String.Format("") End If Orden = OrdenInicial & ViewState(String.Format("O{0}", Campo)).ToString ViewState("Orden") = Orden CargaGrid(Orden) End Sub Protected Sub CargaGrid(Orden As String) Dim DV As DataView = Nothing DV = New DataView(DtDatos, "", Orden, DataViewRowState.CurrentRows) If Orden <> String.Empty Then GvDatos.DataSource = DV.ToTable() Else GvDatos.DataSource = DtDatos End If GvDatos.DataBind() UpDatos.Update() DV.Dispose() End Sub #End Region End Class