Commit inicial Ventas Productivo
This commit is contained in:
238
Sistemas/RolesDetalle.aspx.vb
Normal file
238
Sistemas/RolesDetalle.aspx.vb
Normal file
@@ -0,0 +1,238 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports System.Data
|
||||
Imports System.Drawing
|
||||
Imports Extensiones
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
Partial Class Sistemas_RolesDetalle
|
||||
Inherits ClsPaginas
|
||||
#Region "Propiedades"
|
||||
Private Property CveRol As Integer
|
||||
Get
|
||||
CveRol = ViewState("CveRol").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveRol") = value
|
||||
End Set
|
||||
End Property
|
||||
#End Region
|
||||
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
||||
If Not IsPostBack Then
|
||||
CveRol = If(Request("CveRol") <> "", Request("CveRol").ToString.ToEntero, "-1".ToEntero)
|
||||
CargaDatos()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub CargaDatos()
|
||||
CargaGridIndicadores()
|
||||
CargaGridPermisos()
|
||||
CargaGridProcesos()
|
||||
DdlModulo.DataSource = GlobalDTModulos()
|
||||
DdlModulo.DataBind()
|
||||
|
||||
If CveRol <> -1 Then
|
||||
Dim DTRoles As New DataTable
|
||||
Dim Objeto As New ClsSisRoles
|
||||
If Objeto.GetRoles(CveRol, UsuarioActual.CveEmpresa) Then
|
||||
DTRoles = Objeto.DtResultados
|
||||
If DTRoles.Rows.Count > 0 Then
|
||||
LblRol.Text = DTRoles.FiltroPrimeroValor("Rol")
|
||||
TxtRol.Text = DTRoles.FiltroPrimeroValor("Rol")
|
||||
TxtFecha.Text = DTRoles.FiltroPrimeroValor("FechaIng").ToDate.ToShortDateString
|
||||
TxtUsuarioAlta.Text = DTRoles.FiltroPrimeroValor("Nombre")
|
||||
DdlModulo.SelectedValueExist(DTRoles.FiltroPrimeroValor("CveModulo").ToEntero)
|
||||
Else
|
||||
Dim Liga = $"document.location.href=""/Sistemas/CatRoles.aspx"";"
|
||||
Alert("El Rol solicitado no existe.", TipoMensaje.MsgAdvertencia, Liga)
|
||||
|
||||
End If
|
||||
|
||||
Objeto.Dispose()
|
||||
End If
|
||||
Else
|
||||
LblFechaAlta.Visible = False
|
||||
LblUsuarioAlta.Visible = False
|
||||
End If
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
#Region "I N D I C A D O R E S"
|
||||
Private Sub CargaGridIndicadores()
|
||||
Dim Objeto As New ClsIndicadores
|
||||
If Objeto.GetRolesIndicadores(CveRol) Then
|
||||
GvIndicadores.DataSource = Objeto.DtResultados
|
||||
End If
|
||||
GvIndicadores.DataBind()
|
||||
UpDatos.Update()
|
||||
Objeto.Dispose()
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub GvIndicadores_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvIndicadores.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
If e.Row.DBCampo("CveRol").ToString.ToEntero = CveRol Then
|
||||
e.Row.FCCheckBox("chkIndicador").Checked = True
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "P E R M I S O S"
|
||||
Protected Sub GvPermisos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPermisos.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
If (e.Row.DBCampo("CveModuloAcceso")) <> "" Then e.Row.FCCheckBox("ChkP").Checked = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub CargaGridPermisos()
|
||||
Dim ObjPermisos As New ClsSisRoles()
|
||||
If ObjPermisos.GetRolesModulos(CveRol, -1) Then
|
||||
GvPermisos.DataSource = ObjPermisos.DtResultados.FiltraParametros("AGRUPACION ='N'")
|
||||
Else
|
||||
GvPermisos.DataSource = Nothing
|
||||
End If
|
||||
ObjPermisos.Dispose()
|
||||
GvPermisos.DataBind()
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "P R O C E S O S"
|
||||
Private Sub CargaGridProcesos()
|
||||
Dim ObjPermisos As New ClsSisRoles()
|
||||
If ObjPermisos.GetRolesProcesos(CveRol, -1) Then
|
||||
GvProcesos.DataSource = ObjPermisos.DtResultados
|
||||
Else
|
||||
GvProcesos.DataSource = Nothing
|
||||
End If
|
||||
ObjPermisos.Dispose()
|
||||
GvProcesos.DataBind()
|
||||
End Sub
|
||||
|
||||
|
||||
Protected Sub GvProcesos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvProcesos.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
|
||||
If (e.Row.DBCampo("CveModuloAcceso")) <> "" Then
|
||||
e.Row.Cells(0).CssClass = "bg-yellow"
|
||||
End If
|
||||
If (e.Row.DBCampo("CveProcesoAcceso")) <> "" Then e.Row.FCCheckBox("ChkP").Checked = True
|
||||
|
||||
End If
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
Private Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
|
||||
Dim ObjEmpresa As New ClsSisEmpresas
|
||||
Dim ObjIndicador As New ClsIndicadores(ObjEmpresa.IniciaTransacSQL())
|
||||
Dim Roles As New ClsSisRoles(ObjEmpresa.IniciaTransacSQL())
|
||||
Dim TieneError As Boolean = False
|
||||
|
||||
If CveRol <> -1 Then
|
||||
If TxtRol.Text <> LblRol.Text And CveRol <> -1 Then
|
||||
If Not Roles.UpdateRol(DdlModulo.SelectedValue.ToEntero, TxtRol.Text, UsuarioActual.CveUsuario, CveRol) Then
|
||||
TieneError = True
|
||||
Exit Sub
|
||||
End If
|
||||
End If
|
||||
|
||||
'Agregar Indicadores
|
||||
For Each Row As GridViewRow In GvIndicadores.Rows
|
||||
|
||||
If Row.DataKey("CveIndicador") <> "" AndAlso Row.DataKey("CveRol") <> "" And Row.FCCheckBox("chkIndicador").Checked = False Then
|
||||
If Not ObjIndicador.RemoveIndicadoresRoles(Row.DataKey("CveIndicador").ToEntero, CveRol) Then
|
||||
TieneError = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
If Row.DataKey("CveIndicador") <> "" AndAlso Row.DataKey("CveRol") = "" Then
|
||||
If Row.FCCheckBox("chkIndicador").Checked Then
|
||||
If Not ObjIndicador.AddIndicadoresRoles(Row.DataKey("CveIndicador").ToEntero, CveRol) Then
|
||||
TieneError = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
|
||||
|
||||
For Each Row As GridViewRow In GvPermisos.Rows
|
||||
If Not Roles.UpdateRolesModulos(Row.DataKey("CveRol").ToEntero, Row.DataKey("CveModulo").ToEntero, If(Row.FCCheckBox("ChkP").Checked, 1, 0), UsuarioActual.CveUsuario) Then
|
||||
TieneError = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
For Each Row As GridViewRow In GvProcesos.Rows
|
||||
If Not Roles.UpdateRolesProcesos(Row.DataKey("CveRol").ToEntero, Row.DataKey("CveProceso").ToEntero, If(Row.FCCheckBox("ChkP").Checked, 1, 0), UsuarioActual.CveUsuario) Then
|
||||
TieneError = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
|
||||
|
||||
ElseIf CveRol = -1 Then
|
||||
|
||||
If Not Roles.AddRol(DdlModulo.SelectedValue.ToEntero, TxtRol.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
CveRol = Roles.CveRol
|
||||
|
||||
For Each Row As GridViewRow In GvIndicadores.Rows
|
||||
If Row.DataKey("CveIndicador") <> "" AndAlso Row.DataKey("CveRol") = "" Then
|
||||
If Row.FCCheckBox("chkIndicador").Checked Then
|
||||
If Not ObjIndicador.AddIndicadoresRoles(Row.DataKey("CveIndicador").ToEntero, CveRol) Then
|
||||
TieneError = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
For Each Row As GridViewRow In GvPermisos.Rows
|
||||
If Not Roles.UpdateRolesModulos(CveRol, Row.DataKey("CveModulo").ToEntero, If(Row.FCCheckBox("ChkP").Checked, 1, 0), UsuarioActual.CveUsuario) Then
|
||||
TieneError = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
For Each Row As GridViewRow In GvProcesos.Rows
|
||||
If Not Roles.UpdateRolesProcesos(CveRol, Row.DataKey("CveProceso").ToEntero, If(Row.FCCheckBox("ChkP").Checked, 1, 0), UsuarioActual.CveUsuario) Then
|
||||
TieneError = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
End If
|
||||
|
||||
|
||||
|
||||
If TieneError = False Then
|
||||
Dim Liga = $"document.location.href=""/Sistemas/CatRoles.aspx"";"
|
||||
Alert("Se han guardado los cambios correctamente.", TipoMensaje.MsgInformacion, Liga)
|
||||
ObjEmpresa.Commit()
|
||||
Else
|
||||
Alert("Ha ocurrido un problema, no se han guardado los cambios.", TipoMensaje.MsgError)
|
||||
ObjEmpresa.RollBack()
|
||||
End If
|
||||
|
||||
ObjEmpresa.Dispose()
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user