Пример #1
0
        private void CheckUserGroupForModule(Guid obj, Guid grKey)
        {
            var t = from x in db.UserGroupForm where x.ModuleKey == obj && x.UserGroupKey == grKey select x;

            if (!(t.Count() > 0))
            {
                var ts = from x in db.UserGroupModule where x.ModuleKey == obj && x.UserGroupKey == grKey select x;
                foreach (var item in ts)
                {
                    UserGroupModule a = db.UserGroupModule.SingleOrDefault(x => x.UserGroupModuleKey == item.UserGroupModuleKey);
                    db.UserGroupModule.Remove(a);
                    db.SaveChanges();
                }
            }
        }
Пример #2
0
        private void CheckForModuleBeforDelete(UserGroupForm f)
        {
            HasanHoutoneEntities ac = new HasanHoutoneEntities();
            var temp = from x in ac.UserGroupForm where x.UserGroupKey == f.UserGroupKey && x.ModuleKey == f.ModuleKey && x.CompanyKey == GlobalClass.Company.CompanyKey select x;

            if (temp.Count() > 0)
            {
            }
            else
            {
                UserGroupModule obj = db.UserGroupModule.FirstOrDefault(x => x.UserGroupKey == f.UserGroupKey && x.ModuleKey == f.ModuleKey && x.CompanyKey == GlobalClass.Company.CompanyKey);
                ac.UserGroupModule.Remove(obj);
                ac.SaveChanges();
            }
        }
Пример #3
0
 public ActionResult Delete(Guid?id)
 {
     if (GlobalClass.SystemSession)
     {
         Usergroup company = db.Usergroup.Find(id);
         var       temp    = from x in db.UserGroupForm where x.UserGroupKey == id select x;
         var       temp2   = from x in db.UserGroupModule where x.UserGroupKey == id select x;
         var       temp3   = from x in db.StaffList where x.Usergr == id select x;
         if (temp.Count() > 0)
         {
             foreach (var a in temp)
             {
                 HasanHoutoneEntities ac   = new HasanHoutoneEntities();
                 UserGroupForm        form = db.UserGroupForm.Find(a.UserGroupFormKey);
                 ac.UserGroupForm.Remove(form);
                 ac.SaveChanges();
             }
         }
         if (temp3.Count() > 0)
         {
             foreach (var a in temp3)
             {
                 HasanHoutoneEntities ac   = new HasanHoutoneEntities();
                 StaffList            form = db.StaffList.Find(a.PersonnelKey);
                 form.Usergr = null;
                 ac.SaveChanges();
             }
         }
         if (temp2.Count() > 0)
         {
             foreach (var a in temp2)
             {
                 HasanHoutoneEntities ac   = new HasanHoutoneEntities();
                 UserGroupModule      form = db.UserGroupModule.Find(a.UserGroupModuleKey);
                 ac.UserGroupModule.Remove(form);
                 ac.SaveChanges();
             }
         }
         db.Usergroup.Remove(company);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         Exception e = new Exception("Sorry, your Session has Expired");
         return(View("Error", new HandleErrorInfo(e, "UserHome", "Logout")));
     }
 }
Пример #4
0
        private void CheckForModule(Guid moduleID, Guid UserGroupKey)
        {
            HasanHoutoneEntities ac = new HasanHoutoneEntities();
            var temp = from x in ac.UserGroupModule where x.UserGroupKey == UserGroupKey && x.ModuleKey == moduleID && x.CompanyKey == GlobalClass.Company.CompanyKey select x;

            if (temp.Count() > 0)
            {
            }
            else
            {
                UserGroupModule obj = new UserGroupModule();
                obj.CompanyKey         = GlobalClass.Company.CompanyKey;
                obj.ModuleKey          = moduleID;
                obj.UserGroupKey       = UserGroupKey;
                obj.UserGroupModuleKey = Guid.NewGuid();
                ac.UserGroupModule.Add(obj);
                ac.SaveChanges();
            }
        }