/// <summary> /// 打印美团单 /// </summary> /// <param name="groupName"></param> /// <param name="printer"></param> /// <param name="custmerNO"></param> /// <param name="tabie"></param> public void Printeg(string groupName, tm_Printer printer, int custmerNO, string tabie, int type) { var p = new NetPrintHelper(); var batai = p.GetPrint(printer.IP, printer.Port);//获得吧台打印机 var liunull = p.BuildStream();//初始化一个网络访问数据流 try { var liu = p.GetStream(batai, liunull);//获得通讯打印流 string title = ""; p.SetFontSize(liu, 2);//字体变大 if (type == 4) { p.SetFontSize(liu, 3);//字体变大 title = "####点菜单(走菜)####"; } if (type == 1) { p.SetFontSize(liu, 3);//字体变大 title = "美团单"; } p.SetBold(liu, 1);//加粗 p.PrintText(liu, tabie + "\n");//打印文字 p.PrintText(liu, title + "\n\n");//打印文字 p.SetBold(liu, 0);//取消加粗 p.SetFontSize(liu, 0); p.SetDuiQi(liu, 0); p.PrintText(liu, DateTime.Now.ToString() + " 客数:" + custmerNO + "\n");//打印文字 p.PrintText(liu, "------------------------------------------------\n");//打印文字 p.SetFontSize(liu, 1); int length = 40 - groupName.Length; p.PrintText(liu, groupName.PadRight(length) + 1 + " " + "份\n");//打印文字 p.SetFontSize(liu, 0); p.PrintText(liu, "------------------------------------------------\n");//打印文字 p.PrintText(liu, "服务员:002 打印机:" + printer.PrinterName + "\n\n\n\n\n\n");//打印文字 p.QieZhi(liu);//切纸 } catch { //打印机缺纸或者纸匣打开时,不会出现异常,不用特殊代码判断,数据不会丢失. } finally { p.DiposeStreamClient(batai, liunull);//释放资源 } }
public void Printeg() { var p = new NetPrintHelper(); var batai = p.GetPrint();//获得吧台打印机 var liunull = p.BuildStream();//初始化一个网络访问数据流 try { var liu = p.GetStream(batai, liunull);//获得通讯打印流 string title = ""; p.SetFontSize(liu, 2);//字体变大 title = "点菜单"; p.SetFontSize(liu, 0); p.PrintText(liu, "------------------------------------------------\n");//打印文字 p.PrintText(liu, "服务员:002 打印机:测试\n\n\n\n\n\n");//打印文字 p.QieZhi(liu);//切纸 } catch { //打印机缺纸或者纸匣打开时,不会出现异常,不用特殊代码判断,数据不会丢失. } finally { p.DiposeStreamClient(batai, liunull);//释放资源 } }
/// <summary> /// 单个打印点菜单 /// </summary> /// <param name="dishesName">菜品名称</param> /// <param name="dishesCount">菜品数量</param> /// <param name="unitName">菜品单位</param> /// <param name="custmerNO">客数</param> /// <param name="printer">打印机信息</param> /// <param name="type">单子类型</param> /// <param name="tabieName">餐台名称</param> public void Printeg(string dishesName, decimal dishesCount, string unitName, int custmerNO, tm_Printer printer, int type, string tabieName) { var p = new NetPrintHelper(); var batai = p.GetPrint(printer.IP, printer.Port);//获得吧台打印机 var liunull = p.BuildStream();//初始化一个网络访问数据流 try { var liu = p.GetStream(batai, liunull);//获得通讯打印流 string title = ""; if (type == 1) { p.SetFontSize(liu, 2);//字体变大 title = "点菜单(留存)"; } if (type == 9) { p.SetFontSize(liu, 2);//字体变大 title = "点菜单(上菜)"; } if (type == 2) { p.SetFontSize(liu, 2);//字体变大 title = "----叫菜单(留存)----"; } if (type == 8) { p.SetFontSize(liu, 2);//字体变大 title = "----叫菜单(上菜)----"; } if (type == 3) { p.SetFontSize(liu, 3);//字体变大 title = "####退菜单####"; } p.SetBold(liu, 1);//加粗 p.PrintText(liu, tabieName + "\n");//打印文字 p.PrintText(liu, title + "\n\n");//打印文字 p.SetBold(liu, 0);//取消加粗 p.SetFontSize(liu, 0); p.SetDuiQi(liu, 0); //tm_TabieUsingInfo entity = Core.Container.Instance.Resolve<IServiceTabieUsingInfo>().GetEntity(dishesInfo.TabieUsingID); p.PrintText(liu, DateTime.Now.ToString() + " 客数:" + custmerNO + "\n");//打印文字 p.PrintText(liu, "------------------------------------------------\n");//打印文字 p.SetFontSize(liu, 1); int length = 40 - dishesName.Length; p.PrintText(liu, dishesName.PadRight(length) + Math.Abs(dishesCount) + " " + unitName + "\n");//打印文字 //dishesInfo.IsPrint = 1; //Core.Container.Instance.Resolve<IServiceTabieDishesInfo>().Update(dishesInfo); p.SetFontSize(liu, 0); p.PrintText(liu, "------------------------------------------------\n");//打印文字 p.PrintText(liu, "服务员:002 打印机:" + printer.PrinterName + "\n\n\n\n\n\n");//打印文字 p.QieZhi(liu);//切纸 } catch { //打印机缺纸或者纸匣打开时,不会出现异常,不用特殊代码判断,数据不会丢失. } finally { p.DiposeStreamClient(batai, liunull);//释放资源 } }
/// <summary> /// 批量打印点菜单 /// </summary> /// <param name="list"></param> /// <param name="printer"></param> /// <param name="type"></param> /// <param name="tabie"></param> public void Printeg(IList<tm_TabieDishesInfo> list, tm_Printer printer, int type, string tabie) { var p = new NetPrintHelper(); var batai = p.GetPrint(printer.IP, printer.Port);//获得吧台打印机 var liunull = p.BuildStream();//初始化一个网络访问数据流 try { var liu = p.GetStream(batai, liunull);//获得通讯打印流 string title = ""; if (type == 1) { p.SetFontSize(liu, 2);//字体变大 title = "点菜单"; } else if (type == 2) { p.SetFontSize(liu, 2);//字体变大 title = "加菜单"; } else { p.SetFontSize(liu, 3);//字体变大 title = "#退菜单#"; } p.SetBold(liu, 1);//加粗 p.PrintText(liu, tabie + "\n");//打印文字 p.PrintText(liu, title + "\n\n");//打印文字 p.SetBold(liu, 0);//取消加粗 p.SetFontSize(liu, 0); p.SetDuiQi(liu, 0); tm_TabieUsingInfo entity = Core.Container.Instance.Resolve<IServiceTabieUsingInfo>().GetEntity(list[0].TabieUsingID); p.PrintText(liu, DateTime.Now.ToString() + " 客数:" + entity.Population + "\n");//打印文字 p.PrintText(liu, "------------------------------------------------\n");//打印文字 p.SetFontSize(liu, 1); foreach (tm_TabieDishesInfo item in list) { int length = 40 - item.DishesName.Length; p.PrintText(liu, item.DishesName.PadRight(length) + item.DishesCount + " " + item.UnitName + "\n");//打印文字 item.IsPrint = 1; Core.Container.Instance.Resolve<IServiceTabieDishesInfo>().Update(item); } p.SetFontSize(liu, 0); p.PrintText(liu, "------------------------------------------------\n");//打印文字 p.PrintText(liu, "服务员:002 打印机:" + printer.PrinterName + "\n\n\n\n\n\n");//打印文字 p.QieZhi(liu);//切纸 } catch { //打印机缺纸或者纸匣打开时,不会出现异常,不用特殊代码判断,数据不会丢失. } finally { p.DiposeStreamClient(batai, liunull);//释放资源 } }