示例#1
0
    protected void btn_chinhsua_submit_Click(object sender, EventArgs e)
    {
        if (txt_matkhau.Value.Length < 8)
        {
            check_matkhau.Visible = true;
        }

        if (Regex.IsMatch(txt_hoten.Value.ToString(), @"[`1234567890-=;',./~!@#$%^&*()_+{}:|<>?]") || txt_hoten.Value == "")
        {
            check_hoten.Visible = true;
        }

        if (!Regex.IsMatch(txt_sdt.Value, @"^[0-9]+$") || txt_sdt.Value == "")
        {
            if (txt_sdt.Value.Length == 10 || txt_sdt.Value.Length == 11)
            {
                check_sdt.Visible = false;
            }
            else
            {
                check_sdt.Visible = true;
            }
        }

        if (txt_diachi.Value == "")
        {
            check_diachi.Visible = true;
        }

        if (check_matkhau.Visible == false && check_hoten.Visible == false && check_sdt.Visible == false && check_diachi.Visible == false)
        {
            Thanhvien tv = new Thanhvien();
            tv.Email   = function.email;
            tv.Matkhau = function.Mahoa(txt_matkhau.Value);
            tv.Hoten   = txt_hoten.Value;
            tv.Diachi  = txt_diachi.Value;
            tv.Sdt     = txt_sdt.Value;

            try
            {
                ThanhvienBUS.Thanhvien_Update(tv);
                Response.Write("<script>alert('Cập nhật tài khoản thành công')</script>");
                function.hoten  = txt_hoten.Value;
                function.diachi = txt_diachi.Value;
                function.sdt    = txt_sdt.Value;
            }
            catch (Exception)
            {
                Response.Write("<script>alert('Cập nhật tài khoản thất bại')</script>");
            }
        }
    }