Exemplo n.º 1
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.º 2
0
 /// <summary>
 /// 明细设计
 /// </summary>
 /// <param name="dic"></param>
 public void DetailDesigner(Dictionary<string, DataTable> dic)
 {
     if (dic == null)
     {
         return;
     }
     FastReport.Report report = new FastReport.Report();
     foreach (string key in dic.Keys)
     {
         report.RegisterData(dic[key], key);
     }
     //report.Show();
     report.Design();
     report.Dispose();
     dic = null;
 }
        private void toolPrintPreview_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 + "张";
                (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.Show();
            }
            catch (Exception exx)
            {
                MessageBox.Show(exx.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // free resources used by report
                report1.Dispose();
            }
            #endregion
        }
Exemplo n.º 4
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.º 5
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.º 6
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.º 7
0
        void ButtonJSPreviewClick(object sender, EventArgs e)
        {
            if (CheckFillOK())
            {
                DataSet   tmpDs    = new DataSet();
                DataSet   FDataSet = new DataSet();
                DataTable table    = new DataTable();


                int i_ProjectID;
                int i_CompanyID;
                i_ProjectID = Convert.ToInt32(comboBoxProject.SelectedValue.ToString());
                i_CompanyID = Convert.ToInt32(comboBoxCompany.SelectedValue.ToString());
                LeaseHT tLeaseHT = BLL.LeaseBLL.GetLeaseHT(i_ProjectID, i_CompanyID);

                tmpDs           = BLL.LeaseBLL.GetLeaseAccountDs(0);            //随便取数据,用空结构填充
                table           = tmpDs.Tables[0].Clone();
                table.TableName = "LeaseAccount";
                FDataSet.Tables.Add(table);

                tmpDs           = BLL.LeaseBLL.GetLeaseAccountList(0);
                table           = tmpDs.Tables[0].Clone();
                table.TableName = "LeaseAccountList";
                FDataSet.Tables.Add(table);

                tmpDs           = BLL.LeaseBLL.GetLeaseAccountLeft(0);
                table           = tmpDs.Tables[0].Clone();
                table.TableName = "LeaseAccountLeft";
                FDataSet.Tables.Add(table);

                //将需要结算的数据填写到报表中的表中
                FillReportData(FDataSet);

                FastReport.Report report1 = new FastReport.Report();
                report1.Load("Reports\\LeaseJS.frx");
                report1.RegisterData(FDataSet);
                report1.Show();
                report1.Dispose();
            }
        }
Exemplo n.º 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            string  sql      = "select * from fastReportForPrint where frxName='frxa.frx'";
            DataSet dsa      = getDataSet(sql);
            DataSet FDataSet = new DataSet();

            if (dsa.Tables[0].Rows.Count > 0)
            {
                sql      = dsa.Tables[0].Rows[0]["sqlStr"].ToString() + " where id=1";
                FDataSet = getDataSet(sql);
                FastReport.Report report1 = new FastReport.Report();
                try
                {
                    // load the existing report
                    report1.Load(dsa.Tables[0].Rows[0]["frxName"].ToString());
                    // register the dataset
                    report1.RegisterData(FDataSet);
                    report1.GetDataSource(dsa.Tables[0].Rows[0]["fromTable"].ToString()).Enabled = true;
                    // run the report
                    report1.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    // free resources used by report
                    report1.Dispose();
                }
            }

            //DataTable table = new DataTable();
            //table.TableName = "S_User";
            //FDataSet.Tables.Add(table);
            //table.Columns.Add("Name", typeof(string));
            //table.Columns.Add("Pwd", typeof(string));
            //table.Rows.Add("管理员", "19A2854144B63A8F7617A6F225019B12");
            //table.Rows.Add("超级管理员", "EBEC10142B9FC9E4E67B0CFD347E23E6");
        }
