private void billTimer_Tick(object sender, EventArgs e) { try { billTimer.Stop(); Padorder order = CommService.GetLastNotPrintPadorder(); if (order != null) { BillInfoService bService = new BillInfoService(); BillInfo billinfo = bService.GetBillInfoByBillkey(order.billkey); BillDetailInfoService dService = new BillDetailInfoService(); List<BillDetailInfo> bills = dService.GetBillDetailInfoByBillkey(order.billkey); //List<BillDetailInfo> AllDetailInfos = new List<BillDetailInfo>(); List<BillDetailInfo> KitchenDetailInfos = new List<BillDetailInfo>(); List<BillDetailInfo> BarDetailInfos = new List<BillDetailInfo>(); foreach (BillDetailInfo bd in bills) { if (bd.isPrint == 1) break; if (FoodService.IsPlanFood(bd.FoodCnName)) { PlanFoodService pService = new PlanFoodService(); List<PlanFood> planFoods = pService.GetPlanFood(bd.FoodCnName); foreach (PlanFood f in planFoods) { BillDetailInfo pdInfo = new BillDetailInfo(); pdInfo.BillKey = order.billkey; pdInfo.FoodCnName = f.planFoodname; pdInfo.foodCount = f.planFoodCount; pdInfo.FoodID = 0; pdInfo.FoodPrice = f.planFoodPrice; pdInfo.FoodUnit = f.planFoodUnit; pdInfo.Handsel = "否"; pdInfo.isPrint = 0; pdInfo.jiaocai = order.jiaocai; pdInfo.remark = ""; pdInfo.Mark = ""; pdInfo.Stauts = "已点菜"; pdInfo.Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); pdInfo.UserName = App.userName; if (FoodService.IsKitchenFood(f.planFoodname)) { KitchenDetailInfos.Add(pdInfo); } else { BarDetailInfos.Add(pdInfo); } } } else { if (FoodService.IsKitchenFood(bd.FoodCnName)) { KitchenDetailInfos.Add(bd); } else { BarDetailInfos.Add(bd); } } } // 打印 TabInfoService tabService = new TabInfoService(); TabInfo tabInfo = tabService.GetTabInfoByTabName(order.tabname); // 打印账单 if (bills.Count <= 0) return; string tabStatus = tabInfo.status; if (tabStatus.Equals("开台")) { ConsumeBillPrinter conPrinter = new ConsumeBillPrinter(billinfo, "点餐单", bills); conPrinter.pdDocument.Print(); if (KitchenDetailInfos.Count > 0) { KitchenBillPrinter kitPrinter = new KitchenBillPrinter(billinfo, "点餐单", KitchenDetailInfos); kitPrinter.pdDocument.Print(); foreach (BillDetailInfo d in KitchenDetailInfos) { KitchenBillDetailPrinter kitDetailPrinter = new KitchenBillDetailPrinter(d, tabName, "后厨点菜单"); kitDetailPrinter.pdDocument.Print(); BillDetailInfoService.UpdatePrintByID(d.ID); } } if (BarDetailInfos.Count > 0) { BarBillPrinter barPrinter = new BarBillPrinter(billinfo, "点餐单", BarDetailInfos); barPrinter.pdDocument.Print(); foreach (BillDetailInfo d in BarDetailInfos) { BarBillDetailPrinter barDetailPrinter = new BarBillDetailPrinter(d, tabName, "酒吧点菜单"); barDetailPrinter.pdDocument.Print(); BillDetailInfoService.UpdatePrintByID(d.ID); } } } else { ConsumeBillPrinter conPrinter = new ConsumeBillPrinter(billinfo, "加菜单", bills); conPrinter.pdDocument.Print(); if (KitchenDetailInfos.Count > 0) { KitchenBillPrinter kitPrinter = new KitchenBillPrinter(billinfo, "加餐单", KitchenDetailInfos); kitPrinter.pdDocument.Print(); foreach (BillDetailInfo d in KitchenDetailInfos) { KitchenBillDetailPrinter kitDetailPrinter = new KitchenBillDetailPrinter(d, tabName, "后厨加菜单"); kitDetailPrinter.pdDocument.Print(); BillDetailInfoService.UpdatePrintByID(d.ID); } } if (BarDetailInfos.Count > 0) { BarBillPrinter barPrinter = new BarBillPrinter(billinfo, "加餐单", BarDetailInfos); barPrinter.pdDocument.Print(); foreach (BillDetailInfo d in BarDetailInfos) { BarBillDetailPrinter barDetailPrinter = new BarBillDetailPrinter(d, tabName, "酒吧加菜单"); barDetailPrinter.pdDocument.Print(); BillDetailInfoService.UpdatePrintByID(d.ID); } } } // 1 收银打印 总单 (点餐单或者加餐单) // 2 后厨打印总单+分单 (点餐单或者加餐单) // 3 酒吧打印总单+分单 (点餐单或者加餐单) if (tabInfo.status.Equals("开台")) { tabService.UpdateTabInfoStatus(tabName, "点餐"); } else { tabService.UpdateTabInfoStatus(tabName, "加餐"); } BillInfoService.UpdateBillIsPrintByBillkey(order.billkey); CommService.SetPadorderPrinted(order.id); } // 设置次order 已经打印 billTimer.Start(); } catch (Exception ex) { billTimer.Start(); MessageBox.Show(ex.Message); } }
private void lbOrder_Click(object sender, EventArgs e) { string billkey = BillInfoService.GetNotCheckOutBillkeyByTabName(tabName); BillInfoService bService = new BillInfoService(); BillInfo billInfo = bService.GetBillInfoByBillkey(billkey); BillDetailInfoService service = new BillDetailInfoService(); List<BillDetailInfo> AllDetailInfos = new List<BillDetailInfo>(); List<BillDetailInfo> KitchenDetailInfos = new List<BillDetailInfo>(); List<BillDetailInfo> BarDetailInfos = new List<BillDetailInfo>(); foreach (DataGridViewRow row in dvBill.Rows) { if (row.Cells["status"].Value.ToString() == "未确认") { BillDetailInfo dinfo = new BillDetailInfo(); dinfo.BillKey = billkey; dinfo.FoodCnName = row.Cells["foodname"].Value.ToString(); dinfo.foodCount = Convert.ToInt32(row.Cells["foodcount"].Value); dinfo.FoodID = 0; dinfo.FoodPrice = float.Parse(row.Cells["foodprice"].Value.ToString()); dinfo.FoodUnit = row.Cells["foodunit"].Value.ToString(); dinfo.Handsel = row.Cells["give"].Value.ToString(); dinfo.isPrint = 0; dinfo.jiaocai = row.Cells["hold"].Value.ToString(); dinfo.remark = row.Cells["cook"].Value.ToString(); dinfo.Mark = ""; dinfo.Stauts = "已点菜"; dinfo.Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); dinfo.UserName = App.userName; int id = service.AddBillDetailInfo(dinfo); dinfo.ID = id; if (FoodService.IsPlanFood(dinfo.FoodCnName)) { PlanFoodService pService = new PlanFoodService(); List<PlanFood> planFoods = pService.GetPlanFood(dinfo.FoodCnName); AllDetailInfos.Add(dinfo); foreach (PlanFood f in planFoods) { BillDetailInfo pdInfo = new BillDetailInfo(); pdInfo.BillKey = billkey; pdInfo.FoodCnName = f.planFoodname; pdInfo.foodCount = f.planFoodCount; pdInfo.FoodID = 0; pdInfo.FoodPrice = f.planFoodPrice; pdInfo.FoodUnit = f.planFoodUnit; pdInfo.Handsel = row.Cells["give"].Value.ToString(); pdInfo.isPrint = 0; pdInfo.jiaocai = row.Cells["hold"].Value.ToString(); pdInfo.remark = row.Cells["cook"].Value.ToString(); pdInfo.Mark = ""; pdInfo.Stauts = "已点菜"; pdInfo.Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); pdInfo.UserName = App.userName; if (FoodService.IsKitchenFood(f.planFoodname)) { KitchenDetailInfos.Add(pdInfo); } else { BarDetailInfos.Add(pdInfo); } } } else { AllDetailInfos.Add(dinfo); if (FoodService.IsKitchenFood(dinfo.FoodCnName)) { KitchenDetailInfos.Add(dinfo); } else { BarDetailInfos.Add(dinfo); } } } } TabInfoService tabService = new TabInfoService(); TabInfo tabInfo = tabService.GetTabInfoByTabName(tabName); // 打印账单 if (AllDetailInfos.Count <= 0) return; string tabStatus = tabInfo.status; if (tabStatus.Equals("开台")) { ConsumeBillPrinter conPrinter = new ConsumeBillPrinter(billInfo, "点餐单",AllDetailInfos); conPrinter.pdDocument.Print(); if (KitchenDetailInfos.Count > 0) { KitchenBillPrinter kitPrinter = new KitchenBillPrinter(billInfo, "点餐单", KitchenDetailInfos); kitPrinter.pdDocument.Print(); foreach (BillDetailInfo d in KitchenDetailInfos) { KitchenBillDetailPrinter kitDetailPrinter = new KitchenBillDetailPrinter(d, tabName, "后厨点菜单"); kitDetailPrinter.pdDocument.Print(); } } if (BarDetailInfos.Count > 0) { BarBillPrinter barPrinter = new BarBillPrinter(billInfo, "点餐单", BarDetailInfos); barPrinter.pdDocument.Print(); foreach (BillDetailInfo d in BarDetailInfos) { BarBillDetailPrinter barDetailPrinter = new BarBillDetailPrinter(d, tabName, "酒吧点菜单"); barDetailPrinter.pdDocument.Print(); } } } else { ConsumeBillPrinter conPrinter = new ConsumeBillPrinter(billInfo, "加菜单", AllDetailInfos); conPrinter.pdDocument.Print(); if (KitchenDetailInfos.Count > 0) { KitchenBillPrinter kitPrinter = new KitchenBillPrinter(billInfo, "加餐单", KitchenDetailInfos); kitPrinter.pdDocument.Print(); foreach (BillDetailInfo d in KitchenDetailInfos) { KitchenBillDetailPrinter kitDetailPrinter = new KitchenBillDetailPrinter(d, tabName, "后厨加菜单"); kitDetailPrinter.pdDocument.Print(); } } if (BarDetailInfos.Count > 0) { BarBillPrinter barPrinter = new BarBillPrinter(billInfo, "加餐单", BarDetailInfos); barPrinter.pdDocument.Print(); foreach (BillDetailInfo d in BarDetailInfos) { BarBillDetailPrinter barDetailPrinter = new BarBillDetailPrinter(d, tabName, "酒吧加菜单"); barDetailPrinter.pdDocument.Print(); } } } // 1 收银打印 总单 (点餐单或者加餐单) // 2 后厨打印总单+分单 (点餐单或者加餐单) // 3 酒吧打印总单+分单 (点餐单或者加餐单) if (tabInfo.status.Equals("开台")) { tabService.UpdateTabInfoStatus(tabName, "点餐"); } else { tabService.UpdateTabInfoStatus(tabName, "加餐"); } BillInfoService.UpdateBillIsPrintByBillkey(billkey); //this.DialogResult = System.Windows.Forms.DialogResult.OK; }