From 380907116fb40895d77424e36deb111b0d1564d3 Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Thu, 19 Oct 2017 15:55:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=93=E5=8D=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QualityAndOrder/HurryRecordPrint.cs | 47 +++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/QualityAndOrder/HurryRecordPrint.cs b/QualityAndOrder/HurryRecordPrint.cs index fed802d..a410de8 100644 --- a/QualityAndOrder/HurryRecordPrint.cs +++ b/QualityAndOrder/HurryRecordPrint.cs @@ -12,20 +12,55 @@ namespace QualityAndOrder { public static void Print(HurryRecord entity) { + entity.LiveColonyHouse_Name = "B-12-1,B-12-2,B-12-3,B-12-4"; + PrintAPI.B_GetUSBBufferLen(); PrintAPI.B_EnumUSB(new byte[128]); PrintAPI.B_CreateUSBPort(1); - PrintAPI.B_Prn_Text_TrueType(250, 15, 38, "宋体", 1, 700, 0, 0, 0, "C1", "急宰扫码"); - PrintAPI.B_Bar2d_QR(45, 75, 2, 13, 'M', 'A', 0, 0, 0, string.Format("s{0}e", entity.ID)); + PrintAPI.B_Prn_Text_TrueType(255, 15, 38, "宋体", 1, 700, 0, 0, 0, "C1", "急宰单"); + PrintAPI.B_Bar2d_QR(40, 75, 2, 12, 'M', 'A', 0, 0, 0, string.Format("s{0}e", entity.ID)); - PrintAPI.B_Prn_Text_TrueType(335, 90, 32, "宋体", 1, 600, 0, 0, 0, "C2", string.Format("磅单号:{0}", entity.B3WeighBill_ID)); - PrintAPI.B_Prn_Text_TrueType(335, 150, 32, "宋体", 1, 600, 0, 0, 0, "C3", string.Format("供应商:{0}", entity.Supplier_Name)); - PrintAPI.B_Prn_Text_TrueType(335, 210, 32, "宋体", 1, 600, 0, 0, 0, "C4", string.Format("头 数:{0}", entity.HurryNumber)); - PrintAPI.B_Prn_Text_TrueType(335, 270, 32, "宋体", 1, 600, 0, 0, 0, "C5", string.Format("时 间:{0}", entity.Time.ToString("MM/dd HH:mm"))); + PrintAPI.B_Prn_Text_TrueType(300, 90, 32, "宋体", 1, 600, 0, 0, 0, "C2", string.Format("磅单号:{0}", entity.B3WeighBill_ID)); + PrintAPI.B_Prn_Text_TrueType(300, 135, 32, "宋体", 1, 600, 0, 0, 0, "C3", string.Format("供应商:{0}", entity.Supplier_Name)); + PrintAPI.B_Prn_Text_TrueType(300, 180, 32, "宋体", 1, 600, 0, 0, 0, "C4", string.Format("头 数:{0}", entity.HurryNumber)); + var names = GetHouseNames(entity.LiveColonyHouse_Name); + PrintAPI.B_Prn_Text_TrueType(300, 225, 32, "宋体", 1, 600, 0, 0, 0, "C5", string.Format("圈 舍:{0}", names.Any() ? names[0] : string.Empty)); + names.RemoveAt(0); + var p = 6; + var x = 270; + foreach (var v in names) + { + PrintAPI.B_Prn_Text_TrueType(303, x, 32, "宋体", 1, 600, 0, 0, 0, "C" + p, string.Format(" {0}", names.Any() ? names[0] : string.Empty)); + p += 1; + x += 45; + } + PrintAPI.B_Prn_Text_TrueType(300, x, 32, "宋体", 1, 600, 0, 0, 0, "C" + p, string.Format("时 间:{0}", entity.Time.ToString("MM/dd HH:mm"))); PrintAPI.B_Set_Direction('B'); PrintAPI.B_Print_Out(1); PrintAPI.B_ClosePrn(); } + + static List GetHouseNames(string houseName) + { + var rst = new List(); + if (string.IsNullOrEmpty(houseName)) + return rst; + var arr = houseName.Split(new char[] { ',' }); + var temp = string.Empty; + foreach (var item in arr) + { + if(string.IsNullOrEmpty(temp)) + temp = item; + else + { + rst.Add(string.Format("{0},{1}", temp, item)); + temp = string.Empty; + } + } + if (!string.IsNullOrEmpty(temp)) + rst.Add(temp); + return rst; + } } }