Exemplo n.º 9
0
        void ButtonPrintJFClick(object sender, EventArgs e)
        {
            DataSet tmpDs = BLL.ChargeBLL.GetJFDs();

            //
            FastReport.Report report1 = new FastReport.Report();
            report1.Load("Reports\\JFPrint.frx");

            DataSet   FDataSet = new DataSet();
            DataTable table    = new DataTable();

            table           = tmpDs.Tables[0].Copy();
            table.TableName = "Charge";
            FDataSet.Tables.Add(table);

            tmpDs           = BLL.ChargeBLL.GetCanSFAll(textBoxPeriodNo.Text);
            table           = tmpDs.Tables[0].Copy();
            table.TableName = "ChargeDetail";
            FDataSet.Tables.Add(table);
            DataRelation dr = new DataRelation("FK_1", FDataSet.Tables["Charge"].Columns["CID"], FDataSet.Tables["ChargeDetail"].Columns["CID"]);

            FDataSet.Relations.Add(dr);

            tmpDs           = BLL.CustomersBLL.GetAllCustomers();
            table           = tmpDs.Tables[0].Copy();
            table.TableName = "Customers";
            FDataSet.Tables.Add(table);

            tmpDs           = BLL.WyInfosBLL.GetAllWyInfos();
            table           = tmpDs.Tables[0].Copy();
            table.TableName = "WyInfos";
            FDataSet.Tables.Add(table);
            dr = new DataRelation("FK_2", FDataSet.Tables["Customers"].Columns["CustomerID"], FDataSet.Tables["Wyinfos"].Columns["CustomerID"]);
            FDataSet.Relations.Add(dr);

            report1.RegisterData(FDataSet);
            report1.Show();
            report1.Dispose();
        }
Exemplo n.º 10
0
 /// <summary>
 /// 明细设计
 /// </summary>
 /// <param name="dic"></param>
 public void DetailDesigner(Dictionary <string, DataTable> dic)
 {
     if (dic == null)
     {
         return;
     }
     FastReport.Report report = new FastReport.Report();
     foreach (string key in dic.Keys)
     {
         report.RegisterData(dic[key], key);
     }
     //FastReport.Report report = GetDetailReport(dic);
     //if (report == null)
     //{
     //    return;
     //}
     //report.Prepare();
     //report.Show();
     report.DoublePass = true;
     report.Design();
     report.Dispose();
     dic = null;
 }
Exemplo n.º 11
0
        void ButtonPrtRKDClick(object sender, EventArgs e)
        {
            //打印入库单
            FastReport.Report report1 = new FastReport.Report();
            report1.Load("Reports\\RKD.frx");
            int i_ReceiptID = Convert.ToInt32(dataGridView1.CurrentRow.Cells["ReceiptID"].Value.ToString());

            DataSet   FDataSet = new DataSet();
            DataTable table    = new DataTable();
            DataSet   ds1      = BLL.RKBLL.GetReceipt1(i_ReceiptID);

            table           = ds1.Tables[0].Copy();
            table.TableName = "Receipt";
            FDataSet.Tables.Add(table);

            ds1             = BLL.RKBLL.GetReceiptItems(i_ReceiptID);
            table           = ds1.Tables[0].Copy();
            table.TableName = "ReceiptItems";
            FDataSet.Tables.Add(table);

            report1.RegisterData(FDataSet);
            report1.Show();
            report1.Dispose();
        }
Exemplo n.º 12
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.º 13
0
 /// <summary>
 /// 打印预览
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void tsmPreviewReport_Click(object sender, EventArgs e)
 {
     report = new FastReport.Report();
     if (!report.IsRunning)
     {
         GetData(tsmChooseDetail[iDefaultChecked].Name);
         report.Load(new MemoryStream(bt));
         RegReportData();
     }
     frmReportPreview rp = new frmReportPreview(report);
     rp.ShowDialog();
     report.Dispose();
 }
Exemplo n.º 14
0
 /// <summary>
 /// 打印
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void tsmPrintReport_Click(object sender, EventArgs e)
 {
     report = new FastReport.Report();
     if (!report.IsPrinting)
     {
         GetData(tsmChooseDetail[iDefaultChecked].Name);
         report.Load(new MemoryStream(bt));
         RegReportData();
     }
     report.Print();
     report.Dispose();
 }
