Exemplo n.º 1
0
        //----以下是YX01数据采集----
        private void GetParaDataPrint_YX02(int tt_itemtype)
        {
            //单板打印
            if (PrintText != "")
            {
                FastReport.Report report = new FastReport.Report();

                report.Prepare();
                report.Load(Application.StartupPath + "\\LABLE\\YX_2.frx");
                report.SetParameterValue("S01", PrintText);

                report.PrintSettings.ShowDialog = false;

                //--打印
                if (tt_itemtype == 1)
                {
                    report.Print();
                }

                //--预览
                if (tt_itemtype == 2)
                {
                    report.Design();
                }
            }
        }
Exemplo n.º 2
0
        private byte[] InternalGenerateReport(string reportFile, Dictionary <string, string> parameters)
        {
            FastReport.Report report = new FastReport.Report();
            report.Load(Path.Combine("Reports", reportFile));
            if (string.IsNullOrWhiteSpace(_appSettings.ConnectionString))
            {
                throw new NotSupportedException("Connectionstring não informada");
            }

            report.Dictionary.Connections[0].ConnectionString = _appSettings.ConnectionString;
            //report.SetParameterValue("initialDate", "2019-01-01");
            //report.SetParameterValue("finalDate", "2019-01-07");

            foreach (var parameter in parameters)
            {
                report.SetParameterValue(parameter.Key, parameter.Value);
            }

            report.Prepare();

            // report.Parameters[0].Value = 143;
            //report.Refresh();

            PDFSimpleExport export = new PDFSimpleExport();

            using (MemoryStream ms = new MemoryStream())
            {
                report.Export(export, ms);
                ms.Flush();
                return(ms.ToArray());
            }
        }
Exemplo n.º 3
0
 //打印
 void UCReport_PrintEvent(object sender, EventArgs e)
 {
     if (dt == null || dt.Rows.Count == 0)
     {
         MessageBoxEx.Show("请查询出要打印的数据!");
         return;
     }
     string fileName = GetDefaultStyleFile();
     // create report instance
     FastReport.Report report = new FastReport.Report();
     if (!string.IsNullOrEmpty(fileName))
     {
         report.Load(fileName);
         report.RegisterData(dt, styleObject);
     }
     else
     {
         Report.FastReportEx reportEx = new Report.FastReportEx();
         reportEx.dicSpanRows = dicSpanRows;
         reportEx.dt = dt;
         reportEx.styleObject = styleObject;
         reportEx.styleTitle = styleTitle;
         report = reportEx.DefaultReport();
     }
     if (paperSize != null && report.Pages.Count > 0)
     {
         FastReport.ReportPage page = (FastReport.ReportPage)report.Pages[0];
         page.PaperHeight = paperSize.Height;
         page.PaperWidth = paperSize.Width;
     }
     report.Prepare();
     report.Print();
     report.Dispose();
 }
Exemplo n.º 4
0
        //导出
        void UCReport_ExportEvent(object sender, EventArgs e)
        {
            string fileName = GetDefaultStyleFile();

            // create report instance
            FastReport.Report report = new FastReport.Report();
            if (!string.IsNullOrEmpty(fileName))
            {
                report.Load(fileName);
                report.RegisterData(dt, styleObject);
            }
            else
            {
                Report.FastReportEx reportEx = new Report.FastReportEx();
                reportEx.dicSpanRows = dicSpanRows;
                reportEx.dt          = dt;
                reportEx.styleObject = styleObject;
                reportEx.styleTitle  = styleTitle;
                report = reportEx.DefaultReport();
            }
            if (report == null)
            {
                return;
            }
            report.Prepare();
            PDFExport export = new PDFExport();

            export.Export(report);
            report.Dispose();
        }
Exemplo n.º 5
0
        //打印
        void UCReport_PrintEvent(object sender, EventArgs e)
        {
            string fileName = GetDefaultStyleFile();

            // create report instance
            FastReport.Report report = new FastReport.Report();
            if (!string.IsNullOrEmpty(fileName))
            {
                report.Load(fileName);
                report.RegisterData(dt, styleObject);
            }
            else
            {
                Report.FastReportEx reportEx = new Report.FastReportEx();
                reportEx.dicSpanRows = dicSpanRows;
                reportEx.dt          = dt;
                reportEx.styleObject = styleObject;
                reportEx.styleTitle  = styleTitle;
                report = reportEx.DefaultReport();
            }
            if (paperSize != null && report.Pages.Count > 0)
            {
                FastReport.ReportPage page = (FastReport.ReportPage)report.Pages[0];
                page.PaperHeight = paperSize.Height;
                page.PaperWidth  = paperSize.Width;
            }
            report.Prepare();
            report.Print();
            report.Dispose();
        }
Exemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            DateTime d_rq1 = dateTimePicker1.Value.Date;
            DateTime d_rq2 = dateTimePicker1.Value.AddDays(1).Date;

            var dataList = SqlUtil.Inst.Orders.Where(a => a.date >= d_rq1 && a.date < d_rq2).ToList().Select(a => new {
                no   = a.no,
                date = a.date.ToString("yyyy年MM月dd日"),
                zje  = a.zje.ToString("0.00"),
                yhje = a.yhje.ToString("0.00"),
                ssje = (a.zje - a.yhje).ToString("0.00"),
                zffs = a.zffs
            }).ToList();

            Assembly assembly = Assembly.GetExecutingAssembly();

            //获取指定的资源

            using (Stream stream = assembly.GetManifestResourceStream("DishSysManager.daily_mx.frx"))
            {
                if (stream != null)  //没有找到,GetManifestResourceStream会返回null
                {
                    report.Clear();
                    report.Load(stream);
                    report.RegisterData(dataList, "mx");
                    report.Preview = this.previewControl1;
                    report.Prepare();
                    report.ShowPrepared();
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// FastReports
        /// </summary>
        /// <param name="isDesign"></param>
        private void FastReports(bool isDesign)
        {
            System.Data.DataSet printDataDs = new System.Data.DataSet();
            try
            {
                int[]   rownumber = this.gridViewMainData.GetSelectedRows();
                DataRow row       = this.gridViewMainData.GetDataRow(rownumber[0]);
                System.Data.DataTable mainData    = ToDataTable(row);
                System.Data.DataTable detailsData = ((DataView)this.gridViewDetailsData.DataSource).ToTable();
                if (mainData != null && mainData.Rows.Count > 0)
                {
                    mainData.TableName = "mainData";
                    printDataDs.Tables.Add(mainData.Copy());
                }
                if (detailsData != null && detailsData.Rows.Count > 0)
                {
                    detailsData.TableName = "detailsData";
                    printDataDs.Tables.Add(detailsData.Copy());
                }
                FastReport.Report report = new FastReport.Report();
                Res.LocaleFolder = AppDomain.CurrentDomain.BaseDirectory + "FastReports\\Localization";
                Res.LoadLocale(Res.LocaleFolder + @"\Chinese (Simplified).frl");
                string FDataTables = "FDataTables";
                string filename    = @"FastReports\Reports\fx_001.frx";
                report.Load(filename);

                using (Designer designer = new Designer())
                {
                    designer.SetModified(this, "EditData");
                    int i = 0;
                    foreach (DataTable dt in printDataDs.Tables)
                    {
                        FDataTables = "FDataTables" + i.ToString();
                        printDataDs.Tables[i].TableName = FDataTables;
                        report.RegisterData(printDataDs.Tables[i], FDataTables);
                        report.GetDataSource(FDataTables).Enabled = true;
                        i = i + 1;
                    }
                    Res.LocaleFolder = AppDomain.CurrentDomain.BaseDirectory + "FastReports\\Localization";
                    Res.LoadLocale(Res.LocaleFolder + @"\Chinese (Simplified).frl");
                    if (isDesign)
                    {
                        report.Design();
                    }
                    else
                    {
                        report.SetParameterValue("time", DateTime.Now.Date.ToString("yyyy-MM-dd"));
                        report.Prepare();
                        report.ShowPrepared();
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }
Exemplo n.º 8
0
        public static void GenereteReport(ReportParams reportParams)
        {
            if (reportParams == null)
            {
                throw new ArgumentNullException($"{nameof(reportParams)} cannot be null.");
            }

            // create report instance
            using (FastReport.Report report = new FastReport.Report())
            {
                // load the existing report
                report.Load(reportParams.FrxPath);

                // register datasource's
                if (reportParams.DataSource != null)
                {
                    foreach (var pair in reportParams.DataSource)
                    {
                        report.RegisterData(pair.Value, pair.Key);
                    }
                }

                if (reportParams.Parameters != null)
                {
                    foreach (var pair in reportParams.Parameters)
                    {
                        report.SetParameterValue(pair.Key, pair.Value);
                    }
                }

                // prepare the report
                report.Prepare();

                ExportBase export = null;
                switch (reportParams.OutputType)
                {
                case 0:     // export to html
                    export = new HTMLExport();
                    (export as HTMLExport).Format = HTMLExportFormat.HTML;
                    break;

                case 1:
                    export = new ImageExport();
                    (export as ImageExport).ImageFormat = ImageExportFormat.Png;
                    break;

                default:
                    throw new ArgumentException($"O parametro {reportParams.OutputType} é inválido");
                }

                report.Export(export, reportParams.OutStream);
            }

            reportParams.OutStream.Position = 0;
        }
Exemplo n.º 9
0
        public FormReportCP(string ord_no)
        {
            InitializeComponent();
            var order = SqlUtil.Inst.Orders.FirstOrDefault(a => a.no == ord_no);

            if (order == null)
            {
                return;
            }
            var          dataList  = SqlUtil.Inst.Details.Where(a => a.ord_no == order.no).ToList();
            Assembly     assembly  = Assembly.GetExecutingAssembly();
            List <Order> dataList2 = new List <Order>();

            dataList2.Add(order);
            var hz = dataList2.Select(a => new
            {
                date = a.date.ToString("yyyy-MM-dd HH:mm"),
                zje  = a.zje.ToString("0.00"),
                yhje = a.yhje.ToString("0.00"),
                sfje = (a.zje - a.yhje).ToString("0.00"),
                a.desk,
                ord_no = a.no
            }).ToList();

            //获取指定的资源

            using (Stream stream = assembly.GetManifestResourceStream("DishSysManager.daily_cp.frx"))
            {
                if (stream != null)  //没有找到,GetManifestResourceStream会返回null
                {
                    report.Clear();
                    report.Load(stream);
                    report.RegisterData(dataList, "mx");
                    report.RegisterData(hz, "hz");
                    report.Prepare();
                    report.PrintSettings.ShowDialog = false;
                    report.Print();
                }
            }
            autoClose = true;
        }
Exemplo n.º 10
0
 private void ShowModels(List <Maticsoft.Model.SMT_VERMODEL_INFO> infos)
 {
     modelTree.Nodes[1].Nodes.Clear();
     foreach (var item in infos)
     {
         Node model = new Node(item.VERM_NAME);
         model.Tag = item;
         modelTree.Nodes[1].Nodes.Add(model);
         if (_lastSelectModel != null && _lastSelectModel.ID == item.ID)
         {
             _lastSelectModel       = item;
             modelTree.SelectedNode = model;
         }
     }
     if (_lastSelectModel == null)
     {
         _report.Clear();
         _report.Prepare();
         _report.ShowPrepared();
     }
     modelTree.ExpandAll();
 }
Exemplo n.º 11
0
 public void DetailPrint(Dictionary <string, DataTable> dic)
 {
     if (dic == null)
     {
         return;
     }
     FastReport.Report report = GetDetailReport(dic);
     if (report == null)
     {
         return;
     }
     report.Prepare();
     report.Print();
     report.Dispose();
     dic = null;
 }
Exemplo n.º 12
0
        private void toolPrint_Click(object sender, EventArgs e)
        {
            #region
            FastReport.Report report1 = new FastReport.Report();
            try
            {
                // load the existing report
                report1.Load(Application.StartupPath + @"\PRINTModel\收据模板\日结明细单模板.frx");

                (report1.FindObject("txtYSCOUNT") as FastReport.TextObject).Text        = "发票数量:" + intYSCount + "张,收据数量:" + intYSRECEIPRNOCOUNT.ToString() + "张";
                (report1.FindObject("txtYSSF") as FastReport.TextObject).Text           = "应收水费:" + decBCYS.ToString("F2") + "元";
                (report1.FindObject("txtSSSF") as FastReport.TextObject).Text           = "实收金额:" + decYSBCSS.ToString("F2") + "元";
                (report1.FindObject("txtSSSFXJ") as FastReport.TextObject).Text         = "现金:" + decYSBCSSXJ.ToString("F2") + "元";
                (report1.FindObject("txtSSSFPOS") as FastReport.TextObject).Text        = "POS机:" + decYSBCSSPOS.ToString("F2") + "元";
                (report1.FindObject("txtSSSFZHUANZHANG") as FastReport.TextObject).Text = "转账汇款:" + decYSBCSSZHUANZHANG.ToString("F2") + "元";
                (report1.FindObject("txtYEZJ") as FastReport.TextObject).Text           = "余额增减:" + decYSBCSZ.ToString("F2") + "元";

                (report1.FindObject("txtYCCount") as FastReport.TextObject).Text        = "单据数量:" + intYCCount + "张";
                (report1.FindObject("txtQQYE") as FastReport.TextObject).Text           = "前期余额:" + decYCQQYE.ToString("F2") + "元";
                (report1.FindObject("txtYCSF") as FastReport.TextObject).Text           = "预存收费:" + decYCBCSZ.ToString("F2") + "元";
                (report1.FindObject("txtYCSFXJ") as FastReport.TextObject).Text         = "现金:" + decYCBCSZXJ.ToString("F2") + "元";
                (report1.FindObject("txtYCSFPOS") as FastReport.TextObject).Text        = "POS机:" + decYCBCSZPOS.ToString("F2") + "元";
                (report1.FindObject("txtYCSFZHUANZHANG") as FastReport.TextObject).Text = "转账汇款:" + decYCBCSZZHUANZHANG.ToString("F2") + "元";
                (report1.FindObject("txtJSYE") as FastReport.TextObject).Text           = "结算余额::" + decYCJSYE.ToString("F2") + "元";

                (report1.FindObject("txtJEZJ") as FastReport.TextObject).Text     = "金额总计: " + labBCSS.Text;
                (report1.FindObject("txtDateTime") as FastReport.TextObject).Text = "统计时间:" + dtpStartSearch.Value.ToString("yyyy-MM-dd HH:mm:ss") + " 至 " + dtpEndSearch.Value.ToString("yyyy-MM-dd HH:mm:ss");

                (report1.FindObject("txtWorkerName") as FastReport.TextObject).Text = "收 费 员:" + txtWorkerNameSearch.Text;

                report1.PrintSettings.ShowDialog = false;
                report1.Prepare();
                report1.Print();
            }
            catch (Exception exx)
            {
                MessageBox.Show(exx.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
            #endregion
        }
Exemplo n.º 13
0
        private string GenderPDF(string model, DataSet ds)
        {
            FastReport.Report report = new FastReport.Report();
            report.Load(model);
            report.RegisterData(ds);

            report.Prepare();
            //report.PreparePhase1();
            //report.PreparePhase2();

            //初始化输出类
            PDFExport export = new PDFExport();
            //输出
            string path = "E:\\lis\\temp.pdf";
            export.Export(report, path);

            return path;
        }
Exemplo n.º 14
0
 /// <summary>
 /// 打印
 /// </summary>
 /// <param name="dt"></param>
 public void Print(DataTable dt)
 {
     if (dt == null || dt.Rows.Count == 0)
     {
         MessageBoxEx.ShowWarning("没有可打印的数据");
         return;
     }
     FastReport.Report report = GetReport(dt);
     if (report != null)
     {
         report.Prepare();
         report.Print();
         report.Dispose();
     }
     else
     {
         MessageBoxEx.ShowWarning("没有可打印的数据");
     }
 }
Exemplo n.º 15
0
 /// <summary>
 /// 预览
 /// </summary>
 /// <param name="dt"></param>
 public void Preview(DataTable dt)
 {
     if (dt == null || dt.Rows.Count == 0)
     {
         MessageBoxEx.ShowWarning("没有可预览数据!");
         return;
     }
     FastReport.Report report = GetReport(dt);
     report.Save("tb_parts.frx");
     if (report != null)
     {
         report.Prepare();
         report.ShowPrepared();
         report.Dispose();
     }
     else
     {
         MessageBoxEx.ShowWarning("没有预览数据!");
     }
 }
Exemplo n.º 16
0
        public static void Print(DataSet dsData, string frxPath, string path)
        {
            FastReport.Report report = new FastReport.Report();
            report.RegisterData(dsData);
            using (FileStream fs = new FileStream(frxPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                report.Load(fs);
            }
            report.Prepare();

            PDFExport export = new PDFExport();

            export.SetReport(report);
            export.Compressed      = true;
            export.Background      = false;
            export.PrintOptimized  = false;
            export.OpenAfterExport = false;
            export.EmbeddingFonts  = true;
            report.Export(export, path);
            report.Dispose();
        }
Exemplo n.º 17
0
        //导出
        void UCReport_ExportEvent(object sender, EventArgs e)
        {
            if (dt == null || dt.Rows.Count == 0)
            {
                MessageBoxEx.Show("请查询出要导出的数据!");
                return;
            }
            string fileName = GetDefaultStyleFile();

            // create report instance
            FastReport.Report report = new FastReport.Report();
            if (!string.IsNullOrEmpty(fileName))
            {
                report.Load(fileName);
                report.RegisterData(dt, styleObject);
            }
            else
            {
                Report.FastReportEx reportEx = new Report.FastReportEx();
                reportEx.dicSpanRows = dicSpanRows;
                reportEx.dt          = dt;
                reportEx.styleObject = styleObject;
                reportEx.styleTitle  = styleTitle;
                report = reportEx.DefaultReport();
            }
            if (report == null)
            {
                return;
            }
            report.Prepare();
            report.FileName = styleTitle;
            //PDFExport export = new PDFExport();
            //export.Name = "name";
            //export.Title = styleTitle;
            //export.Export(report,styleTitle+".pdf");
            FastReport.Export.Csv.CSVExport csvExport = new FastReport.Export.Csv.CSVExport();
            csvExport.Export(report);
            //report.Export(export, styleTitle + ".pdf");
            report.Dispose();
        }
Exemplo n.º 18
0
 /// <summary>
 /// 订单打印
 /// </summary>
 /// <param name="info"></param>
 private void PrintOrderInfo(OrderInfo info)
 {
     if (info == null)
     {
         return;
     }
     _report.Parameters.FindByName("PWONo").Value           = info.PWONo;
     _report.Parameters.FindByName("PlatNo").Value          = info.PlateNo;
     _report.Parameters.FindByName("T102Code").Value        = info.T102Code;
     _report.Parameters.FindByName("LotNumber").Value       = info.LotNumber;
     _report.Parameters.FindByName("MachineModeling").Value = info.MachineModelling;
     _report.Parameters.FindByName("Texture").Value         = info.Texture;
     _report.Parameters.FindByName("BatchNumber").Value     = info.BatchNumber;
     _report.Parameters.FindByName("Quantity").Value        = info.Qty.ToString();
     _report.Parameters.FindByName("BatchQty").Value        = info.BatchQty.ToString();
     _report.Parameters.FindByName("MONumber").Value        = info.MONumber;
     _report.Parameters.FindByName("MOLineNo").Value        = info.MOLineNo;
     System.Drawing.Printing.PrinterSettings prnSetting =
         new System.Drawing.Printing.PrinterSettings();
     if (_report.Prepare())
     {
         // 取消循环打印-李智颖 2018-3-2
         //bool rePrinter = false;
         //do
         //{
         if (_report.ShowPrintDialog(out prnSetting))
         {
             _report.PrintPrepared(prnSetting);
             //rePrinter = (
             //    ShowMessageBox.Show(
             //        "铸造产品标识卡已经打印完成,是否需要重新打印?",
             //        "系统信息",
             //        MessageBoxButtons.YesNo,
             //        MessageBoxIcon.Question,
             //        MessageBoxDefaultButton.Button2) == DialogResult.Yes);
         }
         //} while (rePrinter);
     }
 }
Exemplo n.º 19
0
        private void btCharge_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgList.Rows.Count == 0)
                {
                    mes.Show("未找到预交水费的用户信息!");
                    return;
                }
                if (!Information.IsNumeric(txtBCYC.Text))
                {
                    return;
                }
                else
                if (Convert.ToDecimal(txtBCYC.Text) <= 0)
                {
                    mes.Show("预存金额不能为'0'");
                    txtBCYC.Focus();
                    return;
                }

                if (chkReceipt.Checked)
                {
                    if (txtReceiptNO.Text.Trim() == "")
                    {
                        mes.Show("收据号不能为空!");
                        return;
                    }
                }
                txtReceiptNO.Text = txtReceiptNO.Text.Trim().PadLeft(8, '0');

                //预存金额
                decimal decYCMoney = Convert.ToDecimal(txtBCYC.Text);

                for (int i = 0; i < dgList.SelectedRows.Count; i++)
                {
                    try
                    {
                        string strWaterUserID = "", strWaterUserNO = "", strWaterUserName = "", strWaterUserAddress = "",
                               strMeterReaderID = "", strMeterReaderName = "", strMeterReaderTel = "";

                        object objWaterUserID = dgList.SelectedRows[i].Cells["waterUserId"].Value;
                        if (objWaterUserID == null || objWaterUserID == DBNull.Value)
                        {
                            mes.Show("第'" + (i + 1).ToString() + "行用户ID获取失败,批量收费终止!");
                            return;
                        }
                        if ((decSumYuCun_YY + decYCMoney) > decSumYuCun_YK)
                        {
                            if (mes.ShowQ("检测到当前营业用户预存余额>业扩预存款,确定要继续吗?") != DialogResult.OK)
                            {
                                return;
                            }
                        }

                        #region 生成用户信息
                        strWaterUserID = objWaterUserID.ToString();
                        object objWaterUserMes = dgList.SelectedRows[i].Cells["waterUserNO"].Value;
                        if (objWaterUserMes != null && objWaterUserMes != DBNull.Value)
                        {
                            strWaterUserNO = objWaterUserMes.ToString();
                        }

                        objWaterUserMes = dgList.SelectedRows[i].Cells["waterUserName"].Value;
                        if (objWaterUserMes != null && objWaterUserMes != DBNull.Value)
                        {
                            strWaterUserName = objWaterUserMes.ToString();
                        }

                        objWaterUserMes = dgList.SelectedRows[i].Cells["waterUserAddress"].Value;
                        if (objWaterUserMes != null && objWaterUserMes != DBNull.Value)
                        {
                            strWaterUserAddress = objWaterUserMes.ToString();
                        }

                        object objWaterUser = dgList.SelectedRows[i].Cells["METERREADERID"].Value;
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strMeterReaderID = objWaterUser.ToString();

                            DataRow[] drMeterReader     = dtMeterReader.Select("LOGINID='" + strMeterReaderID + "'");
                            object    objMeterReaderTel = drMeterReader[0]["TELEPHONENO"];
                            if (objMeterReaderTel != null && objMeterReaderTel != DBNull.Value)
                            {
                                strMeterReaderTel = objMeterReaderTel.ToString();
                            }
                        }

                        objWaterUser = dgList.SelectedRows[i].Cells["meterReaderName"].Value;
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strMeterReaderName = objWaterUser.ToString();
                        }
                        #endregion

                        //计算结算余额
                        decimal decQQYE = 0, decJSYE = 0;
                        object  objPrestore = dgList.SelectedRows[i].Cells["prestore"].Value;
                        if (Information.IsNumeric(objPrestore))
                        {
                            decQQYE = Convert.ToDecimal(objPrestore);
                        }

                        decJSYE = decQQYE + Convert.ToDecimal(txtBCYC.Text);

                        string CHARGEID = GETTABLEID.GetTableID(strLoginID, "WATERFEECHARGE");
                        string PRESTORERUNNINGACCOUNTID = GETTABLEID.GetTableID(strLoginID, "PRESTORERUNNINGACCOUNT");
                        string _chargeID = sysidal.GetNewChargeID(strLoginID);

                        string strSQL  = string.Format(@"BEGIN TRAN
DECLARE @prestore DECIMAL(18,0)=0
SELECT @prestore=prestore FROM Meter_Install_Group WHERE GROUPID='{0}'

INSERT INTO Meter_Charge (CHARGEID,TaskID,CHARGEBCSS,CHARGEBCYS,TOTALCHARGE,prestore,FeeList,
CHARGETYPEID,CHARGEClASS,CHARGEWORKERID,CHARGEWORKERNAME,CHARGEDATETIME,RECEIPTPRINTCOUNT,ReceiptPrintSign,RECEIPTNO,ReceiptPrintTime)  
VALUES('{1}','{2}',0-{3},0,0,@prestore-{3},'余额转营业','6','17','{4}','{5}',GETDATE(),1,'1','{7}',GETDATE())

UPDATE Meter_Install_Group SET prestore=@prestore-{3} WHERE GROUPID='{0}'

SELECT @prestore=prestore FROM waterUser WHERE waterUserId='{6}'

INSERT INTO WATERFEECHARGE (CHARGEID,CHARGETYPEID,CHARGEClASS,CHARGEBCYS,CHARGEBCSS,CHARGEYSQQYE,CHARGEYSBCSZ,CHARGEYSJSYE,CHARGEWORKERID,
CHARGEWORKERNAME,CHARGEDATETIME,RECEIPTPRINTCOUNT,RECEIPTNO) 
VALUES('{9}','6','17',0,{3},@prestore,{3},@prestore+{3},'{4}','{5}',GETDATE(),'1','{7}')

INSERT INTO PRESTORERUNNINGACCOUNT (PRESTORERUNNINGACCOUNTID,CHARGEID,WATERUSERID,WATERUSERNO,WATERUSERNAME,WATERUSERADDRESS,AREANO,PIANNO,
DUANNO,ORDERNUMBER,COMMUNITYID,COMMUNITYNAME,METERREADERID,METERREADERNAME,CHARGERID,CHARGERNAME,WATERUSERTYPEID,WATERUSERTYPENAME,
WATERMETERTYPEID,WATERMETERTYPEVALUE,WATERMETERTYPECLASSID,WATERMETERTYPECLASSNAME,WATERUSERHOUSETYPE,CREATETYPE,WATERUSERPHONE,BUILDINGNO,UNITNO)

SELECT '{8}','{9}', WATERUSERID,WATERUSERNO,WATERUSERNAME,WATERUSERADDRESS,AREANO,PIANNO,DUANNO,ORDERNUMBER,COMMUNITYID,COMMUNITYNAME,
METERREADERID,METERREADERNAME,CHARGERID,CHARGERNAME,WATERUSERTYPEID,WATERUSERTYPENAME,WATERMETERTYPEID,WATERMETERTYPEVALUE,WATERMETERTYPECLASSID,
WATERMETERTYPECLASSNAME,WATERUSERHOUSETYPE,CREATETYPE,waterUserTelphoneNO,BUILDINGNO,UNITNO FROM V_WATERUSER_CONNECTWATERMETER WHERE waterUserId='{6}'

UPDATE waterUser SET prestore=@prestore+{3} WHERE waterUserId='{6}'

COMMIT TRAN", strGroupID, _chargeID, strTaskID, decYCMoney, strLoginID, strLoginName, strWaterUserID, txtReceiptNO.Text, PRESTORERUNNINGACCOUNTID, CHARGEID);
                        int    intRows = SqlServerHelper.ExcuteSql(strSQL);
                        if (intRows > 0)
                        {
                            decSumYuCun_YY      = decSumYuCun_YY + decYCMoney;
                            labYuCunSum_YY.Text = decSumYuCun_YY.ToString() + "元";

                            decimal decUserArearage = 0, decWaterUserPrestore = 0;
                            object  objUserArearage = dgList.SelectedRows[i].Cells["USERAREARAGE"].Value;
                            if (Information.IsNumeric(objUserArearage))
                            {
                                decUserArearage = Convert.ToDecimal(objUserArearage);
                            }
                            object objUserPrestore = dgList.SelectedRows[i].Cells["prestore"].Value;
                            if (Information.IsNumeric(objUserPrestore))
                            {
                                decWaterUserPrestore = Convert.ToDecimal(objUserPrestore);
                            }
                            decWaterUserPrestore = decWaterUserPrestore + decYCMoney;
                            decUserArearage      = decUserArearage + decYCMoney;
                            dgList.SelectedRows[i].Cells["USERAREARAGE"].Value = decUserArearage.ToString("F2");
                            dgList.SelectedRows[i].Cells["prestore"].Value     = decWaterUserPrestore.ToString("F2");

                            //如果勾选了打收据,打印收据
                            if (chkReceipt.Checked)
                            {
                                //--打印收据
                                #region
                                FastReport.Report report1 = new FastReport.Report();
                                try
                                {
                                    DataTable dtLastRecord = BLLwaterUser.QuerySQL("SELECT TOP 1 readMeterRecordId,readMeterRecordYearAndMonth,waterMeterLastNumber," +
                                                                                   "(CASE chargeState WHEN 0  THEN waterMeterLastNumber " +
                                                                                   "ELSE waterMeterEndNumber END) AS waterMeterEndNumber " +
                                                                                   "FROM readMeterRecord " +
                                                                                   "WHERE WATERUSERID='" +
                                                                                   strWaterUserID + "' ORDER BY readMeterRecordYearAndMonth DESC,readMeterRecordDate DESC");
                                    DataTable dtTemp = dtLastRecord.Clone();
                                    dtTemp.Columns["readMeterRecordYearAndMonth"].DataType = typeof(string);
                                    if (dtLastRecord.Rows.Count > 0)
                                    {
                                        dtTemp.ImportRow(dtLastRecord.Rows[0]);
                                        object objReadMeterRecordYearAndMonth = dtTemp.Rows[0]["readMeterRecordYearAndMonth"];
                                        if (Information.IsDate(objReadMeterRecordYearAndMonth))
                                        {
                                            dtTemp.Rows[0]["readMeterRecordYearAndMonth"] = Convert.ToDateTime(objReadMeterRecordYearAndMonth).ToString("yyyy-MM");
                                        }
                                    }
                                    //DataTable dtTemp = dtLastRecord.Copy();
                                    DataSet ds = new DataSet();
                                    dtTemp.TableName = "营业坐收收据模板";
                                    ds.Tables.Add(dtTemp);
                                    // load the existing report
                                    report1.Load(Application.StartupPath + @"\PRINTModel\收据模板\预存收费收据模板.frx");

                                    (report1.FindObject("txtDateTime") as FastReport.TextObject).Text               = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                                    (report1.FindObject("CellWaterUserNO") as FastReport.Table.TableCell).Text      = strWaterUserNO;
                                    (report1.FindObject("CellWaterUserName") as FastReport.Table.TableCell).Text    = strWaterUserName;
                                    (report1.FindObject("CellWaterUserAddress") as FastReport.Table.TableCell).Text = strWaterUserAddress;

                                    (report1.FindObject("txtQQYE") as FastReport.TextObject).Text = "前期余额: " + decQQYE.ToString("F2");
                                    string strBCSS = decYCMoney.ToString("F2");
                                    (report1.FindObject("txtBCJF") as FastReport.TextObject).Text             = "本次预存:         " + strBCSS;
                                    (report1.FindObject("txtJSYE") as FastReport.TextObject).Text             = "结算余额: " + decJSYE.ToString("F2");
                                    (report1.FindObject("txtChargeWorkerName") as FastReport.TextObject).Text = strLoginName;
                                    (report1.FindObject("txtReceiptNO") as FastReport.TextObject).Text        = "NO." + txtReceiptNO.Text;

                                    (report1.FindObject("txtMeterReader") as FastReport.TextObject).Text    = strMeterReaderName;
                                    (report1.FindObject("txtMeterReaderTel") as FastReport.TextObject).Text = strMeterReaderTel;

                                    string strCapMoney = RMBToCapMoney.CmycurD(strBCSS);
                                    (report1.FindObject("txtCapMoney") as FastReport.TextObject).Text = "金额大写:" + strCapMoney;

                                    // register the dataset
                                    report1.RegisterData(ds);
                                    report1.GetDataSource("营业坐收收据模板").Enabled = true;
                                    report1.PrintSettings.ShowDialog          = false;
                                    report1.Prepare();
                                    report1.Print();

                                    //获取新的收据号码,8位收据号
                                    if (Information.IsNumeric(txtReceiptNO.Text))
                                    {
                                        txtReceiptNO.Text = (Convert.ToInt64(txtReceiptNO.Text) + 1).ToString().PadLeft(8, '0');
                                    }
                                }
                                catch (Exception exx)
                                {
                                    MessageBox.Show(exx.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                                finally
                                {
                                    // free resources used by report
                                    report1.Dispose();
                                }
                                #endregion
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        mes.Show("预收失败!原因:" + ex.Message);
                        log.Write(ex.ToString(), MsgType.Error);
                        return;
                    }
                }
                btCharge.Enabled = false;
            }
            catch (Exception ex)
            {
                mes.Show(ex.Message);
                log.Write(ex.ToString(), MsgType.Error);
                return;
            }
        }
Exemplo n.º 20
0
        //导出
        void UCReport_ExportEvent(object sender, EventArgs e)
        {
            if (dt == null || dt.Rows.Count == 0)
            {
                MessageBoxEx.Show("请查询出要导出的数据!");
                return;
            }
            string fileName = GetDefaultStyleFile();
            // create report instance
            FastReport.Report report = new FastReport.Report();
            if (!string.IsNullOrEmpty(fileName))
            {
                report.Load(fileName);
                report.RegisterData(dt, styleObject);
            }
            else
            {

                Report.FastReportEx reportEx = new Report.FastReportEx();
                reportEx.dicSpanRows = dicSpanRows;
                reportEx.dt = dt;
                reportEx.styleObject = styleObject;
                reportEx.styleTitle = styleTitle;
                report = reportEx.DefaultReport();
            }
            if (report == null)
            {
                return;
            }
            report.Prepare();
            report.FileName = styleTitle;
            //PDFExport export = new PDFExport();
            //export.Name = "name";
            //export.Title = styleTitle;
            //export.Export(report,styleTitle+".pdf");
            FastReport.Export.Csv.CSVExport csvExport = new FastReport.Export.Csv.CSVExport();
            csvExport.Export(report);
            //report.Export(export, styleTitle + ".pdf");
            report.Dispose();
        }
Exemplo n.º 21
0
 private string GenderPDF(string model, DataSet ds)
 {
     //
     using (FastReport.Report report = new FastReport.Report())
     {
         report.Load(model);
         report.RegisterData(ds);
         report.Prepare(); //报告准备
         //report.PreparePhase1();
         //report.PreparePhase2();
         //初始化PDF输出类
         using (PDFExport export = new PDFExport())
         {
             this.InitPDFExport(export);
             //输出PDF
             string fileFullName = GetFileFullName();
             export.Export(report, fileFullName);
             return fileFullName;
         }
     }
 }
        private void bgWork_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                labProgress.Text = "进度:0/0";
                int intAllCount = dtUserList.Rows.Count;
                prb.Minimum = 0;
                prb.Maximum = intAllCount;
                prb.Value   = 0;
                //btCharge.Enabled = false;

                //获取连打起始号及终止号
                int intStartRow = 0, intEndRow = dgWaterUser.Rows.Count;
                if (!Information.IsNumeric(txtStartRow.Text))
                {
                    mes.Show("请输入连打起始行号!");
                    txtStartRow.Focus();
                    return;
                }
                else
                {
                    if (Convert.ToInt32(txtStartRow.Text) < 1)
                    {
                        mes.Show("连打起始行号不能小于1!");
                        txtStartRow.Focus();
                        return;
                    }
                    intStartRow = Convert.ToInt32(txtStartRow.Text);
                }
                if (Information.IsNumeric(txtEndRow.Text))
                {
                    if (Convert.ToInt32(txtStartRow.Text) > Convert.ToInt32(txtEndRow.Text))
                    {
                        mes.Show("连打起始行号不能大于终止行号!");
                        txtEndRow.Focus();
                        return;
                    }
                    if (Convert.ToInt32(txtEndRow.Text) < dgWaterUser.Rows.Count)
                    {
                        intEndRow = Convert.ToInt32(txtEndRow.Text);
                    }
                }
                //int intRowNumber=1;
                //if(Information.IsNumeric(txtStartRow.Text))
                //    intRowNumber=Convert.ToInt32(txtStartRow.Text);

                string strMaxInformNO = txtInformNO.Text.PadLeft(8, '0');
                for (int i = intStartRow - 1; i < intEndRow; i++)
                {
                    if (bgWork.CancellationPending)
                    {
                        e.Cancel = true;
                        break;
                    }
                    string strWaterUserName = "", strWaterUserID = "", strWaterUserAddress = "", strMeterReader = "", strMeterReaderTel = "";

                    object objWaterUserID = dgWaterUser.Rows[i].Cells["waterUserId"].Value;
                    if (objWaterUserID != null && objWaterUserID != DBNull.Value)
                    {
                        strWaterUserID = objWaterUserID.ToString();
                        object objWaterUserName = dgWaterUser.Rows[i].Cells["waterUserName"].Value;
                        if (objWaterUserName != null && objWaterUserName != DBNull.Value)
                        {
                            strWaterUserName = objWaterUserName.ToString();
                        }
                        object objWaterUserAddress = dgWaterUser.Rows[i].Cells["waterUserAddress"].Value;
                        if (objWaterUserAddress != null && objWaterUserAddress != DBNull.Value)
                        {
                            strWaterUserAddress = objWaterUserAddress.ToString();
                        }
                        object objMeterReader = dgWaterUser.Rows[i].Cells["meterReaderID"].Value;
                        if (objMeterReader != null && objMeterReader != DBNull.Value)
                        {
                            DataRow[] dr = dtMeterReader.Select("loginId='" + objMeterReader.ToString() + "'");
                            if (dr.Length > 0)
                            {
                                objMeterReader = dr[0]["userName"];
                                if (objMeterReader != null && objMeterReader != DBNull.Value)
                                {
                                    strMeterReader = objMeterReader.ToString();
                                }
                                objMeterReader = dr[0]["telePhoneNO"];
                                if (objMeterReader != null && objMeterReader != DBNull.Value)
                                {
                                    strMeterReaderTel = objMeterReader.ToString();
                                }
                            }
                        }

                        //获取用户余额
                        decimal decWaterUserPrestore = 0, decToltalFee = 0, decArearage = 0;
                        object  objWaterUserPreStore = BLLwaterUser.GetPrestore(" AND WATERUSERID='" + strWaterUserID + "'");
                        if (Information.IsNumeric(objWaterUserPreStore))
                        {
                            decWaterUserPrestore = Convert.ToDecimal(objWaterUserPreStore);
                        }

                        //获取用户水表欠费信息
                        string    strFilter  = " AND totalChargeEND>0 AND waterUserId='" + objWaterUserID.ToString() + "' AND chargeState=1 ORDER BY readMeterRecordYear,readMeterRecordMonth";
                        DataTable dtYSDetail = BLLreadMeterRecord.QueryYSDetailByWaterMeter(strFilter);

                        object objSumArearage = dtYSDetail.Compute("SUM(totalCharge)", "");
                        if (Information.IsNumeric(objSumArearage))
                        {
                            decToltalFee = Convert.ToDecimal(objSumArearage);
                        }
                        decArearage = decWaterUserPrestore - decToltalFee;

                        DataTable dtReadMeterRecord = BLLreadMeterRecord.Query(" AND waterUserId='" + objWaterUserID.ToString() + "' AND DATEDIFF(MONTH,readMeterRecordYearAndMonth,'" + dtpMonthSearch.Value + "')=0");

                        decimal decJianXian = 0;
                        if (Information.IsNumeric(labCondition.Text))
                        {
                            decJianXian = Convert.ToDecimal(labCondition.Text);
                        }
                        #region 打印通知单
                        DataSet   ds             = new DataSet();
                        DataTable dtYSDetailTemp = dtReadMeterRecord.Copy();
                        dtYSDetailTemp.TableName = "水费通知单模板";
                        ds.Tables.Add(dtYSDetailTemp);
                        FastReport.Report report1 = new FastReport.Report();
                        try
                        {
                            // load the existing report
                            report1.Load(Application.StartupPath + @"\PRINTModel\收据模板\水费通知单模板.frx");

                            (report1.FindObject("CellWaterUserName") as FastReport.Table.TableCell).Text    = strWaterUserName;
                            (report1.FindObject("CellWaterUserNO") as FastReport.Table.TableCell).Text      = strWaterUserID;
                            (report1.FindObject("CellWaterUserAddress") as FastReport.Table.TableCell).Text = strWaterUserAddress;
                            (report1.FindObject("txtQQYE") as FastReport.TextObject).Text =
                                "前期余额:" + decWaterUserPrestore.ToString("F2") + "     水费合计:" + decToltalFee.ToString("F2");

                            (report1.FindObject("txtQFHJ") as FastReport.TextObject).Text = "用户余额:      " + decArearage.ToString("F2");

                            (report1.FindObject("txtMeterReader") as FastReport.TextObject).Text    = strMeterReader;
                            (report1.FindObject("txtMeterReaderTel") as FastReport.TextObject).Text = strMeterReaderTel;

                            if (decJianXian == 0)
                            {
                                if (decArearage < 0)
                                {
                                    (report1.FindObject("txtTip") as FastReport.TextObject).Text = "您已欠费,请及时交纳水费";
                                }
                            }
                            else
                            if (decArearage >= 0 && decArearage <= decJianXian)
                            {
                                (report1.FindObject("txtTip") as FastReport.TextObject).Text = "您的余额已不足,请您及时交费";
                            }
                            else if (decArearage < 0)
                            {
                                (report1.FindObject("txtTip") as FastReport.TextObject).Text = "您已欠费,请您及时交纳水费";
                            }

                            (report1.FindObject("txtReceiptNO") as FastReport.TextObject).Text = "NO." + strMaxInformNO;

                            // register the dataset
                            report1.RegisterData(ds);
                            report1.GetDataSource("水费通知单模板").Enabled = true;
                            //report1.Show();
                            report1.PrintSettings.ShowDialog = false;
                            report1.Prepare();
                            report1.Print();

                            try
                            {
                                for (int j = 0; j < dtReadMeterRecord.Rows.Count; j++)
                                {
                                    object objID = dtReadMeterRecord.Rows[j]["readMeterRecordId"];
                                    if (objID != null && objID != DBNull.Value)
                                    {
                                        MODELreadMeterRecord MODELreadMeterRecord = new MODELreadMeterRecord();

                                        MODELreadMeterRecord.WATERUSERQQYEINFORM = decWaterUserPrestore;
                                        MODELreadMeterRecord.WATERUSERJSYEINFORM = decArearage;
                                        MODELreadMeterRecord.INFORMNO            = strMaxInformNO;
                                        MODELreadMeterRecord.INFORMPRINTSIGN     = "1";
                                        MODELreadMeterRecord.PRINTWORKERID       = strLogID;
                                        MODELreadMeterRecord.PRINTWORKERNAME     = strUserName;
                                        MODELreadMeterRecord.readMeterRecordId   = objID.ToString();

                                        if (!BLLreadMeterRecord.UpdateInformPrintSign(MODELreadMeterRecord))
                                        {
                                            mes.Show("更新用户'" + strWaterUserID + "-" + strWaterUserName + "'的通知单失打印标志失败,请重打通知单!");
                                            return;
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                mes.Show("更新用户'" + strWaterUserID + "-" + strWaterUserName + "'的通知单失打印标志失败,原因:" + ex.Message);
                                log.Write(ex.ToString(), MsgType.Error);
                                return;
                            }
                            strMaxInformNO = (Convert.ToInt32(strMaxInformNO) + 1).ToString().PadLeft(8, '0');
                        }
                        catch (Exception exx)
                        {
                            mes.Show(exx.Message);
                            log.Write(exx.ToString(), MsgType.Error);
                            return;
                        }
                        finally
                        {
                            // free resources used by report
                            report1.Dispose();
                        }
                        #endregion
                    }
                    else
                    {
                        mes.Show("第" + (i + 1).ToString() + "行用户ID为空,无法获取金额,请查询后重试!");
                        return;
                    }
                    prb.Value        = i + 1;
                    labProgress.Text = "进度:" + (i + 1) + "/" + intAllCount;
                }
                txtInformNO.Text = strMaxInformNO;
            }
            catch (Exception ex)
            {
                mes.Show(ex.Message);
                log.Write(ex.ToString(), MsgType.Error);
            }
        }
Exemplo n.º 23
0
        private void Btn_Submit_Click(object sender, EventArgs e)
        {
            string Matter = string.Format("【退款审批】-用户号:{0};用户名:{1};退款金额:{2};退款原因:{3}", WATERUSERNO.Text, ApplyUser.Text, CHARGEBCSS_IN.Text, RefundDescribe.Text);

            Btn_Submit.Enabled = false;
            int count = sysidal.UpdateApprove_Refund_defalut(ResolveID, IsPass.Checked, UserOpinion.Text.Trim(), PointSort, TaskID, Matter);

            if (count > 0)
            {
                if (sysidal.IsWorkTaskOver("User_Refund", TaskID))//获取审批状态,如果是Meter_WorkTask.state=5 和User_Refund.state=5,说明审批流程走完
                {
                    bool IsUserRefund = false;
                    //======================================================================================================

                    #region 20160909 ByRen
                    //修改PersonalWork_DAL类函数GetUserAllowRefund,增加预存单号ID、地址、账户余额字段,修改查询条件VV.CHARGEBCSS<=VW.prestore
                    //using BASEFUNCTION;//引用基本函数类,获取收费ID
                    //增加收费员ID和收费员姓名
                    //private string strLoginID = "";
                    //private string strUserName = "";
                    //在窗体加载时判断能否获取到收费员ID和姓名
                    //在类SqlServerHelper内添加自定义执行函数ExcuteSql
                    //新建@"\PRINTModel\收据模板\审批_退费模板.frx"打印模板
                    //-----增加了打印收据,应增加加打印收据勾选框及收据号
                    //引用fastreport类
                    //添加了退款单号的更新

                    string strWaterUserID = "", strWaterUserName = "", strWaterUserAddress = "", strChargeIDOld = "", strPrestoreRunningAccountIDOld = "",
                           strChargeIDNew = "", strPrestoreRunningAccountIDNew = "";
                    decimal decPrestore = 0, decRefund = 0;

                    DateTime dtNow = new DateTime();
                    Messages mes   = new Messages();
                    dtNow = mes.GetDatetimeNow();

                    Hashtable ht           = sysidal.GetUserAllowRefund(CHARGEID_IN.Text);
                    object    objWaterUser = ht["WATERUSERNO"];
                    if (objWaterUser != null && objWaterUser != DBNull.Value)
                    {
                        strWaterUserID = objWaterUser.ToString();

                        objWaterUser = ht["APPLYUSER"];
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strWaterUserName = objWaterUser.ToString();
                        }

                        objWaterUser = ht["WATERUSERADDRESS"];
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strWaterUserAddress = objWaterUser.ToString();
                        }

                        objWaterUser = ht["CHARGEID"];
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strChargeIDOld = objWaterUser.ToString();
                        }

                        objWaterUser = ht["PRESTORERUNNINGACCOUNTID"];
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strPrestoreRunningAccountIDOld = objWaterUser.ToString();
                        }

                        try
                        {
                            objWaterUser = ht["PRESTORE"];
                            if (objWaterUser != null && objWaterUser != DBNull.Value)
                            {
                                decPrestore = Convert.ToDecimal(objWaterUser);
                            }
                        }
                        catch (Exception ex)
                        {
                        }

                        try
                        {
                            decRefund = Convert.ToDecimal(CHARGEBCSS_IN.Text);
                        }
                        catch (Exception ex)
                        {
                        }

                        GETTABLEID GETTABLEID = new GETTABLEID();
                        strChargeIDNew = GETTABLEID.GetTableID(strLoginID, "WATERFEECHARGE");
                        strPrestoreRunningAccountIDNew = GETTABLEID.GetTableID(strLoginID, "PRESTORERUNNINGACCOUNT");

                        string strSQL = string.Format(@"
BEGIN TRAN
BEGIN
INSERT INTO PRESTORERUNNINGACCOUNT(PRESTORERUNNINGACCOUNTID,CHARGEID,WATERUSERID,WATERUSERNO,WATERUSERNAME,WATERUSERNAMECODE,WATERUSERPHONE,WATERUSERADDRESS,WATERUSERPEOPLECOUNT,AREANO,PIANNO,DUANNO,
ORDERNUMBER,COMMUNITYID,COMMUNITYNAME,BUILDINGNO,UNITNO,METERREADERID,METERREADERNAME,CHARGERID,CHARGERNAME,WATERUSERTYPEID,WATERUSERTYPENAME,WATERMETERTYPEID,
WATERMETERTYPEVALUE,WATERMETERTYPECLASSID,WATERMETERTYPECLASSNAME,WATERUSERHOUSETYPE,CREATETYPE)  
SELECT '{0}','{1}',WATERUSERID,WATERUSERNO,WATERUSERNAME,WATERUSERNAMECODE,WATERUSERPHONE,WATERUSERADDRESS,WATERUSERPEOPLECOUNT,AREANO,PIANNO,DUANNO,
ORDERNUMBER,COMMUNITYID,COMMUNITYNAME,BUILDINGNO,UNITNO,METERREADERID,METERREADERNAME,CHARGERID,CHARGERNAME,WATERUSERTYPEID,WATERUSERTYPENAME,WATERMETERTYPEID,
WATERMETERTYPEVALUE,WATERMETERTYPECLASSID,WATERMETERTYPECLASSNAME,WATERUSERHOUSETYPE,CREATETYPE FROM PRESTORERUNNINGACCOUNT 
WHERE PRESTORERUNNINGACCOUNTID='{2}'", strPrestoreRunningAccountIDNew, strChargeIDNew, strPrestoreRunningAccountIDOld);

                        strSQL += string.Format(@"
INSERT INTO WATERFEECHARGE(CHARGEID,CHARGETYPEID,CHARGEClASS,CHARGEBCSS,CHARGEYSQQYE,CHARGEYSBCSZ,CHARGEYSJSYE,CHARGEWORKERID,CHARGEWORKERNAME,CHARGEDATETIME,RECEIPTNO)
SELECT '{0}','1','6',-{1},{2},-{3},{4},'{5}','{6}',GETDATE(),RECEIPTNO FROM WATERFEECHARGE WHERE CHARGEID='{7}'",
                                                strChargeIDNew, decRefund, decPrestore, decRefund, decPrestore - decRefund, strLoginID, strUserName, strChargeIDOld);

                        strSQL += string.Format(@"
UPDATE WATERUSER SET PRESTORE={0} WHERE WATERUSERID='{1}'", decPrestore - decRefund, strWaterUserID);

                        strSQL += @"END
IF(@@ERROR>0)
BEGIN
ROLLBACK TRAN
RETURN
END
COMMIT TRAN
";

                        int intRows = 0;
                        try
                        {
                            intRows = new SqlServerHelper().ExcuteSql(strSQL);
                        }
                        catch (Exception ex)
                        {
                            mes.Show("执行退款语句失败,原因:" + ex.Message);
                            return;
                        }
                        if (intRows > 0)
                        {
                            IsUserRefund = true;
                            //打印收据
                            FastReport.Report report1 = new FastReport.Report();
                            try
                            {
                                // load the existing report
                                report1.Load(Application.StartupPath + @"\PRINTModel\收据模板\审批_退费模板.frx");
                                (report1.FindObject("CellWaterUserNO") as FastReport.Table.TableCell).Text      = strWaterUserID;
                                (report1.FindObject("CellWaterUserName") as FastReport.Table.TableCell).Text    = strWaterUserName;
                                (report1.FindObject("CellWaterUserAddress") as FastReport.Table.TableCell).Text = strWaterUserAddress;
                                (report1.FindObject("txtQQYE") as FastReport.TextObject).Text             = "前期余额:            " + decPrestore.ToString("F2");
                                (report1.FindObject("txtBCJF") as FastReport.TextObject).Text             = "本次退费: " + (0 - decRefund).ToString();
                                (report1.FindObject("txtJSYE") as FastReport.TextObject).Text             = "结算余额:            " + (decPrestore - decRefund).ToString("F2");
                                (report1.FindObject("txtChargeWorkerName") as FastReport.TextObject).Text = strUserName;
                                (report1.FindObject("txtReceiptNO") as FastReport.TextObject).Text        = "NO.";

                                (report1.FindObject("txtMeterReader") as FastReport.TextObject).Text = "抄表员";
                                report1.Prepare();
                                report1.PrintSettings.ShowDialog = false;
                                report1.Print();
                            }
                            catch (Exception ex)
                            {
                                mes.Show("打印收据错误,原因:" + ex.Message);
                            }
                            finally
                            {
                                // free resources used by report
                                report1.Dispose();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("账户余额不足或收款单号不存在,无法退款!");
                        return;
                    }
                    #endregion
                    if (IsUserRefund)
                    {
                        Hashtable hu = new Hashtable();

                        //退款时间:CHARGEID_OutTime
                        //退款金额: CHARGEBCSS_Out
                        //退款人ID:CHARGEWORKERID
                        //退款人:CHARGEWORKERNAME
                        //退款状态:IsRefund;0-未退款,1-已退款

                        hu["IsRefund"]         = 1;
                        hu["CHARGEWORKERNAME"] = AppDomain.CurrentDomain.GetData("USERNAME").ToString();
                        hu["CHARGEWORKERID"]   = AppDomain.CurrentDomain.GetData("LOGINID").ToString();
                        hu["CHARGEID_OutTime"] = DateTime.Now.ToString();
                        hu["CHARGEBCSS_Out"]   = 0;//=====================================================

                        //添加退款单号 ByRen
                        hu["CHARGEID_Out"] = strChargeIDNew;

                        int upCount = new SqlServerHelper().UpdateByHashtable("User_Refund", "TaskID", TaskID, hu);

                        if (upCount > 0)
                        {
                            this.DialogResult = DialogResult.OK;
                            MessageBox.Show("退款成功!");
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("退款成功 ,记录保存失败!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("退款失败!");
                    }
                }
                else
                {
                    this.DialogResult = DialogResult.OK;
                    MessageBox.Show("审批成功!");
                    this.Close();
                }
            }
            else
            {
                Btn_Submit.Enabled = true;
            }
        }
Exemplo n.º 24
0
        private void Btn_Print_Click(object sender, EventArgs e)
        {
            if (!Information.IsNumeric(TB_RECEIPTNO.Text))
            {
                MessageBox.Show("收据号只能由数字组成,请输入正确的收据号!");
                TB_RECEIPTNO.Focus();
                return;
            }
            TB_RECEIPTNO.Text = TB_RECEIPTNO.Text.PadLeft(8, '0');
            if (labIsFinal.Text == "预算收费")
            {
                #region 打印预算收据
                if (dtFeeList.Rows.Count == 0)
                {
                    mes.Show("预算费用明细表为空,请重新打开窗体!");
                    return;
                }
                //====================================打印
                DataSet   ds     = new DataSet();
                DataTable dtTemp = dtFeeList.Copy();
                dtTemp.TableName = "收据模板";
                ds.Tables.Add(dtTemp);
                FastReport.Report report1 = new FastReport.Report();

                try
                {
                    string strCapMoney = RMBToCapMoney.CmycurD(decSum_IsFinal0);//金额大写

                    // load the existing report
                    report1.Load(Application.StartupPath + @"\PRINTModel\业扩模板\业扩预算收据模板.frx");

                    (report1.FindObject("txtReceiptNO") as FastReport.TextObject).Text        = "NO." + TB_RECEIPTNO.Text;
                    (report1.FindObject("txtWaterUserNO") as FastReport.TextObject).Text      = "用 户 号:" + waterUserId.Text;
                    (report1.FindObject("txtSD") as FastReport.TextObject).Text               = "受理编号:" + SD.Text;
                    (report1.FindObject("txtWaterUserName") as FastReport.TextObject).Text    = "用户名称:" + waterUserName.Text;
                    (report1.FindObject("txtWaterUserAddress") as FastReport.TextObject).Text = "地    址:" + waterUserAddress.Text;

                    (report1.FindObject("txtCapMoney") as FastReport.TextObject).Text = "金额大写:" + strCapMoney;
                    (report1.FindObject("txtCasher") as FastReport.TextObject).Text   = "收 款 员:" + CHARGEWORKERNAME.Text;

                    (report1.FindObject("txtReceiptNO1") as FastReport.TextObject).Text        = "NO." + TB_RECEIPTNO.Text;
                    (report1.FindObject("txtWaterUserNO1") as FastReport.TextObject).Text      = "用 户 号:" + waterUserId.Text;
                    (report1.FindObject("txtSD1") as FastReport.TextObject).Text               = "受理编号:" + SD.Text;
                    (report1.FindObject("txtWaterUserName1") as FastReport.TextObject).Text    = "用户名称:" + waterUserName.Text;
                    (report1.FindObject("txtWaterUserAddress1") as FastReport.TextObject).Text = "地    址:" + waterUserAddress.Text;

                    (report1.FindObject("txtCapMoney1") as FastReport.TextObject).Text = "金额大写:" + strCapMoney;
                    (report1.FindObject("txtCasher1") as FastReport.TextObject).Text   = "收 款 员:" + CHARGEWORKERNAME.Text;

                    // register the dataset
                    report1.RegisterData(ds);
                    report1.GetDataSource("收据模板").Enabled = true;
                    //report1.Show();
                    report1.PrintSettings.ShowDialog = false;
                    report1.Prepare();
                    report1.Print();
                }
                catch (Exception ex)
                {
                    mes.Show("收据打印失败:" + ex.Message);
                }

                //更新预算收据号
                string strSQL = string.Format(@"UPDATE Meter_Charge SET RECEIPTPRINTCOUNT=1,ReceiptPrintSign='1',ReceiptPrintTime=GETDATE(),
RECEIPTNO='{1}' WHERE CHARGEID IN (SELECT CHARGEID FROM View_TaskFee WHERE TaskID='{0}' AND IsFinal='1')", TaskID, TB_RECEIPTNO.Text);
                int    count  = new SqlServerHelper().ExcuteSql(strSQL);
                if (count == 0)
                {
                    mes.Show("更新收据单号失败!");
                }
                #endregion
            }
            else
            {
                #region 打印决算收据
                try
                {
                    decimal decBCSS = 0;
                    if (Information.IsNumeric(CHARGEBCSS.Text))
                    {
                        decBCSS = Convert.ToDecimal(CHARGEBCSS.Text);
                    }

                    string strCapMoney = RMBToCapMoney.CmycurD(decBCSS);//金额大写

                    FastReport.Report report1 = new FastReport.Report();
                    // load the existing report
                    report1.Load(Application.StartupPath + @"\PRINTModel\业扩模板\业扩决算收据模板.frx");

                    (report1.FindObject("txtReceiptNO") as FastReport.TextObject).Text        = "NO." + TB_RECEIPTNO.Text;
                    (report1.FindObject("txtWaterUserNO") as FastReport.TextObject).Text      = "用 户 号:" + waterUserId.Text;
                    (report1.FindObject("txtSD") as FastReport.TextObject).Text               = "受理编号:" + SD.Text;
                    (report1.FindObject("txtWaterUserName") as FastReport.TextObject).Text    = "用户名称:" + waterUserName.Text;
                    (report1.FindObject("txtWaterUserAddress") as FastReport.TextObject).Text = "地    址:" + waterUserAddress.Text;

                    if (!CHARGETYPENAME.Text.Equals("现金"))
                    {
                        (report1.FindObject("txtRunningNO") as FastReport.TextObject).Text = "交易流水号:" + POSRUNNINGNO.Text;
                    }
                    else
                    {
                        (report1.FindObject("txtRunningNO") as FastReport.TextObject).Text = "";
                    }

                    (report1.FindObject("txtCapMoney") as FastReport.TextObject).Text = "金额大写:" + strCapMoney;
                    (report1.FindObject("txtCasher") as FastReport.TextObject).Text   = "收 款 员:" + CHARGEWORKERNAME.Text;
                    if (decBCSS < 0)
                    {
                        (report1.FindObject("txtWaterUserSign") as FastReport.TextObject).Text = "用户签字:";
                        (report1.FindObject("txtBCSS") as FastReport.TextObject).Text          = "本次退款:" + decBCSS.ToString("F2") + "元";
                    }
                    else
                    {
                        (report1.FindObject("txtWaterUserSign") as FastReport.TextObject).Text = "";
                        (report1.FindObject("txtBCSS") as FastReport.TextObject).Text          = "本次实收:" + decBCSS.ToString("F2") + "元";
                    }

                    (report1.FindObject("txtReceiptNO1") as FastReport.TextObject).Text        = "NO." + TB_RECEIPTNO.Text;
                    (report1.FindObject("txtWaterUserNO1") as FastReport.TextObject).Text      = "用 户 号:" + waterUserId.Text;
                    (report1.FindObject("txtSD1") as FastReport.TextObject).Text               = "受理编号:" + SD.Text;
                    (report1.FindObject("txtWaterUserName1") as FastReport.TextObject).Text    = "用户名称:" + waterUserName.Text;
                    (report1.FindObject("txtWaterUserAddress1") as FastReport.TextObject).Text = "地    址:" + waterUserAddress.Text;

                    if (!CHARGETYPENAME.Text.Equals("现金"))
                    {
                        (report1.FindObject("txtRunningNO1") as FastReport.TextObject).Text = "交易流水号:" + POSRUNNINGNO.Text;
                    }
                    else
                    {
                        (report1.FindObject("txtRunningNO1") as FastReport.TextObject).Text = "";
                    }
                    (report1.FindObject("txtCapMoney1") as FastReport.TextObject).Text = "金额大写:" + strCapMoney;
                    (report1.FindObject("txtCasher1") as FastReport.TextObject).Text   = "收 款 员:" + CHARGEWORKERNAME.Text;
                    if (decBCSS < 0)
                    {
                        (report1.FindObject("txtWaterUserSign1") as FastReport.TextObject).Text = "用户签字:";
                        (report1.FindObject("txtBCSS1") as FastReport.TextObject).Text          = "本次退款:" + decBCSS.ToString("F2") + "元";
                    }
                    else
                    {
                        (report1.FindObject("txtWaterUserSign1") as FastReport.TextObject).Text = "";
                        (report1.FindObject("txtBCSS1") as FastReport.TextObject).Text          = "本次实收:" + decBCSS.ToString("F2") + "元";
                    }

                    //report1.Show();
                    report1.PrintSettings.ShowDialog = false;
                    report1.Prepare();
                    report1.Print();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("收据打印失败:" + ex.Message);
                }
                #endregion

                //更新预算收据号
                string strSQL = string.Format(@"UPDATE Meter_Charge SET RECEIPTPRINTCOUNT=1,ReceiptPrintSign='1',ReceiptPrintTime=GETDATE(),
RECEIPTNO='{1}' WHERE CHARGEID='{0}'", _ChargeID, TB_RECEIPTNO.Text);
                int    count  = new SqlServerHelper().ExcuteSql(strSQL);
                if (count == 0)
                {
                    mes.Show("更新收据单号失败!");
                }
            }
            if (Information.IsNumeric(TB_RECEIPTNO.Text))
            {
                TB_RECEIPTNO.Text = (Convert.ToInt32(TB_RECEIPTNO.Text) + 1).ToString().PadLeft(8, '0');
            }
            else
            {
                TB_RECEIPTNO.Text = "00000001";
            }
        }
Exemplo n.º 25
0
 private void frmReportPreview_Load(object sender, EventArgs e)
 {
     PreRepot.Preview = previewControl1;
     PreRepot.Prepare();
     PreRepot.ShowPrepared();
 }
        public HttpResponseMessage PostReport(JObject JsonRequest)
        {
            int    status = 0;
            string error  = "";

            try
            {
                String className  = "FastReport." + JsonRequest["ClassName"].ToString();
                string rootPath   = System.Environment.CurrentDirectory;
                string outputPath = Path.Combine(rootPath, "output.pdf");
                //FastReport.Report report = new FastReport.Report();
                //string filename = @"C:\Users\lipan\Desktop\report3.frx";
                //report.Load(filename);
                FastReport.Report report = (FastReport.Report)Activator.CreateInstance(System.Type.GetType(className));
                DataSet           data   = new DataSet();
                DataTable         table  = new DataTable();
                int num = 0;
                foreach (var item in JsonRequest)
                {
                    if (item.Key.StartsWith("ClassName"))
                    {
                        continue;
                    }
                    if (item.Key.StartsWith("Signature"))
                    {
                        DataTable dt = new DataTable();
                        dt.TableName = item.Key;
                        dt.Columns.Add(item.Key, typeof(byte[]));
                        WebClient wc = new WebClient();
                        byte[]    bytes;
                        if (item.Value.ToString() == "")
                        {
                            //此处留空时处理;
                            bytes = wc.DownloadData(Path.Combine(rootPath, "EmptySignature.PNG"));
                        }
                        else
                        {
                            bytes = wc.DownloadData(item.Value.ToString());
                        }
                        MemoryStream msIMG = new MemoryStream(bytes);
                        Image        img   = System.Drawing.Image.FromStream(msIMG);
                        //Image img = Image.FromFile(folderPath + item.Key + ".PNG");
                        DataRow      row = dt.NewRow();
                        MemoryStream ms  = new MemoryStream();
                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
                        row[item.Key] = ms.ToArray();
                        dt.Rows.Add(row);
                        data.Tables.Add(dt);
                        continue;
                    }
                    table           = CSVHelper.ConvertJsonToDatatable(JsonRequest.ToString(), num);
                    table.TableName = item.Key;
                    data.Tables.Add(table);
                    num++;
                }
                report.RegisterData(data);
                int tableNum = data.Tables.Count;
                for (int i = 0; i < tableNum; i++)
                {
                    report.GetDataSource(data.Tables[i].TableName).Enabled = true;
                }
                report.Prepare();
                FastReport.Export.Pdf.PDFExport export = new FastReport.Export.Pdf.PDFExport();
                report.Export(export, outputPath);
                System.Diagnostics.Process.Start(outputPath);
            }
            catch (Exception e)
            {
                status = -1;
                error  = e.ToString();
            }

            String returnValue = JsonConvert.SerializeObject(new
            {
                status = status.ToString(), error = error
            });

            return(ResultToJson.toJson(returnValue));
        }
Exemplo n.º 27
0
        //----以下是MP01数据采集----
        private void GetParaDataPrint_MP01(int tt_itemtype)
        {
            //第一步数据准备
            DataSet   dst = new DataSet();
            DataTable dt  = new DataTable();

            dst.Tables.Add(dt);
            dt.Columns.Add("参数");
            dt.Columns.Add("名称");
            dt.Columns.Add("内容");


            DataRow row1 = dt.NewRow();

            row1["参数"] = "S01";
            row1["名称"] = "产品型号";
            row1["内容"] = this.label29.Text;
            dt.Rows.Add(row1);


            DataRow row2 = dt.NewRow();

            row2["参数"] = "S02";
            row2["名称"] = "COMITID";
            row2["内容"] = this.label61.Text;
            dt.Rows.Add(row2);



            DataRow row3 = dt.NewRow();

            row3["参数"] = "S03";
            row3["名称"] = "GPSN";
            row3["内容"] = this.label9.Text;
            dt.Rows.Add(row3);


            DataRow row4 = dt.NewRow();

            row4["参数"] = "S04";
            row4["名称"] = "物料编码";
            row4["内容"] = this.label49.Text;
            dt.Rows.Add(row4);

            DataRow row5 = dt.NewRow();

            row5["参数"] = "S05";
            row5["名称"] = "短MAC";
            row5["内容"] = this.label7.Text;
            dt.Rows.Add(row5);

            DataRow row6 = dt.NewRow();

            row6["参数"] = "S06";
            row6["名称"] = "长MAC";
            row6["内容"] = this.label8.Text;
            dt.Rows.Add(row6);


            this.dataGridView2.DataSource = null;
            this.dataGridView2.Rows.Clear();

            this.dataGridView2.DataSource = dst.Tables[0];
            this.dataGridView2.Update();

            this.dataGridView2.Columns[0].Width = 60;
            this.dataGridView2.Columns[1].Width = 80;
            this.dataGridView2.Columns[2].Width = 200;


            //第四步 打印或预览
            //单板打印
            if (dst.Tables.Count > 0 && dst.Tables[0].Rows.Count > 0 && tt_itemtype > 0)
            {
                FastReport.Report report = new FastReport.Report();

                report.Prepare();
                report.Load(tt_path);
                report.SetParameterValue("S01", dst.Tables[0].Rows[0][2].ToString());
                report.SetParameterValue("S02", dst.Tables[0].Rows[1][2].ToString());
                report.SetParameterValue("S03", dst.Tables[0].Rows[2][2].ToString());
                report.SetParameterValue("S04", dst.Tables[0].Rows[3][2].ToString());
                report.SetParameterValue("S05", dst.Tables[0].Rows[4][2].ToString());
                report.SetParameterValue("S06", dst.Tables[0].Rows[5][2].ToString());


                report.PrintSettings.ShowDialog = false;

                //--打印
                if (tt_itemtype == 1)
                {
                    report.Print();
                    PutLableInfor("打印完毕");
                }

                //--预览
                if (tt_itemtype == 2)
                {
                    report.Design();
                    PutLableInfor("预览完毕");
                }



                setRichtexBox("99、打印或预览完毕,请检查铭牌,OK");
            }
            else
            {
                setRichtexBox("99、获取信息失败,或不是单板扫描状态,不能打印,over");
                PutLableInfor("获取信息失败,或不是单板扫描状态,不能打印");
            }
        }
Exemplo n.º 28
0
        internal void PrintOrder(OrderInfo order, bool preview = false)
        {
            string fileName = Path.Combine(Environment.CurrentDirectory, "steelorder.frx");
            FastReport.Report report = new FastReport.Report();
            report.Load(fileName);
            report.SetParameterValue("orderno", order.orderno);
            report.SetParameterValue("orderid", order.orderid);
            report.SetParameterValue("customer", order.customer);
            report.SetParameterValue("phone", order.phone);
            report.SetParameterValue("addr", order.addr);
            report.SetParameterValue("orderdate", order.orderdate);
            string detailno = "0", guage = "", number = "", acreage = "", price = "", money = "", note = "";
            for (int i = 1; i < 6; i++)
            {
                detailno = "detailno" + i.ToString();
                guage = "guage" + i.ToString();
                number = "number" + i.ToString();
                acreage = "acreage" + i.ToString();
                price = "price" + i.ToString();
                money = "money" + i.ToString();
                note = "note" + i.ToString();
                if (i <= order.Detail.Count)
                {
                    report.SetParameterValue(detailno, order.Detail[i - 1].XH);
                    report.SetParameterValue(guage, order.Detail[i - 1].GG);
                    report.SetParameterValue(number, (order.Detail[i - 1].SL.ToString()));
                    report.SetParameterValue(acreage, (order.Detail[i - 1].MJ.ToString()));
                    report.SetParameterValue(price, (order.Detail[i - 1].DJ.ToString()));
                    report.SetParameterValue(money, (order.Detail[i - 1].JE.ToString()));
                    report.SetParameterValue(note, order.Detail[i - 1].BZ);
                }
                else
                {
                    report.SetParameterValue(detailno, i.ToString());
                    report.SetParameterValue(guage, "");
                    report.SetParameterValue(number, "");
                    report.SetParameterValue(acreage, "");
                    report.SetParameterValue(price, "");
                    report.SetParameterValue(money, "");
                    report.SetParameterValue(note, "");
                }
            }
            report.SetParameterValue("sumnumber", (order.sumnumber.ToString()));
            report.SetParameterValue("sumacreage", order.sumacreage.ToString());
            report.SetParameterValue("summoney", (order.summoney.ToString()));

            report.SetParameterValue("dxje", RMBUtils.CmycurD(Convert.ToDecimal(order.summoney)));
            report.SetParameterValue("operation", order.operation);
            report.SetParameterValue("sign", order.sign);
            report.SetParameterValue("lxdz", order.lxdz);
            report.SetParameterValue("lxdh", order.lxdh);
            report.SetParameterValue("bz", order.bz);

            report.PrintSettings.ShowDialog = false;
            //FastReport环境变量设置(打印时不提示 "正在准备../正在打印..",一个程序只需设定一次,故一般写在程序入口)
            (new FastReport.EnvironmentSettings()).ReportSettings.ShowProgress = false;
            if (preview)
            {
                report.Prepare();
                report.ShowPrepared();
            }
            else
            {
                report.Print();
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// 导出
        /// </summary>
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtCompanyCode.Text))
            {
                MessageBox.Show("请选择公司。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (string.IsNullOrEmpty(txtFilePath.Text))
            {
                MessageBox.Show("请选择保存路径。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            BaseCompanyTable    companyTable  = bCompany.GetModel(txtCompanyCode.Text.Trim());
            BllOrderHeaderTable orderTable    = bOrderH.GetModel(_slipNumber);
            BaseCustomerTable   customerTable = bCustomer.GetModel(orderTable.ENDER_CUSTOMER_CODE);

            report.Preview = previewControl1;
            DataTable dt = new DataTable();

            dt.TableName = "ds";
            dt.Columns.Add("i", System.Type.GetType("System.Decimal"));
            dt.Columns.Add("SPEC", System.Type.GetType("System.String"));
            dt.Columns.Add("QUANTITY", System.Type.GetType("System.Decimal"));
            dt.Columns.Add("PRICE", System.Type.GetType("System.Decimal"));
            dt.Columns.Add("DISCOUNT", System.Type.GetType("System.Decimal"));
            dt.Columns.Add("AMOUNT", System.Type.GetType("System.Decimal"));
            dt.Columns.Add("MATERIAL", System.Type.GetType("System.String"));
            dt.Columns.Add("MEMO", System.Type.GetType("System.String"));
            dt.Columns.Add("DESCRIPTION", System.Type.GetType("System.String"));
            dt.Columns.Add("DESCRIPTION1", System.Type.GetType("System.String"));
            int j = 1;

            foreach (BllOrderLineTable lineModel in orderTable.Items)
            {
                if (lineModel.PRICE_DISCOUNT.ToString().Equals("0.00"))
                {
                    object[] rows = { j++, lineModel.SPEC, lineModel.QUANTITY, lineModel.PRICE, null, lineModel.AMOUNT, lineModel.METERIAL, lineModel.MEMO, lineModel.DESCRIPTION, lineModel.DESCRIPTION1 };

                    dt.Rows.Add(rows);
                }
                else
                {
                    object[] rows = { j++, lineModel.SPEC, lineModel.QUANTITY, lineModel.PRICE, 0 - lineModel.PRICE_DISCOUNT, lineModel.AMOUNT, lineModel.METERIAL, lineModel.MEMO, lineModel.DESCRIPTION, lineModel.DESCRIPTION1 };
                    dt.Rows.Add(rows);
                }
            }

            DataSet ds = new DataSet();

            ds.Tables.Add(dt);

            string fileName   = "";
            string amountName = "";

            if (CConstant.LANGUAGE_CN.Equals(cboLanguage.SelectedValue))
            {
                fileName   = @"Reports\Proforma_Invoice.frx";
                amountName = NumberConvert.NumberToEnglish(CConvert.ToString(orderTable.AMOUNT_INCLUDED_TAX), false);
            }
            else if (CConstant.LANGUAGE_EN.Equals(cboLanguage.SelectedValue))
            {
                fileName   = @"Reports\Order_EN.frx";
                amountName = NumberConvert.NumberToEnglish(CConvert.ToString(orderTable.AMOUNT_INCLUDED_TAX), false);
            }

            try
            {
                if (File.Exists(fileName))
                {
                    report.Load(fileName);
                    report.SetParameterValue("CompanyName", companyTable.NAME);
                    report.SetParameterValue("EnglishCompanyName", companyTable.NAME_ENGLISH);
                    report.SetParameterValue("CompanyTel", companyTable.PHONE_NUMBER);
                    report.SetParameterValue("CompanyFax", companyTable.FAX_NUMBER);
                    report.SetParameterValue("CompanyAddress", companyTable.ADDRESS_MIDDLE);
                    report.SetParameterValue("CompanyUrl", companyTable.URL);
                    report.SetParameterValue("CompanyEmail", companyTable.EMAIL);
                    report.SetParameterValue("SlipNumber", _slipNumber);
                    report.SetParameterValue("SlipDate", CConvert.ToDateTime(orderTable.SLIP_DATE).ToString("yyyy/MM/dd"));
                    report.SetParameterValue("Currency", orderTable.CURRENCY_NAME);
                    report.SetParameterValue("CustomerName", customerTable.NAME);
                    int COUNT = 0;
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        if (dr["DISCOUNT"].ToString() != "")
                        {
                            COUNT++;
                        }
                    }
                    if (COUNT > 0)
                    {
                        report.SetParameterValue("DISCOUNT", "Discount");
                    }

                    if (customerTable.PHONE_NUMBER.ToString() != "")
                    {
                        report.SetParameterValue("CustomerTel", "Tel:" + customerTable.PHONE_NUMBER);
                    }
                    if (customerTable.FAX_NUMBER.ToString() != "")
                    {
                        report.SetParameterValue("CustomerFax", "Fax:" + customerTable.FAX_NUMBER);
                    }
                    if (customerTable.ADDRESS_FIRST.ToString() != "")
                    {
                        report.SetParameterValue("CustomerAddress", "Address:" + customerTable.ADDRESS_FIRST);
                    }
                    report.SetParameterValue("CustomerMessage", txtMessage.Text);
                    report.SetParameterValue("DeliveryTerms", orderTable.DELIVERY_TERMS);
                    report.SetParameterValue("PaymentTerms", orderTable.PAYMENT_TERMS);
                    if (orderTable.DISCOUNT_RATE > 0)
                    {
                        report.SetParameterValue("DiscountRate", "-" + orderTable.DISCOUNT_RATE + "%");
                        report.SetParameterValue("DiscountAmount", orderTable.AMOUNT_INCLUDED_TAX);
                    }
                    report.SetParameterValue("AmountName", amountName);

                    report.SetParameterValue("FullNameEn", txtBankEn.Text);
                    report.SetParameterValue("DetailEn", rtxtDetail.Text);
                    if (companyTable.COMPANY_PICTURE != null)
                    {
                        MemoryStream ms    = new MemoryStream((byte[])companyTable.COMPANY_PICTURE);
                        Image        image = Image.FromStream(ms);
                        ((FastReport.PictureObject)report.FindObject("CompanyPicture")).Image = image;
                    }
                    if (companyTable.LOGO != null)
                    {
                        MemoryStream ms1    = new MemoryStream((byte[])companyTable.LOGO);
                        Image        image1 = Image.FromStream(ms1);
                        ((FastReport.PictureObject)report.FindObject("Logo")).Image = image1;
                    }
                    report.RegisterData(ds);
                    report.Prepare();
                    if (fileName.Equals(@"Reports\Proforma_Invoice.frx"))
                    {
                        report.Export(new FastReport.Export.Pdf.PDFExport(), this.txtFilePath.Text + "\\Proforma_Invoice" + _slipNumber + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf");
                    }
                    else
                    {
                        report.Export(new FastReport.Export.Pdf.PDFExport(), this.txtFilePath.Text + "\\Order_" + _slipNumber + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf");
                    }
                    MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }

            catch (Exception ex)
            {
                Logger.Error("", ex);
            }
        }
        private void Btn_Print_Click(object sender, EventArgs e)
        {
            if (!CheckBCSS())
            {
                return;
            }
            hc["CHARGEClASS"] = 15;

            if (ReceiptPrintSign.Checked)
            {
                if (!Information.IsNumeric(RECEIPTNO.Text))
                {
                    MessageBox.Show("收据号只能由数字组成,请输入正确的收据号!");
                    RECEIPTNO.Focus();
                    return;
                }
            }

            if (!CHARGETYPEID.Text.Equals("现金"))
            {
                if (POSRUNNINGNO.Text.Trim() == "")
                {
                    MessageBox.Show("请输入交易流水号!");
                    POSRUNNINGNO.Focus();
                    return;
                }
            }
            string strCapMoney = RMBHelper.CmycurD(_BCSS);

            RECEIPTNO.Text = RECEIPTNO.Text.PadLeft(8, '0');
            if (Approve_Finance())
            {
                if (ReceiptPrintSign.Checked)
                {
                    try
                    {
                        FastReport.Report report1 = new FastReport.Report();
                        // load the existing report
                        report1.Load(Application.StartupPath + @"\PRINTModel\业扩模板\业扩决算收据模板.frx");

                        (report1.FindObject("txtReceiptNO") as FastReport.TextObject).Text        = "NO." + RECEIPTNO.Text;
                        (report1.FindObject("txtWaterUserNO") as FastReport.TextObject).Text      = "用 户 号:" + waterUserId.Text;
                        (report1.FindObject("txtSD") as FastReport.TextObject).Text               = "受理编号:" + SD.Text;
                        (report1.FindObject("txtWaterUserName") as FastReport.TextObject).Text    = "用户名称:" + waterUserName.Text;
                        (report1.FindObject("txtWaterUserAddress") as FastReport.TextObject).Text = "地    址:" + waterUserAddress.Text;

                        if (!CHARGETYPEID.Text.Equals("现金"))
                        {
                            (report1.FindObject("txtRunningNO") as FastReport.TextObject).Text = "交易流水号:" + POSRUNNINGNO.Text;
                        }
                        else
                        {
                            (report1.FindObject("txtRunningNO") as FastReport.TextObject).Text = "";
                        }

                        (report1.FindObject("txtCapMoney") as FastReport.TextObject).Text = "金额大写:" + strCapMoney;
                        (report1.FindObject("txtCasher") as FastReport.TextObject).Text   = "收 款 员:" + strRealName;
                        if (_BCSS < 0)
                        {
                            (report1.FindObject("txtWaterUserSign") as FastReport.TextObject).Text = "用户签字:";
                            (report1.FindObject("txtBCSS") as FastReport.TextObject).Text          = "本次退款:" + _BCSS.ToString("F2") + "元";
                        }
                        else
                        {
                            (report1.FindObject("txtWaterUserSign") as FastReport.TextObject).Text = "";
                            (report1.FindObject("txtBCSS") as FastReport.TextObject).Text          = "本次实收:" + _BCSS.ToString("F2") + "元";
                        }

                        (report1.FindObject("txtReceiptNO1") as FastReport.TextObject).Text        = "NO." + RECEIPTNO.Text;
                        (report1.FindObject("txtWaterUserNO1") as FastReport.TextObject).Text      = "用 户 号:" + waterUserId.Text;
                        (report1.FindObject("txtSD1") as FastReport.TextObject).Text               = "受理编号:" + SD.Text;
                        (report1.FindObject("txtWaterUserName1") as FastReport.TextObject).Text    = "用户名称:" + waterUserName.Text;
                        (report1.FindObject("txtWaterUserAddress1") as FastReport.TextObject).Text = "地    址:" + waterUserAddress.Text;

                        if (!CHARGETYPEID.Text.Equals("现金"))
                        {
                            (report1.FindObject("txtRunningNO1") as FastReport.TextObject).Text = "交易流水号:" + POSRUNNINGNO.Text;
                        }
                        else
                        {
                            (report1.FindObject("txtRunningNO1") as FastReport.TextObject).Text = "";
                        }
                        (report1.FindObject("txtCapMoney1") as FastReport.TextObject).Text = "金额大写:" + strCapMoney;
                        (report1.FindObject("txtCasher1") as FastReport.TextObject).Text   = "收 款 员:" + strRealName;
                        if (_BCSS < 0)
                        {
                            (report1.FindObject("txtWaterUserSign1") as FastReport.TextObject).Text = "用户签字:";
                            (report1.FindObject("txtBCSS1") as FastReport.TextObject).Text          = "本次退款:" + _BCSS.ToString("F2") + "元";
                        }
                        else
                        {
                            (report1.FindObject("txtWaterUserSign1") as FastReport.TextObject).Text = "";
                            (report1.FindObject("txtBCSS1") as FastReport.TextObject).Text          = "本次实收:" + _BCSS.ToString("F2") + "元";
                        }

                        //report1.Show();
                        report1.PrintSettings.ShowDialog = false;
                        report1.Prepare();
                        report1.Print();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("收据打印失败:" + ex.Message);
                    }
                    if (Information.IsNumeric(RECEIPTNO.Text))
                    {
                        RECEIPTNO.Text = (Convert.ToInt32(RECEIPTNO.Text) + 1).ToString().PadLeft(8, '0');
                    }
                    else
                    {
                        RECEIPTNO.Text = "00000001";
                    }
                }
                else
                {
                    return;
                }
                MessageBox.Show("收费成功!");
                TOTALCHARGE.Text = "0";
                CHARGEBCYS.Text  = "0";
                CHARGEBCSS.Text  = "0";
                BindDepartmentFee();

                Btn_Print.Visible  = false;
                Btn_Settle.Visible = false;
            }
            else
            {
                MessageBox.Show("结算失败!");
            }
        }
Exemplo n.º 31
0
        private void toolPrint_Click(object sender, EventArgs e)
        {
            if (dtList.Rows.Count == 0)
            {
                toolPrint.Enabled        = false;
                toolPrintPreview.Enabled = false;
                return;
            }

            DataSet   ds           = new DataSet();
            DataTable dtRecordTemp = dtList.Clone();

            dtRecordTemp.Columns["收费月份"].DataType = typeof(string);
            foreach (DataRow dr in dtList.Rows)
            {
                dtRecordTemp.ImportRow(dr);
            }
            for (int i = 0; i < dtRecordTemp.Rows.Count; i++)
            {
                object obj = dtRecordTemp.Rows[i]["收费月份"];
                if (Information.IsDate(obj))
                {
                    dtRecordTemp.Rows[i]["收费月份"] = Convert.ToDateTime(obj).ToString("yyyy-MM");
                }
                //object objWaterMeterNO = dtRecord.Rows[i]["waterMeterNo"];
                //if (objWaterMeterNO != null && objWaterMeterNO != DBNull.Value)
                //    if (objWaterMeterNO.ToString().Length > 7)
                //        dtRecord.Rows[i]["waterMeterNo"] = objWaterMeterNO.ToString().Substring(6, 2);
            }

            dtRecordTemp.ImportRow(dtSum.Rows[0]);
            DataTable dtPrint = dtRecordTemp.Copy();

            dtPrint.TableName = "一户式查询模板";

            string strWaterUserID = "", strWaterUserName = "", strAddress = "";
            object objWaterUser = dtList.Rows[0]["用户编号"];

            if (objWaterUser != null && objWaterUser != DBNull.Value)
            {
                strWaterUserID = objWaterUser.ToString();
            }
            objWaterUser = dtList.Rows[0]["用户名称"];
            if (objWaterUser != null && objWaterUser != DBNull.Value)
            {
                strWaterUserName = objWaterUser.ToString();
            }
            objWaterUser = dtList.Rows[0]["地址"];
            if (objWaterUser != null && objWaterUser != DBNull.Value)
            {
                strAddress = objWaterUser.ToString();
            }

            ds.Tables.Add(dtPrint);
            FastReport.Report report1 = new FastReport.Report();
            try
            {
                // load the existing report
                report1.Load(Application.StartupPath + @"\PRINTModel\收据模板\一户式查询模板.frx");
                (report1.FindObject("txtWaterUser") as FastReport.TextObject).Text        = "用户编号:" + strWaterUserID + "       用户名称:" + strWaterUserName;
                (report1.FindObject("txtWaterUserAddress") as FastReport.TextObject).Text = "地    址:" + strAddress;
                // register the dataset
                report1.RegisterData(ds);
                report1.GetDataSource("一户式查询模板").Enabled = true;
                // run the report
                report1.Prepare();
                report1.PrintSettings.ShowDialog = false;
                report1.Print();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
        }
Exemplo n.º 32
0
        //导出
        void UCReport_ExportEvent(object sender, EventArgs e)
        {
            string fileName = GetDefaultStyleFile();
            // create report instance
            FastReport.Report report = new FastReport.Report();
            if (!string.IsNullOrEmpty(fileName))
            {
                report.Load(fileName);
                report.RegisterData(dt, styleObject);
            }
            else
            {

                Report.FastReportEx reportEx = new Report.FastReportEx();
                reportEx.dicSpanRows = dicSpanRows;
                reportEx.dt = dt;
                reportEx.styleObject = styleObject;
                reportEx.styleTitle = styleTitle;
                report = reportEx.DefaultReport();
            }
            if (report == null)
            {
                return;
            }
            report.Prepare();
            PDFExport export = new PDFExport();
            export.Export(report);
            report.Dispose();
        }
        private void btReceiptPrint_Click(object sender, EventArgs e)
        {
            //获取连打起始号及终止号
            int intStartRow = 0, intEndRow = dgList.Rows.Count - 1;

            if (!Information.IsNumeric(txtStartRow.Text))
            {
                mes.Show("请输入连打起始行号!");
                txtStartRow.Focus();
                return;
            }
            else
            {
                if (Convert.ToInt32(txtStartRow.Text) < 1)
                {
                    mes.Show("连打起始行号不能小于1!");
                    txtStartRow.Focus();
                    return;
                }
                intStartRow = Convert.ToInt32(txtStartRow.Text);
            }
            if (Information.IsNumeric(txtEndRow.Text))
            {
                if (Convert.ToInt32(txtStartRow.Text) > Convert.ToInt32(txtEndRow.Text))
                {
                    mes.Show("连打起始行号不能大于终止行号!");
                    txtEndRow.Focus();
                    return;
                }
                if (Convert.ToInt32(txtEndRow.Text) < dgList.Rows.Count)
                {
                    intEndRow = Convert.ToInt32(txtEndRow.Text);
                }
            }
            if (mes.ShowQ("确定要打印第 " + intStartRow.ToString() + " 至第 " + intEndRow.ToString() + " 行的通知单信息吗?") != DialogResult.OK)
            {
                return;
            }

            for (int i = intStartRow - 1; i < intEndRow; i++)
            {
                //获取抄表记录ID
                string strreadMeterRecordId = "";

                //存储结算余额,如果结算余额大于0,打印模板则隐藏欠费提醒,否则显示欠费提醒。
                decimal decJSJE = 0;

                string strWaterUserID = "";
                object objWaterUserID = dtUserList.Rows[i]["waterUserId"];
                if (objWaterUserID != null && objWaterUserID != DBNull.Value)
                {
                    strWaterUserID = objWaterUserID.ToString();
                }

                DataTable dtUserListTemp = dtUserList.Copy();
                DataView  dvWaterUserID  = dtUserListTemp.DefaultView;
                dvWaterUserID.RowFilter = "waterUserId='" + strWaterUserID + "'";
                DataTable dtWaterUserID = dvWaterUserID.ToTable();

                int intCurrentPage = 0, intSumPageNO = dtWaterUserID.Rows.Count;
                if (i == intStartRow - 1 && intSumPageNO > 1)
                {
                    //如果用户数量大约1,判断第一个readMeterRecordId的rowindex和当前选择的起始rowindex是否一致,不一致则不允许打印。否则会造成打印出问题
                    int    intFirstStartRow = 0;
                    string strStartRowID = "", strFirstStartRowID = "";
                    object objreadMeterRecordId = dtUserList.Rows[i]["readMeterRecordId"];
                    if (objreadMeterRecordId != null && objreadMeterRecordId != DBNull.Value)
                    {
                        strStartRowID = objreadMeterRecordId.ToString();
                    }
                    for (int k = 0; k < dtUserList.Rows.Count; k++)
                    {
                        objreadMeterRecordId = dtUserList.Rows[k]["readMeterRecordId"];
                        if (objreadMeterRecordId != null && objreadMeterRecordId != DBNull.Value)
                        {
                            strFirstStartRowID = objreadMeterRecordId.ToString();
                            if (strStartRowID == strFirstStartRowID)
                            {
                                intFirstStartRow = k;
                                break;
                            }
                        }
                    }
                    if (i > intFirstStartRow)
                    {
                        mes.Show("请从该用户第一页通知单开始打印!");
                        return;
                    }
                }
                for (int j = 0; j < intSumPageNO; j++)
                {
                    object objreadMeterRecordId = dtWaterUserID.Rows[j]["readMeterRecordId"];
                    if (objreadMeterRecordId != null && objreadMeterRecordId != DBNull.Value)
                    {
                        strreadMeterRecordId = objreadMeterRecordId.ToString();
                        object objJSJE = dtWaterUserID.Rows[j]["WATERUSERJSYE"];
                        if (Information.IsNumeric(objJSJE))
                        {
                            decJSJE = Convert.ToDecimal(objJSJE);
                        }
                    }
                    else
                    {
                        mes.Show("第'" + (i + j + 1).ToString() + "行抄表ID获取失败,无法执行打印操作!");
                        return;
                    }
                    try
                    {
                        //存储收费表,打印收据用
                        DataTable dtRecord = dtWaterUserID.Clone();
                        dtRecord.ImportRow(dtWaterUserID.Rows[j]);

                        MODELreadMeterRecord MODELreadMeterRecord = new MODELreadMeterRecord();
                        MODELreadMeterRecord.INFORMNO          = txtInvoiceNO.Text.PadLeft(8, '0');
                        MODELreadMeterRecord.PRINTWORKERID     = strLogID;
                        MODELreadMeterRecord.PRINTWORKERNAME   = strUserName;
                        MODELreadMeterRecord.readMeterRecordId = strreadMeterRecordId;
                        if (BLLreadMeterRecord.UpdateInformNO(MODELreadMeterRecord))
                        {
                            intCurrentPage = j + 1;

                            //如果是最后一张单据显示用户余额,否则不显示余额
                            if (intCurrentPage < intSumPageNO)
                            {
                                dtRecord.Rows[0]["WATERUSERJSYE"] = DBNull.Value;
                            }

                            dtUserList.Rows[i + j]["INFORMNO"] = MODELreadMeterRecord.INFORMNO;
                            //每张通知单添加页号,方便用户区分最终的用户余额
                            DataColumn dcPage = new DataColumn("PAGESUMMERY", typeof(string));
                            dtRecord.Columns.Add(dcPage);
                            dtRecord.Rows[0]["PAGESUMMERY"] = "第" + intCurrentPage + "/" + intSumPageNO + "页";

                            #region
                            DataSet ds = new DataSet();
                            dtRecord.TableName = "水费通知单模板";
                            ds.Tables.Add(dtRecord);
                            FastReport.Report report1 = new FastReport.Report();
                            try
                            {
                                // load the existing report
                                report1.Load(Application.StartupPath + @"\PRINTModel\收据模板\水费通知单模板.frx");
                                // register the dataset
                                report1.RegisterData(ds);
                                report1.GetDataSource("水费通知单模板").Enabled = true;

                                if (decJSJE < 0)
                                {
                                    (report1.FindObject("txtQFSM") as FastReport.TextObject).Visible = true;
                                }
                                //report1.Show();
                                report1.PrintSettings.ShowDialog = false;
                                report1.Prepare();
                                report1.Print();

                                txtInvoiceNO.Text = (Convert.ToInt32(txtInvoiceNO.Text) + 1).ToString().PadLeft(8, '0');
                            }
                            catch (Exception exx)
                            {
                                mes.Show(exx.Message);
                                log.Write(exx.ToString(), MsgType.Error);
                                return;
                            }
                            finally
                            {
                                // free resources used by report
                                report1.Dispose();
                            }
                            #endregion
                        }
                    }
                    catch (Exception ex)
                    {
                        mes.Show("第" + (i + 1).ToString() + "行更新通知单号失败,原因:" + ex.Message);
                        log.Write(ex.ToString(), MsgType.Error);
                        return;
                    }
                }
                i = i + intSumPageNO - 1;//随着用户数量大约1的打印,计数器增加;
            }
        }
        private void btCharge_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgWaterUser.Rows.Count == 0)
                {
                    mes.Show("未找到预交水费的用户信息!");
                    return;
                }

                if (cmbChargeType.SelectedValue == null || cmbChargeType.SelectedValue == DBNull.Value)
                {
                    mes.Show("收费方式不能为空!");
                    cmbChargeType.Focus();
                    return;
                }
                if (!Information.IsNumeric(txtBCYC.Text))
                {
                    return;
                }
                else
                if (Convert.ToDecimal(txtBCYC.Text) <= 0)
                {
                    mes.Show("预存金额不能为'0'");
                    txtBCYC.Focus();
                    return;
                }

                for (int i = 0; i < dgWaterUser.SelectedRows.Count; i++)
                {
                    try
                    {
                        string strWaterUserID = "", strWaterUserNO = "", strWaterUserName = "", strWaterUserNameCode = "", strTelNO = "", strWaterUserPhone = "", strWaterUserAddress = "",
                               strAreaNO = "", strPianNO = "", strDuanNO = "", strCommunityID = "", strCommunityName = "", strBuildingNO = "", strUnitNO = "", strMeterReaderID = "",
                               strMeterReaderName = "", strMeterReaderTel = "", strChargeID = "", strChargerName = "", strWaterUserTypeID = "", strWaterUserTypeName = "", strWaterUserHouseType = "",
                               strCreateType = "", strWaterMeterTypeID = "", strWaterMeterTypeName = "", strWaterMeterTypeClassID = "", strWaterMeterTypeClassName = "";
                        int intPepleCount = 1, intOrderNumber = 0;

                        object objWaterUserID = dgWaterUser.SelectedRows[i].Cells["waterUserId"].Value;
                        if (objWaterUserID == null || objWaterUserID == DBNull.Value)
                        {
                            mes.Show("第'" + (i + 1).ToString() + "行用户ID获取失败,批量收费终止!");
                            return;
                        }

                        //计算结算余额
                        decimal decQQYE = 0, decJSYE = 0;
                        object  objPrestore = dgWaterUser.SelectedRows[i].Cells["prestore"].Value;
                        if (Information.IsNumeric(objPrestore))
                        {
                            decQQYE = Convert.ToDecimal(objPrestore);
                        }

                        decJSYE = decQQYE + Convert.ToDecimal(txtBCYC.Text);

                        #region 生成用户信息
                        strWaterUserID = objWaterUserID.ToString();
                        object objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["waterUserNO"].Value;
                        if (objWaterUserMes != null && objWaterUserMes != DBNull.Value)
                        {
                            strWaterUserNO = objWaterUserMes.ToString();
                        }

                        objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["waterUserName"].Value;
                        if (objWaterUserMes != null && objWaterUserMes != DBNull.Value)
                        {
                            strWaterUserName = objWaterUserMes.ToString();
                        }

                        objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["waterUserTelphoneNO"].Value;
                        if (objWaterUserMes != null && objWaterUserMes != DBNull.Value)
                        {
                            strTelNO = objWaterUserMes.ToString();
                        }

                        objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["waterPhone"].Value;
                        if (objWaterUserMes != null && objWaterUserMes != DBNull.Value)
                        {
                            strWaterUserPhone = objWaterUserMes.ToString();
                        }

                        object objWaterUser = dgWaterUser.SelectedRows[i].Cells["areaNO"].Value;
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strAreaNO = objWaterUser.ToString();
                        }
                        objWaterUser = dgWaterUser.SelectedRows[i].Cells["pianNO"].Value;
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strPianNO = objWaterUser.ToString();
                        }
                        objWaterUser = dgWaterUser.SelectedRows[i].Cells["DuanNO"].Value;
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strDuanNO = objWaterUser.ToString();
                        }
                        objWaterUser = dgWaterUser.SelectedRows[i].Cells["COMMUNITYID"].Value;
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strCommunityID = objWaterUser.ToString();
                        }
                        objWaterUser = dgWaterUser.SelectedRows[i].Cells["COMMUNITYNAME"].Value;
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strCommunityName = objWaterUser.ToString();
                        }

                        objWaterUser = dgWaterUser.SelectedRows[i].Cells["buildingNO"].Value;
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strBuildingNO = objWaterUser.ToString();
                        }

                        objWaterUser = dgWaterUser.SelectedRows[i].Cells["unitNO"].Value;
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strUnitNO = objWaterUser.ToString();
                        }

                        objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["WATERUSERTYPEID"].Value;
                        if (objWaterUserMes != null && objWaterUserMes != DBNull.Value)
                        {
                            strWaterUserTypeID = objWaterUserMes.ToString();
                        }

                        objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["waterUserTypeName"].Value;
                        if (objWaterUserMes != null && objWaterUserMes != DBNull.Value)
                        {
                            strWaterUserTypeName = objWaterUserMes.ToString();
                        }

                        objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["WATERMETERTYPEID"].Value;
                        if (objWaterUserMes != null && objWaterUserMes != DBNull.Value)
                        {
                            strWaterMeterTypeID = objWaterUserMes.ToString();
                        }

                        objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["WATERMETERTYPEVALUE"].Value;
                        if (objWaterUserMes != null && objWaterUserMes != DBNull.Value)
                        {
                            strWaterMeterTypeName = objWaterUserMes.ToString();
                        }

                        objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["WATERMETERTYPECLASSID"].Value;
                        if (objWaterUserMes != null && objWaterUserMes != DBNull.Value)
                        {
                            strWaterMeterTypeClassID = objWaterUserMes.ToString();
                        }

                        objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["WATERMETERTYPECLASSNAME"].Value;
                        if (objWaterUserMes != null && objWaterUserMes != DBNull.Value)
                        {
                            strWaterMeterTypeClassName = objWaterUserMes.ToString();
                        }

                        objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["waterUserAddress"].Value;
                        if (objWaterUserMes != null && objWaterUserMes != DBNull.Value)
                        {
                            strWaterUserAddress = objWaterUserMes.ToString();
                        }
                        objWaterUser = dgWaterUser.SelectedRows[i].Cells["createType"].Value;
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strCreateType = objWaterUser.ToString();
                        }

                        objWaterUser = dgWaterUser.SelectedRows[i].Cells["METERREADERID"].Value;
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strMeterReaderID = objWaterUser.ToString();

                            DataRow[] drMeterReader     = dtMeterReader.Select("LOGINID='" + strMeterReaderID + "'");
                            object    objMeterReaderTel = drMeterReader[0]["TELEPHONENO"];
                            if (objMeterReaderTel != null && objMeterReaderTel != DBNull.Value)
                            {
                                strMeterReaderTel = objMeterReaderTel.ToString();
                            }
                        }

                        objWaterUser = dgWaterUser.SelectedRows[i].Cells["meterReaderName"].Value;
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strMeterReaderName = objWaterUser.ToString();
                        }

                        objWaterUser = dgWaterUser.SelectedRows[i].Cells["chargerName"].Value;
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strChargerName = objWaterUser.ToString();
                        }

                        objWaterUser = dgWaterUser.SelectedRows[i].Cells["CHARGERID"].Value;
                        if (objWaterUser != null && objWaterUser != DBNull.Value)
                        {
                            strChargeID = objWaterUser.ToString();
                        }

                        objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["waterUserHouseTypeS"].Value;
                        if (objWaterUserMes != null && objWaterUserMes != DBNull.Value)
                        {
                            strWaterUserHouseType = objWaterUserMes.ToString();
                        }

                        objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["ordernumber"].Value;
                        if (Information.IsNumeric(objWaterUserMes))
                        {
                            intOrderNumber = Convert.ToInt16(objWaterUserMes);
                        }

                        objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["WATERUSERPEOPLECOUNT"].Value;
                        if (Information.IsNumeric(objWaterUserMes))
                        {
                            intPepleCount = Convert.ToInt16(objWaterUserMes);
                        }
                        #endregion

                        MODELWATERFEECHARGE MODELWATERFEECHARGE = new MODELWATERFEECHARGE();
                        MODELWATERFEECHARGE.CHARGEID     = GETTABLEID.GetTableID(strLoginID, "WATERFEECHARGE");
                        MODELWATERFEECHARGE.CHARGETYPEID = cmbChargeType.SelectedValue.ToString();
                        if (cmbChargeType.SelectedValue.ToString() == "2")
                        {
                            MODELWATERFEECHARGE.POSRUNNINGNO = txtJYLSH.Text;
                        }
                        MODELWATERFEECHARGE.CHARGEClASS      = "2";//收费类型是水费预收
                        MODELWATERFEECHARGE.CHARGEBCSS       = Convert.ToDecimal(txtBCYC.Text);
                        MODELWATERFEECHARGE.CHARGEYSQQYE     = decQQYE;
                        MODELWATERFEECHARGE.CHARGEYSBCSZ     = Convert.ToDecimal(txtBCYC.Text);
                        MODELWATERFEECHARGE.CHARGEYSJSYE     = decJSYE;
                        MODELWATERFEECHARGE.CHARGEWORKERID   = strLoginID;
                        MODELWATERFEECHARGE.CHARGEWORKERNAME = strLoginName;
                        MODELWATERFEECHARGE.CHARGEDATETIME   = mes.GetDatetimeNow();
                        MODELWATERFEECHARGE.INVOICEPRINTSIGN = "0";
                        if (chkReceipt.Checked)
                        {
                            MODELWATERFEECHARGE.RECEIPTPRINTCOUNT = 1;
                            MODELWATERFEECHARGE.RECEIPTNO         = txtReceiptNO.Text;
                        }
                        if (BLLWATERFEECHARGE.Insert(MODELWATERFEECHARGE))
                        {
                            try
                            {
                                MODELPRESTORERUNNINGACCOUNT MODELPRESTORERUNNINGACCOUNT = new MODELPRESTORERUNNINGACCOUNT();
                                MODELPRESTORERUNNINGACCOUNT.PRESTORERUNNINGACCOUNTID = GETTABLEID.GetTableID(strLoginID, "PRESTORERUNNINGACCOUNT");
                                MODELPRESTORERUNNINGACCOUNT.WATERUSERID       = strWaterUserID;
                                MODELPRESTORERUNNINGACCOUNT.WATERUSERNO       = strWaterUserNO;
                                MODELPRESTORERUNNINGACCOUNT.WATERUSERNAME     = strWaterUserName;
                                MODELPRESTORERUNNINGACCOUNT.WATERUSERNAMECODE = strWaterUserNameCode;
                                MODELPRESTORERUNNINGACCOUNT.WATERUSERPHONE    = strTelNO;
                                if (strWaterUserPhone != "")
                                {
                                    if (strTelNO != "")
                                    {
                                        MODELPRESTORERUNNINGACCOUNT.WATERUSERPHONE = strTelNO + ";" + strWaterUserPhone;
                                    }
                                    else
                                    {
                                        MODELPRESTORERUNNINGACCOUNT.WATERUSERPHONE = strWaterUserPhone;
                                    }
                                }

                                MODELPRESTORERUNNINGACCOUNT.WATERUSERADDRESS     = strWaterUserAddress;
                                MODELPRESTORERUNNINGACCOUNT.WATERUSERPEOPLECOUNT = intPepleCount;
                                MODELPRESTORERUNNINGACCOUNT.AREANO        = strAreaNO;
                                MODELPRESTORERUNNINGACCOUNT.PIANNO        = strPianNO;
                                MODELPRESTORERUNNINGACCOUNT.DUANNO        = strDuanNO;
                                MODELPRESTORERUNNINGACCOUNT.COMMUNITYID   = strCommunityID;
                                MODELPRESTORERUNNINGACCOUNT.COMMUNITYNAME = strCommunityName;

                                MODELPRESTORERUNNINGACCOUNT.ORDERNUMBER             = intOrderNumber;
                                MODELPRESTORERUNNINGACCOUNT.BUILDINGNO              = strBuildingNO;
                                MODELPRESTORERUNNINGACCOUNT.UNITNO                  = strUnitNO;
                                MODELPRESTORERUNNINGACCOUNT.METERREADERID           = strMeterReaderID;
                                MODELPRESTORERUNNINGACCOUNT.METERREADERNAME         = strMeterReaderName;
                                MODELPRESTORERUNNINGACCOUNT.CHARGERID               = strLoginID;
                                MODELPRESTORERUNNINGACCOUNT.CHARGERNAME             = strLoginName;
                                MODELPRESTORERUNNINGACCOUNT.WATERUSERTYPEID         = strWaterUserTypeID;
                                MODELPRESTORERUNNINGACCOUNT.WATERUSERTYPENAME       = strWaterUserTypeName;
                                MODELPRESTORERUNNINGACCOUNT.waterMeterTypeId        = strWaterMeterTypeID;
                                MODELPRESTORERUNNINGACCOUNT.waterMeterTypeValue     = strWaterMeterTypeName;
                                MODELPRESTORERUNNINGACCOUNT.WATERMETERTYPECLASSID   = strWaterMeterTypeClassID;
                                MODELPRESTORERUNNINGACCOUNT.WATERMETERTYPECLASSNAME = strWaterMeterTypeClassName;
                                MODELPRESTORERUNNINGACCOUNT.WATERUSERTYPENAME       = strWaterUserTypeName;
                                MODELPRESTORERUNNINGACCOUNT.WATERUSERTYPENAME       = strWaterUserTypeName;
                                MODELPRESTORERUNNINGACCOUNT.WATERUSERHOUSETYPE      = strWaterUserHouseType;
                                MODELPRESTORERUNNINGACCOUNT.CREATETYPE              = strCreateType;
                                MODELPRESTORERUNNINGACCOUNT.MEMO     = txtMemo.Text;
                                MODELPRESTORERUNNINGACCOUNT.CHARGEID = MODELWATERFEECHARGE.CHARGEID;
                                if (BLLPRESTORERUNNINGACCOUNT.Insert(MODELPRESTORERUNNINGACCOUNT))
                                {
                                    //txtYSQQYE.Text = txtJSYE.Text;
                                    //txtWaterFeeReal.Text =( Convert.ToDecimal(txtWaterFee.Text) - Convert.ToDecimal(txtYSQQYE.Text)).ToString();
                                    //txtBCYC.Text = "0";

                                    //更新余额
                                    string strUpdatePrestore = "UPDATE waterUser SET prestore=" + MODELWATERFEECHARGE.CHARGEYSJSYE + " WHERE waterUserId='" + strWaterUserID + "'";
                                    if (!BLLwaterUser.UpdateSQL(strUpdatePrestore))
                                    {
                                        string strError = "更新用户编号为'" + strWaterUserNO + "'的余额失败,请重新收费!";
                                        mes.Show(strError);
                                        log.Write(strError, MsgType.Error);
                                        //回滚预存流水表
                                        BLLPRESTORERUNNINGACCOUNT.Delete(MODELPRESTORERUNNINGACCOUNT.PRESTORERUNNINGACCOUNTID);
                                        //回滚收费记录表
                                        BLLWATERFEECHARGE.Delete(MODELWATERFEECHARGE.CHARGEID);
                                    }
                                    else
                                    {
                                        decimal decUserArearage = 0, decWaterUserPrestore = 0;
                                        object  objUserArearage = dgWaterUser.SelectedRows[i].Cells["USERAREARAGE"].Value;
                                        if (Information.IsNumeric(objUserArearage))
                                        {
                                            decUserArearage = Convert.ToDecimal(objUserArearage);
                                        }
                                        object objUserPrestore = dgWaterUser.SelectedRows[i].Cells["prestore"].Value;
                                        if (Information.IsNumeric(objUserPrestore))
                                        {
                                            decWaterUserPrestore = Convert.ToDecimal(objUserPrestore);
                                        }
                                        decWaterUserPrestore = decWaterUserPrestore + MODELWATERFEECHARGE.CHARGEBCSS;
                                        decUserArearage      = decUserArearage + MODELWATERFEECHARGE.CHARGEBCSS;
                                        dgWaterUser.SelectedRows[i].Cells["USERAREARAGE"].Value = decUserArearage.ToString("F2");
                                        dgWaterUser.SelectedRows[i].Cells["prestore"].Value     = decWaterUserPrestore.ToString("F2");
                                    }
                                    //如果勾选了打收据,打印收据
                                    if (chkReceipt.Checked)
                                    {
                                        //--打印收据
                                        #region
                                        FastReport.Report report1 = new FastReport.Report();
                                        try
                                        {
                                            DataTable dtLastRecord = BLLwaterUser.QuerySQL("SELECT TOP 1 readMeterRecordId,readMeterRecordYearAndMonth,waterMeterLastNumber," +
                                                                                           "(CASE chargeState WHEN 0  THEN waterMeterLastNumber " +
                                                                                           "ELSE waterMeterEndNumber END) AS waterMeterEndNumber " +
                                                                                           "FROM readMeterRecord " +
                                                                                           "WHERE WATERUSERID='" +
                                                                                           strWaterUserID + "' ORDER BY readMeterRecordYearAndMonth DESC,readMeterRecordDate DESC");
                                            DataTable dtTemp = dtLastRecord.Clone();
                                            dtTemp.Columns["readMeterRecordYearAndMonth"].DataType = typeof(string);
                                            if (dtLastRecord.Rows.Count > 0)
                                            {
                                                dtTemp.ImportRow(dtLastRecord.Rows[0]);
                                                object objReadMeterRecordYearAndMonth = dtTemp.Rows[0]["readMeterRecordYearAndMonth"];
                                                if (Information.IsDate(objReadMeterRecordYearAndMonth))
                                                {
                                                    dtTemp.Rows[0]["readMeterRecordYearAndMonth"] = Convert.ToDateTime(objReadMeterRecordYearAndMonth).ToString("yyyy-MM");
                                                }
                                            }
                                            //DataTable dtTemp = dtLastRecord.Copy();
                                            DataSet ds = new DataSet();
                                            dtTemp.TableName = "营业坐收收据模板";
                                            ds.Tables.Add(dtTemp);
                                            // load the existing report
                                            report1.Load(Application.StartupPath + @"\PRINTModel\收据模板\预存收费收据模板.frx");

                                            (report1.FindObject("txtDateTime") as FastReport.TextObject).Text = MODELWATERFEECHARGE.CHARGEDATETIME.ToString("yyyy-MM-dd HH:mm:ss");
                                            //if (cmbChargeType.SelectedValue.ToString() == "2")
                                            //{
                                            //    (report1.FindObject("Cell45") as FastReport.Table.TableCell).Text = txtWaterUserNO.Text + "   交易流水号:" + txtJYLSH.Text;
                                            //}
                                            //else
                                            (report1.FindObject("CellWaterUserNO") as FastReport.Table.TableCell).Text      = strWaterUserNO;
                                            (report1.FindObject("CellWaterUserName") as FastReport.Table.TableCell).Text    = strWaterUserName;
                                            (report1.FindObject("CellWaterUserAddress") as FastReport.Table.TableCell).Text = strWaterUserAddress;

                                            (report1.FindObject("txtQQYE") as FastReport.TextObject).Text = "前期余额: " + MODELWATERFEECHARGE.CHARGEYSQQYE.ToString("F2");
                                            string strBCSS = MODELWATERFEECHARGE.CHARGEBCSS.ToString("F2");
                                            (report1.FindObject("txtBCJF") as FastReport.TextObject).Text = "本次预存:         " + strBCSS;
                                            (report1.FindObject("txtJSYE") as FastReport.TextObject).Text = "结算余额: " + MODELWATERFEECHARGE.CHARGEYSJSYE.ToString("F2");

                                            //if (cmbChargeType.SelectedValue.ToString() == "2")
                                            //{
                                            //    (report1.FindObject("txtPOSRUNNINGNO") as FastReport.TextObject).Text = "交易流水号: " + MODELWATERFEECHARGE.POSRUNNINGNO;
                                            //}
                                            (report1.FindObject("txtChargeWorkerName") as FastReport.TextObject).Text = strLoginName;
                                            (report1.FindObject("txtReceiptNO") as FastReport.TextObject).Text        = "NO." + txtReceiptNO.Text;

                                            (report1.FindObject("txtMeterReader") as FastReport.TextObject).Text    = strMeterReaderName;
                                            (report1.FindObject("txtMeterReaderTel") as FastReport.TextObject).Text = strMeterReaderTel;

                                            string strCapMoney = RMBToCapMoney.CmycurD(strBCSS);
                                            if (cmbChargeType.SelectedValue.ToString() == "2")
                                            {
                                                (report1.FindObject("txtCapMoney") as FastReport.TextObject).Text = "金额大写:" + strCapMoney + Environment.NewLine + "交易流水号:" + txtJYLSH.Text;
                                            }
                                            else
                                            {
                                                (report1.FindObject("txtCapMoney") as FastReport.TextObject).Text = "金额大写:" + strCapMoney;
                                            }

                                            // register the dataset
                                            report1.RegisterData(ds);
                                            report1.GetDataSource("营业坐收收据模板").Enabled = true;
                                            report1.PrintSettings.ShowDialog          = false;
                                            report1.Prepare();
                                            report1.Print();

                                            //获取新的收据号码,8位收据号
                                            if (Information.IsNumeric(txtReceiptNO.Text))
                                            {
                                                txtReceiptNO.Text = (Convert.ToInt64(txtReceiptNO.Text) + 1).ToString().PadLeft(8, '0');
                                            }
                                        }
                                        catch (Exception exx)
                                        {
                                            MessageBox.Show(exx.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                            return;
                                        }
                                        finally
                                        {
                                            // free resources used by report
                                            report1.Dispose();
                                        }
                                        #endregion
                                    }
                                }
                            }
                            catch (Exception exx)
                            {
                                mes.Show("插入预收流水表失败!原因:" + exx.Message);
                                log.Write(exx.ToString(), MsgType.Error);
                                return;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        mes.Show("预收失败!原因:" + ex.Message);
                        log.Write(ex.ToString(), MsgType.Error);
                        return;
                    }
                }
                btCharge.Enabled = false;
                //dgWaterList.DataSource = null;
            }
            catch (Exception ex)
            {
                mes.Show(ex.Message);
                log.Write(ex.ToString(), MsgType.Error);
                return;
            }
        }
Exemplo n.º 35
0
        public static string GetReportString(string reportFilePath, string dataSetName, IEnumerable <object> data, string exportFormat)
        {
            FastReport.Report report = new FastReport.Report();
            string            result = string.Empty;

            if (FileHelper.IsExistFile(reportFilePath))
            {
                try
                {
                    report.Load(reportFilePath);            // Download the report
                    report.RegisterData(data, dataSetName); // Register data in the report
                }
                catch
                {
                    //var log = LogFactory.GetLogger("FastReportHelper");
                    //log.Error(ex.Message);
                    return(result);
                }
                using (MemoryStream stream = new MemoryStream())
                {
                    if (exportFormat.Equals("pdf", StringComparison.InvariantCultureIgnoreCase))
                    {
                        //FastReport.Export.Pdf.PDFExport pdf = new FastReport.Export.Pdf.PDFExport {
                        //    Producer = "",
                        //    AllowPrint=true,
                        //    AllowModify=true,
                        //    PrintScaling=true,

                        //    RichTextQuality=100,
                        //    Compressed=false
                        //};
                        //report.Export(pdf, stream);

                        //FileHelper.CreateFile("\\log\\PDF" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg", stream.ToArray());
                    }
                    else if (exportFormat.Equals("Jpeg", StringComparison.InvariantCultureIgnoreCase))
                    {
                        FastReport.Export.Image.ImageExport image = new FastReport.Export.Image.ImageExport
                        {
                            ImageFormat   = FastReport.Export.Image.ImageExportFormat.Jpeg,
                            SeparateFiles = false,
                            JpegQuality   = 100
                        };
                        report.Prepare();
                        report.Export(image, stream);
                        FileHelper.CreateFile("\\log\\JPG" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg", stream.ToArray());

                        //foreach (var item in image.GeneratedFiles)
                        //{
                        //    var temp = item;
                        //    var log = LogFactory.GetLogger("FastReportHelper");
                        //    log.Info(temp);
                        //}
                        //return report.SaveToStringBase64();
                    }
                    else if (exportFormat.Equals("Bmp", StringComparison.InvariantCultureIgnoreCase))
                    {
                        FastReport.Export.Image.ImageExport image = new FastReport.Export.Image.ImageExport
                        {
                            ImageFormat = FastReport.Export.Image.ImageExportFormat.Bmp
                        };
                        report.Prepare();
                        report.Export(image, stream);
                    }
                    else if (exportFormat.Equals("Gif", StringComparison.InvariantCultureIgnoreCase))
                    {
                        FastReport.Export.Image.ImageExport image = new FastReport.Export.Image.ImageExport
                        {
                            ImageFormat = FastReport.Export.Image.ImageExportFormat.Gif
                        };
                        report.Prepare();
                        report.Export(image, stream);
                    }
                    else if (exportFormat.Equals("Png", StringComparison.InvariantCultureIgnoreCase))
                    {
                        FastReport.Export.Image.ImageExport image = new FastReport.Export.Image.ImageExport
                        {
                            ImageFormat   = FastReport.Export.Image.ImageExportFormat.Png,
                            SeparateFiles = false
                        };
                        report.Prepare();
                        report.Export(image, stream);
                    }
                    else if (exportFormat.Equals("Tiff", StringComparison.InvariantCultureIgnoreCase))
                    {
                        FastReport.Export.Image.ImageExport image = new FastReport.Export.Image.ImageExport
                        {
                            ImageFormat = FastReport.Export.Image.ImageExportFormat.Tiff
                        };
                        report.Prepare();
                        report.Export(image, stream);
                    }
                    else if (exportFormat.Equals("html", StringComparison.InvariantCultureIgnoreCase))
                    {
                        FastReport.Export.Html.HTMLExport image = new FastReport.Export.Html.HTMLExport
                        {
                            EnableMargins = false,
                            Pictures      = true,
                            EmbedPictures = true,
                            ImageFormat   = ImageFormat.Png
                        };
                        report.Prepare();
                        report.Export(image, stream);
                        return(System.Text.Encoding.UTF8.GetString(stream.ToArray()));
                    }


                    result = Convert.ToBase64String(stream.ToArray());
                }
            }
            else
            {
                //var log = LogFactory.GetLogger("FastReportHelper");
                //log.Error(reportFilePath + ",目录不存在!");
            }
            return(result);
        }