protected void btnDangky_Click(object sender, EventArgs e) { WEBBANHANG.Connect con = new WEBBANHANG.Connect(); con.conect(); string sql = "select * from TaiKhoan"; DataTable tb = con.getTK(sql); int n = int.Parse(tb.Rows.Count.ToString()); bool flag = true; for (int i = 0; i < n; i++) { if (tb.Rows[i]["TenKH"].ToString() == rsUser.Text) { flag = false; Response.Write("<script>alert('User đã tồn tại')</script>"); break; } } if (flag == true) { if (rsPass.Text != "" && rePass.Text != "") { if (rsPass.Text == rePass.Text) { string _type = "0"; string cmdStr = "insert into TaiKhoan(TenKH,Pass,Email,KieuKH) values(N'" + rsUser.Text + "','" + rsPass.Text + "','" + email.Text + "','" + _type + "')"; con.ExeCuteNonQuery(cmdStr); Response.Write("<script>alert('Đăng Ký thành công')</script>"); Response.Redirect("DangNhap.aspx"); } else { Response.Write("<script>alert('Đăng Ký Thất Bại')</script>"); } } else { Response.Write("<script>alert('Password/nhập lại password không được bỏ trống')</script>"); } } }