public void RemoveDishFromOrder() { if (RemoveToOrderDish != null) { if (Order.OrderStatus == OrderStatus.InWork) { bool printDeleted = true; var resPrinted = new List <string>(); if (RemoveToOrderDish.Printed) { printDeleted = PrintRecieps.PrintOnWinPrinter.PrintOrderToGoToKitchen(Order, out resPrinted, new List <IDishPackageLabel>() { RemoveToOrderDish }); } if (printDeleted) { foreach (var ord in OrderDishez.Where(a => a.PositionInOrder > RemoveToOrderDish.PositionInOrder)) { ord.PositionInOrder--; } OrderDishez.Remove(RemoveToOrderDish); } else { UI.UIModify.ShowAlert("Ошибка при печати на кухню!" + Environment.NewLine + "Блюдо удалено не будет" + Environment.NewLine + string.Join(Environment.NewLine, resPrinted)); } } else { if (WndDeleteDishModel.ShowWndDeleteDish(RemoveToOrderDish)) { bool printDeleted = true; var resPrinted = new List <string>(); { printDeleted = PrintRecieps.PrintOnWinPrinter.PrintOrderToGoToKitchen(Order, out resPrinted, new List <IDishPackageLabel>() { RemoveToOrderDish }); } } } } }
public bool SaveOrder() { logger.Debug($"SaveOrder {Order.Id}"); bool NewOrder = (Order.Id == 0); try { if (Order.OrderCustomer == null) { logger.Debug($"Order.OrderCustomer== null {Order?.Id}"); UI.UIModify.ShowAlert("Нельзя сохранить заказ без указания клиента"); logger.Debug($"Order.OrderCustomer== null end {Order.Id}"); return(false); } List <long> oldItms = OrderDishez.Where(a => a.Printed).Select(a => a.Id).ToList(); Order.DishPackages = OrderDishez.ToList(); Order.IsSHSent = true; var sRes = DataCatalogsSingleton.Instance.OrdersToGoData.EndEdit(Order); if (!sRes.Succeess) { UI.UIModify.ShowAlert($"Ошибка при сохранении заказа {sRes.ErrorMessage}"); return(false); } try { foreach (var dp in sRes.UpdatedItem.DishPackages) { dp.Printed = oldItms.Contains(dp.Id); } if (sRes.UpdatedItem.DishPackages != null && sRes.UpdatedItem.DishPackages.Any(a => !a.Printed)) { //Печатаем List <string> outErr = new List <string>(); if (!PrintRecieps.PrintOnWinPrinter.PrintOrderToGoToKitchen(sRes.UpdatedItem, out outErr)) { foreach (string s in outErr) { UI.UIModify.ShowAlert(s); } } else { foreach (var d in sRes.UpdatedItem.DishPackages) { d.Printed = true; } } } } catch (Exception e) { logger.Error("Error save print " + e.Message); } if (Order.OrderStatus != OrderStatus.InWork) { var CreateSHres = SH.SHWrapper.CreateSalesInvoiceSync(Order, out string err); if (!CreateSHres) { UI.UIModify.ShowAlert($"{err + Environment.NewLine} Накладная будет создана при появлении связи со StoreHouse"); Models.ToGoOrdersModelSingleton.Instance.UpdateOrder(Order); } } if (NewOrder) { MainClass.AfterSaveNewToGoOrder(); } return(true); } catch (Exception e) { logger.Error($"SaveOrder Error {Order.Id} Mess: {e.Message}"); return(false); } finally { } }