예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            B_Admin badmin = new B_Admin();

            badmin.CheckMulitLogin();
            if (!badmin.ChkPermissions("RoleEdit"))
            {
                function.WriteErrMsg("没有权限进行此项操作");
            }
            if (!Page.IsPostBack)
            {
                ViewState["RoleID"] = Request.QueryString["RoleID"];
                //判断当前管理员是否存在
                if (B_Admin.IsExist(DataConverter.CLng(ViewState["RoleID"])))
                {
                    this.LblTitle.Text = "修改角色";
                    this.Literal1.Text = "修改角色";
                    role = B_Role.GetRoleById(DataConverter.CLng(ViewState["RoleID"]));
                    this.txbRoleName.Text = role.RoleName;
                    this.tbRoleInfo.Text  = role.Description;
                }
                else
                {
                    this.LblTitle.Text = "添加角色";
                    this.Literal1.Text = "添加角色";
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 角色新增
        /// </summary>
        /// <param name="RoleCode"></param>
        /// <param name="RoleName"></param>
        /// <param name="RoleDescribe"></param>
        /// <returns></returns>
        public ActionResult InsertRole(string RoleCode, string RoleName, string RoleDescribe)
        {
            string strMsg = "fali";

            try
            {
                int oldRole = (from tbRole in myModels.B_Role
                               where
                               tbRole.RoleCode == RoleCode &&
                               tbRole.RoleName == RoleName &&
                               tbRole.RoleDescribe == RoleDescribe
                               select tbRole).Count();
                if (oldRole == 0)
                {
                    B_Role myRole = new B_Role();
                    myRole.RoleCode     = RoleCode;
                    myRole.RoleName     = RoleName;
                    myRole.RoleDescribe = RoleDescribe;
                    myModels.B_Role.Add(myRole);
                    if (myModels.SaveChanges() > 0)
                    {
                        strMsg = "success";
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(Json(strMsg, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public ContentResult RightsToConfig(int id, string[] idlist)
        {
            if (idlist == null || idlist.Length <= 0)
            {
                return(Content("分配角色权限失败,请选择要分配的权限!"));
            }
            List <int> rList = new List <int>();

            foreach (string sid in idlist)
            {
                int tid = 0;
                if (int.TryParse(sid, out tid))
                {
                    rList.Add(tid);
                }
            }
            if (B_Role.RelevanceRightsList(id, rList))
            {
                B_MenuRights.ClearHashMenuRights();
            }
            else
            {
                return(Content("分配角色权限失败!"));
            }
            return(Content("ok"));
        }
예제 #4
0
        public ActionResult B_RoleMin(int id)
        {
            B_Role dbBORoles = B_Role.GetEntityByID(id);

            if (dbBORoles == null)
            {
                return(View(ErrorPage.ViewName, new ErrorPage {
                    Message = "分配角色权限失败,角色不存在或已删除!"
                }));
            }

            List <B_UserDesktopAuth> roRightsList = B_UserDesktopAuth.GetEntitysMainRoleID(id, CurrentUser.UserName);
            HashSet <int>            setRights    = new HashSet <int>();

            foreach (B_UserDesktopAuth roRights in roRightsList)
            {
                setRights.Add(roRights.MainID);
            }

            ViewBag.MenuRights = B_UserDesktopAuth.GetRolesDesktopAuth(id);

            ViewBag.HashRights     = setRights;
            ViewBag.dbBORoles      = dbBORoles;
            ViewData["UserName"]   = CurrentUser.UserName;
            ViewData["C_UserName"] = WeConfig.robot;
            return(View());
        }
예제 #5
0
        /// <summary>
        /// 增加角色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        #region

        protected void Button2_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                switch (this.LblTitle.Text)
                {
                case ("添加角色"):
                    role.RoleName    = this.txbRoleName.Text;
                    role.Description = this.tbRoleInfo.Text;
                    if (B_Role.Add(role))
                    {
                        Response.Redirect("RoleManage.aspx");
                    }
                    else
                    {
                        function.WriteErrMsg("添加失败!");
                    }
                    break;

                case ("修改角色"):
                    role.RoleID      = DataConverter.CLng(ViewState["RoleID"]);
                    role.RoleName    = this.txbRoleName.Text;
                    role.Description = this.tbRoleInfo.Text;
                    if (B_Role.Update(role))
                    {
                        Response.Redirect("RoleManage.aspx");
                    }
                    else
                    {
                        function.WriteErrMsg("修改失败!");
                    }
                    break;
                }
            }
        }
예제 #6
0
        public void MyBind()
        {
            B_Role brole = new B_Role();

            ViewState["RoleList"] = brole.GetRoleAll();
            DataTable dt = new DataTable();

            if (RoleID == 0)
            {
                dt = badmin.Sel();
            }
            else
            {
                dt = badmin.SelByRole(RoleID);
            }
            EGV.Visible = (dt != null && dt.Rows.Count > 0);
            string strwhere = "1=1 ";

            if (!string.IsNullOrEmpty(SearchKey))
            {
                strwhere += "AND AdminName Like '%" + SearchKey + "%'";
            }
            if (IsLock > -1)
            {
                strwhere += "AND islock=" + IsLock;
            }
            dt.DefaultView.RowFilter = strwhere;
            EGV.DataSource           = dt;
            EGV.DataKeyNames         = new string[] { "AdminID" };
            EGV.DataBind();
        }
예제 #7
0
        private void myBind()
        {
            DataView dt = B_Role.GetRoleInfo();

            this.EGV.DataSource   = dt;//.FindRows(" AddUser="******"RoleID" };
            this.EGV.DataBind();
        }
예제 #8
0
        public ActionResult B_UserEdit(int id)
        {
            B_User        user  = B_User.GetEntityByID(id);
            List <B_Role> roles = B_Role.GetUserRoles(user.UserName);
            B_Role        role  = (roles != null && roles.Count > 0) ? roles[0] : null;

            user.RoleID = role == null ? 0 : role.ID;
            return(View(user));
        }
예제 #9
0
파일: AddWork.aspx.cs 프로젝트: zwt-zf/cms
    private void Bind()
    {
        DataTable dt = B_Role.GetRoleName();

        this.cblRoleList.DataSource     = dt;
        this.cblRoleList.DataTextField  = "RoleName";
        this.cblRoleList.DataValueField = "RoleId";
        this.cblRoleList.DataBind();
    }
예제 #10
0
        public ContentResult B_RoleToDel(int id)
        {
            int rtn = B_Role.DeleteByID(id);

            if (rtn > 0)
            {
                return(Content("ok"));
            }
            return(Content("删除出错"));
        }
예제 #11
0
        public ContentResult B_UserToAdd(B_User user)
        {
            if (string.IsNullOrWhiteSpace(user.UserName))
            {
                return(Content("用户名不能为空"));
            }
            string reg   = "^[\u4E00-\u9FA5A-Za-z0-9_]+$";
            Regex  regex = new Regex(reg, RegexOptions.None);

            if (regex.IsMatch(user.UserName) == false)
            {
                return(Content("用户名只能为中文、字母或数字"));
            }

            if (B_User.GetUserCountByUserName(user.UserName) > 0)
            {
                return(Content("该用户名已存在,请换一个吧"));
            }

            if (string.IsNullOrWhiteSpace(user.Name))
            {
                return(Content("姓名不能为空"));
            }

            bool IsValid = false;

            if (Request["IsValid"] != null)
            {
                if (Request["IsValid"].ToString() == "on")
                {
                    IsValid = true;
                }
            }

            user.IsValid = IsValid;
            user.DatAdd  = DateTime.Now;
            int rtn = user.InsertAndReturnIdentity();

            if (rtn > 0)
            {
                if (user.RoleID > 0)
                {
                    if (B_Role.EditUserRole(user.UserName, user.RoleID))
                    {
                        return(Content("ok"));
                    }
                    else
                    {
                        return(Content("角色保存出错"));
                    }
                }
                return(Content("ok"));
            }
            return(Content("添加出错"));
        }
예제 #12
0
        public void DataBind(string key = "")
        {
            DataTable dt = pubBll.SelByType(2);

            if (!badmin.GetAdminLogin().RoleList.Contains(",1,"))
            {
                GetTable(dt, B_Role.GetPowerInfoByIDs(badmin.GetAdminLogin().RoleList));
            }
            Egv.DataSource = dt;
            Egv.DataBind();
        }
        protected void MyBind(string key = "")
        {
            M_AdminInfo adminMod = B_Admin.GetLogin();
            DataTable   pubtable = pubBll.SelByType();

            if (!B_Admin.IsSuperManage(adminMod.AdminId))
            {
                GetTable(pubtable, B_Role.GetPowerInfoByIDs(adminMod.RoleList));
            }
            Egv.DataSource = pubtable;
            Egv.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (function.isAjax())
            {
                string action = Request.Form["action"];
                string result = "";
                switch (action)
                {
                case "checkname":
                    if (B_Role.IsExit(Request.Form["name"]))
                    {
                        result = "-1";
                    }
                    else
                    {
                        result = "1";
                    }
                    break;

                default:
                    break;
                }
                Response.Write(result); Response.Flush(); Response.End();
            }
            Call.SetBreadCrumb(Master, "<li><a href='" + CustomerPageAction.customPath2 + "Main.aspx'>工作台</a></li><li><a href='UserManage.aspx'>用户管理</a></li><li> <a href='AdminManage.aspx'>管理员管理</a></li><li><a href=\"RoleManage.aspx\">角色管理</a></li><li><asp:Literal Text='添加角色'>" + Literal1_Hid.Value + "</asp:Literal></li>");
            B_Admin badmin = new B_Admin();

            if (!B_ARoleAuth.Check(ZoomLa.Model.ZLEnum.Auth.user, "RoleEdit"))
            {
                function.WriteErrMsg("没有权限进行此项操作");
            }
            if (!Page.IsPostBack)
            {
                ViewState["RoleID"] = Request.QueryString["RoleID"];

                //判断当前角色是否存在
                if (B_Role.IsExit(DataConverter.CLng(ViewState["RoleID"])))
                {
                    this.LblTitle.Text      = "修改角色";
                    this.Literal1_Hid.Value = "修改角色";
                    role = B_Role.GetRoleById(DataConverter.CLng(ViewState["RoleID"]));
                    this.txbRoleName.Text  = role.RoleName;
                    this.tbRoleInfo.Text   = role.Description;
                    EditRoleName_Hid.Value = role.RoleName;
                }
                else
                {
                    this.LblTitle.Text      = "添加角色";
                    this.Literal1_Hid.Value = "添加角色";
                }
            }
        }
예제 #15
0
        public ContentResult ToSetUserDesktop(string DesktopIDSet)
        {
            if (B_Role.SetUserDesktopAuth(CurrentUser.RoleID, CurrentUser.UserName, DesktopIDSet))
            {
                B_MenuRights.ClearHashMenuRights();
            }
            else
            {
                return(Content("分配角色权限失败!"));
            }

            return(Content("ok"));
        }
예제 #16
0
        private void Bind()
        {
            DataTable dt = B_Role.GetRoleName();

            cblRoleList.DataSource     = dt;
            cblRoleList.DataTextField  = "RoleName";
            cblRoleList.DataValueField = "RoleId";
            cblRoleList.DataBind();
            if (dt != null)
            {
                dt.Dispose();
            }
        }
예제 #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        function.AccessRulo();
        B_Admin badmin = new B_Admin();

        badmin.CheckIsLogin();
        if (!this.Page.IsPostBack)
        {
            string Pubid = string.IsNullOrEmpty(Request.QueryString["Pubid"].ToString()) ? "0" : Request.QueryString["Pubid"].ToString();
            pubMod = pubBll.SelReturnModel(DataConverter.CLng(Pubid));
            string prowinfo = B_Role.GetPowerInfoByIDs(badmin.GetAdminLogin().RoleList);
            if (!badmin.GetAdminLogin().RoleList.Contains(",1,") && !prowinfo.Contains("," + pubMod.PubTableName + ","))
            {
                function.WriteErrMsg("无权限管理该互动模型!!");
            }
            string ModelID = bpub.GetSelect(DataConverter.CLng(Pubid)).PubModelID.ToString();
            //  int ModelID = string.IsNullOrEmpty(Request.QueryString["ModelID"]) ? 0 : DataConverter.CLng(Request.QueryString["ModelID"]);
            this.HiddenPubid.Value = Pubid;
            if (DataConverter.CLng(ModelID) <= 0)
            {
                function.WriteErrMsg("缺少用户模型ID参数!");
            }
            //jc:查找相应模版实体
            //    M_ModelInfo model = bmodel.GetModelById(ModelID);
            string small = string.IsNullOrEmpty(Request.QueryString["small"]) ? "0" : Request.QueryString["small"].ToString();
            this.HiddenSmall.Value = small;
            this.HdnModelID.Value  = ModelID;
            M_ModelInfo model = bmodel.GetModelById(DataConverter.CLng(ModelID));
            int         ID    = string.IsNullOrEmpty(Request.QueryString["ID"]) ? 0 : DataConverter.CLng(Request.QueryString["ID"]);
            this.HiddenID.Value = ID.ToString();
            ViewState["ID"]     = ID.ToString();
            if (ID < 0)
            {
                function.WriteErrMsg("缺少ID参数!");
            }


            DataTable UserData = new DataTable();
            DataTable aas      = ShowGrid();
            int       zong     = aas.Rows.Count;


            UserData = buser.GetUserModeInfo(model.TableName, ID, 18);

            this.ptit.Text = UserData.Rows[0]["PubTitle"].ToString();

            DetailsView1.DataSource = UserData.DefaultView;
            DetailsView1.DataBind();
            Call.SetBreadCrumb(Master, "<li><a href='" + CustomerPageAction.customPath2 + "I/Main.aspx'>工作台</a></li><li><a href='pubmanage.aspx'>互动管理</a></li> <li><a href='Pubsinfo.aspx?Pubid=" + Pubid + "&type=0'>互动信息管理</a></li><li>互动信息</li>");
        }
    }
        /// <summary>
        /// 验证角色名称是否已经存在
        /// </summary>
        /// <param name="source"></param>
        /// <param name="args"></param>
        #region

        protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
        {
            string roleName = this.txbRoleName.Text;

            if (B_Role.IsExit(roleName))
            {
                this.cvRole.Visible   = true;
                args.IsValid          = false;
                this.txbRoleName.Text = "sdfsdf";
            }
            else
            {
                args.IsValid = true;
            }
        }
예제 #19
0
 //string[] powerList = string.Empty;
 //StringBuilder sb = new StringBuilder();
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         B_Admin badmin = new B_Admin();
         badmin.CheckMulitLogin();
         ViewState["roleid"] = Request.QueryString["id"];
         //默认显示该角色信息
         M_RoleInfo role = B_Role.GetRoleById(DataConverter.CLng(ViewState["roleid"]));
         this.LblRoleName.Text    = role.RoleName;
         this.LblDescription.Text = role.Description;
         //填充该角色所具有的权限
         string Power   = "";
         string RoleStr = B_Role.GetPowerInfo(role.RoleID);
         for (int t = 0; t < this.CheckBoxList1.Items.Count; t++)
         {
             Power = this.CheckBoxList1.Items[t].Value;
             if (RoleStr.IndexOf(Power) >= 0)
             {
                 this.CheckBoxList1.Items[t].Selected = true;
             }
         }
         for (int y = 0; y < this.CheckBoxList2.Items.Count; y++)
         {
             Power = this.CheckBoxList2.Items[y].Value;
             if (RoleStr.IndexOf(Power) >= 0)
             {
                 this.CheckBoxList2.Items[y].Selected = true;
             }
         }
         for (int x = 0; x < this.CheckBoxList3.Items.Count; x++)
         {
             Power = this.CheckBoxList3.Items[x].Value;
             if (RoleStr.IndexOf(Power) >= 0)
             {
                 this.CheckBoxList3.Items[x].Selected = true;
             }
         }
         for (int s = 0; s < this.CheckBoxList4.Items.Count; s++)
         {
             Power = this.CheckBoxList4.Items[s].Value;
             if (RoleStr.IndexOf(Power) >= 0)
             {
                 this.CheckBoxList4.Items[s].Selected = true;
             }
         }
     }
 }
예제 #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ZoomLa.Common.function.AccessRulo();
            B_Admin badmin = new B_Admin();

            if (!this.Page.IsPostBack)
            {
                string Pubid = string.IsNullOrEmpty(Request.QueryString["Pubid"]) ? "0" : Request.QueryString["Pubid"].ToString();
                pubMod = bpub.SelReturnModel(DataConverter.CLng(Pubid));
                string prowinfo = B_Role.GetPowerInfoByIDs(badmin.GetAdminLogin().RoleList);
                if (!badmin.GetAdminLogin().RoleList.Contains(",1,") && !prowinfo.Contains("," + pubMod.PubTableName + ","))
                {
                    function.WriteErrMsg("无权限管理该互动信息!!");
                }
                string Parentid = string.IsNullOrEmpty(Request.QueryString["Parentid"]) ? "0" : Request.QueryString["Parentid"].ToString();
                int    ModelID  = DataConverter.CLng(bpub.GetSelect(DataConverter.CLng(Pubid)).PubModelID.ToString());
                this.HdnType.Value = string.IsNullOrEmpty(Request.QueryString["small"]) ? null : Request.QueryString["small"].ToString();
                if (DataConverter.CLng(Pubid) <= 0 || DataConverter.CLng(Parentid) <= 0)
                {
                    function.WriteErrMsg("缺少用户参数!");
                }
                //jc:查找相应模版实体
                M_ModelInfo model = bmodel.GetModelById(ModelID);
                this.HdnPubid.Value       = Pubid;
                this.HiddenParentid.Value = Parentid;
                this.HdnModel.Value       = ModelID.ToString();
                int ID = string.IsNullOrEmpty(Request.QueryString["ID"]) ? 0 : DataConverter.CLng(Request.QueryString["ID"]);
                this.HdnID.Value       = ID.ToString();
                this.LblModelName.Text = "回复" + model.ItemName;
                string Html = bfield.InputallHtml(ModelID, 0, new ModelConfig());
                //GetPubModelHtmlall
                ModelHtml.Text = Html;



                ///////////
                DataTable UserData = new DataTable();
                DataTable aas      = ShowGrid();

                int zong = aas == null ? 0 : aas.Rows.Count;
                int sID  = string.IsNullOrEmpty(Request.QueryString["Parentid"]) ? 0 : DataConverter.CLng(Request.QueryString["Parentid"]);
                UserData = buser.GetUserModeInfo(model.TableName, sID, 18);
                DetailsView1.DataSource = UserData.DefaultView;
                DetailsView1.DataBind();
                //////////////
                Call.SetBreadCrumb(Master, "<li><a href='" + CustomerPageAction.customPath2 + "I/Main.aspx'>工作台</a></li><li><a href='pubmanage.aspx'>互动管理</a></li><li>添加信息</li>");
            }
        }
예제 #21
0
 protected void LnkModify_Click(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "ModifyRole")
     {
         Page.Response.Redirect("AddRole.aspx?RoleID=" + e.CommandArgument.ToString());
     }
     if (e.CommandName == "Del")
     {
         B_Role.DelRoleByID(DataConverter.CLng(e.CommandArgument.ToString()));
         bind();
     }
     if (e.CommandName == "ModifyPower")
     {
         Page.Response.Redirect("RoleManager.aspx?id=" + e.CommandArgument.ToString());
     }
 }
예제 #22
0
        protected string GetRole(string structid)
        {
            string[]  str   = structid.Split(new Char[] { ',' });
            string    strs  = "";
            B_Role    brole = new B_Role();
            DataTable dt    = new DataTable();

            for (int i = 0; i < str.Length; i++)
            {
                dt = brole.Sel(DataConverter.CLng(str[i]));
                if (dt.Rows.Count > 0)
                {
                    strs += dt.Rows[0]["RoleName"] + " ";
                }
            }
            return(strs);
        }
예제 #23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            function.AccessRulo();
            B_Admin badmin = new B_Admin();

            if (!this.IsPostBack)
            {
                int pubid = DataConverter.CLng(Request.QueryString["Pubid"]);
                ViewState["pubid"] = pubid.ToString();
                M_Pub  pubinfo  = pub.GetSelect(pubid);
                string prowinfo = B_Role.GetPowerInfoByIDs(badmin.GetAdminLogin().RoleList);
                if (!badmin.GetAdminLogin().RoleList.Contains(",1,") && !prowinfo.Contains("," + pubinfo.PubTableName + ","))
                {
                    function.WriteErrMsg("无权限管理该互动模型!!");
                }
                string ModelID = (pubinfo.PubModelID == 0) ? "0" : pubinfo.PubModelID.ToString();
                if (DataConverter.CLng(ModelID) <= 0)
                {
                    function.WriteErrMsg("无模块信息");
                }
                int ID = string.IsNullOrEmpty(Request.QueryString["ID"]) ? 0 : DataConverter.CLng(Request.QueryString["ID"]);
                this.HdnID.Value = ID.ToString();
                string      type  = (Request.QueryString["type"] == null) ? "0" : Request.QueryString["type"].ToString();
                M_ModelInfo model = bmodel.GetModelById(DataConverter.CLng(ModelID));
                this.HdnModelID.Value     = ModelID.ToString();
                this.HiddenType.Value     = type;
                this.HiddenPubid.Value    = pubid.ToString();
                this.ViewState["ModelID"] = ModelID.ToString();
                this.ViewState["cType"]   = "1";
                RepNodeBind();
                int nodeid = (Request.QueryString["nodeid"] == null) ? 0 : DataConverter.CLng(Request.QueryString["nodeid"]);
                this.HiddenNode.Value = "";
                if (nodeid == 0)
                {
                    Call.SetBreadCrumb(Master, "<li><a href='" + CustomerPageAction.customPath2 + "I/Main.aspx'>工作台</a></li><li><a href='pubmanage.aspx'>互动管理</a></li><li><a href='AddPub.aspx?Parentid=" + this.HdnID.Value + "&Pubid=" + this.HiddenPubid.Value + "' style='color:red;'>[添加回复]</a></li>");
                }
                else
                {
                    B_Node bbn = new B_Node();
                    M_Node nn  = bbn.GetNodeXML(nodeid);
                    Call.SetBreadCrumb(Master, "<li><a href='" + CustomerPageAction.customPath2 + "I/Main.aspx'>工作台</a></li><li><a href='pubmanage.aspx'>互动管理</a></li><li><a href='Pubsinfo.aspx?nodeid=" + nodeid + "&Pubid=" + this.HiddenPubid.Value + "' style='color:red;'>" + nn.NodeName + "</a></li>");
                    this.HiddenNode.Value = "&nodeid=" + nodeid;
                }
                //this.Label1.Text = "<a href='AddPub.aspx?Parentid=" + this.HdnID.Value + "&Pubid=" + this.HiddenPubid.Value + "'>[&nbsp;&nbsp;&nbsp;添加回复&nbsp;&nbsp;]</a>";
            }
        }
