private void Button_Login(object sender, RoutedEventArgs e) { if (TaiKhoan.Text.Length == 0) { MessageBox.Show("Vui lòng điền tài khoản."); TaiKhoan.Focus(); } //else if (!Regex.IsMatch(TaiKhoan.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) //{ // errormessage.Text = "Enter a valid email."; // TaiKhoan.Select(0, TaiKhoan.Text.Length); // TaiKhoan.Focus(); //} else { string taikhoan = TaiKhoan.Text; string matkhau = MatKhau.Password; SqlConnection con = new SqlConnection(DataSource.ConnectionString()); con.Open(); SqlCommand cmd = new SqlCommand("Select * from Users where Username='******' and Password='******'", con); cmd.CommandType = CommandType.Text; SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = cmd; DataSet dataSet = new DataSet(); adapter.Fill(dataSet); if (dataSet.Tables[0].Rows.Count > 0) { MainWindow.Show(); Close(); } else { MessageBox.Show("Sorry! Please enter existing emailid/password."); } con.Close(); } }