/// <summary>
        /// Search button , find specific dish with some filter
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            Order          test  = (Order)OrderListCombobox.SelectedValue;
            CasheRoutLevel test2 = bl.FindCashRoutLevelByOrderNumber(test.OrderNumber);

            order.OrderNumber = test.OrderNumber;
            // search by name
            if (PriceTextBox.Text == "" && Nametextbox.Text != "")
            {
                // if we don't have matching , reinitialise the dish list
                if (bl.ListOfDish(x => x.Request == test2 && x.Name.Contains(Nametextbox.Text)).Count() == 0)
                {
                    MessageBox.Show("No matching found");
                    Nametextbox.Text = "";
                    this.ListOfDishCombobox.ItemsSource = bl.ByCashRoutonly(test2);
                }
                else
                {
                    this.ListOfDishCombobox.ItemsSource = bl.ListOfDish(x => x.Name.Contains(Nametextbox.Text) && x.Request == test2);
                }
            }
            // search by price
            else if (PriceTextBox.Text != "" && Nametextbox.Text == "")
            {
                // if we don't have matching , reinitialise the dish list
                if (bl.ListOfDish(x => x.PriceOfDish <= int.Parse(PriceTextBox.Text) && x.Request == test2).Count() == 0)
                {
                    MessageBox.Show("No matching found");
                    PriceTextBox.Text = "";
                    this.ListOfDishCombobox.ItemsSource = bl.ByCashRoutonly(test2);
                }
                else
                {
                    // searching
                    this.ListOfDishCombobox.ItemsSource = bl.ListOfDish(x => x.PriceOfDish <= int.Parse(PriceTextBox.Text) && x.Request == test2);
                }
            }
            // search by price and name
            else if (PriceTextBox.Text != "" && Nametextbox.Text != "")
            {
                // if we don't have matching , reinitialise the dish list
                if (bl.ListOfDish(x => x.PriceOfDish <= int.Parse(PriceTextBox.Text) && x.Name.Contains(Nametextbox.Text) && x.Request == test2).Count() == 0)
                {
                    MessageBox.Show("No matching found");
                    PriceTextBox.Text = "";
                    Nametextbox.Text  = "";
                    this.ListOfDishCombobox.ItemsSource = bl.ByCashRoutonly(test2);
                }
                else
                {
                    // searching
                    this.ListOfDishCombobox.ItemsSource = bl.ListOfDish(x => x.PriceOfDish <= int.Parse(PriceTextBox.Text) && x.Name.Contains(Nametextbox.Text) && x.Request == test2);
                }
            }
            else
            {
                // if we don't have nothing
                this.ListOfDishCombobox.ItemsSource = bl.ByCashRoutonly(test2);
            }
        }
        /// <summary>
        /// Delete an ordered dish
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                /* Message : i know this isn't the better way if we made data binding but i have a problem with datacontext
                 *  he just work a time after that all not working so i was forced to use this ...
                 */
                Order          test  = (Order)OrderListCombobox.SelectedValue;
                CasheRoutLevel test2 = bl.FindCashRoutLevelByOrderNumber(test.OrderNumber);
                order.OrderNumber   = test.OrderNumber;
                order.QuantityOrder = int.Parse(quantityTextBox.Text);
                order.DishID        = int.Parse(menuIDTextBox.Text);

                // delete the dish
                bl.DeleteSpecificOrdered(order.OrderNumber, order.DishID, order.QuantityOrder);
                // refreshing the list of dish
                ListOfDishCombobox.ItemsSource = bl.ListOfDish(x => x.Request == test2);
                // refreshing the price
                TotalPriceLabel.Content = bl.TotalPrice(order.OrderNumber);
                // reinitialize data
                order = new Ordered_Dish();
                this.NextButton.IsEnabled = true;
                this.menuIDTextBox.Text   = this.quantityTextBox.Text = "0";
                // refreshing the orderedllist
                this.OrderedCombobox.ItemsSource = bl.ListOfOrdered(x => x.OrderNumber == ((Order)OrderListCombobox.SelectedValue).OrderNumber);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #3
0
        /// <summary>
        /// Checking the ID
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="choice"></param>
        /// <returns></returns>
        public bool IsExistingID(int ID, CasheRoutLevel choice)
        {
            // searching
            Dish tmp = ListOfDish(d => d.MenuID == ID && d.Request == choice).FirstOrDefault();

            if (tmp == null)
            {
                throw new Exception("can't find dish for this id");
            }
            return(true);
        }
        /// <summary>
        /// Add an ordereddish
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddOrderedButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                /* Message : i know this isn't useful if we made data binding but i have a problem with datacontext
                 *  he just work a time after that all not working so i was forced to use this ...
                 */
                order.DishID = int.Parse(menuIDTextBox.Text);
                Order          test  = (Order)OrderListCombobox.SelectedValue;
                CasheRoutLevel test2 = bl.FindCashRoutLevelByOrderNumber(test.OrderNumber);
                order.OrderNumber   = test.OrderNumber;
                order.QuantityOrder = int.Parse(quantityTextBox.Text);

                // checking is the id exist
                if (bl.IsExistingID(order.DishID, bl.FindCashRoutLevelByOrderNumber(order.OrderNumber)))
                {
                    // setting price
                    order.Price = bl.FindPriceByID(order.DishID);
                    order.name  = bl.NameByID(order.DishID);
                    bl.IsExecissivePrice(bl.TotalPrice(order.OrderNumber) + order.Price * order.QuantityOrder, 700);
                    // adding the ordered dish and trying to reduce the quantity ordered
                    bl.AddOrdered(order);
                    // refreshing the price
                    TotalPriceLabel.Content = bl.TotalPrice(order.OrderNumber).ToString();
                    // refreshing the ListOfDish with new quantity
                    ListOfDishCombobox.ItemsSource = bl.ListOfDish(x => x.Request == test2);
                    // reinitialise data
                    order = new Ordered_Dish();
                    this.NextButton.IsEnabled        = true;
                    this.menuIDTextBox.Text          = this.quantityTextBox.Text = "0";
                    this.OrderedCombobox.ItemsSource = bl.ListOfOrdered(x => x.OrderNumber == ((Order)OrderListCombobox.SelectedValue).OrderNumber);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #5
0
 /// <summary>
 /// Getting all the dish with a specific cashrout level + XML
 /// </summary>
 /// <param name="Specific"></param>
 /// <returns></returns>
 public IEnumerable <Dish> ByCashRoutonly(CasheRoutLevel Specific)
 {
     return(obj.ListOfDish(item => item.Request == Specific));
 }
Example #6
0
 /// <summary>
 /// Getting all the branch with a specific cashrout level
 /// </summary>
 /// <param name="Specific"></param>
 /// <returns></returns>
 public IEnumerable <Branch> CheckLevelOfCahrout(CasheRoutLevel Specific)
 {
     return(ListOfBranch(item => item.CashroutLevel == Specific));
 }