Beispiel #1
0
        private void simplePrint_Click(object sender, EventArgs e)
        {
            if (Config.GetValue("isDemo").ToString() == "1")
            {
                return;
            }
            DevExpress.XtraReports.UI.XtraReport rptTmp = null;
            string reportFile, title;

            if (lcisysFormReport.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Always)
            {
                DataTable dtFormReport = lookUpEditsysFormReport.Properties.DataSource as DataTable;
                DataRow   dr           = dtFormReport.Rows[lookUpEditsysFormReport.ItemIndex];
                reportFile = checkEditNgoaiTe.Checked ? dr["ReportFile2"].ToString() : dr["ReportFile"].ToString();
                title      = checkEditNgoaiTe.Checked ? dr["ReportName2"].ToString() : dr["ReportName"].ToString();
            }
            else
            {
                reportFile = checkEditNgoaiTe.Checked ? _data.DrTable["ReportFile2"].ToString() : _data.DrTable["ReportFile"].ToString();
                title      = checkEditNgoaiTe.Checked ? _data.DrTable["ReportName2"].ToString() : _data.DrTable["ReportName"].ToString();
            }

            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";
            }
            if (System.IO.File.Exists(path))
            {
                //rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true);
                //rptTmp.DataSource = gridViewReport.DataSource;
                //if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2)
                //    (rptTmp.DataSource as DataView).RowFilter = "InBaoCao = 1";
                //XRControl xrcTitle = rptTmp.FindControl("title", true);
                //if (xrcTitle != null)
                //    xrcTitle.Text = title;

                //SetVariables(rptTmp);
                //rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" };
                ////rptTmp.Print("\\\\vytc\\Canon LBP2900");
                //rptTmp.Print(Config.GetValue("PrinterName").ToString());
                CDTControl.Printing re = new CDTControl.Printing(gridViewReport.DataSource, path);
                re.Print();
            }
            else
            {
                rptTmp.Print(Config.GetValue("PrinterName").ToString());
            }
            if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2)
            {
                gridViewReport.ActiveFilterString = "";
            }
        }
Beispiel #2
0
        public bool Print()
        {
            if (rptTmp == null)
            {
                return(false);
            }
            SetVariables(rptTmp);
            rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" };
            rptTmp.DataSource       = db;

            if (ExitPrinter(Config.GetValue("PrinterName").ToString()))
            {
                rptTmp.Print(Config.GetValue("PrinterName").ToString());
                return(true);
            }
            else
            {
                MessageBox.Show("Không tìm thấy máy in!");
                return(false);
            }
        }
Beispiel #3
0
        ///   <param name="rptTmp">DevReport file.</param>
        ///   <param name="_Script">Script get data for report.</param>
        ///   <param name="index">Index Row which get data</param>
        ///   <param name="isPrint">Print or Preview</param>
        ///   <param name="j">Liên Parameter</param>
        private void PrintPreview(DevExpress.XtraReports.UI.XtraReport rptTmp, string _Script, int index, int isPrint, int j)
        {
            DataTable dtReport = new DataTable();

            try
            {
                if (_Script == string.Empty)
                {
                    dtReport = _data.GetDataForPrint(index);
                    DataMasterDetail dta = (_data as DataMasterDetail);
                    if (dta != null)
                    {
                        richTextBox1.Text = dta.PrintSQL;
                    }
                }
                else
                {
                    dtReport = _data.GetDataForPrint(index, _Script);
                    DataMasterDetail dta = (_data as DataMasterDetail);
                    if (dta != null)
                    {
                        richTextBox1.Text = dta.PrintSQL;
                    }
                }
            }
            catch { }
            dtReport = AddRecordToData(dtReport);
            DevExpress.XtraReports.UI.XRControl xrcTitle = rptTmp.FindControl("title", true);
            if (xrcTitle != null)
            {
                xrcTitle.Text = textEditTitle.Text.ToUpper();
            }
            DevExpress.XtraReports.UI.XRControl xrcSoCTGoc = rptTmp.FindControl("SoCTGoc", true);
            if (xrcSoCTGoc != null)
            {
                xrcSoCTGoc.Text = textEditSoCTGoc.Text;
            }
            //SetVariables(rptTmp);


            if (dtReport == null)
            {
                return;
            }
            rptTmp.DataSource       = dtReport;
            rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" };
            SetVariables(rptTmp);
            if (Config.GetValue("Language").ToString() == "1")
            {
                Translate(rptTmp);
            }
            SetVariables(rptTmp, j);
            rptTmp.ShowPrintMarginsWarning = false;
            if (isPrint == 0)
            {
                rptTmp.Print();
                //Update LanIn
            }
            else if (isPrint == 1)
            {
                rptTmp.ShowPreview();
            }
            else if (isPrint == 2)
            {
                SaveFileDialog fd = new SaveFileDialog();
                fd.Filter       = "(*.xls)|*.xls";
                fd.AddExtension = true;
                fd.ShowDialog();
                if (fd.FileName != string.Empty)
                {
                    rptTmp.ExportToXls(fd.FileName);
                }
            }
        }
