コード例 #1
0
 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();
         }
     }
 }
コード例 #2
0
 public TacGiaView()
 {
     InitializeComponent();
     using (var db = new QLTV_DBContext())
     {
         TacGiaList.ItemsSource = db.TACGIAs.ToList();
     }
 }
コード例 #3
0
 public NhaXuatBanView()
 {
     InitializeComponent();
     using (var db = new QLTV_DBContext())
     {
         NXBList.ItemsSource = db.NHAXUATBANs.ToList();
     }
 }
コード例 #4
0
 public QuyDinhView()
 {
     InitializeComponent();
     using (var db = new QLTV_DBContext())
     {
         QuyDinhList.ItemsSource = db.THAMSOs.ToList();
     }
 }
コード例 #5
0
 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();
     }
 }
コード例 #6
0
 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();
     }
 }
コード例 #7
0
 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();
     }
 }
コード例 #8
0
 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";
     }
 }
コード例 #9
0
 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();
     }
 }
コード例 #10
0
 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();
         }
     }
 }
コード例 #11
0
 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();
     }
 }
コード例 #12
0
 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();
         }
     }
 }
コード例 #13
0
 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;
         }
     }
 }
コード例 #14
0
 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();
         }
     }
 }
コード例 #15
0
 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();
         }
     }
 }
コード例 #16
0
 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";
     }
 }
コード例 #17
0
 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);
     }
 }
コード例 #18
0
 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";
     }
 }
コード例 #19
0
 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);
     }
 }