예제 #1
0
        public ActionResult MyFunds(BillsSearchModel info)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int   user = PageValidate.FilterParam(User.Identity.Name);
            Bills dal  = new Bills(db);

            if (!RoleCheck.CheckHasAuthority(user, db, "经费管理"))
            {
                info.userId = user;
            }
            info.PageSize = 0;
            info.userId   = user;
            var bills = dal.GetApplyList(info).ToList();

            foreach (var bill in bills)
            {
                bill.contents         = dal.getContents(bill.reimbursementCode, 0).ToList();
                bill.attachmentsCount = dal.getAttachments(bill.reimbursementCode, 0).Count();
            }
            ViewData["Bills"] = bills;
            List <SelectOption> options = DropDownList.RespondStateSelect();

            ViewData["RState"] = DropDownList.SetDropDownList(options);
            return(View(info));
        }
예제 #2
0
        public static List <SelectOption> FundsSelect(int user)
        {
            string       key   = cache_funds + user;
            List <Funds> funds = DBCaches <Funds> .getCache(cache_funds);

            List <SelectOption> options = (List <SelectOption>)DataCache.GetCache(key);

            if (options == null)
            {
                var query = from fund in funds
                            where fund.f_state == 1
                            select fund;
                if (user > 0 && !RoleCheck.CheckHasAuthority(user, db, "经费管理"))
                {
                    query = query.Where(x => x.f_manager == user);
                }
                options = (from fund in query
                           select new SelectOption
                {
                    id = fund.f_id.ToString(),
                    text = string.Format("{0}({1})", fund.f_name, fund.f_code)
                }).ToList();
                if (options.Count() > 0)
                {
                    DataCache.SetCache(key, options);
                }
            }
            return(options);
        }
        public ActionResult Responded(BillsSearchModel info)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "Index" }));
            }
            ApplyManager dal    = new ApplyManager(db);
            int          userId = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(userId, db, "批复管理", "批复"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限。" }));
            }
            if (RoleCheck.CheckHasAuthority(userId, db, "批复管理"))
            {
                if (info.userId == null)
                {
                    info.userId = 0;
                }
            }
            else
            {
                info.userId = userId;
            }
            SetSelect();
            var list = getResponseDetail((int)info.userId, 1, 2, 3, 4);

            ViewData["Bills"] = list;
            return(View(info));
        }
