From 59bb0ff824963db60bb7bd1d4bbddb190b3f7cb2 Mon Sep 17 00:00:00 2001 From: minom Date: Fri, 17 Jul 2026 17:40:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AA=BF=E6=95=B4=E7=89=88=E5=9E=8B=E8=A8=AD?= =?UTF-8?q?=E8=A8=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/App_Code/api/statisticsController.cs | 56 +- web/admin/activity/item_reg.aspx | 11 +- web/admin/activity/item_reg.aspx.cs | 9 +- web/admin/bill/statistic.vue | 2 +- web/admin/item/TabletDesigner.aspx | 12 +- web/admin/print/TabletDesign.aspx | 1437 ++++++++++++++++++++++ web/admin/print/TabletDesign.aspx.cs | 14 + web/web.config | 8 +- 8 files changed, 1523 insertions(+), 26 deletions(-) create mode 100644 web/admin/print/TabletDesign.aspx create mode 100644 web/admin/print/TabletDesign.aspx.cs diff --git a/web/App_Code/api/statisticsController.cs b/web/App_Code/api/statisticsController.cs index 655ab47..4e46b91 100644 --- a/web/App_Code/api/statisticsController.cs +++ b/web/App_Code/api/statisticsController.cs @@ -7,6 +7,7 @@ using NPOI.SS.UserModel; using OfficeOpenXml; using System; using System.Collections.Generic; +using System.Data.Entity; using System.Data.SqlClient; using System.IO; using System.Linq; @@ -146,10 +147,18 @@ public class statisticsController: ApiController return Ok(data); } + //public static IEnumerable Between( + // this IEnumerable source, + // T low, + // T high) where T : IComparable + //{ + // // 運用 IComparable 比較大小,泛型可支援 int, double, DateTime 等 + // return source.Where(item => item.CompareTo(low) >= 0 && item.CompareTo(high) <= 0); + //} [HttpPost] [Route("api/statistics/GetStatistic")] - public IHttpActionResult GetStatistic(string statistic_mode) + public IHttpActionResult GetStatistic(string statistic_mode,string s_date,string e_date) { try { @@ -166,11 +175,20 @@ public class statisticsController: ApiController LogUtility log = new LogUtility(); // 建立分頁 var ws = excel.Workbook.Worksheets.Add("MySheet"); + //var query = _db.activities.AsQueryable(); + //if (!string.IsNullOrEmpty(s_date)) + //{ + // query= query.Where(a => a.startDate_solar.Value.ToString("yyyyMMdd").CompareTo(s_date) >= 0); + //} + //if (!string.IsNullOrEmpty(e_date)) + //{ + // query = query.Where(a => a.endDate_solar.Value.ToString("yyyyMMdd").CompareTo(e_date) <= 0); + //} var data = (from a in _db.activities join b in _db.pro_order on a.num equals b.activity_num join c in _db.pro_order_detail on b.order_no equals c.order_no //join d in _db.activity_relating on a.num equals d.activity_num - join f in _db.actItems on c.actItem_num equals f.num + join f in _db.actItems on c.actItem_num equals f.num select new { a.num, @@ -181,9 +199,19 @@ public class statisticsController: ApiController c.actItem_num, item_subject = f.subject, c.qty, - c.price + c.price, + a.startDate_solar, + a.endDate_solar }).ToList(); + if (!string.IsNullOrEmpty(s_date)) + { + data = data.Where(a => a.startDate_solar.Value.ToString("yyyyMMdd").CompareTo(s_date) >= 0).ToList(); + } + if (!string.IsNullOrEmpty(e_date)) + { + data = data.Where(a => a.endDate_solar.Value.ToString("yyyyMMdd").CompareTo(e_date) <= 0).ToList(); + } int i = 0; i++; if (statistic_mode == "01") @@ -198,7 +226,7 @@ public class statisticsController: ApiController ws.Cells[i, 8].Value = "應收"; ws.Cells[i, 9].Value = "應付"; i++; - var list = data.GroupBy(x => new { x.num, x.subject, x.actItem_num, x.item_subject }).Select(y => + var list = data.ToList().GroupBy(x => new { x.num, x.subject, x.actItem_num, x.item_subject }).Select(y => new { y.Key.num, @@ -213,8 +241,8 @@ public class statisticsController: ApiController ws.Cells[i, 1].Value = i - 1; ws.Cells[i, 2].Value = item.subject; ws.Cells[i, 3].Value = item.item_subject; - ws.Cells[i, 4].Value = item.qty.Value; - ws.Cells[i, 5].Value = item.price.Value; + ws.Cells[i, 4].Value =item.qty==null?0: item.qty.Value; + ws.Cells[i, 5].Value =item.price==null?0: item.price.Value; ws.Cells[i, 6].Formula = $"=D{i}*E{i}"; var draftList = (from a in drafts @@ -240,13 +268,17 @@ public class statisticsController: ApiController } else { + var jj = JsonConvert.DeserializeObject(items.draft); - foreach (var j in jj["pro_order_detail_items"]) + if (jj["pro_order_detail_items"]!=null) { - if (item.subject == j["activity_name"].ToString() && - item.item_subject == j["actitem_name"].ToString()) + foreach (var j in jj["pro_order_detail_items"]) { - payed = payed + decimal.Parse(j["reconcile"].ToString()); + if (item.subject == j["activity_name"].ToString() && + item.item_subject == j["actitem_name"].ToString()) + { + payed = payed + decimal.Parse(j["reconcile"].ToString()); + } } } } @@ -301,7 +333,7 @@ public class statisticsController: ApiController decimal payed = 0; foreach (var d in dd) { - payed = payed + (decimal)d.check_amount;// -(decimal)d.remain_amount; + payed = payed +d.check_amount==null?0: (decimal)d.check_amount;// -(decimal)d.remain_amount; } ws.Cells[i, 5].Value = payed; ws.Cells[i, 6].Formula = $"=if(D{i}>E{i},D{i}-E{i},0)"; @@ -357,7 +389,7 @@ public class statisticsController: ApiController } catch (Exception ex) { - return Ok(new { result = "N", message = ex.Message}); + return Ok(new { result = "N", message = ex.Message+ex.StackTrace}); //return BadRequest($"{ex.Message}{ex.StackTrace}"); } } diff --git a/web/admin/activity/item_reg.aspx b/web/admin/activity/item_reg.aspx index 4da6b4d..83de570 100644 --- a/web/admin/activity/item_reg.aspx +++ b/web/admin/activity/item_reg.aspx @@ -598,9 +598,9 @@ - + 相關文件--%> @@ -726,7 +726,7 @@ -
+ <%--
+ >