public frmThongTinNguyenLieu(NguyenLieu nguyenLieu = null, int flag = 1) { InitializeComponent(); hienThi(); // khi người dùng nhấn thêm thì ấn nút sửa đi if (flag == 1) { txtMaNguyenLieu.Text = CServices.taoMa <NguyenLieu>(CNguyenLieu_BUS.toList()); btnSua.IsEnabled = false; btnLuu.IsEnabled = false; } // khi người dùng nhấn nút sửa else if (flag == 2) { btnThem.IsEnabled = false; btnSua.IsEnabled = false; } // là khi người dùng bấm nút xem chi tiết else { btnThem.IsEnabled = false; btnLuu.IsEnabled = false; isEnabledThongTin(false); } if (nguyenLieu != null) { NguyenLieuSelect = nguyenLieu; hienThiThongTin(NguyenLieuSelect); } }
public frmThongTinNhanVien(NhanVien nhanVien = null, int flag = 1) { InitializeComponent(); cmbLoaiNhanVien.ItemsSource = CLoaiNhanVien_BUS.toListTenLoai(); dateNgayVaoLam.SelectedDate = DateTime.Now; // khi người dùng nhấn thêm thì ấn nút sửa if (flag == 1) { txtMaNhanVien.Text = CServices.taoMa <NhanVien>(CNhanVien_BUS.toListAll()); btnSua.IsEnabled = false; btnLuu.IsEnabled = false; } // khi người dùng nhấn nút sửa else if (flag == 2) { btnThem.IsEnabled = false; btnSua.IsEnabled = false; } // là khi người dùng bấm nút xem chi tiết else { btnThem.IsEnabled = false; btnLuu.IsEnabled = false; btnChosse.IsEnabled = false; isEnabledThongTin(false); } if (nhanVien != null) { nhanVienSelect = nhanVien; hienThiThongTin(nhanVienSelect); } }
private void btnBoChon_Click(object sender, RoutedEventArgs e) { hienThiThongTin(new LoaiNhanVien()); isEnabledThongTin(false); loaiNhanVienSelect = null; txtMaLoaiNhanVien.Text = CServices.taoMa <LoaiNhanVien>(CLoaiNhanVien_BUS.toList()); }
private void btnThem_Click(object sender, RoutedEventArgs e) { try { LoaiNhanVien loaiNhanVien = new LoaiNhanVien(); loaiNhanVien.maLoaiNhanvien = txtMaLoaiNhanVien.Text; loaiNhanVien.tenLoai = txtTenLoai.Text; if (CLoaiNhanVien_BUS.add(loaiNhanVien)) { MessageBox.Show("Thêm thành công"); hienThiDSLoaiNhanVien(CLoaiNhanVien_BUS.toList()); txtMaLoaiNhanVien.Text = CServices.taoMa <LoaiNhanVien>(CLoaiNhanVien_BUS.toList()); txtTenLoai.Text = ""; } } catch (ArgumentNullException) { MessageBox.Show("Lỗi! Dữ liệu rống"); } catch (FormatException) { MessageBox.Show("Lỗi! Dữ liệu không hợp lệ, Lương cơ bản phải là số"); } catch (OverflowException) { MessageBox.Show("Lỗi! Độ dài quá giới hạn cho phép"); } }
public frmQuanLyLoaiNhanVien() { InitializeComponent(); loaiNhanVienSelect = new LoaiNhanVien(); hienThiDSLoaiNhanVien(CLoaiNhanVien_BUS.toList()); isEnabledThongTin(false); txtMaLoaiNhanVien.Text = CServices.taoMa <LoaiNhanVien>(CLoaiNhanVien_BUS.toList()); }
public frmQuanLyLoaiNguyenLieu() { InitializeComponent(); txtMaLoaiNguyenLieu.Text = CServices.taoMa <LoaiNguyenLieu>(CLoaiNguyenLieu_BUS.toListAll()); loaiNguyenLieuSeclect = new LoaiNguyenLieu(); hienThiDSLoaiNhanVien(CLoaiNguyenLieu_BUS.toList()); isEnabledThongTin(false); }
public frmQuanLySanPham() { InitializeComponent(); hienthiSP(); hienThiDSNguyenLieu(); txtMasanpham.Text = CServices.taoMa <SanPham>(CSanPham_BUS.DsSanPham()); nguyenLieuThanhPhans = new List <NguyenLieu>(); }
public void load() { txtMasanpham.Text = CServices.taoMa <SanPham>(CSanPham_BUS.DsSanPham()); txtDonvitinh.Text = null; cboLoaisanpham.Text = null; txtTensanpham.Text = ""; txtDongia.Text = ""; sanPhamSelect = null; nguyenLieuThanhPhans = new List <NguyenLieu>(); hienThiDSNguyenLieuDuocChon(); }
private void btnBochon_Click(object sender, RoutedEventArgs e) { txtMasanpham.Text = CServices.taoMa <SanPham>(CSanPham_BUS.DsSanPham()); txtDonvitinh.Text = null; cboLoaisanpham.Text = null; txtTensanpham.Text = ""; txtDongia.Text = ""; sanPhamSelect = null; nguyenLieuThanhPhans = new List <NguyenLieu>(); hienThiDSNguyenLieuDuocChon(); }
public frmThongTinPhieuNhap(NhanVien nhanVien = null, PhieuNhapNguyenLieu phieuNhapNguyenLieu = null, int flag = 1) { InitializeComponent(); nhanVienSelect = nhanVien; chiTietNguyenLieus = CChiTietNguyenLieu_BUS.toList(); list1 = CChiTietPhieuNhapNguyenLieu_BUS.toListAll(); phieuNhapNguyenLieuSelect = phieuNhapNguyenLieu; chiTietPhieuNhaps = new List <ChiTietPhieuNhap>(); donViTinhs = new List <string>(); if (nhanVienSelect == null) { nhanVienSelect = new NhanVien(); } if (phieuNhapNguyenLieuSelect == null) { phieuNhapNguyenLieuSelect = new PhieuNhapNguyenLieu(); } txtMaPhieuNhap.Text = CServices.taoMa <PhieuNhapNguyenLieu>(CPhieuNhapNguyenLieu_BUS.toListAll()); donViTinhs.Add("Kg"); donViTinhs.Add("Gam"); donViTinhs.Add("Lon"); donViTinhs.Add("Chai"); donViTinhs.Add("Trái"); donViTinhs.Add("Lít"); cmbDonViTinh.ItemsSource = donViTinhs; if (flag == 1) { btnSua.IsEnabled = false; btnXoa.IsEnabled = false; flat = 1; } // là khi người dùng bấm nút xem chi tiết else { btnThem.IsEnabled = false; btnSua.IsEnabled = false; btnXoa.IsEnabled = false; btnTaoPhieuNhap.IsEnabled = false; flat = 0; isEnabledThongTin(false); } hienThiThongTin(phieuNhapNguyenLieuSelect); }
private void btnSua_Click(object sender, RoutedEventArgs e) { LoaiNguyenLieu loaiNguyenLieu = new LoaiNguyenLieu(); loaiNguyenLieu.maLoaiNguyenLieu = txtMaLoaiNguyenLieu.Text; loaiNguyenLieu.tenLoaiNguyenLieu = txtTenLoai.Text; loaiNguyenLieu.trangThai = 0; if (CLoaiNguyenLieu_BUS.edit(loaiNguyenLieu)) { MessageBox.Show("Sửa thành công"); hienThiDSLoaiNhanVien(CLoaiNguyenLieu_BUS.toList()); txtMaLoaiNguyenLieu.Text = CServices.taoMa <LoaiNguyenLieu>(CLoaiNguyenLieu_BUS.toListAll()); txtTenLoai.Text = ""; } }
private void btnChonNL_Click(object sender, RoutedEventArgs e) { if (dgChiTietNguyenLieu.SelectedItem == null) { MessageBox.Show("Bạn chưa chọn chi tiết Nguyên Liệu cần xuất"); return; } int index = dgChiTietNguyenLieu.SelectedIndex; chiTietPhieuNhapselect = new ChiTietPhieuNhap(); chiTietPhieuNhapselect = chiTietPhieuNhaps[index] as ChiTietPhieuNhap; if (chiTietPhieuNhapselect == null) { MessageBox.Show("Không có chi tiết phiếu nhập"); } else { ChiTietPhieuXuat chitietPhieuXuat = new ChiTietPhieuXuat(); if (i == 0) { chitietPhieuXuat.maChiTietPhieuXuat = taoMaChiTietPX(); i = 1; } else { chitietPhieuXuat.maChiTietPhieuXuat = CServices.taoMa <ChiTietPhieuXuat>(chiTietPhieuXuats); } chitietPhieuXuat.maChitietNguyenLieu = chiTietPhieuNhapselect.maChitietNguyenLieu; chitietPhieuXuat.soLuong = chiTietPhieuNhapselect.soLuong; chitietPhieuXuat.donGia = chiTietPhieuNhapselect.donGia; chitietPhieuXuat.thanhTien = chiTietPhieuNhapselect.thanhTien; chitietPhieuXuat.maPhieuXuat = txtMaPhieuXuat.Text; chitietPhieuXuat.ChiTietNguyenLieu = chiTietPhieuNhapselect.ChiTietNguyenLieu; chiTietPhieuXuats.Add(chitietPhieuXuat); dgChitietPhieuXuat.ItemsSource = chiTietPhieuXuats.Select(x => new { maChiTietPhieuXuat = x.maChitietNguyenLieu.Substring(0, 13), tenNguyenLieu = x.ChiTietNguyenLieu.NguyenLieu.tenNguyenLieu.Trim(), soLuong = x.soLuong, donGia = x.donGia, thanhTien = x.thanhTien }); txtBoxTongtien.Text = tinhTongThanhTien(chiTietPhieuXuats).ToString(); } }
private void btnXoa_Click(object sender, RoutedEventArgs e) { if (loaiNguyenLieuSeclect != null) { if (CLoaiNguyenLieu_BUS.remove(loaiNguyenLieuSeclect)) { MessageBox.Show("Xóa thành công"); hienThiDSLoaiNhanVien(CLoaiNguyenLieu_BUS.toList()); txtMaLoaiNguyenLieu.Text = CServices.taoMa <LoaiNguyenLieu>(CLoaiNguyenLieu_BUS.toListAll()); txtTenLoai.Text = ""; } } else { MessageBox.Show("Vui lòng chọn nguyên liệu cần xóa"); } }
private void btnTaoThongKe_Click(object sender, RoutedEventArgs e) { if (chiTietThongKes.Count() > 0) { double tongThanTien = 0; string maThongKe = CServices.taoMa <ThongKe>(CThongKe.toList()); foreach (var item in chiTietThongKes) { tongThanTien += item.Item6; } ThongKe thongKe = new ThongKe(); thongKe.maThongKe = maThongKe; thongKe.ngayLap = DateTime.Now; thongKe.tongThanhTien = tongThanTien; if (!CThongKe.add(thongKe)) { return; } foreach (var chiTiet in chiTietThongKes) { ChiTietThongKe chiTietThongKe = new ChiTietThongKe(); chiTietThongKe.maChiTietThongKe = CServices.taoMa <ChiTietThongKe>(CChiTietThongKe.toList()); chiTietThongKe.maThongKe = maThongKe; chiTietThongKe.maNhanVien = chiTiet.Item1; chiTietThongKe.soLuongHoaDon = chiTiet.Item4; chiTietThongKe.soLuongBan = chiTiet.Item5; chiTietThongKe.ngayLap = DateTime.Now; chiTietThongKe.thanhTien = chiTiet.Item6; if (!CChiTietThongKe.add(chiTietThongKe)) { return; } } this.Close(); } else { MessageBox.Show("Danh sách chi tiết thống kê rỗng, không thể tạo thống kê"); } }
private void btnXoa_Click(object sender, RoutedEventArgs e) { if (loaiNhanVienSelect != null) { if (CLoaiNhanVien_BUS.remove(loaiNhanVienSelect)) { MessageBox.Show("Xóa thành công"); hienThiDSLoaiNhanVien(CLoaiNhanVien_BUS.toList()); loaiNhanVienSelect = null; txtTenLoai.Text = ""; txtMaLoaiNhanVien.Text = CServices.taoMa <LoaiNhanVien>(CLoaiNhanVien_BUS.toList()); } } else { MessageBox.Show("Vui lòng chọn nhân viên cần xóa"); } }
public void HienThiDSLoaiSanPham() { List <LoaiSanPham> list = CLoaiSanPham_BUS.toList(); if (list.Count > 0) { dgLoaisanpham.ItemsSource = list.Select(x => new { maLoaiSanPham = x.maLoaiSanPham, tenLoai = x.tenLoai, trangThai = x.trangThai == 0 ? "Mở" : "Khóa" }); } else { MessageBox.Show("Danh sách loại sản phẩm rỗng, chưa có loại sản phẩm nào"); } txtmaLoai.Text = CServices.taoMa <LoaiSanPham>(CLoaiSanPham_BUS.toList()); }
private void dgLoaisanpham_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { if (dgLoaisanpham.SelectedItem != null) { a = CLoaiSanPham_BUS.find(dgLoaisanpham.SelectedValue.ToString()); txtmaLoai.Text = a.maLoaiSanPham; txttenLoai.Text = a.tenLoai; } else { txtmaLoai.Text = CServices.taoMa <LoaiSanPham>(CLoaiSanPham_BUS.DSLoaiSP()); txttenLoai.Text = ""; } } catch (Exception ex) { MessageBox.Show("Có lỗi: " + ex.Message); } }
public frmKetCa(NhanVien nv = null) { InitializeComponent(); nhanVien = nv; if (nhanVien == null) { nhanVien = new NhanVien(); } ketCa = new KetCa(); DateTime gioKetThuc = DateTime.Now; ketCa.maKetCa = CServices.taoMa <KetCa>(CCa_BUS.toList()); ketCa.maNhanVien = nhanVien.maNhanVien; ketCa.gioBatDau = CCa_BUS.CaLamViec.GioBatDau; ketCa.gioKetThuc = gioKetThuc; ketCa.ngayLap = gioKetThuc; CCa_BUS.CaLamViec.GioKetThuc = DateTime.Now; List <HoaDon> hoaDons = new List <HoaDon>(); hoaDons = CHoaDon_BUS.toList(CCa_BUS.CaLamViec); foreach (HoaDon hoaDon in hoaDons) { hoaDon.maKetCa = ketCa.maKetCa; } ketCa.soLuong = hoaDons.Count(); double tongTienBan = CHoaDon_BUS.tongTienBan(hoaDons); ketCa.tongTienBan = tongTienBan; ketCa.tienDauCa = 0; ketCa.tongDoanhThu = tongTienBan; ketCa.HoaDons = hoaDons; hienThiThongTin(ketCa); }
private void btnSua_Click(object sender, RoutedEventArgs e) { if (loaiNhanVienSelect != null) { var result = MessageBox.Show("Do you want to save changes?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { LoaiNhanVien loaiNhanVien = new LoaiNhanVien(); loaiNhanVien.maLoaiNhanvien = txtMaLoaiNhanVien.Text; loaiNhanVien.tenLoai = txtTenLoai.Text; if (CLoaiNhanVien_BUS.edit(loaiNhanVien)) { MessageBox.Show("Sửa thành công"); hienThiDSLoaiNhanVien(CLoaiNhanVien_BUS.toList()); txtTenLoai.Text = ""; txtMaLoaiNhanVien.Text = CServices.taoMa <LoaiNhanVien>(CLoaiNhanVien_BUS.toList()); } } } }
private void btnThemLoaiSP_Click(object sender, RoutedEventArgs e) { try { LoaiSanPham a = new LoaiSanPham(); a.maLoaiSanPham = txtmaLoai.Text; a.tenLoai = txttenLoai.Text; a.trangThai = 0; string makt = txtmaLoai.Text; if (CLoaiSanPham_BUS.KTRong(a)) { if (CLoaiSanPham_BUS.find(makt) == null) { CLoaiSanPham_BUS.add(a); MessageBox.Show("Thêm thành công"); txtmaLoai.Text = CServices.taoMa <LoaiSanPham>(CLoaiSanPham_BUS.DSLoaiSP()); } else { MessageBox.Show("Mã Loại bị trùng!"); } } else { MessageBox.Show("Vui lòng nhập tên loại"); } } catch (Exception ex) { MessageBox.Show("Có lỗi: " + ex.Message); } HienThiDSLoaiSanPham(); load(); txttenLoai.Text = ""; //btnBoChon_Click(sender, e); }
private void btnTinhtien_Click(object sender, RoutedEventArgs e) { if (chiTietHoaDons.Count() == 0) { MessageBox.Show("Hóa Đơn chưa có chi tiết hóa đơn"); return; } string maHoaDon = CServices.taoMa <HoaDon>(CHoaDon_BUS.toList()); if (CHoaDon_BUS.find(maHoaDon) == null) { try { HoaDon hoaDon = new HoaDon(); hoaDon.maHoaDon = maHoaDon; hoaDon.maNhanVien = nhanVienSelect.maNhanVien; hoaDon.ngayLap = DateTime.Now; hoaDon.tongThanhTien = tongThanhTien; if (txtTienKhachDua.Text == "" || txtTienKhachDua.Text == null) { MessageBox.Show("Vui lòng nhập tiền khách đưa"); return; } else { hoaDon.tienKhachDua = double.Parse(txtTienKhachDua.Text); } if (txtTienThoiLai.Text == "" || txtTienThoiLai.Text == null) { MessageBox.Show("Vui lòng nhập tiền khách đưa để tính tiền thối lại"); return; } else { double tienThua = hoaDon.tienKhachDua.Value - hoaDon.tongThanhTien; if (tienThua < 0) { MessageBox.Show("Tiền khách đưa không thể nhỏ hơn tổng thành tiền"); return; } else if (tienThua >= 500000) { txtTienThoiLai.Text = ""; MessageBox.Show("Xem lại tiền khách đưa"); return; } else { hoaDon.tienThua = tienThua; } } hoaDon.trangThai = 0; foreach (var item in chiTietHoaDons) { ChiTietHoaDon a = new ChiTietHoaDon(); a.maHoaDon = hoaDon.maHoaDon; a.maSanPham = item.maSanPham; a.soLuong = item.soLuong; a.thanhTien = CChiTietHoaDon_BUS.tinhThanhTien(item); hoaDon.ChiTietHoaDons.Add(a); } if (CHoaDon_BUS.add(hoaDon)) { MessageBox.Show("Xuất hóa đơn thành công"); } else { return; } chiTietHoaDons.Clear(); hienThiDSChiTietHD(chiTietHoaDons); tongThanhTien = 0; txtTongTien.Text = ""; txtTienKhachDua.Text = ""; txtTienThoiLai.Text = ""; } catch (ArgumentNullException) { MessageBox.Show("Không được để rỗng đơn giá, tiền khách đưa, tiền thừa"); } catch (FormatException) { MessageBox.Show("Đơn giá, tiền khách đưa, tiền thừa, phải là số"); } catch (OverflowException) { MessageBox.Show("Đơn giá, tiền khách đưa, tiền thừa, vượt quá giới hạn lưu trữ"); } } else { MessageBox.Show("Mã hóa đơn đã tồn tại"); } }
private void btnThemTK_Click(object sender, RoutedEventArgs e) { try { if (txtTaiKhoan.Text == "" || txtTaiKhoan.Text == null || txtMatKhau.Text == "" || txtMatKhau.Text == null) { MessageBox.Show("Yêu cầu điền thông tin tài khoản"); return; } TaiKhoan taiKhoan = new TaiKhoan(); string maNhanVien = CNhanVien_BUS.findTenbyMa(cmbTenNhanVien.SelectedItem.ToString()); if (maNhanVien == "") { MessageBox.Show("Vui lòng chọn nhân viên"); return; } taiKhoan.maNhanVien = maNhanVien; if (taiKhoan.maNhanVien == null || taiKhoan.maNhanVien == "") { MessageBox.Show("Không lấy được mã nhân viên"); return; } if ((txtTaiKhoan.Text == null || txtTaiKhoan.Text == "") && (txtMatKhau.Text == null || txtMatKhau.Text == "")) { MessageBox.Show("Điền đầy đủ thông tin tài khoản"); return; } if (CTaiKhoan_BUS.findTK(txtTaiKhoan.Text)) { MessageBox.Show("Tên tài khoản đã tồn tại"); return; } foreach (char item in txtTaiKhoan.Text) { if ((item < 65 || item > 90) && (item < 97 || item > 122) && (item < 0 || item > 57)) { MessageBox.Show("Tên tài khoản chỉ có các chữ cái in hoa hoặc thường và số"); return; } } taiKhoan.tenTaiKhoan = txtTaiKhoan.Text; taiKhoan.matKhau = CTaiKhoan_BUS.Encrypt(txtMatKhau.Text); taiKhoan.maTaiKhoan = CServices.taoMa <TaiKhoan>(CTaiKhoan_BUS.toList()); taiKhoan.trangThai = 0; if (CServices.kiemTraThongTin(taiKhoan)) //Kiểm tra thông tin tài khoản hợp lệ { CTaiKhoan_BUS.add(taiKhoan); //Thêm tài khoản MessageBox.Show("Thêm thành công"); } } catch (NullReferenceException) { MessageBox.Show("Bạn chưa chọn mã nhân viên cần cấp tài khoản"); } hienthiDStaikhoan(); load(); cmbTenNhanVien_Loaded(sender, e); }
private void btnXuatNguyenLieu_Click(object sender, RoutedEventArgs e) { if (chiTietPhieuXuats.Count() == 0) { MessageBox.Show("Hóa Đơn chưa có chi tiết Phiếu Xuất"); return; } if (CPhieuXuatNguyenLieu_BUS.find(txtMaPhieuXuat.Text) == null) { try { PhieuXuatNguyenLieu phieuXuat = new PhieuXuatNguyenLieu(); phieuXuat.maPhieuXuat = txtMaPhieuXuat.Text; phieuXuat.ngayXuat = DateTime.Now; phieuXuat.tongThanhTien = double.Parse(txtBoxTongtien.Text); phieuXuat.maNhanVien = nhanVienSelected.maNhanVien; phieuXuat.trangThai = 0; foreach (var item in chiTietPhieuXuats) { ChiTietPhieuXuat ctPX = new ChiTietPhieuXuat(); ctPX.maChiTietPhieuXuat = item.maChiTietPhieuXuat; ctPX.maChitietNguyenLieu = item.maChitietNguyenLieu; ctPX.soLuong = item.soLuong; ctPX.donGia = item.donGia; ctPX.thanhTien = item.thanhTien; ctPX.maPhieuXuat = phieuXuat.maPhieuXuat; phieuXuat.ChiTietPhieuXuats.Add(ctPX); } dc.PhieuXuatNguyenLieux.Add(phieuXuat); dc.SaveChanges(); MessageBox.Show("Xuất Nguyên Liệu Thành Công"); txtMaPhieuXuat.Text = CServices.taoMa <PhieuXuatNguyenLieu>(CPhieuXuatNguyenLieu_BUS.toList()); CChiTietPhieuXuat_BUS.CapNhapSoLuong_CTNguyenLieu(chiTietPhieuXuats); //CChiTietPhieuNhapNguyenLieu_BUS.CapNhapSoLuong_CTPhieuNhap(chiTietPhieuXuats); chiTietPhieuXuats.Clear(); hienThiDSChiTietPX(chiTietPhieuXuats); chiTietPhieuNhaps = CChiTietPhieuNhapNguyenLieu_BUS.toList(); HienthiNguyenLieu(chiTietPhieuNhaps); chiTietPhieuNhapselect = null; i = 0; } catch (DbEntityValidationException) { MessageBox.Show("Lỗi kiểu dữ liệu"); } catch (DbUpdateException) { MessageBox.Show("Không cập được dữ liệu"); } catch (ArgumentNullException) { MessageBox.Show("Không được để rỗng đơn giá"); } catch (FormatException) { MessageBox.Show("Đơn giá phải là số"); } catch (OverflowException) { MessageBox.Show("Đơn giá vượt quá giới hạn lưu trữ"); } } else { MessageBox.Show("Mã Phiếu Xuất đã tồn tại"); } }
public void taoMaPhieuXuat() { txtMaPhieuXuat.Text = CServices.taoMa <PhieuXuatNguyenLieu>(CPhieuXuatNguyenLieu_BUS.toList()); }
public string taoMaChiTietPX() { string a = CServices.taoMa <ChiTietPhieuXuat>(CChiTietPhieuXuat_BUS.toList()); return(a); }
private void hienThi() { if (dateNgayBatDau.SelectedDate > DateTime.Now || dateNgayKetThuc.SelectedDate > DateTime.Now) { MessageBox.Show("Ngày bắt đầu và ngày kết thúc không được lớn hơn ngày hiện tại"); return; } List <HoaDon> hoaDons = new List <HoaDon>(); List <NhanVien> nhanViens = new List <NhanVien>(); hoaDons = CHoaDon_BUS.toList(dateNgayBatDau.SelectedDate.Value, dateNgayKetThuc.SelectedDate.Value); nhanViens = CNhanVien_BUS.toList(); if (hoaDons.Count() > 0) { txtMaThongKe.Text = CServices.taoMa <ThongKe>(CThongKe.toList()); txtNgayLapThongKe.Text = DateTime.Now.ToString("dd/MM/yyyy"); double tongThanhTien = 0; hoaDons.ForEach(x => tongThanhTien += x.tongThanhTien); txtTongThanhTien.Text = String.Format("{0:#,###,0 VND;(#,###,0 VND);0 VND}", tongThanhTien); chiTietThongKes = new List <Tuple <string, string, string, int, int, double> >(); //bool flag = false; foreach (var nhanVien in nhanViens) { int soLuongHoaDon = 0; int soLuongBan = 0; double thanhTien = 0; foreach (var hoaDon in hoaDons) { if (nhanVien.maNhanVien == hoaDon.maNhanVien) { soLuongBan += hoaDon.ChiTietHoaDons.Count(); thanhTien += hoaDon.tongThanhTien; soLuongHoaDon++; //flag = true; } } //if (flag) //{ var chiTietThongKe = new Tuple <string, string, string, int, int, double>( nhanVien.maNhanVien, nhanVien.hoNhanVien, nhanVien.tenNhanVien, soLuongHoaDon, soLuongBan, thanhTien); chiTietThongKes.Add(chiTietThongKe); //} //flag = false; } dgChiTietThongKe.ItemsSource = chiTietThongKes.Select(x => new { maNhanVien = x.Item1, hoNhanVien = x.Item2, tenNhanVien = x.Item3, soLuongHoaDon = x.Item4, soLuongBan = x.Item5, thanhTien = x.Item6 }); } else { MessageBox.Show("Không có hóa đơn nào được bán"); } }
private void btnThem_Click(object sender, RoutedEventArgs e) { try { if (dateNgayNhap.SelectedDate.Value != null && dateNgayHetHan.SelectedDate.Value != null && cmbTenNguyenLieu.SelectedItem.ToString() != null) { string tenNguyenLieu = cmbTenNguyenLieu.SelectedItem.ToString(); NguyenLieu nguyenLieu = CNguyenLieu_BUS.findNguyenLieuByTen(tenNguyenLieu); if (nguyenLieu != null) { ChiTietPhieuNhap chiTiet = new ChiTietPhieuNhap(); // tạo mã chi tiết phiếu nhập if (list1.Count() == 0) { chiTiet.maChiTietPhieuNhap = CServices.taoMa <ChiTietPhieuNhap>(chiTietPhieuNhaps); } else { chiTiet.maChiTietPhieuNhap = CServices.taoMa <ChiTietPhieuNhap>(list1); list1 = new List <ChiTietPhieuNhap>(); } // tạo mã chi tiết nguyên liệu //if (chiTietNguyenLieus.Count() == 0) //{ // List<ChiTietNguyenLieu> temp = new List<ChiTietNguyenLieu>(); // foreach (var item in chiTietPhieuNhaps) // { // temp.Add(item.ChiTietNguyenLieu); // } // chiTiet.maChitietNguyenLieu = CChiTietNguyenLieu_BUS // .taoMa(txtMaChiTietNguyenLieu.Text, temp); //} //else //{ // chiTiet.maChitietNguyenLieu = CChiTietNguyenLieu_BUS // .taoMa(txtMaChiTietNguyenLieu.Text, chiTietNguyenLieus); // chiTietNguyenLieus = new List<ChiTietNguyenLieu>(); //} chiTiet.maChitietNguyenLieu = chiTiet.maChiTietPhieuNhap + txtMaChiTietNguyenLieu.Text; chiTiet.maPhieuNhap = txtMaPhieuNhap.Text; chiTiet.soLuong = int.Parse(txtSoLuong.Text); chiTiet.donGia = double.Parse(txtDonGia.Text); chiTiet.thanhTien = double.Parse(txtThanhTien.Text); ChiTietNguyenLieu chiTietNguyenLieu = new ChiTietNguyenLieu(); chiTietNguyenLieu.maChiTietNguyenLieu = chiTiet.maChitietNguyenLieu; chiTietNguyenLieu.maNguyenLieu = nguyenLieu.maNguyenLieu; chiTietNguyenLieu.ngayHetHan = dateNgayHetHan.SelectedDate.Value; chiTietNguyenLieu.soLuong = chiTiet.soLuong; chiTietNguyenLieu.donViTinh = cmbDonViTinh.Text; chiTiet.ChiTietNguyenLieu = chiTietNguyenLieu; if (CServices.kiemTraThongTin(chiTiet)) { chiTietPhieuNhaps.Add(chiTiet); txtTongThanhTien.Text = tinhTongThanhTien(chiTietPhieuNhaps).ToString(); hienThiDSChiTietPhieuNhap(chiTietPhieuNhaps); hienThiDefault(); } } } } catch (InvalidOperationException) { MessageBox.Show("Lỗi! Không được để dữ liệu nhập vào là rỗng"); } catch (FormatException) { MessageBox.Show("Lỗi! Số lượng và Đơn giá phải là số"); } catch (ArgumentNullException) { MessageBox.Show("Lỗi! Không được để dữ liệu nhập vào là rỗng"); } catch (OverflowException) { MessageBox.Show("Lỗi! Dữ liệu nhập vào vượt quá giới hạn cho phép"); } }
private void btnThem_Click(object sender, RoutedEventArgs e) { try { SanPham sp1 = new SanPham(); sp1.maSanPham = txtMasanpham.Text; sp1.tenSanPham = txtTensanpham.Text; sp1.donViTinh = txtDonvitinh.Text; if (cboLoaisanpham.SelectedItem != null) { loaisanpham = CSanPham_BUS.findTen(cboLoaisanpham.SelectedItem.ToString()); sp1.maLoaiSanPham = loaisanpham.maLoaiSanPham; } else { MessageBox.Show("Loại sản phẩm không được để trống"); return; } sp1.donGia = int.Parse(txtDongia.Text); sp1.trangThai = 0; if (nguyenLieuThanhPhans.Count() > 0) { List <ThanhPhan> thanhPhans = new List <ThanhPhan>(); foreach (NguyenLieu nguyenLieu in nguyenLieuThanhPhans) { ThanhPhan thanhPhan = new ThanhPhan(); thanhPhan.maNguyenLieu = nguyenLieu.maNguyenLieu; thanhPhan.maSanPham = sp1.maSanPham; thanhPhan.trangThai = 0; } sp1.ThanhPhans = thanhPhans; } else { MessageBox.Show("Vui lòng chọn thành phần nguyên liệu có trong sản phẩm"); return; } if (CSanPham_BUS.KTRong(sp1)) { if (CServices.kiemTraThongTin(sp1)) { if (CSanPham_BUS.find(txtMasanpham.Text) == null) { if (CSanPham_BUS.add(sp1)) { MessageBox.Show("Thêm thành công"); txtMasanpham.Text = CServices.taoMa <SanPham>(CSanPham_BUS.DsSanPham()); hienthiSP(); load(); nguyenLieuThanhPhans = new List <NguyenLieu>(); hienThiDSNguyenLieuDuocChon(); } } else { MessageBox.Show("Mã sản phẩm bị trùng"); } } else { MessageBox.Show("Xem lại đơn giá"); } } else { MessageBox.Show("Yêu cầu nhập đầy đủ thông tin sản phẩm"); } } catch (ArgumentNullException) { MessageBox.Show("Không được để rỗng đơn giá"); } catch (FormatException) { MessageBox.Show("Đơn giá phải là số"); } catch (OverflowException) { MessageBox.Show("Đơn giá vượt quá giới hạn lưu trữ"); } catch (NullReferenceException) { MessageBox.Show("Dữ liệu không được bỏ trống"); } }
public void load() { txtmaLoai.Text = CServices.taoMa <LoaiSanPham>(CLoaiSanPham_BUS.DSLoaiSP()); a = null; }
private void btnBoChon_Click(object sender, RoutedEventArgs e) { txtmaLoai.Text = CServices.taoMa <LoaiSanPham>(CLoaiSanPham_BUS.DSLoaiSP()); txttenLoai.Text = ""; a = null; }