Exemple #1
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnDel_Click(object sender, EventArgs e)
        {
            string dlist = ControlTools.CheckCbx(GVData, "CheckSelect", "LabVisible");

            if (_systemRolesBll.GetModel(int.Parse(dlist)) == null)
            {
                Alert("该项已经不存在"); return;
            }
            string[] listid = dlist.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            int      id     = 0;

            if (listid.Length > 0)
            {
                for (int i = 0; i < listid.Length; i++)
                {
                    if (new Haikan.SchoolProjectsCore.MDB.BLL.SystemUser().GetList("RoleID=" + listid[i]).Tables[0].Rows.Count > 0)
                    {
                        id += 1;
                    }
                }
            }
            if (id <= 0)
            {
                _systemRolesBll.DeleteList(dlist);
                Bind();
            }
            else
            {
                Alert("所选部门中有存在用户的部门,不能删除,请重新选择!");
            }
        }
Exemple #2
0
        /// <summary>
        /// 页面加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                return;
            }

            // 修改
            if (Request.QueryString["ID"] != null)
            {
                var id = Convert.ToInt32(Request.QueryString["ID"]);
                if (id <= 0)
                {
                    return;
                }

                // 获取数据
                _systemRolesModel = _systemRolesBll.GetModel(id);
                if (_systemRolesModel == null)
                {
                    return;
                }

                tbRoleName.Text    = _systemRolesModel.RoleName; // 角色名称
                tbRoleName.Enabled = false;                      // 如果是修改,禁止编辑角色名称
                tbRemarks.Text     = _systemRolesModel.Remarks;  // 备注信息

                // 绑定数据
                Bind();

                // 对控件进行赋值
                foreach (Control item in MyMenus.Items)
                {
                    var checklist = item.FindControl("MyCheckBoxList") as CheckBoxList;
                    ControlTools.GetCheckList(checklist, _systemRolesModel.Actionstr);
                }
            }
            else // 添加
            {
                Bind();
            }
        }
        /// <summary>
        /// 点击登陆
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            // 先判断验证码
            _systemSetModel = _systemSetBll.GetModel(_systemSetBll.GetMaxId());
            // 判断是否需要验证码
            if (_systemSetModel.IsIdentifyingCode.ToString() == "0")
            {
                if (Session["yzm"] != null && !string.Equals(Session["yzm"].ToString(), TxtYZM.Text, StringComparison.CurrentCultureIgnoreCase))
                {
                    Alert("验证码错误");
                    return;
                }
            }

            // sql注入风险检查
            if (SystemPage.SqlFilter(TxtUserName.Text.Trim()) || SystemPage.SqlFilter(TxtUserPwd.Text.Trim()))
            {
                Alert("帐号错误,请注意非法字符!");
                return;
            }

            // 密码可能是原文或者md5加密后的
            var strWhere = "UserName = '******' and (UserPWD = '" + DesEncrypt.GetMd5String(TxtUserPwd.Text.Trim()) + "' or UserPWD = '" + TxtUserPwd.Text.Trim() + "')";

            var d = _systemUserBll.GetList(" UserName='******'");

            if (d.Tables[0].Rows.Count > 0)
            {
                // 检测是否非法登录3次
                var verify = _illegalityLogin.PwdIsCorrect(TxtUserName.Text.Trim(), 3, TxtUserPwd.Text.Trim());

                if (verify == "成功")
                {
                    // 获取该用户的相关信息
                    var ds = _systemUserBll.GetModelList(strWhere);

                    if (ds.Count <= 0)
                    {
                        Alert("对不起,没有找到对应的用户!");
                        return;
                    }

                    _systemUserModel = ds[0];
                    if (_systemUserModel == null)
                    {
                        Alert("对不起,没有找到对应的用户!");
                        return;
                    }

                    if (_systemUserModel.IsEnter == 1)
                    {
                        Alert("对不起,您已被禁止登录!");
                        return;
                    }

                    // 获取角色和权限
                    var roleId = Convert.ToInt32(_systemUserModel.RoleID);
                    _systemRolesModel = _systemRolesBll.GetModel(roleId);
                    if (_systemRolesModel != null)
                    {
                        Session["roleId"]    = _systemUserModel.RoleID;
                        Session["RoleName"]  = _systemRolesModel.RoleName;
                        Session["ActionStr"] = _systemRolesModel.Actionstr;
                    }

                    // 个人信息
                    Session["userid"]             = _systemUserModel.ID;
                    Session["TrueName"]           = _systemUserModel.TrueName;
                    Session["username"]           = TxtUserName.Text.Trim();
                    Session["Department"]         = _systemUserModel.DepartmentID;
                    Session["BirthDay"]           = _systemUserModel.BirthDay;
                    Session["IdentityCard"]       = _systemUserModel.SFZSerils;          //身份证号码
                    Session["Sex"]                = _systemUserModel.Sex;
                    Session["JiaRuBenDanWeiTime"] = _systemUserModel.JiaRuBenDanWeiTime; // 入职时间
                    Session["TelephoneNumber"]    = _systemUserModel.TelphoneNumber;     // 联系电话

                    // 判断是否选择了记住密码
                    if (chkRemembered.Checked)
                    {
                        var cookie = new HttpCookie("RememberPWD");
                        cookie.Values.Add("Name", TxtUserName.Text.Trim());

                        // 如果长度大于20,可以判定为md5加密后的密码,直接保存即可,否则需要加密后保存
                        cookie.Values.Add("UserPwd",
                                          TxtUserPwd.Text.Trim().Length > 20
                                ? TxtUserPwd.Text.Trim()
                                : DesEncrypt.GetMd5String(TxtUserPwd.Text.Trim()));

                        cookie.Expires = DateTime.Now.AddDays(60.0);// 有效期2个月
                        HttpContext.Current.Response.Cookies.Add(cookie);
                    }

                    // 左侧菜单,保存到cookies中
                    var menuStr = BindStr();
                    if (menuStr != "")
                    {
                        DataCache.SetCache("HaikanSchoolProjects-" + Session["userid"], menuStr);
                    }

                    // 跳转到主界面
                    Response.Redirect("/General/Main.aspx");
                }
                else
                {
                    Alert(verify);
                }
            }
            else
            {
                Alert("不存在该用户");
            }
        }