Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
        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);
                }
            }
        }
Ejemplo n.º 3
0
 public ActionResult Noti()
 {
     using (var context = new OASysModelContainer())
     {
         var noty = from n in context.Notification select n;
         return PartialView("NotiFy",noty);
     }
 }
Ejemplo n.º 4
0
 public ActionResult PermEdit(int roleId)
 {
     using (var cxt = new OASysModelContainer())
     {
         var data = cxt.UserRole.SingleOrDefault(r => r.RoleId == roleId);
         return PartialView(data);
     }
 }
Ejemplo n.º 5
0
 public ActionResult ReCycleIndex()
 {
     using (var cxt = new OASysModelContainer())
     {
         var data = cxt.File.Where(f => f.IsRecycled);
         return PartialView(data.ToList());
     }
 }
Ejemplo n.º 6
0
 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");
     }
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 8
0
 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);
     }
 }
Ejemplo n.º 9
0
        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;
            }
        }
Ejemplo n.º 10
0
 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);
 }
Ejemplo n.º 11
0
 public static void LoadRole(this User user)
 {
     using (var cxt = new OASysModelContainer())
         {
             user.UserRole = cxt.UserRole.SingleOrDefault(r => r.RoleId == user.UserRoleId);
         }
 }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 13
0
 public ActionResult CheSelect()
 {
     using (var contxt = new OASysModelContainer())
     {
         var che = from n in contxt.Car select n;
         return PartialView("Che", che);
     }
 }
Ejemplo n.º 14
0
        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("修改失败");
            }
        }
Ejemplo n.º 15
0
 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);
 }
Ejemplo n.º 16
0
 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());
     }
 }
Ejemplo n.º 17
0
 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);
 }
Ejemplo n.º 18
0
        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("添加失败");
            }
        }
Ejemplo n.º 19
0
        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);
            }
        }
Ejemplo n.º 20
0
 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");
     }
 }
Ejemplo n.º 21
0
 public ActionResult RoleManaIndex()
 {
     using (var cxt = new OASys.Models.OASysModelContainer())
     {
         return PartialView(cxt.UserRole.ToArray());
     }
 }
Ejemplo n.º 22
0
 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");
     }
 }
Ejemplo n.º 23
0
 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();
 }