예제 #4
0
        public JsonResult SetRoleAuth(List <ViewRoleAuthority> auths)
        {
            BaseJsonData json = new BaseJsonData();

            if (!User.Identity.IsAuthenticated)
            {
                json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。";
                json.msg_code = "notLogin";
                goto next;
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                json.msg_text = "没有权限。";
                json.msg_code = "NoPower";
                goto next;
            }
            if (auths == null || auths.Count() == 0)
            {
                json.msg_text = "没有接收任何数据。";
                json.msg_code = "NoReceive";
                goto next;
            }
            bool firstIn = true;

            foreach (ViewRoleAuthority item in auths)
            {
                if (firstIn)
                {
                    db.Role_vs_Authority.RemoveRange(db.Role_vs_Authority.Where(x => x.rva_role_id == item.roleId));
                    firstIn = false;
                }
                Role_vs_Authority rva = new Role_vs_Authority()
                {
                    rva_auth_id = item.authId,
                    rva_role_id = item.roleId
                };
                db.Role_vs_Authority.Add(rva);
            }
            try
            {
                db.SaveChanges();
                json.state    = 1;
                json.msg_text = "角色的权限修改成功。";
                json.msg_code = "success";
            }
            catch (Exception ex)
            {
                json.msg_text = "角色权限修改出错。";
                json.msg_code = "error";
                Common.ErrorUnit.WriteErrorLog(ex.ToString(), this.GetType().ToString());
            }
            SysLog.WriteLog(user, "重置角色的权限", IpHelper.GetIP(), "", 5, "", db);
            //重设置角色权限后,必需清除缓存
            DataCache.RemoveCacheBySearch("user_vs_roles");
next:
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
예제 #5
0
        public JsonResult ContrlModule(EditModules models)
        {
            BaseJsonData json = new BaseJsonData();

            if (!User.Identity.IsAuthenticated)
            {
                json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。";
                json.msg_code = "notLogin";
                goto next;
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                json.msg_text = "没有权限。";
                json.msg_code = "NoPower";
                goto next;
            }
            if (ModelState.IsValid)
            {
                string ctrl_name;
                foreach (ModuleInfo info in models.modules)
                {
                    ctrl_name = info.name;
                    var no1 = db.Role_vs_Controller.Where(x => x.rvc_role_id != 1 && x.rvc_controller == ctrl_name);
                    if (no1.Count() > 0)
                    {
                        db.Role_vs_Controller.RemoveRange(no1);
                        db.SaveChanges();
                    }
                    if (info.roles != null && info.roles.Length > 0)
                    {
                        foreach (RoleInfo rinfo in info.roles)
                        {
                            Role_vs_Controller rvc = new Role_vs_Controller();
                            rvc.rvc_role_id    = rinfo.id;
                            rvc.rvc_controller = ctrl_name;
                            if (db.Role_vs_Controller.Find(rvc.rvc_role_id, rvc.rvc_controller) == null)
                            {
                                db.Role_vs_Controller.Add(rvc);
                            }
                        }
                    }
                }
                db.SaveChanges();
                SysLog.WriteLog(user, "修改系统模块", IpHelper.GetIP(), "", 5, "", db);
                json.state    = 1;
                json.msg_code = "success";
                json.msg_text = "数据更新成功。";
                DBCaches2.ClearCache("dic-module");
            }
            else
            {
                json.msg_code = "error";
                json.msg_text = "数据接收错误。";
            }
next:
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
예제 #6
0
        public JsonResult UpdateRole(Dic_Role model)
        {
            BaseJsonData json = new BaseJsonData();

            if (!User.Identity.IsAuthenticated)
            {
                json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。";
                json.msg_code = "notLogin";
                goto next;
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                json.msg_text = "没有权限。";
                json.msg_code = "NoPower";
                goto next;
            }
            if (model.role_id == 0)
            {
                json.msg_text = "获取角色的ID出错。";
                json.msg_code = "IDError";
                goto next;
            }
            if (model.role_id == 1)
            {
                json.msg_text = "该角色不允许修改。";
                json.msg_code = "CanNotUpdate";
                goto next;
            }
            var same = db.Dic_Role.Where(x => x.role_name == model.role_name && x.role_id != model.role_id);

            if (same.Count() > 0)
            {
                json.msg_text = "该名称已存在。";
                json.msg_code = "NameExists";
                goto next;
            }
            db.Entry(model).State = EntityState.Modified;
            try
            {
                db.SaveChanges();
                DBCaches <Dic_Role> .ClearCache("cache_role");
            }
            catch
            {
                json.msg_text = "更新,请重新操作。";
                json.msg_code = "UpdateErr";
                goto next;
            }
            json.state    = 1;
            json.msg_code = "success";
            json.msg_text = "更新成功!";
            SysLog.WriteLog(user, string.Format("更新角色[{0}]名称", model.role_name), IpHelper.GetIP(), "", 5, "", db);
next:
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
예제 #7
0
        public ActionResult Index(BasePagerModel pager)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int uid = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(uid, db, "用户管理"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限。" }));
            }
            if (pager == null)
            {
                pager = new BasePagerModel();
            }
            ViewData["search"] = pager;
            var list = (from user in db.User_Info
                        join uvr in db.User_vs_Role
                        on user.user_id equals uvr.uvr_user_id into T1
                        from t1 in T1.DefaultIfEmpty()
                        join role in db.Dic_Role
                        on t1.uvr_role_id equals role.role_id into T2
                        from t2 in T2.DefaultIfEmpty()
                        join ue in db.User_Extend
                        on user.user_id equals ue.user_id into T3
                        from t3 in T3.DefaultIfEmpty()
                        join dept in db.Dic_Department
                        on t3.user_dept_id equals dept.dept_id into T4
                        from t4 in T4.DefaultIfEmpty()
                        join post in db.Dic_Post
                        on t3.user_post_id equals post.post_id into T5
                        from t5 in T5.DefaultIfEmpty()
                        orderby user.user_id ascending
                        select new UserListModel
            {
                id = user.user_id,
                name = user.user_name,
                roleName = t2.role_name == null?"":t2.role_name,
                stateTxt = user.user_state == 1 ? "正常" : (user.user_state == 2 ? "锁定" : (user.user_state == 0 ? "未启用" : "未知")),
                realName = user.real_name,
                times = user.user_login_times,
                deptName = t4.dept_name == null?"":t4.dept_name,
                postName = t5.post_name == null?"":t5.post_name,
                picture = t3.user_picture == null?"default.jpg":t3.user_picture,
                loginTimes = user.user_login_times
            }).Skip((pager.PageIndex - 1) * pager.PageSize).Take(pager.PageSize).ToList();

            foreach (var item in list)
            {
                item.realName = Common.DEncrypt.AESEncrypt.Decrypt(item.realName);
            }
            return(View(list));
        }
예제 #8
0
        public ActionResult Index()
        {
            int uid = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(uid, db, "用户管理"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限。" }));
            }
            BasePagerModel pager = new BasePagerModel();

            return(Index(pager));
        }
예제 #9
0
        public JsonResult DeleteRole(string rid)
        {
            int          id   = PageValidate.FilterParam(rid);
            BaseJsonData json = new BaseJsonData();

            if (!User.Identity.IsAuthenticated)
            {
                json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。";
                json.msg_code = "notLogin";
                goto next;
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                json.msg_text = "没有权限。";
                json.msg_code = "NoPower";
                goto next;
            }
            if (id == 1)
            {
                json.msg_text = "该角色不允许删除。";
                json.msg_code = "CanNotDel";
                goto next;
            }
            Dic_Role model = db.Dic_Role.Find(id);

            if (model == null)
            {
                json.msg_text = "没有找到该角色,该角色可能已被删除。";
                json.msg_code = "noThis";
                goto next;
            }
            db.Dic_Role.Remove(model);
            try
            {
                db.SaveChanges();
                DBCaches <Dic_Role> .ClearCache("cache_role");
            }
            catch
            {
                json.msg_text = "删除失败,请重新操作。";
                json.msg_code = "recyErr";
                goto next;
            }
            json.state    = 1;
            json.msg_code = "success";
            json.msg_text = "删除成功!";
            SysLog.WriteLog(user, string.Format("删除角色[{0}]", model.role_name), IpHelper.GetIP(), "", 5, "", db);
next:
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
예제 #10
0
        // GET: UserManager/Edit/5
        public ActionResult Edit(int?id)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "用户管理"))
            {
                id = user;
            }
            if (id == null)
            {
                id = user;
            }
            setSelect();
            UserEditModel model = new UserEditModel();
            User_Info     info  = db.User_Info.Find(id);

            if (info == null)
            {
                ViewBag.msg = "该用户可能已被删除,无法查到该用户信息。";
                goto next;
            }
            info.ToDecrypt();
            model.FromUserInfoDB(info);
            User_Extend extend = db.User_Extend.Find(id);

            if (extend != null)
            {
                model.FromUserExtendDB(extend);
                int p = (from dept in db.Dic_Department where dept.dept_id == extend.user_dept_id select dept.dept_parent_id).FirstOrDefault();
                if (p == 0)
                {
                    model.deptId = extend.user_dept_id;
                }
                else
                {
                    int dept_id = (from dept in db.Dic_Department where dept.dept_id == p select dept.dept_id).FirstOrDefault();
                    model.deptId    = dept_id;
                    model.deptChild = extend.user_dept_id;
                    List <SelectOption> options = DropDownList.getDepartment(dept_id);
                    ViewBag.DeptChild = DropDownList.SetDropDownList(options);
                }
            }
            model.roleId = (from svr in db.User_vs_Role
                            where svr.uvr_user_id == id
                            select svr.uvr_role_id).DefaultIfEmpty(0).FirstOrDefault();
next:
            return(View(model));
        }