Exemplo n.º 15
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.º 16
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.º 17
0
        public static void getReport(string SQL, string AliasName, string FolderName, string FileName)
        {
            FastReport.Report report = new FastReport.Report();
            try
            {
                if (Function.FTPDownload(@"C:\Report/" + FolderName, FolderName, FileName))
                {
                    DataTable dt = Services.Database.ExecuteQuery(SQL).Tables[0];

                    report.RegisterData(dt, AliasName);
                    report.GetDataSource(AliasName).Enabled = true;
                    report.Load(@"C:\Report/" + FolderName + "/" + FileName);
                    report.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Дараахи алдаа гарлаа. " + ex.Message.ToString(), "Алдаа", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                report.Dispose();
            }
        }
        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.º 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
        private void Btn_Print_Click(object sender, EventArgs e)
        {
            if (RECEIPTNO.Text.Trim() == "")
            {
                mes.Show("请输入收据号!");
                RECEIPTNO.Focus();
                return;
            }
            if (!Information.IsNumeric(RECEIPTNO.Text))
            {
                mes.Show("收据号只能由数字组成!");
                RECEIPTNO.SelectAll();
                return;
            }
            RECEIPTNO.Text = RECEIPTNO.Text.PadLeft(8, '0');
            if (BLLWATERFEECHARGE.IsExistReceiptNO(RECEIPTNO.Text))
            {
                if (mes.ShowQ("系统检测到号码为'" + RECEIPTNO.Text + "'的收据已使用,确定使用此号码吗?") != DialogResult.OK)
                {
                    RECEIPTNO.SelectAll();
                    return;
                }
            }
            if (CHARGETYPEID.SelectedValue == null || CHARGETYPEID.SelectedValue == DBNull.Value)
            {
                mes.Show("收款方式不能为空!");
                CHARGETYPEID.Focus();
                return;
            }
            else
            {
                if (CHARGETYPEID.SelectedValue.ToString() == "2")
                {
                    if (POSRUNNINGNO.Text.Trim() == "")
                    {
                        mes.Show("请输入POS机收费的交易流水号!");
                        POSRUNNINGNO.Focus();
                        return;
                    }
                }
            }

            if (_BCSS > 0m)
            {
                if (Approve_Finance())
                {
                    //===================================ByRen201610170956===================================================打印收据
                    #region
                    FastReport.Report report1 = new FastReport.Report();
                    try
                    {
                        string   strWaterUserName = "", strAddress = "", strFeeName = "";
                        DateTime dtNow     = mes.GetDatetimeNow(); //获取收据打印时间
                        decimal  decDepSum = 0;

                        object objMes = htBaseMes["WATERUSERNAME"];
                        if (objMes != null && objMes != DBNull.Value)
                        {
                            strWaterUserName = objMes.ToString();
                        }

                        objMes = htBaseMes["WATERUSERADDRESS"];
                        if (objMes != null && objMes != DBNull.Value)
                        {
                            strAddress = objMes.ToString();
                        }

                        for (int i = 0; i < dtFeeItems.Rows.Count; i++)
                        {
                            string  strFeeNameSingle = "";
                            decimal decFeeSingle     = 0;

                            object obj = dtFeeItems.Rows[i]["FeeItem"];
                            if (obj != null && obj != DBNull.Value)
                            {
                                strFeeNameSingle = obj.ToString();
                            }

                            obj = dtFeeItems.Rows[i]["Fee"];
                            if (Information.IsNumeric(obj))
                            {
                                decFeeSingle = Convert.ToDecimal(obj);
                            }

                            if (strFeeName == "")
                            {
                                strFeeName = strFeeNameSingle + ":" + decFeeSingle.ToString("F2");
                            }
                            else
                            {
                                strFeeName += "\r\n" + strFeeNameSingle + ":" + decFeeSingle.ToString("F2");
                            }

                            decDepSum += decFeeSingle;
                        }

                        report1.Load(Application.StartupPath + @"\PRINTModel\收据模板\报装预算收据.frx");

                        (report1.FindObject("CellWaterUserName") as FastReport.Table.TableCell).Text    = strWaterUserName;
                        (report1.FindObject("CellWaterUserAddress") as FastReport.Table.TableCell).Text = strAddress;

                        (report1.FindObject("txtBCSS") as FastReport.TextObject).Text             = "本次实收: " + _BCSS.ToString("F2");
                        (report1.FindObject("txtYSZJ") as FastReport.TextObject).Text             = "预算总计: " + _BCSS.ToString("F2");
                        (report1.FindObject("txtFeeDetailSummery") as FastReport.TextObject).Text = strFeeDepartMent + "预算明细: ";
                        (report1.FindObject("txtFeeDetail") as FastReport.TextObject).Text        = strFeeName;

                        (report1.FindObject("txtChargeWorkerName") as FastReport.TextObject).Text = strRealName;
                        (report1.FindObject("txtReceiptNO") as FastReport.TextObject).Text        = "NO." + RECEIPTNO.Text.PadLeft(8, '0');

                        string strCapMoney = RMBToCapMoney.CmycurD(_BCSS.ToString("F2"));
                        if (CHARGETYPEID.SelectedValue.ToString() == "2")
                        {
                            (report1.FindObject("txtCapMoney") as FastReport.TextObject).Text = "金额大写:" + strCapMoney + "   " + "交易流水号:" + POSRUNNINGNO.Text;
                        }
                        else
                        {
                            (report1.FindObject("txtCapMoney") as FastReport.TextObject).Text = "金额大写:" + strCapMoney;
                        }

                        report1.PrintSettings.ShowDialog = false;
                        report1.Prepare();
                        report1.Print();

                        //获取新的收据号码,8位收据号
                        if (Information.IsNumeric(RECEIPTNO.Text))
                        {
                            RECEIPTNO.Text = (Convert.ToInt64(RECEIPTNO.Text) + 1).ToString().PadLeft(8, '0');
                        }
                    }
                    catch (Exception exx)
                    {
                        MessageBox.Show(exx.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        // free resources used by report
                        report1.Dispose();
                    }
                    #endregion
                    //=========================================================================

                    mes.Show("收费成功!");
                    BindDepartmentFee();
                    TOTALCHARGE.Text = "";
                    CHARGEBCSS.Text  = "";
                }
            }
            else
            {
                mes.Show("未检测到收费信息!");
            }
        }
Exemplo n.º 21
0
        void ButtonPrintClick(object sender, EventArgs e)
        {
            //预览结算单
            if (dataGridView1.CurrentRow == null)
            {
                return;
            }

            int       i_CompanyID = Convert.ToInt32(comboBoxProjectCompany.SelectedValue);
            int       i_ProjectID = Convert.ToInt32(comboBoxProject.SelectedValue);
            string    sBillCycle  = dataGridView1.CurrentRow.Cells["BillCycle"].Value.ToString();
            DataSet   tmpDs       = new DataSet();
            DataSet   FDataSet    = new DataSet();
            DataTable table       = new DataTable();

            //DataRelation dr;
            FastReport.Report report1 = new FastReport.Report();

            Companies tC = new Companies();

            tC = BLL.CompanyBLL.GetCompany(i_CompanyID);
            switch (tC.CompanyType)
            {
            case 0:                             //客户
            case 2:                             //班组
                tmpDs = BLL.CompanyBLL.GetAllCompany(i_CompanyID);
                //
                report1.Load("Reports\\JSD1.frx");


                table           = tmpDs.Tables[0].Copy();
                table.TableName = "Companies";
                FDataSet.Tables.Add(table);

                tmpDs           = BLL.ProjectsBLL.GetAllProject(i_ProjectID);
                table           = tmpDs.Tables[0].Copy();
                table.TableName = "Projects";
                FDataSet.Tables.Add(table);

                tmpDs           = BLL.CKBLL.GetOutStocks(i_ProjectID, i_CompanyID, "已结算", sBillCycle);
                table           = tmpDs.Tables[0].Copy();
                table.TableName = "OutStock";
                FDataSet.Tables.Add(table);

                tmpDs           = BLL.CKBLL.GetOutStockItems(i_ProjectID, i_CompanyID, "已结算", sBillCycle);
                table           = tmpDs.Tables[0].Copy();
                table.TableName = "OutStockItems";
                FDataSet.Tables.Add(table);

                report1.RegisterData(FDataSet);
                report1.Show();
                report1.Dispose();
                break;

            case 1:                             //供货商
                tmpDs = BLL.CompanyBLL.GetAllCompany(i_CompanyID);
                report1.Load("Reports\\JSD.frx");

                table           = tmpDs.Tables[0].Copy();
                table.TableName = "Companies";
                FDataSet.Tables.Add(table);

                tmpDs           = BLL.ProjectsBLL.GetAllProject(i_ProjectID);
                table           = tmpDs.Tables[0].Copy();
                table.TableName = "Projects";
                FDataSet.Tables.Add(table);

                tmpDs           = BLL.ReceiptBLL.GetReceipt(i_ProjectID, i_CompanyID, "已结算", sBillCycle);
                table           = tmpDs.Tables[0].Copy();
                table.TableName = "Receipt";
                FDataSet.Tables.Add(table);

                tmpDs           = BLL.ReceiptBLL.GetReceiptItems(i_ProjectID, i_CompanyID, "已结算", sBillCycle);
                table           = tmpDs.Tables[0].Copy();
                table.TableName = "ReceiptItems";
                FDataSet.Tables.Add(table);


                report1.RegisterData(FDataSet);
                report1.Show();
                report1.Dispose();
                break;
            }
        }
        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的打印,计数器增加;
            }
        }
