예제 #1
0
 public static void CustomReportUpload(object sender, FastReport.Design.ReportUploadEventArgs e)
 {
     try
     {
         FastReport.Report report = e.Report;
         string            strTemplateFileName = report.FileName;
         string            strExt                = Path.GetExtension(strTemplateFileName);
         string            strFileName           = Path.GetFileName(strTemplateFileName);
         string            strReportTemplateName = strFileName.Substring(0, strFileName.Length - strExt.Length);
         int iReportTemplateID = GetReportTemplateID(strReportTemplateName);
         if (iReportTemplateID > 0)
         {
             byte[] bReport = ReportHelper.ConvertToByte(strTemplateFileName);
             LBDbParameterCollection parms = new LBDbParameterCollection();
             parms.Add(new LBParameter("ReportTemplateID", enLBDbType.Int64, iReportTemplateID));
             parms.Add(new LBParameter("TemplateFileTime", enLBDbType.DateTime, DateTime.Now));
             parms.Add(new LBParameter("TemplateData", enLBDbType.Object, bReport));
             DataSet dsReturn;
             Dictionary <string, object> dictResult;
             ExecuteSQL.CallSP(12003, parms, out dsReturn, out dictResult);
             LB.WinFunction.LBCommonHelper.ShowCommonMessage("上传成功!");
         }
     }
     catch (Exception ex)
     {
         LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
     }
 }
