Пример #1
0
        private void simpleButtonSuaMau_Click(object sender, EventArgs e)
        {
            DataTable dtReport = _data.GetDataForPrint(_arrIndex[0]);

            if (dtReport == null)
            {
                return;
            }
            DevExpress.XtraReports.UI.XtraReport rptTmp = null;
            string path;

            if (Config.GetValue("DuongDanBaoCao") != null)
            {
                path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("Package").ToString() + "\\" + _reportFile + ".repx";
            }
            else
            {
                path = Application.StartupPath + "\\Reports\\" + Config.GetValue("Package").ToString() + "\\" + _reportFile + ".repx";
            }
            string pathTmp;

            if (Config.GetValue("DuongDanBaoCao") != null)
            {
                pathTmp = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("Package").ToString() + "\\" + _reportFile + ".repx";
            }
            else
            {
                pathTmp = Application.StartupPath + "\\" + Config.GetValue("Package").ToString() + "\\Reports\\template.repx";
            }
            if (System.IO.File.Exists(path))
            {
                rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true);
            }
            else if (System.IO.File.Exists(pathTmp))
            {
                rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(pathTmp, true);
            }
            else
            {
                rptTmp = new DevExpress.XtraReports.UI.XtraReport();
            }
            if (rptTmp != null)
            {
                rptTmp.DataSource = dtReport;
                XRDesignFormEx designForm = new XRDesignFormEx();
                designForm.OpenReport(rptTmp);
                if (System.IO.File.Exists(path))
                {
                    designForm.FileName = path;
                }
                designForm.KeyPreview = true;
                designForm.KeyDown   += new KeyEventHandler(designForm_KeyDown);
                designForm.Show();
            }
        }
Пример #2
0
        private void simpleButtonSuaMau_Click(object sender, EventArgs e)
        {
            if (!bool.Parse(Config.GetValue("Admin").ToString()))
            {
                return;
            }

            int       index    = _arrIndex[0];
            DataTable dtReport = new DataTable();

            try
            {
                if (_Script == string.Empty)
                {
                    dtReport = _data.GetDataForPrint(index);
                }
                else
                {
                    dtReport = _data.GetDataForPrint(index, _Script);
                }
            }
            catch { }
            if (dtReport == null)
            {
                return;
            }
            dtReport = AddRecordToData(dtReport);

            DevExpress.XtraReports.UI.XtraReport rptTmp = null;
            string path = "";

            if (Config.GetValue("DuongDanBaoCao") != null)
            {
                path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("DbName").ToString() + "\\" + _reportFile + ".repx";
            }
            else
            {
                path = Application.StartupPath + "\\Reports\\" + Config.GetValue("DbName").ToString() + "\\" + _reportFile + ".repx";
            }
            if (drMau == null || (drMau != null && drMau["FileName"] == DBNull.Value))
            {
                string pathTmp;
                if (Config.GetValue("DuongDanBaoCao") != null)
                {
                    pathTmp = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("DbName").ToString() + "\\" + _reportFile + ".repx";
                }
                else
                {
                    pathTmp = Application.StartupPath + "\\" + Config.GetValue("DbName").ToString() + "\\Reports\\template.repx";
                }
                if (System.IO.File.Exists(path))
                {
                    rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true);
                }
                else if (System.IO.File.Exists(pathTmp))
                {
                    rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(pathTmp, true);
                }
                else
                {
                    rptTmp = new DevExpress.XtraReports.UI.XtraReport();
                }
            }
            else
            {
                System.IO.MemoryStream ms = new System.IO.MemoryStream(drMau["FileName"] as byte[]);
                rptTmp = XtraReport.FromStream(ms, true);
            }
            if (rptTmp != null)
            {
                rptTmp.DataSource = dtReport;
                if (drMau != null)
                {
                    rptTmp.Tag = drMau;
                }
                XRDesignFormEx designForm = new XRDesignFormEx();
                designForm.OpenReport(rptTmp);
                designForm.Tag = drMau;
                if (System.IO.File.Exists(path))
                {
                    designForm.FileName = path;
                }
                designForm.KeyPreview  = true;
                designForm.KeyDown    += new KeyEventHandler(designForm_KeyDown);
                designForm.FormClosed += designForm_FormClosed;
                designForm.Show();
            }
        }