1015 lines
56 KiB
VB.net
1015 lines
56 KiB
VB.net
Imports System.Data
|
|
Imports Extensiones
|
|
Partial Class Sistemas_PopUpAddUsuario
|
|
Inherits ClsPaginas
|
|
#Region "PROPIEDADES"
|
|
Public Property CveCliente As Integer
|
|
Get
|
|
Return ViewState("CveCliente").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveCliente") = value
|
|
End Set
|
|
End Property
|
|
Public Property CveProveedor As Integer
|
|
Get
|
|
Return ViewState("CveProveedor").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveProveedor") = value
|
|
End Set
|
|
End Property
|
|
Public Property CveUsuario As Integer
|
|
Get
|
|
Return ViewState("CveUsuario").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveUsuario") = value
|
|
End Set
|
|
End Property
|
|
Private Property DTModulos As DataTable
|
|
Get
|
|
Return CType(ViewState("DTModulos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTModulos") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property DtNotificacionesUsuarios As DataTable
|
|
Get
|
|
Return CType(ViewState("DtNotificacionesUsuarios"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtNotificacionesUsuarios") = value
|
|
End Set
|
|
End Property
|
|
Public Property CvePlataforma As Integer
|
|
Get
|
|
Return ViewState("CvePlataforma").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CvePlataforma") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
CType(Me.Master, BaseMasterPage).EsPopup = True
|
|
If Request("CveUsuario") IsNot Nothing AndAlso IsNumeric(Request("CveUsuario")) AndAlso Request("CveUsuario").ToEntero > 0 Then
|
|
ViewState("CveUsuario") = Request("CveUsuario").ToEntero
|
|
If CveUsuario > 0 Then
|
|
TxtEmail.Enabled = False
|
|
CargaUsuario()
|
|
End If
|
|
Else
|
|
CveUsuario = -1
|
|
LtlUsuario.Text = "Nuevo Usuario"
|
|
End If
|
|
If Request("CveCliente") IsNot Nothing AndAlso IsNumeric(Request("CveCliente")) AndAlso Request("CveCliente").ToEntero > 0 Then
|
|
ViewState("CveCliente") = Request("CveCliente").ToEntero
|
|
'CargaDispositivos()
|
|
'CargarNotificaciones()
|
|
Else
|
|
CveCliente = -1
|
|
End If
|
|
If Request("CveProveedor") IsNot Nothing AndAlso IsNumeric(Request("CveProveedor")) AndAlso Request("CveProveedor").ToEntero > 0 Then
|
|
ViewState("CveProveedor") = Request("CveProveedor").ToEntero
|
|
'CargaDispositivos()
|
|
'CargarNotificaciones()
|
|
Else
|
|
CveProveedor = -1
|
|
End If
|
|
|
|
If UsuarioActual.Empresa.CvePlataforma = 3 AndAlso (ViewState("CveProveedor") > 0 Or ViewState("CveCliente") > 0) Then
|
|
CargaDispositivos()
|
|
CargarNotificaciones()
|
|
TabApp.Visible = True
|
|
CargaGridModulosAccesoApp()
|
|
End If
|
|
|
|
If UsuarioActual.Empresa.CvePlataforma = 1 AndAlso (ViewState("CveProveedor") > 0 OrElse ViewState("CveCliente") > 0) Then
|
|
TabVehiculos.Visible = False
|
|
TabPermisoVehiculos.Visible = False
|
|
TabNotificaciones.Visible = False
|
|
TabPermisoComandos.Visible = False
|
|
|
|
If CveUsuario > 0 Then
|
|
DivEstatus.Visible = True
|
|
Else
|
|
DivEstatus.Visible = False
|
|
End If
|
|
Else
|
|
DivEstatus.Visible = False
|
|
CargaComandos()
|
|
End If
|
|
|
|
'INICIALIZA CVEPLATAFORMA
|
|
If UsuarioActual.Empresa.CvePlataforma = 1 And ViewState("CveCliente") > 0 Then
|
|
ViewState("CvePlataforma") = 6
|
|
ElseIf UsuarioActual.Empresa.CvePlataforma = 1 And ViewState("CveProveedor") > 0 Then
|
|
ViewState("CvePlataforma") = 7
|
|
Else
|
|
ViewState("CvePlataforma") = 3
|
|
End If
|
|
|
|
CargaModulosAcceso()
|
|
CargaModulosPermisos()
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub CargaUsuario()
|
|
If CveUsuario > 0 Then
|
|
Dim ObjUsuario As New ClsSisUsuarios()
|
|
If ObjUsuario.GetUsuarios(CveUsuario) Then
|
|
LtlUsuario.Text = ObjUsuario.DtResultados.Rows(0)("Usuario").ToString()
|
|
TxtEmail.Text = ObjUsuario.DtResultados.Rows(0)("Correo").ToString()
|
|
TxtNombre.Text = ObjUsuario.DtResultados.Rows(0)("Nombre").ToString()
|
|
ChkEstatus.Checked = ObjUsuario.DtResultados.Rows(0)("Estatus")
|
|
|
|
If ObjUsuario.DtResultados.Rows(0)("CveRol").ToString.ToEntero = 1200 OrElse ObjUsuario.DtResultados.Rows(0)("CveRol").ToString.ToEntero = 1198 Then
|
|
BtnDefaultPWD.Visible = True
|
|
|
|
End If
|
|
Dim Dt As Data.DataTable = GlobalDTUsuarios(CveUsuario)
|
|
Dim empresas As New StringBuilder()
|
|
If Dt.FiltraParametros("CvePlataforma = 3").Rows.Count > 0 Then
|
|
empresas.Append($"<div class='text-center'><h3>Empresas</h3></div>")
|
|
End If
|
|
For Each row As DataRow In Dt.FiltraParametros("CvePlataforma = 3 ", "", {"CveEmpresa", "Empresa"}).Rows
|
|
empresas.Append($"<div><strong>{row("Empresa").ToString()}</strong></div>")
|
|
For Each wor As DataRow In Dt.Select($"CvePlataforma = 3 AND CveCliente>0 AND CveEmpresa={row("CveEmpresa").ToString().ToEntero()}")
|
|
empresas.Append($"<div style='padding-left:15px;'>{wor("Cliente").ToString()}</div>")
|
|
Next
|
|
Next
|
|
LtlEmpresas.Text = empresas.ToString()
|
|
Else
|
|
LtlUsuario.Text = ""
|
|
TxtEmail.Text = ""
|
|
TxtNombre.Text = ""
|
|
LtlEmpresas.Text = ""
|
|
BtnDefaultPWD.Visible = False
|
|
|
|
|
|
End If
|
|
ObjUsuario.Dispose()
|
|
UpUsuario.Update()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub BtnDefaultPWD_Click(sender As Object, e As EventArgs) Handles BtnDefaultPWD.Click
|
|
Dim ObjUsuario As New ClsSisUsuarios
|
|
If ObjUsuario.UpdateUsuarioContrasenia(ContraseñaPredeterminadaEncriptada, CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
If ObjUsuario.UpdateUsuario(LtlUsuario.Text, TxtNombre.Text, -1, TxtEmail.Text, -1, -1, True, True, -1, CveUsuario, -1, -1) Then
|
|
Alert("La contraseña se reestableció correctamente a la contraseña por default '-acceso-'.")
|
|
Dim Liga As String = $"{Context.Request.Url.OriginalString.Substring(0, Context.Request.Url.OriginalString.Length - Context.Request.Url.PathAndQuery.Length)}/LogIn.aspx"
|
|
Dim LigaActivar As String = Liga & "?p=" & Encripta("CveU=" & CveUsuario & "&Clave=" & "-acceso-" & "&Opcion=Activar&Hora=" & DateTime.Now.Ticks& & "&CveE=" & UsuarioActual.CveEmpresa)
|
|
|
|
If UsuarioActual.Empresa.CvePlataforma = 3 Then
|
|
EnviaCorreoGPS(Liga, LigaActivar)
|
|
Else
|
|
EnviaCorreo(Liga, LigaActivar)
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
ObjUsuario.Dispose()
|
|
End Sub
|
|
Private Sub CargaComandos()
|
|
Dim ObjGPS As New ClsGPS
|
|
If ObjGPS.GetUsuariosComandos(CveUsuario, UsuarioActual.CveUsuario, -1) Then
|
|
GvPermisosComandos.DataSource = ObjGPS.DtResultados
|
|
End If
|
|
ObjGPS.Dispose()
|
|
GvPermisosComandos.DataBind()
|
|
UppComandos.Update()
|
|
End Sub
|
|
Private Function ValidaDatos() As Boolean
|
|
Dim Valido As Boolean = False
|
|
|
|
If Not String.IsNullOrEmpty(TxtEmail.Text.Trim) Then
|
|
Valido = True
|
|
Else
|
|
Alert("Debe asginar un correo al usuario", TipoMensaje.MsgAdvertencia)
|
|
Valido = False
|
|
Return Valido
|
|
End If
|
|
|
|
If Not String.IsNullOrEmpty(TxtNombre.Text.Trim) Then
|
|
Valido = True
|
|
Else
|
|
Alert("Debe asignar un nombre al usuario", TipoMensaje.MsgAdvertencia)
|
|
Valido = False
|
|
Return Valido
|
|
End If
|
|
|
|
Dim NumModulos As Integer = 0
|
|
For Each Row As GridViewRow In GvModulosAcceso.Rows
|
|
If Row.RowType = DataControlRowType.DataRow Then
|
|
If Row.FCCheckBox("ChkPermitir").Checked Then
|
|
NumModulos = NumModulos + 1
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
If NumModulos > 0 Or (UsuarioActual.CveEmpresa.Contiene(143, 1)) Then
|
|
Valido = True
|
|
Else
|
|
Alert("Debe seleccionar al menos 1 modulo", TipoMensaje.MsgAdvertencia)
|
|
Valido = False
|
|
Return Valido
|
|
End If
|
|
|
|
Return Valido
|
|
End Function
|
|
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs)
|
|
If Not ValidaDatos() Then
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim HuboError As Boolean
|
|
Dim Editar As Boolean = False
|
|
Dim Mensaje As String = ""
|
|
Dim ObjUsuarios As New ClsSisUsuarios()
|
|
ObjUsuarios.IniciaTransacSQL()
|
|
|
|
Try
|
|
|
|
If CveUsuario = -1 Then
|
|
'VALIDA NO ALTERAR DATOS DE OTRO USUARIO
|
|
'Dim UsuariosExistentes As Integer = GlobalDTUsuarios().COUNT("CveUsuario", $"Usuario IN ('{TxtNombre.Text.Trim}','{TxtEmail.Text.Trim}') OR Correo = '{TxtEmail.Text.Trim}'")
|
|
'If UsuariosExistentes > 0 Then
|
|
' ObjUsuarios.RollBack()
|
|
' ObjUsuarios.Dispose()
|
|
' Alert("Los datos ingresados ya existen en el sistema.Favor de verificar si existe el usuario", TipoMensaje.MsgAdvertencia)
|
|
' Return
|
|
'End If
|
|
Editar = False
|
|
'AGREGA USUARIO
|
|
If UsuarioActual.Empresa.CvePlataforma = 3 Then
|
|
CveUsuario = ObjUsuarios.AddUsuarioPopUp(TxtEmail.Text.Trim, ContraseñaPredeterminadaEncriptada, TxtNombre.Text, TxtEmail.Text, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCliente, CveProveedor)
|
|
ElseIf UsuarioActual.Empresa.CvePlataforma = 1 Then
|
|
CveUsuario = ObjUsuarios.AddUsuarioPortal(TxtEmail.Text.Trim, ContraseñaPredeterminadaEncriptada, TxtNombre.Text, TxtEmail.Text, CveCliente, CveProveedor, CvePlataforma, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
End If
|
|
|
|
'ENVIA CORREO
|
|
If CveUsuario > 0 Then
|
|
Dim Liga As String = $"{Context.Request.Url.OriginalString.Substring(0, Context.Request.Url.OriginalString.Length - Context.Request.Url.PathAndQuery.Length)}/LogIn.aspx"
|
|
Dim LigaActivar As String = Liga & "?p=" & Encripta("CveU=" & CveUsuario & "&Clave=" & "-acceso-" & "&Opcion=Activar&Hora=" & DateTime.Now.Ticks& & "&CveE=" & UsuarioActual.CveEmpresa)
|
|
|
|
If UsuarioActual.Empresa.CvePlataforma = 3 Then
|
|
Mensaje = EnviaCorreoGPS(Liga, LigaActivar)
|
|
Else
|
|
Mensaje = EnviaCorreo(Liga, LigaActivar)
|
|
End If
|
|
|
|
Else
|
|
HuboError = True
|
|
End If
|
|
|
|
'AGREGA ACCESO A MODULOS
|
|
If Not HuboError Then
|
|
For Each Row As GridViewRow In GvModulosAcceso.Rows
|
|
'Nota, permitir, tiene 3 valores, ''(Vacio), no se ha estipulado, '0' que se denego, '1' permitido(aplicado solo cuando no viene del rol
|
|
If Row.DataKey("CveModuloAcceso") <> "" Then
|
|
If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkDenegar").Checked OrElse Row.DataKey("Permitir") = "0" AndAlso Row.FCCheckBox("ChkDenegar").Checked = False Then
|
|
If Not ObjUsuarios.UpdateUsuariosModulos(CveUsuario, Row.DataKey("CveModulo").ToEntero, Not Row.FCCheckBox("ChkDenegar").Checked, UsuarioActual.CveUsuario) Then
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
Else
|
|
If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkPermitir").Checked OrElse Row.DataKey("Permitir") = "1" AndAlso Row.FCCheckBox("ChkPermitir").Checked = False Then
|
|
If Not ObjUsuarios.UpdateUsuariosModulos(CveUsuario, Row.DataKey("CveModulo").ToEntero, Row.FCCheckBox("ChkPermitir").Checked, UsuarioActual.CveUsuario) Then
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
'EXCLUSIVO GPS -- DISPOSITIVOS, COMANDOS
|
|
If UsuarioActual.Empresa.CvePlataforma = 3 Then
|
|
If Not HuboError AndAlso CveCliente > 0 AndAlso UsuarioActual.Empresa.CvePlataforma = 3 Then
|
|
For Each row As GridViewRow In GvDispositivos.Rows
|
|
If Not ObjUsuarios.UpdateUsuariosDispositivos(CveUsuario, row.DataKey("CveDispositivo").ToEntero, row.FCCheckBox("chkDis").Checked) Then
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
If Not HuboError AndAlso CveCliente > 0 AndAlso UsuarioActual.Empresa.CvePlataforma = 3 Then
|
|
For Each row As GridViewRow In GvPermisosComandos.Rows
|
|
Dim Permitir As Boolean = row.FCCheckBox("ChkP").Checked
|
|
Dim EsFavorito As Boolean = row.FCCheckBox("ChkFavorito").Checked
|
|
If Not ObjUsuarios.UpdateUsuariosComandos(CveUsuario, UsuarioActual.CveUsuario, row.DataKey("CveComando").ToEntero, Permitir, EsFavorito) Then
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
'If Not HuboError AndAlso CveCliente > 0 Then
|
|
' Using ObjNotificaciones As New ClsSisNotificaciones()
|
|
' For Each row As GridViewRow In GVNotificaciones.Rows
|
|
' If row.FCCheckBox("chkCorreo").Checked OrElse row.FCCheckBox("chkVentana").Checked OrElse row.FCCheckBox("chkSMS").Checked OrElse
|
|
' row.FCCheckBox("chkApp").Checked OrElse row.FCCheckBox("chkCampana").Checked Then
|
|
' If Not ObjNotificaciones.AddUsuariosNotificacion(CveUsuario, row.DataKey("CveNotificacion"), row.FCCheckBox("chkCorreo").Checked, row.FCCheckBox("chkVentana").Checked, row.FCCheckBox("chkSMS").Checked,
|
|
' row.FCCheckBox("chkApp").Checked, row.FCCheckBox("chkCampana").Checked) Then
|
|
' HuboError = True
|
|
' End If
|
|
' End If
|
|
' Next
|
|
' End Using
|
|
'End If
|
|
End If
|
|
|
|
'AGREGA PERMISOS
|
|
If Not HuboError Then
|
|
For Each Row As GridViewRow In GvModulosPermiso.Rows
|
|
If Row.DataKey("CveProcesoAcceso") <> "" Then
|
|
'checo si el permiso que tiene es del rol, de ser así, nada más actualizo los denegados
|
|
If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkD").Checked OrElse Row.DataKey("Permitir") = "0" AndAlso Row.FCCheckBox("ChkD").Checked = False Then
|
|
If Not ObjUsuarios.UpdateUsuariosProcesos(CveUsuario, Row.DataKey("CveProceso").ToEntero, Not Row.FCCheckBox("ChkD").Checked, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
Else
|
|
'permisos que el rol, no le está otorgando, y serán únicos para el usuario
|
|
If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkP").Checked OrElse Row.DataKey("Permitir") = "1" AndAlso Row.FCCheckBox("ChkP").Checked = False Then
|
|
If Not ObjUsuarios.UpdateUsuariosProcesos(CveUsuario, Row.DataKey("CveProceso").ToEntero, Row.FCCheckBox("ChkP").Checked, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
ElseIf CveUsuario > 0 Then
|
|
'VALIDA NO ALTERAR DATOS DE OTRO USUARIO
|
|
'Dim DtUsuarios As DataTable = GlobalDTUsuarios.FiltraParametros($"CveUsuario <> {CveUsuario}")
|
|
|
|
Editar = True
|
|
|
|
'Dim UsuariosExistentes As Integer = DtUsuarios.COUNT("CveUsuario", $"Usuario IN ('{TxtEmail.Text.Trim}') OR Correo = '{TxtEmail.Text.Trim}'")
|
|
'If UsuariosExistentes > 0 Then
|
|
' ObjUsuarios.RollBack()
|
|
' ObjUsuarios.Dispose()
|
|
' Alert("Los datos ingresados ya existen en el sistema.Favor de verificar si existe el usuario", TipoMensaje.MsgAdvertencia)
|
|
' Return
|
|
'End If
|
|
|
|
'SI ES UN USUARIO DEL ERP, DEBE DARLE ACCESO AL CLIENTE
|
|
If UsuarioActual.Empresa.CvePlataforma = 1 AndAlso CveCliente > 0 Then
|
|
Dim DtClientesAcceso As DataTable = Nothing
|
|
If Not HuboError AndAlso ObjUsuarios.GetUsuarioCliente(CveUsuario, CveCliente) Then
|
|
'DEBE AGREGAR EL USUARIO AL CLIENTE
|
|
If ObjUsuarios.DtResultados.Rows.Count = 0 Then
|
|
If Not HuboError AndAlso Not ObjUsuarios.AddUsuarioCliente(CveUsuario, CveCliente) Then
|
|
HuboError = True
|
|
End If
|
|
End If
|
|
Else
|
|
HuboError = True
|
|
End If
|
|
'SI ES UN USUARIO DEL ERP, DEBE DARLE ACCESO AL PROVEEDOR
|
|
ElseIf UsuarioActual.Empresa.CvePlataforma = 1 AndAlso CveProveedor > 0 Then
|
|
Dim DtProveedoresAcceso As DataTable = Nothing
|
|
If Not HuboError AndAlso ObjUsuarios.GetUsuarioProveedor(CveUsuario, CveProveedor) Then
|
|
'DEBE AGREGAR EL USUARIO AL PROVEEDOR
|
|
If ObjUsuarios.DtResultados.Rows.Count = 0 Then
|
|
If Not HuboError AndAlso Not ObjUsuarios.AddUsuarioProveedor(CveUsuario, CveProveedor) Then
|
|
HuboError = True
|
|
End If
|
|
End If
|
|
Else
|
|
HuboError = True
|
|
End If
|
|
ElseIf UsuarioActual.Empresa.CvePlataforma = 3 Then
|
|
If Not ObjUsuarios.UpdateUsuario(LtlUsuario.Text.Trim, TxtNombre.Text, -1, TxtEmail.Text, -1, -1, False, True, -1, CveUsuario, -1, -1) Then
|
|
HuboError = True
|
|
End If
|
|
|
|
If Not HuboError AndAlso Not ObjUsuarios.AddUsuarioCliente(CveUsuario, CveCliente) Then
|
|
HuboError = True
|
|
End If
|
|
|
|
ElseIf CvePlataforma = 6 OrElse CvePlataforma = 7 Then
|
|
If Not ObjUsuarios.UpdateUsuarioPortal(LtlUsuario.Text.Trim, TxtNombre.Text, TxtEmail.Text, ChkEstatus.Checked, "-1", CveCliente, CveProveedor, CveUsuario, UsuarioActual.CveUsuario) Then
|
|
HuboError = True
|
|
End If
|
|
End If
|
|
|
|
If Not HuboError Then
|
|
For Each Row As GridViewRow In GvModulosAcceso.Rows
|
|
'Nota, permitir, tiene 3 valores, ''(Vacio), no se ha estipulado, '0' que se denego, '1' permitido(aplicado solo cuando no viene del rol
|
|
If Row.DataKey("CveModuloAcceso") <> "" Then
|
|
If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkDenegar").Checked OrElse Row.DataKey("Permitir") = "0" AndAlso Row.FCCheckBox("ChkDenegar").Checked = False Then
|
|
If Not ObjUsuarios.UpdateUsuariosModulos(CveUsuario, Row.DataKey("CveModulo").ToEntero, Not Row.FCCheckBox("ChkDenegar").Checked, UsuarioActual.CveUsuario) Then
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
Else
|
|
If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkPermitir").Checked OrElse Row.DataKey("Permitir") = "1" AndAlso Row.FCCheckBox("ChkPermitir").Checked = False Then
|
|
If Not ObjUsuarios.UpdateUsuariosModulos(CveUsuario, Row.DataKey("CveModulo").ToEntero, Row.FCCheckBox("ChkPermitir").Checked, UsuarioActual.CveUsuario) Then
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
For Each Row As GridViewRow In GvModulosApp.Rows
|
|
'Nota, permitir, tiene 3 valores, ''(Vacio), no se ha estipulado, '0' que se denego, '1' permitido(aplicado solo cuando no viene del rol
|
|
If Row.DataKey("CveModuloAcceso") <> "" Then
|
|
If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkDenegar").Checked OrElse Row.DataKey("Permitir") = "0" AndAlso Row.FCCheckBox("ChkDenegar").Checked = False Then
|
|
If Not ObjUsuarios.UpdateUsuariosModulos(CveUsuario, Row.DataKey("CveModulo").ToEntero, Not Row.FCCheckBox("ChkDenegar").Checked, UsuarioActual.CveUsuario) Then
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
Else
|
|
If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkPermitir").Checked OrElse Row.DataKey("Permitir") = "1" AndAlso Row.FCCheckBox("ChkPermitir").Checked = False Then
|
|
If Not ObjUsuarios.UpdateUsuariosModulos(CveUsuario, Row.DataKey("CveModulo").ToEntero, Row.FCCheckBox("ChkPermitir").Checked, UsuarioActual.CveUsuario) Then
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
'EXCLUSIVO GPS
|
|
If Not HuboError AndAlso CveCliente > 0 AndAlso UsuarioActual.Empresa.CvePlataforma = 3 Then
|
|
For Each row As GridViewRow In GvDispositivos.Rows
|
|
If Not ObjUsuarios.UpdateUsuariosDispositivos(CveUsuario, row.DataKey("CveDispositivo").ToEntero, row.FCCheckBox("chkDis").Checked) Then
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
If Not HuboError AndAlso CveCliente > 0 AndAlso UsuarioActual.Empresa.CvePlataforma = 3 Then
|
|
For Each row As GridViewRow In GvPermisosComandos.Rows
|
|
Dim Permitir As Boolean = row.FCCheckBox("ChkP").Checked
|
|
Dim EsFavorito As Boolean = row.FCCheckBox("ChkFavorito").Checked
|
|
If Not ObjUsuarios.UpdateUsuariosComandos(CveUsuario, UsuarioActual.CveUsuario, row.DataKey("CveComando").ToEntero, Permitir, EsFavorito) Then
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
'If Not HuboError AndAlso CveCliente > 0 Then
|
|
' Using ObjNotificaciones As New ClsSisNotificaciones()
|
|
' ObjNotificaciones.DeleteNotificacion(-1, CveUsuario)
|
|
' For Each row As GridViewRow In GVNotificaciones.Rows
|
|
' If row.FCCheckBox("chkCorreo").Checked OrElse row.FCCheckBox("chkVentana").Checked OrElse row.FCCheckBox("chkSMS").Checked OrElse
|
|
' row.FCCheckBox("chkApp").Checked OrElse row.FCCheckBox("chkCampana").Checked Then
|
|
' If Not ObjNotificaciones.AddUsuariosNotificacion(CveUsuario, row.DataKey("CveNotificacion"), row.FCCheckBox("chkCorreo").Checked, row.FCCheckBox("chkVentana").Checked, row.FCCheckBox("chkSMS").Checked,
|
|
' row.FCCheckBox("chkApp").Checked, row.FCCheckBox("chkCampana").Checked) Then
|
|
' HuboError = True
|
|
' End If
|
|
' End If
|
|
' Next
|
|
' End Using
|
|
'End If
|
|
|
|
If Not HuboError Then
|
|
For Each Row As GridViewRow In GvModulosPermiso.Rows
|
|
If Row.DataKey("CveProcesoAcceso") <> "" Then
|
|
'checo si el permiso que tiene es del rol, de ser así, nada más actualizo los denegados
|
|
If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkD").Checked OrElse Row.DataKey("Permitir") = "0" AndAlso Row.FCCheckBox("ChkD").Checked = False Then
|
|
If Not ObjUsuarios.UpdateUsuariosProcesos(CveUsuario, Row.DataKey("CveProceso").ToEntero, Not Row.FCCheckBox("ChkD").Checked, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
Else
|
|
'permisos que el rol, no le está otorgando, y serán únicos para el usuario
|
|
If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkP").Checked OrElse Row.DataKey("Permitir") = "1" AndAlso Row.FCCheckBox("ChkP").Checked = False Then
|
|
If Not ObjUsuarios.UpdateUsuariosProcesos(CveUsuario, Row.DataKey("CveProceso").ToEntero, Row.FCCheckBox("ChkP").Checked, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
End If
|
|
Else
|
|
Alert("Ocurrió un error al agregar el usuario.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
Catch ex As Exception
|
|
HuboError = true
|
|
OnError("Ocurrió un error al agregar el usuario.", ex)
|
|
End Try
|
|
|
|
If Not HuboError Then
|
|
ObjUsuarios.Commit()
|
|
|
|
Dim JSBTN As String = ""
|
|
|
|
If UsuarioActual.Empresa.CvePlataforma = 3 AndAlso UsuarioActual.CveCliente > 0 Then
|
|
JSBTN = $"document.location.href=""javascript:Ir2({CveCliente})"";"
|
|
ElseIf CveCliente > 0 Then
|
|
JSBTN = $"document.location.href=""javascript:Ir({CveCliente})"";"
|
|
ElseIf CveProveedor > 0 Then
|
|
JSBTN = $"document.location.href=""javascript:IrProveedores({CveProveedor})"";"
|
|
End If
|
|
|
|
If Editar Then
|
|
Alert($"El usuario se actualizó correctamente. <br><br>{Mensaje} ", TipoMensaje.MsgInformacion, JSBTN)
|
|
Else
|
|
Alert($"El usuario se guardó correctamente. <br><br>{Mensaje}", TipoMensaje.MsgInformacion, JSBTN)
|
|
End If
|
|
|
|
Else
|
|
ObjUsuarios.RollBack()
|
|
Alert("Ocurrió un error al agregar el usuario.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjUsuarios.Dispose()
|
|
|
|
If Not HuboError AndAlso UsuarioActual.Empresa.CvePlataforma = 3 Then
|
|
|
|
Using ObjNotificaciones As New ClsSisNotificaciones()
|
|
ObjNotificaciones.DeleteNotificacion(-1, CveUsuario)
|
|
For Each row As GridViewRow In GVNotificaciones.Rows
|
|
If row.FCCheckBox("chkCorreo").Checked OrElse row.FCCheckBox("chkVentana").Checked OrElse row.FCCheckBox("chkSMS").Checked OrElse
|
|
row.FCCheckBox("chkApp").Checked OrElse row.FCCheckBox("chkCampana").Checked Then
|
|
If Not ObjNotificaciones.AddUsuariosNotificacion(CveUsuario, row.DataKey("CveNotificacion"), row.FCCheckBox("chkCorreo").Checked, row.FCCheckBox("chkVentana").Checked, row.FCCheckBox("chkSMS").Checked,
|
|
row.FCCheckBox("chkApp").Checked, row.FCCheckBox("chkCampana").Checked) Then
|
|
HuboError = True
|
|
End If
|
|
End If
|
|
Next
|
|
End Using
|
|
|
|
End If
|
|
|
|
RecargarGlobalUsuarios()
|
|
RecargarGlobal()
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub RecargarGlobal()
|
|
Dim GPS As New ClsGPS
|
|
If GPS.DispositivosUsuariosGet(-1, -1, -1, -1, -1) Then
|
|
GlobalDTDispositivosUsuarios(-1, -1) = GPS.DtResultados
|
|
End If
|
|
GPS.Dispose()
|
|
End Sub
|
|
Private Sub RecargarGlobalUsuarios()
|
|
GlobalDTUsuarios(-1, CveEmpresa:=UsuarioActual.CveEmpresa) = Nothing
|
|
GlobalDTAlmacenUsuarios(-1, UsuarioActual.CveEmpresa) = Nothing
|
|
'Dim ObjUsuarios As New ClsSisUsuarios
|
|
'If ObjUsuarios.GetUsuariosEmpresas(-1) Then
|
|
' Application("GlobalDTUsuarios") = ObjUsuarios.DtResultados
|
|
' Application("GlobalDTUsuarioResponsable") = ObjUsuarios.DtResultados.FiltraParametros("ProveedoresResponsables > 0")
|
|
'End If
|
|
'ObjUsuarios.Dispose()
|
|
End Sub
|
|
|
|
#Region "MANDAR CORREOS"
|
|
Private Function EnviaCorreo(Liga As String, LigaActivar As String) As String
|
|
Dim Retorno As String = ""
|
|
Try
|
|
Dim URL As String = UrlSitio
|
|
|
|
If UsuarioActual.Empresa.CvePlataforma = 3 Then
|
|
URL = "https://gps.signalsgps.com/"
|
|
End If
|
|
|
|
Dim Para = TxtEmail.Text.Trim
|
|
Dim Asunto = ""
|
|
If CveCliente > 0 Then
|
|
Asunto = "ACTIVACIÓN DEL PORTAL DE CLIENTE"
|
|
ElseIf CveProveedor > 0 Then
|
|
Asunto = "ACTIVACIÓN DEL PORTAL DE PROVEEDOR"
|
|
End If
|
|
|
|
Dim SBBody As New StringBuilder
|
|
'Linia de estilos
|
|
SBBody.Append("<style> .mailbody{ background-color:#EEF1F5; padding:15px; font-family :'Open Sans', sans-serif; } .mailcontent{ background-color:#fff; font-size: 14px; color: #333; padding:0px 15px ; } .mailtitle{padding:8px;color:#32C5D2; font-size: 18px;font-weight: 700!important;border-bottom:2px solid #EEF1F5;text-transform: uppercase;}.marco{border: 1px solid #869ab3;border-top: 0;background-color: #67809F; margin: 10px 15px 25px 15px;color: #fff;}.marco-title{padding: 10px 10px;text-transform: uppercase;font-weight: 700!important;}.marco-body{color:#333;background-color:#fff;}.nota{background: #E5E5E5;padding:15px;color:#333;} .logo { font-size:12px; font-style:italic; text-align:right; } .col1{width:180px;font-weight: 700!important;display:inline-block;} .col2{min-width:260px;display:inline-block;} </style>")
|
|
'incio Cuerpo del correo
|
|
SBBody.Append("<div Class='mailbody'>")
|
|
SBBody.Append("<div Class='mailcontent'>")
|
|
SBBody.Append("<div Class='mailtitle'>")
|
|
SBBody.Append("ALTA DE CUENTA")
|
|
SBBody.Append("</div>")
|
|
SBBody.Append("<br/>")
|
|
SBBody.AppendFormat("<b> Estimado {0}:</b><br/>", TxtNombre.Text.ToUpper)
|
|
SBBody.AppendFormat("El presente correo es para informarle que se le han asignado los siguientes datos para el acceso a la Plataforma de: <b>{0}</b><br/><br/>", UsuarioActual.Empresa.Empresa)
|
|
SBBody.Append("<div Class='marco'>")
|
|
SBBody.Append("<div Class='marco-title'>Datos de usuario</div>")
|
|
SBBody.Append("<div Class='marco-body'>")
|
|
SBBody.Append("<div>")
|
|
SBBody.Append("<div>")
|
|
SBBody.Append("<div class='col1'> Usuario</div>")
|
|
SBBody.AppendFormat("<div class='col2'>{0}</div>", TxtEmail.Text)
|
|
SBBody.Append("</div>")
|
|
SBBody.Append("<div>")
|
|
SBBody.Append("<div class='col1'> Accesé al sistema dando click a la liga y estableciendo su contraseña</div>")
|
|
SBBody.AppendFormat("<div class='col2'><a href='{0}'target='_blank'>Activar</a></div>", LigaActivar)
|
|
SBBody.Append("</div>")
|
|
SBBody.Append("</div>")
|
|
SBBody.Append("</div>")
|
|
SBBody.Append("<br/>")
|
|
SBBody.Append("Para Activar su cuenta debera cambiar su contraseña.<br/><br/>")
|
|
SBBody.Append("<div Class='nota'>")
|
|
SBBody.Append("Nota Favor de NO responder este correo. ")
|
|
SBBody.Append("</div><br/><br/>")
|
|
SBBody.AppendFormat("<div class='logo'><img src='{0}Imagenes/LogoSinFondo.png' style='width:30px;'/>ADSistemas </div>", URL)
|
|
SBBody.Append("</div>")
|
|
SBBody.Append("</div>")
|
|
'Termino Cuerpo del correo
|
|
|
|
Dim Hilo As New System.Threading.Thread(Sub() MandaCorreo(Asunto, Para, SBBody.ToString))
|
|
Hilo.Start()
|
|
|
|
'Dim JSBTN As String = ""
|
|
'If UsuarioActual.CveCliente > 0 Then
|
|
' JSBTN = $"document.location.href=""javascript:Ir2({CveCliente})"";"
|
|
'ElseIf CveCliente > 0 Then
|
|
' JSBTN = $"document.location.href=""javascript:Ir({CveCliente})"";"
|
|
'End If
|
|
'If UsuarioActual.Empresa.CvePlataforma = 3 Then
|
|
' Alert("El correo se ha enviado correctamente a: " + TxtEmail.Text + ".", TipoMensaje.MsgInformacion, JSBTN)
|
|
'End If
|
|
|
|
Retorno = $"El correo se ha enviado correctamente a: <b>{TxtEmail.Text}</b>."
|
|
|
|
Catch ex As Exception
|
|
OnError("Ocurrió error al mandar MAIL", ex)
|
|
End Try
|
|
|
|
Return Retorno
|
|
End Function
|
|
|
|
Private Function EnviaCorreoGPS(Liga As String, LigaActivar As String) As String
|
|
Dim Retorno As String = ""
|
|
Try
|
|
'Dim URL As String = "https://gps.signalsgps.com/" + LigaActivar
|
|
|
|
Dim Para = TxtEmail.Text.Trim
|
|
Dim Asunto = "ACCESO A SIGNALS GPS"
|
|
|
|
'Dim SBBody As New StringBuilder
|
|
''Linia de estilos
|
|
'SBBody.Append("<style> .mailbody{ background-color:#EEF1F5; padding:15px; font-family :'Open Sans', sans-serif; } .mailcontent{ background-color:#fff; font-size: 14px; color: #333; padding:0px 15px ; } .mailtitle{padding:8px;color:#32C5D2; font-size: 18px;font-weight: 700!important;border-bottom:2px solid #EEF1F5;text-transform: uppercase;}.marco{border: 1px solid #869ab3;border-top: 0;background-color: #67809F; margin: 10px 15px 25px 15px;color: #fff;}.marco-title{padding: 10px 10px;text-transform: uppercase;font-weight: 700!important;}.marco-body{color:#333;background-color:#fff;}.nota{background: #E5E5E5;padding:15px;color:#333;} .logo { font-size:12px; font-style:italic; text-align:right; } .col1{width:180px;font-weight: 700!important;display:inline-block;} .col2{min-width:260px;display:inline-block;} </style>")
|
|
''incio Cuerpo del correo
|
|
'SBBody.Append("<div Class='mailbody'>")
|
|
'SBBody.Append("<div Class='mailcontent'>")
|
|
'SBBody.Append("<div Class='mailtitle'>")
|
|
'SBBody.Append("ALTA DE CUENTA")
|
|
'SBBody.Append("</div>")
|
|
'SBBody.Append("<br/>")
|
|
'SBBody.AppendFormat("<b> Estimado {0}:</b><br/>", TxtNombre.Text.ToUpper)
|
|
'SBBody.AppendFormat("El presente correo es para informarle que se le han asignado los siguientes datos para el acceso a la Plataforma de: <b>{0}</b><br/><br/>", UsuarioActual.Empresa.Empresa)
|
|
'SBBody.Append("<div Class='marco'>")
|
|
'SBBody.Append("<div Class='marco-title'>Datos de usuario</div>")
|
|
'SBBody.Append("<div Class='marco-body'>")
|
|
'SBBody.Append("<div>")
|
|
'SBBody.Append("<div>")
|
|
'SBBody.Append("<div class='col1'> Usuario</div>")
|
|
'SBBody.AppendFormat("<div class='col2'>{0}</div>", TxtEmail.Text)
|
|
'SBBody.Append("</div>")
|
|
'SBBody.Append("<div>")
|
|
'SBBody.Append("<div class='col1'> Accesé al sistema dando click a la liga y estableciendo su contraseña</div>")
|
|
'SBBody.AppendFormat("<div class='col2'><a href='{0}'target='_blank'>Activar</a></div>", LigaActivar)
|
|
'SBBody.Append("</div>")
|
|
'SBBody.Append("</div>")
|
|
'SBBody.Append("</div>")
|
|
'SBBody.Append("<br/>")
|
|
'SBBody.Append("Para Activar su cuenta debera cambiar su contraseña.<br/><br/>")
|
|
'SBBody.Append("<div Class='nota'>")
|
|
'SBBody.Append("Nota Favor de NO responder este correo. ")
|
|
'SBBody.Append("</div><br/><br/>")
|
|
'SBBody.AppendFormat("<div class='logo'><img src='{0}Imagenes/LogoSinFondo.png' style='width:30px;'/>ADSistemas </div>", URL)
|
|
'SBBody.Append("</div>")
|
|
'SBBody.Append("</div>")
|
|
|
|
Dim SBBody As New StringBuilder()
|
|
|
|
SBBody.Append("<div>")
|
|
SBBody.Append("<div style ='border: none; border-bottom: solid #eef1f5 1.5pt; padding: 0in 0in 6.0pt 0in;'>")
|
|
SBBody.Append(" <table style='border-collapse: collapse;' border='0' cellspacing='0' cellpadding='0'>")
|
|
SBBody.Append(" <tbody>")
|
|
SBBody.Append(" <tr>")
|
|
SBBody.Append(" <td style='width: 65.55pt; padding: 0in 5.4pt 0in 5.4pt;' valign='top' width='87'> </td>")
|
|
SBBody.Append(" <td style='width: 376.5pt; padding: 0in 5.4pt 0in 5.4pt;' valign='bottom' width='502'>")
|
|
SBBody.Append(" <p class='MsoNormal' style='background: white;'><span style='font-size: 13.5pt; font-family: ' Avenir Next LT Pro Light',sans-serif; color: #c00000; text-transform: uppercase;'>DATOS DE ACCESO<u></u><u></u></span></p>")
|
|
SBBody.Append(" <p class='MsoNormal'><span style='font-size: 13.5pt; font-family: ' Avenir Next LT Pro Light',sans-serif; color: #c00000; text-transform: uppercase;'><u></u> <u></u></span></p>")
|
|
SBBody.Append(" </td>")
|
|
SBBody.Append(" </tr>")
|
|
SBBody.Append(" </tbody>")
|
|
SBBody.Append(" </table>")
|
|
SBBody.Append("</div>")
|
|
SBBody.AppendFormat(" <p Class='MsoNormal' style='margin-bottom: 12.0pt; background: white;'><span lang='ES-MX' style='font-size: 10.5pt; font-family: 'Avenir Next LT Pro Light',sans-serif; color: #404040;'><br /><strong>Estimado / a {0}:<u></u><u></u></strong></span></p>", TxtNombre.Text)
|
|
SBBody.Append(" <p Class='MsoNormal' style='margin-bottom: 12.0pt; background: white;'><span lang='ES-MX' style='font-size: 10.5pt; font-family: 'Avenir Next LT Pro Light',sans-serif; color: #333333;'>El presente correo es para informarle que se le han asignado los siguentes datos para el acceso</span><span lang='ES-MX' style='font-size: 10.5pt; font-family: 'Avenir Next LT Pro Light',sans-serif; color: black;'> a la plataforma </span><strong><span lang='ES-MX' style='font-size: 10.5pt; font-family: 'Avenir Next LT Pro Light',sans-serif; color: #c00000;'>SIGNALS GPS</span></strong><u></u><u></u></p>")
|
|
SBBody.Append(" <table style ='border-collapse: collapse;' border='0' cellspacing='0' cellpadding='0'>")
|
|
SBBody.Append(" <tbody>")
|
|
SBBody.Append(" <tr style='height: 21.25pt;'>")
|
|
SBBody.Append(" <td style='width: 441.4pt; border: none; border-bottom: solid #c00000 1.0pt; background: #e7e6e6; padding: 5.4pt 5.4pt 5.4pt 5.4pt; height: 21.25pt;' valign='bottom' width='589'>")
|
|
SBBody.Append(" <p class='MsoNormal' style='margin-bottom: 12.0pt; text-align: center;' align='center'><strong><span style='font-family: ' Avenir Next LT Pro Light',sans-serif; color: #c00000;'>USUARIO ASIGNADO</span></strong><u></u><u></u></p>")
|
|
SBBody.Append(" </td>")
|
|
SBBody.Append(" </tr>")
|
|
SBBody.Append(" <tr>")
|
|
SBBody.Append(" <td style='width: 441.4pt; border: none; border-bottom: solid #c00000 1.0pt; padding: 5.4pt 5.4pt 5.4pt 5.4pt;' valign='top' width='589'>")
|
|
SBBody.Append(" <p class='MsoNormal' style='margin-bottom: 12.0pt;'><strong><span style='font-family: ' Arial Nova Light',sans-serif; color: #c00000;'>Usuario</span></strong><span style='font-family: ' Arial Nova Light',sans-serif; color: #c00000;'>:<u></u><u></u></span></p>")
|
|
SBBody.AppendFormat(" <p class='MsoNormal' style='margin-bottom: 12.0pt;'><span style='font-family: ' Arial Nova Light',sans-serif;'><a href='mailto:{0}' target='_blank' rel='noopener'>{0}</a><u></u><u></u></span></p>", TxtEmail.Text)
|
|
SBBody.Append(" </td>")
|
|
SBBody.Append(" </tr>")
|
|
SBBody.Append(" <tr>")
|
|
SBBody.Append(" <td style='width: 441.4pt; padding: 5.4pt 5.4pt 5.4pt 5.4pt;' valign='top' width='589'>")
|
|
SBBody.Append(" <p class='MsoNormal' style='margin-bottom: 12.0pt;'><strong><span style='font-family: ' Arial Nova Light',sans-serif; color: #c00000;'>Contraseña</span></strong><span style='font-family: ' Arial Nova Light',sans-serif; color: #c00000;'>:<u></u><u></u></span></p>")
|
|
SBBody.Append(" <p class='MsoNormal' style='margin-bottom: 12.0pt;'><span style='font-size: 9.0pt; font-family: ' Arial',sans-serif; color: #333333; background: white;'>-acceso-</span><u></u><u></u></p>")
|
|
SBBody.Append(" </td>")
|
|
SBBody.Append(" </tr>")
|
|
SBBody.Append(" <tr>")
|
|
SBBody.Append(" <td style='width: 441.4pt; background: #c00000; padding: 5.4pt 5.4pt 5.4pt 5.4pt;' valign='top' width='589'>")
|
|
SBBody.AppendFormat(" <p class='MsoNormal' style='margin-bottom: 12.0pt; text-align: center;' align='center'><strong><span style='font-size: 22.0pt; font-family: ' Segoe UI Emoji',sans-serif; color: white;'><img class='CToWUd' style='margin: 0 0.2ex; vertical-align: middle; max-height: 24px;' src='https://mail.google.com/mail/e/1f446' alt='👆' data-goomoji='1f446' data-image-whitelisted=''/></span></strong><strong><span style='font-size: 22.0pt; font-family: ' Arial Nova Light',sans-serif; color: white;'><a href='{0}' target='_blank' rel='noopener' data-saferedirecturl='https://www.google.com/url?q={0}&source=gmail&ust=1617928195657000&usg=AFQjCNGY8Tj8s35QxHYX-RPcqPlzZoBBFg'><span style='color: white;'>INGRESAR A SIGNALS GPS</span></a></span></strong><strong><span style='font-size: 22.0pt; font-family: ' Segoe UI Emoji',sans-serif; color: white;'><img class='CToWUd' style='margin: 0 0.2ex; vertical-align: middle; max-height: 24px;' src='https://mail.google.com/mail/e/1f446' alt='👆' data-goomoji='1f446' data-image-whitelisted=''/></span></strong><u></u><u></u></p>", LigaActivar)
|
|
SBBody.Append(" </td>")
|
|
SBBody.Append(" </tr>")
|
|
SBBody.Append("</tbody>")
|
|
SBBody.Append("</table>")
|
|
SBBody.Append("<div>")
|
|
SBBody.Append("<p Class='MsoNormal' style='margin-bottom: 12.0pt; background: white;'><span lang='ES-MX' style='font-size: 10.5pt; font-family: 'Arial Nova Light',sans-serif; color: #333333;'><br /></span><span lang='ES-MX' style='font-size: 10.5pt; font-family: 'Arial Nova Light',sans-serif; color: black;'>F</span><span lang='ES-MX' style='font-size: 10.5pt; font-family: 'Arial Nova Light',sans-serif; color: #333333;'>avor de NO responder este correo. <u></u><u></u></span></p>")
|
|
SBBody.Append("</div>")
|
|
SBBody.Append(" <p Class='MsoNormal' style='margin-bottom: 12.0pt; background: white;'><span lang='ES-MX' style='font-size: 10.5pt; font-family: 'Arial Nova Light',sans-serif; color: #333333;'><u></u> <u></u></span></p>")
|
|
SBBody.Append("</div>")
|
|
'Termino Cuerpo del correo
|
|
|
|
Dim Hilo As New System.Threading.Thread(Sub() MandaCorreo(Asunto, Para, SBBody.ToString))
|
|
Hilo.Start()
|
|
|
|
'Dim JSBTN As String = ""
|
|
'If UsuarioActual.CveCliente > 0 Then
|
|
' JSBTN = $"document.location.href=""javascript: Ir2({CveCliente})"";"
|
|
'ElseIf CveCliente > 0 Then
|
|
' JSBTN = $"document.location.href=""javascript:Ir({CveCliente})"";"
|
|
'End If
|
|
'If UsuarioActual.Empresa.CvePlataforma = 3 Then
|
|
' Alert("El correo se ha enviado correctamente a: " + TxtEmail.Text + ".", TipoMensaje.MsgInformacion, JSBTN)
|
|
'End If
|
|
|
|
Retorno = $"El correo se ha enviado correctamente a: <b>{TxtEmail.Text}</b>."
|
|
|
|
Catch ex As Exception
|
|
OnError("Ocurrió error al mandar MAIL", ex)
|
|
End Try
|
|
|
|
Return Retorno
|
|
End Function
|
|
Private Sub MandaCorreo(Asunto As String, Para As String, Body As String)
|
|
Dim a As String = String.Format("{0} -- {1} ---- -->", Asunto, Para)
|
|
a.GuardaLog()
|
|
Dim Mail As New ClsSisMail()
|
|
|
|
Dim EmpresaEnvio As Empresa = ClsPaginas.EmpresaNotificaciones
|
|
|
|
If UsuarioActual.Empresa.CvePlataforma = 3 Then
|
|
EmpresaEnvio = ClsPaginas.EmpresaNotificacionesGPS
|
|
End If
|
|
|
|
Mail.SendMail(EmpresaEnvio, Para, Asunto, Body)
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "M O D U L O S"
|
|
Public Sub CargaModulosAcceso()
|
|
Dim ObjPermisos As New ClsSisUsuarios
|
|
If ObjPermisos.GetUsuariosModulos(CveUsuario, UsuarioActual.CveEmpresa, If(False, UsuarioActual.CveUsuario, -1)) Then
|
|
If UsuarioActual.Empresa.CvePlataforma = 1 AndAlso CveCliente > 0 Then
|
|
DTModulos = ObjPermisos.DtResultados.FiltraParametros("Liga <> '' AND CvePlataforma = 6")
|
|
ElseIf UsuarioActual.Empresa.CvePlataforma = 1 AndAlso CveProveedor > 0 Then
|
|
DTModulos = ObjPermisos.DtResultados.FiltraParametros("Liga <> '' AND CvePlataforma = 7")
|
|
Else
|
|
DTModulos = ObjPermisos.DtResultados.FiltraParametros($"Liga <> '' AND CvePlataforma = {UsuarioActual.Empresa.CvePlataforma}")
|
|
End If
|
|
Else
|
|
DTModulos = Nothing
|
|
End If
|
|
|
|
ObjPermisos.Dispose()
|
|
|
|
CargaGridModulosAcceso()
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaGridModulosAcceso()
|
|
GvModulosAcceso.DataSource = DTModulos
|
|
GvModulosAcceso.DataBind()
|
|
If (GvModulosAcceso.Rows.Count > 0) Then
|
|
GvModulosAcceso.UseAccessibleHeader = True
|
|
GvModulosAcceso.HeaderRow.TableSection = TableRowSection.TableHeader
|
|
End If
|
|
|
|
UpDatos.Update()
|
|
End Sub
|
|
Private Sub CargaGridModulosAccesoApp()
|
|
Dim ObjPermisos As New ClsSisUsuarios
|
|
If ObjPermisos.GetUsuariosModulos(CveUsuario, UsuarioActual.CveEmpresa, If(False, UsuarioActual.CveUsuario, -1)) Then
|
|
If UsuarioActual.CveRol = 1 Then
|
|
GvModulosApp.DataSource = ObjPermisos.DtResultados.FiltraParametros($"CvePlataforma = 5")
|
|
Else
|
|
GvModulosApp.DataSource = ObjPermisos.DtResultados.FiltraParametros($"CvePlataforma = 5 AND CveModulo <> 5010")
|
|
End If
|
|
End If
|
|
ObjPermisos.Dispose()
|
|
GvModulosApp.DataBind()
|
|
If (GvModulosApp.Rows.Count > 0) Then
|
|
GvModulosApp.UseAccessibleHeader = True
|
|
GvModulosApp.HeaderRow.TableSection = TableRowSection.TableHeader
|
|
End If
|
|
|
|
UpDatos.Update()
|
|
End Sub
|
|
Protected Sub GvModulosAcceso_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvModulosAcceso.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If (e.Row.DBCampo("Permitir")) = "0" Then
|
|
e.Row.FCCheckBox("ChkDenegar").Checked = True
|
|
End If
|
|
If (e.Row.DBCampo("CveModuloAcceso")) <> "" Then
|
|
e.Row.FCCheckBox("ChkDenegar").Enabled = True
|
|
e.Row.Cells(3).CssClass = "bg-yellow"
|
|
Else
|
|
e.Row.FCCheckBox("ChkPermitir").Enabled = True
|
|
If e.Row.DBCampo("Permitir") = "1" Then e.Row.FCCheckBox("ChkPermitir").Checked = True
|
|
End If
|
|
End If
|
|
End Sub
|
|
Protected Sub GvModulosApp_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvModulosApp.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If (e.Row.DBCampo("Permitir")) = "0" Then
|
|
e.Row.FCCheckBox("ChkDenegar").Checked = True
|
|
End If
|
|
If (e.Row.DBCampo("CveModuloAcceso")) <> "" Then
|
|
e.Row.FCCheckBox("ChkDenegar").Enabled = True
|
|
e.Row.Cells(3).CssClass = "bg-yellow"
|
|
Else
|
|
e.Row.FCCheckBox("ChkPermitir").Enabled = True
|
|
If e.Row.DBCampo("Permitir") = "1" Then e.Row.FCCheckBox("ChkPermitir").Checked = True
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub CargaModulosPermisos()
|
|
Dim ObjProcesos As New ClsSisUsuarios
|
|
|
|
|
|
If ObjProcesos.GetUsuariosProcesos(CveUsuario, If(False, UsuarioActual.CveUsuario, -1)) Then
|
|
If UsuarioActual.Empresa.CvePlataforma = 1 And CveCliente > 0 Then
|
|
GvModulosPermiso.DataSource = ObjProcesos.DtResultados.FiltraParametros($"CvePlataforma = 6")
|
|
ElseIf UsuarioActual.Empresa.CvePlataforma = 1 And CveProveedor > 0 Then
|
|
GvModulosPermiso.DataSource = ObjProcesos.DtResultados.FiltraParametros($"CvePlataforma = 7")
|
|
If CveUsuario > 0 Then
|
|
BtnDefaultPWD.Visible = True
|
|
End If
|
|
ElseIf UsuarioActual.Empresa.CvePlataforma = 3 Then
|
|
GvModulosPermiso.DataSource = ObjProcesos.DtResultados.FiltraParametros("CveModulo = 433")
|
|
End If
|
|
Else
|
|
GvModulosPermiso.DataSource = Nothing
|
|
End If
|
|
|
|
ObjProcesos.Dispose()
|
|
|
|
GvModulosPermiso.DataBind()
|
|
UpDatos.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvModulosPermiso_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvModulosPermiso.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
'cuando el Módulo es heredado del rol
|
|
If (e.Row.DBCampo("CveModuloAcceso")) <> "" Then
|
|
e.Row.Cells(0).CssClass = "bg-yellow"
|
|
' = "bg-font-yellow" '.BackColor = Color.Gold
|
|
End If
|
|
'cuando el Módulo es heredado del Rol
|
|
If (e.Row.DBCampo("CveModuloUsuarioAcceso")) <> "" Then
|
|
e.Row.Cells(0).CssClass = "bg-purple-plum"
|
|
End If
|
|
'cuando el Proceso es heredado del Rol
|
|
If (e.Row.DBCampo("CveProcesoAcceso")) <> "" Then
|
|
e.Row.FCCheckBox("ChkD").Enabled = True
|
|
e.Row.Cells(3).CssClass = "bg-yellow"
|
|
Else
|
|
e.Row.FCCheckBox("ChkP").Enabled = True
|
|
If e.Row.DBCampo("Permitir") = "1" Then e.Row.FCCheckBox("ChkP").Checked = True
|
|
End If
|
|
|
|
If (e.Row.DBCampo("Permitir")) = "0" Then
|
|
e.Row.FCCheckBox("ChkD").Checked = True
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
Protected Sub GvPermisosComandos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPermisosComandos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
Dim Permitir As Integer = e.Row.DBCampo("Permitir").ToEntero
|
|
Dim EsFavorito As Boolean = CBool(e.Row.DBCampo("EsFavorito"))
|
|
|
|
e.Row.FCCheckBox("ChkFavorito").Checked = EsFavorito
|
|
|
|
If Permitir = 0 Then
|
|
e.Row.FCCheckBox("ChkP").Checked = False
|
|
End If
|
|
|
|
If Permitir = 1 Then
|
|
e.Row.FCCheckBox("ChkP").Checked = True
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "V E H I C U L O S"
|
|
Private Sub CargaDispositivos()
|
|
GvDispositivos.DataSource = GlobalDTDispositivos(CveCliente).FiltraParametros("Estatus = 1 ")
|
|
GvDispositivos.DataBind()
|
|
End Sub
|
|
Protected Sub GvDispositivos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDispositivos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If CveUsuario > 0 Then
|
|
If GlobalDTDispositivosUsuarios(CveCliente).FiltroPrimeroValor("Permitir", $"CveUsuario = {CveUsuario} AND CveDispositivo = {e.Row.DBCampo("CveDispositivo")} ").ToString = "True" Then
|
|
e.Row.FCCheckBox("chkDis").Checked = True
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "N O T I F I C A C I O N E S"
|
|
Private Sub CargarNotificaciones()
|
|
Dim ObjNotificaciones As New ClsSisNotificaciones
|
|
If ObjNotificaciones.GetNotificaciones(-1) Then
|
|
DtNotificacionesUsuarios = ObjNotificaciones.DtResultados.FiltraParametros($"CveUsuario = {CveUsuario} ")
|
|
GVNotificaciones.DataSource = ObjNotificaciones.DtResultados.FiltraParametros("1 = 1", "CveNotificacion", {"CveNotificacion", "Nombre"})
|
|
End If
|
|
ObjNotificaciones.Dispose()
|
|
GVNotificaciones.DataBind()
|
|
End Sub
|
|
|
|
Protected Sub GvNotificaciones_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVNotificaciones.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If DtNotificacionesUsuarios.Rows.Count > 0 Then
|
|
e.Row.FCCheckBox("chkCampana").Checked = If(DtNotificacionesUsuarios.FiltroPrimeroValor("Alerta_Campana", $"CveNotificacion = {e.Row.DBCampo("CveNotificacion").ToString}").ToString = "True", True, False)
|
|
e.Row.FCCheckBox("chkCorreo").Checked = If(DtNotificacionesUsuarios.FiltroPrimeroValor("Alerta_Correo", $"CveNotificacion = {e.Row.DBCampo("CveNotificacion")}").ToString = "True", True, False)
|
|
e.Row.FCCheckBox("chkVentana").Checked = If(DtNotificacionesUsuarios.FiltroPrimeroValor("Alerta_Ventana", $"CveNotificacion = {e.Row.DBCampo("CveNotificacion")}").ToString = "True", True, False)
|
|
e.Row.FCCheckBox("chkSMS").Checked = If(DtNotificacionesUsuarios.FiltroPrimeroValor("Alerta_SMS", $"CveNotificacion = {e.Row.DBCampo("CveNotificacion")}").ToString = "True", True, False)
|
|
e.Row.FCCheckBox("chkApp").Checked = If(DtNotificacionesUsuarios.FiltroPrimeroValor("Alerta_App", $"CveNotificacion = {e.Row.DBCampo("CveNotificacion")}").ToString = "True", True, False)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
Protected Sub BtnCambiarUsuario_Click(sender As Object, e As EventArgs)
|
|
|
|
CveUsuario = -1
|
|
Dim usuario As String = TxtEmail.Text
|
|
Dim objs As New ClsSisUsuarios
|
|
objs.GetWSusuarios(usuario)
|
|
If objs.DtResultados.Rows.Count > 0 Then
|
|
CveUsuario = objs.DtResultados.Rows(0)("CveUsuario").ToString().ToEntero()
|
|
End If
|
|
objs.Dispose()
|
|
|
|
If CveUsuario > -1 Then
|
|
CargaUsuario()
|
|
Else
|
|
|
|
LtlUsuario.Text = ""
|
|
TxtEmail.Text = ""
|
|
TxtNombre.Text = ""
|
|
LtlEmpresas.Text = ""
|
|
BtnDefaultPWD.Visible = False
|
|
|
|
UpUsuario.Update()
|
|
End If
|
|
If CveCliente > 0 Then
|
|
|
|
CargaDispositivos()
|
|
CargarNotificaciones()
|
|
End If
|
|
|
|
CargaModulosAcceso()
|
|
CargaModulosPermisos()
|
|
CargaComandos()
|
|
UpDatos.Update()
|
|
|
|
RegistraScript(" $('.CustomSpinner').hide();")
|
|
End Sub
|
|
|
|
End Class
|