예제 #11
0
        public JsonResult DeleteAttachment(int id)
        {
            BaseJsonData json = new BaseJsonData();

            if (!User.Identity.IsAuthenticated)
            {
                json.msg_code = "nologin";
                goto next;
            }
            Reimbursement_Attachment atta = db.Reimbursement_Attachment.Find(id);

            if (atta == null)
            {
                json.msg_code = "nodate";
                json.msg_text = "附件不存在或被删除。";
                goto next;
            }
            Reimbursement bill = db.Reimbursement.Find(atta.atta_reimbursement_code);

            if (bill != null)
            {
                int user = Common.PageValidate.FilterParam(User.Identity.Name);
                if (user != bill.r_add_user_id && !RoleCheck.CheckHasAuthority(user, db, "系统管理"))
                {
                    json.msg_code = "forbidden";
                    json.msg_text = "没有权限操作他人申请的报销单。";
                    goto next;
                }
                if (bill.r_bill_state == 1)
                {
                    json.msg_code = "forbidden";
                    json.msg_text = "已批复同意的报销单不允许删除任何信息。";
                    goto next;
                }
            }
            db.Reimbursement_Attachment.Remove(atta);
            try
            {
                db.SaveChanges();
            }
            catch (Exception e)
            {
                ErrorUnit.WriteErrorLog(e.ToString(), this.GetType().Name);
                json.msg_code = "error";
                json.msg_text = "附件删除失败。";
                goto next;
            }
            json.state    = 1;
            json.msg_code = "success";
next:
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
예제 #12
0
        public ActionResult Detail(StatisticsSearch search)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            setSearchSelect(user);
            if (!RoleCheck.CheckHasAuthority(user, db, "经费管理"))
            {
                search.manager = user;
                search.userId  = user;
            }
            if (search.userId == null)
            {
                search.userId = 0;
            }
            ApplyManager dal   = new ApplyManager(db);
            var          query = dal.GetReimbursement("", (int)search.userId).Where(x => x.state == 1);

            if (search.manager > 0)
            {
                query = query.Where(x => x.manager == search.manager);
            }
            if (search.beginDate != null)
            {
                search.beginDate = DateTime.Parse(((DateTime)search.beginDate).ToString("yyyy-MM-dd 00:00:00.000"));
                query            = query.Where(x => x.time >= search.beginDate);
            }
            if (search.endDate != null)
            {
                search.endDate = DateTime.Parse(((DateTime)search.endDate).ToString("yyyy-MM-dd 23:59:59.999"));
                query          = query.Where(x => x.time <= search.endDate);
            }
            search.Amount = query.Count();
            query         = query.OrderByDescending(x => x.time).Skip(search.PageSize * (search.PageIndex - 1)).Take(search.PageSize);
            var list = query.ToList();

            foreach (var item in list)
            {
                item.userName         = AESEncrypt.Decrypt(item.userName);
                item.attachmentsCount = (from content in db.Reimbursement_Content
                                         join detail in db.Reimbursement_Detail on content.content_id equals detail.detail_content_id
                                         where content.c_reimbursement_code == item.reimbursementCode
                                         select content.content_id).Count();
            }
            ViewData["Details"] = list;
            return(View(search));
        }
