public ToGoOrdersViewModel() { Logger _logger = LogManager.GetCurrentClassLogger(); // ToGoOrdersModelSingleton.Instance.OnOrderAdded += new ToGoOrdersModelSingleton.OrderAddedHandler(ord => { AfterAddOrder(); }); AddNewOrderCommand = new DelegateCommand(_ => { MainClass.ShowUC(UI.UIModify.GetCtrlAddToGoOrder()); }); EditOrderCommand = new DelegateCommand(_ => { if (CurentOrder != null) { try { if (!CanEditCurentOrder) { return; } MainClass.StartBusy(); MainClass.ShowUC(UI.UIModify.GetCtrlAddToGoOrder(CurentOrder)); } catch { } finally { MainClass.StopBusy(); } } }); CopyOrderCommand = new DelegateCommand(_ => { if (CurentOrder != null) { MainClass.StartBusy(); var CopyOrder = (OrderToGo)CurentOrder.Clone(); MainClass.ShowUC(UI.UIModify.GetCtrlAddToGoOrder(CopyOrder)); MainClass.StopBusy(); } }); CloseOrderCommand = new DelegateCommand(_ => { if (CurentOrder != null) { MainClass.CloseSingleCheck(CurentOrder); RaisePropertyChanged("CanEditCurentOrder"); RaisePropertyChanged("CanCloseCurentOrder"); } }); DeleteOrderCommand = new DelegateCommand(_ => { try { _logger.Debug("DeleteOrderCommand ToGo"); if (CurentOrder != null) { _logger.Debug($"DeleteOrderCommand ToGo Id: {CurentOrder.Id}"); var delres = UI.UIModify.ShowPromt($"Вы уверены, что хотите удалить заказ №{CurentOrder.Id + Environment.NewLine}. Если да, то введите номер заказа.", "Удалить", "Отмена", "Удаление заказа"); if (delres != null && delres.DialogResult.GetValueOrDefault()) { if (delres.PromptResult != null && (delres.PromptResult.Trim() == CurentOrder.Id.ToString())) { var resPrinted = new List <string>(); var printDeleted = PrintRecieps.PrintOnWinPrinter.PrintOrderToGoToKitchen(CurentOrder, out resPrinted, CurentOrder.DishPackagesForLab); if (printDeleted) { ToGoOrdersModelSingleton.Instance.DeleteOrder(CurentOrder); } else { //ToGoOrdersModelSingleton.Instance.DeleteOrder(CurentOrder); UI.UIModify.ShowAlert("Ошибка при печати на кухню!" + Environment.NewLine + "Заказ удален не будет" + Environment.NewLine + string.Join(Environment.NewLine, resPrinted)); } } } } } catch (Exception e) { _logger.Error($"DeleteOrderCommand error : {e.Message}"); } }); PrintLabelCommand = new DelegateCommand(_ => { if (CurentOrder != null) { UI.UIModify.ShowWndPrintLabels(CurentOrder); } else { UI.UIModify.ShowAlert("Нет заказа для печати"); } }); RefreshCommand = new DelegateCommand(_ => { if (!MainClass.AddToGoOrderPaneOpen()) { RealTimeUpdaterSingleton.Instance.UpdateData(); //ToGoOrdersModelSingleton.Instance.RefreshOrdersRange(); // DataCatalogsSingleton.Instance.OrdersToGoData.FillUpdate(); } else { UI.UIModify.ShowAlert($"Для обновления данных по заказам ToGo {Environment.NewLine} необходимо закрыть все вкладки {Environment.NewLine}с добавление либо изменением заказа ToGo."); } }); PrintInvoiceItems = new DelegateCommand(_ => { if (CurentOrder != null) { UI.UIModify.ShowWndPrintExcelDoc($"Накладная ToGo на к заказу №{ CurentOrder.Id}", AlohaService.ExcelExport.ExportHelper.ExportToGoToExcelWorkbookRussian(CurentOrder)); } else { UI.UIModify.ShowAlert("Нет заказа для печати"); } } ); ChangeStatusCommand = new DelegateCommand(_ => { try { if ((CurentOrder != null)) { //CurentOrder.SendById = Authorization.CurentUser.Id; //CurentOrder.SendBy = Authorization.CurentUser; // UI.UIModify.ShowAlert("ChangeStatusCommand from togo orders"); if (CurentOrder.OrderStatus == OrderStatus.InWork) { CurentOrder.OrderStatus = OrderStatus.Sent; SH.SHWrapper.CreateSalesInvoiceSync(CurentOrder, out string err); } else if (CurentOrder.OrderStatus == OrderStatus.Sent) { CurentOrder.OrderStatus = OrderStatus.InWork; } Models.ToGoOrdersModelSingleton.Instance.UpdateOrder(CurentOrder); RaisePropertyChanged("SetSendStatusBntName"); } else { UI.UIModify.ShowAlert("Нет заказа для отправки"); } } catch { } } ); }
public AirOrdersViewModel() { Logger logger = LogManager.GetCurrentClassLogger(); EnableCollectionSynchronization(); AirOrdersModelSingleton.Instance.OnOrderAdded += new AirOrdersModelSingleton.OrderAddedHandler(ord => { AfterAddOrder(); }); AddNewOrderCommand = new DelegateCommand(_ => { MainClass.ShowUC(UI.UIModify.GetCtrlAddOrder()); }); EditOrderCommand = new DelegateCommand(_ => { //thread if (CurentOrder != null) { if (!CanEditCurentOrder) { return; } MainClass.StartBusy(); MainClass.ShowUC(UI.UIModify.GetCtrlAddOrder(CurentOrder)); MainClass.StopBusy(); } }); CopyOrderCommand = new DelegateCommand(_ => { if (CurentOrder != null) { MainClass.StartBusy(); var CopyOrder = (OrderFlight)CurentOrder.Clone(); MainClass.ShowUC(UI.UIModify.GetCtrlAddOrder(CopyOrder)); MainClass.StopBusy(); } }); CloseOrderCommand = new DelegateCommand(_ => { if (CurentOrder != null) { MainClass.CloseSingleCheck(CurentOrder); RaisePropertyChanged("CanEditCurentOrder"); RaisePropertyChanged("CanCloseCurentOrder"); } }); DeleteOrderCommand = new DelegateCommand(_ => { try { logger.Debug($"DeleteOrderCommand ToFly"); if (CurentOrder != null) { logger.Debug($"DeleteOrderCommand ToFly Id: {CurentOrder.Id}"); var delres = UI.UIModify.ShowPromt($"Вы уверены, что хотите удалить заказ №{CurentOrder.Id + Environment.NewLine}. Если да, то введите номер заказа.", "Удалить", "Отмена", "Удаление заказа"); if (delres != null && delres.DialogResult.GetValueOrDefault()) { if (delres.PromptResult != null && (delres.PromptResult.Trim() == CurentOrder.Id.ToString())) { AirOrdersModelSingleton.Instance.DeleteOrder(CurentOrder); } } } } catch (Exception e) { logger.Error($"DeleteOrderCommand error : {e.Message}"); } }); RefreshCommand = new DelegateCommand(_ => { if (!MainClass.AddAirOrderPaneOpen()) { AirOrdersModelSingleton.Instance.RefreshOrdersRange(); } else { UI.UIModify.ShowAlert($"Для обновления данных по заказам ToFly {Environment.NewLine} необходимо закрыть все вкладки {Environment.NewLine}с добавление либо изменением заказа ToFly."); } }); SetSendStatusCommand = new DelegateCommand(_ => { if (CurentOrder != null) { logger.Debug($"SetSendStatusCommand {CurentOrder.Id}"); CurentOrder.SendById = Authorization.CurentUser.Id; CurentOrder.SendBy = Authorization.CurentUser; if (curentOrder.OrderStatus == OrderStatus.InWork) { CurentOrder.OrderStatus = OrderStatus.Sent; SH.SHWrapper.CreateSalesInvoiceSync(CurentOrder, out string err); } else if (curentOrder.OrderStatus == OrderStatus.Sent) { CurentOrder.OrderStatus = OrderStatus.InWork; } Models.AirOrdersModelSingleton.Instance.UpdateOrder(CurentOrder); logger.Debug($"SetSendStatusCommand end {CurentOrder.Id}"); RaisePropertyChanged("SetSendStatusBntName"); } }); PrintLabelCommand = new DelegateCommand(_ => { UI.UIModify.ShowWndPrintLabels(CurentOrder); }); }