public void DishInOrderDown() { if (RemoveToOrderDish.PositionInOrder > 1) { OrderDishez.Move((int)RemoveToOrderDish.PositionInOrder - 1, (int)RemoveToOrderDish.PositionInOrder - 2); OrderDishez[(int)RemoveToOrderDish.PositionInOrder - 1].PositionInOrder++; RemoveToOrderDish.PositionInOrder--; } }
public void DishInOrderUp() { if (RemoveToOrderDish.PositionInOrder < OrderDishez.Count) { OrderDishez.Move((int)RemoveToOrderDish.PositionInOrder - 1, (int)RemoveToOrderDish.PositionInOrder); OrderDishez[(int)RemoveToOrderDish.PositionInOrder - 1].PositionInOrder--; RemoveToOrderDish.PositionInOrder++; } }
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 }); } } } } }
private void EventsInit() { OrderDishez.CollectionChanged += ((sender, e) => { Order.DishPackages = OrderDishez.ToList(); OrderChanged?.Invoke(); }); //OrderDishez_CollectionChanged; OrderDishez.ItemPropertyChanged += ((sender, e) => { OrderChanged?.Invoke(); }); Order.PropertyChanged += ((sender, e) => { OrderChanged?.Invoke(); }); }
public bool SaveOrder() { logger.Debug($"SaveOrder {Order.Id}"); var addRes = true; try { if (Order.OrderCustomer == null) { logger.Debug($"Order.OrderCustomer== null {Order?.Id}"); addRes = false; UI.UIModify.ShowAlert("Нельзя сохранить заказ без указания клиента"); logger.Debug($"Order.OrderCustomer== null end {Order.Id}"); } Order.DishPackages = OrderDishez.ToList(); Order.IsSHSent = true; bool addToBaseRes = false; logger.Debug($"Before addRes"); if (addRes) { /* * if (Order.Id == 0) * { * addToBaseRes = ToGoOrdersModelSingleton.Instance.AddOrder(Order, OrderDishez.ToList()); * } * else * { * addToBaseRes = ToGoOrdersModelSingleton.Instance.UpdateOrder(Order); * } */ addToBaseRes = DataCatalogsSingleton.Instance.OrdersToGoData.EndEdit(Order).Succeess; logger.Debug($"After addRes addToBaseRes: {addToBaseRes}"); try { if (Order.DishPackages == null) { logger.Debug($"Before Print: Order.DishPackages==null"); } else { logger.Debug($"Before Print: Non print count: {Order.DishPackages.Where(a => !a.Printed).Count()}"); } if (Order.DishPackages != null && Order.DishPackages.Any(a => !a.Printed)) { //Печатаем List <string> outErr = new List <string>(); if (!PrintRecieps.PrintOnWinPrinter.PrintOrderToGoToKitchen(Order, out outErr)) { foreach (string s in outErr) { UI.UIModify.ShowAlert(s); } } else { foreach (var d in Order.DishPackages) { d.Printed = true; } } } } catch (Exception e) { logger.Error("Error save print " + e.Message); } } logger.Debug($"Before addToBaseRes"); if (addToBaseRes) { //SH.SHWrapper.CreateSalesInvoice(Order); 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); } } return(true); } return(false); } catch (Exception e) { logger.Error($"SaveOrder Error {Order.Id} Mess: {e.Message}"); return(false); } finally { } }
public void AddDishToOrder() { try { if ((AddToOrderDish == null) || (AddToOrderDish.Dish == null) || (AddToOrderDish.Dish.Barcode == 0)) { return; } bool res = true; if (DataCatalogsSingleton.Instance.OpenDishezToGoBarCodes.Contains(AddToOrderDish.Dish.Barcode)) { if (SelectedOpenDish == null) { var od = new Dish() { Name = OpenDishName, LabelRussianName = OpenDishName, //Name = OpenDishName, SHId = AddToOrderDish.Dish.SHId, Barcode = AddToOrderDish.Dish.Barcode, PriceForFlight = AddToOrderDish.TotalPrice, IsAlcohol = AddToOrderDish.Dish.IsAlcohol, IsTemporary = true, IsActive = true, IsToGo = true, }; var vm = new CreateTmpDishViewModel(od); var wnd = new UI.WndCreateTmpDish() { DataContext = vm }; wnd.Owner = MainClass.MainAppwindow; wnd.ShowDialog(); if (vm.Result) { res = DataCatalogsSingleton.Instance.AddOpenDish(od); AddToOrderDish.Dish = od; AddToOrderDish.TotalPrice = AddToOrderDish.Dish.PriceForFlight; } else { res = false; } } else { AddToOrderDish.Dish = SelectedOpenDish; } } if (res) { AddToOrderDish.DishId = AddToOrderDish.Dish.Id; AddToOrderDish.DishName = AddToOrderDish.Dish.Name; AddToOrderDish.PositionInOrder = OrderDishez.Count + 1; AddToOrderDish.Printed = false; OrderDishez.Add((DishPackageToGoOrder)AddToOrderDish.Clone()); } } catch { } }
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 { } }