Beispiel #4
0
        private void PrintOrPreview(bool isPrint, int j)
        {
            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";
            }
            if (System.IO.File.Exists(path))
            {
                for (int i = 0; i < _arrIndex.Length; i++)
                {
                    int       index    = _arrIndex[i];
                    DataTable dtReport = _data.GetDataForPrint(index);
                    if (_data.mt.Columns.Contains("PrintIndex"))
                    {
                        _reportFile = tbMau.Rows[int.Parse(_data.mt.Rows[index]["PrintIndex"].ToString())]["RFile"].ToString();
                    }
                    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";
                    }

                    rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true);
                    DevExpress.XtraReports.UI.XRControl xrcTitle = rptTmp.FindControl("title", true);
                    if (xrcTitle != null)
                    {
                        xrcTitle.Text = textEditTitle.Text.ToUpper();
                    }
                    DevExpress.XtraReports.UI.XRControl xrcSoCTGoc = rptTmp.FindControl("SoCTGoc", true);
                    if (xrcSoCTGoc != null)
                    {
                        xrcSoCTGoc.Text = textEditSoCTGoc.Text;
                    }
                    //SetVariables(rptTmp);


                    if (dtReport == null)
                    {
                        continue;
                    }
                    rptTmp.DataSource       = dtReport;
                    rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" };
                    SetVariables(rptTmp);
                    if (Config.GetValue("Language").ToString() == "1")
                    {
                        Translate(rptTmp);
                    }
                    SetVariables(rptTmp, j);
                    if (isPrint)
                    {
                        rptTmp.Print();
                    }
                    else
                    {
                        rptTmp.ShowPreview();
                    }
                }
            }
            else
            {
                XtraMessageBox.Show("Không tìm thấy file báo cáo " + _reportFile);
            }
        }
Beispiel #5
0
        ///   <param name="rptTmp">DevReport file.</param>
        ///   <param name="_Script">Script get data for report.</param>
        ///   <param name="index">Index Row which get data</param>
        ///   <param name="isPrint">Print or Preview</param>
        ///   <param name="j">Liên Parameter</param>
        private void PrintPreview(DevExpress.XtraReports.UI.XtraReport rptTmp, string _Script, int index, bool isPrint, int j)
        {
            DataTable dtReport = new DataTable();

            try
            {
                if (_Script == string.Empty)
                {
                    dtReport = _data.GetDataForPrint(index);
                    DataMasterDetail dta = (_data as DataMasterDetail);
                    if (dta != null)
                    {
                        richTextBox1.Text = dta.PrintSQL;
                    }
                }
                else
                {
                    dtReport = _data.GetDataForPrint(index, _Script);
                    DataMasterDetail dta = (_data as DataMasterDetail);
                    if (dta != null)
                    {
                        richTextBox1.Text = dta.PrintSQL;
                    }
                }
            }
            catch { }
            dtReport = AddRecordToData(dtReport);
            DevExpress.XtraReports.UI.XRControl xrcTitle = rptTmp.FindControl("title", true);
            if (xrcTitle != null)
            {
                xrcTitle.Text = textEditTitle.Text.ToUpper();
            }
            DevExpress.XtraReports.UI.XRControl xrcSoCTGoc = rptTmp.FindControl("SoCTGoc", true);
            if (xrcSoCTGoc != null)
            {
                xrcSoCTGoc.Text = textEditSoCTGoc.Text;
            }
            //SetVariables(rptTmp);


            if (dtReport == null)
            {
                return;
            }
            rptTmp.DataSource       = dtReport;
            rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" };
            SetVariables(rptTmp);
            if (Config.GetValue("Language").ToString() == "1")
            {
                Translate(rptTmp);
            }
            SetVariables(rptTmp, j);
            if (isPrint)
            {
                rptTmp.Print();
            }
            else
            {
                rptTmp.ShowPreview();
            }
        }