-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)
128 lines
5.0 KiB
VB.net
128 lines
5.0 KiB
VB.net
|
|
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
|
|
Partial Class Prospectos_RepProspectos
|
|
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
|
|
ddlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa)
|
|
ddlVendedor.DataBind()
|
|
ddlVendedor.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
|
|
'rol de prospectador
|
|
If UsuarioActual.CveRol = 1015 Then
|
|
ddlVendedor.Enabled = False
|
|
End If
|
|
|
|
CargaDatos()
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub CargaDatos()
|
|
Dim ObjProspectos As New ClsProspectos
|
|
If ObjProspectos.GetRepProspectos(ddlVendedor.SelectedValue.ToEntero, DdlAgrupador.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
ViewState("DTProspectos") = ObjProspectos.DtResultados
|
|
Else
|
|
Me.GvDatos.DataSource = Nothing
|
|
End If
|
|
ObjProspectos.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("DTProspectos"), DataTable), "", Orden, DataViewRowState.CurrentRows)
|
|
GvDatos.DataSource = DV.ToTable()
|
|
DV.Dispose()
|
|
Else
|
|
GvDatos.DataSource = CType(ViewState("DTProspectos"), 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();")
|
|
' 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("NombreCompleto") = "" Then
|
|
e.Row.FCHyperLink("HplNombre").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
|
|
e.Row.FCHyperLink("HplNombre").NavigateUrl = String.Format("/Prospectos/ProspectosSIP.aspx?CveProspecto={0}", e.Row.DBCampo("CveProspecto"))
|
|
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
|