private List <CBangXepHangNguyenLieuNhap> getDSNguyenLieuXuat(int month) { List <CBangXepHangNguyenLieuNhap> dsNguyenLieuXuat = new List <CBangXepHangNguyenLieuNhap>(); List <NguyenLieu> nguyenLieus = new List <NguyenLieu>(); List <PhieuXuatNguyenLieu> phieuXuatNguyenLieus = new List <PhieuXuatNguyenLieu>(); nguyenLieus = CNguyenLieu_BUS.to_List(); phieuXuatNguyenLieus = CPhieuXuatNguyenLieu_BUS.toListInMonth(month); if (phieuXuatNguyenLieus.Count() > 0) { foreach (NguyenLieu nguyenLieu in nguyenLieus) { foreach (PhieuXuatNguyenLieu phieuXuat in phieuXuatNguyenLieus) { foreach (ChiTietPhieuXuat chiTiet in phieuXuat.ChiTietPhieuXuats.ToList()) { if (chiTiet.ChiTietNguyenLieu.maNguyenLieu == nguyenLieu.maNguyenLieu) { int soLuong = chiTiet.soLuong.Value; double donGia = chiTiet.donGia.Value; dsNguyenLieuXuat.Add(new CBangXepHangNguyenLieuNhap( nguyenLieu.maNguyenLieu, nguyenLieu.tenNguyenLieu, soLuong, donGia)); } } } } } return(dsNguyenLieuXuat); }
private void cmbLocSanPham_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (cmbLocSanPham.SelectedItem != null) { string tenSanPham = cmbLocSanPham.SelectedItem.ToString(); if (tenSanPham != null && tenSanPham != "") { // Hiển thị bảng thống kê sản phẩm SanPham sanPham = CSanPham_BUS.findSPbyTen(tenSanPham); if (sanPham.tenSanPham != null) { List <CBangXepHangSanPham> list = new List <CBangXepHangSanPham>(); int soLuongBan = CHoaDon_BUS.demSoLuongSanPham(sanPham.maSanPham, monthSelect); list.Add(new CBangXepHangSanPham( sanPham.maSanPham, sanPham.tenSanPham.ToString(), soLuongBan, sanPham.donGia.Value)); showListSanPham(list); } // Hiển thị bảng thống kê phiếu nhập nguyên liệu List <CBangXepHangNguyenLieuNhap> dsNguyenLieuNhap = new List <CBangXepHangNguyenLieuNhap>(); List <PhieuNhapNguyenLieu> phieuNhapNguyenLieus = new List <PhieuNhapNguyenLieu>(); phieuNhapNguyenLieus = CPhieuNhapNguyenLieu_BUS.toListInMonth(monthSelect); if (phieuNhapNguyenLieus.Count() > 0) { foreach (ThanhPhan thanhPhan in sanPham.ThanhPhans.Where(x => x.trangThai == 0).ToList()) { foreach (PhieuNhapNguyenLieu phieuNhap in phieuNhapNguyenLieus) { foreach (ChiTietPhieuNhap chiTiet in phieuNhap.ChiTietPhieuNhaps.ToList()) { if (chiTiet.ChiTietNguyenLieu.maNguyenLieu == thanhPhan.maNguyenLieu) { int soLuong = chiTiet.soLuong.Value; double donGia = chiTiet.donGia.Value; dsNguyenLieuNhap.Add(new CBangXepHangNguyenLieuNhap( thanhPhan.maNguyenLieu, thanhPhan.NguyenLieu.tenNguyenLieu, soLuong, donGia)); } } } } showListNguyenLieuNhap(dsNguyenLieuNhap); } // Hiển thị bảng thống kê phiếu xuất nguyên liệu List <CBangXepHangNguyenLieuNhap> dsNguyenLieuXuat = new List <CBangXepHangNguyenLieuNhap>(); List <PhieuXuatNguyenLieu> phieuXuatNguyenLieus = new List <PhieuXuatNguyenLieu>(); phieuXuatNguyenLieus = CPhieuXuatNguyenLieu_BUS.toListInMonth(monthSelect); if (phieuXuatNguyenLieus.Count() > 0) { foreach (ThanhPhan thanhPhan in sanPham.ThanhPhans.Where(x => x.trangThai == 0).ToList()) { foreach (PhieuXuatNguyenLieu phieuXuat in phieuXuatNguyenLieus) { foreach (ChiTietPhieuXuat chiTiet in phieuXuat.ChiTietPhieuXuats.ToList()) { if (chiTiet.ChiTietNguyenLieu.maNguyenLieu == thanhPhan.maNguyenLieu) { int soLuong = chiTiet.soLuong.Value; double donGia = chiTiet.donGia.Value; dsNguyenLieuXuat.Add(new CBangXepHangNguyenLieuNhap( thanhPhan.maNguyenLieu, thanhPhan.NguyenLieu.tenNguyenLieu, soLuong, donGia)); } } } } showListNguyenLieuXuat(dsNguyenLieuXuat); } } else { MessageBox.Show("Không lấy được nguyên liệu đã chọn"); return; } } }