public ActionResult Login([Bind(Include = "LoginId,LoginPwd")]LoginUser user)
        {
            if (!ModelState.IsValid)
            {
                return View(user);
            }
            using (var cxt = new OASysModelContainer())
            {

                var u = cxt.User.SingleOrDefault(us => us.LoginId.Equals(user.LoginId));
                if (u != null && u.LoginPwd == user.LoginPwd)
                {
                    if (u.StateId!=1)
                    {
                        ModelState.AddModelError("UserValidate", "用户已冻结,无法登录");
                    return View(user);
                    }
                    FormsAuthentication.SetAuthCookie(u.LoginId.ToString(), true);
                    u.Branch = cxt.Branch.SingleOrDefault(b => b.BranchId == u.BranchId);
                    Session["UserValidate"] = u;
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("UserValidate", "用户名或密码不正确");
                    return View(user);
                }
            }
        }
        public static User GetFullUser(this IPrincipal User)
        {
            if (User==null)
            {
                return null;
            }
            if (User.Identity==null)
            {
                return null;
            }
            var name = User.Identity.Name;
            if (name == null)
            {

                return null;
            }
            else
            {
                int u;
                if (!int.TryParse(name, out u))
                {
                    return null;
                }
                using (var cxt = new OASysModelContainer())
                {
                    return cxt.User.SingleOrDefault(us => us.UserId == u);
                }
            }
        }
 public ActionResult Noti()
 {
     using (var context = new OASysModelContainer())
     {
         var noty = from n in context.Notification select n;
         return PartialView("NotiFy",noty);
     }
 }
 public ActionResult PermEdit(int roleId)
 {
     using (var cxt = new OASysModelContainer())
     {
         var data = cxt.UserRole.SingleOrDefault(r => r.RoleId == roleId);
         return PartialView(data);
     }
 }
 public ActionResult ReCycleIndex()
 {
     using (var cxt = new OASysModelContainer())
     {
         var data = cxt.File.Where(f => f.IsRecycled);
         return PartialView(data.ToList());
     }
 }
 public ActionResult AddSeal()
 {
     using (var context = new OASysModelContainer())
     {
         var sel = from n in context.DictSub where n.Dict.DictType == 1 select n;
         ViewBag.Zhang = new SelectList(sel, "DictSubId", "DictSubName", "---请选择---");
         return PartialView("Seal");
     }
 }
Exemple #7
0
 public static bool ExistName(this UserRole userRole)
 {
     bool flag = false;
     using (var cxt = new OASysModelContainer())
     {
         flag = cxt.UserRole.Where(r => r.RoleName.ToLower().Equals(userRole.RoleName.ToLower())).Count() > 0;
     }
     return flag;
 }
 public ActionResult OrganManaIndex()
 {
     using (var cxt = new OASys.Models.OASysModelContainer())
     {
         var data = cxt.Branch.ToList();
         data.ForEach(d => d.Organ = cxt.Organ.Where(o => o.OrganId == d.OrganId).SingleOrDefault());
         return PartialView(data);
     }
 }
        public static User GetUserById(this int userId)
        {
            using (var cxt = new OASysModelContainer())
            {
                var  user =  cxt.User.SingleOrDefault(u => u.UserId == userId);
                if (user==null)
                {
                    return null;
                }
                user.Branch = cxt.Branch.SingleOrDefault(b => b.BranchId == user.BranchId);
                if (user.Branch!=null)
                {
                    user.Branch.Organ = cxt.Organ.SingleOrDefault(o=>o.OrganId==user.Branch.OrganId);

                }
                //user.UserRole = cxt.UserRole.SingleOrDefault(r=>r.RoleId==user.UserRoleId);
                //user.Job = cxt.Job.SingleOrDefault(j=>j.JobId==user.JobId);
                //user.Sex = cxt.Sex.SingleOrDefault(s => s.SexId == user.SexId);

                return user;
            }
        }
 public ActionResult RoleNameExists(string roleName)
 {
     string str;
     using (var cxt = new OASysModelContainer())
     {
         var flag = cxt.UserRole.Where(r=>r.RoleName.ToLower().Equals(roleName.ToLower())).Count() > 0 ;
         if (flag)
         {
             str = "角色名已存在";
         }
         else
         {
             str = "角色名可用";
         }
     }
     return Content(str);
 }
Exemple #11
0
 public static void LoadRole(this User user)
 {
     using (var cxt = new OASysModelContainer())
         {
             user.UserRole = cxt.UserRole.SingleOrDefault(r => r.RoleId == user.UserRoleId);
         }
 }
