Esempio n. 1
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);
                }
            }
        }