Example #1
0
        private void Print()
        {
            string path;

            DevExpress.XtraReports.UI.XtraReport rptTmp = null;
            if (Config.GetValue("DuongDanBaoCao") != null)
            {
                path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("Package").ToString() + "\\" + "billPOS.repx";
            }
            else
            {
                path = Application.StartupPath + "\\Reports\\" + Config.GetValue("Package").ToString() + "\\" + "billPOS.repx";
            }

            if (System.IO.File.Exists(path))
            {
                rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true);
            }
            else
            {
                rptTmp = new DevExpress.XtraReports.UI.XtraReport();
            }

            if (rptTmp != null)
            {
                rptTmp.DataSource       = _cban.tb;
                rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" };
                SetVariables(rptTmp);
                DevExpress.XtraReports.UI.XRControl xrcTongTien = rptTmp.FindControl("TongTien", true);
                if (xrcTongTien != null)
                {
                    xrcTongTien.Text = double.Parse(_cban.tTien.ToString()).ToString("### ### ### ###");
                }
                //DevExpress.XtraReports.UI.XRControl xrcDatt = rptTmp.FindControl("DaTT", true);
                //if (xrcDatt != null)
                //    xrcDatt.Text = double.Parse(cDaTT.EditValue.ToString()).ToString("### ### ### ###");
                //DevExpress.XtraReports.UI.XRControl xrcConlai = rptTmp.FindControl("Conlai", true);
                //if (xrcConlai != null)
                //    xrcConlai.Text = double.Parse(cConlai.EditValue.ToString()).ToString("### ### ### ###");
                DevExpress.XtraReports.UI.XRControl xrcID = rptTmp.FindControl("ID", true);
                if (xrcID != null)
                {
                    xrcID.Text = _cban.id;
                }
                //DevExpress.XtraReports.UI.XRControl xrbID = rptTmp.FindControl("BCID", true);
                //if (xrbID != null)
                //    xrbID.Text = txtCode.Text;

                ////rptTmp.Print();
                rptTmp.Print();
            }
        }
Example #2
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);
                }
            }
        }
Example #3
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);
            }
        }
Example #4
0
        private void Print(int i)
        {
            string path;
            string rfile = "billPOS.repx";

            if (i == 1)
            {
                rfile = "billBEP.repx";
            }
            DevExpress.XtraReports.UI.XtraReport rptTmp = null;
            if (Config.GetValue("DuongDanBaoCao") != null)
            {
                path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("Package").ToString() + "\\" + rfile;// "billPOS.repx";
            }
            else
            {
                path = Application.StartupPath + "\\Reports\\" + Config.GetValue("Package").ToString() + "\\" + rfile; //+ "billPOS.repx";
            }
            if (System.IO.File.Exists(path))
            {
                rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true);
            }
            else
            {
                rptTmp = new DevExpress.XtraReports.UI.XtraReport();
            }

            if (rptTmp != null)
            {
                DataTable tbSource = _cban.tb.Clone();
                if (i == 1)
                {
                    DataRow[] lr = _cban.tb.Select(); lr = _cban.tb.Select("InBep=1 and slin>0");
                    foreach (DataRow dr in lr)
                    {
                        tbSource.Rows.Add(dr.ItemArray);
                    }
                    // foreach (DataRow dr in _cban.tb.Rows) dr["InBep"] = true;
                }
                else
                {
                    tbSource = _cban.tb.Copy();
                }
                if (tbSource.Rows.Count == 0)
                {
                    return;
                }
                rptTmp.DataSource       = tbSource;
                rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" };
                SetVariables(rptTmp);
                DevExpress.XtraReports.UI.XRControl xrcTongTien = rptTmp.FindControl("TongTien", true);
                if (xrcTongTien != null)
                {
                    xrcTongTien.Text = double.Parse(_cban.tTien.ToString()).ToString("### ### ### ###");
                }
                //DevExpress.XtraReports.UI.XRControl xrcDatt = rptTmp.FindControl("DaTT", true);
                //if (xrcDatt != null)
                //    xrcDatt.Text = double.Parse(cDaTT.EditValue.ToString()).ToString("### ### ### ###");
                //DevExpress.XtraReports.UI.XRControl xrcConlai = rptTmp.FindControl("Conlai", true);
                //if (xrcConlai != null)
                //    xrcConlai.Text = double.Parse(cConlai.EditValue.ToString()).ToString("### ### ### ###");
                DevExpress.XtraReports.UI.XRControl xrcID = rptTmp.FindControl("ID", true);
                if (xrcID != null)
                {
                    xrcID.Text = _cban.id;
                }
                //DevExpress.XtraReports.UI.XRControl xrbID = rptTmp.FindControl("BCID", true);
                //if (xrbID != null)
                //    xrbID.Text = txtCode.Text;

                ////rptTmp.Print();
                if (i == 1)
                {
                    if (printerBEP != "")
                    {
                        rptTmp.Print(printerBEP);
                    }
                    else
                    {
                        rptTmp.Print();
                    }
                }
                else
                {
                    if (printerPOS != "")
                    {
                        rptTmp.Print(printerPOS);
                    }
                    else
                    {
                        rptTmp.Print();
                    }
                }
            }
        }