Exemple #12
0
 public static bool SysConfig(this User user, bool enable)
 {
     user.LoadRole();
     var ur = user.UserRole;
     SystemRole sr = (SystemRole)ur.SystemRole;
     var flag = sr.HasFlag(SystemRole.SysConfig);
     if (enable)
     {
         if (flag)
         {
             return true;
         }
         else
         {
             sr = sr | SystemRole.SysConfig;
         }
     }
     else
     {
         if (flag)
         {
             sr = (SystemRole)(sr - SystemRole.SysConfig);
         }
         else
         {
             return true;
         }
     }
     using (var cxt = new OASysModelContainer())
     {
         user.LoadRole();
         cxt.UserRole.Attach(ur);
         ur.SystemRole = (int)sr;
         return cxt.SaveChanges() > 0;
     }
 }
 public ActionResult CheSelect()
 {
     using (var contxt = new OASysModelContainer())
     {
         var che = from n in contxt.Car select n;
         return PartialView("Che", che);
     }
 }
        public ActionResult PermEdit([Bind(Exclude = "SystemRole,DesktopRole")]Perm perm)
        {
            ActionResult ar;
            User user;
            if (!UserVal(out ar,out user))
            {
                return ar;
            }
            var permFlag = user.HasPermManage();
            if (!permFlag)
            {
                return Content("修改失败,权限不足");
            }

            if (perm.SystemRole == -1 || perm.DesktopRole == -1)
            {
                return Content("修改失败,检测到非法提交");
            }
            bool flag;
            using (var cxt = new OASysModelContainer())
            {
                var role = cxt.UserRole.SingleOrDefault(r => r.RoleId == perm.RoleId);
                role.SystemRole = perm.SystemRole;
                role.DesktopRole = perm.DesktopRole;
                flag = cxt.SaveChanges() > 0;
            }
            if (flag)
            {
                return Content("修改成功");
            }
            else
            {
                return Content("修改失败");
            }
        }
 public ActionResult UserLoginIdExists(string loginId)
 {
     string str;
     using (var cxt = new OASysModelContainer())
     {
         var flag = cxt.User.Where(u => u.LoginId.ToLower().Equals(loginId.ToLower())).Count() > 0;
         if (flag)
         {
             str = "登录名已存在";
         }
         else
         {
             str = "登录名可用";
         }
     }
     return Content(str);
 }
 public ActionResult EditChe(int id)
 {
     using (var context = new OASysModelContainer())
     {
         var cher = from n in context.Car where n.CarId == id select n;
         return PartialView("EditChe", cher.SingleOrDefault());
     }
 }
 public ActionResult UserEdit(int userId)
 {
     var user = userId.GetUserById();
     if (user==null)
     {
         return Content("该用户不存在");
     }
     using (var cxt = new OASysModelContainer())
     {
         ViewBag.Branches = new SelectList(cxt.Branch.ToList(), dataValueField: "BranchId", dataTextField: "BranchName");
         ViewBag.Organs = new SelectList(cxt.Organ.ToList(), dataValueField: "OrganId", dataTextField: "OrganName");
         ViewBag.Roles = new SelectList(cxt.UserRole.ToList(), dataValueField: "RoleId", dataTextField: "RoleName");
         ViewBag.Jobs = new SelectList(cxt.Job.ToList(), dataValueField: "JobId", dataTextField: "JobName");
     }
     return PartialView(user);
 }
        public ActionResult UserAdd(User user)
        {
            ActionResult ar;
            User currentUser;
            if (!UserVal(out ar, out currentUser))
            {
                return ar;
            }
            var flag = currentUser.HasRoleManage();
            if (!flag)
            {
                return Content("添加失败,权限不足");
            }
            using (var cxt = new OASysModelContainer())
            {
                var exist = cxt.User.Where(u => u.LoginId.ToLower().Equals(user.LoginId.ToLower())).Count() > 0;
                if (exist)
                {
                    return Content("添加失败,登录名重复");
                }
            }

            user.Address = "未录入";
            user.Email = "未录入";
            user.Telephone = "未录入";
            user.Phone = "未录入";
            var add = user.Add();
            if (add)
            {
                return Content("添加成功");
            }
            else
            {
                return Content("添加失败");
            }
        }
        public ActionResult SelectMeetingRoom(string uName, string rName, DateTime? sTime, DateTime? eTime, int? DictSubId)
        {
            using (var context = new OASysModelContainer())
            {

                var MeetingRoom = from n in context.MeetingRoomOrder select n;
                if (DictSubId.HasValue)
                {
                    MeetingRoom = from n in MeetingRoom where n.DictSubId == DictSubId.Value select n;
                }
                if (sTime.HasValue)
                {
                    MeetingRoom = from n in MeetingRoom where n.StartTime == sTime.Value select n;
                }
                if (eTime.HasValue)
                {
                    MeetingRoom = from n in MeetingRoom where n.EndTime == eTime.Value select n;
                }
                if (!string.IsNullOrWhiteSpace(uName))
                {
                    MeetingRoom = from n in MeetingRoom where n.OrderUser.UserName.Contains(uName.Trim()) select n;
                }
                if (!string.IsNullOrWhiteSpace(rName))
                {
                    MeetingRoom = from n in MeetingRoom where n.OrderRoom.RoomName.Contains(rName.Trim()) select n;
                }

                return Json(MeetingRoom);
            }
        }
 public ActionResult XdMetroom()
 {
     using (var context = new OASysModelContainer())
     {
         var sel = from n in context.DictSub where n.Dict.DictType == 2 select n;
         ViewBag.Zhang = new SelectList(sel, "DictSubId", "DictSubName", "---选择会议类型---");
         return PartialView("XdMer");
     }
 }
 public ActionResult RoleManaIndex()
 {
     using (var cxt = new OASys.Models.OASysModelContainer())
     {
         return PartialView(cxt.UserRole.ToArray());
     }
 }
 public ActionResult selectNoTi(int id)
 {
     using (var context = new OASysModelContainer())
     {
         var sql = from n in context.Notification where n.NotifyId == id select n;
         return PartialView("SelectNoTi");
     }
 }
 public ActionResult UserAdd()
 {
     using (var cxt = new OASysModelContainer())
     {
         ViewBag.Branches = new SelectList(cxt.Branch.ToList(), dataValueField: "BranchId", dataTextField: "BranchName");
         ViewBag.Organs = new SelectList(cxt.Organ.ToList(), dataValueField: "OrganId", dataTextField: "OrganName");
         ViewBag.Roles = new SelectList(cxt.UserRole.ToList(), dataValueField: "RoleId", dataTextField: "RoleName");
         ViewBag.Jobs = new SelectList(cxt.Job.ToList(), dataValueField: "JobId", dataTextField: "JobName");
     }
     return PartialView();
 }