コード例 #1
0
 public bool Checked(OrderDishViewModel dish)
 {
     return(_valueDishChecker.Checked(new OrderFilterValue()
     {
         DepartmentId = dish.DepartmentId, StatusId = dish.DishStatusId
     }));
 }
コード例 #2
0
ファイル: OrderPageHelper.cs プロジェクト: AlCher2018/KDS
        public void ResetMaxDishesCountOnPage()
        {
            // создать элемент заказа (блюдо)
            OrderDishViewModel dishModel = new OrderDishViewModel();

            dishModel.DishName = "QWERTY";
            dishModel.Quantity = 1;
            // создать панель элемента
            DishPanel dshPnl = new DishPanel(dishModel, _colWidth);

            // вычислить его высоту
            _canvas.Children.Add(dshPnl);
            double h = 0d;

#if fromActualHeight
            dshPnl.UpdateLayout();
            h = dshPnl.ActualHeight;
#else
            dshPnl.Measure(_sizeMeasure);
            h = dshPnl.DesiredSize.Height;
#endif
            _canvas.Children.Clear();

            // вычислить кол-во элементов на странице, округлить до ближайшего наибольшего
            if (h > 0d)
            {
                _maxDishesCountOnPage = Convert.ToInt32(Math.Ceiling((_pageColsCount * _colHeight) / h));
                AppLib.WriteLogTraceMessage(" - reset order items count to {0}", _maxDishesCountOnPage.ToString());
            }
            else
            {
                AppLib.WriteLogErrorMessage(" - error while measure dish panel, dish height = 0!!!");
            }
        }
コード例 #3
0
ファイル: DishPanel.xaml.cs プロジェクト: AlCher2018/KDS
        //private DishPanel _parentPanel;


        public DishPanel(OrderDishViewModel dishView, double panelWidth)
        {
            this.Width = panelWidth;
            InitializeComponent();

            this.MouseUp += root_MouseUp;
            _dishView     = dishView;
            //_parentPanel = parentPanel;
            grdDishLine.DataContext = _dishView;

            _isDish         = _dishView.ParentUID.IsNull(); // признак блюда
            _isIngrIndepend = (bool)WpfHelper.GetAppGlobalValue("IsIngredientsIndependent", false);

            _dishView.PropertyChanged += DishView_PropertyChanged;

            double fontScale        = (double)WpfHelper.GetAppGlobalValue("AppFontScale", 1.0d);
            double fontSizeDishName = (double)WpfHelper.GetAppGlobalValue("ordPnlDishNameFontSize");

            this.tbDishIndex.FontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlDishIndexFontSize");
            this.tbDishName.FontSize  = fontScale * (_isDish
                ? (double)WpfHelper.GetAppGlobalValue("ordPnlDishNameFontSize")
                : (double)WpfHelper.GetAppGlobalValue("ordPnlIngrNameFontSize"));
            // модификаторы
            if (dishView.Comment.IsNull() == false)
            {
                this.tbComment.Text     = string.Format("\n({0})", dishView.Comment);
                this.tbComment.FontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlDishCommentFontSize");
            }
            this.tbDishQuantity.FontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlDishQuantityFontSize");

            tbDishStatusTS.FontSize   = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlDishTimerFontSize");
            tbDishStatusTS.FontWeight = FontWeights.Bold;

            _padd           = 0.5 * fontSizeDishName; // от размера фонта наименования блюда
            brdMain.Padding = new Thickness(0, 0.5 * _padd, 0, 0.5 * _padd);

            brdTimer.Padding = new Thickness(0, _padd, 0, _padd);
            double timerCornerRadius = 0.015 * this.Width;

            brdTimer.CornerRadius = new CornerRadius(timerCornerRadius, timerCornerRadius, timerCornerRadius, timerCornerRadius);

            // рамка вокруг таймера
            setTimerBorder();

            // кисти и прочее
            //    блюдо
            if (_isDish)
            {
                tbDishName.FontWeight = FontWeights.Bold;
            }
            //    ингредиент
            else
            {
                tbDishName.FontWeight = FontWeights.Bold;
                BrushesPair brPair = BrushHelper.AppBrushes["ingrLineBase"];
                tbDishName.Background = brPair.Background;
                tbDishName.Foreground = brPair.Foreground;
            }
        }