Example #5
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.Detail     = new DevExpress.XtraReports.UI.DetailBand();
     this.xrControl1 = new DevExpress.XtraReports.UI.XRControl();
     this.xrLabel3   = new DevExpress.XtraReports.UI.XRLabel();
     this.xrLabel2   = new DevExpress.XtraReports.UI.XRLabel();
     this.xrLabel1   = new DevExpress.XtraReports.UI.XRLabel();
     this.PageHeader = new DevExpress.XtraReports.UI.PageHeaderBand();
     this.PageFooter = new DevExpress.XtraReports.UI.PageFooterBand();
     ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
     //
     // Detail
     //
     this.Detail.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
         this.xrControl1,
         this.xrLabel3,
         this.xrLabel2,
         this.xrLabel1
     });
     this.Detail.Name = "Detail";
     //
     // xrControl1
     //
     this.xrControl1.Borders  = DevExpress.XtraPrinting.BorderSide.All;
     this.xrControl1.Location = new System.Drawing.Point(550, 8);
     this.xrControl1.Name     = "xrControl1";
     this.xrControl1.ParentStyleUsing.UseBorders = false;
     this.xrControl1.Size = new System.Drawing.Size(100, 25);
     //
     // xrLabel3
     //
     this.xrLabel3.Location = new System.Drawing.Point(408, 33);
     this.xrLabel3.Name     = "xrLabel3";
     this.xrLabel3.Size     = new System.Drawing.Size(100, 25);
     this.xrLabel3.Text     = "xrLabel3";
     //
     // xrLabel2
     //
     this.xrLabel2.Location = new System.Drawing.Point(267, 50);
     this.xrLabel2.Name     = "xrLabel2";
     this.xrLabel2.Size     = new System.Drawing.Size(100, 25);
     this.xrLabel2.Text     = "xrLabel2";
     //
     // xrLabel1
     //
     this.xrLabel1.Location = new System.Drawing.Point(150, 17);
     this.xrLabel1.Name     = "xrLabel1";
     this.xrLabel1.Size     = new System.Drawing.Size(100, 25);
     this.xrLabel1.Text     = "xrLabel1";
     //
     // PageHeader
     //
     this.PageHeader.Height = 30;
     this.PageHeader.Name   = "PageHeader";
     //
     // PageFooter
     //
     this.PageFooter.Height = 30;
     this.PageFooter.Name   = "PageFooter";
     //
     // XtraReport1
     //
     this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
         this.Detail,
         this.PageHeader,
         this.PageFooter
     });
     ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
 }
Example #6
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();
            }
        }