private void Button_Click(object sender, RoutedEventArgs e) { //9、点击出菜,打印机打印一条小票,显示桌号、备注信息、名称、份数、开台服务员名字。 if (GridMenuComplete.SelectedItem != null) { MenuInfo mi = GridMenuComplete.SelectedItem as MenuInfo; if (mi.SelectedDesk != null) { DXInfo.Restaurant.DeskManageFacade dmf = new DXInfo.Restaurant.DeskManageFacade(); dmf.CancelOutMenu(uow, mi.OrderMenuId, App.MyIdentity.oper.UserId, mi.SelectedDesk.DeskId); List <SelInv> confirmmenu = new List <SelInv>(); SelInv si = new SelInv(); var inv = (from d in uow.Inventory.GetAll() where d.Id == mi.InventoryId select d).FirstOrDefault(); si.Category = inv.Category; si.Amount = mi.Price; si.Quantity = 1; si.Name = mi.InvName; si.Comment = mi.Comment; confirmmenu.Add(si); var ctx = new { DeskNo = mi.SelectedDesk.DeskCode + "(取消出菜)", Sum = mi.Price, Count = 1, lSelInv = confirmmenu, CreateDate = DateTime.Now, DeptName = App.MyIdentity.dept.DeptName, }; System.Printing.LocalPrintServer lp = new System.Printing.LocalPrintServer(); System.Printing.PrintQueue pq = new System.Printing.PrintQueue(lp, inv.Printer); DeskConfirmWindow dcw = new DeskConfirmWindow(ctx, pq); if (dcw.ShowDialog().GetValueOrDefault()) { } MessageBox.Show(mi.SelectedDesk.DeskCode + "(" + mi.InvName + ")" + "取消出菜成功"); UpdateOrderMenuData(); } else { MessageBox.Show("请选中桌台号"); } } }
private void btnConfirm_Click(object sender, RoutedEventArgs e) { #region 菜品入库 Hashtable htAdd = new Hashtable(); Hashtable htSub = new Hashtable(); if (GridSelected.ItemsSource == null) { ocSelDesks = new ObservableCollection <DXInfo.Models.OrderMenuEx>(); } else { ocSelDesks = GridSelected.ItemsSource as ObservableCollection <DXInfo.Models.OrderMenuEx>; } if (desk != null && order != null && ocSelDesks.Count > 0) { using (TransactionScope transaction = new TransactionScope()) { int addmenu = 0; foreach (DXInfo.Models.OrderMenuEx selDesk in ocSelDesks) { if (selDesk.Id != Guid.Empty) { DXInfo.Models.OrderMenus orderMenu = uow.OrderMenus.GetById(selDesk.Id);//.Where(w => w.Id == selDesk.Id).FirstOrDefault(); if (orderMenu != null) { if (orderMenu.Status == 2 && orderMenu.Quantity != selDesk.Quantity) { DXInfo.Models.Inventory inv = uow.Inventory.GetById(orderMenu.InventoryId);//.Where(w => w.Id == orderMenu.InventoryId).FirstOrDefault(); if (!string.IsNullOrEmpty(inv.Printer)) { if (orderMenu.Quantity > selDesk.Quantity) { if (htSub.Contains(inv.Printer)) { List <InventoryEx> confirmmenu = htSub[inv.Printer] as List <InventoryEx>; InventoryEx si = new InventoryEx(); si.Category = inv.Category; //si.Quantity = orderMenu.Quantity - selDesk.Quantity; si.SalePrice = inv.SalePrice; //si.Amount = inv.SalePrice * (orderMenu.Quantity - selDesk.Quantity); si.Quantity = orderMenu.Quantity - selDesk.Quantity; si.Name = inv.Name; si.Comment = orderMenu.Comment; confirmmenu.Add(si); htSub[inv.Printer] = confirmmenu; } else { List <InventoryEx> confirmmenu = new List <InventoryEx>(); InventoryEx si = new InventoryEx(); si.Category = inv.Category; //si.Amount = inv.SalePrice * (orderMenu.Quantity - selDesk.Quantity); //si.Quantity = orderMenu.Quantity - selDesk.Quantity; si.SalePrice = inv.SalePrice; si.Quantity = orderMenu.Quantity - selDesk.Quantity; si.Name = inv.Name; si.Comment = orderMenu.Comment; confirmmenu.Add(si); htSub.Add(inv.Printer, confirmmenu); } } else { if (htAdd.Contains(inv.Printer)) { List <InventoryEx> confirmmenu = htAdd[inv.Printer] as List <InventoryEx>; InventoryEx si = new InventoryEx(); si.Category = inv.Category; //si.Amount = inv.SalePrice*(selDesk.Quantity-orderMenu.Quantity); //si.Quantity = orderMenu.Quantity - selDesk.Quantity; si.SalePrice = inv.SalePrice; si.Quantity = selDesk.Quantity - orderMenu.Quantity; si.Name = inv.Name; si.Comment = orderMenu.Comment; confirmmenu.Add(si); htAdd[inv.Printer] = confirmmenu; } else { List <InventoryEx> confirmmenu = new List <InventoryEx>(); InventoryEx si = new InventoryEx(); si.Category = inv.Category; //si.Amount = inv.SalePrice * (selDesk.Quantity - orderMenu.Quantity); si.SalePrice = inv.SalePrice; si.Quantity = selDesk.Quantity - orderMenu.Quantity; si.Name = inv.Name; si.Comment = orderMenu.Comment; confirmmenu.Add(si); htAdd.Add(inv.Printer, confirmmenu); } } } } orderMenu.Quantity = selDesk.Quantity; orderMenu.Amount = selDesk.Quantity * orderMenu.Price; orderMenu.Comment = selDesk.Comment; DXInfo.Models.OrderMenusHis menuHis = new DXInfo.Models.OrderMenusHis(); menuHis.LinkId = orderMenu.Id; menuHis.OrderId = orderMenu.OrderId; menuHis.InventoryId = orderMenu.InventoryId; menuHis.Price = orderMenu.Price; menuHis.Quantity = orderMenu.Quantity; menuHis.Amount = orderMenu.Amount; menuHis.UserId = App.MyIdentity.oper.UserId; menuHis.CreateDate = DateTime.Now; menuHis.Status = orderMenu.Status; menuHis.Comment = orderMenu.Comment; uow.OrderMenusHis.Add(menuHis); } } else { DXInfo.Models.OrderMenus orderMenu = new DXInfo.Models.OrderMenus(); orderMenu.OrderId = order.Id; orderMenu.InventoryId = selDesk.InventoryId; orderMenu.Price = selDesk.Price; orderMenu.Quantity = selDesk.Quantity; orderMenu.Amount = selDesk.Amount; orderMenu.Comment = selDesk.Comment; orderMenu.CreateDate = DateTime.Now; orderMenu.UserId = App.MyIdentity.user.UserId; uow.OrderMenus.Add(orderMenu); uow.Commit(); DXInfo.Models.OrderMenusHis menuHis = new DXInfo.Models.OrderMenusHis(); menuHis.LinkId = orderMenu.Id; menuHis.OrderId = orderMenu.OrderId; menuHis.InventoryId = orderMenu.InventoryId; menuHis.Price = orderMenu.Price; menuHis.Quantity = orderMenu.Quantity; menuHis.Amount = orderMenu.Amount; menuHis.UserId = App.MyIdentity.oper.UserId; menuHis.CreateDate = DateTime.Now; menuHis.Status = orderMenu.Status; menuHis.Comment = orderMenu.Comment; uow.OrderMenusHis.Add(menuHis); addmenu++; } } if (addmenu > 0) { DXInfo.Models.OrderDishes odish = uow.OrderDishes.GetById(order.Id);//.Where(w => w.Id == order.Id).FirstOrDefault(); odish.Status = 0; } uow.Commit(); transaction.Complete(); } } #endregion string deskCodes = ""; DXInfo.Restaurant.DeskManageFacade dmf = new DXInfo.Restaurant.DeskManageFacade(uow, Guid.Empty, Guid.Empty); deskCodes = dmf.GetOrderDeskCodes(uow, order.Id); if (htAdd.Count > 0) { foreach (DictionaryEntry de in htAdd) { List <InventoryEx> confirmmenu = de.Value as List <InventoryEx>; decimal dsum = confirmmenu.Sum(s => s.Amount); decimal dcount = confirmmenu.Sum(s => s.Quantity); if (confirmmenu.Count > 0) { var ctx = new { DeskNo = deskCodes + "(加单)", Sum = dsum, Count = dcount, lSelInv = confirmmenu, CreateDate = DateTime.Now, DeptName = App.MyIdentity.dept.DeptName, }; System.Printing.LocalPrintServer lp = new System.Printing.LocalPrintServer(); System.Printing.PrintQueue pq = new System.Printing.PrintQueue(lp, de.Key.ToString()); DeskConfirmWindow dcw = new DeskConfirmWindow(ctx, pq); if (dcw.ShowDialog().GetValueOrDefault()) { } } } } if (htSub.Count > 0) { foreach (DictionaryEntry de in htSub) { List <InventoryEx> confirmmenu = de.Value as List <InventoryEx>; decimal dsum = confirmmenu.Sum(s => s.Amount); decimal dcount = confirmmenu.Sum(s => s.Quantity); if (confirmmenu.Count > 0) { var ctx = new { DeskNo = deskCodes + "(减单)", Sum = dsum, Count = dcount, lSelInv = confirmmenu, CreateDate = DateTime.Now, DeptName = App.MyIdentity.dept.DeptName, }; System.Printing.LocalPrintServer lp = new System.Printing.LocalPrintServer(); System.Printing.PrintQueue pq = new System.Printing.PrintQueue(lp, de.Key.ToString()); DeskConfirmWindow dcw = new DeskConfirmWindow(ctx, pq); if (dcw.ShowDialog().GetValueOrDefault()) { } } } } this.DialogResult = true; }