예제 #24
0
        public ContentResult B_UserToDel(int id)
        {
            B_User user = B_User.GetEntityByID(id);

            if (CurrentUser.UserName == user.UserName)
            {
                return(Content("不能删除当前登录用户"));
            }
            int rtn = B_User.DeleteByID(id);

            if (rtn > 0)
            {
                B_Role.DelUserRoleByUserName(user.UserName);
                return(Content("ok"));
            }
            return(Content("删除出错"));
        }
예제 #25
0
        public ContentResult B_UserToEdit(B_User user)
        {
            if (string.IsNullOrWhiteSpace(user.Name))
            {
                return(Content("姓名不能为空"));
            }
            if (user.UserName == user.PassWord)
            {
                return(Content("账号密码不能一致"));
            }
            if (user.PassWord.Length < 6)
            {
                return(Content("密码必须在6位以上"));
            }
            bool IsValid = false;

            if (Request["IsValid"] != null)
            {
                string IsStr = Request["IsValid"].ToString();
                if (IsStr == "on")
                {
                    IsValid = true;
                }
            }
            user.IsValid = IsValid;
            B_User oldUser = B_User.GetEntityByID(user.ID);
            int    rtn     = user.UserEditByID();

            if (rtn > 0)
            {
                if (user.RoleID > 0)
                {
                    if (B_Role.EditUserRole(oldUser.UserName, user.RoleID))
                    {
                        return(Content("ok"));
                    }
                    else
                    {
                        return(Content("角色保存出错"));
                    }
                }
                return(Content("ok"));
            }
            return(Content("保存出错"));
        }
