Esempio n. 1
0
        private void cmdPrint_Click(object sender, EventArgs e)
        {
            try
            {
                //Truyền dữ liệu vào datatable
                DataTable m_dtReport = BAOCAO_THUOC.ThuocLaythongtinInphieuDutruthuoc(Utility.Int16Dbnull(cboKhoxuat.SelectedValue, -1), KIEU_THUOC_VT);
                THU_VIEN_CHUNG.CreateXML(m_dtReport, "thuoc_PhieuDutru.xml");

                if (m_dtReport.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Không tìm thấy dữ liệu cho báo cáo", "Thông báo", MessageBoxIcon.Warning);
                    return;
                }

                //Add logo vào datatable
                Utility.UpdateLogotoDatatable(ref m_dtReport);
                string tieude = "", reportname = "";
                string mabaocao = "thuoc_PhieuDutru";
                var    crpt     = Utility.GetReport(mabaocao, ref tieude, ref reportname);
                if (crpt == null)
                {
                    return;
                }

                //baocaO_TIEUDE1.TIEUDE
                frmPrintPreview objForm = new frmPrintPreview(tieude, crpt, true, m_dtReport.Rows.Count <= 0 ? false : true);
                crpt.SetDataSource(m_dtReport);

                objForm.mv_sReportFileName = System.IO.Path.GetFileName(reportname);
                objForm.mv_sReportCode     = mabaocao;
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(globalVariables.SysDate));
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "txtTrinhky", "");
                Utility.SetParameterValue(crpt, "tenkho", cboKhoxuat.Text);


                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception exception)
            {
                Utility.ShowMsg("Lỗi:" + exception.Message);
            }
        }