git-tfs-id: [http://192.168.1.10:8080/tfs/AyA]$/SINORT;C430
This commit is contained in:
parent
18310f9dd6
commit
3583987abd
7 changed files with 289 additions and 45 deletions
|
|
@ -82,6 +82,9 @@ namespace AYA.SlnSinort.WCF
|
|||
#endregion
|
||||
|
||||
#region RolesUsuario
|
||||
[OperationContract]
|
||||
List<RolesUsuario> ValidarRolesUsuario(CatalogosPostJSON model);
|
||||
|
||||
[OperationContract]
|
||||
Usuario BuscarUsuario(CatalogosPostJSON model);
|
||||
|
||||
|
|
@ -91,7 +94,8 @@ namespace AYA.SlnSinort.WCF
|
|||
[OperationContract]
|
||||
RolesUsuarioJSON InsertarActualizarRolesUsuario(RolesUsuarioJSON model);
|
||||
|
||||
|
||||
[OperationContract]
|
||||
RolesUsuarioJSON EliminarRolesUsuario(RolesUsuarioJSON model);
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -331,6 +331,21 @@ namespace AYA.SlnSinort.WCF
|
|||
|
||||
#region RolesUsuarios
|
||||
|
||||
|
||||
public List<RolesUsuario> ValidarRolesUsuario(CatalogosPostJSON model)
|
||||
{
|
||||
List<RolesUsuario> respuesta = null;
|
||||
try
|
||||
{
|
||||
respuesta = new UsuarioDAL().ValidarRolesUsuario(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Error(ex);
|
||||
}
|
||||
return respuesta;
|
||||
}
|
||||
|
||||
public Usuario BuscarUsuario(CatalogosPostJSON model)
|
||||
{
|
||||
Usuario respuesta = null;
|
||||
|
|
@ -379,6 +394,24 @@ namespace AYA.SlnSinort.WCF
|
|||
return model;
|
||||
}
|
||||
|
||||
public RolesUsuarioJSON EliminarRolesUsuario(RolesUsuarioJSON model)
|
||||
{
|
||||
var usuarioDAL = new UsuarioDAL();
|
||||
try
|
||||
{
|
||||
foreach (var rolUsuario in model.ListaRolesUsuarios)
|
||||
usuarioDAL.EliminarRolesUsuario(rolUsuario);
|
||||
|
||||
model.CodigoRespuesta = EnumTipoCodigoRespuesta.EXITOSO;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR;
|
||||
throw;
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region WCFAYA
|
||||
|
|
|
|||
|
|
@ -197,7 +197,30 @@ this.ActualizarItem = function () {
|
|||
if (!confirm("Se guardarán los cambios.\n ¿Desea continuar?"))
|
||||
{ return; }
|
||||
|
||||
|
||||
|
||||
TableItems = $('#TableItems').DataTable();
|
||||
var repetido = false;
|
||||
var data = TableItems
|
||||
.rows()
|
||||
.data();
|
||||
|
||||
$.each(data, function (key, item) {
|
||||
|
||||
if (item[2] == $("#txtDescripcion").val()) {
|
||||
repetido = true
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (repetido == true) {
|
||||
toastr.warning('Ya existe una aplicación con el mismo título', Message_Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Aplicacion = {
|
||||
IdAplicacion: $('#hiddenId').val(),
|
||||
|
|
@ -225,6 +248,24 @@ this.InsertarItem = function () {
|
|||
|
||||
|
||||
TableItems = $('#TableItems').DataTable();
|
||||
var repetido = false;
|
||||
var data = TableItems
|
||||
.rows()
|
||||
.data();
|
||||
|
||||
$.each(data, function (key, item) {
|
||||
|
||||
if (item[2] == $("#txtDescripcion").val()) {
|
||||
repetido = true
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (repetido == true) {
|
||||
toastr.warning('Ya existe una aplicación con el mismo título', Message_Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
Aplicacion = {
|
||||
Descripcion: $("#txtDescripcion").val(),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
var DataCatalogo;
|
||||
var id_column = 1;
|
||||
var model = {};
|
||||
|
||||
var idRoles;
|
||||
|
||||
//#region READY
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ this.getDataModel = function () {
|
|||
|
||||
$("#btnAgregarUsuario").unbind("click");
|
||||
$("#btnAgregarUsuario").click(function () {
|
||||
AgregarUsuario();
|
||||
ValidarRolesUsuario();
|
||||
});
|
||||
|
||||
$("#btnBuscarOpcion").unbind("click");
|
||||
|
|
@ -63,7 +63,7 @@ this.getDataModel = function () {
|
|||
$('#GridRolesUsuarios').TableInit(0, false, true, true, false, null, null);
|
||||
ObtenerRoles();
|
||||
CargarUsuariosSistema();
|
||||
CargarPantallasSistema();
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -195,7 +195,26 @@ this.ActualizarItem = function () {
|
|||
if (!confirm("Se guardarán los cambios.\n ¿Desea continuar?"))
|
||||
{ return; }
|
||||
|
||||
|
||||
TableItems = $('#TableItems').DataTable();
|
||||
var repetido = false;
|
||||
var data = TableItems
|
||||
.rows()
|
||||
.data();
|
||||
|
||||
$.each(data, function (key, item) {
|
||||
|
||||
if (item[2] == $("#txtDescripcion").val()) {
|
||||
repetido = true
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (repetido == true) {
|
||||
toastr.warning('Ya existe un rol con la misma descripción', Message_Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
Rol = {
|
||||
IdRol: $('#hiddenId').val(),
|
||||
|
|
@ -221,6 +240,24 @@ this.InsertarItem = function () {
|
|||
|
||||
|
||||
TableItems = $('#TableItems').DataTable();
|
||||
var repetido = false;
|
||||
var data = TableItems
|
||||
.rows()
|
||||
.data();
|
||||
|
||||
$.each(data, function (key, item) {
|
||||
|
||||
if (item[2] == $("#txtDescripcion").val()) {
|
||||
repetido = true
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (repetido == true) {
|
||||
toastr.warning('Ya existe un rol con la misma descripción', Message_Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
Rol = {
|
||||
Descripcion: $("#txtDescripcion").val(),
|
||||
|
|
@ -254,8 +291,11 @@ this.LimpiarControles = function () {
|
|||
//Asignar opciones por rol
|
||||
this.AbrirRolesPantallas = function (id) {
|
||||
if (ValidarPermisos('Asignar permisos por rol').length > 0) {
|
||||
|
||||
idRoles = id;
|
||||
$("#modalRolesOpciones").modal('show');
|
||||
CargarPantallas(id);
|
||||
|
||||
}
|
||||
else {
|
||||
toastr.warning('No tiene permisos para ejecutar esta opción', Message_Warning);
|
||||
|
|
@ -394,10 +434,15 @@ this.HabilitarOpcion = function (id, value) {
|
|||
|
||||
}
|
||||
|
||||
this.CargarPantallasSistema = function (filtro) {
|
||||
this.CargarPantallasSistema = function () {
|
||||
|
||||
var uri = CatalogosWCF + '/api/ObtenerPantallas';
|
||||
AjaxPostData(uri, null, false, false, CargarGridPantallas, null, null);
|
||||
|
||||
model = {
|
||||
codigo: idRoles
|
||||
};
|
||||
|
||||
AjaxPostData(uri, model, false, false, CargarGridPantallas, null, null);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -424,8 +469,9 @@ this.CargarGridPantallas = function (data) {
|
|||
|
||||
this.BuscarPantalla = function () {
|
||||
|
||||
CargarPantallasSistema();
|
||||
|
||||
if ($.fn.DataTable.isDataTable('#tableOpciones')) {
|
||||
if ($.fn.DataTable.isDataTable('#tableOpciones')) {
|
||||
|
||||
LoadMessage();
|
||||
$('#tableOpciones').DataTable().search('').draw();
|
||||
|
|
@ -559,14 +605,17 @@ this.GuardarRolesUsuarios = function () {
|
|||
.rows()
|
||||
.data();
|
||||
|
||||
var estadoRol;
|
||||
$.each(data, function (key, item) {
|
||||
|
||||
estadoRol = item[4].indexOf("Deshabilitar") == -1 ? false : true;
|
||||
|
||||
RolesUsuarios = {
|
||||
|
||||
IdRolesUsuario: item[1],
|
||||
IdRol: IdRoles,
|
||||
UsuarioSistema: item[2],
|
||||
Estado: true
|
||||
Estado: estadoRol
|
||||
|
||||
}
|
||||
ArrayRolesUsuarios.push(RolesUsuarios);
|
||||
|
|
@ -619,6 +668,33 @@ this.HabilitarUsuario = function (id, value) {
|
|||
|
||||
}
|
||||
|
||||
this.EliminarUsuario = function (id) {
|
||||
|
||||
var msg = '¿Está seguro que desea eliminar el usuario?';
|
||||
|
||||
if (!confirm(msg)) return;
|
||||
|
||||
var ArrayRolesUsuarios = [];
|
||||
|
||||
RolesUsuarios = {
|
||||
IdRolesUsuario: id,
|
||||
|
||||
}
|
||||
ArrayRolesUsuarios.push(RolesUsuarios);
|
||||
|
||||
var model = {
|
||||
ListaRolesUsuarios: ArrayRolesUsuarios
|
||||
|
||||
}
|
||||
|
||||
var uri = CatalogosWCF + '/api/EliminarRolesUsuario';
|
||||
AjaxPostData(uri, model, true, null, null, null, null);
|
||||
CargarUsuarios($('#hiddenIdRol').val());
|
||||
ENDREQUEST();
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.CargarUsuariosSistema = function (filtro) {
|
||||
|
||||
var uri = CatalogosWCF + '/api/ObtenerUsuario';
|
||||
|
|
@ -651,9 +727,12 @@ this.CargarGridUsuarios = function (data) {
|
|||
this.BuscarUsuario = function () {
|
||||
SelectedCatalog = 'Usuarios';
|
||||
|
||||
|
||||
if ($.fn.DataTable.isDataTable('#tableUsuarios')) {
|
||||
|
||||
LoadMessage();
|
||||
var table = $('#tableUsuarios').DataTable();
|
||||
|
||||
$('#tableUsuarios').DataTable().search('').draw();
|
||||
$('#modalUsuario').modal('show');
|
||||
ENDREQUEST();
|
||||
|
|
@ -661,10 +740,32 @@ this.BuscarUsuario = function () {
|
|||
}
|
||||
}
|
||||
|
||||
this.AgregarUsuario = function () {
|
||||
this.ValidarRolesUsuario = function (id) {
|
||||
|
||||
if ($("#txtUsuario").val() == '') {
|
||||
toastr.warning("Debe seleccionar un usuario", Message_Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var uri = CatalogosWCF + '/api/ValidarRolesUsuario';
|
||||
model = {
|
||||
codigo: $("#hiddenUsuario").val()
|
||||
};
|
||||
|
||||
AjaxPostData(uri, model, false, false, AgregarUsuario, null, null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.AgregarUsuario = function (data) {
|
||||
ENDREQUEST();
|
||||
if (!confirm("¿Desea agregar un nuevo usuario?")) return;
|
||||
|
||||
|
||||
if (data.length > 0) {
|
||||
toastr.warning("El usuario seleccionado ya tiene un rol asignado", Message_Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var GridRolesUsuarios = $('#GridRolesUsuarios').DataTable();
|
||||
var option = $("#ucbtnRemoverParticipante").html();
|
||||
var stateIcon = $("#ucItemsIcon").html();
|
||||
|
|
|
|||
|
|
@ -116,41 +116,10 @@
|
|||
</button>
|
||||
</div>
|
||||
|
||||
@*<div class="modal fade" id="modalRolesPantallas" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" style="display: none;">
|
||||
<div class="modal-dialog modal-lg" style="width:50%;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4><i class="fa fa-bars"></i> Pantallas</h4>
|
||||
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<table id="GridRolesPantallas" class="table table-condensed dataTable no-footer">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
<th class="col-sm-4">Descripción</th>
|
||||
<th class="col-sm-1 text-center">Acción</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="ucbtnCheck" style="display:none;">
|
||||
<input type="checkbox" id="chkSeleccionar_[$id]" [$check]>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-success btn-sm" onclick="javascript: GuardarRolesPantallas()">Guardar</button>
|
||||
<button type="button" class="btn btn-danger btn-sm" data-dismiss="modal">Cerrar</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>*@
|
||||
@*---------------------Roles Opciones---------------------------------------------------------*@
|
||||
<div class="modal fade" id="modalRolesOpciones" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" style="display: none;">
|
||||
<div class="modal-dialog modal-lg" style="width:50%;">
|
||||
<div class="modal-dialog modal-lg" style="max-height:90%;overflow-y: auto;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4><i class="fa fa-bars"></i> Opciones</h4>
|
||||
|
|
@ -296,11 +265,26 @@
|
|||
<i class="fa [$icon] fa-2x"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div id="ucItemsHabiliar" style="display:none;">
|
||||
|
||||
<div id="ucItemsHabiliar" style="display:none;">
|
||||
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-info dropdown-toggle btn-xs" data-toggle="dropdown">
|
||||
<i class="fa fa-wrench"></i> Opciones <span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="javascript: EliminarUsuario([$CodItem]);"><i class="fa fa-trash"></i> Eliminar</a></li>
|
||||
<li><a href="javascript: HabilitarUsuario([$CodItem],[$value]);"><i class="fa [$icon]"></i> [$opcion]</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@*<div id="ucItemsHabiliar" style="display:none;">
|
||||
<button type="button" id="btnhabilitar" class="btn btn-default btn-xs" onclick="javascript: HabilitarUsuario([$CodItem], [$value])">
|
||||
<i class=" fa [$icon]"></i> [$opcion]
|
||||
</button>
|
||||
</div>
|
||||
</div>*@
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -19,13 +19,24 @@ namespace AYA.SlnSinortModel.DAL.Sinort
|
|||
{
|
||||
|
||||
List<Pantallas> registros = null;
|
||||
List<RolesPantallas> rolespantallas = null;
|
||||
string filtro = model != null ? model.filtro : null;
|
||||
List<int> listIdPantalla = new List<int>();
|
||||
|
||||
try
|
||||
{
|
||||
using (SinortContex db = new SinortContex())
|
||||
{
|
||||
registros = db.Pantallas.Where(t => t.Estado == true && (string.IsNullOrEmpty(filtro) || t.Descripcion.Trim().ToLower() == filtro.Trim().ToLower())).OrderByDescending(q => q.IdPantalla).ToList();
|
||||
|
||||
rolespantallas = db.RolesPantallas.Where(r => r.IdRol.ToString() == model.codigo).Include(u => u.Pantallas).OrderBy(u => u.Pantallas.Descripcion).AsNoTracking().ToList();
|
||||
|
||||
foreach (var roles in rolespantallas)
|
||||
{
|
||||
listIdPantalla.Add(Convert.ToInt32(roles.IdPantalla));
|
||||
}
|
||||
|
||||
registros = db.Pantallas.Where(p => p.Estado == true && !listIdPantalla.Contains(p.IdPantalla)).OrderByDescending(p => p.IdPantalla).ToList();
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,35 @@ namespace AYA.SlnSinortModel.DAL.Sinort
|
|||
public class UsuarioDAL
|
||||
{
|
||||
Log log = new Log("UsuarioDAL");
|
||||
|
||||
#region ObtenerUsuariosRol
|
||||
public List<RolesUsuario> ValidarRolesUsuario(CatalogosPostJSON model)
|
||||
{
|
||||
List<RolesUsuario> registros = null;
|
||||
|
||||
try
|
||||
{
|
||||
using (SinortContex db = new SinortContex())
|
||||
{
|
||||
|
||||
if (model != null && !string.IsNullOrWhiteSpace(model.codigo))
|
||||
{
|
||||
|
||||
registros = db.RolesUsuario.Where(r => r.UsuarioSistema.ToString() == model.codigo).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Error(ex);
|
||||
}
|
||||
|
||||
return registros;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region ObtenerUsuario
|
||||
public List<Usuario> ObtenerUsuario()
|
||||
{
|
||||
|
|
@ -151,6 +180,47 @@ namespace AYA.SlnSinortModel.DAL.Sinort
|
|||
return Respuesta;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public BaseJson EliminarRolesUsuario(RolesUsuario model)
|
||||
{
|
||||
RolesUsuario Actual = new RolesUsuario();
|
||||
BaseJson Respuesta = new BaseJson();
|
||||
|
||||
try
|
||||
{
|
||||
model.ClearProperties();
|
||||
|
||||
using (SinortContex Conn = new SinortContex())
|
||||
{
|
||||
Actual = Conn.RolesUsuario.FirstOrDefault(x => x.IdRolesUsuario == model.IdRolesUsuario);
|
||||
if (Actual != null)
|
||||
{
|
||||
Conn.Entry(Actual).State = System.Data.Entity.EntityState.Deleted;
|
||||
Conn.SaveChanges();
|
||||
Conn.Commit();
|
||||
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.EXITOSO.ToString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch (DbEntityValidationException ex)
|
||||
{
|
||||
log.Error(ex);
|
||||
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Error(ex);
|
||||
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
||||
}
|
||||
finally
|
||||
{
|
||||
Actual = null;
|
||||
}
|
||||
return Respuesta;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UsuariosAyA
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue