private void btnHoanTat_Click(object sender, EventArgs e) { var result = MessageBox.Show("Bạn có muốn lưu sự thay đổi xuống cơ sở dữ liệu hay không?", "Lưu thông tin", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { string str = checkSeri(); if (str.Equals("")) { if (ls_cthd.Count == 0) { MessageBox.Show("Chưa có sản phẩm nào được chọn, xin vui lòng kiểm tra lại!"); } else { hoadonnhap.MaHoaDon = txtMaPhieu.Text.Trim(); hoadonnhap.GhiChu = txtGhiChu.Text.Trim(); hoadonnhap.NgayLap = dateNgayBan.Value; //bien trang thai hoa don hoadonnhap.TrangThai = 1; hoadonnhap.MaNhanVienSua = hoadonnhap.MaNhanVien; hoadonnhap.NgaySua = hoadonnhap.NgayLap; List <Kho_View> list_LK_In_Kho = Kho_DAL.getAll_LinhKien(); Kho_View kho_v; LinhKien_View lk_v; foreach (var cthd in ls_cthd) { //tinh lai gia nhap kho_v = list_LK_In_Kho.Where(temp => temp.MaLinhKien == cthd.MaLinhKien).FirstOrDefault(); lk_v = LinhKien_DAL.get_LinhKien_ByMaLK(cthd.MaLinhKien); if (lk_v != null) { if (!(lk_v.GiaNhap == cthd.GiaNhap)) { if (kho_v != null) { cthd.GiaNhap = ((lk_v.GiaNhap * kho_v.SoLuong) + (cthd.GiaNhap * cthd.SoLuong)) / (kho_v.SoLuong + cthd.SoLuong); } } } } if (HoaDonNhap_DAL.add_HoaDonNhap(hoadonnhap, ls_cthd)) { MessageBox.Show("Lưu thông tin thành công!"); f_Clear(); } else { MessageBox.Show("Đã có lỗi xảy ra, vui lòng kiểm tra dữ liệu!"); } } } else { MessageBox.Show("Bạn chưa nhập đầy đủ số Seri của linh kiện " + str); } } }
public static void Run(Kho_BLL Kho_BLL, Kho_DAL Kho_DAL, ArrayList arrayList) { int chon; while (true) { Menu(); //chọn chức năng chon = int.Parse(Console.ReadLine()); //nếu nhập = 0 thì dừng chương trình if (chon == 0) { break; } switch (chon) { case 1: Kho_BLL.Them(arrayList); Kho_DAL.ghiFile(arrayList); Console.WriteLine(" Nhập phím bất kì để tiếp tục"); Console.ReadLine(); Console.Clear(); break; case 2: Kho_BLL.Hien(arrayList); Console.WriteLine(" Nhập phím bất kì để tiếp tục"); Console.ReadLine(); Console.Clear(); break; case 3: Kho_BLL.Sua(arrayList); Kho_DAL.ghiFile(arrayList); Console.WriteLine(" Nhập phím bất kì để tiếp tục"); Console.ReadLine(); Console.Clear(); break; case 4: Kho_BLL.Xoa(arrayList); Kho_DAL.ghiFile(arrayList); Console.WriteLine(" Nhập phím bất kì để tiếp tục"); Console.ReadLine(); Console.Clear(); break; case 5: Kho_BLL.Timkiem(arrayList); Console.WriteLine(" Nhập phím bất kì để tiếp tục"); Console.ReadLine(); Console.Clear(); break; default: break; } } }
private void setGridCtrl_LinhKien() { list_LK_inKho = Kho_DAL.getAll_LinhKien(); gridCtrlLoc.DataSource = list_LK_inKho; }
private void InitVal() { gridControl1.DataSource = Kho_DAL.getAll_LinhKien(); }