Ejemplo n.º 1
0
        protected void bt_Login_Click(object sender, EventArgs e)
        {
            string    phone = tb_Phone.Text.Trim();
            string    pwd   = tb_Pwd.Text.Trim();
            ClientBll bll   = new ClientBll();

            if (Session["Phone"] == null || (string)Session["Phone"] != phone)
            {
                if (string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(pwd))
                {
                    Response.Write("用户名和密码不能为空!");
                }
                else if (phone.Equals("888") && pwd.Equals("admin123"))
                {
                    Response.Redirect("admin.aspx");
                }
                else
                {
                    switch (bll.CheckLogin(phone, pwd))
                    {
                    case LoginState.NoName:
                        Response.Write("用户名不存在,请重新输入");
                        break;

                    case LoginState.PwdErr:
                        Response.Write("密码错误,请重新输入!");
                        break;

                    case LoginState.OK:
                        Session["Phone"] = phone;
                        Client client = bll.SelectClient(phone);
                        string name   = client.Name;
                        Session["Name"]     = name;
                        Session["ClientID"] = client.ID;

                        Response.Redirect("HomePage.aspx");
                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                Response.Write("该账号已经登录!");
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            tb_phone.Attributes.Add("style", "background-color:transparent");
            Response.Write(Session["Name"] + ",");
            Response.Write("您好!");
            Response.Write("如要修改手机号码,请联系管理员!");
            string phone = (string)Session["Phone"];

            if (phone == null) //判断用户是否登录
            {
                Response.Redirect("/Login.aspx");
            }
            else
            {
                if (!IsPostBack)  //页面首次加载
                {
                    Client client = clientBll.SelectClient(phone);
                    if (client == null)
                    {
                        Response.Write("<script>alert('需修改的用户不存在')</script>");
                    }
                    else
                    {   //将从数据库中获取的数据加载到对应的控件中
                        tb_phone.Text = client.Phone;
                        tb_Name.Text  = client.Name;
                        tb_Age.Text   = client.Age == null ? "" : client.Age.ToString();
                        if (client.Sex == "男")
                        {
                            rbl_Sex.SelectedValue = "男";
                        }

                        else if (client.Sex == "女")
                        {
                            rbl_Sex.SelectedValue = "女";
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        protected void bt_OK_Click(object sender, EventArgs e)
        {
            ClientBll bll = new ClientBll();

            string oldPwd   = tb_OldPwd.Text.Trim();
            string newPWd   = tb_NewPwd.Text.Trim();
            string reNewPwd = tb_ReNewPwd.Text.Trim();
            string phone    = (string)Session["Phone"];
            Client client   = bll.SelectClient(phone);

            if (oldPwd != client.Pwd)
            {
                Response.Write("<script>alert('旧密码错误!')</script>");
            }
            else if (oldPwd == newPWd)
            {
                Response.Write("<script>alert('新密码与旧密码一致!!')</script>");
            }
            else
            if (newPWd != reNewPwd)
            {
                Response.Write("<script>alert('密码不一致!')</script>");
            }
            else if (bll.UpdatePwd(newPWd, client.Phone))
            {
                Session["UpdatePwd"] = 1;
                Session["Phone"]     = null;
                Session["Name"]      = null;

                Response.Redirect("Login.aspx");
            }
            else
            {
                Response.Write("<script>alert('修改密码失败!')</script>");
            }
        }