public bool ThemChiTietBaoCaoTonKho(ChiTietBaoCaoTonKho ct) { return _ChiTietBaoCaoTonKhoDAL.ThemChiTietBaoCaoTonKho(ct); }
private void sbLapBaoCao_Click(object sender, EventArgs e) { string thoigian = DateTime.Now.ToString("MM/dd/yyyy"); DataTable dt = gcDanhSachBaoCao.DataSource as DataTable; bool isExist = false; int samerow = 0; if (dt != null) { for (int j = 0; j < dt.Rows.Count; j++) { DateTime thoigiandalap = Convert.ToDateTime(dt.Rows[j].ItemArray[1].ToString()); if (thoigiandalap.ToString("MM/dd/yyyy") == thoigian) { isExist = true; samerow = j; break; } } } if (!isExist) { //truong hop bao cao chua lap string mabaocao = _BaoCaoTonKhoBUS.LapBaoCao(thoigian).ToString(); DataTable cttonkho = _ChiTietBaoCaoTonKhoBUS.LayThongTinTonKho(); if (cttonkho != null && cttonkho.Rows.Count > 0) { for (int i = 0; i < cttonkho.Rows.Count; i++) { ChiTietBaoCaoTonKho ct = new ChiTietBaoCaoTonKho(); ct.MaBCTK = mabaocao; ct.MaMatHang = cttonkho.Rows[i].ItemArray[0].ToString(); ct.SoLuongTon = Convert.ToInt16(cttonkho.Rows[i].ItemArray[3].ToString()); _ChiTietBaoCaoTonKhoBUS.ThemChiTietBaoCaoTonKho(ct); } } } else { DialogResult dr = MessageBox.Show("Có Báo Cáo Đã Được Lập Trong Hôm Nay\n Bạn Có muốn Lập Lại Báo Cáo?\n Mọi Thông Tin Của Báo Cáo Này Sẽ Được Làm Lại", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { string mabaocao = dt.Rows[samerow].ItemArray[0].ToString(); _ChiTietBaoCaoTonKhoBUS.XoaChiTietBaoCaoTonKho(mabaocao); //them lai chi tiet bao cao ton kho DataTable cttonkho = _ChiTietBaoCaoTonKhoBUS.LayThongTinTonKho(); if (cttonkho != null && cttonkho.Rows.Count > 0) { for (int i = 0; i < cttonkho.Rows.Count; i++) { ChiTietBaoCaoTonKho ct = new ChiTietBaoCaoTonKho(); ct.MaBCTK = mabaocao; ct.MaMatHang = cttonkho.Rows[i].ItemArray[0].ToString(); ct.TenMatHang = cttonkho.Rows[i].ItemArray[1].ToString(); ct.NhaCungCap = cttonkho.Rows[i].ItemArray[2].ToString(); ct.SoLuongTon = Convert.ToInt32(cttonkho.Rows[i].ItemArray[3].ToString()); _ChiTietBaoCaoTonKhoBUS.ThemChiTietBaoCaoTonKho(ct); } } } } LayDanhSachBaoCao(); }