Public Class EditarABMpermisos
#Region "Movimiento del Formulario"
'Declaraciones API Windows
Private Declare Function SendMessage _
Lib "user32" _
Alias "SendMessageA" ( _
ByVal hwnd As Integer, _
ByVal wMsg As Integer, _
ByVal wParam As Integer, _
ByRef lParam As Object) As Integer
Private Declare Function ReleaseCapture Lib "user32" () As Integer
' constantes / variables
Private Const WM_NCLBUTTONDOWN As Integer = &HA1
Private Const HTCAPTION As Integer = 2
Sub Mover_Formulario(ByVal frm As Form)
ReleaseCapture()
'cambiar el puntero
Me.Cursor = Cursors.SizeAll
If Me.WindowState = FormWindowState.Normal Then
Dim ret As Integer = SendMessage( _
frm.Handle.ToInt32, _
WM_NCLBUTTONDOWN, _
HTCAPTION, 0)
End If
'reestablecer el cursor al soltar
Me.Cursor = Cursors.Default
End Sub
'Evento del Formulario para soltar *************************************************************************
Private Sub MensajeSistema_KeyDown( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Escape Then Me.Close()
End Sub
'Muevo desde el Formulario *************************************************************************
Private Sub MensajeSistema_MouseDown( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
' pasar el formulario como parámetro
Mover_Formulario(Me)
End If
End Sub
'Muevo desde la barra *************************************************************************
Private Sub TSMenu_MouseDown(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles TSMenu.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
' pasar el formulario como parámetro
Mover_Formulario(Me)
End If
End Sub
#End Region
#Region "Declaraciones"
Public Enum Tipo
Perfil
Usuario
End Enum
Public TipoIngreso As Tipo
Private mDt As New DataTable
Private IdAplicacionSeleccionada As Integer
Private IdAplicacionSel As Integer
Private IdPerfilSel As Integer
Private IdUsuarioSel As Integer
Private IdControlSel As Integer
Private VisibleSel As Boolean
Private ActivoSel As Boolean
#End Region
#Region "Funciones"
Private Sub ListarPerfiles()
mDt = New DataTable
mDt = ConexionSQL.EjecutarSP("SP_HERRAMIENTAS_SIGMA_SEGURIDAD_LISTADO_PERFILES")
If Not IsNothing(mDt) Then
GLUE_Perfiles.Properties.DataSource = mDt
Else
GLUE_Perfiles.Properties.DataSource = Nothing
End If
End Sub
Private Sub ListarUsuarios()
mDt = New DataTable
mDt = ConexionSQL.EjecutarSP("SP_HERRAMIENTAS_SIGMA_SEGURIDAD_LISTADO_USUARIOS")
If Not IsNothing(mDt) Then
GLUE_Usuarios.Properties.DataSource = mDt
Else
GLUE_Usuarios.Properties.DataSource = Nothing
End If
End Sub
Private Sub ListarControlesPorPerfil()
If (Not IsNothing(GLUE_Aplicaciones.EditValue)) And (Not IsNothing(GLUE_Perfiles.EditValue)) Then
mDt = New DataTable
mDt = ConexionSQL.EjecutarSP("SP_HERRAMIENTAS_SIGMA_SEGURIDAD_LISTADO_DE_CONTROLES_POR_PERFIL", GLUE_Aplicaciones.EditValue, GLUE_Perfiles.EditValue)
If Not IsNothing(mDt) Then
GcPermisos.DataSource = mDt
Else
GcPermisos.DataSource = Nothing
End If
Else
GcPermisos.DataSource = Nothing
End If
End Sub
Private Sub GrabarPermisosPorPerfil()
IdAplicacionSel = GLUE_Aplicaciones.EditValue
IdPerfilSel = GLUE_Perfiles.EditValue
For i As Integer = 0 To GvPermisos.RowCount - 1
IdControlSel = GvPermisos.GetRowCellValue(i, "IDCONTROL")
VisibleSel = GvPermisos.GetRowCellValue(i, "VISIBLE")
ActivoSel = GvPermisos.GetRowCellValue(i, "ACTIVO")
ConexionSQL.EjecutarSP("SP_HERRAMIENTAS_SIGMA_SEGURIDAD_INGRESAR_PERMISO_POR_PERFIL", IdControlSel, IdAplicacionSel, IdPerfilSel, VisibleSel, ActivoSel)
Next
CargarControlesPerfil(IdAplicacionSel, IdPerfilSel)
End Sub
'----------------------------------------------
Private Sub CargarControlesPerfil(ByVal iAplicacion As Integer, ByVal iperfil As Integer)
'objInformesRN.SP_HERRAMIENTAS_SIGMA_SEGURIDAD_LISTADO_CONTROLES_POR_PERFIL(My.Application.IDAPLICACION, My.Application.IDPERFIL)
'mDtListadoControles = objInformesRN.Tabla
Dim aDtListaControlPerfil = New DataTable
aDtListaControlPerfil = ConexionSQL.EjecutarSP("SP_HERRAMIENTAS_SIGMA_SEGURIDAD_LISTADO_CONTROLES_POR_PERFIL", iAplicacion, iperfil)
CambiarControlPorSeguridad(aDtListaControlPerfil)
End Sub
Public Sub CambiarControlPorSeguridad(ByRef mdtListadocontroles1 As DataTable)
Dim Ncontrol As String
Dim Cactivo As Boolean
Dim Cvisible As Boolean
For i As Integer = 0 To mdtListadocontroles1.Rows.Count - 1
Ncontrol = mdtListadocontroles1.Rows(i).Item("NOMBRECONTROL")
Cvisible = mdtListadocontroles1.Rows(i).Item("VISIBLE")
Cactivo = mdtListadocontroles1.Rows(i).Item("ACTIVO")
If Cactivo = False Or Cvisible = False Then
ConexionSQL.EjecutarSP("SP_HERRAMIENTAS_SIGMA_SEGURIDAD_MODIFICAR_ESTADO_CONTROLES_POR_USUARIO", My.Application.IDAPLICACION, Ncontrol, Cactivo, Cvisible, My.Application.IDUSUARIO)
End If
Next
End Sub
'----------------------------------------
Private Sub ListadoDeControlesPorUsuario()
mDt = New DataTable
mDt = ConexionSQL.EjecutarSP("SP_HERRAMIENTAS_SIGMA_SEGURIDAD_LISTADO_DE_CONTROLES_POR_USUARIO", GLUE_Aplicaciones.EditValue, GLUE_Usuarios.EditValue)
If Not IsNothing(mDt) Then
GcPermisos.DataSource = mDt
Else
GcPermisos.DataSource = Nothing
End If
End Sub
Private Sub GrabarPermisosPorUsuario()
IdAplicacionSel = GLUE_Aplicaciones.EditValue
IdUsuarioSel = GLUE_Usuarios.EditValue
For i As Integer = 0 To GvPermisos.RowCount - 1
IdControlSel = GvPermisos.GetRowCellValue(i, "IDCONTROL")
VisibleSel = GvPermisos.GetRowCellValue(i, "VISIBLE")
ActivoSel = GvPermisos.GetRowCellValue(i, "ACTIVO")
ConexionSQL.EjecutarSP("SP_HERRAMIENTAS_SIGMA_SEGURIDAD_INGRESAR_PERMISO_POR_USUARIO", IdControlSel, IdAplicacionSel, IdUsuarioSel, VisibleSel, ActivoSel)
Next
ConexionSQL.EjecutarSP("SP_HERRAMIENTAS_SIGMA_SEGURIDAD_LIMPIAR_LISTADO_CONTROLES_POR_USUARIO", IdAplicacionSel, IdUsuarioSel)
End Sub
Private Sub IniciarAplicacion()
ListarControles() 'carga listado de aplicaciones
If TipoIngreso = Tipo.Perfil Then
PanelUsuario.Enabled = False
PanelUsuario.Visible = False
ListarPerfiles()
ElseIf TipoIngreso = Tipo.Usuario Then
PanelPerfil.Enabled = False
PanelPerfil.Visible = False
ListarUsuarios()
End If
End Sub
Private Sub ListarControles()
mDt = New DataTable
mDt = ConexionSQL.EjecutarSP("SP_HERRAMIENTAS_SIGMA_SEGURIDAD_LISTADO_APLICACIONES")
If Not IsNothing(mDt) Then
GLUE_Aplicaciones.Properties.DataSource = mDt
Else
GLUE_Aplicaciones.Properties.DataSource = Nothing
End If
End Sub
#End Region
#Region "Eventos"
Private Sub BTCancelar_Click(sender As Object, e As EventArgs) Handles BTCancelar.Click
Me.Close()
End Sub
Private Sub TSB_Maximizar_Click(sender As Object, e As EventArgs) Handles TSB_Maximizar.Click
If Me.WindowState = FormWindowState.Maximized Then
Me.WindowState = FormWindowState.Normal
Else
Me.WindowState = FormWindowState.Maximized
End If
End Sub
Private Sub EditarPermisos_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
IniciarAplicacion()
validarChebox()
Catch ex As Exception
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: al listar controles por perfil." & vbCrLf & ex.Message.ToString).ShowDialog()
End Try
End Sub
Private Sub GLUE_Aplicaciones_EditValueChanged(sender As Object, e As EventArgs) Handles GLUE_Aplicaciones.EditValueChanged
Try
ListarControlesPorPerfil()
Catch ex As Exception
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: al listar controles por perfil." & vbCrLf & ex.Message.ToString).ShowDialog()
End Try
End Sub
Private Sub GLUE_Perfiles_EditValueChanged(sender As Object, e As EventArgs) Handles GLUE_Perfiles.EditValueChanged
Try
ListarControlesPorPerfil()
validarChebox()
Catch ex As Exception
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: al listar controles por perfil." & vbCrLf & ex.Message.ToString).ShowDialog()
End Try
End Sub
Private Sub BtnGrabar_Click(sender As Object, e As EventArgs) Handles BtnGrabar.Click
Try
If GvPermisos.RowCount > 0 Then
If IsNothing(GLUE_Aplicaciones.EditValue) Then
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: no se ha seleccionado una aplicación válida.").ShowDialog()
Exit Sub
End If
If TipoIngreso = Tipo.Perfil Then
If IsNothing(GLUE_Perfiles.EditValue) Then
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: no se ha seleccionado un perfil válido.").ShowDialog()
Exit Sub
End If
GrabarPermisosPorPerfil()
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Correcto, "Se grabó correctamente.").ShowDialog()
Me.Close()
ElseIf TipoIngreso = Tipo.Usuario Then
If IsNothing(GLUE_Usuarios.EditValue) Then
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: no se ha seleccionado un usuario válido.").ShowDialog()
Exit Sub
End If
GrabarPermisosPorUsuario()
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Correcto, "Se grabó correctamente").ShowDialog()
Me.Close()
End If
Else
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: selección no válida.").ShowDialog()
End If
Catch ex As Exception
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: al intentar grabar." & vbCrLf & ex.Message.ToString).ShowDialog()
End Try
End Sub
Private Sub GLUE_Usuarios_EditValueChanged(sender As Object, e As EventArgs) Handles GLUE_Usuarios.EditValueChanged
Try
ListadoDeControlesPorUsuario()
validarChebox()
Catch ex As Exception
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: al intentar listar controles por usuario." & vbCrLf & ex.Message.ToString).ShowDialog()
End Try
End Sub
#End Region
Private Sub CB_ActivarTodos_CheckedChanged(sender As Object, e As EventArgs) Handles CHB_ActivarTodos.CheckedChanged
Try
If IsNothing(GLUE_Aplicaciones.EditValue) Then
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: no se ha seleccionado una aplicación válida.").ShowDialog()
Exit Sub
End If
If TipoIngreso = Tipo.Perfil Then
If IsNothing(GLUE_Perfiles.EditValue) Then
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: no se ha seleccionado un perfil válido.").ShowDialog()
Exit Sub
End If
ElseIf TipoIngreso = Tipo.Usuario Then
If IsNothing(GLUE_Usuarios.EditValue) Then
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: no se ha seleccionado un Usuario válido.").ShowDialog()
Exit Sub
End If
End If
IdAplicacionSel = GLUE_Aplicaciones.EditValue
IdPerfilSel = GLUE_Perfiles.EditValue
If CHB_ActivarTodos.Checked = False Then
For i As Integer = 0 To GvPermisos.RowCount - 1
GvPermisos.SetRowCellValue(i, "ACTIVO", False)
Next
Else
For i As Integer = 0 To GvPermisos.RowCount - 1
GvPermisos.SetRowCellValue(i, "ACTIVO", True)
Next
End If
Catch ex As Exception
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR RB001: al intentar Seleccionar todo los registros visibles." & vbCrLf & ex.Message.ToString).ShowDialog()
End Try
End Sub
Sub validarChebox()
Try
If Not IsNothing(GLUE_Perfiles.EditValue) Or Not IsNothing(GLUE_Usuarios.EditValue) Then
CHB_VisibleTodos.Enabled = True
CHB_ActivarTodos.Enabled = True
Else
CHB_VisibleTodos.Enabled = False
CHB_ActivarTodos.Enabled = False
End If
' CHB_VisibleTodos.Checked = False
' CHB_ActivarTodos.Checked = False
Catch ex As Exception
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR CH0024: " & vbCrLf & ex.Message.ToString).ShowDialog()
End Try
End Sub
Private Sub CHB_VisibleTodos_CheckedChanged(sender As Object, e As EventArgs) Handles CHB_VisibleTodos.CheckedChanged
Try
If IsNothing(GLUE_Aplicaciones.EditValue) Then
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: no se ha seleccionado una aplicación válida.").ShowDialog()
Exit Sub
End If
If TipoIngreso = Tipo.Perfil Then
If IsNothing(GLUE_Perfiles.EditValue) Then
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: no se ha seleccionado un perfil válido.").ShowDialog()
Exit Sub
End If
ElseIf TipoIngreso = Tipo.Usuario Then
If IsNothing(GLUE_Usuarios.EditValue) Then
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: no se ha seleccionado un Usuario válido.").ShowDialog()
Exit Sub
End If
End If
IdAplicacionSel = GLUE_Aplicaciones.EditValue
IdPerfilSel = GLUE_Perfiles.EditValue
If CHB_VisibleTodos.Checked = False Then
For i As Integer = 0 To GvPermisos.RowCount - 1
GvPermisos.SetRowCellValue(i, "VISIBLE", False)
Next
Else
For i As Integer = 0 To GvPermisos.RowCount - 1
GvPermisos.SetRowCellValue(i, "VISIBLE", True)
Next
End If
Catch ex As Exception
GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR RB001: al intentar Seleccionar todo los registros visibles." & vbCrLf & ex.Message.ToString).ShowDialog()
End Try
End Sub
End Class
Suscribirse a:
Enviar comentarios (Atom)
Los mail de oulook no se pueden reenviar.
cuando en el asunto poseen un caracter especial por ejemplo @#$ los correos no salen y no te muestra ningun correo de rebote, especialmente...
-
https://msdn.microsoft.com/en-us/library/office/ff192694.aspx filtros DoCmd.SetFilter Method (Access) Office 2013 and later Ot...
-
Tabla de operadores Access para Office 365 Access 2019 Access 2016 Access 2013 Access 2010 Access 2007 Un operador es...
No hay comentarios:
Publicar un comentario