diff --git a/AYA.SlnSynor/AYA.SlnSynor.WCF/SinortCatalogos.svc.cs b/AYA.SlnSynor/AYA.SlnSynor.WCF/SinortCatalogos.svc.cs index 8c7c82fe7..3e69cd7b4 100644 --- a/AYA.SlnSynor/AYA.SlnSynor.WCF/SinortCatalogos.svc.cs +++ b/AYA.SlnSynor/AYA.SlnSynor.WCF/SinortCatalogos.svc.cs @@ -56,26 +56,13 @@ namespace AYA.SlnSinort.WCF } catch (Exception ex) { - - // throw; - //} - return respuesta; - } - public BaseJson ModificarEstadoEmisorPN(Emisor model) - { - BaseJson respuesta = new BaseJson(); - try - { - respuesta = new EmisorDAL().ModificarEstadoEmisorPN(model); - - } - catch (Exception ex) - { throw; } return respuesta; } + + #endregion } } diff --git a/AYA.SlnSynor/AYA.SlnSynor/AYA.SlnSinort.csproj b/AYA.SlnSynor/AYA.SlnSynor/AYA.SlnSinort.csproj index d86210a5a..06e57c8b0 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/AYA.SlnSinort.csproj +++ b/AYA.SlnSynor/AYA.SlnSynor/AYA.SlnSinort.csproj @@ -182,6 +182,7 @@ + @@ -8103,6 +8104,7 @@ + @@ -8152,10 +8154,12 @@ + + diff --git a/AYA.SlnSynor/AYA.SlnSynor/App_Start/BundleConfig.cs b/AYA.SlnSynor/AYA.SlnSynor/App_Start/BundleConfig.cs index 09742166d..15b086ce2 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/App_Start/BundleConfig.cs +++ b/AYA.SlnSynor/AYA.SlnSynor/App_Start/BundleConfig.cs @@ -51,9 +51,8 @@ namespace AYA.SlnSinort .Include("~/Scripts/toastr.min.js") .Include("~/Scripts/jquery.validate.min.js")); - bundles.Add(new ScriptBundle("~/Script-Catalogos") - .Include("~/Sinort-Scripts/EmisorPN.js") - .Include("~/Sinort-Scripts/Mantenimientos.js")); + + } } diff --git a/AYA.SlnSynor/AYA.SlnSynor/Controllers/Catalogos/CatalogosController.cs b/AYA.SlnSynor/AYA.SlnSynor/Controllers/Catalogos/CatalogosController.cs index e08a19c7d..8aca95991 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Controllers/Catalogos/CatalogosController.cs +++ b/AYA.SlnSynor/AYA.SlnSynor/Controllers/Catalogos/CatalogosController.cs @@ -19,5 +19,10 @@ namespace AYA.SlnSinort.Controllers.Catalogos InitControllers(); return View(); } + public ActionResult Aplicacion() + { + InitControllers(); + return View(); + } } } \ No newline at end of file diff --git a/AYA.SlnSynor/AYA.SlnSynor/ControllersWebApi/Matenimimento/AplicacionAPIController.cs b/AYA.SlnSynor/AYA.SlnSynor/ControllersWebApi/Matenimimento/AplicacionAPIController.cs new file mode 100644 index 000000000..7e223a3a6 --- /dev/null +++ b/AYA.SlnSynor/AYA.SlnSynor/ControllersWebApi/Matenimimento/AplicacionAPIController.cs @@ -0,0 +1,51 @@ +using AYA.SlnSinortModel.DAL.Sinort; +using AYA.SlnSinortModel.Entidades; +using AYA.SlnSinortModel.Sinort; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Http; + + +namespace AYA.SlnSinort.ControllersWebApi.Matenimimento +{ + public class AplicacionAPIController : ApiController + { + #region Aplicacion + [HttpGet] + public List ObtenerAplicacion() + { + List respuesta = null; + try + { + respuesta = new AplicacionDAL().ObtenerAplicacion(); + + } + catch (Exception ex) + { + throw; + } + return respuesta; + } + + [HttpPost] + public BaseJson InsertarActualizarAplicacion(Aplicacion model) + { + BaseJson respuesta = new BaseJson(); + try + { + respuesta = new AplicacionDAL().InsertarActualizarAplicacion(model); + } + catch (Exception ex) + { + + throw; + } + return respuesta; + } + + + #endregion + } +} \ No newline at end of file diff --git a/AYA.SlnSynor/AYA.SlnSynor/Scripts/_references.js b/AYA.SlnSynor/AYA.SlnSynor/Scripts/_references.js index fa1e8ba84..668a30458 100644 Binary files a/AYA.SlnSynor/AYA.SlnSynor/Scripts/_references.js and b/AYA.SlnSynor/AYA.SlnSynor/Scripts/_references.js differ diff --git a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Aplicacion.js b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Aplicacion.js new file mode 100644 index 000000000..5b0ca3608 --- /dev/null +++ b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Aplicacion.js @@ -0,0 +1,342 @@ +//$("#formCatalogo").EnableValidationToolTip(); +var DataCatalogo; +var id_column = 1; +var Item = {}; + + +//#region READY + +jQuery(document).ready(function () { + + + getDataModel(); + + +}); + +//#endregion + +this.getDataModel = function () { + + $('#txtDescripcion').attr('size', 50); + + $('#btnGuardar').hide(); + $('#btnInsertar').show(); + + + $('#btnLimpiar').click(function () { + limpiar(); + + $('#btnGuardar').hide(); + $('#btnInsertar').show(); + }); + + $('#btnGuardar').click(function () { + ActualizarItem(); + }); + + $('#btnInsertar').click(function () { + InsertarItem(); + }); + + + obtenerItems(); + + +} + +this.obtenerItems = function () { + + + var uri = server + 'api/AplicacionAPI/ObtenerAplicacion'; + + var DTO = JSON.stringify(Item); + STARTREQUEST(); + //$.getJSON(uri).done(function (data) { + + $.ajax({ + type: 'GET', + url: uri, + cache: false, + data: DTO, + contentType: 'application/json; charset=utf-8', + dataType: 'json', + success: function (data) { + + $('#TableItems').TableInit(0, false, true, true, false, null, null); + + var TableItems = $('#TableItems').DataTable(); + var lista = data; + + $.each(lista, function (key, item) { + + + var option = $("#ucItemsCatalogo").html(); + + option = replaceAll("[$CodItem]", item.IdAplicacion, option); + + var stateIcon = $("#ucItemsIcon").html(); + + if (item.Estado == false) { + stateIcon = replaceAll("[$icon]", "fa-check-circle", stateIcon); + stateIcon = replaceAll("[$state_color]", "muted", stateIcon); + + option = replaceAll("[$opcion]", "Habilitar", option); + option = replaceAll("[$icon]", "fa-check", option); + option = replaceAll("[$value]", "1", option); + } + else { + stateIcon = replaceAll("[$icon]", "fa-check-circle", stateIcon); + stateIcon = replaceAll("[$state_color]", "success", stateIcon); + + option = replaceAll("[$opcion]", "Deshabilitar", option); + option = replaceAll("[$icon]", "fa-times", option); + option = replaceAll("[$value]", "0", option); + } + + TableItems.row.add([stateIcon, + item.IdAplicacion, + item.Descripcion, + option]).draw(); + + }); + + ENDREQUEST(); + } + }).fail(function (jqxhr, textStatus, error) { + + toastr.error("Ha ocurrido un error inesperado. Vuela a intentarlo mas tarde"); + + console.log("Request Failed: " + textStatus + ', ' + error); + + ENDREQUEST(); + + }).then(function (value) { + + ENDREQUEST(); + }); + +} + +this.EditarItem = function (id) { + + TableItems = $('#TableItems').DataTable(); + limpiar(); + var indexes = getRowIndex(TableItems, id_column, id); + + if (indexes != null) { + + $('#hiddenId').val(id) + $('#txtDescripcion').val(TableItems.cell(indexes, 2).data()); + + + + $("#formCatalogo").validateElement("#txtDescripcion"); + + + $('#lbTituloAccion').empty(); + $('#lbTituloAccion').append('Editar Valor de Campo ID: ' + id); + + $('#btnInsertar').hide(); + $('#btnGuardar').show(); + } + + +} + +this.toggleEnabledItem = function (id, value) { + + var msg = '¿Está seguro que desea habilitar la aplicación?'; + + if (value == 0) { + msg = '¿Está seguro que desea deshabilitar la aplicación?'; + } + + if (id == null || value == null) { + toastr.warning("No se pudo obtener el ID de la Aplicación seleccionada."); + return; + } + + if (!confirm(msg)) + { return; } + STARTREQUEST(); + + TableItems = $('#TableItems').DataTable(); + + Item = { + IdEmisor: id, + Estado: value, + } + + var uri = server + 'api/AplicacionAPI/InsertarActualizarAplicacion'; + var DTO = JSON.stringify(Item); + + $.ajax({ + type: 'POST', + url: uri, + cache: false, + data: DTO, + contentType: 'application/json; charset=utf-8', + dataType: 'json', + success: function (data) { + + if (data.CodigoRespuesta == "EXITOSO") { + toastr.info('Información actualizada con éxito', 'Completado'); + limpiar(); + + $('#btnGuardar').hide(); + $('#btnInsertar').show(); + + TableItems.clear().draw(); + obtenerItems(); + ENDREQUEST(); + } + else { + toastr.error("Ha ocurrido un error."); + ENDREQUEST(); + } + + } + }).fail(function (jqxhr, textStatus, error) { + + toastr.error("Ha ocurrido un error inesperado. Vuela a intentarlo."); + ENDREQUEST(); + + }).then(function (value) { + + ENDREQUEST(); + + }); + +} + +this.ActualizarItem = function () { + + if (!$("#formCatalogo").valid()) { + toastr.warning("Ingresar todos los campos que son requeridos."); + return false; + } + + if (!confirm("Se guardarán los cambios.\n ¿Desea continuar?")) + { return; } + STARTREQUEST(); + TableItems = $('#TableItems').DataTable(); + + Emisor = { + IdEmisor: $('#hiddenId').val(), + Descripcion: $('#txtDescripcion').val(), + Estado: 1, + } + + var uri = server + 'api/AplicacionAPI/InsertarActualizarAplicacion' + var DTO = JSON.stringify(Emisor); + + $.ajax({ + type: 'POST', + url: uri, + cache: false, + data: DTO, + contentType: 'application/json; charset=utf-8', + dataType: 'json', + success: function (data) { + + if (data.CodigoRespuesta == "EXITOSO") { + toastr.info('Información guardada con éxito', 'Completado'); + limpiar(); + + $('#btnGuardar').hide(); + $('#btnInsertar').show(); + + $('#lbTituloAccion').empty(); + $('#lbTituloAccion').append('Ingresar Nueva Aplicación'); + + TableItems.clear().draw(); + obtenerItems(); + ENDREQUEST(); + + } + else { + toastr.error("Ha ocurrido un error."); + ENDREQUEST(); + + } + + } + }).fail(function (jqxhr, textStatus, error) { + + toastr.error("Ha ocurrido un error inesperado. Vuela a intentarlo."); + ENDREQUEST(); + + }).then(function (value) { + + ENDREQUEST(); + }); +} + +this.InsertarItem = function () { + + + if (!$("#formCatalogo").valid()) { + toastr.warning("Ingresar todos los campos que son requeridos."); + return false; + } + + if (!confirm("Va a ingresar una nueva aplicación.\n ¿Desea continuar?")) + { return; } + + STARTREQUEST(); + TableItems = $('#TableItems').DataTable(); + + Emisor = { + Descripcion: $("#txtDescripcion").val(), + IdTipoEmisor: 1, + Estado: 1 + } + + var uri = server + 'api/AplicacionAPI/InsertarActualizarAplicacion'; + var DTO = JSON.stringify(Emisor); + + $.ajax({ + type: 'POST', + url: uri, + cache: false, + data: DTO, + contentType: 'application/json; charset=utf-8', + dataType: 'json', + success: function (data) { + + if (data.CodigoRespuesta == "EXITOSO") { + toastr.info('Información guardada con exito', 'Completado'); + limpiar(); + $('#btnGuardar').hide(); + $('#btnInsertar').show(); + + TableItems.clear().draw(); + obtenerItems(); + ENDREQUEST(); + } + else { + toastr.error("Ha ocurrido un error."); + ENDREQUEST(); + } + } + }).fail(function (jqxhr, textStatus, error) { + + toastr.error("Ha ocurrido un error inesperado. Vuela a intentarlo."); + ENDREQUEST(); + + }).then(function (value) { + ENDREQUEST(); + }); +} + +this.limpiar = function () { + + $('#txtDescripcion').val(''); + $("#formCatalogo").validateElement("#txtDescripcion"); + + $('#lbTituloAccion').empty(); + $('#lbTituloAccion').append('Ingresar Nueva Aplicación'); +} + + diff --git a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/EmisorPN.js b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/EmisorPN.js index d752dcab9..ca06ac984 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/EmisorPN.js +++ b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/EmisorPN.js @@ -54,7 +54,7 @@ this.obtenerItems = function () { STARTREQUEST(); $.ajax({ - type: 'GET', + type: 'POST', url: uri, cache: false, data: DTO, diff --git a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Mantenimientos.js b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Mantenimientos.js index a5b1e2ad6..7ea421d86 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Mantenimientos.js +++ b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Mantenimientos.js @@ -1,5 +1,5 @@ //#region READY - +var Item = {}; jQuery(document).ready(function () { CargarMantenimiento(); }); @@ -8,32 +8,41 @@ jQuery(document).ready(function () { this.CargarMantenimiento = function () { - var uri = "api/MantenimientoAPI/ObtenerMantenimientoCatalogos" + var uri = server + 'api/MantenimientoAPI/ObtenerMantenimientoCatalogos'; + var DTO = JSON.stringify(Item); STARTREQUEST(); - $.getJSON(server + uri).done(function (data) { + //$.getJSON(server + uri).done(function (data) { + $.ajax({ + type: 'GET', + url: uri, + cache: false, + data: DTO, + contentType: 'application/json; charset=utf-8', + dataType: 'json', + success: function (data) { - if (data != null) { - lista = data; - var Seleccionar = $("#ucbtnVista").html(); - var columnDefinition = [ - { "data": "Catalogo" }, - { "data": null, className: "center", defaultContent: Seleccionar } - ]; + if (data != null) { + lista = data; + var Seleccionar = $("#ucbtnVista").html(); + var columnDefinition = [ + { "data": "Catalogo" }, + { "data": null, className: "center", defaultContent: Seleccionar } + ]; - $('#tableMantenimiento').TableInitSpanish(1, true, true, true, true, columnDefinition, lista); + $('#tableMantenimiento').TableInit(1, true, true, true, true, columnDefinition, lista); - if ($.fn.DataTable.isDataTable('#tableMantenimiento')) { - LoadMessage(); - $('#tableMantenimiento').DataTable().search('').draw(); - ENDREQUEST(); + if ($.fn.DataTable.isDataTable('#tableMantenimiento')) { + + $('#tableMantenimiento').DataTable().search('').draw(); + ENDREQUEST(); + } + } + + else { + toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error); } } - - else { - toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error); - } - }).fail(function (jqxhr, textStatus, error) { ENDREQUEST(); toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error); diff --git a/AYA.SlnSynor/AYA.SlnSynor/Views/Catalogos/Aplicacion.cshtml b/AYA.SlnSynor/AYA.SlnSynor/Views/Catalogos/Aplicacion.cshtml new file mode 100644 index 000000000..84c29ba3b --- /dev/null +++ b/AYA.SlnSynor/AYA.SlnSynor/Views/Catalogos/Aplicacion.cshtml @@ -0,0 +1,97 @@ + +@{ + ViewBag.Title = "Aplicacion"; + Layout = "~/Views/Shared/_Layout.cshtml"; +} + + +
+
+ + + +@Scripts.Render("~/Sinort-Scripts/Aplicacion.js") + + + + + diff --git a/AYA.SlnSynor/AYA.SlnSynor/Views/Catalogos/EmisorPN.cshtml b/AYA.SlnSynor/AYA.SlnSynor/Views/Catalogos/EmisorPN.cshtml index 68a179338..ac9f70a02 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Views/Catalogos/EmisorPN.cshtml +++ b/AYA.SlnSynor/AYA.SlnSynor/Views/Catalogos/EmisorPN.cshtml @@ -88,5 +88,5 @@ -@Scripts.Render("~/Script-Catalogos") +@Scripts.Render("~/Sinort-Scripts/EmisorPN.js") diff --git a/AYA.SlnSynor/AYA.SlnSynor/Views/Catalogos/Mantenimiento.cshtml b/AYA.SlnSynor/AYA.SlnSynor/Views/Catalogos/Mantenimiento.cshtml index 8f92330e1..6799260a0 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Views/Catalogos/Mantenimiento.cshtml +++ b/AYA.SlnSynor/AYA.SlnSynor/Views/Catalogos/Mantenimiento.cshtml @@ -4,32 +4,36 @@ Layout = "~/Views/Shared/_Layout.cshtml"; } - +