Files
SIG/Sistemas/CatParametros.aspx.vb
2023-08-25 07:35:45 -07:00

201 lines
8.9 KiB
VB.net

Imports Extensiones
Imports System.Data
Partial Class CatParametros
Inherits ClsPaginas
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
ViewState("Orden") = ""
ViewState("CveRol") = -1
CargaModulos()
CargaDatos()
'Permisos
'Permiso Registro
If UsuarioActual.TienePermisoProceso(1) Then LbAgregar.Enabled = True Else LbAgregar.Enabled = False
'Permiso Modificar
If UsuarioActual.TienePermisoProceso(2) Then GvDatos.Columns(9).Visible = True Else GvDatos.Columns(9).Visible = False
'Permiso Eliminar
If UsuarioActual.TienePermisoProceso(3) Then GvDatos.Columns(10).Visible = True Else GvDatos.Columns(10).Visible = False
End If
End Sub
Private Sub CargaModulos()
CboModulos.DataSource = GlobalDTModulos.FiltraParametros("NOT (Agrupacion = 'S')")
CboModulos.DataBind()
CboModulos.Items.Insert(0, New ListItem("Seleccione", "-1"))
End Sub
Public Sub CargaDatos()
Dim Parametros As New ClsSisParametros
If Parametros.GetParametros() Then
ViewState("DTParametros") = Parametros.DtResultados
Else
GvDatos.DataSource = Nothing
End If
Parametros.Dispose()
If ViewState("Orden").ToString() <> String.Empty Then
CargaGrid(ViewState("Orden").ToString())
Else
CargaGrid("")
End If
End Sub
Protected Sub LbAgregar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LbAgregar.Click
Dim Parametro As New ClsSisParametros
If Parametro.AddParametros(TxtCveParam.Text.ToEntero, TxtDescripcion.Text.Trim, CboModulos.SelectedValue.ToEntero, TxtStrValor1.Text, TxtStrValor2.Text, TxtNumValor1.Text, TxtNumValor2.Text, TxtDTValor1.Text, TxtDTValor2.Text, TxtDTVencimiento.Text, UsuarioActual.CveUsuario) Then
TxtDescripcion.Text = ""
Alert("El nuevo Parámetro se guardó correctamente.", TipoMensaje.MsgInformacion)
UpTitulos.Update()
ViewState("DTParametros") = Parametro.DtResultados
Application("GlobalDTParametros") = Parametro.DtResultados
If ViewState("Orden").ToString() <> String.Empty Then
CargaGrid(ViewState("Orden").ToString())
Else
CargaGrid("")
End If
End If
Parametro.Dispose()
'"$(""#DivAltaReporte"").hide();"
End Sub
#Region "G V D A T O S"
Protected Sub GvDatos_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowState = DataControlRowState.Alternate OrElse e.Row.RowState = DataControlRowState.Normal Then
e.Row.Cells(0).Width = Unit.Pixel(39)
e.Row.Cells(1).Width = Unit.Pixel(109)
e.Row.Cells(2).Width = Unit.Pixel(165)
e.Row.Cells(3).Width = Unit.Pixel(155)
e.Row.Cells(4).Width = Unit.Pixel(84)
e.Row.Cells(5).Width = Unit.Pixel(119)
e.Row.Cells(6).Width = Unit.Pixel(114)
e.Row.Cells(7).Width = Unit.Pixel(88)
e.Row.Cells(8).Width = Unit.Pixel(88)
e.Row.Cells(9).Width = Unit.Pixel(64)
e.Row.Cells(10).Width = Unit.Pixel(68)
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Center
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left
e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Left
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left
e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right
e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Center
e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Center
e.Row.Cells(7).HorizontalAlign = HorizontalAlign.Center
e.Row.Cells(8).HorizontalAlign = HorizontalAlign.Center
e.Row.Cells(9).HorizontalAlign = HorizontalAlign.Center
e.Row.Cells(10).HorizontalAlign = HorizontalAlign.Center
End If
End If
End Sub
Protected Sub GvDatos_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvDatos.RowEditing
GvDatos.EditIndex = e.NewEditIndex
If ViewState("Orden").ToString() <> String.Empty Then
CargaGrid(ViewState("Orden").ToString())
Else
CargaGrid("")
End If
Dim EditingRow As GridViewRow = GvDatos.Rows(e.NewEditIndex)
Dim CboModulosR As DropDownList = CType(EditingRow.FindControl("CboModulo"), DropDownList)
For Each LI As ListItem In CboModulos.Items
CboModulosR.Items.Add(LI)
Next
CboModulosR.SelectedValue = EditingRow.DataKey("CveModulo")
End Sub
Protected Sub GvDatos_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvDatos.RowUpdating
Dim gvr As GridViewRow = GvDatos.Rows(e.RowIndex)
Dim CveParametro As Integer = GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero
Dim Parametro As New ClsSisParametros
If Parametro.UpdateParametros(gvr.FCTextBox("TxtCveParam").Text, gvr.FCTextBox("TxtDescrip").Text, gvr.FCDropDownList("CboModulo").SelectedValue.ToEntero,
gvr.FCTextBox("TxtStrValor1").Text, gvr.FCTextBox("TxtStrValor2").Text, gvr.FCTextBox("TxtNumValor1").Text, gvr.FCTextBox("TxtNumValor2").Text,
gvr.FCTextBox("TxtDTValor1").Text, gvr.FCTextBox("TxtDTValor2").Text, gvr.FCTextBox("TxtFechaVencimiento").Text, UsuarioActual.CveUsuario, CveParametro) Then
GvDatos.EditIndex = -1
ViewState("DTParametros") = Parametro.DtResultados
Application("GlobalDTParametros") = Parametro.DtResultados
End If
Parametro.Dispose()
If ViewState("Orden").ToString() <> String.Empty Then
CargaGrid(ViewState("Orden").ToString())
Else
CargaGrid("")
End If
End Sub
Protected Sub GvDatos_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvDatos.RowCancelingEdit
GvDatos.EditIndex = -1
If ViewState("Orden").ToString() <> String.Empty Then
CargaGrid(ViewState("Orden").ToString())
Else
CargaGrid("")
End If
End Sub
Protected Sub GvDatos_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
Dim Parametro As New ClsSisParametros
If Parametro.RemoveParametros(GvDatos.DataKeys(e.RowIndex).Value.ToString().ToEntero()) Then
GvDatos.EditIndex = -1
ViewState("DTParametros") = Parametro.DtResultados
End If
Parametro.Dispose()
If ViewState("Orden").ToString() <> String.Empty Then
CargaGrid(ViewState("Orden").ToString())
Else
CargaGrid("")
End If
End Sub
#End Region
#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("<i class='fa fa-sort-asc' style='color:#999' ></i>")
Else
ViewState(String.Format("O{0}", Campo)) = String.Format("{0} DESC", Campo)
Literal.Text = String.Format("<i class='fa fa-sort-desc' style='color:#999' ></i>")
End If
Orden = OrdenInicial & ViewState(String.Format("O{0}", Campo)).ToString
ViewState("Orden") = Orden
CargaGrid(Orden)
End Sub
Private Sub CargaGrid(ByVal Orden As String)
If Orden <> String.Empty Then
Dim DV As New DataView(CType(ViewState("DTParametros"), DataTable), "", Orden, DataViewRowState.CurrentRows)
GvDatos.DataSource = DV.ToTable()
DV.Dispose()
Else
GvDatos.DataSource = CType(ViewState("DTParametros"), DataTable)
End If
Application("GlobalDTParametros") = CType(ViewState("DTParametros"), DataTable)
GvDatos.DataBind()
UpDatos.Update()
End Sub
#End Region
End Class