예제 #2
0
        private void btnSaveReport_Click(object sender, EventArgs e)
        {
            try
            {
                #region -- 保存报表 --
                if (mReportArgs.ReportTemplateID == 0)
                {
                    ReportRequestArgs args = new ReportRequestArgs(0, mReportArgs.ReportTypeID, mReportArgs.DSDataSource, mReportArgs.RecordDR);

                    this.txtReportPath.Text = ReportHelper.AddNewReport(args, this.txtReportTemplateName.Text);

                    if (!File.Exists(this.txtReportPath.Text))
                    {
                        throw new Exception("报表文件不存在,无法保存!");
                    }
                    byte[] bReport = ReportHelper.ConvertToByte(this.txtReportPath.Text);
                    LBDbParameterCollection parms = new LBDbParameterCollection();
                    parms.Add(new LBParameter("ReportTemplateID", enLBDbType.Int64, 0));
                    parms.Add(new LBParameter("ReportTemplateName", enLBDbType.String, this.txtReportTemplateName.Text));
                    parms.Add(new LBParameter("TemplateFileTime", enLBDbType.DateTime, DateTime.Now));
                    parms.Add(new LBParameter("TemplateSeq", enLBDbType.Int32, 0));
                    parms.Add(new LBParameter("Description", enLBDbType.String, this.txtDescription.Text));
                    parms.Add(new LBParameter("TemplateData", enLBDbType.Object, bReport));
                    parms.Add(new LBParameter("ReportTypeID", enLBDbType.Int64, mReportArgs.ReportTypeID));
                    parms.Add(new LBParameter("PrinterName", enLBDbType.String, this.txtPrinterName.Text));
                    parms.Add(new LBParameter("MachineName", enLBDbType.String, LoginInfo.MachineName));
                    parms.Add(new LBParameter("IsManualPaperType", enLBDbType.Boolean, rbManualPaperType.Checked));
                    parms.Add(new LBParameter("PaperType", enLBDbType.String, this.txtPaperType.Text));
                    parms.Add(new LBParameter("IsManualPaperSize", enLBDbType.Boolean, rbManualPaperSize.Checked));
                    if (this.txtPaperSizeHeight.Text != "")
                    {
                        parms.Add(new LBParameter("PaperSizeHeight", enLBDbType.Int32, this.txtPaperSizeHeight.Text));
                    }
                    if (this.txtPaperSizeWidth.Text != "")
                    {
                        parms.Add(new LBParameter("PaperSizeWidth", enLBDbType.Int32, this.txtPaperSizeWidth.Text));
                    }
                    parms.Add(new LBParameter("IsPaperTransverse", enLBDbType.Boolean, rbPaperTransverse.Checked));
                    parms.Add(new LBParameter("PrintCount", enLBDbType.Int32, LBConverter.ToInt32(this.txtPrintCount.Text)));
                    DataSet dsReturn;
                    Dictionary <string, object> dictResult;
                    ExecuteSQL.CallSP(12000, parms, out dsReturn, out dictResult);

                    if (dictResult.ContainsKey("ReportTemplateID"))
                    {
                        if (dictResult["ReportTemplateID"] != null)
                        {
                            mReportArgs.ReportTemplateID = Convert.ToInt64(dictResult["ReportTemplateID"]);
                        }
                    }
                }
                else
                {
                    byte[]   bReport            = null;
                    DateTime dtTemplateFileTime = DateTime.Now;
                    string   strReportPath      = this.txtReportPath.Text;
                    if (strReportPath != "")
                    {
                        if (File.Exists(strReportPath))
                        {
                            bReport = ReportHelper.ConvertToByte(strReportPath);
                            //dtTemplateFileTime = File.GetLastWriteTime(strReportPath);
                        }
                        else
                        {
                            throw new Exception("报表文件不存在,无法保存!");
                        }
                    }
                    else
                    {
                        string strReportFile;
                        bool   bolExists = ReportHelper.RefleshClientReport(mReportArgs.ReportTemplateID, out strReportFile);

                        if (bolExists)
                        {
                            bReport            = ReportHelper.ConvertToByte(strReportFile);
                            dtTemplateFileTime = File.GetLastWriteTime(strReportFile);
                        }
                        else
                        {
                            throw new Exception("报表文件不存在,无法保存!");
                        }
                    }

                    LBDbParameterCollection parms = new LBDbParameterCollection();
                    parms.Add(new LBParameter("ReportTemplateID", enLBDbType.Int64, mReportArgs.ReportTemplateID));
                    parms.Add(new LBParameter("ReportTemplateName", enLBDbType.String, this.txtReportTemplateName.Text));
                    parms.Add(new LBParameter("TemplateFileTime", enLBDbType.DateTime, dtTemplateFileTime));
                    parms.Add(new LBParameter("TemplateSeq", enLBDbType.Int32, 0));
                    parms.Add(new LBParameter("Description", enLBDbType.String, this.txtDescription.Text));
                    parms.Add(new LBParameter("TemplateData", enLBDbType.Object, bReport));
                    parms.Add(new LBParameter("ReportTypeID", enLBDbType.Int64, mReportArgs.ReportTypeID));
                    parms.Add(new LBParameter("PrinterName", enLBDbType.String, this.txtPrinterName.Text));
                    parms.Add(new LBParameter("MachineName", enLBDbType.String, LoginInfo.MachineName));
                    parms.Add(new LBParameter("IsManualPaperType", enLBDbType.Boolean, rbManualPaperType.Checked));
                    parms.Add(new LBParameter("PaperType", enLBDbType.String, this.txtPaperType.Text));
                    parms.Add(new LBParameter("IsManualPaperSize", enLBDbType.Boolean, rbManualPaperSize.Checked));
                    if (this.txtPaperSizeHeight.Text != "")
                    {
                        parms.Add(new LBParameter("PaperSizeHeight", enLBDbType.Int32, this.txtPaperSizeHeight.Text));
                    }
                    if (this.txtPaperSizeWidth.Text != "")
                    {
                        parms.Add(new LBParameter("PaperSizeWidth", enLBDbType.Int32, this.txtPaperSizeWidth.Text));
                    }
                    parms.Add(new LBParameter("IsPaperTransverse", enLBDbType.Boolean, rbPaperTransverse.Checked));
                    parms.Add(new LBParameter("PrintCount", enLBDbType.Int32, LBConverter.ToInt32(this.txtPrintCount.Text)));
                    DataSet dsReturn;
                    Dictionary <string, object> dictResult;
                    ExecuteSQL.CallSP(12001, parms, out dsReturn, out dictResult);
                }
                #endregion -- 保存报表 --

                LB.WinFunction.LBCommonHelper.ShowCommonMessage("保存成功!");
            }
            catch (Exception ex)
            {
                LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
            }
        }