Ejemplo n.º 1
0
 /// <summary>
 /// Agrega una instancia de riesgos_estatus
 /// </summary>
 /// <param name="entidad"></param>
 /// <returns></returns>
 public string Agregar(riesgos_estatus entidad)
 {
     try
     {
         string mess = "";
         if (Exist(entidad.estatus))
         {
             mess = "Ya existe un estatus llamado: " + entidad.estatus;
         }
         else
         {
             riesgos_estatus estatus = new riesgos_estatus
             {
                 estatus = entidad.estatus,
                 activo  = true,
                 usuario = entidad.usuario.ToUpper(),
                 fecha   = DateTime.Now
             };
             Proyectos_ConnextEntities context = new Proyectos_ConnextEntities();
             context.riesgos_estatus.Add(estatus);
             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());
     }
 }
        private string Editar(riesgos_estatus id_riesgos_estatus)
        {
            RiesgosEstatusCOM PE       = new RiesgosEstatusCOM();
            string            vmensaje = PE.Editar(id_riesgos_estatus);

            return(vmensaje);
        }
        private riesgos_estatus GetProyectoEstatus(int id_riesgos_estatus)
        {
            riesgos_estatus dt = new riesgos_estatus();

            try
            {
                RiesgosEstatusCOM PE = new RiesgosEstatusCOM();
                dt = PE.estatus(id_riesgos_estatus);
            }
            catch (Exception)
            {
                dt = null;
            }
            return(dt);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Devuelve una instancia de la clase riesgos_estatus
 /// </summary>
 /// <param name="id_proyecto_perido"></param>
 /// <returns></returns>
 public riesgos_estatus estatus(int id_riesgos_estatus)
 {
     try
     {
         Proyectos_ConnextEntities context = new Proyectos_ConnextEntities();
         riesgos_estatus           estatus = context.riesgos_estatus
                                             .First(i => i.id_riesgos_estatus == id_riesgos_estatus);
         return(estatus);
     }
     catch (DbEntityValidationException ex)
     {
         var errorMessages = ex.EntityValidationErrors
                             .SelectMany(x => x.ValidationErrors)
                             .Select(x => x.ErrorMessage);
         var fullErrorMessage = string.Join("; ", errorMessages);
         return(null);
     }
 }
        protected void lnkguardar_Click(object sender, EventArgs e)
        {
            try
            {
                string          vmensaje           = string.Empty;
                int             id_riesgos_estatus = Convert.ToInt32(hdfid_riesgos_estatus.Value == "" ? "0" : hdfid_riesgos_estatus.Value);
                riesgos_estatus PE = new riesgos_estatus();
                PE.estatus = txtestatus.Text;

                if (id_riesgos_estatus > 0)
                {
                    PE.id_riesgos_estatus = id_riesgos_estatus;
                }
                PE.activo  = chkactivo.Checked;
                PE.usuario = Session["usuario"] as string;
                if (PE.estatus == "")
                {
                    ModalShow("#ModalProyectoestatus");
                    Toast.Error("Error al procesar estatus : Ingrese un titulo", this);
                }
                else
                {
                    vmensaje = id_riesgos_estatus > 0 ? Editar(PE) : Agregar(PE);
                    if (vmensaje == "")
                    {
                        txtestatus.Text             = "";
                        chkactivo.Checked           = false;
                        hdfid_riesgos_estatus.Value = "";
                        CargarCatalogo();
                        Toast.Success("Estatus agregado correctamente.", "Mensaje del sistema", this);
                    }
                    else
                    {
                        ModalShow("#ModalProyectoestatus");
                        Toast.Error("Error al procesar estatus : " + vmensaje, this);
                    }
                }
            }
            catch (Exception ex)
            {
                ModalShow("#ModalProyectoestatus");
                Toast.Error("Error al procesar estatus : " + ex.Message, this);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Elimina una instancia de riesgos_estatus
 /// </summary>
 /// <param name="entidad"></param>
 /// <returns></returns>
 public string Eliminar(int id_riesgos_estatus)
 {
     try
     {
         Proyectos_ConnextEntities context = new Proyectos_ConnextEntities();
         riesgos_estatus           periodo = context.riesgos_estatus
                                             .First(i => i.id_riesgos_estatus == id_riesgos_estatus);
         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());
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Edita una instancia de proyectos estatus
 /// </summary>
 /// <param name="entidad"></param>
 /// <returns></returns>
 public string Editar(riesgos_estatus entidad)
 {
     try
     {
         Proyectos_ConnextEntities context = new Proyectos_ConnextEntities();
         riesgos_estatus           estatus = context.riesgos_estatus
                                             .First(i => i.id_riesgos_estatus == entidad.id_riesgos_estatus);
         estatus.estatus = entidad.estatus;
         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 btneventgrid_Click(object sender, EventArgs e)
 {
     try
     {
         int id_riesgos_estatus = Convert.ToInt32(hdfid_riesgos_estatus.Value == "" ? "0" : hdfid_riesgos_estatus.Value);
         if (id_riesgos_estatus > 0)
         {
             riesgos_estatus PE = GetProyectoEstatus(id_riesgos_estatus);
             if (PE != null)
             {
                 txtestatus.Text   = PE.estatus;
                 chkactivo.Checked = PE.activo;
                 ModalShow("#ModalProyectoestatus");
             }
         }
     }
     catch (Exception ex)
     {
         Toast.Error("Error al cargar estatus : " + ex.Message, this);
     }
 }
 protected void btneliminar_Click(object sender, EventArgs e)
 {
     try
     {
         int             id_riesgos_estatus = Convert.ToInt32(hdfid_riesgos_estatus.Value == "" ? "0" : hdfid_riesgos_estatus.Value);
         riesgos_estatus PE = new riesgos_estatus();
         PE.id_riesgos_estatus = id_riesgos_estatus;
         string vmensaje = Eliminar(id_riesgos_estatus);
         if (vmensaje == "")
         {
             CargarCatalogo();
             Toast.Success("Estatus eliminado correctamente.", "Mensaje del sistema", this);
         }
         else
         {
             Toast.Error("Error al eliminar estatus: " + vmensaje, this);
         }
     }
     catch (Exception ex)
     {
         Toast.Error("Error al eliminar estatus: " + ex.Message, this);
     }
 }