Files
SIG/Prospectos/RepSolicitudes.aspx.vb
MLopez 021e50c4b7 Limpieza masiva ClsPaginas
-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)
2023-01-31 21:56:32 -07:00

117 lines
4.5 KiB
VB.net

Option Strict On
Imports System.Data
Imports Extensiones
Partial Class Prospectos_RepSolicitudes
Inherits ClsPaginas
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
ViewState("Orden") = String.Empty
CargaDatos()
End If
End Sub
Public Sub CargaDatos()
Dim ObjSolicitudes As New ClsProspectos
If ObjSolicitudes.GetRepSolicitudes(DdlAgrupador.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
ViewState("DTSolicitudes") = ObjSolicitudes.DtResultados
Else
Me.GvDatos.DataSource = Nothing
End If
ObjSolicitudes.Dispose()
If ViewState("Orden").ToString() <> String.Empty Then
CargaGrid(ViewState("Orden").ToString())
Else
CargaGrid("")
End If
UPDatos.Update()
End Sub
Private Sub CargaGrid(Orden As String)
If Orden <> String.Empty Then
Dim DV As New DataView(CType(ViewState("DTSolicitudes"), DataTable), "", Orden, DataViewRowState.CurrentRows)
GvDatos.DataSource = DV.ToTable()
DV.Dispose()
Else
GvDatos.DataSource = CType(ViewState("DTSolicitudes"), DataTable)
End If
GvDatos.DataBind()
End Sub
Protected Sub GvDatos_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GvDatos.RowCreated
If (e.Row.RowType = DataControlRowType.DataRow AndAlso (e.Row.RowState = DataControlRowState.Normal OrElse e.Row.RowState = DataControlRowState.Alternate)) Then
e.Row.TabIndex = -1
e.Row.Attributes("onclick") = String.Format("javascript:SelectRow(this, {0});", e.Row.RowIndex)
e.Row.Attributes("onkeydown") = "javascript:return SelectSibling(event);"
e.Row.Attributes("onselectstart") = "javascript:return false;"
'e.Row.Cells(10).Attributes.Add("onclick", "EC();")
e.Row.Cells(1).Attributes.Add("onclick", "EC();")
End If
End Sub
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("Descripcion1") = "" Then
e.Row.FCLiteral("LtlDescripcion").Text = String.Format("{0} - ({1})", e.Row.DBCampo("Agrupador"), e.Row.DBCampo("Cantidad"))
e.Row.CssClass = "SubTotales3"
'e.Row.Cells(2).ColumnSpan = 3
'e.Row.Cells.RemoveAt(3) : e.Row.Cells.RemoveAt(3)
Else
e.Row.Cells(2).Width = 250
End If
End If
End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
CargaDatos()
UPDatos.Update()
RegistraScript("UpperBound = " & GvDatos.Rows.Count - 1 & ";")
End Sub
Protected Sub ImgExcel_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles ImgExcel.Click
GvDatos.ExportToExcel("Prospectos")
End Sub
Protected Sub LbOrden_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim Tipo As Integer = 1
Dim Orden As String = ""
Dim Campo As String = ""
Dim ImgButon As ImageButton = Nothing
Const OrdenInicial As String = "Agrupador,OrdenAgrupador,"
Select Case sender.GetType().Name
Case "LinkButton"
Tipo = 1
Campo = CType(sender, LinkButton).CommandArgument
ImgButon = CType(CType(sender, LinkButton).BindingContainer.FindControl("Img" & Campo.Replace(",", "_")), ImageButton)
Case "ImageButton"
Tipo = 2
Campo = CType(sender, ImageButton).CommandArgument
ImgButon = CType(sender, ImageButton)
End Select
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)
RegistraScript(String.Format("$get('{0}').src='{1}'", ImgButon.ClientID, "/Imagenes/FlechasArriba.gif"))
Else
ViewState(String.Format("O{0}", Campo)) = String.Format("{0} DESC", Campo)
RegistraScript(String.Format("$get({0}).src='{1}'", ImgButon.ClientID, "/Imagenes/FlechasAbajo.gif"))
End If
Orden = OrdenInicial & ViewState(String.Format("O{0}", Campo)).ToString
CargaGrid(Orden)
End Sub
End Class