private void btSave_Click(object sender, RoutedEventArgs e) { using (var db = new QLTV_DBContext()) { if (CheckNull() == true) { return; } else { var dg = new DOCGIA(txtMaDocGia.Text, txtTenDocGia.Text, DateTime.Parse(dpNgaySinh.Text), cbLoaiDG.SelectedValue.ToString(), txtDiaChi.Text, txtPhone.Text, txtEmail.Text, DateTime.Parse(dpNgayLapPhieu.Text), DateTime.Parse(dpNgayHetHan.Text)); db.DOCGIAs.Add(dg); db.SaveChanges(); DocGiaList.ItemsSource = db.DOCGIAs.ToList(); DocGiaList.Items.Refresh(); } } }
public TacGiaView() { InitializeComponent(); using (var db = new QLTV_DBContext()) { TacGiaList.ItemsSource = db.TACGIAs.ToList(); } }
public NhaXuatBanView() { InitializeComponent(); using (var db = new QLTV_DBContext()) { NXBList.ItemsSource = db.NHAXUATBANs.ToList(); } }
public QuyDinhView() { InitializeComponent(); using (var db = new QLTV_DBContext()) { QuyDinhList.ItemsSource = db.THAMSOs.ToList(); } }
private void cbTheLoai_SelectionChanged(object sender, SelectionChangedEventArgs e) { using (var db = new QLTV_DBContext()) { var query = from p in db.SACHs join q in db.LOAISACHs on p.LoaiSach_Id equals q.LoaiSach_Id where p.LoaiSach_Id == cbTheLoai.SelectedValue.ToString() select new { p.Sach_Id, p.TenSach, q.TenLoaiSach, p.NamXB, p.Gia }; SachList.ItemsSource = query.ToList(); } }
private void cbNXB_SelectionChanged(object sender, SelectionChangedEventArgs e) { using (var db = new QLTV_DBContext()) { var query = from p in db.NHAXUATBANs join q in db.SACHs on p.NXB_Id equals q.NXB_Id where p.NXB_Id == cbNXB.SelectedValue.ToString() select new { q.Sach_Id, q.TenSach, q.LoaiSach_Id, p.TenNXB, q.Gia }; SachList.ItemsSource = query.ToList(); } }
private void cbLoaiDG_SelectionChanged(object sender, SelectionChangedEventArgs e) { using (var db = new QLTV_DBContext()) { var query = from p in db.DOCGIAs join q in db.LOAIDOCGIAs on p.LoaidocGia_Id equals q.LoaiDocGia_Id where p.LoaidocGia_Id == cbLoaiDG.SelectedValue.ToString() select p; DocGiaList.ItemsSource = query.ToList(); } }
public TraCuuDocGiaView() { InitializeComponent(); using (var db = new QLTV_DBContext()) { DocGiaList.ItemsSource = db.DOCGIAs.ToList(); //combobox Thể Loại cbLoaiDG.ItemsSource = db.LOAIDOCGIAs.ToList(); cbLoaiDG.SelectedValuePath = "LoaiDocGia_Id"; cbLoaiDG.DisplayMemberPath = "TenLoaiDocGia"; } }
private void btCapNhatTG_Click(object sender, RoutedEventArgs e) { using (var db = new QLTV_DBContext()) { var t = db.TACGIAs.Find(txtMaTG.Text); t.TacGia_Id = txtMaTG.Text; t.TenTacGia = txtTenTG.Text; t.GhiChu = txtGhiChu.Text; db.SaveChanges(); TacGiaList.ItemsSource = db.TACGIAs.ToList(); TacGiaList.Items.Refresh(); } }
private void txtMaDG_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { using (var db = new QLTV_DBContext()) { var query = from p in db.DOCGIAs where p.DocGia_Id == txtMaDG.Text select p; DocGiaList.ItemsSource = query.ToList(); } } }
private void btCapNhatNXB_Click(object sender, RoutedEventArgs e) { using (var db = new QLTV_DBContext()) { var t = db.NHAXUATBANs.Find(txtMaNXB.Text); t.NXB_Id = txtMaNXB.Text; t.TenNXB = txtTenNXB.Text; t.GhiChu = txtGhiChu.Text; db.SaveChanges(); NXBList.ItemsSource = db.NHAXUATBANs.ToList(); NXBList.Items.Refresh(); } }
private void btThemTG_Click(object sender, RoutedEventArgs e) { if (CheckNull() == true) { return; } else { using (var db = new QLTV_DBContext()) { var tg = new TACGIA(txtMaTG.Text, txtTenTG.Text, txtGhiChu.Text); db.TACGIAs.Add(tg); db.SaveChanges(); TacGiaList.ItemsSource = db.TACGIAs.ToList(); TacGiaList.Items.Refresh(); } } }
private void txtMaDocGia_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { using (var db = new QLTV_DBContext()) { var t = db.DOCGIAs.Find(txtMaDocGia.Text); txtTenDocGia.Text = t.TenDocGia; txtDiaChi.Text = t.DiaChi; cbLoaiDG.Text = t.LOAIdOCGIA.TenLoaiDocGia; dpNgayHetHan.Text = t.NgayHetHan.ToString(); dpNgayLapPhieu.Text = t.NgayLapThe.ToString(); dpNgaySinh.Text = t.NgaySinh.ToString(); txtEmail.Text = t.Email; txtPhone.Text = t.SoDT; } } }
private void btThem_Click(object sender, RoutedEventArgs e) { if (CheckNull() == true) { return; } else { using (var db = new QLTV_DBContext()) { var qd = new THAMSO(txtNoiDungQD_ID.Text, int.Parse(txtGiaTri.Text), txtGhichu.Text); db.THAMSOs.Add(qd); db.SaveChanges(); QuyDinhList.ItemsSource = db.THAMSOs.ToList(); QuyDinhList.Items.Refresh(); } } }
private void btThemNXB_Click(object sender, RoutedEventArgs e) { if (CheckNull() == true) { return; } else { using (var db = new QLTV_DBContext()) { var nxb = new NXB(txtMaNXB.Text, txtTenNXB.Text, txtGhiChu.Text); db.NHAXUATBANs.Add(nxb); db.SaveChanges(); NXBList.ItemsSource = db.NHAXUATBANs.ToList(); NXBList.Items.Refresh(); } } }
public SachMoiView() { InitializeComponent(); using (var db = new QLTV_DBContext()) { SachList.ItemsSource = db.SACHs.ToList(); //combobox Thể Loại cbNXB.ItemsSource = db.NHAXUATBANs.ToList(); cbNXB.SelectedValuePath = "NXB_Id"; cbNXB.DisplayMemberPath = "TenNXB"; //combobox tác giả cbTacGia.ItemsSource = db.TACGIAs.ToList(); cbTacGia.SelectedValuePath = "TacGia_Id"; cbTacGia.DisplayMemberPath = "TenTacGia"; //combobox Thể Loại sách cbTheLoai.ItemsSource = db.LOAISACHs.ToList(); cbTheLoai.SelectedValuePath = "LoaiSach_Id"; cbTheLoai.DisplayMemberPath = "TenLoaiSach"; } }
private void btXoaNXB_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Bạn muốn xóa thông tin này?", "Delete", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { using (var db = new QLTV_DBContext()) { var nxb = db.NHAXUATBANs.Find(txtMaNXB.Text); if (nxb != null) { db.NHAXUATBANs.Remove(nxb); db.SaveChanges(); NXBList.ItemsSource = db.NHAXUATBANs.ToList(); NXBList.Items.Refresh(); } } } else { MessageBox.Show("Bạn chưa chọn thông tin NXB nào!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information); } }
public TraCuuSachView() { InitializeComponent(); //combobox số phiếu nhập using (var db = new QLTV_DBContext()) { SachList.ItemsSource = db.SACHs.ToList(); //combobox Thể Loại cbTheLoai.ItemsSource = db.LOAISACHs.ToList(); cbTheLoai.SelectedValuePath = "LoaiSach_Id"; cbTheLoai.DisplayMemberPath = "TenLoaiSach"; //combobox Tác Giả cbTacGia.ItemsSource = db.TACGIAs.ToList(); cbTacGia.SelectedValuePath = "TacGia_Id"; cbTacGia.DisplayMemberPath = "TenTacGia"; //combobox Nhà Xuất Bản cbNXB.ItemsSource = db.NHAXUATBANs.ToList(); cbNXB.SelectedValuePath = "NXB_Id"; cbNXB.DisplayMemberPath = "TenNXB"; } }
private void btXoaTG_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Bạn muốn xóa tác giả này?", "Delete", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { using (var db = new QLTV_DBContext()) { var tg = db.TACGIAs.Find(txtMaTG.Text); if (tg != null) { db.TACGIAs.Remove(tg); db.SaveChanges(); TacGiaList.ItemsSource = db.TACGIAs.ToList(); TacGiaList.Items.Refresh(); } } } else { MessageBox.Show("Bạn chưa chọn sản phẩm", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information); } }