Exemplo n.º 23
0
 /// <summary>
 /// 设计报表
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void tsmDesginReport_Click(object sender, EventArgs e)
 {
     report = new FastReport.Report();
     if (!report.IsDesigning)
     {
         GetData(tsmChooseDetail[iDefaultChecked].Name);
         report.Load(new MemoryStream(bt));
         RegReportData();
     }
     frmReportDesign rp = new frmReportDesign(report);
     rp.ReportGUID = rpGUID;
     rp.ShowDialog();
     report.Dispose();
     //刷新菜单
     CreateMenu();
 }
Exemplo n.º 24
0
 protected override void OnHandleDestroyed(EventArgs e)
 {
     _report.Clear();
     _report.Dispose();
     base.OnHandleDestroyed(e);
 }
        private void btCharge_Click(object sender, EventArgs e)
        {
            if (txtWaterUserID.Text.Trim() == "")
            {
                mes.Show("未找到用户ID信息,请重新查询后重试!");
                txtWaterUserNOSearch.Focus();
                return;
            }

            //如果用户存在欠费金额,则不允退费
            object objWaterUserQF = BLLreadMeterRecord.QueryQFByWaterUser(txtWaterUserID.Text.Trim());

            if (Information.IsNumeric(objWaterUserQF))
            {
                txtWaterFee.Text = Convert.ToDecimal(objWaterUserQF).ToString("F2");
                if (Convert.ToDecimal(objWaterUserQF) > 0)
                {
                    mes.Show("当前用户存在欠费余额,无法执行退费操作!");
                    return;
                }
            }
            else
            {
                txtWaterFee.Text = "0";
            }

            if (Convert.ToDecimal(txtYSQQYE.Text) <= 0)
            {
                mes.Show("用户预存余额为0,无需退费!");
                txtYSQQYE.Focus();
                return;
            }

            if (chkReceipt.Checked)
            {
                if (txtReceiptNO.Text.Trim() == "")
                {
                    mes.Show("请输入收据号!");
                    txtReceiptNO.Focus();
                    return;
                }
                if (!Information.IsNumeric(txtReceiptNO.Text))
                {
                    mes.Show("收据号只能由数字组成!");
                    txtReceiptNO.SelectAll();
                    return;
                }
                txtReceiptNO.Text = txtReceiptNO.Text.PadLeft(8, '0');
                if (BLLWATERFEECHARGE.IsExistReceiptNO(txtReceiptNO.Text))
                {
                    if (mes.ShowQ("系统检测到号码为'" + txtReceiptNO.Text + "'的收据已使用,确定使用此号码吗?") != DialogResult.OK)
                    {
                        txtReceiptNO.SelectAll();
                        return;
                    }
                }
            }

            try
            {
                MODELWATERFEECHARGE MODELWATERFEECHARGE = new MODELWATERFEECHARGE();
                MODELWATERFEECHARGE.CHARGEID         = GETTABLEID.GetTableID(strLoginID, "WATERFEECHARGE");
                MODELWATERFEECHARGE.CHARGETYPEID     = "1";
                MODELWATERFEECHARGE.CHARGEClASS      = "6";//收费类型是用户余额退费
                MODELWATERFEECHARGE.CHARGEYSQQYE     = Convert.ToDecimal(txtYSQQYE.Text);
                MODELWATERFEECHARGE.CHARGEBCSS       = 0 - MODELWATERFEECHARGE.CHARGEYSQQYE;
                MODELWATERFEECHARGE.CHARGEYSBCSZ     = 0 - MODELWATERFEECHARGE.CHARGEYSQQYE;
                MODELWATERFEECHARGE.CHARGEYSJSYE     = 0;
                MODELWATERFEECHARGE.CHARGEWORKERID   = strLoginID;
                MODELWATERFEECHARGE.CHARGEWORKERNAME = strLoginName;
                MODELWATERFEECHARGE.CHARGEDATETIME   = mes.GetDatetimeNow();
                MODELWATERFEECHARGE.INVOICEPRINTSIGN = "0";
                if (chkReceipt.Checked)
                {
                    MODELWATERFEECHARGE.RECEIPTPRINTCOUNT = 1;
                    MODELWATERFEECHARGE.RECEIPTNO         = txtReceiptNO.Text;
                }
                MODELWATERFEECHARGE.INVOICEPRINTSIGN = "0";
                MODELWATERFEECHARGE.MEMO             = txtMemo.Text;
                if (BLLWATERFEECHARGE.Insert(MODELWATERFEECHARGE))
                {
                    try
                    {
                        MODELPRESTORERUNNINGACCOUNT MODELPRESTORERUNNINGACCOUNT = new MODELPRESTORERUNNINGACCOUNT();
                        MODELPRESTORERUNNINGACCOUNT.PRESTORERUNNINGACCOUNTID = GETTABLEID.GetTableID(strLoginID, "PRESTORERUNNINGACCOUNT");
                        MODELPRESTORERUNNINGACCOUNT.WATERUSERID       = txtWaterUserID.Text;
                        MODELPRESTORERUNNINGACCOUNT.WATERUSERNO       = txtWaterUserNO.Text;
                        MODELPRESTORERUNNINGACCOUNT.WATERUSERNAME     = txtWaterUserName.Text;
                        MODELPRESTORERUNNINGACCOUNT.WATERUSERNAMECODE = txtNameCode.Text;
                        MODELPRESTORERUNNINGACCOUNT.WATERUSERPHONE    = txtWaterUserPhone.Text;
                        MODELPRESTORERUNNINGACCOUNT.WATERUSERADDRESS  = txtWaterUserAddress.Text;
                        if (Information.IsNumeric(txtWaterUserPeopleCount.Text))
                        {
                            MODELPRESTORERUNNINGACCOUNT.WATERUSERPEOPLECOUNT = Convert.ToInt16(txtWaterUserPeopleCount.Text);
                        }
                        MODELPRESTORERUNNINGACCOUNT.AREANO        = txtAreaNO.Text;
                        MODELPRESTORERUNNINGACCOUNT.PIANNO        = txtPianNO.Text;
                        MODELPRESTORERUNNINGACCOUNT.DUANNO        = txtDuanNO.Text;
                        MODELPRESTORERUNNINGACCOUNT.COMMUNITYID   = txtCommunityID.Text;
                        MODELPRESTORERUNNINGACCOUNT.COMMUNITYNAME = txtCommunity.Text;
                        if (Information.IsNumeric(txtOrderNumber.Text))
                        {
                            MODELPRESTORERUNNINGACCOUNT.ORDERNUMBER = Convert.ToInt16(txtOrderNumber.Text);
                        }
                        //MODELPRESTORERUNNINGACCOUNT.BUILDINGNO = txtBuildingNO.Text;
                        //MODELPRESTORERUNNINGACCOUNT.UNITNO = txtUnitNO.Text;
                        MODELPRESTORERUNNINGACCOUNT.METERREADERID           = txtMeterReaderID.Text;
                        MODELPRESTORERUNNINGACCOUNT.METERREADERNAME         = txtMeterReader.Text;
                        MODELPRESTORERUNNINGACCOUNT.CHARGERID               = txtChargerID.Text;
                        MODELPRESTORERUNNINGACCOUNT.CHARGERNAME             = txtCharger.Text;
                        MODELPRESTORERUNNINGACCOUNT.waterMeterTypeId        = txtWaterMeterTypeID.Text;
                        MODELPRESTORERUNNINGACCOUNT.waterMeterTypeValue     = txtWaterMeterTypeValue.Text;
                        MODELPRESTORERUNNINGACCOUNT.WATERMETERTYPECLASSID   = txtWaterMeterTypeClassID.Text;
                        MODELPRESTORERUNNINGACCOUNT.WATERMETERTYPECLASSNAME = txtWaterMeterTypeClassName.Text;
                        MODELPRESTORERUNNINGACCOUNT.WATERUSERTYPEID         = txtWaterUserTypeID.Text;
                        MODELPRESTORERUNNINGACCOUNT.WATERUSERTYPENAME       = txtWaterUserType.Text;
                        //MODELPRESTORERUNNINGACCOUNT.WATERUSERHOUSETYPE = txtWaterUserHouseType.Text;
                        //MODELPRESTORERUNNINGACCOUNT.CREATETYPE = txtCreateType.Text;
                        //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";
                            btCharge.Enabled = false;
                            btSearchLS_Click(null, null);

                            //更新余额
                            string strUpdatePrestore = "UPDATE waterUser SET prestore=" + MODELWATERFEECHARGE.CHARGEYSJSYE + " WHERE waterUserId='" + txtWaterUserID.Text + "'";
                            if (!BLLwaterUser.UpdateSQL(strUpdatePrestore))
                            {
                                string strError = "更新用户编号为'" + txtWaterUserID.Text + "'的余额失败,请手动添加预收余额!";
                                mes.Show(strError);
                                log.Write(strError, MsgType.Error);
                            }
                            //如果勾选了打收据,打印收据
                            else if (chkReceipt.Checked)
                            {
                                //--打印收据
                                #region
                                FastReport.Report report1 = new FastReport.Report();
                                try
                                {
                                    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      = txtWaterUserNO.Text;
                                    (report1.FindObject("CellWaterUserName") as FastReport.Table.TableCell).Text    = txtWaterUserName.Text;
                                    (report1.FindObject("CellWaterUserAddress") as FastReport.Table.TableCell).Text = txtWaterUserAddress.Text;

                                    (report1.FindObject("txtQQYE") as FastReport.TextObject).Text = "前期余额: " + MODELWATERFEECHARGE.CHARGEYSQQYE.ToString("F2");
                                    (report1.FindObject("txtBCTF") as FastReport.TextObject).Text = "本次退费:         " + MODELWATERFEECHARGE.CHARGEYSBCSZ;
                                    (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    = txtMeterReader.Text;
                                    (report1.FindObject("txtMeterReaderTel") as FastReport.TextObject).Text = txtMeterReaderTel.Text;

                                    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);
                                }
                                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;
            }
        }
Exemplo n.º 26
0
        void ButtonPrintClick(object sender, EventArgs e)
        {
            int i_ProjectID = Convert.ToInt32(comboBoxProject.SelectedValue);
            int i_CompanyID = Convert.ToInt32(comboBoxProjectCompany.SelectedValue);

            DataSet   tmpDs    = new DataSet();
            DataSet   FDataSet = new DataSet();
            DataTable table    = new DataTable();

//			DataRelation dr;
            FastReport.Report report1 = new FastReport.Report();

            Companies tC = new Companies();

            tC = BLL.CompanyBLL.GetCompany(i_CompanyID);
            switch (tC.CompanyType)
            {
            case 0:                             //客户
            case 2:                             //班组
                tmpDs = BLL.CompanyBLL.GetAllCompany(i_CompanyID);
                //
                report1.Load("Reports\\JSD1.frx");


                table           = tmpDs.Tables[0].Copy();
                table.TableName = "Companies";
                FDataSet.Tables.Add(table);

                tmpDs           = BLL.ProjectsBLL.GetAllProject(i_ProjectID);
                table           = tmpDs.Tables[0].Copy();
                table.TableName = "Projects";
                FDataSet.Tables.Add(table);

                string s_OutStockIDs = "";
                foreach (DataGridViewRow item in this.dataGridView1.SelectedRows)
                {
                    s_OutStockIDs  +=  item.Cells["OutStockID"].Value.ToString();
                    s_OutStockIDs  += ",";
                }
                if (s_OutStockIDs.Length > 0)
                {
                    s_OutStockIDs = s_OutStockIDs.Substring(0, s_OutStockIDs.Length - 1);
                }

                tmpDs           = BLL.CKBLL.GetOutStock(s_OutStockIDs);
                table           = tmpDs.Tables[0].Copy();
                table.TableName = "OutStock";
                FDataSet.Tables.Add(table);

                tmpDs           = BLL.CKBLL.GetOutStockItems(s_OutStockIDs);
                table           = tmpDs.Tables[0].Copy();
                table.TableName = "OutStockItems";
                FDataSet.Tables.Add(table);

//					dr  = new DataRelation("FK_1",FDataSet.Tables["OutStock"].Columns["OutStockID"],FDataSet.Tables["OutStockItems"].Columns["OutStockID"]);
//					FDataSet.Relations.Add(dr);

                report1.RegisterData(FDataSet);
                report1.Show();
                report1.Dispose();
                break;

            case 1:                             //供货商
                tmpDs = BLL.CompanyBLL.GetAllCompany(i_CompanyID);
                //

                report1.Load("Reports\\JSD.frx");


                table           = tmpDs.Tables[0].Copy();
                table.TableName = "Companies";
                FDataSet.Tables.Add(table);

                tmpDs           = BLL.ProjectsBLL.GetAllProject(i_ProjectID);
                table           = tmpDs.Tables[0].Copy();
                table.TableName = "Projects";
                FDataSet.Tables.Add(table);



                string s_ReceiptIDs = "";
                foreach (DataGridViewRow item in this.dataGridView1.SelectedRows)
                {
                    s_ReceiptIDs  +=  item.Cells["ReceiptID"].Value.ToString();
                    s_ReceiptIDs  += ",";
                }
                if (s_ReceiptIDs.Length > 0)
                {
                    s_ReceiptIDs = s_ReceiptIDs.Substring(0, s_ReceiptIDs.Length - 1);
                }

                tmpDs           = BLL.ReceiptBLL.GetCommMaterialRecord(s_ReceiptIDs);
                table           = tmpDs.Tables[0].Copy();
                table.TableName = "Receipt";
                FDataSet.Tables.Add(table);

                tmpDs           = BLL.RKBLL.GetReceiptItems(s_ReceiptIDs);
                table           = tmpDs.Tables[0].Copy();
                table.TableName = "ReceiptItems";
                FDataSet.Tables.Add(table);

//					dr  = new DataRelation("FK_1",FDataSet.Tables["Receipt"].Columns["ReceiptID"],FDataSet.Tables["ReceiptItems"].Columns["ReceiptID"]);
//					FDataSet.Relations.Add(dr);

                report1.RegisterData(FDataSet);
                report1.Show();
                report1.Dispose();
                break;
            }
        }
Exemplo n.º 27
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;
            }
        }
        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.º 29
0
 /// <summary>
 /// 新增报表
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void tsmAddReport_Click(object sender, EventArgs e)
 {
     report = new FastReport.Report();
     RegReportData();
     frmReportDesign rp = new frmReportDesign(report);
     rp.ReportGUID = rpGUID;
     rp.ShowDialog();
     report.Dispose();
     //ClearListData();
     CreateMenu();
 }