From 4a16f96ceaac9b4cf684287cd2865fc3d2966475 Mon Sep 17 00:00:00 2001 From: username@email.com <yzy2002yzy@163.com> Date: 星期五, 14 三月 2025 08:33:51 +0800 Subject: [PATCH] 这个账务处理需要导出功能 不能他们不收款 --- CY_ECommercePlatform/CY.WebForm/Pages/business/DeliverPlanDakaList.aspx.designer.cs | 9 + CY_ECommercePlatform/CY.WebForm/Pages/business/InvoicingConfirm.aspx.designer.cs | 9 + CY_ECommercePlatform/CY.WebForm/Pages/business/DeliverPlanDakaList.aspx | 17 +++ CY_ECommercePlatform/CY.WebForm/Pages/business/DeliverPlanDakaList.aspx.cs | 101 +++++++++++++++++++ CY_ECommercePlatform/CY.WebForm/Pages/business/InvoicingConfirm.aspx | 13 ++ CY_ECommercePlatform/CY.WebForm/Pages/business/InvoicingConfirm.aspx.cs | 101 ++++++++++++++++++++ 6 files changed, 245 insertions(+), 5 deletions(-) diff --git a/CY_ECommercePlatform/CY.WebForm/Pages/business/DeliverPlanDakaList.aspx b/CY_ECommercePlatform/CY.WebForm/Pages/business/DeliverPlanDakaList.aspx index 9907d7c..c837d2b 100644 --- a/CY_ECommercePlatform/CY.WebForm/Pages/business/DeliverPlanDakaList.aspx +++ b/CY_ECommercePlatform/CY.WebForm/Pages/business/DeliverPlanDakaList.aspx @@ -294,6 +294,16 @@ window.open('/Pages/business/DeliverPlanFujianShow.aspx?Keyid=' + keyid + '&AttachmentType=' + AttachmentType, '_blank', 'height=750,width=900,top=' + t + ',left=' + l + ',toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no'); } + function showProgress() { + document.getElementById('progressBar').style.display = 'block'; + + + setTimeout(function () { + document.getElementById('progressBar').style.display = 'none'; + }, 2000); // 10000姣绛変簬10绉� + + } + /* 鎵撳嵃閫佽揣鍗� */ @@ -390,7 +400,10 @@ <asp:button id="btn_Search" text="鏌ヨ" runat="server" padding="0px" OnClick="btn_Search_Click" /> <input type="button" value='閲嶇疆' onclick='document.body.innerHTML="";window.location=window.location;' /> - + <asp:Button ID="Button1" Text="瀵煎嚭" OnClientClick="showProgress();return true;" runat="server" OnClick="btn_Daochu_Click" /> + <div id="progressBar" style="display:none; position:fixed; top:50%; left:50%; transform:translate(-50%, -50%);border:1px solid black;height:50px;background-color:azure;"> + 姝e湪瀵煎嚭Excel鏂囦欢锛岃绋嶅��... +</div> </td> </tr> @@ -406,7 +419,7 @@ <tr> <th width="25"> - 椤哄簭 + 缂栧彿 </th> <th width="60"> 杞﹁締 diff --git a/CY_ECommercePlatform/CY.WebForm/Pages/business/DeliverPlanDakaList.aspx.cs b/CY_ECommercePlatform/CY.WebForm/Pages/business/DeliverPlanDakaList.aspx.cs index 2789512..b9c634d 100644 --- a/CY_ECommercePlatform/CY.WebForm/Pages/business/DeliverPlanDakaList.aspx.cs +++ b/CY_ECommercePlatform/CY.WebForm/Pages/business/DeliverPlanDakaList.aspx.cs @@ -18,6 +18,9 @@ using CY.SQLDAL; using System.Data.SqlClient; using CY.Infrastructure.Logging; +using NPOI.SS.UserModel; +using NPOI.XSSF.UserModel; +using System.IO; namespace CY.WebForm.Pages.business { @@ -228,9 +231,103 @@ UCPager1.AspNetPager.RecordCount = pa.RecordCount; } - - + + //鏌ヨ浜嬩欢 + protected void btn_Daochu_Click(object src, EventArgs e) + { + + byte[] fileBytes = ExportToExcel(); + if (fileBytes != null) + { + Response.Clear(); + Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; + Response.AppendHeader("Content-Disposition", "attachment; filename=鎵撳崱瀵煎嚭.xlsx"); + Response.BinaryWrite(fileBytes); + Response.End(); + } + else + { + // 澶勭悊瀵煎嚭澶辫触鐨勬儏鍐� + Response.Write("瀵煎嚭澶辫触锛岃绋嶅悗閲嶈瘯锛�"); + } + + } + + + public byte[] ExportToExcel() + { + byte[] bt = null; + try + { + Pagination pa = new Pagination(); + pa.PageSize = 1000; + pa.PageIndex = 1; + + + + IEnumerable<OA_DriverRecord> results = _oA_DriverRecordBLL.SelectModelPage(pa, + this.txtCreatTimestart.Value, + this.txtCreatTimeend.Value, + this.selCarId.Value, + this.txtCreater.Value, + this.selClockType.Value + ); + + // 鍒涘缓宸ヤ綔绨� + IWorkbook workbook = new XSSFWorkbook(); + ISheet sheet = workbook.CreateSheet("瀵煎嚭鏁版嵁"); + + // 鍒涘缓琛ㄥご + IRow headerRow = sheet.CreateRow(0); + headerRow.CreateCell(0).SetCellValue("缂栧彿"); + headerRow.CreateCell(1).SetCellValue("杞﹁締"); + headerRow.CreateCell(2).SetCellValue("椹鹃┒鍛�"); + headerRow.CreateCell(3).SetCellValue("鎵撳崱鏃堕棿"); + headerRow.CreateCell(4).SetCellValue("鎵撳崱绫诲瀷"); + headerRow.CreateCell(5).SetCellValue("鏈璐ф儏鍐�"); + headerRow.CreateCell(6).SetCellValue("杞﹀喌"); + headerRow.CreateCell(7).SetCellValue("澶囨敞"); + headerRow.CreateCell(8).SetCellValue("閲岀▼(鍏噷)"); + + + + // 娣诲姞鏁版嵁 + int rowIndex = 1; + foreach (var oA_DriverRecord in results) + { + IRow row = sheet.CreateRow(rowIndex++); + row.CreateCell(0).SetCellValue((rowIndex - 1).ToString()); + row.CreateCell(1).SetCellValue(oA_DriverRecord.CarName); + row.CreateCell(2).SetCellValue(oA_DriverRecord.Creater); + row.CreateCell(3).SetCellValue(oA_DriverRecord.CreatTime.ToString("yyyy-MM-dd")); + row.CreateCell(4).SetCellValue(oA_DriverRecord.ClockTypeName); + row.CreateCell(5).SetCellValue(oA_DriverRecord.EmptyCause); + row.CreateCell(6).SetCellValue(oA_DriverRecord.CarCondition); + row.CreateCell(7).SetCellValue(oA_DriverRecord.Remark); + row.CreateCell(8).SetCellValue(oA_DriverRecord.Mileage.ToString()); + + + + } + + // 灏嗗伐浣滅翱鍐欏叆鍐呭瓨娴� + using (var ms = new MemoryStream()) + { + workbook.Write(ms); + bt = ms.ToArray(); + } + } + catch (Exception e) + { + bt = null; + // 璁板綍鏃ュ織 + + } + return bt; + } + + } } \ No newline at end of file diff --git a/CY_ECommercePlatform/CY.WebForm/Pages/business/DeliverPlanDakaList.aspx.designer.cs b/CY_ECommercePlatform/CY.WebForm/Pages/business/DeliverPlanDakaList.aspx.designer.cs index 12ba3a4..ee83766 100644 --- a/CY_ECommercePlatform/CY.WebForm/Pages/business/DeliverPlanDakaList.aspx.designer.cs +++ b/CY_ECommercePlatform/CY.WebForm/Pages/business/DeliverPlanDakaList.aspx.designer.cs @@ -96,6 +96,15 @@ protected global::System.Web.UI.WebControls.Button btn_Search; /// <summary> + /// Button1 鎺т欢銆� + /// </summary> + /// <remarks> + /// 鑷姩鐢熸垚鐨勫瓧娈点�� + /// 鑻ヨ杩涜淇敼锛岃灏嗗瓧娈靛0鏄庝粠璁捐鍣ㄦ枃浠剁Щ鍒颁唬鐮侀殣钘忔枃浠躲�� + /// </remarks> + protected global::System.Web.UI.WebControls.Button Button1; + + /// <summary> /// RepClientList 鎺т欢銆� /// </summary> /// <remarks> diff --git a/CY_ECommercePlatform/CY.WebForm/Pages/business/InvoicingConfirm.aspx b/CY_ECommercePlatform/CY.WebForm/Pages/business/InvoicingConfirm.aspx index a311a62..3793491 100644 --- a/CY_ECommercePlatform/CY.WebForm/Pages/business/InvoicingConfirm.aspx +++ b/CY_ECommercePlatform/CY.WebForm/Pages/business/InvoicingConfirm.aspx @@ -158,7 +158,15 @@ }); } + function showProgress() { + document.getElementById('progressBar').style.display = 'block'; + + setTimeout(function () { + document.getElementById('progressBar').style.display = 'none'; + }, 2000); // 10000姣绛変簬10绉� + + } $(function () { var value_NowPageAllMoney = 0; @@ -285,7 +293,10 @@ </td> <td > <asp:button id="btn_Search" text="鏌ヨ" runat="server" /> <input type="button" value='閲嶇疆' onclick='document.body.innerHTML="";window.location=window.location;' /> - + <asp:Button ID="Button1" Text="瀵煎嚭" OnClientClick="showProgress();return true;" runat="server" OnClick="btn_Daochu_Click" /> + <div id="progressBar" style="display:none; position:fixed; top:50%; left:50%; transform:translate(-50%, -50%);border:1px solid black;height:50px;background-color:azure;"> + 姝e湪瀵煎嚭Excel鏂囦欢锛岃绋嶅��... +</div> </td> </tr> </table> diff --git a/CY_ECommercePlatform/CY.WebForm/Pages/business/InvoicingConfirm.aspx.cs b/CY_ECommercePlatform/CY.WebForm/Pages/business/InvoicingConfirm.aspx.cs index 11a0de3..007cb84 100644 --- a/CY_ECommercePlatform/CY.WebForm/Pages/business/InvoicingConfirm.aspx.cs +++ b/CY_ECommercePlatform/CY.WebForm/Pages/business/InvoicingConfirm.aspx.cs @@ -29,6 +29,10 @@ using CY.BLL; using CY.WebForm.Pages.common; using System.Transactions; +using CY.Infrastructure.Query; +using NPOI.SS.UserModel; +using NPOI.XSSF.UserModel; +using System.IO; namespace CY.WebForm.Pages.business { @@ -720,6 +724,103 @@ UCPager1.AspNetPager.RecordCount = pagination.RecordCount; } + + + //鏌ヨ浜嬩欢 + protected void btn_Daochu_Click(object src, EventArgs e) + { + + byte[] fileBytes = ExportToExcel(); + if (fileBytes != null) + { + Response.Clear(); + Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; + Response.AppendHeader("Content-Disposition", "attachment; filename=寮�绁ㄧ鐞嗗鍑�.xlsx"); + Response.BinaryWrite(fileBytes); + Response.End(); + } + else + { + // 澶勭悊瀵煎嚭澶辫触鐨勬儏鍐� + Response.Write("瀵煎嚭澶辫触锛岃绋嶅悗閲嶈瘯锛�"); + } + + } + + + public byte[] ExportToExcel() + { + byte[] bt = null; + try + { + Pagination pa = new Pagination(); + pa.PageSize = 1000; + pa.PageIndex = 1; + + + + IEnumerable<OA_Kaipiaoshenqing> results = oA_KaipiaoshenqingBLL.SelectModelPage(pa, CurrentUser.MemberId, this.txtSQBeginDate.Value, this.txtSQEndDate.Value, this.selKaipiaoshenqing.Value, this.selKehuqianshou.Value, this.selBusinessManager.Value, this.txtCustormerName.Value, this.selPayStates.Value, this.selHuikuanStates.Value); + + + // 鍒涘缓宸ヤ綔绨� + IWorkbook workbook = new XSSFWorkbook(); + ISheet sheet = workbook.CreateSheet("瀵煎嚭鏁版嵁"); + + // 鍒涘缓琛ㄥご + IRow headerRow = sheet.CreateRow(0); + headerRow.CreateCell(0).SetCellValue("缂栧彿"); + headerRow.CreateCell(1).SetCellValue("鐢宠寮�绁ㄦ椂闂�"); + headerRow.CreateCell(2).SetCellValue("鐢宠绫诲瀷"); + headerRow.CreateCell(3).SetCellValue("涓氬姟缁忕悊"); + headerRow.CreateCell(4).SetCellValue("瀹㈡埛鍚嶇О"); + headerRow.CreateCell(5).SetCellValue("鍙戠エ鍙风爜"); + headerRow.CreateCell(6).SetCellValue("璁㈠崟鏁伴噺"); + headerRow.CreateCell(7).SetCellValue("閲戦"); + headerRow.CreateCell(8).SetCellValue("澧炲噺閲戦"); + headerRow.CreateCell(9).SetCellValue("鍥炴閲戦"); + headerRow.CreateCell(10).SetCellValue("鏈�杩戝偓娆�"); + headerRow.CreateCell(11).SetCellValue("寮�绁ㄧ姸鎬�"); + + + // 娣诲姞鏁版嵁 + int rowIndex = 1; + foreach (var oA_Kaipiaoshenqing in results) + { + IRow row = sheet.CreateRow(rowIndex++); + row.CreateCell(0).SetCellValue((rowIndex - 1).ToString()); + row.CreateCell(1).SetCellValue(oA_Kaipiaoshenqing.CreateTime.Value.ToString("yyyy-MM-dd")); + row.CreateCell(2).SetCellValue(oA_Kaipiaoshenqing.Shenqingleixing); + row.CreateCell(3).SetCellValue(oA_Kaipiaoshenqing.BusinessManager); + row.CreateCell(4).SetCellValue(oA_Kaipiaoshenqing.BuyerName); + row.CreateCell(5).SetCellValue(oA_Kaipiaoshenqing.Fapiaohao); + row.CreateCell(6).SetCellValue(oA_Kaipiaoshenqing.Dingdanshu.HasValue? oA_Kaipiaoshenqing.Dingdanshu.Value.ToString():""); + row.CreateCell(7).SetCellValue(oA_Kaipiaoshenqing.kpmoney.HasValue ? oA_Kaipiaoshenqing.kpmoney.Value.ToString() : "0"); + row.CreateCell(8).SetCellValue(oA_Kaipiaoshenqing.Zengjianmoney.HasValue ? oA_Kaipiaoshenqing.Zengjianmoney.Value.ToString() : "0"); + row.CreateCell(9).SetCellValue(oA_Kaipiaoshenqing.Huikuanmoney.HasValue ? oA_Kaipiaoshenqing.Huikuanmoney.Value.ToString() : "0"); + row.CreateCell(10).SetCellValue(oA_Kaipiaoshenqing.ShoukuanTime.HasValue? oA_Kaipiaoshenqing.ShoukuanTime.Value.ToString("MM-dd HH:mm") : ""); + row.CreateCell(11).SetCellValue(oA_Kaipiaoshenqing.KaipiaoshenqingName); + + + + } + + // 灏嗗伐浣滅翱鍐欏叆鍐呭瓨娴� + using (var ms = new MemoryStream()) + { + workbook.Write(ms); + bt = ms.ToArray(); + } + } + catch (Exception e) + { + bt = null; + // 璁板綍鏃ュ織 + + } + return bt; + } + + /// <summary> /// 鏌ヨ鍙傛暟 /// </summary> diff --git a/CY_ECommercePlatform/CY.WebForm/Pages/business/InvoicingConfirm.aspx.designer.cs b/CY_ECommercePlatform/CY.WebForm/Pages/business/InvoicingConfirm.aspx.designer.cs index d1358a9..2957cc5 100644 --- a/CY_ECommercePlatform/CY.WebForm/Pages/business/InvoicingConfirm.aspx.designer.cs +++ b/CY_ECommercePlatform/CY.WebForm/Pages/business/InvoicingConfirm.aspx.designer.cs @@ -123,6 +123,15 @@ protected global::System.Web.UI.WebControls.Button btn_Search; /// <summary> + /// Button1 鎺т欢銆� + /// </summary> + /// <remarks> + /// 鑷姩鐢熸垚鐨勫瓧娈点�� + /// 鑻ヨ杩涜淇敼锛岃灏嗗瓧娈靛0鏄庝粠璁捐鍣ㄦ枃浠剁Щ鍒颁唬鐮侀殣钘忔枃浠躲�� + /// </remarks> + protected global::System.Web.UI.WebControls.Button Button1; + + /// <summary> /// rptData 鎺т欢銆� /// </summary> /// <remarks> -- Gitblit v1.9.1