From f6905566f56d58ba4b88adf7bb99955ddb844a05 Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Tue, 20 Mar 2018 11:33:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ButcherWeight/WeightForm.cs | 19 +++ SegmentationWeight/SegmentationWeightForm.cs | 16 +-- SegmentationWeight/SegmentationWeightPrint.cs | 108 +++--------------- 3 files changed, 41 insertions(+), 102 deletions(-) diff --git a/ButcherWeight/WeightForm.cs b/ButcherWeight/WeightForm.cs index 8350d74..3a5b1e2 100644 --- a/ButcherWeight/WeightForm.cs +++ b/ButcherWeight/WeightForm.cs @@ -49,6 +49,7 @@ namespace ButcherWeight uDatePicker1.Date = DateTime.Today; supplierSelect.Init("BaseInfoRpc/GetSupplierList"); purchaseTypeSelect.Init("BaseInfoRpc/GetPurchaseTypeList"); + purchaseTypeSelect.SelectedIndexChanged += PurchaseTypeSelectIndexChange; carSelect.Init("BaseInfoRpc/GetCarList"); liveVarietiesSelect.Init("BaseInfoRpc/GetLiveVarietiesList"); employeeSelect.Init("BaseInfoRpc/GetEmployeeList"); @@ -79,6 +80,24 @@ namespace ButcherWeight }; } + private void PurchaseTypeSelectIndexChange(object sender, EventArgs e) + { + var selectObj = purchaseTypeSelect.SelectedItem as WordPair; + if (selectObj.DisplayName == "社会") + { + penMoneyInput.Text = string.Empty; + penWeightInput.Text = string.Empty; + penPriceInput.Text = string.Empty; + penMoneyInput.ReadOnly = true; + penWeightInput.ReadOnly = true; + } + else + { + penMoneyInput.ReadOnly = false; + penWeightInput.ReadOnly = false; + } + } + private void WeightForm_Load(object sender, EventArgs e) { BindWeightBill(); diff --git a/SegmentationWeight/SegmentationWeightForm.cs b/SegmentationWeight/SegmentationWeightForm.cs index 475f547..df84c37 100644 --- a/SegmentationWeight/SegmentationWeightForm.cs +++ b/SegmentationWeight/SegmentationWeightForm.cs @@ -679,7 +679,7 @@ namespace SegmentationWeight entity.Goods_Name = record.Goods_Name; entity.Date = DateTime.Today; entity.Checker = "001"; - entity.StoreCondition = "0-4℃ 4日"; + entity.StoreCondition = "0-4℃"; entity.Place = "青岛莱西市珠海路5号"; entity.TelNumber = "0532-88488888"; entity.BarCode = record.BarCode; @@ -867,17 +867,9 @@ namespace SegmentationWeight private void PrintEnd(string barcode) { - var entity = new PrintEntity(); - entity.Weight = mWeightRecords.Sum(x => x.Weight).ToString(); - entity.Number = mWeightRecords.Count.ToString(); - entity.BarCode = barcode; - entity.AccountingUnit_Name = "青岛万福集团股份有限公司"; -#if DEBUG - SegmentationWeightPrint.PrintEnd(entity); -#endif -#if !DEBUG - SegmentationWeightPrint.PrintEndHTML(entity); -#endif + var list = mWeightRecords.GroupBy(x => x.Goods_Name).Select(x => new PrintEntity { Goods_Name = x.Key, Weight = x.Sum(y => y.Weight).ToString("F"), Number = x.Count().ToString() }).ToList(); + list.Add(new PrintEntity { Goods_Name = "合计", Weight = mWeightRecords.Sum(x => x.Weight).ToString("F"), Number = mWeightRecords.Count().ToString() }); + SegmentationWeightPrint.PrintEndHTML(list, barcode); } private string GetEndBarCode() diff --git a/SegmentationWeight/SegmentationWeightPrint.cs b/SegmentationWeight/SegmentationWeightPrint.cs index f87ab89..78947a8 100644 --- a/SegmentationWeight/SegmentationWeightPrint.cs +++ b/SegmentationWeight/SegmentationWeightPrint.cs @@ -9,53 +9,6 @@ namespace SegmentationWeight { public class SegmentationWeightPrint { - public static void PrintEnd(PrintEntity entity) - { - PrintAPI.B_GetUSBBufferLen(); - PrintAPI.B_EnumUSB(new byte[128]); - PrintAPI.B_CreateUSBPort(1); - - PrintAPI.B_Prn_Text_TrueType(110, 26, 31, "宋体", 1, 700, 0, 0, 0, "C1", entity.AccountingUnit_Name); - - PrintAPI.B_Prn_Text_TrueType(42, 120, 27, "宋体", 1, 400, 0, 0, 0, "C4", string.Format("总重量:{0}", entity.Weight)); - - PrintAPI.B_Prn_Text_TrueType(42, 200, 27, "宋体", 1, 400, 0, 0, 0, "C6", string.Format("总数量:{0}", entity.Number)); - - PrintAPI.B_Prn_Barcode(42, 320, 0, "1", 3, 22, 35, 'N', entity.BarCode); - PrintAPI.B_Prn_Text_TrueType(173, 360, 25, "宋体", 1, 500, 0, 0, 0, "C9", entity.BarCode); - PrintAPI.B_Bar2d_QR(430, 105, 2, 6, 'M', 'A', 0, 0, 0, entity.BarCode); - - PrintAPI.B_Set_Direction('B'); - PrintAPI.B_Print_Out(1); - PrintAPI.B_ClosePrn(); - } - - public static void Print(PrintEntity entity) - { - PrintAPI.B_GetUSBBufferLen(); - PrintAPI.B_EnumUSB(new byte[128]); - PrintAPI.B_CreateUSBPort(1); - - PrintAPI.B_Prn_Text_TrueType(110, 26, 31, "宋体", 1, 700, 0, 0, 0, "C1", entity.AccountingUnit_Name); - PrintAPI.B_Prn_Text_TrueType(42, 70, 31, "黑体", 1, 400, 0, 0, 0, "C2", string.Format("产品重量:{0}",entity.Weight)); - PrintAPI.B_Prn_Text_TrueType(300, 70, 31, "黑体", 1, 700, 0, 0, 0, "C3", entity.Goods_Name); - - PrintAPI.B_Prn_Text_TrueType(42, 120, 23, "宋体", 1, 400, 0, 0, 0, "C4", string.Format("生产日期:{0}", entity.Date.ToString("yyyy/MM/dd"))); - PrintAPI.B_Prn_Text_TrueType(42, 160, 23, "宋体", 1, 400, 0, 0, 0, "C5", string.Format("检 验 员:{0}", entity.Checker)); - PrintAPI.B_Prn_Text_TrueType(42, 200, 23, "宋体", 1, 400, 0, 0, 0, "C6", string.Format("保 质 期:{0}", entity.StoreCondition)); - - PrintAPI.B_Prn_Text_TrueType(42, 240, 23, "宋体", 1, 400, 0, 0, 0, "C7", string.Format("电话:{0}", entity.TelNumber)); - PrintAPI.B_Prn_Text_TrueType(42, 280, 23, "宋体", 1, 400, 0, 0, 0, "C8", string.Format("产地:{0}", entity.Place)); - - PrintAPI.B_Prn_Barcode(30, 320, 0, "1", 3, 22, 35, 'N', entity.BarCode); - PrintAPI.B_Prn_Text_TrueType(173, 360, 25, "宋体", 1, 500, 0, 0, 0, "C9", entity.BarCode); - PrintAPI.B_Bar2d_QR(430, 105, 2, 6, 'M', 'A', 0, 0, 0, entity._2DQRCode); - - PrintAPI.B_Set_Direction('B'); - PrintAPI.B_Print_Out(1); - PrintAPI.B_ClosePrn(); - } - public static void PrintByHTML(PrintEntity entity) { var dic = new Dictionary(); @@ -71,54 +24,29 @@ namespace SegmentationWeight BwpClientPrint.BwpClientWebPrint.Print("SegmentationWeightPrint.html", dic); } - public static void PrintEndHTML(PrintEntity entity) + public static void PrintEndHTML(List list, string code) { + string firstRow = "{0}:{1}{2}"; + string template = "{0}:{1}{2}"; + var builder = new StringBuilder(); + bool first = true; + foreach (var item in list) + { + if (first) + { + builder.Append(string.Format(firstRow, item.Goods_Name, item.Number, item.Weight, list.Count)); + first = false; + } + else + builder.Append(string.Format(template, item.Goods_Name, item.Number, item.Weight)); + } var dic = new Dictionary(); - dic.Add("$Weight", entity.Weight); - dic.Add("$Number", entity.Number); - BwpClientPrint.BwpClientWebPrint.Create2DPic(entity.BarCode.Replace("A26091201", ""), "ImageUrl.png", 120); + dic.Add("$tableContent", builder.ToString()); + BwpClientPrint.BwpClientWebPrint.Create2DPic(code.Replace("A26091201", ""), "ImageUrl.png", 120); dic.Add("$ImageUrl", "ImageUrl.png"); + dic.Add("$DateTime", DateTime.Now.ToString("yyyy/MM/dd HH:ss")); BwpClientPrint.BwpClientWebPrint.Print("SegmentationWeightPrintEnd.html", dic); } - - public static void PrintEnd5050(PrintEntity entity) - { - PrintAPI.B_GetUSBBufferLen(); - PrintAPI.B_EnumUSB(new byte[128]); - PrintAPI.B_CreateUSBPort(1); - - PrintAPI.B_Prn_Text_TrueType(40, 25, 31, "宋体", 1, 700, 0, 0, 0, "C1", "万福"); - - PrintAPI.B_Prn_Text_TrueType(40, 60, 27, "宋体", 1, 400, 0, 0, 0, "C4", string.Format("总重量:{0}", entity.Weight)); - - PrintAPI.B_Prn_Text_TrueType(40, 95, 27, "宋体", 1, 400, 0, 0, 0, "C6", string.Format("总数量:{0}", entity.Number)); - - PrintAPI.B_Prn_Barcode(10, 320, 0, "1", 3, 22, 35, 'N', entity.BarCode.Replace("A26091201", "")); - PrintAPI.B_Prn_Text_TrueType(40, 400, 25, "宋体", 1, 500, 0, 0, 0, "C9", entity.BarCode.Replace("A26091201", "")); - PrintAPI.B_Bar2d_QR(40, 130, 2, 6, 'M', 'A', 0, 0, 0, entity.BarCode.Replace("A26091201", "")); - - PrintAPI.B_Set_Direction('B'); - PrintAPI.B_Print_Out(1); - PrintAPI.B_ClosePrn(); - } - public static void Print5050(PrintEntity entity) - { - PrintAPI.B_GetUSBBufferLen(); - PrintAPI.B_EnumUSB(new byte[128]); - PrintAPI.B_CreateUSBPort(1); - - PrintAPI.B_Prn_Text_TrueType(40, 26, 31, "黑体", 1, 700, 0, 0, 0, "C1", entity.Goods_Name); - PrintAPI.B_Prn_Text_TrueType(40, 70, 31, "黑体", 1, 400, 0, 0, 0, "C2", string.Format("产品重量:{0}", entity.Weight)); - - - PrintAPI.B_Prn_Barcode(10, 320, 0, "1", 3, 22, 35, 'N', entity.BarCode.Replace("A26091201","")); - PrintAPI.B_Prn_Text_TrueType(40, 360, 25, "宋体", 1, 500, 0, 0, 0, "C9", entity.BarCode.Replace("A26091201", "")); - PrintAPI.B_Bar2d_QR(40, 105, 2, 6, 'M', 'A', 0, 0, 0, entity._2DQRCode.Replace("A26091201", "")); - - PrintAPI.B_Set_Direction('B'); - PrintAPI.B_Print_Out(1); - PrintAPI.B_ClosePrn(); - } } public class PrintEntity {