Ejemplo n.º 1
0
 /// <summary>
 /// 判断管理员是否已经登录(解决Session超时问题)
 /// </summary>
 public bool IsAdminLogin()
 {
     //如果Session为Null
     if (Session["adminname"] != null)
     {
         return(true);
     }
     else
     {
         //检查Cookies
         HttpCookie cookie    = System.Web.HttpContext.Current.Request.Cookies["admin"];
         string     adminname = (string)cookie.Values["adminname"];
         string     adminpwd  = (string)cookie.Values["adminPwd"];
         if (adminname != "" && adminpwd != "")
         {
             Cms.BLL.C_admin   bll   = new Cms.BLL.C_admin();
             Cms.Model.C_admin model = bll.GetModel(adminname, adminpwd);
             if (model != null)
             {
                 Session["adminname"] = model;
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
 public static Cms.Model.C_admin GetLoginState(string id)
 {
     Cms.Model.C_admin model = null;
     if (id == null || id.Length <= 0)
     {
         WebHint.ShowError("登录超时,请重新登录", "/admin/login.aspx", true, "Error");
     }
     else
     {
         model = new Cms.BLL.C_admin().GetModel(Convert.ToInt32(id));
     }
     return(model);
 }
Ejemplo n.º 3
0
    private bool DataUpdate(int _id)
    {
        Cms.BLL.C_admin   bll   = new Cms.BLL.C_admin();
        Cms.Model.C_admin model = new Cms.Model.C_admin();
        model.id        = _id;
        model.role_id   = int.Parse(ddlRoleId.SelectedValue);
        model.role_type = new Cms.BLL.C_admin_role().GetModel(model.role_id).role_type;
        if (cbIsLock.Checked == true)
        {
            model.is_lock = 0;
        }
        else
        {
            model.is_lock = 1;
        }
        ////检测用户名是否重复
        //if (bll.Exists(txtUserName.Text.Trim()))
        //{
        //    return false;
        //}
        model.user_name = txtUserName.Text.Trim();

        model.password  = txtPassword.Text.Trim();
        model.real_name = txtRealName.Text.Trim();
        model.telephone = txtTelephone.Text.Trim();
        model.email     = txtEmail.Text.Trim();
        model.add_time  = DateTime.Now;

        if (bll.Update(model))
        {
            adminUser.AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), model.user_name); //记录日志

            JscriptMsg("修改信息成功!", "manager_list.aspx", "Success");
            return(true);
        }
        else
        {
            JscriptMsg("修改信息失败!", "manager_edit.aspx?action=add", "Error");
            return(false);
        }
    }
Ejemplo n.º 4
0
    public void bind_date(int _id)
    {
        Cms.BLL.C_admin   bll   = new Cms.BLL.C_admin();
        Cms.Model.C_admin model = bll.GetModel(_id);
        ddlRoleId.SelectedValue = model.role_id.ToString();
        if (model.is_lock == 0)
        {
            cbIsLock.Checked = true;
        }
        else
        {
            cbIsLock.Checked = false;
        }
        txtUserName.Text = model.user_name;

        txtUserName.Attributes.Remove("ajaxurl");

        txtPassword.Text  = model.password;
        txtPassword1.Text = model.password;
        txtRealName.Text  = model.real_name;
        txtTelephone.Text = model.telephone;
        txtEmail.Text     = model.email;
    }
Ejemplo n.º 5
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string userName = txtUserName.Text.Trim(); //用户名
        string userPwd  = txtPassword.Text.Trim(); //密码

        if (userName.Equals("") || userPwd.Equals(""))
        {
            msgtip.InnerHtml = "请输入用户名或密码";
            return;
        }
        string sCode = "";

        if (Session["MsgCheckCode"] != null)
        {
            sCode = Session["MsgCheckCode"].ToString();
        }
        else
        {
            msgtip.InnerHtml = "请重新输入验证码!";
            return;
        }
        string rCode = this.SecureCode.Text.ToString().Trim();

        if (rCode != sCode)
        {
            msgtip.InnerHtml = "验证码不正确!";
            return;
        }
        Cms.BLL.C_admin bll = new Cms.BLL.C_admin();

        if (bll.ExistsUser(userName, userPwd))
        {
            DataSet ds = bll.GetList("user_name='" + userName + "' and password='******'");
            if (ds.Tables[0].Rows.Count > 0)
            {
                //写入session
                Session["adminname"] = userName;                                     //保存session 用户名
                Session["id"]        = ds.Tables[0].Rows[0]["id"].ToString();        //保存session 用户名ID
                Session["adminid"]   = ds.Tables[0].Rows[0]["role_id"].ToString();   //保存session 用户名角色ID
                Session["adminType"] = ds.Tables[0].Rows[0]["role_type"].ToString(); //保存session 用户类型
                Session["adminPwd"]  = userPwd;                                      //保存session 用户密码

                //写入Cookie
                HttpCookie cookie = new HttpCookie("admin");                        //创建Cookie
                cookie["adminname"] = userName;                                     //保存Cookie 用户名
                cookie["id"]        = ds.Tables[0].Rows[0]["id"].ToString();        //保存Cookie 用户名ID
                cookie["adminid"]   = ds.Tables[0].Rows[0]["role_id"].ToString();   //保存Cookie 用户名角色ID
                cookie["adminType"] = ds.Tables[0].Rows[0]["role_type"].ToString(); //保存Cookie 用户类型
                cookie["adminPwd"]  = userPwd;                                      //保存Cookie 用户密码

                cookie.Expires = DateTime.Now.AddHours(14400);
                Response.Cookies.Add(cookie);

                adminUser.AddAdminLog(DTEnums.ActionEnum.Login.ToString(), userName); //记录日志
                this.Response.Redirect("index.aspx", true);
            }
            else
            {
                msgtip.InnerHtml = "用户名或密码有误,请重试!";
                return;
            }
        }
        else
        {
            msgtip.InnerHtml = "请输入正确的用户名和密码!";
            return;
        }
    }