Пример #1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     QuanlysachDataContext db   = new QuanlysachDataContext();
     List <user>           data = db.users.Where(t => t.TenDangNhap == txtTenDangNhap.Text && t.PassWord == pwbMatKhau.Password).ToList();
     {
         if (txtTenDangNhap.Text == "" || pwbMatKhau.Password == "")
         {
             MessageBox.Show("Bạn hảy nhập đầy đủ thông tin từ cơ sở dữ liệu vào!", "Thông Báo");
         }
         else
         {
             if (data.Count > 0)
             {
                 //MessageBox.Show("Ban da dang nhap thanh cong !");
                 this.Hide();
                 MainWindow frmMain = new MainWindow();
                 frmMain.ShowDialog();
             }
             else
             {
                 MessageBoxResult result = MessageBox.Show("Ten dan nhap hay mat khau ban nhap khong dung !", "Thong Bao");
                 txtTenDangNhap.Focus();
                 pwbMatKhau.Focus();
                 return;
             }
         }
     }
 }