Exemple #1
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);
        }
Exemple #2
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));
        }
Exemple #3
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));
        }
Exemple #4
0
        public static List <SelectOption> ContentSelect()
        {
            List <Dic_Reimbursement_Content> contents = DBCaches <Dic_Reimbursement_Content> .getCache(cache_content);

            List <SelectOption> option = (from content in contents
                                          select new SelectOption
            {
                id = content.content_id.ToString(),
                text = content.content_title
            }).ToList();

            return(option);
        }
Exemple #5
0
        public static List <SelectOption> RespondStateSelect()
        {
            List <Dic_Respond_State> depts = DBCaches <Dic_Respond_State> .getCache(respond_state);

            List <SelectOption> option = (from ct in depts
                                          select new SelectOption
            {
                id = ct.drs_state_id.ToString(),
                text = ct.drs_state_name
            }).ToList();

            return(option);
        }
Exemple #6
0
        public static List <SelectOption> ProcessSelect()
        {
            List <Process_Info> funds = DBCaches <Process_Info> .getCache(cache_process);

            List <SelectOption> option = (from fund in funds
                                          select new SelectOption
            {
                id = fund.process_id.ToString(),
                text = fund.process_name
            }).ToList();

            return(option);
        }
Exemple #7
0
        public static List <SelectOption> CardTypeSelect()
        {
            List <Dic_CardType> depts = DBCaches <Dic_CardType> .getCache(cache_cardType);

            List <SelectOption> option = (from ct in depts
                                          select new SelectOption
            {
                id = ct.ctype_name,
                text = ct.ctype_name
            }).ToList();

            return(option);
        }
Exemple #8
0
        public static List <SelectOption> RoleSelect(string ignor)
        {
            List <Dic_Role> depts = DBCaches <Dic_Role> .getCache(cache_role);

            List <SelectOption> option = (from ct in depts
                                          where ct.role_name != ignor
                                          select new SelectOption
            {
                id = ct.role_id.ToString(),
                text = ct.role_name
            }).ToList();

            return(option);
        }
Exemple #9
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()));
        }
Exemple #10
0
        public static List <SelectOption> PostSelect()
        {
            List <SelectOption> options = new List <SelectOption>();
            var post = DBCaches <Dic_Post> .getCache(cache_post);

            if (post != null)
            {
                foreach (var item in post)
                {
                    options.Add(new SelectOption {
                        text = item.post_name, id = item.post_id.ToString()
                    });
                }
            }
            return(options);
        }
Exemple #11
0
        public static List <AuthInfo> AuthoritySelect()
        {
            List <Sys_Authority> funds = DBCaches <Sys_Authority> .getCache(cache_authority);

            List <AuthInfo> option = (from auth in funds
                                      select new AuthInfo
            {
                authId = auth.auth_id,
                authInfo = auth.auth_info,
                authName = auth.auth_name,
                isController = auth.auth_is_Controller,
                mapController = auth.auth_map_Controller
            }).ToList();

            return(option);
        }
Exemple #12
0
        public static RoleInfo[] getRoleInfo()
        {
            object roles = DBCaches <Dic_Role> .getCache(cache_role);

            if (roles == null)
            {
                return(null);
            }
            var list_roles = (List <Dic_Role>)roles;
            var list       = (from role in list_roles
                              select new RoleInfo
            {
                id = role.role_id,
                name = role.role_name
            }).ToArray();

            return(list);
        }
Exemple #13
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));
        }
Exemple #14
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));
        }