Esempio n. 1
0
        private string DoAction()
        {
            string result = "";

            BLL.CCOM.Role   bll = new BLL.CCOM.Role();
            Model.CCOM.Role model;
            if (action == MyEnums.ActionEnum.Add.ToString())
            {
                model = new Model.CCOM.Role();
            }
            else
            {
                model = bll.GetModel("Role_id=" + roleId);
            }
            string Name = this.txtName.Text.Trim();

            if (Tools.CheckParams(Name))
            {
                return("请勿输入非法字符");
            }

            if (Name == "")
            {
                return("请填写角色名");
            }
            model.Role_name   = Name;
            model.Role_status = true;
            try
            {
                if (action == MyEnums.ActionEnum.Edit.ToString()) //修改
                {
                    bll.Update(model);
                }
                else
                {
                    bll.Add(model);
                }
            }
            catch (Exception ex)
            {
                result = action == MyEnums.ActionEnum.Edit.ToString() ? "修改失败" : "添加失败" + ex.Message.ToString();
            }

            return(result);
        }
Esempio n. 2
0
        protected void lbtAble_Click(object sender, EventArgs e)
        {
            var bll = new BLL.CCOM.Role();

            var lbtn = sender as LinkButton;

            if (lbtn != null)
            {
                var  id     = Int64.Parse(DESEncrypt.Decrypt(lbtn.ToolTip.ToString()));
                bool isOn   = false;
                bool result = true;
                try
                {
                    var m = bll.GetModel("Role_id=" + id);
                    isOn          = m.Role_status == true;
                    m.Role_status = isOn ^ true;
                    if (bll.Update(m) == false)
                    {
                        result = false;
                    }
                }
                catch
                {
                    result = false;
                }
                string keywords = MyRequest.GetQueryString("keywords");
                int    page     = MyRequest.GetQueryInt("page", 1);
                if (result == true)
                {
                    JscriptMsg(isOn ? "禁用成功!" : "启用成功!", Utils.CombUrlTxt("RoleList.aspx", "fun_id={0}&keywords={1}&page={2}",
                                                                          DESEncrypt.Encrypt(this.fun_id), keywords, page.ToString()), "Success");
                }
                else
                {
                    JscriptMsg(isOn ? "禁用失败!" : "启用失败!", Utils.CombUrlTxt("RoleList.aspx", "fun_id={0}&keywords={1}&page={2}",
                                                                          DESEncrypt.Encrypt(this.fun_id), keywords, page.ToString()), "Error");
                }
                RptBind(CombSqlTxt(this.keywords), " Role_id desc ");
            }
        }