예제 #13
0
        public static List <SelectOption> FundsManagerSelect(int userId)
        {
            string key;
            bool   isManager = RoleCheck.CheckHasAuthority(userId, db, "经费管理");

            if (isManager)
            {
                key = cache_response_user;
            }
            else
            {
                key = cache_response_user + userId;
            }
            List <SelectOption> options = (List <SelectOption>)DataCache.GetCache(key);

            if (options == null)
            {
                var query = (from funds in db.Funds
                             join user in db.User_Info on funds.f_manager equals user.user_id
                             group funds by new { funds.f_manager, user.user_name } into g
                             select new
                {
                    userId = g.Key.f_manager,
                    userName = g.Key.user_name
                }
                             ).ToList();
                if (userId > 0 && !isManager)
                {
                    query = query.Where(x => x.userId == userId).ToList();
                }
                options = (from user in query
                           select new SelectOption
                {
                    id = user.userId.ToString(),
                    text = AESEncrypt.Decrypt(user.userName)
                }).ToList();
                if (isManager)
                {
                    options.Insert(0, new SelectOption {
                        id = "0", text = "全部"
                    });
                }
                if (options.Count() > 0)
                {
                    DataCache.SetCache(key, options);
                }
            }
            return(options);
        }
예제 #14
0
        public ActionResult Role()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限当前内容。" }));
            }
            ViewData["RoleList"] = DBCaches <Dic_Role> .getCache("cache_role");;
            return(View(new Dic_Role()));
        }