コード例 #4
0
ファイル: App.xaml.cs プロジェクト: AlCher2018/KDS
        // изменение статуса блюда с ингредиентами
        private static bool changeStatusDishWithIngrs(AppDataProvider dataProvider, OrderViewModel orderModel, OrderDishViewModel dishModel, OrderStatusEnum newState)
        {
            // для отмененного блюда статус не менять
            //if (dishModel.Quantity < 0) return false;
            // эта настройка от КДС-сервиса
            bool isConfirmedReadyState = (bool)WpfHelper.GetAppGlobalValue("UseReadyConfirmedState", false);

            bool result = false;

            // изменить статус блюда
            result = dataProvider.SetNewDishStatus(orderModel.Id, dishModel.Id, newState);
            if (result == false)
            {
                return(false);
            }

            // есть ли сгруппированные блюда
            if (dishModel.GroupedDishIds.IsNull() == false)
            {
                int[] ids = dishModel.GroupedDishIds.Split(';').Select(sId => sId.ToInt()).ToArray();
                for (int i = 0; i < ids.Length; i++)
                {
                    result = dataProvider.SetNewDishStatus(orderModel.Id, ids[i], newState);
                    if (result == false)
                    {
                        return(false);
                    }
                }
            }

            // если блюдо, то изменить статус ингредиентов
            if (dishModel.ParentUID.IsNull())
            {
                // изменить статус ингредиентов при условиях:
                // - разрешен на данном КДСе
                // - блюдо переходит в статус Готово, Выдан или ПодтвОтмены
                OrderDishViewModel[] ingrs = orderModel.Dishes.Where(d => (d.ParentUID != null) && (d.ParentUID == dishModel.UID)).ToArray();
                if (ingrs.Length > 0)
                {
                    foreach (OrderDishViewModel ingr in ingrs)
                    {
                        if (DishesFilter.Instance.Checked(ingr) ||
                            (!isConfirmedReadyState && (newState == OrderStatusEnum.Ready)) ||
                            (isConfirmedReadyState && (newState == OrderStatusEnum.ReadyConfirmed)) ||
                            (newState == OrderStatusEnum.Cooking) ||
                            (newState == OrderStatusEnum.Took) ||
                            (newState == OrderStatusEnum.CancelConfirmed))
                        {
                            result = dataProvider.SetNewDishStatus(orderModel.Id, ingr.Id, newState);
                            if (result == false)
                            {
                                return(false);
                            }

                            // если есть сгруппированные ингредиенты
                            if (ingr.GroupedDishIds.IsNull() == false)
                            {
                                int[] ids = ingr.GroupedDishIds.Split(';').Select(sId => sId.ToInt()).ToArray();
                                for (int i = 0; i < ids.Length; i++)
                                {
                                    result = dataProvider.SetNewDishStatus(orderModel.Id, ids[i], newState);
                                    if (result == false)
                                    {
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(true);
        } // method
コード例 #5
0
ファイル: App.xaml.cs プロジェクト: AlCher2018/KDS
        // из обработчика MouseUp объектов DishPanel и OrderPanelHeader
        internal static void OpenStateChangeWindow(OrderViewModel orderModel, OrderDishViewModel dishModel)
        {
            if ((orderModel == null) && (dishModel == null))
            {
                return;
            }

            // из РАЗРЕШЕННЫХ переходов выбрать переходы, ДОСТУПНЫЕ для текущего состояния
            OrderStatusEnum currentState = (OrderStatusEnum)((dishModel == null) ? orderModel.OrderStatusId : dishModel.DishStatusId);
            KDSModeEnum     kdsMode      = KDSModeHelper.CurrentKDSMode; // текущий режим КДС

            List <KeyValuePair <OrderStatusEnum, OrderStatusEnum> > allowedActions = KDSModeHelper.DefinedKDSModes[kdsMode].AllowedActions;

            if (allowedActions != null)
            {
                List <OrderStatusEnum> allowedStates = allowedActions.Where(p => (p.Key == currentState)).Select(p => p.Value).ToList();
                // при клике по ЗАКАЗУ проверить статус отображаемых на данном КДСе позиций
                if (dishModel == null)
                {
                    OrderStatusEnum statAllDishes = (OrderStatusEnum)(int)orderModel.StatusAllowedDishes;  //AppLib.GetStatusAllDishes(orderModel.Dishes);
                    if (orderModel.StatusAllowedDishes != StatusEnum.None)
                    {
                        currentState = statAllDishes;  // текущее состояние - по блюдам!
                        // и, если в разрешенных переходах есть пары с таким ключем, т.е. ВСЕ блюда находятся в состоянии, которое есть в разрешенных переходах
                        var tmpList = allowedActions.Where(s => s.Key == statAllDishes).ToList();
                        // то отображаем эти переходы, а не переходы из состояния заказа!
                        if (tmpList != null)
                        {
                            allowedStates = tmpList.Select(p => p.Value).ToList();
                        }
                    }
                }

                StringBuilder sb = new StringBuilder();
                allowedStates.ForEach(status => sb.Append(status.ToString()));
                AppLib.WriteLogClientAction("Open StateChange win, allowedStates: " + sb.ToString());

                // открываем окно изменения статуса
                if (allowedStates.Count != 0)
                {
                    StateChange win = (StateChange)WpfHelper.GetAppGlobalValue("StateChangeWindow");
                    win.CurrentState  = currentState;
                    win.Order         = orderModel;
                    win.Dish          = dishModel;
                    win.AllowedStates = allowedStates;
                    WpfHelper.SetWinSizeToMainWinSize(win);

                    win.ShowDialog();
                    AppLib.WriteLogClientAction("Close StateChange win, result: {0}", win.CurrentState.ToString());

                    // изменить статус
                    AppDataProvider dataProvider = (AppDataProvider)WpfHelper.GetAppGlobalValue("AppDataProvider");
                    OrderStatusEnum newState     = win.CurrentState;
                    if ((newState != OrderStatusEnum.None) && (newState != currentState) && (dataProvider != null))
                    {
                        string sLogMsg;
                        bool   result   = false;
                        bool   finReady = getFinReadyValue(newState); // флаг терминального окончания готовки

                        #region изменение статуса
                        try
                        {
                            // проверить set-канал
                            if (!dataProvider.EnableSetChannel)
                            {
                                dataProvider.CreateSetChannel();
                            }
                            if (!dataProvider.EnableSetChannel)
                            {
                                dataProvider.CreateSetChannel();
                            }

                            // изменение состояния БЛЮДА и разрешенных ингредиентов (2017-07-26)
                            if (dishModel != null)
                            {
                                sLogMsg = string.Format("orderId {0} (num {1}) for change status dishId {2} ({3}) to {4}", orderModel.Id, orderModel.Number, dishModel.Id, dishModel.DishName, newState.ToString());
                                DateTime dtTmr = DateTime.Now;
                                if (dataProvider.LockOrder(orderModel.Id))
                                {
                                    AppLib.WriteLogClientAction("lock " + sLogMsg + ": success");

                                    OrderStatusEnum preState = dishModel.Status;
                                    // изменить статус блюда с ингредиентами
                                    result = changeStatusDishWithIngrs(dataProvider, orderModel, dishModel, newState);

                                    string sBuf = "delock " + sLogMsg + " - " + (DateTime.Now - dtTmr).ToString();
                                    if (dataProvider.DelockOrder(orderModel.Id))
                                    {
                                        AppLib.WriteLogClientAction(sBuf + ": success");
                                    }
                                    else
                                    {
                                        AppLib.WriteLogClientAction(sBuf + ": NOT success");
                                    }
                                }
                                else
                                {
                                    AppLib.WriteLogClientAction("lock " + sLogMsg + ": NOT success");
                                }
                            }

                            // изменение состояния ЗАКАЗА, то изменяем все равно поблюдно
                            else if (dishModel == null)
                            {
                                sLogMsg = string.Format("orderId {0} (num {1}) for change order status to {2}", orderModel.Id, orderModel.Number, newState.ToString());
                                DateTime dtTmr = DateTime.Now;

                                if (dataProvider.LockOrder(orderModel.Id))
                                {
                                    AppLib.WriteLogClientAction("lock " + sLogMsg + ": success");
                                    List <int> dishIds = new List <int>(); // dishes id has changed
                                    // меняем статус БЛЮД в заказе, если блюдо разрешено для данного КДСа
                                    foreach (OrderDishViewModel item in orderModel.Dishes.Where(d => d.ParentUID.IsNull()))
                                    {
                                        if (DishesFilter.Instance.Checked(item))
                                        {
                                            // изменить статус блюда с ингредиентами
                                            result = changeStatusDishWithIngrs(dataProvider, orderModel, item, newState);
                                            if (result)
                                            {
                                                dishIds.Add(item.Id);
                                            }
                                        }
                                    }  // foreach

                                    string sBuf = "delock " + sLogMsg + " - " + (DateTime.Now - dtTmr).ToString();
                                    if (dataProvider.DelockOrder(orderModel.Id))
                                    {
                                        AppLib.WriteLogClientAction(sBuf + ": success");
                                    }
                                    else
                                    {
                                        AppLib.WriteLogClientAction(sBuf + ": NOT success");
                                    }
                                }
                                else
                                {
                                    AppLib.WriteLogClientAction("lock " + sLogMsg + ": NOT success");
                                }
                            }  // order status
                        }
                        catch (Exception ex)
                        {
                            AppLib.WriteLogErrorMessage(ex.ToString());
                            MessageBox.Show("Ошибка изменения состояния. Попробуйте еще раз.", "Ошибка записи нового состояния", MessageBoxButton.OK);
                        }
                        #endregion
                    }
                } // if (allowedStates.Count != 0)
            }     // if (allowedActions != null)
        }         // method
コード例 #6
0
        // CTOR
        public DishPanel(OrderDishViewModel dishView, double panelWidth)
        {
            this.Width = panelWidth;
            this.SnapsToDevicePixels = true;
            this.BorderBrush         = Brushes.DarkBlue;
            this.BorderThickness     = new System.Windows.Thickness(1, 0, 1, 1);
            this.MouseDown          += root_MouseDown;
            this.MouseUp            += root_MouseUp;

            double fontScale        = (double)WpfHelper.GetAppGlobalValue("AppFontScale", 1.0d);
            double fontSizeDishName = (double)WpfHelper.GetAppGlobalValue("ordPnlDishNameFontSize");

            _padd        = 0.5 * fontSizeDishName; // от размера фонта наименования блюда
            this.Padding = new Thickness(0, 0.5 * _padd, 0, 0.5 * _padd);

            _dishView                  = dishView;
            _isDish                    = _dishView.ParentUID.IsNull(); // признак блюда
            _isIngrIndepend            = (bool)WpfHelper.GetAppGlobalValue("IsIngredientsIndependent", false);
            _dishView.PropertyChanged += DishView_PropertyChanged;

            Grid grdDishLine = new Grid();

            this.Child = grdDishLine;
            // содержание грида - 4 строки
            // 0. № п/п
            grdDishLine.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(8d, GridUnitType.Star)
            });
            // 1. наименование блюда
            grdDishLine.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(43d, GridUnitType.Star)
            });
            // 2. количество
            grdDishLine.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(15d, GridUnitType.Star)
            });
            // 3. таймер состояния
            grdDishLine.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(34d, GridUnitType.Star)
            });

            // индекс блюда
            TextBlock tbDishIndex = new TextBlock()
            {
                TextAlignment     = TextAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Text = (_dishView.Index == 0) ? null : _dishView.Index.ToString()
            };

            tbDishIndex.SetValue(Grid.ColumnProperty, 0);
            tbDishIndex.FontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlDishIndexFontSize");
            grdDishLine.Children.Add(tbDishIndex);

            // имя блюда: текст и комментарий
            TextBlock tbDish = new TextBlock()
            {
                TextAlignment     = TextAlignment.Left,
                VerticalAlignment = VerticalAlignment.Center,
                TextWrapping      = TextWrapping.Wrap
            };

            tbDish.SetValue(Grid.ColumnProperty, 1);
            Run tbDishName = new Run()
            {
                FontWeight = FontWeights.Bold,
                Text       = _dishView.DishName
            };
            //   блюдо
            BrushesPair brPair;

            if (_isDish)
            {
                tbDishName.FontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlDishNameFontSize");
                brPair = BrushHelper.AppBrushes["dishLineBase"];
            }
            //    ингредиент
            else
            {
                tbDishName.FontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlIngrNameFontSize");
                brPair = BrushHelper.AppBrushes["ingrLineBase"];
            }
            if (brPair != null)
            {
                this.Background       = brPair.Background;
                tbDishName.Foreground = brPair.Foreground;
            }
            tbDish.Inlines.Add(tbDishName);
            if (dishView.Comment.IsNull() == false)
            {
                Run tbComment = new Run()
                {
                    FontWeight = FontWeights.Normal,
                    FontStyle  = FontStyles.Italic,
                    Text       = Environment.NewLine + string.Format("{0}", _dishView.Comment)
                };
                if (brPair != null)
                {
                    tbComment.Foreground = brPair.Foreground;
                }
                tbComment.FontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlDishCommentFontSize");
                tbDish.Inlines.Add(tbComment);
            }
            grdDishLine.Children.Add(tbDish);

            // количество
            TextBlock tbDishQuantity = new TextBlock()
            {
                TextAlignment = TextAlignment.Center, VerticalAlignment = VerticalAlignment.Center,
                FontWeight    = FontWeights.Bold,
                TextWrapping  = TextWrapping.Wrap
            };
            Binding bind = new Binding("Quantity")
            {
                Source = _dishView, Converter = new DishQuantityToStringConverter()
            };

            tbDishQuantity.SetBinding(TextBlock.TextProperty, bind);
            tbDishQuantity.SetValue(Grid.ColumnProperty, 2);
            tbDishQuantity.Margin   = new Thickness(0, 0, 3, 0);
            tbDishQuantity.FontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlDishQuantityFontSize");
            grdDishLine.Children.Add(tbDishQuantity);

            // рамка таймера
            brdTimer = new Border();
            brdTimer.SetValue(Grid.ColumnProperty, 3);
            brdTimer.Padding = new Thickness(0, _padd, 0, _padd);
            brdTimer.Margin  = new Thickness(0, 0, 3, 0);
            double timerCornerRadius = 0.015 * this.Width;

            brdTimer.CornerRadius = new CornerRadius(timerCornerRadius, timerCornerRadius, timerCornerRadius, timerCornerRadius);
            // текстовый блок таймера
            tbDishStatusTS = new TextBlock()
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                FontWeight          = FontWeights.Bold,
                TextWrapping        = TextWrapping.Wrap
            };
            bind = new Binding("ViewTimerString")
            {
                Source = _dishView
            };
            tbDishStatusTS.SetBinding(TextBlock.TextProperty, bind);
            tbDishStatusTS.FontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlDishTimerFontSize");
            brdTimer.Child          = tbDishStatusTS;

            grdDishLine.Children.Add(brdTimer);

            // рамка вокруг таймера
            setTimerBorder();
        }