コード例 #1
0
 /// <summary>
 /// 判断管理员是否已经登录(解决Session超时问题)
 /// </summary>
 public bool IsAdminLogin()
 {
     //如果Session为Null
     if (Session["AdminNo"] != null && Session["AdminName"] != null && Session["AdminLevel"] != null && Session["AdminType"] != null)
     {
         return(true);
     }
     else
     {
         //检查Cookies
         string adminname = Utils.GetCookie("AdminName", "DtCms"); //解密用户名
         string adminpwd  = Utils.GetCookie("AdminPwd", "DtCms");
         if (adminname != "" && adminpwd != "")
         {
             adminname = DESEncrypt.Decrypt(adminname); //解密用户名
             DtCms.BLL.Administrator bll = new DtCms.BLL.Administrator();
             if (bll.chkAdminLogin(adminname, adminpwd))
             {
                 DtCms.Model.Administrator model = new DtCms.Model.Administrator();
                 model = bll.GetModel(adminname);
                 Session["AdminNo"]    = model.Id;
                 Session["AdminName"]  = model.UserName;
                 Session["AdminType"]  = model.UserType;
                 Session["AdminLevel"] = model.UserLevel;
                 return(true);
             }
         }
     }
     return(false);
 }
コード例 #2
0
 //赋值操作
 private void ShowInfo(int editID)
 {
     DtCms.BLL.Administrator   bll   = new DtCms.BLL.Administrator();
     DtCms.Model.Administrator model = new DtCms.Model.Administrator();
     model            = bll.GetModel(editID);
     txtUserName.Text = model.UserName;
     if (model.IsLock == 1)
     {
         this.rblIsLock.Items[1].Selected = true;
     }
     else
     {
         this.rblIsLock.Items[0].Selected = true;
     }
     txtReadName.Text  = model.ReadName;
     txtUserEmail.Text = model.UserEmail;
     this.strLevel     = model.UserLevel;
     this.strType      = model.UserType;
     if (model.UserType == 1)
     {
         this.rblUserType.Items[0].Selected = true;
     }
     if (model.UserType == 2)
     {
         this.rblUserType.Items[1].Selected = true;
     }
     if (model.UserType == 3)
     {
         this.rblUserType.Items[2].Selected = true;
     }
 }
コード例 #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DtCms.BLL.Administrator   bll   = new DtCms.BLL.Administrator();
            DtCms.Model.Administrator model = bll.GetModel(this.Id);

            string UserPwd   = txtUserPwd.Text.Trim();
            string UserLevel = string.Empty;
            int    UserType  = Convert.ToInt32(rblUserType.SelectedValue);

            if (UserType > 1)
            {
                UserLevel = "," + Request.Form["cbLevel"].Trim() + ",";
            }
            if (UserPwd != null && UserPwd != "")
            {
                model.UserPwd = DtCms.Common.DESEncrypt.Encrypt(UserPwd);
            }
            model.ReadName  = txtReadName.Text.Trim();
            model.UserEmail = txtUserEmail.Text.Trim();
            model.UserType  = UserType;
            model.IsLock    = Convert.ToInt32(rblIsLock.SelectedValue);
            model.UserLevel = UserLevel;

            bll.Update(model);
            //保存日志
            SaveLogs("[管理员管理]编辑管理员:" + model.UserName);
            JscriptPrint("管理员修改成功啦!", "List.aspx", "Success");
        }
コード例 #4
0
        protected void loginsubmit_Click(object sender, ImageClickEventArgs e)
        {
            string UserName = txtUserName.Text.Trim();
            string UserPwd  = txtUserPwd.Text.Trim();

            if (UserName.Equals("") || UserPwd.Equals(""))
            {
                lbMsg.Text = "请输入您要登录用户名或密码";
            }
            else
            {
                if (Session["AdminLoginSun"] == null)
                {
                    Session["AdminLoginSun"] = 1;
                }
                else
                {
                    Session["AdminLoginSun"] = Convert.ToInt32(Session["AdminLoginSun"]) + 1;
                }
                //判断登录
                if (Session["AdminLoginSun"] != null && Convert.ToInt32(Session["AdminLoginSun"]) > 3)
                {
                    lbMsg.Text = "登录错误超过3次,请关闭浏览器重新登录。";
                }
                else if (bll.chkAdminLogin(UserName, DESEncrypt.Encrypt(UserPwd)))
                {
                    DtCms.Model.Administrator model = new DtCms.Model.Administrator();
                    model = bll.GetModel(UserName);
                    Session["AdminNo"]    = model.Id;
                    Session["AdminName"]  = model.UserName;
                    Session["AdminType"]  = model.UserType;
                    Session["AdminLevel"] = model.UserLevel;
                    //设置超时时间
                    Session.Timeout          = 45;
                    Session["AdminLoginSun"] = null;
                    //写入Cookies
                    Utils.WriteCookie("AdminName", "DtCms", DESEncrypt.Encrypt(model.UserName));
                    Utils.WriteCookie("AdminPwd", "DtCms", model.UserPwd);
                    //保存日志
                    new DtCms.Web.UI.ManagePage().SaveLogs(UserName, "[用户登录]状态:登录成功!");

                    Response.Redirect("admin_index.aspx");
                }
                else
                {
                    lbMsg.Text = "您输入的用户名或密码不正确";
                    //保存日志
                    new DtCms.Web.UI.ManagePage().SaveLogs(UserName, "[用户登录] 状态:登录失败!");
                }
            }
        }
コード例 #5
0
 //批量删除
 protected void lbtnDel_Click(object sender, EventArgs e)
 {
     chkLoginLevel("delManage");
     DtCms.BLL.Administrator bll = new DtCms.BLL.Administrator();
     for (int i = 0; i < rptList.Items.Count; i++)
     {
         int      id = Convert.ToInt32(((Label)rptList.Items[i].FindControl("lb_id")).Text);
         CheckBox cb = (CheckBox)rptList.Items[i].FindControl("cb_id");
         if (cb.Checked)
         {
             //保存日志
             SaveLogs("[管理员管理]删除管理员:" + bll.GetModel(id).UserName);
             //删除记录
             bll.Delete(id);
         }
     }
     JscriptPrint("批量删除成功啦!", "", "Success");
     RptBind("");
 }