Beispiel #1
0
        /// <summary>
        /// 预览报表
        /// </summary>
        public static void OpenReportDialog(enRequestReportActionType eActionType, ReportRequestArgs reportRequestArgs)
        {
            ProcessStep.AddStep("OpenReportDialog_Start", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
            //DataRow drReportTemplateConfig = GetReportTemplateRow(reportRequestArgs.ReportTemplateID);
            int iPrintCount = 1;

            DataTable dtReport = ReportHelper.GetReportTemplateByID4Print(reportRequestArgs.ReportTemplateID);

            if (dtReport.Rows.Count > 0)
            {
                DataRow drReportTemplateConfig = dtReport.Rows[0];
                if (eActionType == enRequestReportActionType.DirectPrint)
                {
                    iPrintCount = LBConverter.ToInt32(drReportTemplateConfig["PrintCount"]);
                    if (iPrintCount <= 0)
                    {
                        iPrintCount = 1;
                    }
                }

                ProcessStep.AddStep("GetReportTemplateRow", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                reportRequestArgs.ReportTemplateConfig = drReportTemplateConfig;

                for (int i = 0; i < iPrintCount; i++)
                {
                    ShowReport(eActionType, reportRequestArgs);
                }
            }
            ProcessStep.AddStep("ShowReport_End", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
        }
Beispiel #2
0
        /// <summary>
        /// 预览报表
        /// </summary>
        public static void OpenReportDialog(enRequestReportActionType eActionType, ReportRequestArgs reportRequestArgs)
        {
            ProcessStep.AddStep("OpenReportDialog_Start", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
            DataRow drReportTemplateConfig = GetReportTemplateRow(reportRequestArgs.ReportTemplateID);

            ProcessStep.AddStep("GetReportTemplateRow", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
            reportRequestArgs.ReportTemplateConfig = drReportTemplateConfig;
            ShowReport(eActionType, reportRequestArgs);
            ProcessStep.AddStep("ShowReport_End", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
        }
Beispiel #3
0
        public static FastReport.Report GetReport(ReportRequestArgs e)
        {
            DataTable dtReportTemplateConfig = ReportHelper.GetReportTemplateByID(e.ReportTemplateID);

            if (dtReportTemplateConfig.Rows.Count == 0)
            {
                return(null);
            }
            DataRow drReportTemplateConfig = dtReportTemplateConfig.Rows[0];

            e.ReportTemplateConfig = drReportTemplateConfig;

            long lReportTemplateID = Convert.ToInt64(e.ReportTemplateConfig["ReportTemplateID"]);

            byte[]   reportTempleData         = (byte[])e.ReportTemplateConfig["TemplateData"];
            DateTime dtTemplateFileTime       = DateTime.Parse(e.ReportTemplateConfig["TemplateFileTime"].ToString());
            string   strReportTemplateName    = e.ReportTemplateConfig["ReportTemplateName"].ToString().Trim();
            string   strReportTemplateNameExt = e.ReportTemplateConfig["ReportTemplateNameExt"].ToString().Trim();
            //检测本地是否存在报表文件,如果不存在或者与服务器比本地文件新时更新本地文件
            string strFileFullName = WriteReportWithCheck(lReportTemplateID, strReportTemplateName, dtTemplateFileTime, reportTempleData, strReportTemplateNameExt);

            ProcessStep.AddStep("WriteReportWithCheck_End", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);

            // 加载模板
            FastReport.Report report = null;

            //Form frm = null;
            try
            {
                //frm = new Form();
                report = new FastReport.Report();
                ProcessStep.AddStep("Report_New", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                report.FinishReport += Report_FinishReport;
                report.Load(strFileFullName);
                ProcessStep.AddStep("Report_Load", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                // 纸张设置
                //SetPaperAuto(report, iReportTemplateID);

                BuildParmsAndData(e, report, enBuildParmsAndDataActionType.SetValue);
                ProcessStep.AddStep("BuildParmsAndData", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                //ReportPreviewer previewer = new Report.ReportPreviewer(report);

                SetPrintSettings(report, lReportTemplateID);
                ProcessStep.AddStep("SetPrintSettings", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
            }
            catch (Exception ex)
            {
            }
            return(report);
        }
Beispiel #4
0
        private static void ShowReport(enRequestReportActionType eActionType, ReportRequestArgs e)
        {
            // FastReport 配置
            Config.DesignerSettings.ShowInTaskbar = true;
            Config.DesignerSettings.DefaultFont   = new System.Drawing.Font(Config.DesignerSettings.DefaultFont.FontFamily, 10f);
            //Config.DesignerSettings.Icon = TS.Win.Styles.Sheet.AppIcon;
            Config.DesignerSettings.Text = "报表设计器";
            //Config.PreviewSettings.Buttons = PreviewButtons.Print;
            Config.PreviewSettings.ShowInTaskbar = true;
            //Config.PreviewSettings.Icon = TS.Win.Styles.Sheet.AppIcon;

            long lReportTemplateID = Convert.ToInt64(e.ReportTemplateConfig["ReportTemplateID"]);

            byte[]   reportTempleData         = (byte[])e.ReportTemplateConfig["TemplateData"];
            DateTime dtTemplateFileTime       = DateTime.Parse(e.ReportTemplateConfig["TemplateFileTime"].ToString());
            string   strReportTemplateName    = e.ReportTemplateConfig["ReportTemplateName"].ToString().Trim();
            string   strReportTemplateNameExt = e.ReportTemplateConfig["ReportTemplateNameExt"].ToString().Trim();
            //检测本地是否存在报表文件,如果不存在或者与服务器比本地文件新时更新本地文件
            string strFileFullName = WriteReportWithCheck(lReportTemplateID, strReportTemplateName, dtTemplateFileTime, reportTempleData, strReportTemplateNameExt);

            ProcessStep.AddStep("WriteReportWithCheck_End", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);

            // 加载模板
            FastReport.Report report = null;

            //Form frm = null;
            try
            {
                //frm = new Form();
                report = new FastReport.Report();

                ProcessStep.AddStep("Report_New", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                report.FinishReport += Report_FinishReport;
                report.Load(strFileFullName);
                ProcessStep.AddStep("Report_Load", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                // 纸张设置
                //SetPaperAuto(report, iReportTemplateID);

                BuildParmsAndData(e, report, enBuildParmsAndDataActionType.SetValue);
                ProcessStep.AddStep("BuildParmsAndData", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                //ReportPreviewer previewer = new Report.ReportPreviewer(report);

                SetPrintSettings(report, lReportTemplateID);
                ProcessStep.AddStep("SetPrintSettings", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                if (eActionType == enRequestReportActionType.Preview)//预览
                {
                    //frm.FormBorderStyle = FormBorderStyle.None;
                    //frm.Text = "报表预览[" + strReportTemplateName + "]";
                    //frm.TransparencyKey = frm.BackColor;
                    //frm.Show();

                    //report.Show(true, frm);
                    //LBShowForm.ShowDialog(previewer);
                    report.Show(true);
                }
                else if (eActionType == enRequestReportActionType.DirectPrint)//直接打印
                {
                    report.PrintSettings.ShowDialog = false;
                    report.Print();
                    //string strPrinterStatus =PrinterHelper.GetPrinterStatus(report.PrintSettings.Printer);
                    ProcessStep.AddStep("Print", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                }
            }
            finally
            {
                try
                {
                    if (report != null)
                    {
                        report.Dispose();
                        //if (frm != null)
                        //{
                        //    frm.Close();
                        //}
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #5
0
        public static void PreviceReport(long saleID, enWeightType weightType, enRequestReportActionType requestType)
        {
            ProcessStep.mdtStep = null;
            ReportRequestArgs args;

            if (weightType == enWeightType.WeightIn)
            {
                ProcessStep.AddStep("StartPreviceReport", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                DataTable dtReportTemp = ReportHelper.GetReportTemplateRowByType(6);
                ProcessStep.AddStep("CallView_105", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                if (dtReportTemp.Rows.Count > 0)
                {
                    //打印磅单
                    if (requestType == enRequestReportActionType.DirectPrint)
                    {
                        frmPrint = new frmAutoPrint();
                    }

                    DataRow drReport          = dtReportTemp.Rows[0];
                    long    lReportTemplateID = Convert.ToInt64(drReport["ReportTemplateID"]);
                    long    lReportTypeID     = Convert.ToInt64(drReport["ReportTypeID"]);

                    args = new ReportRequestArgs(lReportTemplateID, 6, null, null);

                    //long lSaleCarInBillID = LBConverter.ToInt64(this.txtSaleCarInBillID.Text);
                    DataTable dtBill = ExecuteSQL.CallView(128, "", "SaleCarInBillID=" + saleID, "");
                    dtBill.TableName = "T006";
                    DataSet dsSource = new DataSet("Report");
                    dsSource.Tables.Add(dtBill);
                    args.DSDataSource = dsSource;

                    ProcessStep.AddStep("CallView_128", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);

                    ReportHelper.OpenReportDialog(requestType, args);

                    ProcessStep.AddStep("OpenReportDialog_End", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);

                    if (requestType == enRequestReportActionType.DirectPrint)
                    {
                        //记录小票打印次数
                        LBDbParameterCollection parmCol = new LBDbParameterCollection();
                        parmCol.Add(new LBParameter("SaleCarInBillID", enLBDbType.Int64, saleID));

                        DataSet dsReturn;
                        Dictionary <string, object> dictValue;
                        ExecuteSQL.CallSP(14109, parmCol, out dsReturn, out dictValue);

                        ProcessStep.AddStep("CallSP_14109", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                        DataTable dtt = ProcessStep.mdtStep;

                        LBShowForm.ShowDialog(frmPrint);
                    }
                }
            }
            else if (weightType == enWeightType.WeightOut ||
                     weightType == enWeightType.WeightOnlyOut)
            {
                DataTable dtReportTemp = ReportHelper.GetReportTemplateRowByType(7);
                if (dtReportTemp.Rows.Count > 0)
                {
                    //打印磅单
                    if (requestType == enRequestReportActionType.DirectPrint)
                    {
                        frmPrint = new frmAutoPrint();
                    }

                    DataRow drReport          = dtReportTemp.Rows[0];
                    long    lReportTemplateID = Convert.ToInt64(drReport["ReportTemplateID"]);
                    long    lReportTypeID     = Convert.ToInt64(drReport["ReportTypeID"]);

                    args = new ReportRequestArgs(lReportTemplateID, 7, null, null);

                    //long lSaleCarOutBillID = LBConverter.ToInt64(this.txtSaleCarOutBillID.Text);
                    DataTable dtBill = ExecuteSQL.CallView(125, "", "SaleCarOutBillID=" + saleID, "");
                    dtBill.TableName = "T007";
                    DataSet dsSource = new DataSet("Report");
                    dsSource.Tables.Add(dtBill);
                    args.DSDataSource = dsSource;

                    ReportHelper.OpenReportDialog(requestType, args);

                    if (requestType == enRequestReportActionType.DirectPrint)
                    {
                        //记录磅单打印次数
                        LBDbParameterCollection parmCol = new LBDbParameterCollection();
                        parmCol.Add(new LBParameter("SaleCarOutBillID", enLBDbType.Int64, saleID));

                        DataSet dsReturn;
                        Dictionary <string, object> dictValue;
                        ExecuteSQL.CallSP(14110, parmCol, out dsReturn, out dictValue);

                        LBShowForm.ShowDialog(frmPrint);
                    }
                }
            }
        }