diff --git a/AYA.SlnSynor/AYA.SlnSynor.WCF/ISinort.cs b/AYA.SlnSynor/AYA.SlnSynor.WCF/ISinort.cs index 05eb461c2..e13cefa3a 100644 --- a/AYA.SlnSynor/AYA.SlnSynor.WCF/ISinort.cs +++ b/AYA.SlnSynor/AYA.SlnSynor.WCF/ISinort.cs @@ -18,8 +18,8 @@ namespace AYA.SlnSinort.WCF [OperationContract] ProyectoNormativoJSON GuardarProyectoNormativo(ProyectoNormativoJSON model); - //[OperationContract] - //ProyectoNormativoJSON GuardarConvocatoriaProyectoNormativo(ProyectoNormativoJSON model); + [OperationContract] + ProyectoNormativoJSON GuardarConvocatoriaProyectoNormativo(ProyectoNormativoJSON model); //[OperationContract] //ProyectoNormativoJSON EliminarConvocatoriaProyectoNormativo(ProyectoNormativoJSON model); diff --git a/AYA.SlnSynor/AYA.SlnSynor.WCF/Sinort.svc.cs b/AYA.SlnSynor/AYA.SlnSynor.WCF/Sinort.svc.cs index ad464a7ea..c3d775e1e 100644 --- a/AYA.SlnSynor/AYA.SlnSynor.WCF/Sinort.svc.cs +++ b/AYA.SlnSynor/AYA.SlnSynor.WCF/Sinort.svc.cs @@ -34,6 +34,7 @@ namespace AYA.SlnSinort.WCF } model = new ProyectoNormativoDAL().GuardarProyectoNormativo(model); + } catch (Exception ex) { @@ -43,33 +44,33 @@ namespace AYA.SlnSinort.WCF return model; } - //public ProyectoNormativoJSON GuardarConvocatoriaProyectoNormativo(ProyectoNormativoJSON model) - //{ - // try - // { - // if (model.ProyectoNormativo == null) - // { - // model.CodigoRespuesta = EnumTipoCodigoRespuesta.ADVERTENCIA; - // model.DescripcionRespuesta = "No se encontraron datos del proyecto normativo"; - // return model; - // } + public ProyectoNormativoJSON GuardarConvocatoriaProyectoNormativo(ProyectoNormativoJSON model) + { + try + { + if (model.ProyectoNormativo == null) + { + model.CodigoRespuesta = EnumTipoCodigoRespuesta.ADVERTENCIA; + model.DescripcionRespuesta = "No se encontraron datos del proyecto normativo"; + return model; + } - // if (model.ProyectoNormativo.ConvocatoriaProyectoNormativo == null || model.ProyectoNormativo.ConvocatoriaProyectoNormativo == null || model.ProyectoNormativo.ConvocatoriaProyectoNormativo.Count == 0) - // { - // model.CodigoRespuesta = EnumTipoCodigoRespuesta.ADVERTENCIA; - // model.DescripcionRespuesta = "No se encontraron datos asociados a la convocatoria del proyecto normativo"; - // return model; - // } + if (model.ProyectoNormativo.Convocatoria == null || model.ProyectoNormativo.Convocatoria.Count == 0) + { + model.CodigoRespuesta = EnumTipoCodigoRespuesta.ADVERTENCIA; + model.DescripcionRespuesta = "No se encontraron datos asociados a la convocatoria del proyecto normativo"; + return model; + } - // model = new ConvocatoriaDAL().GuardarConvocatoriaProyectoNormativo(model); - // } - // catch (Exception ex) - // { - // log.Error(ex); - // model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR; - // } - // return model; - //} + model = new ConvocatoriaDAL().GuardarConvocatoriaProyectoNormativo(model); + } + catch (Exception ex) + { + log.Error(ex); + model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR; + } + return model; + } //public ProyectoNormativoJSON EliminarConvocatoriaProyectoNormativo(ProyectoNormativoJSON model) //{ diff --git a/AYA.SlnSynor/AYA.SlnSynor/Controllers/BaseController.cs b/AYA.SlnSynor/AYA.SlnSynor/Controllers/BaseController.cs index a045ba035..dab8af94f 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Controllers/BaseController.cs +++ b/AYA.SlnSynor/AYA.SlnSynor/Controllers/BaseController.cs @@ -14,8 +14,10 @@ namespace AYA.SlnSinort.Controllers public void InitControllers() { Atesa.Utilitarios.ObtieneParametros parametros = new Atesa.Utilitarios.ObtieneParametros(); - var SinortWCF = parametros.GetValueKeyRegedit("SinortWCF", false); - var SinortCatalogosWCF = parametros.GetValueKeyRegedit("SinortCatalogosWCF",false); + var SinortWCF = "http://localhost/AYA.SlnSinort.WCF/Sinort.svc"; + //parametros.GetValueKeyRegedit("SinortWCF", false); + var SinortCatalogosWCF = "http://localhost/AYA.SlnSinort.WCF/SinortCatalogos.svc"; + //parametros.GetValueKeyRegedit("SinortCatalogosWCF",false); ViewBag.SinortWCF = SinortWCF; ViewBag.SinortCatalogosWCF = SinortCatalogosWCF; diff --git a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Global.js b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Global.js index 22c23ef29..d8feead6b 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Global.js +++ b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Global.js @@ -1650,4 +1650,138 @@ $.datepicker.regional['es'] = { showMonthAfterYear: false, yearSuffix: '' }; -$.datepicker.setDefaults($.datepicker.regional['es']); \ No newline at end of file +$.datepicker.setDefaults($.datepicker.regional['es']); + +function getDateFromFormat(val, format) { + val = val + ""; + format = format + ""; + var i_val = 0; + var i_format = 0; + var c = ""; + var token = ""; + var token2 = ""; + var x, y; + var now = new Date(); + var year = now.getYear(); + var month = now.getMonth() + 1; + var date = 1; + var hh = now.getHours(); + var mm = now.getMinutes(); + var ss = now.getSeconds(); + var ampm = ""; + + while (i_format < format.length) { + // Get next token from format string + c = format.charAt(i_format); + token = ""; + while ((format.charAt(i_format) == c) && (i_format < format.length)) { + token += format.charAt(i_format++); + } + // Extract contents of value based on format token + if (token == "yyyy" || token == "yy" || token == "y") { + if (token == "yyyy") { x = 4; y = 4; } + if (token == "yy") { x = 2; y = 2; } + if (token == "y") { x = 2; y = 4; } + year = _getInt(val, i_val, x, y); + if (year == null) { return 0; } + i_val += year.length; + if (year.length == 2) { + if (year > 70) { year = 1900 + (year - 0); } + else { year = 2000 + (year - 0); } + } + } + else if (token == "MMM" || token == "NNN") { + month = 0; + for (var i = 0; i < MONTH_NAMES.length; i++) { + var month_name = MONTH_NAMES[i]; + if (val.substring(i_val, i_val + month_name.length).toLowerCase() == month_name.toLowerCase()) { + if (token == "MMM" || (token == "NNN" && i > 11)) { + month = i + 1; + if (month > 12) { month -= 12; } + i_val += month_name.length; + break; + } + } + } + if ((month < 1) || (month > 12)) { return 0; } + } + else if (token == "EE" || token == "E") { + for (var i = 0; i < DAY_NAMES.length; i++) { + var day_name = DAY_NAMES[i]; + if (val.substring(i_val, i_val + day_name.length).toLowerCase() == day_name.toLowerCase()) { + i_val += day_name.length; + break; + } + } + } + else if (token == "MM" || token == "M") { + month = _getInt(val, i_val, token.length, 2); + if (month == null || (month < 1) || (month > 12)) { return 0; } + i_val += month.length; + } + else if (token == "dd" || token == "d") { + date = _getInt(val, i_val, token.length, 2); + if (date == null || (date < 1) || (date > 31)) { return 0; } + i_val += date.length; + } + else if (token == "hh" || token == "h") { + hh = _getInt(val, i_val, token.length, 2); + if (hh == null || (hh < 1) || (hh > 12)) { return 0; } + i_val += hh.length; + } + else if (token == "HH" || token == "H") { + hh = _getInt(val, i_val, token.length, 2); + if (hh == null || (hh < 0) || (hh > 23)) { return 0; } + i_val += hh.length; + } + else if (token == "KK" || token == "K") { + hh = _getInt(val, i_val, token.length, 2); + if (hh == null || (hh < 0) || (hh > 11)) { return 0; } + i_val += hh.length; + } + else if (token == "kk" || token == "k") { + hh = _getInt(val, i_val, token.length, 2); + if (hh == null || (hh < 1) || (hh > 24)) { return 0; } + i_val += hh.length; hh--; + } + else if (token == "mm" || token == "m") { + mm = _getInt(val, i_val, token.length, 2); + if (mm == null || (mm < 0) || (mm > 59)) { return 0; } + i_val += mm.length; + } + else if (token == "ss" || token == "s") { + ss = _getInt(val, i_val, token.length, 2); + if (ss == null || (ss < 0) || (ss > 59)) { return 0; } + i_val += ss.length; + } + else if (token == "a") { + if (val.substring(i_val, i_val + 2).toLowerCase() == "am") { ampm = "AM"; } + else if (val.substring(i_val, i_val + 2).toLowerCase() == "pm") { ampm = "PM"; } + else { return 0; } + i_val += 2; + } + else { + if (val.substring(i_val, i_val + token.length) != token) { return 0; } + else { i_val += token.length; } + } + } + // If there are any trailing characters left in the value, it doesn't match + if (i_val != val.length) { return 0; } + // Is date valid for month? + if (month == 2) { + // Check for leap year + if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) { // leap year + if (date > 29) { return 0; } + } + else { if (date > 28) { return 0; } } + } + if ((month == 4) || (month == 6) || (month == 9) || (month == 11)) { + if (date > 30) { return 0; } + } + // Correct hours value + if (hh < 12 && ampm == "PM") { hh = hh - 0 + 12; } + else if (hh > 11 && ampm == "AM") { hh -= 12; } + var newdate = new Date(year, month - 1, date, hh, mm, ss); + return newdate.getTime(); +} + diff --git a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Mantenimientos.js b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Mantenimientos.js index 3e1a1ef20..6639a7e5c 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Mantenimientos.js +++ b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Mantenimientos.js @@ -6,7 +6,7 @@ jQuery(document).ready(function () { this.CargarMantenimiento = function () { - + var uri = CatalogosWCF + '/api/ObtenerMantenimientoCatalogos'; AjaxPostData(uri, Item, true, false, CargarTablaMantenimiento, null, null); } diff --git a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/PropuestaNormativa/PropuestaNormativa.js b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/PropuestaNormativa/PropuestaNormativa.js index cb8035e63..954dbcf0b 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/PropuestaNormativa/PropuestaNormativa.js +++ b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/PropuestaNormativa/PropuestaNormativa.js @@ -11,6 +11,7 @@ jQuery(document).ready(function () { this.getDataModel = function () { CargarEmisor(); CargarAplicacion(); + CargarUsuarios(); $("#btnBuscarUsuario").unbind("click"); $("#btnBuscarUsuario").click(function () { BuscarUsuario(); @@ -20,7 +21,10 @@ this.getDataModel = function () { $("#btnAgregarUsuario").click(function () { AgregarUsuario(); }); - CargarUsuarios(); + $('#btnGuardarPropuesta').click(function () { + GuardarPropuesta(); + }); + $('#GridConvocados').TableInit(0, false, true, true, false, null, null); $(function () { @@ -40,7 +44,7 @@ this.CargarEmisor = function (filtro) { var uri = CatalogosWCF + '/api/ObtenerEmisorPopUp'; var model= { - IdTipoEmisor: 1, + IdTipo: 1, filtro: filtro == null ? '' : '&filtro=' + filtro } @@ -108,7 +112,7 @@ this.CargarAplicacion = function (filtro) { var uri = CatalogosWCF + '/api/ObtenerAplicacionPopUp'; var model = { - IdTipoAplicacion: 1, + IdTipo: 1, filtro: filtro == null ? '' : '&filtro=' + filtro } @@ -259,9 +263,77 @@ this.LimpiarUsuario = function () { } this.GuardarPropuesta = function () { - $('#hiddenUsuario').val(''); + + if (!$("#formPropuestaNormativa").valid()) { + toastr.warning("Ingresar todos los campos que son requeridos."); + return false; + } + + if (!confirm("Va a ingresar una nueva propuesta normativa .\n ¿Desea continuar?")) + { return; } + + + TableItems = $('#TableItems').DataTable(); + PropuestaNormativa + = { + NombreProyectoNormativo: $("#txtProyectoNormativo").val(), + IdTipoProyecto: 1, + IdEmisor: $('#hiddenEmisor').val(), + IdAplicacion: $('#hiddenAplicacion').val(), + + FechaInicioConsulta: $("#txtFechaInicio").val(), + FechaFinConsulta: $("#txtFechaFinalizacion").val(), + PromotorProyecto: $("#txtPromotorProyecto").val(), + IdEstado : 1, + FechaMaximaConfirmarParticipacion: $("#txtFechaMaximaConfirmarParticipacion").val() + } + model = { + ProyectoNormativo: PropuestaNormativa + } + var uri = SinortWCF + '/api/GuardarProyectoNormativo'; + AjaxPostData(uri, model, true, true, null, null, true); + + ENDREQUEST(); +} + +this.GuardarConvocadosPropuestaNormativa = function () { + + + tableParticipantes = $('#tableParticipantes').DataTable(); + var IdRoles = $('#hiddenIdRol').val(); + var ArrayParticipantes = []; + var data = tableParticipantes + .rows() + .data(); + + $.each(data, function (key, item) { + + + var cheched = $("#chkSeleccionar_" + item[1]).prop("checked") ? true : false + + + RolesPantallas = { + + IdRolesPantallas: item[0], + IdRol: IdRoles, + IdPantalla: item[1], + Estado: cheched + + } + ArrayRolesPantallas.push(RolesPantallas); + }); + + var uri = CatalogosWCF + '/api/InsertarActualizarRolesPantallas'; + var model = { + ListaRolesPantallas: ArrayRolesPantallas + }; + + AjaxPostData(uri, model, true, true, null, null, null); + + + + ENDREQUEST(); } - diff --git a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Rol.js b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Rol.js index ccb3b57cb..c21001193 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Rol.js +++ b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Rol.js @@ -323,55 +323,6 @@ this.AbrirRolesUsuario = function (id) { CargarUsuarios(id); } -//this.BuscarUsuario = function (data) { - -// var model = { -// codigo :$('#txtUsuario').val() -// } -// var uri = CatalogosWCF + '/api/BuscarUsuario'; -// AjaxPostData(uri, model, true, false, MostarUsuario, null, null); - -//} -//this.MostarUsuario = function (data) { -// GridRolesUsuarios = $('#GridRolesUsuarios').DataTable(); -// var repetido = false; - -// var stateIcon = $("#ucItemsIcon").html(); - - -// stateIcon = replaceAll("[$icon]", "fa-check-circle", stateIcon); -// stateIcon = replaceAll("[$state_color]", "muted", stateIcon); - - - - - -// var data1 = GridRolesUsuarios -// .rows() -// .data(); - -// $.each(data1, function (key, item) { - - -// if (item[3] == data.UsuarioSistema) { -// repetido = true; -// } - -// }); - -// if (repetido == false) { - -// GridRolesUsuarios.row.add([stateIcon, -// 0, -// data.IdUsuario, -// data.UsuarioSistema, -// data.NombreUsuario, -// ""]).draw(); - -// } -// ENDREQUEST(); -// $('#txtUsuario').val(''); -//} this.CargarUsuarios = function (id) { $('#hiddenIdRol').val(id) diff --git a/AYA.SlnSynor/AYA.SlnSynor/Views/PropuestaNormativa/Index.cshtml b/AYA.SlnSynor/AYA.SlnSynor/Views/PropuestaNormativa/Index.cshtml index 37105b269..10da0bfc9 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Views/PropuestaNormativa/Index.cshtml +++ b/AYA.SlnSynor/AYA.SlnSynor/Views/PropuestaNormativa/Index.cshtml @@ -142,7 +142,7 @@ diff --git a/AYA.SlnSynor/AYA.SlnSynor/dist/css/AdminLTE.css b/AYA.SlnSynor/AYA.SlnSynor/dist/css/AdminLTE.css index 241b5ad58..8045b187c 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/dist/css/AdminLTE.css +++ b/AYA.SlnSynor/AYA.SlnSynor/dist/css/AdminLTE.css @@ -417,7 +417,7 @@ a:focus { left: 0; padding-top: 50px; min-height: 100%; - width: 230px; + width: 300px; z-index: 810; -webkit-transition: -webkit-transform 0.3s ease-in-out, width 0.3s ease-in-out; -moz-transition: -moz-transform 0.3s ease-in-out, width 0.3s ease-in-out; diff --git a/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/ConvocatoriaDAL.cs b/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/ConvocatoriaDAL.cs index e74a20d82..2ecbdd7ae 100644 --- a/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/ConvocatoriaDAL.cs +++ b/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/ConvocatoriaDAL.cs @@ -15,47 +15,47 @@ namespace AYA.SlnSinortModel.DAL.Sinort { Log log = new Log("ConvocatoriaDAL"); - //public ProyectoNormativoJSON GuardarConvocatoriaProyectoNormativo(ProyectoNormativoJSON model) - //{ - // try - // { - // using (SinortContex Conn = new SinortContex()) - // { - // foreach (var Convocado in model.ProyectoNormativo.ConvocatoriaProyectoNormativo) - // { - // if (!Conn.Convocatoria.Any(x => x.IdProyectoNormativo == model.ProyectoNormativo.IdProyectoNormativo && x.UsuarioSistema == Convocado.UsuarioSistema)) - // { - // Convocado.FechaCreacion = DateTime.Now; - // Convocado.Estado = false; - // Conn.Convocatoria.Add(Convocado); - // } - // else - // { - // Convocado.FechaModificacion = DateTime.Now; - // Conn.Entry(Convocado).State = System.Data.Entity.EntityState.Detached; - // Conn.Convocatoria.Attach(Convocado); - // Conn.Entry(Convocado).State = System.Data.Entity.EntityState.Modified; - // } - // } + public ProyectoNormativoJSON GuardarConvocatoriaProyectoNormativo(ProyectoNormativoJSON model) + { + try + { + using (SinortContex Conn = new SinortContex()) + { + foreach (var Convocado in model.ProyectoNormativo.Convocatoria) + { + if (!Conn.Convocatoria.Any(x => x.IdProyectoNormativo == model.ProyectoNormativo.IdProyectoNormativo && x.UsuarioSistema == Convocado.UsuarioSistema)) + { + Convocado.FechaCreacion = DateTime.Now; + Convocado.Participante = false; + Conn.Convocatoria.Add(Convocado); + } + else + { + Convocado.FechaModificacion = DateTime.Now; + Conn.Entry(Convocado).State = System.Data.Entity.EntityState.Detached; + Conn.Convocatoria.Attach(Convocado); + Conn.Entry(Convocado).State = System.Data.Entity.EntityState.Modified; + } + } - // Conn.SaveChanges(); - // Conn.Commit(); - // model.CodigoRespuesta = EnumTipoCodigoRespuesta.EXITOSO; - // } - // } - // catch (DbEntityValidationException ex) - // { - // log.Error(ex); - // model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR; - // } - // catch (Exception ex) - // { - // log.Error(ex); - // model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR; - // } + Conn.SaveChanges(); + Conn.Commit(); + model.CodigoRespuesta = EnumTipoCodigoRespuesta.EXITOSO; + } + } + catch (DbEntityValidationException ex) + { + log.Error(ex); + model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR; + } + catch (Exception ex) + { + log.Error(ex); + model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR; + } - // return model; - //} + return model; + } //public ProyectoNormativoJSON EliminarConvocatoriaProyectoNormativo(ProyectoNormativoJSON model) //{ diff --git a/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/ProyectoNormativoDAL.cs b/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/ProyectoNormativoDAL.cs index e5ab0178c..a39b30930 100644 --- a/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/ProyectoNormativoDAL.cs +++ b/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/ProyectoNormativoDAL.cs @@ -42,6 +42,7 @@ namespace AYA.SlnSinortModel.DAL.Sinort Conn.SaveChanges(); Conn.Commit(); model.CodigoRespuesta = EnumTipoCodigoRespuesta.EXITOSO; + model.IdProyectoNormativo = model.ProyectoNormativo.IdProyectoNormativo; } } catch (DbEntityValidationException ex) diff --git a/AYA.SlnSynor/AYA.SlnSynorModel/Entidades/Json.cs b/AYA.SlnSynor/AYA.SlnSynorModel/Entidades/Json.cs index 6ba1f76f5..ebe1b6c00 100644 --- a/AYA.SlnSynor/AYA.SlnSynorModel/Entidades/Json.cs +++ b/AYA.SlnSynor/AYA.SlnSynorModel/Entidades/Json.cs @@ -17,5 +17,6 @@ namespace AYA.SlnSinortModel.Entidades { public ProyectoNormativo ProyectoNormativo { get; set; } public Convocatoria Convocado { get; set; } + public int? IdProyectoNormativo { get; set; } } }