Exemplo n.º 1
0
    /// <summary>
    /// 修改密码
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        SP.BLL.members bll = new SP.BLL.members();

        //判断两次密码输入是否一致,如果不一致,则弹出提示信息,并返回
        if (TextBox1.Text == TextBox2.Text)
        {
            //根据用户编号和原密码得到用户信息
            DataSet ds = bll.GetList(" lname=" + Session["lname"].ToString() + " and pass='******'");

            //判断原密码是否正确
            if (ds.Tables[0].Rows.Count > 0)
            {
                //更新新密码
                SP.Model.members model = new SP.Model.members();
                model.pass  = Md5Hash(TextBox1.Text);
                model.lname = Session["lname"].ToString();

                bll.Update(model);
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('修改成功!');</script>");
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('原密码不正确!');</script>");
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('两次密码输入不一致!');</script>");
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 登录
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        SP.BLL.members bll = new SP.BLL.members();
        //根据用户名和密码得到用户信息
        DataSet ds = bll.GetList(" lname='" + txt_lname.Text + "' and pass='******'");

        //判断用户是否存在
        if (ds.Tables[0].Rows.Count > 0)
        {
            DataRow dr = ds.Tables[0].Rows[0];


            //把用户信息存入到Session
            Session["lname"] = dr["lname"].ToString();

            //跳转
            Response.Redirect("default.aspx");
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('用户名或密码错误!');</script>");

            return;
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// 注册
    /// </summary>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        SP.BLL.members bll = new SP.BLL.members();

        //验证是否已经存在
        if (bll.Exists(txt_lname.Text))
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('该登录名已存在,请重新输入!');</script>");
            return;
        }

        if (txt_pass.Text != txt_pass2.Text)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('两次密码输入不一致,请重新输入!');</script>");
            return;
        }

        string addrpic = "";

        if (fppic.HasFile)
        {
            string name     = this.fppic.PostedFile.FileName;
            int    i        = name.LastIndexOf('.');
            string extname  = name.Substring(i);
            string filename = DateTime.Now.ToString("yyyyMMddhhmmssfff");
            string path     = filename + extname;
            string savePath = Server.MapPath(@"uploads\" + filename + extname);
            fppic.PostedFile.SaveAs(savePath);
            addrpic = path;
        }

        string   lname   = txt_lname.Text;
        string   pass    = Md5Hash(txt_pass.Text);
        string   mname   = txt_mname.Text;
        string   sex     = rtsex.SelectedValue;
        string   tel     = txt_tel.Text;
        string   mpic    = addrpic;
        DateTime regtime = DateTime.Now;

        SP.Model.members model = new SP.Model.members();
        model.lname   = lname;
        model.pass    = pass;
        model.mname   = mname;
        model.sex     = sex;
        model.tel     = tel;
        model.mpic    = mpic;
        model.regtime = regtime;

        bll.Add(model);

        Session["lname"] = txt_lname.Text;

        Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('恭喜您注册成功!');location.href='default.aspx';</script>");
    }
Exemplo n.º 4
0
 //初始化
 private void ShowInfo()
 {
     if (Request.QueryString["id"] != null)
     {
         SP.BLL.members   bll   = new SP.BLL.members();
         SP.Model.members model = bll.GetModel(Request.QueryString["id"]);
         this.lbllname.Text   = model.lname;
         this.lblpass.Text    = model.pass;
         this.lblmname.Text   = model.mname;
         this.lblsex.Text     = model.sex;
         this.lbltel.Text     = model.tel;
         imgpic.ImageUrl      = "../../uploads/" + model.mpic;
         this.lblregtime.Text = model.regtime.ToString();
     }
 }