private void Save_Data()
        {
            try
            {
                List<ListItem> ilist= multiselect_to.Items.Cast<ListItem>().ToList();
                if (ilist.Count > 0)
                {
                    foreach (var i in ilist)
                    {
                        USER_PERMISSION u = new USER_PERMISSION();
                        u.PER_TYPE = Utils.CIntDef(ddlMenu.SelectedValue);
                        u.PER_GROUP = _UnitData.GetIdGroupByUser(Utils.CIntDef(i.Value));
                        u.PER_USER = Utils.CIntDef(i.Value);
                        u.PER_VIEW = chkFuntion.Items[0].Selected == true ? true : false;
                        u.PER_ADD = chkFuntion.Items[1].Selected == true ? true : false;
                        u.PER_EDIT = chkFuntion.Items[2].Selected == true ? true : false;
                        u.PER_DELE = chkFuntion.Items[3].Selected == true ? true : false;

                        _UserPermissionData.Create(u);
                        db.SubmitChanges();
                    }
                }
            }
            catch (Exception) { throw; }
        }
        private void Save_Data()
        {
            try
            {
                List <ListItem> ilist = multiselect_to.Items.Cast <ListItem>().ToList();
                if (ilist.Count > 0)
                {
                    foreach (var i in ilist)
                    {
                        USER_PERMISSION u = new USER_PERMISSION();
                        u.PER_TYPE  = Utils.CIntDef(ddlMenu.SelectedValue);
                        u.PER_GROUP = _UnitData.GetIdGroupByUser(Utils.CIntDef(i.Value));
                        u.PER_USER  = Utils.CIntDef(i.Value);
                        u.PER_VIEW  = chkFuntion.Items[0].Selected == true ? true : false;
                        u.PER_ADD   = chkFuntion.Items[1].Selected == true ? true : false;
                        u.PER_EDIT  = chkFuntion.Items[2].Selected == true ? true : false;
                        u.PER_DELE  = chkFuntion.Items[3].Selected == true ? true : false;

                        _UserPermissionData.Create(u);
                        db.SubmitChanges();
                    }
                }
            }
            catch (Exception) { throw; }
        }
Exemple #3
0
 public virtual void Remove(int id)
 {
     try
     {
         USER_PERMISSION b = this.GetById(id);
         this.Remove(b);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Exemple #4
0
 public virtual void Remove(USER_PERMISSION b)
 {
     try
     {
         db.USER_PERMISSIONs.DeleteOnSubmit(b);
         db.SubmitChanges();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Exemple #5
0
 public virtual void Create(USER_PERMISSION cus)
 {
     try
     {
         this.db.USER_PERMISSIONs.InsertOnSubmit(cus);
         db.SubmitChanges();
     }
     catch //(Exception e)
     {
         //throw new Exception(e.Message);
     }
 }
 public virtual void Remove(USER_PERMISSION b)
 {
     try
     {
         db.USER_PERMISSIONs.DeleteOnSubmit(b);
         db.SubmitChanges();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
 public virtual void Create(USER_PERMISSION cus)
 {
     try
     {
         this.db.USER_PERMISSIONs.InsertOnSubmit(cus);
         db.SubmitChanges();
     }
     catch //(Exception e)
     {
         //throw new Exception(e.Message);
     }
 }
Exemple #8
0
 public virtual void Update(USER_PERMISSION cus)
 {
     try
     {
         USER_PERMISSION cusOld = this.GetById(cus.ID);
         cusOld = cus;
         db.SubmitChanges();
     }
     catch //(Exception e)
     {
         //throw new Exception(e.Message);
     }
 }
 public virtual void Update(USER_PERMISSION cus)
 {
     try
     {
         USER_PERMISSION cusOld = this.GetById(cus.ID);
         cusOld = cus;
         db.SubmitChanges();
     }
     catch //(Exception e)
     {
         //throw new Exception(e.Message);
     }
 }
Exemple #10
0
        // [ValidateAntiForgeryToken]
        public ActionResult ListPermission2(USER user, AddUserPermission model, string selectedPermissions)
        {
            //lấy ra các quyền nhân viên
            int[] SelectedGroupPermission = string.IsNullOrWhiteSpace(selectedPermissions) ? new int[0]
                    : selectedPermissions.Split(',').Select(x => int.Parse(x)).ToArray();

            user = db.USERs.Include(x => x.USER_PERMISSION).FirstOrDefault(x => x.ID == model.UserId);
            if (user == null)
            {
                return(HttpNotFound());
            }
            if (SelectedGroupPermission == null)
            {
                SelectedGroupPermission = new int[0];
            }
            //ktra selectedpermiss có quyền hay chưa
            var deleted = user.USER_PERMISSION.Where(x => SelectedGroupPermission.Contains(x.Permisstion_ID) == false);

            foreach (var userPermission in deleted.ToList())
            {
                db.USER_PERMISSION.Remove(userPermission);
            }
            var addNew = SelectedGroupPermission.Where(x => user.USER_PERMISSION.All(y => y.Permisstion_ID != x));

            foreach (var permissionId in addNew)
            {
                var permission = new USER_PERMISSION();
                permission.User_ID        = model.UserId;
                permission.Permisstion_ID = permissionId;
                db.USER_PERMISSION.Add(permission);
            }
            var log = new StringBuilder();

            log.Append(db.GetAddDeleteLog((USER_PERMISSION permission) => permission.Permisstion_ID));
            db.SaveChanges();
            return(Json(new RedirectCommand()
            {
                Code = ResultCode.Success, Message = "Cập nhật thành công", Url = Url.Action("ListPermission", new { id = user.ID })
            },
                        JsonRequestBehavior.AllowGet));
        }
Exemple #11
0
        //cập nhật quyền người dùng
        public string updatePermission(int id, int usertemp)
        {
            string msg   = "";
            var    grant = db.USER_PERMISSION.Find(id, usertemp);

            if (grant == null)
            {
                USER_PERMISSION g = new USER_PERMISSION()
                {
                    PERMISSION_ID = id, USER_ID = usertemp, DESCRIPTION = ""
                };
                db.USER_PERMISSION.Add(g);
                msg = "<div class='alert alert-success'> Cấp quyền thành công </div>";
            }
            else
            {
                db.USER_PERMISSION.Remove(grant);
                msg = "<div class='alert alert-danger'> Hủy quyền thành công </div>";
            }
            db.SaveChanges();
            return(msg);
        }