예제 #26
0
        public ContentResult B_RoleToAdd(B_Role role)
        {
            if (string.IsNullOrWhiteSpace(role.RoleName))
            {
                return(Content("角色名不能为空"));
            }
            if (RepeatHelper.NoRepeat("B_Role", "RoleName", role.RoleName, role.ID) > 0)
            {
                return(Content("角色名已存在"));
            }
            int rtn = role.InsertAndReturnIdentity();

            if (rtn > 0)
            {
                return(Content("ok"));
            }
            return(Content("添加出错"));
        }
예제 #27
0
        public ContentResult B_RoleToEdit(B_Role role)
        {
            if (string.IsNullOrWhiteSpace(role.RoleName))
            {
                return(Content("角色名不能为空"));
            }
            if (RepeatHelper.NoRepeat("B_Role", "RoleName", role.RoleName, role.ID) > 0)
            {
                return(Content("角色名已存在"));
            }
            int rtn = role.UpdateByID();

            if (rtn > 0)
            {
                return(Content("ok"));
            }
            return(Content("保存出错"));
        }
예제 #28
0
        /// <summary>
        /// 角色删除
        /// </summary>
        /// <param name="RoleID"></param>
        /// <returns></returns>
        public ActionResult DeleteRole(int RoleID)
        {
            string strMsg = "fail";

            try
            {
                B_Role dbRole = (from tbRole in myModels.B_Role
                                 where tbRole.RoleID == RoleID
                                 select tbRole).Single();
                myModels.B_Role.Remove(dbRole);
                myModels.SaveChanges();
                strMsg = "success";
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(Json(strMsg, JsonRequestBehavior.AllowGet));
        }
예제 #29
0
 protected void EGV_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "ModifyRole")
     {
         Page.Response.Redirect("AddRole.aspx?RoleID=" + e.CommandArgument.ToString());
     }
     if (e.CommandName == "Del")
     {
         B_Role.DelRoleByID(DataConverter.CLng(e.CommandArgument.ToString()));
         myBind();
     }
     if (e.CommandName == "ModifyPower")
     {
         Page.Response.Redirect("RoleAuthList.aspx?id=" + e.CommandArgument.ToString());
     }
     if (e.CommandName == "ListRolelist")
     {
         Page.Response.Redirect("AdminManage.aspx?id=" + e.CommandArgument.ToString());
     }
 }
