private void btXoa_Click(object sender, RoutedEventArgs e) { TaiKhoanBUS bus = new TaiKhoanBUS(); try { bus.Delete(tbTaiKhoan.Text); MessageBox.Show("Xóa thành công !"); } catch (Exception) { MessageBox.Show("Xóa thất bại !"); } LoadData(); }
private void btThem_Click(object sender, RoutedEventArgs e) { TaiKhoan taiKhoan = new TaiKhoan() { TenDangNhap = tbTaiKhoan.Text, MatKhau = tbMatKhau.Text }; TaiKhoanBUS bus = new TaiKhoanBUS(); try { bus.Insert(taiKhoan); MessageBox.Show("Thêm thành công !"); } catch (Exception) { MessageBox.Show("Thêm thất bại !"); } LoadData(); }
private void LoadData() { List<TaiKhoan> _taiKhoan = new List<TaiKhoan>(); TaiKhoanBUS _busTaiKhoan = new TaiKhoanBUS(); _taiKhoan = _busTaiKhoan.GetList(); dataGrid.Items.Clear(); foreach (TaiKhoan i in _taiKhoan) { ThongTinTaiKhoan _thongTinTaiKhoan = new ThongTinTaiKhoan(); _thongTinTaiKhoan.TenDangNhap = i.TenDangNhap; _thongTinTaiKhoan.MatKhau = i.MatKhau; dataGrid.IsReadOnly = true; dataGrid.Items.Add(_thongTinTaiKhoan); } }