屠宰场客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.3 KiB

using BO.BO.Bill;
using BWP.WinFormControl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QualityAndOrder
{
public static class HurryRecordPrint
{
public static void Print(HurryRecord entity)
{
PrintAPI.B_GetUSBBufferLen();
PrintAPI.B_EnumUSB(new byte[128]);
PrintAPI.B_CreateUSBPort(1);
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));
var y = 50;
var cIdx = 1;
PrintAPI.B_Prn_Text_TrueType(300, y += 40, 32, "宋体", 1, 600, 0, 0, 0, "C" + (++cIdx), string.Format("磅单号:{0}", entity.B3WeighBill_ID));
;
PrintAPI.B_Prn_Text_TrueType(300, y += 40, 32, "宋体", 1, 600, 0, 0, 0, "C" + (++cIdx), string.Format("总头数:{0}", entity.TotalNumber));
PrintAPI.B_Prn_Text_TrueType(300, y += 40, 32, "宋体", 1, 600, 0, 0, 0, "C" + (++cIdx), string.Format("急宰头数:{0}", entity.HurryNumber));
var names = GetHouseNames(entity.LiveColonyHouse_Name);
PrintAPI.B_Prn_Text_TrueType(300, y += 40, 32, "宋体", 1, 600, 0, 0, 0, "C" + (++cIdx), string.Format("圈 舍:{0}", names.Any() ? names[0] : string.Empty));
names.RemoveAt(0);
foreach (var v in names)
PrintAPI.B_Prn_Text_TrueType(303, y += 40, 32, "宋体", 1, 600, 0, 0, 0, "C" + (++cIdx), string.Format(" {0}", names.Any() ? names[0] : string.Empty));
PrintAPI.B_Prn_Text_TrueType(300, y += 40, 32, "宋体", 1, 600, 0, 0, 0, "C" + (++cIdx), 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<string> GetHouseNames(string houseName)
{
var rst = new List<string>();
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;
}
}
}