public void ArrTongHangXuat() { ArrBCXH = new Entities.BCXuatHangTheoNhomHang[NhomHang.Length]; for (int i = 0; i < NhomHang.Length; i++) { LayChiTiet_HangHoaXuat_TheoNhomHang(NhomHang[i].MaNhomHang, NhomHang[i].TenNhomHang); LayChiTiet_SoLuong_HangHoaXuat_TheoKho(); ArrBCXH[i] = new Entities.BCXuatHangTheoNhomHang(); int TongHangHoaXuatTheoKho = 0; for (int j = 0; j < ctBCXH.Length; j++) { TongHangHoaXuatTheoKho = TongHangHoaXuatTheoKho + ctBCXH[j].TongSoLuongXuat; } ArrBCXH[i].MaNhomHang = NhomHang[i].MaNhomHang; ArrBCXH[i].TenNhomHang = NhomHang[i].TenNhomHang; ArrBCXH[i].TongSoLuongXuat = TongHangHoaXuatTheoKho; ctBCXH = null; } }
private void frmBCXuatHangTheoNhomHang_Load(object sender, EventArgs e) { try { for (int i = 0; i < cbbthang.Items.Count; i++) { if (cbbthang.Items[i].ToString() == datesv.Month.ToString()) { cbbthang.SelectedIndex = i; break; } } for (int i = 0; i < cbbnam.Items.Count; i++) { if (cbbnam.Items[i].ToString() == datesv.Year.ToString()) { cbbnam.SelectedIndex = i; break; } } LayNhomHang(); //Entities.NhomHang[] K_nhomhang = this.NhomHang; LayNgay(); DateTime K_BatDau = this.BatDau; DateTime K_KetThuc = this.KetThuc; GoiHang(); ChiTietGoiHang(); //Entities.GoiHang[] K_goihang = this.goihang; //Entities.ChiTietGoiHang[] K_chitietgoihang = this.chitietgoihang; LayHangHoa(); //Entities.HangHoa[] K_hanghoa = this.HangHoa; LayHDBanHang(); //Entities.HDBanHang[] K_HDBanHang = this.HDBanHang; LayChiTiet_HDBanHang(); //Entities.ChiTietHDBanHang[] K_ctHDBanHang = this.ctHDBanHang; LayPhieuDieuChuyenKhoNoiBo(); //Entities.PhieuDieuChuyenKhoNoiBo[] K_PDieuChuyen = this.PDieuChuyen; LayChiTiet_PhieuDieuChuyenKho(); //Entities.ChiTietPhieuDieuChuyenKho[] K_ctPDCK = this.ctPDCK; LayPhieuXuatHuy(); //Entities.PhieuXuatHuy[] K_PXuatHuy = this.PXuatHuy; LayChiTiet_XuatHuy(); //Entities.ChiTietXuatHuy[] K_ctPXuatHuy = this.ctPXuatHuy; LayTraLaiNCC(); //Entities.TraLaiNCC[] K_TraLaiNCC = this.TraLaiNCC; LayChiTiet_TraLaiNCC(); //Entities.ChiTietTraLaiNhaCungCap[] K_ctTraLaiNCC = this.ctTraLaiNCC; LayChiTiet_HangHoaXuat(); ArrTongHangXuat(); ///////////////////////////////MRK FIX List<Entities.BCXuatHangTheoNhomHang> tem0 = new List<BCXuatHangTheoNhomHang>(); double tong0 = 0; foreach (Entities.BCXuatHangTheoNhomHang item in ArrBCXH) { tong0 += item.TongSoLuongXuat; tem0.Add(item); } Entities.BCXuatHangTheoNhomHang tem1 = new BCXuatHangTheoNhomHang(); tem1.TenNhomHang = "Tổng: "; tem1.TongSoLuongXuat = (int)tong0; tem0.Add(tem1); ////////////////////////////////////// //dtgvhienthi.DataSource = ArrBCXH; dtgvhienthi.DataSource = tem0.ToArray(); FixDatagridview(); ctBCXH_Search = ArrBCXH; if (ArrBCXH.Length > 0) { tsslchitiet.Enabled = true; tsslPdf.Enabled = true; tsslExcel.Enabled = true; tsslWord.Enabled = true; } else { tsslchitiet.Enabled = false; tsslPdf.Enabled = false; tsslExcel.Enabled = false; tsslWord.Enabled = false; } } catch { } }
private void btnhienthi_Click(object sender, EventArgs e) { if (KiemTra()) { LayNhomHang(); LayNgay(); LayHangHoa(); GoiHang(); ChiTietGoiHang(); LayHDBanHang(); LayChiTiet_HDBanHang(); LayPhieuDieuChuyenKhoNoiBo(); LayChiTiet_PhieuDieuChuyenKho(); LayPhieuXuatHuy(); LayChiTiet_XuatHuy(); LayTraLaiNCC(); LayChiTiet_TraLaiNCC(); LayChiTiet_HangHoaXuat(); ArrTongHangXuat(); ///////////////////////////////MRK FIX List<Entities.BCXuatHangTheoNhomHang> tem0 = new List<BCXuatHangTheoNhomHang>(); double tong0 = 0; foreach (Entities.BCXuatHangTheoNhomHang item in ArrBCXH) { if (item == null) { continue; } tong0 += item.TongSoLuongXuat; tem0.Add(item); } Entities.BCXuatHangTheoNhomHang tem1 = new BCXuatHangTheoNhomHang(); tem1.TenNhomHang = "Tổng: "; tem1.TongSoLuongXuat = (int)tong0; tem0.Add(tem1); ////////////////////////////////////// //dtgvhienthi.DataSource = ArrBCXH; dtgvhienthi.DataSource = tem0.ToArray(); FixDatagridview(); ctBCXH_Search = ArrBCXH; if (ArrBCXH.Length > 0) { tsslchitiet.Enabled = true; tsslPdf.Enabled = true; tsslExcel.Enabled = true; tsslWord.Enabled = true; } else { tsslchitiet.Enabled = false; tsslPdf.Enabled = false; tsslExcel.Enabled = false; tsslWord.Enabled = false; } } }
private void txtTimKiem_TextChanged(object sender, EventArgs e) { if (rdbTen.Checked == true) { if (ctBCXH_Search == null) { BCXuatHangTheoNhomHang[] tkkt = new BCXuatHangTheoNhomHang[0]; dtgvhienthi.DataSource = tkkt; FixDatagridview(); tsslchitiet.Enabled = false; tsslExcel.Enabled = false; tsslPdf.Enabled = false; tsslWord.Enabled = false; } else if (ctBCXH_Search != null) { if (txtTimKiem.Text.Length == 0) { BCXuatHangTheoNhomHang[] tkkt = new BCXuatHangTheoNhomHang[0]; dtgvhienthi.DataSource = tkkt; FixDatagridview(); tsslchitiet.Enabled = false; tsslExcel.Enabled = false; tsslPdf.Enabled = false; tsslWord.Enabled = false; } else { int ctBCXH_Search_count = 0; for (int i = 0; i < ctBCXH_Search.Length; i++) { int index = -1; index = ctBCXH_Search[i].TenNhomHang.ToLower().IndexOf(txtTimKiem.Text.Trim().ToLower()); if (index >= 0) { ctBCXH_Search_count++; } } BCXuatHangTheoNhomHang[] ctBCXH_Search1 = new BCXuatHangTheoNhomHang[ctBCXH_Search_count]; ctBCXH_Search_count = 0; for (int i = 0; i < ctBCXH_Search.Length; i++) { int index = -1; index = ctBCXH_Search[i].TenNhomHang.ToLower().IndexOf(txtTimKiem.Text.Trim().ToLower()); if (index >= 0) { ctBCXH_Search1[ctBCXH_Search_count] = ctBCXH_Search[i]; ctBCXH_Search_count++; } } if (ctBCXH_Search_count == 0) { tsslchitiet.Enabled = false; tsslExcel.Enabled = false; tsslPdf.Enabled = false; tsslWord.Enabled = false; } else { tsslchitiet.Enabled = true; tsslExcel.Enabled = true; tsslPdf.Enabled = true; tsslWord.Enabled = true; } ///////////////////////////////MRK FIX List<Entities.BCXuatHangTheoNhomHang> tem0 = new List<BCXuatHangTheoNhomHang>(); double tong0 = 0; foreach (Entities.BCXuatHangTheoNhomHang item in ctBCXH_Search1) { tong0 += item.TongSoLuongXuat; tem0.Add(item); } Entities.BCXuatHangTheoNhomHang tem1 = new BCXuatHangTheoNhomHang(); tem1.TenNhomHang = "Tổng: "; tem1.TongSoLuongXuat = (int)tong0; tem0.Add(tem1); ////////////////////////////////////// dtgvhienthi.DataSource = tem0.ToArray(); //dtgvhienthi.DataSource = ctBCXH_Search1; FixDatagridview(); } } } else if (rdbMa.Checked == true) { if (ctBCXH_Search == null) { BCXuatHangTheoNhomHang[] tkkt = new BCXuatHangTheoNhomHang[0]; dtgvhienthi.DataSource = tkkt; FixDatagridview(); tsslchitiet.Enabled = false; tsslExcel.Enabled = false; tsslPdf.Enabled = false; tsslWord.Enabled = false; } else if (ctBCXH_Search != null) { if (txtTimKiem.Text.Length == 0) { BCXuatHangTheoNhomHang[] tkkt = new BCXuatHangTheoNhomHang[0]; dtgvhienthi.DataSource = tkkt; FixDatagridview(); tsslchitiet.Enabled = false; tsslExcel.Enabled = false; tsslPdf.Enabled = false; tsslWord.Enabled = false; } else { int ctBCXH_Search_count = 0; for (int i = 0; i < ctBCXH_Search.Length; i++) { int index = -1; index = ctBCXH_Search[i].MaNhomHang.ToLower().IndexOf(txtTimKiem.Text.Trim().ToLower()); if (index >= 0) { ctBCXH_Search_count++; } } BCXuatHangTheoNhomHang[] ctBCXH_Search1 = new BCXuatHangTheoNhomHang[ctBCXH_Search_count]; ctBCXH_Search_count = 0; for (int i = 0; i < ctBCXH_Search.Length; i++) { int index = -1; index = ctBCXH_Search[i].MaNhomHang.ToLower().IndexOf(txtTimKiem.Text.Trim().ToLower()); if (index >= 0) { ctBCXH_Search1[ctBCXH_Search_count] = ctBCXH_Search[i]; ctBCXH_Search_count++; } } if (ctBCXH_Search_count == 0) { tsslchitiet.Enabled = false; tsslExcel.Enabled = false; tsslPdf.Enabled = false; tsslWord.Enabled = false; } else { tsslchitiet.Enabled = true; tsslExcel.Enabled = true; tsslPdf.Enabled = true; tsslWord.Enabled = true; } ///////////////////////////////MRK FIX List<Entities.BCXuatHangTheoNhomHang> tem0 = new List<BCXuatHangTheoNhomHang>(); double tong0 = 0; foreach (Entities.BCXuatHangTheoNhomHang item in ctBCXH_Search1) { tong0 += item.TongSoLuongXuat; tem0.Add(item); } Entities.BCXuatHangTheoNhomHang tem1 = new BCXuatHangTheoNhomHang(); tem1.TenNhomHang = "Tổng: "; tem1.TongSoLuongXuat = (int)tong0; tem0.Add(tem1); ////////////////////////////////////// dtgvhienthi.DataSource = tem0.ToArray(); //dtgvhienthi.DataSource = ctBCXH_Search1; FixDatagridview(); } } } }
private void rdbTatCa_CheckedChanged(object sender, EventArgs e) { if (rdbTatCa.Checked == true) { txtTimKiem.Text = ""; if (ctBCXH_Search.Length > 0) { tsslchitiet.Enabled = true; tsslPdf.Enabled = true; tsslExcel.Enabled = true; tsslWord.Enabled = true; } else { tsslchitiet.Enabled = false; tsslPdf.Enabled = false; tsslExcel.Enabled = false; tsslWord.Enabled = false; } ///////////////////////////////MRK FIX List<Entities.BCXuatHangTheoNhomHang> tem0 = new List<BCXuatHangTheoNhomHang>(); double tong0 = 0; foreach (Entities.BCXuatHangTheoNhomHang item in ctBCXH_Search) { tong0 += item.TongSoLuongXuat; tem0.Add(item); } Entities.BCXuatHangTheoNhomHang tem1 = new BCXuatHangTheoNhomHang(); tem1.TenNhomHang = "Tổng: "; tem1.TongSoLuongXuat = (int)tong0; tem0.Add(tem1); ////////////////////////////////////// dtgvhienthi.DataSource = tem0.ToArray(); //dtgvhienthi.DataSource = ctBCXH_Search; FixDatagridview(); } }