private string Editar(riesgos_estrategia id_riesgo_estrategia) { RiesgosEstrategiaCOM PE = new RiesgosEstrategiaCOM(); string vmensaje = PE.Editar(id_riesgo_estrategia); return(vmensaje); }
private riesgos_estrategia GetProyectoEstatus(int id_riesgo_estrategia) { riesgos_estrategia dt = new riesgos_estrategia(); try { RiesgosEstrategiaCOM PE = new RiesgosEstrategiaCOM(); dt = PE.estrategia(id_riesgo_estrategia); } catch (Exception) { dt = null; } return(dt); }
/// <summary> /// Devuelve una instancia de la clase riesgos_estrategia /// </summary> /// <param name="id_proyecto_perido"></param> /// <returns></returns> public riesgos_estrategia estrategia(int id_riesgo_estrategia) { try { Proyectos_ConnextEntities context = new Proyectos_ConnextEntities(); riesgos_estrategia impacto = context.riesgos_estrategia .First(i => i.id_riesgo_estrategia == id_riesgo_estrategia); return(impacto); } catch (DbEntityValidationException ex) { var errorMessages = ex.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); var fullErrorMessage = string.Join("; ", errorMessages); return(null); } }
/// <summary> /// Elimina una instancia de riesgos_estrategia /// </summary> /// <param name="entidad"></param> /// <returns></returns> public string Eliminar(int id_riesgo_estrategia) { try { Proyectos_ConnextEntities context = new Proyectos_ConnextEntities(); riesgos_estrategia periodo = context.riesgos_estrategia .First(i => i.id_riesgo_estrategia == id_riesgo_estrategia); periodo.activo = false; context.SaveChanges(); return(""); } catch (DbEntityValidationException ex) { var errorMessages = ex.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); var fullErrorMessage = string.Join("; ", errorMessages); return(fullErrorMessage.ToString()); } }
/// <summary> /// Edita una instancia de riesgos_estrategia /// </summary> /// <param name="entidad"></param> /// <returns></returns> public string Editar(riesgos_estrategia entidad) { try { Proyectos_ConnextEntities context = new Proyectos_ConnextEntities(); riesgos_estrategia impacto = context.riesgos_estrategia .First(i => i.id_riesgo_estrategia == entidad.id_riesgo_estrategia); impacto.nombre = entidad.nombre; impacto.descripcion = entidad.descripcion; impacto.valor_min = entidad.valor_min; impacto.valor_max = entidad.valor_max; context.SaveChanges(); return(""); } catch (DbEntityValidationException ex) { var errorMessages = ex.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); var fullErrorMessage = string.Join("; ", errorMessages); return(fullErrorMessage.ToString()); } }
protected void btneliminar_Click(object sender, EventArgs e) { try { int id_riesgo_estrategia = Convert.ToInt32(hdfid_riesgo_estrategia.Value == "" ? "0" : hdfid_riesgo_estrategia.Value); riesgos_estrategia PE = new riesgos_estrategia(); PE.id_riesgo_estrategia = id_riesgo_estrategia; string vmensaje = Eliminar(id_riesgo_estrategia); if (vmensaje == "") { CargarCatalogo(); Toast.Success("Estrategia eliminada correctamente.", "Mensaje del sistema", this); } else { Toast.Error("Error al eliminar estrategia: " + vmensaje, this); } } catch (Exception ex) { Toast.Error("Error al eliminar estrategia: " + ex.Message, this); } }
protected void btneventgrid_Click(object sender, EventArgs e) { try { int id_riesgo_estrategia = Convert.ToInt32(hdfid_riesgo_estrategia.Value == "" ? "0" : hdfid_riesgo_estrategia.Value); if (id_riesgo_estrategia > 0) { riesgos_estrategia PE = GetProyectoEstatus(id_riesgo_estrategia); if (PE != null) { txtestatus.Text = PE.nombre; txtmax.Text = PE.valor_max.ToString(); txtmin.Text = PE.valor_min.ToString(); chkactivo.Checked = PE.activo; ModalShow("#ModalProyectoestatus"); } } } catch (Exception ex) { Toast.Error("Error al cargar Estrategia : " + ex.Message, this); } }
/// <summary> /// Agrega una instancia de riesgos_estrategia /// </summary> /// <param name="entidad"></param> /// <returns></returns> public string Agregar(riesgos_estrategia entidad) { try { string mess = ""; if (Exist(entidad.nombre)) { mess = "Ya existe una estrategia llamado: " + entidad.nombre; } else { riesgos_estrategia impacto = new riesgos_estrategia { nombre = entidad.nombre, activo = true, usuario = entidad.usuario.ToUpper(), descripcion = entidad.descripcion, valor_max = entidad.valor_max, valor_min = entidad.valor_min, fecha = DateTime.Now }; Proyectos_ConnextEntities context = new Proyectos_ConnextEntities(); context.riesgos_estrategia.Add(impacto); context.SaveChanges(); } return(mess); } catch (DbEntityValidationException ex) { var errorMessages = ex.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); var fullErrorMessage = string.Join("; ", errorMessages); return(fullErrorMessage.ToString()); } }
protected void lnkguardar_Click(object sender, EventArgs e) { try { string vmensaje = string.Empty; int id_riesgo_estrategia = Convert.ToInt32(hdfid_riesgo_estrategia.Value == "" ? "0" : hdfid_riesgo_estrategia.Value); riesgos_estrategia PE = new riesgos_estrategia(); PE.nombre = txtestatus.Text; if (id_riesgo_estrategia > 0) { PE.id_riesgo_estrategia = id_riesgo_estrategia; } PE.activo = chkactivo.Checked; PE.usuario = Session["usuario"] as string; PE.valor_min = txtmin.Text == ""? Convert.ToByte(0) : Convert.ToByte(txtmin.Text); PE.valor_max = txtmax.Text == "" ? Convert.ToByte(0) : Convert.ToByte(txtmax.Text); if (PE.nombre == "") { ModalShow("#ModalProyectoestatus"); Toast.Error("Error al procesar Estrategia : Ingrese un titulo", this); } else if (PE.valor_min == 0) { ModalShow("#ModalProyectoestatus"); Toast.Error("Error al procesar Estrategia : Ingrese un valor minimo", this); } else if (PE.valor_max == 0) { ModalShow("#ModalProyectoestatus"); Toast.Error("Error al procesar Estrategia : Ingrese un valor maximo", this); } else if (PE.valor_max < PE.valor_min) { ModalShow("#ModalProyectoestatus"); Toast.Error("Error al procesar Estrategia : El valor maximo debe ser mayor o igual al minimo.", this); } else { vmensaje = id_riesgo_estrategia > 0 ? Editar(PE) : Agregar(PE); if (vmensaje == "") { txtestatus.Text = ""; chkactivo.Checked = false; hdfid_riesgo_estrategia.Value = ""; CargarCatalogo(); Toast.Success("Estrategia agregada correctamente.", "Mensaje del sistema", this); } else { ModalShow("#ModalProyectoestatus"); Toast.Error("Error al procesar Estrategia : " + vmensaje, this); } } } catch (Exception ex) { ModalShow("#ModalProyectoestatus"); Toast.Error("Error al procesar Estrategia : " + ex.Message, this); } }