예제 #15
0
        // GET: FundsManager/Create
        public ActionResult Create()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int user = Common.PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "添加经费", "经费管理"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限。" }));
            }
            SetSelect();
            return(View(new FundsModel()));
        }
예제 #16
0
        public static List <SelectOption> UserSelect(int userId)
        {
            string key       = cache_user + userId;
            bool   isManager = RoleCheck.CheckHasAuthority(userId, db, "经费管理", "用户管理");

            if (isManager)
            {
                key = cache_user;
            }
            else
            {
                key = cache_user + userId;
            }
            List <SelectOption> options = (List <SelectOption>)DataCache.GetCache(key);

            if (options == null)
            {
                var query = (from user in db.User_Info
                             where user.user_state == 1
                             select new
                {
                    userId = user.user_id,
                    userName = user.real_name
                }).ToList();
                if (userId > 0 && !isManager)
                {
                    query = query.Where(x => x.userId == userId).ToList();
                }

                options = (from user in query
                           select new SelectOption
                {
                    id = user.userId.ToString(),
                    text = AESEncrypt.Decrypt(user.userName)
                }).ToList();
                if (isManager)
                {
                    options.Insert(0, new SelectOption {
                        id = "0", text = "全部"
                    });
                }
                if (options.Count() > 0)
                {
                    DataCache.SetCache(key, options);
                }
            }
            return(options);
        }
예제 #17
0
        public ActionResult SiteSet()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限执行当前操作。" }));
            }

            ViewModels.SiteInfo info = Lythen.Controllers.SiteInfo.getSiteInfo();
            return(View(info));
        }
