Esempio n. 1
0
        protected void bt_Login_Click(object sender, EventArgs e)
        {
            string    Phone  = tb_Phone.Text.Trim();
            Client    client = new Client();
            string    Pwd    = tb_Pwd.Text.Trim();
            string    rePwd  = tb_RePwd.Text.Trim();
            ClientBll bll    = new ClientBll();
            string    Name   = tb_Name.Text.Trim();
            byte      Age    = 0;

            //Byte.TryParse(yourAge.value(), out Age);
            Byte.TryParse(tb_Age.Text.Trim(), out Age);
            string Sex = rbl_Sex.SelectedValue == "男" ? "男" : "女";

            if (string.IsNullOrEmpty(Phone) || string.IsNullOrEmpty(Pwd))
            {
                Response.Write("用户名和密码不能为空!");
            }

            else if (Pwd != rePwd)
            {
                Response.Write("密码不一致!请重新输入!");
            }
            else
            {
                if (!bll.SelectPhoneCount(Phone))
                {
                    client.Phone = Phone;
                    client.Pwd   = Pwd;
                    client.Name  = Name;
                    client.Sex   = Sex;
                    client.Age   = Age;
                    bool isOK = bll.AddClient(client);
                    if (isOK)
                    {
                        Response.Write("<script>alert('注册成功!!')</script>");
                        Response.Redirect("Login.aspx");
                    }
                    else
                    {
                        Response.Write("<script>alert('注册失败!')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('用户已经存在,请重新输入!')</script>");
                }
            }
        }
Esempio n. 2
0
        protected void bt_adminUpadate_Click(object sender, EventArgs e)
        {
            Client client = new Client();
            string phone  = tb_Phone.Text.Trim();
            string name   = tb_name.Text.Trim();

            string pwd = tb_pwd.Text.Trim();

            //Response.Write(phone + "..." + name + "..."+pwd+"..."+ rbl_sex.SelectedItem.Value);
            client.Phone = phone;
            client.Name  = name;
            client.Pwd   = pwd;
            if (string.IsNullOrEmpty(phone))
            {
                Response.Write("<script>alert('手机号不能为空!')</script>");
            }
            else if (phone != phone2 && clientBll.SelectPhoneCount(phone))//判断如果管理员修改了用户账号时,该账号是否已经存在
            {
                Response.Write("<script>alert('该账号已经存在!')</script>");
            }
            else if (string.IsNullOrEmpty(pwd))
            {
                Response.Write("<script>alert('密码不能为空!')</script>");
            }

            else if (string.IsNullOrEmpty(name))
            {
                Response.Write("<script>alert('昵称不能为空')</script>");
            }
            else
            {
                client.Sex = rbl_sex.SelectedItem.Value;
                int age;

                client.Age = Int32.TryParse(tb_age.Text.Trim(), out age) ? (byte?)age : null;;
                if (clientBll.adminUpdate(client, showId) && feedBackBll.adminUpdate(client, phone2) && replyBll.adminUpdate(client, phone2))//同时更新三个表
                {
                    Response.Write("<script>alert('修改成功')</script>");
                    //Response.Redirect("adminClient.aspx");
                }
                else
                {
                    Response.Write("<script>alert('修改失败')</script>");
                }
                //Response.Write(phone2);
            }
        }