예제 #30
0
        //
        // GET: /Home/

        public ActionResult Index(string url)
        {
            try
            {
                BaseAuthorizeModel auth = BaseAuthorizeHelper.GetAuthorizeModel(this.HttpContext);
                if (string.IsNullOrWhiteSpace(auth.TempDataMsg) == false)
                {
                    TempData["Msg"] = auth.TempDataMsg;
                }
                if (auth.IsAuthorize == false)
                {
                    string userAgent = Request.UserAgent;
                    return(RedirectToAction("Login", "Home", new { url = Request.Url.ToString() }));
                }
                B_User        user  = auth.CurrentSYSUser;
                List <B_Menu> menus = B_Menu.GetShowMenus();

                if (user.UserName != WeConfig.robot)
                {
                    menus.RemoveAll(m => m.IsRobot);
                }

                List <B_Role>       roles     = B_Role.GetUserRoles(user.UserName);
                List <B_MenuRights> rolerignt = B_MenuRights.GetRoleUser(roles[0].ID);
                ViewData["role"]     = (roles != null && roles.Count > 0) ? roles[0] : null;
                ViewData["menus"]    = menus;
                ViewData["url"]      = url;
                ViewData["UserRole"] = rolerignt;

                return(View(user));
            }
            catch (Exception ex)
            {
                DAL.Log.Instance.Write(ex.ToString());
                return(View(ErrorPage.ViewName, new ErrorPage {
                    Message = ex.ToString()
                }));
            }
        }