예제 #18
0
        public JsonResult DeleteDept(string pid)
        {
            int          id   = PageValidate.FilterParam(pid);
            BaseJsonData json = new BaseJsonData();

            if (!User.Identity.IsAuthenticated)
            {
                json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。";
                json.msg_code = "notLogin";
                goto next;
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                json.msg_text = "没有权限。";
                json.msg_code = "NoPower";
                goto next;
            }
            Dic_Department model = db.Dic_Department.Find(id);

            if (model == null)
            {
                json.msg_text = "没有找到该部门/科室,该部门/科室可能已被删除。";
                json.msg_code = "noThis";
                goto next;
            }
            db.Dic_Department.Remove(model);
            try
            {
                db.SaveChanges();
                DBCaches2.ClearCache("cache_depts");
            }
            catch
            {
                json.msg_text = "删除失败,请重新操作。";
                json.msg_code = "recyErr";
                goto next;
            }
            SysLog.WriteLog(user, string.Format("删除部门[{0}]", model.dept_name), IpHelper.GetIP(), "", 5, "", db);
            json.state    = 1;
            json.msg_code = "success";
            json.msg_text = "删除成功!";
next:
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
예제 #19
0
        public JsonResult GetRoleAuth(int roleId)
        {
            BaseJsonData json = new BaseJsonData();

            if (!User.Identity.IsAuthenticated)
            {
                json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。";
                json.msg_code = "notLogin";
                goto next;
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                json.msg_text = "没有权限。";
                json.msg_code = "NoPower";
                goto next;
            }
            if (roleId == 0)
            {
                json.msg_text = "获取角色出错。";
                json.msg_code = "IDError";
                goto next;
            }
            var rvas = from rva in db.Role_vs_Authority
                       where rva.rva_role_id == roleId
                       select new ViewRoleAuthority
            {
                authId = rva.rva_auth_id,
                roleId = rva.rva_role_id
            };

            if (rvas.Count() == 0)
            {
                json.state    = 0;
                json.msg_code = "noData";
                json.msg_text = "没有数据。";
            }
            else
            {
                json.state = 1;
                json.data  = rvas.ToList();
            }
next:
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
예제 #20
0
        public ActionResult Create([Bind(Include = "code,name,source,amount,balance,processId,info,state")] FundsModel funds)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int user = Common.PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "添加经费", "经费管理"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限。" }));
            }
            SetSelect();
            if (ModelState.IsValid)
            {
                if (db.Funds.Where(x => x.f_code == funds.code).Count() > 0)
                {
                    ViewBag.msg = "该代码已被使用";
                    return(View(funds));
                }
                if (db.Funds.Where(x => x.f_name == funds.name).Count() > 0)
                {
                    ViewBag.msg = "该名称已被使用";
                    return(View(funds));
                }
                //if (funds.processId == null || funds.processId == 0)
                //{
                //    ViewBag.msg = "未选择批复流程。";
                //    return View(funds);
                //}
                if (funds.amount == 0)
                {
                    ViewBag.msg = "请设置经费总额。";
                    return(View(funds));
                }
                Funds model = new Funds();
                funds.toDBModel(model);
                model.f_manager = user;
                db.Funds.Add(model);
                db.SaveChanges();
                SysLog.WriteLog(user, string.Format("经费添加[{0}]", model.f_code), IpHelper.GetIP(), model.f_id.ToString(), 6, "", db);
                ViewBag.msg = "经费添加成功。";
            }

            return(View(funds));
        }
예제 #21
0
        // GET: Teacher/Details/5
        public ActionResult Details(int id)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int userid = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(userid, db, "用户查询", "用户管理") && id != userid)
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限。" }));
            }
            TeacherSearch model = new TeacherSearch();

            model.id = id;
            return(View(GetInfo(model)));
        }
예제 #22
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int userid = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(userid, db, "用户管理"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限。" }));
            }
            User_Info user_Info = db.User_Infos.Find(id);

            db.User_Infos.Remove(user_Info);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #23
0
        public ActionResult TimesStaticstics(StatisticsSearch search)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            setSearchSelect(user);
            if (!RoleCheck.CheckHasAuthority(user, db, "统计"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限。" }));
            }
            Statistics dal   = new Statistics(db);
            var        query = dal.GetTimesStatistics(search);

            ViewData["StatData"] = query;
            return(View(search));
        }
예제 #24
0
        public ActionResult Department()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限执行当前操作。" }));
            }

            List <SelectOption> options = DropDownList.getDepartment();

            ViewBag.Dept         = DropDownList.SetDropDownList(options);
            ViewData["DeptList"] = DBCaches2.getDeptCache();
            return(View(new DepartMentModel()));
        }
예제 #25
0
        // GET: FundsManager/Edit/5
        public ActionResult Edit(int?id)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            int user = Common.PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "添加经费", "经费管理"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限。" }));
            }
            SetSelect();
            FundsModel funds = (from f in db.Funds
                                where f.f_id == (int)id
                                select new FundsModel
            {
                amount = f.f_amount,
                id = f.f_id,
                balance = f.f_balance,
                info = f.f_info,
                manager = f.f_manager,
                name = f.f_name,
                source = f.f_source,
                state = f.f_state,
                code = f.f_code
            }).FirstOrDefault();

            if (funds == null)
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有找到该经费。" }));
            }
            if (user != funds.manager && !RoleCheck.CheckHasAuthority(user, db, "经费管理"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有对该经费的管理权限。" }));
            }
            return(View(funds));
        }
