コード例 #1
0
        public CreateNewOrderViewModel(CreateNewOrder createNewOrder)
        {
            this.createNewOrder = createNewOrder;

            Service s = new Service();

            AllMenuList      = s.GetAllMenu().ToList();
            AllOrderItemList = s.GetAllOrderItem().ToList();
            AllOrderList     = s.GetAllOrder().ToList();

            try
            {
                using (PizzaRestoranEntities context = new PizzaRestoranEntities())
                {
                    tblOrder tblOrder = new tblOrder();
                    DateTime dateTime = DateTime.Now;

                    tblOrder.DateTimeOrder = dateTime;
                    tblOrder.Guest         = LoggedGuest.id;
                    tblOrder.OrderStatus   = 1;
                    tblOrder.TotalPrice    = 0;
                    tblOrder.Archived      = 0;

                    context.tblOrders.Add(tblOrder);
                    context.SaveChanges();
                }
                AllOrderList = s.GetAllOrder().ToList();

                OrderList = s.GetOrder(AllOrderList.LastOrDefault().OrderID).ToList();
            }
            catch (Exception)
            {
            }
        }
コード例 #2
0
        /// <summary>
        /// Method for deleting the selected item from the order
        /// </summary>
        public void DeleteExecute()
        {
            try
            {
                MessageBoxResult dialogDelete = Xceed.Wpf.Toolkit.MessageBox.Show($"Do you want to exclude the item from the order?\n\nItem: {order.Expr2} ({order.Expr3})", "Delete item", MessageBoxButton.YesNo, MessageBoxImage.Warning);

                if (dialogDelete == MessageBoxResult.Yes)
                {
                    if (Order != null)
                    {
                        Service s = new Service();

                        int  orderItemID = Order.OrderItemID;
                        bool isOrderItem = s.IsOrderID(orderItemID);
                        if (isOrderItem == true)
                        {
                            s.DeleteOrderItem(orderItemID);
                            OrderList = s.GetOrder(AllOrderList.LastOrDefault().OrderID).ToList();

                            OrderList = s.GetOrder(AllOrderList.LastOrDefault().OrderID).ToList();
                            TotalSum  = 0;
                            if (OrderList.Count == 0)
                            {
                                createNewOrder.msgNoItems.Visibility       = Visibility.Visible;
                                createNewOrder.gridOrderItem.Visibility    = Visibility.Collapsed;
                                createNewOrder.btnPlaceOrderNow.Visibility = Visibility.Collapsed;
                                createNewOrder.txtTotalSum.Text            = TotalSum.ToString() + ",00";
                                createNewOrder.txtTotalSumBottom.Text      = TotalSum.ToString() + ",00 RSD";
                            }
                            else
                            {
                                createNewOrder.msgNoItems.Visibility       = Visibility.Collapsed;
                                createNewOrder.gridOrderItem.Visibility    = Visibility.Visible;
                                createNewOrder.btnPlaceOrderNow.Visibility = Visibility.Visible;
                                foreach (var item in OrderList)
                                {
                                    TotalSum += item.OrderSum;
                                    createNewOrder.txtTotalSum.Text       = TotalSum.ToString() + ",00";
                                    createNewOrder.txtTotalSumBottom.Text = TotalSum.ToString() + ",00 RSD";
                                }
                            }
                            CreateNewOrder.counter             = CreateNewOrder.counter - 1;
                            createNewOrder.CountingBadge.Badge = CreateNewOrder.counter;
                        }
                        else
                        {
                            MessageBoxResult dialog = Xceed.Wpf.Toolkit.MessageBox.Show("Unable to delete...", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #3
0
        /// <summary>
        /// Add the selected menu item to the order
        /// </summary>
        private void AddItemExecute()
        {
            try
            {
                Service      s            = new Service();
                AddOrderItem addOrderItem = new AddOrderItem();
                if (AllMenu != null)
                {
                    List <tblOrder> tblOrders = s.GetAllOrder();

                    addOrderItem.txtName.Text  = AllMenu.ProductName;
                    addOrderItem.txtOrder.Text = Convert.ToString(tblOrders.LastOrDefault().OrderID);
                    addOrderItem.txtPrice.Text = Convert.ToString(AllMenu.PriceProduct);

                    addOrderItem.ShowDialog();
                    if ((addOrderItem.DataContext as AddOrderItemViewModel).IsUpdateItem == true)
                    {
                        OrderList = s.GetOrder(AllOrderList.LastOrDefault().OrderID).ToList();
                        TotalSum  = 0;
                        if (OrderList.Count == 0)
                        {
                            createNewOrder.msgNoItems.Visibility       = Visibility.Visible;
                            createNewOrder.gridOrderItem.Visibility    = Visibility.Collapsed;
                            createNewOrder.btnPlaceOrderNow.Visibility = Visibility.Collapsed;
                            createNewOrder.txtTotalSum.Text            = TotalSum.ToString() + ",00";
                            createNewOrder.txtTotalSumBottom.Text      = TotalSum.ToString() + ",00 RSD";
                        }
                        else
                        {
                            createNewOrder.msgNoItems.Visibility       = Visibility.Collapsed;
                            createNewOrder.gridOrderItem.Visibility    = Visibility.Visible;
                            createNewOrder.btnPlaceOrderNow.Visibility = Visibility.Visible;
                            foreach (var item in OrderList)
                            {
                                TotalSum += item.OrderSum;
                                createNewOrder.txtTotalSum.Text       = TotalSum.ToString() + ",00";
                                createNewOrder.txtTotalSumBottom.Text = TotalSum.ToString() + ",00 RSD";
                            }
                        }
                        CreateNewOrder.counter             = CreateNewOrder.counter + 1;
                        createNewOrder.CountingBadge.Badge = CreateNewOrder.counter;
                    }
                }
                createNewOrder.DataGridAllMenu.UnselectAll();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }