From ccba57a38cc482544752bea068cff88715361cb9 Mon Sep 17 00:00:00 2001 From: jmoya Date: Mon, 10 Sep 2018 23:00:59 +0000 Subject: [PATCH] git-tfs-id: [http://192.168.1.10:8080/tfs/AyA]$/SINORT;C462 --- AYA.SlnSynor/AYA.SlnSynor.WCF/ISinort.cs | 3 + AYA.SlnSynor/AYA.SlnSynor.WCF/Sinort.svc.cs | 12 + .../Sinort-Scripts/PropuestaNormativa/Foro.js | 232 ++++++++++++------ .../PropuestaNormativa/PropuestaNormativa.js | 230 ++++++++++------- .../Sinort/ProyectoNormativoDAL.cs | 22 ++ .../AYA.SlnSynorModel/Entidades/Json.cs | 2 + 6 files changed, 339 insertions(+), 162 deletions(-) diff --git a/AYA.SlnSynor/AYA.SlnSynor.WCF/ISinort.cs b/AYA.SlnSynor/AYA.SlnSynor.WCF/ISinort.cs index 09192f4ee..04c79d4cc 100644 --- a/AYA.SlnSynor/AYA.SlnSynor.WCF/ISinort.cs +++ b/AYA.SlnSynor/AYA.SlnSynor.WCF/ISinort.cs @@ -20,6 +20,9 @@ namespace AYA.SlnSinort.WCF [OperationContract] ProyectoNormativoJSON GuardarProyectoNormativo(ProyectoNormativoJSON model); + [OperationContract] + string BuscarNombreProyecto(ProyectoNormativoJSON model); + [OperationContract] ProyectoNormativoJSON GuardarConvocatoriaProyectoNormativo(ProyectoNormativoJSON model); diff --git a/AYA.SlnSynor/AYA.SlnSynor.WCF/Sinort.svc.cs b/AYA.SlnSynor/AYA.SlnSynor.WCF/Sinort.svc.cs index 79fe873cb..4a5d7f62f 100644 --- a/AYA.SlnSynor/AYA.SlnSynor.WCF/Sinort.svc.cs +++ b/AYA.SlnSynor/AYA.SlnSynor.WCF/Sinort.svc.cs @@ -53,7 +53,19 @@ namespace AYA.SlnSinort.WCF } return model; } + public string BuscarNombreProyecto(ProyectoNormativoJSON model) { + string respuesta = null; + try + { + respuesta = new ProyectoNormativoDAL().BuscarNombreProyecto(model); + } + catch (Exception ex) + { + log.Error(ex); + } + return respuesta; + } public ProyectoNormativoJSON GuardarConvocatoriaProyectoNormativo(ProyectoNormativoJSON model) { diff --git a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/PropuestaNormativa/Foro.js b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/PropuestaNormativa/Foro.js index 5ae076077..d2f7ecca7 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/PropuestaNormativa/Foro.js +++ b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/PropuestaNormativa/Foro.js @@ -19,7 +19,7 @@ this.getDataModel = function () { $("#btnAgregarUsuario").unbind("click"); $("#btnAgregarUsuario").click(function () { - AgregarUsuario(); + VerificarRolUsuario(); }); $("#btnBuscarUsuarioExterno").unbind("click"); @@ -29,7 +29,7 @@ this.getDataModel = function () { $("#btnAgregarUsuarioExterno").unbind("click"); $("#btnAgregarUsuarioExterno").click(function () { - AgregarUsuarioExterno(); + VerificarRolUsuarioExterno(); }); $('#GridConvocados').TableInit(0, false, true, true, false, null, null); @@ -121,49 +121,6 @@ this.BuscarUsuario = function () { } } - -this.AgregarUsuario = function () { - - if ($("#txtUsuario").val() == '') { - toastr.warning("Debe seleccionar un usuario", Message_Warning); - return; - } - - if (!confirm("¿Desea convocar a un nuevo participante?")) return; - - var tableParticipantes = $('#tableParticipantes').DataTable(); - var repetido = false; - var data = tableParticipantes - .rows() - .data(); - - $.each(data, function (key, item) { - - if (item[0] == $('#hiddenUsuarioExterno').val()) { - repetido = true - return false; - } - - }); - - if (repetido == true) { - toastr.warning('No puede convocar dos veces al mismo usuario', Message_Warning); - return; - } - var option = $("#ucbtnRemoverParticipante").html(); - - - tableParticipantes.row.add( - [$("#hiddenUsuario").val(), - $("#txtUsuario").val(), - option]) - .draw(); - - toastr.success(Message_Default, Message_Success); - $('#hiddenUsuario').val(''); - $('#txtUsuario').val(''); -} - this.BuscarUsuarioExterno = function () { SelectedCatalog = 'UsuariosExterno'; @@ -176,47 +133,174 @@ this.BuscarUsuarioExterno = function () { } } +//this.AgregarUsuario = function () { -this.AgregarUsuarioExterno = function () { +// if ($("#txtUsuario").val() == '') { +// toastr.warning("Debe seleccionar un usuario", Message_Warning); +// return; +// } - if ($("#txtUsuarioExterno").val() == '') { - toastr.warning("Debe seleccionar un usuario", Message_Warning); - return; +// if (!confirm("¿Desea convocar a un nuevo participante?")) return; + +// var tableParticipantes = $('#tableParticipantes').DataTable(); +// var repetido = false; +// var data = tableParticipantes +// .rows() +// .data(); + +// $.each(data, function (key, item) { + +// if (item[0] == $('#hiddenUsuarioExterno').val()) { +// repetido = true +// return false; +// } + +// }); + +// if (repetido == true) { +// toastr.warning('No puede convocar dos veces al mismo usuario', Message_Warning); +// return; +// } +// var option = $("#ucbtnRemoverParticipante").html(); + + +// tableParticipantes.row.add( +// [$("#hiddenUsuario").val(), +// $("#txtUsuario").val(), +// option]) +// .draw(); + +// toastr.success(Message_Default, Message_Success); +// $('#hiddenUsuario').val(''); +// $('#txtUsuario').val(''); +//} +this.VerificarRolUsuario = function () { + + if ($("#txtUsuario").val() != "") { + + model = { + codigo: $('#hiddenUsuario').val() + } + var uri = CatalogosWCF + '/api/BuscarUsuarioRol'; + AjaxPostData(uri, model, false, false, AgregarUsuario, null, null); } + else { + toastr.warning("Debe seleccionar un usuario", Message_Warning); + } +} +this.AgregarUsuario = function (data) { - if (!confirm("¿Desea convocar a un nuevo participante?")) return; + if (data.pantallas.length > 0) { - var tableParticipantes = $('#tableParticipantes').DataTable(); - var repetido = false; - var data = tableParticipantes - .rows() - .data(); - - $.each(data, function (key, item) { - - if (item[0] == $('#hiddenUsuarioExterno').val()) { - repetido = true - return false; + if (!confirm("¿Desea convocar a un nuevo usuario?")) { + ENDREQUEST(); return; } - }); + var tableParticipantes = $('#tableParticipantes').DataTable(); - if (repetido == true) { - toastr.warning('No puede convocar dos veces al mismo usuario', Message_Warning); - return; + var repetido = false; + var datos = tableParticipantes + .rows() + .data(); + + $.each(datos, function (key, item) { + + if (item[1].toLowerCase() == $("#hiddenUsuario").val()) { + repetido = true + return false; + } + + }); + + if (repetido == true) { + toastr.warning('Ya existe el usuario en la lista de participantes', Message_Warning); + return; + } + + + var option = $("#ucbtnRemoverParticipante").html(); + + + tableParticipantes.row.add( + [$("#hiddenUsuario").val(), + $("#txtUsuario").val(), + option]) + .draw(); + + toastr.success(Message_Default, Message_Success); + + $('#hiddenUsuario').val(''); + $('#txtUsuario').val(''); + + } else { + toastr.warning("Debe asignarle un rol al usuario", Message_Warning); } + ENDREQUEST(); +} +this.VerificarRolUsuarioExterno = function () { - var option = $("#ucbtnRemoverParticipante").html(); + if ($("#txtUsuarioExterno").val() != "") { - tableParticipantes.row.add( - [$("#hiddenUsuarioExterno").val(), - $("#txtUsuarioExterno").val(), - option]) - .draw(); + model = { + codigo: $('#hiddenUsuarioExterno').val() + } + var uri = CatalogosWCF + '/api/BuscarUsuarioRol'; + AjaxPostData(uri, model, false, false, AgregarUsuario, null, null); + } + else { + toastr.warning("Debe seleccionar un usuario", Message_Warning); + } +} +this.AgregarUsuarioExterno = function (data) { - toastr.success(Message_Default, Message_Success); - $('#hiddenUsuarioExterno').val(''); - $('#txtUsuarioExterno').val(''); + if (data.pantallas.length > 0) { + + if (!confirm("¿Desea convocar a un nuevo usuario?")) { + ENDREQUEST(); return; + } + + + var tableParticipantes = $('#tableParticipantes').DataTable(); + var ArrayParticipantes = []; + + + var repetido = false; + var datos = tableParticipantes + .rows() + .data(); + + $.each(datos, function (key, item) { + + if (item[1].toLowerCase() == $("#hiddenUsuarioExterno").val()) { + repetido = true + return false; + } + + }); + + if (repetido == true) { + toastr.warning('Ya existe el usuario en la lista de participantes', Message_Warning); + return; + } + + var option = $("#ucbtnRemoverParticipante").html(); + + + tableParticipantes.row.add( + [$("#hiddenusuario").val(), + $("#txtUsuario").val(), + option]) + .draw(); + + toastr.success(Message_Default, Message_Success); + + $('#hiddenUsuarioExterno').val(''); + $('#txtUsuarioExterno').val(''); + + } else { + toastr.warning("Debe asignarle un rol al usuario", Message_Warning); + } + ENDREQUEST(); } this.LimpiarUsuarioExterno = function () { diff --git a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/PropuestaNormativa/PropuestaNormativa.js b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/PropuestaNormativa/PropuestaNormativa.js index f81337f2b..18f3d9d49 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/PropuestaNormativa/PropuestaNormativa.js +++ b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/PropuestaNormativa/PropuestaNormativa.js @@ -26,7 +26,7 @@ this.getDataModel = function () { $("#btnAgregarUsuario").unbind("click"); $("#btnAgregarUsuario").click(function () { - AgregarUsuario(); + VerificarRolUsuario(); }); $("#btnBuscarUsuarioExterno").unbind("click"); @@ -36,7 +36,7 @@ this.getDataModel = function () { $("#btnAgregarUsuarioExterno").unbind("click"); $("#btnAgregarUsuarioExterno").click(function () { - AgregarUsuarioExterno(); + VerificarRolUsuarioExterno(); }); $("#btnBuscarEmisor").unbind("click"); @@ -225,8 +225,6 @@ this.CargarGridUsuariosExternos = function (data) { ENDREQUEST(); } - - this.BuscarUsuario = function () { SelectedCatalog = 'Usuarios'; @@ -239,56 +237,6 @@ this.BuscarUsuario = function () { } } - -this.AgregarUsuario = function () { - - if ($("#txtUsuario").val() == '') { - toastr.warning("Debe seleccionar un usuario", Message_Warning); - return; - } - - if (!confirm("¿Desea convocar a un nuevo participante?")) return; - - var tableParticipantes = $('#tableParticipantes').DataTable(); - var repetido = false; - var data = tableParticipantes - .rows() - .data(); - - $.each(data, function (key, item) { - - if (item[0] == $('#hiddenusuario').val()) { - repetido = true - return false; - } - - }); - - if (repetido == true) { - toastr.warning('No puede convocar dos veces al mismo usuario', Message_Warning); - return; - } - - - var option = $("#ucbtnRemoverParticipante").html(); - - - tableParticipantes.row.add( - [$("#hiddenusuario").val(), - $("#txtUsuario").val(), - option]) - .draw(); - - toastr.success(Message_Default, Message_Success); - $('#hiddenusuario').val(''); - $('#txtUsuario').val(''); -} - -this.LimpiarUsuario = function () { - $('#hiddenusuario').val(''); - $('#txtUsuario').val(''); -} - this.BuscarUsuarioExterno = function () { SelectedCatalog = 'UsuariosExterno'; @@ -302,55 +250,146 @@ this.BuscarUsuarioExterno = function () { } } -this.AgregarUsuarioExterno = function () { +this.VerificarRolUsuario = function () { - if ($("#txtUsuarioExterno").val() == '') { - toastr.warning("Debe seleccionar un usuario", Message_Warning); - return; + if ($("#txtUsuario").val() != "") { + + model = { + codigo: $('#hiddenusuario').val() + } + var uri = CatalogosWCF + '/api/BuscarUsuarioRol'; + AjaxPostData(uri, model, false, false, AgregarUsuario, null, null); } + else { + toastr.warning("Debe seleccionar un usuario", Message_Warning); + } +} +this.AgregarUsuario = function (data) { - if (!confirm("¿Desea convocar a un nuevo participante?")) return; + if (data.pantallas.length > 0) { - var tableParticipantes = $('#tableParticipantes').DataTable(); - var repetido = false; - var data = tableParticipantes - .rows() - .data(); - - $.each(data, function (key, item) { - - if (item[0] == $('#hiddenUsuarioExterno').val()) { - repetido = true - return false; + if (!confirm("¿Desea convocar a un nuevo usuario?")) { + ENDREQUEST(); return; } - }); + var tableParticipantes = $('#tableParticipantes').DataTable(); - if (repetido == true) { - toastr.warning('No puede convocar dos veces al mismo usuario', Message_Warning); - return; + var repetido = false; + var datos = tableParticipantes + .rows() + .data(); + + $.each(datos, function (key, item) { + + if (item[1].toLowerCase() == $("#hiddenusuario").val()) { + repetido = true + return false; + } + + }); + + if (repetido == true) { + toastr.warning('Ya existe el usuario en la lista de participantes', Message_Warning); + return; + } + + + var option = $("#ucbtnRemoverParticipante").html(); + + + tableParticipantes.row.add( + [$("#hiddenusuario").val(), + $("#txtUsuario").val(), + option]) + .draw(); + + toastr.success(Message_Default, Message_Success); + + $('#hiddenusuario').val(''); + $('#txtUsuario').val(''); + + } else { + toastr.warning("Debe asignarle un rol al usuario", Message_Warning); } - - var option = $("#ucbtnRemoverParticipante").html(); - - tableParticipantes.row.add( - [$("#hiddenUsuarioExterno").val(), - $("#txtUsuarioExterno").val(), - option]) - .draw(); - - toastr.success(Message_Default, Message_Success); - $('#hiddenUsuarioExterno').val(''); - $('#txtUsuarioExterno').val(''); + ENDREQUEST(); } +this.VerificarRolUsuarioExterno = function () { + + if ($("#txtUsuarioExterno").val() != "") { + + model = { + codigo: $('#hiddenUsuarioExterno').val() + } + var uri = CatalogosWCF + '/api/BuscarUsuarioRol'; + AjaxPostData(uri, model, false, false, AgregarUsuario, null, null); + } + else { + toastr.warning("Debe seleccionar un usuario", Message_Warning); + } +} + +this.AgregarUsuarioExterno = function (data) { + + if (data.pantallas.length > 0) { + + if (!confirm("¿Desea convocar a un nuevo usuario?")) { + ENDREQUEST(); return; + } + + + var tableParticipantes = $('#tableParticipantes').DataTable(); + var ArrayParticipantes = []; + + + var repetido = false; + var datos = tableParticipantes + .rows() + .data(); + + $.each(datos, function (key, item) { + + if (item[1].toLowerCase() == $("#hiddenUsuarioExterno").val()) { + repetido = true + return false; + } + + }); + + if (repetido == true) { + toastr.warning('Ya existe el usuario en la lista de participantes', Message_Warning); + return; + } + + var option = $("#ucbtnRemoverParticipante").html(); + + + tableParticipantes.row.add( + [$("#hiddenusuario").val(), + $("#txtUsuario").val(), + option]) + .draw(); + + toastr.success(Message_Default, Message_Success); + + $('#hiddenUsuarioExterno').val(''); + $('#txtUsuarioExterno').val(''); + + } else { + toastr.warning("Debe asignarle un rol al usuario", Message_Warning); + } + ENDREQUEST(); +} +this.LimpiarUsuario = function () { + $('#hiddenusuario').val(''); + $('#txtUsuario').val(''); +} this.LimpiarUsuarioExterno = function () { $('#hiddenUsuarioExterno').val(''); $('#txtUsuarioExterno').val(''); } - //TABLES $('#tableUsuariosExterno').on('click', 'button', function () { @@ -409,7 +448,21 @@ $('#tableUsuarios').on('click', 'button', function () { $('#modalUsuario').modal('hide'); }); - +this.BuscarNombre = function () { + model = { + nombreProyecto: $("#txtNombreProyecto").val() + } + var uri = SinortWCF + '/api/BuscarNombreProyecto'; + AjaxPostData(uri, model, false, false, ExisteNombre, null, null); +} +this.ExisteNombre = function (data) { + if(data!= null){ + if (parseInt(data) > 0) { + toastr.warning("El nombre de la propuesta ya existe"); + return false; + } + } +} this.GuardarPropuesta = function () { if (!$("#formPropuestaNormativa").valid()) { @@ -422,6 +475,7 @@ this.GuardarPropuesta = function () { return false; } + BuscarNombre(); if (!confirm("Va a ingresar una nueva propuesta normativa .\n ¿Desea continuar?")) { return; } diff --git a/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/ProyectoNormativoDAL.cs b/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/ProyectoNormativoDAL.cs index 554f28246..c0bc0cd83 100644 --- a/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/ProyectoNormativoDAL.cs +++ b/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/ProyectoNormativoDAL.cs @@ -15,7 +15,29 @@ namespace AYA.SlnSinortModel.DAL.Sinort public class ProyectoNormativoDAL { Log log = new Log("ProyectoNormativoDAL"); + public string BuscarNombreProyecto(ProyectoNormativoJSON model) + { + string nombre = "0"; + try + { + using (SinortContex db = new SinortContex()) + { + + + nombre = db.ProyectoNormativo.Where(r => r.NombreProyectoNormativo.ToString() == model.nombreProyecto.ToLower()).Count().ToString(); + + + } + } + catch (Exception ex) + { + log.Error(ex); + + } + + return nombre; + } public ProyectoNormativoJSON GuardarProyectoNormativo(ProyectoNormativoJSON model) { try diff --git a/AYA.SlnSynor/AYA.SlnSynorModel/Entidades/Json.cs b/AYA.SlnSynor/AYA.SlnSynorModel/Entidades/Json.cs index 7b127a868..bd1e05676 100644 --- a/AYA.SlnSynor/AYA.SlnSynorModel/Entidades/Json.cs +++ b/AYA.SlnSynor/AYA.SlnSynorModel/Entidades/Json.cs @@ -26,6 +26,8 @@ namespace AYA.SlnSinortModel.Entidades public PlantillaEmail PlantillaEmail { get; set; } public TareasPendientes TareasPendientes { get; set; } public List ListaTareasPendientes { get; set; } + + public string nombreProyecto { get; set; } } //Ficha tecnica