예제 #26
0
        public ActionResult Department(DepartMentModel info)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限执行当前操作。" }));
            }

            List <SelectOption> options = DropDownList.getDepartment();

            ViewBag.Dept = DropDownList.SetDropDownList(options);
            Dic_Department model = new Dic_Department();

            model.dept_name = PageValidate.InputText(info.deptName, 50);
            if (db.Dic_Department.Where(x => x.dept_name == model.dept_name && x.dept_parent_id == info.parentId).Count() > 0)
            {
                ViewBag.msg = "名称已存在";
            }
            else
            {
                model.dept_parent_id = info.parentId;
                db.Dic_Department.Add(model);
                try
                {
                    db.SaveChanges();
                    DBCaches2.ClearCache("cache_depts");
                }
                catch
                {
                    ViewBag.msg = "部门添加失败,请重试。";
                }
            }
            SysLog.WriteLog(user, string.Format("添加部门[{0}]", model.dept_name), IpHelper.GetIP(), "", 5, "", db);
            ViewData["DeptList"] = DBCaches2.getDeptCache();
            return(View(info));
        }
예제 #27
0
        public JsonResult DeleteAllCache()
        {
            BaseJsonData json = new BaseJsonData();

            if (!User.Identity.IsAuthenticated)
            {
                json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。";
                json.msg_code = "notLogin";
                return(Json(json, JsonRequestBehavior.AllowGet));
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                json.msg_text = "没有权限。";
                json.msg_code = "NoPower";
                return(Json(json, JsonRequestBehavior.AllowGet));
            }
            DataCache.RemoveAllCache();
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
예제 #28
0
        public ActionResult SiteSet([Bind(Include = "name,company,introduce,companyAddress,companyPhone,companyEmail,managerName,managerPhone,managerEmail")] ViewModels.SiteInfo info)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限执行当前操作。" }));
            }

            Sys_SiteInfo model = db.Sys_SiteInfo.FirstOrDefault();

            if (model != null)
            {
                db.Sys_SiteInfo.Remove(model);
                db.SaveChanges();
            }
            model = new Sys_SiteInfo();
            info.toDBModel(model);
            db.Sys_SiteInfo.Add(model);

            try
            {
                db.SaveChanges();
                DBCaches <Sys_SiteInfo> .ClearCache("site-name");

                DBCaches <Sys_SiteInfo> .ClearCache("site-info");
            }
            catch (Exception ex)
            {
                @ViewBag.msg = "修改失败。";
            }
            SysLog.WriteLog(user, "修改网站信息", IpHelper.GetIP(), "", 5, "", db);
            @ViewBag.msg = "修改成功。";
            return(View(info));
        }
예제 #29
0
        public ActionResult ContrlModule()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限执行当前操作。" }));
            }

            List <ModuleInfo> models = DBCaches2.getModuleInfo();

            foreach (ModuleInfo model in models)
            {
                int[] roles = (from rvc in db.Role_vs_Controller
                               where rvc.rvc_controller == model.name
                               select rvc.rvc_role_id
                               ).ToArray();
                RoleInfo[] rvcs = DBCaches2.getRoleInfo();
                foreach (RoleInfo item in rvcs)
                {
                    if (roles.Contains(item.id))
                    {
                        item.hasrole = true;
                    }
                    else
                    {
                        item.hasrole = false;
                    }
                }
                model.roles = rvcs;
            }
            return(View(models));
        }
예제 #30
0
        public ActionResult Role(Dic_Role model)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限当前内容。" }));
            }

            model.role_name = PageValidate.InputText(model.role_name, 50);
            if (db.Dic_Role.Where(x => x.role_name == model.role_name).Count() > 0)
            {
                ViewBag.msg = "角色名称已存在";
            }
            else
            {
                db.Dic_Role.Add(model);
                try
                {
                    db.SaveChanges();
                    DBCaches <Dic_Role> .ClearCache("cache_role");
                }
                catch
                {
                    ViewBag.msg = "角色添加失败,请重试。";
                }
            }

            SysLog.WriteLog(user, string.Format("添加角色[{0}]", model.role_name), IpHelper.GetIP(), "", 5, "", db);
            ViewData["RoleList"] = DBCaches <Dic_Role> .getCache("cache_role");// db.Dic_Post.ToList();

            return(View(model));
        }