Exemple #1
0
        private void btnAgregarNuevoRol_Click(object sender, EventArgs e)
        {
            roles nrol = new Modelo.roles();

            nrol.pkRol        = FrmCategoriaRoles.Rol;
            nrol.sNombre      = txtRol.Text;
            nrol.sDescripcion = txtDescripcion.Text;


            nrol.modificar(nrol);
            wRol.cargardatos();
            this.Close();
        }
Exemple #2
0
 public void modificar(roles nrol)
 {
     try
     {
         using (var ctx = new DataModel())
         {
             ctx.roles.Attach(nrol);
             ctx.Entry(nrol).State = EntityState.Modified;
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #3
0
 public void eliminar(int pkRol)
 {
     try
     {
         using (var ctx = new DataModel())
         {
             roles user = ctx.roles.Single(r => r.pkRol == pkRol);
             ctx.Entry(user).State = EntityState.Deleted;
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #4
0
 public void guardar(roles nroles)
 {
     try
     {
         using (var ctx = new DataModel())
         {
             if (nroles.pkRol > 0)
             {
                 ctx.Entry(nroles).State = EntityState.Modified;
             }
             else
             {
                 ctx.Entry(nroles).State = EntityState.Added;
             }
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }