private void btnXemBaoCao_Click(object sender, EventArgs e) { var tb = new HideNotifications(); cbxThang.Text = thang.ToString(); numNam.Value = nam; if (nam <= DateTime.Now.Year) { if (thang <= DateTime.Now.Month) { rptBaoCaoSuDungThuoc report = new rptBaoCaoSuDungThuoc(); report.DataSource = BaoCaoThuoc.LayDuLieu(thang, nam); report.BinData(); ReportPrintTool tool = new ReportPrintTool(report); report.ShowPreviewDialog(); } else { lblThongBao.ForeColor = Color.Red; lblThongBao.Text = "Tháng không tồn tại"; tb.stt(lblThongBao); } } else { lblThongBao.ForeColor = Color.Red; lblThongBao.Text = "Năm không tồn tại"; tb.stt(lblThongBao); numNam.Focus(); } }
//Hàm LoadData để load lại dữ liệu khi có sự thay đổi public void LoatData() { cbxThang.Text = thang.ToString(); numNam.Value = nam; dgvDSThuoc.DataSource = BaoCaoThuoc.LayDuLieu(thang, nam); dgvDSThuoc.Columns["TenThuoc"].HeaderText = "Thuốc"; dgvDSThuoc.Columns["DonVi"].HeaderText = "Đơn vị tính"; dgvDSThuoc.Columns["TongSoLuong"].HeaderText = "Số lượng"; dgvDSThuoc.Columns["SoLanDung"].HeaderText = "Số lần dùng"; dgvDSThuoc.Columns["TenThuoc"].Width = 200; dgvDSThuoc.Columns["DonVi"].Width = 80; dgvDSThuoc.Columns["TongSoLuong"].Width = 200; dgvDSThuoc.Columns["SoLanDung"].Width = 200; }