Exemplo n.º 1
0
        public override void OnClickOK(object sender, EventArgs e)
        {
            CP_Popup_Sure popup = new CP_Popup_Sure();

            popup.SetAsEdit(CP_Popop_EditMenu_txtName.Text);
            popup.ShowDialog();

            if (!(popup.DialogResult == DialogResult.OK))
            {
                DialogResult = DialogResult.Cancel;
                Close();
            }

            Dish_Service dishService = new Dish_Service();

            //Store the values of all of the inputs
            string       name        = CP_Popop_EditMenu_txtName.Text;
            string       description = CP_Popop_EditMenu_txtDescription.Text;
            string       ingredients = CP_Popop_EditMenu_txtIngredients.Text;
            DishCategory category;

            bool priceParsed = double.TryParse(CP_Popop_EditMenu_txtPrice.Text, out double price);
            bool stockParsed = int.TryParse(CP_Popup_EditMenu_txtStock.Text, out int stock);

            if (!(priceParsed && stockParsed))
            {
                Close();
            }

            if (CP_PopopEditEmployee_rbtnVoor.Checked)
            {
                category = DishCategory.Voorgerechten;
            }
            else if (CP_PopopEditEmployee_rbtnTussen.Checked)
            {
                category = DishCategory.Tussengerechten;
            }
            else if (CP_PopopEditEmployee_rbtnHoofd.Checked)
            {
                category = DishCategory.Hoofdgerechten;
            }
            else
            {
                category = DishCategory.Nagerechten;
            }

            //Add a new dish to the system
            try
            {
                dishService.ModifyDish(new Dish(id, name, description, ingredients, price, stock, category));
            }
            catch (Exception ex)
            {
                ErrorHandler.Instance.HandleError("Gerecht met id " + id + " kon niet aangepast worden!", "Gerecht niet aangepast", ex);

                //Tell the ControlPanel form that the action didn't succeed
                DialogResult = DialogResult.Cancel;
            }
        }
Exemplo n.º 2
0
        public override void OnClickOK(object sender, EventArgs e)
        {
            //Check if the user is sure
            CP_Popup_Sure popup = new CP_Popup_Sure();

            popup.SetAsChangeStock(item.Name);
            popup.ShowDialog();

            if (!(popup.DialogResult == DialogResult.OK))
            {
                DialogResult = DialogResult.Cancel;
                Close();
            }

            //Store the value of the input
            bool stockParsed = int.TryParse(CP_Popup_ChangeStock_txtStock.Text, out int stock);

            //Close the form if the parse fails
            if (!stockParsed)
            {
                Close();
            }

            //Check whether to use the Dish or the drink Service
            if (item.GetType() == typeof(Dish))
            {
                Dish_Service dishService = new Dish_Service();

                //Modify the stock
                try
                {
                    dishService.ModifyStock(item.Id, stock);
                }
                catch (Exception ex)
                {
                    ErrorHandler.Instance.HandleError("Voorraad van " + item.Id + " kon niet aangepast worden!", "Voorraad niet aangepast", ex);

                    //Tell the ControlPanel form that the action didn't succeed
                    DialogResult = DialogResult.Cancel;
                }
            }
            else
            {
                Drink_Service drinkService = new Drink_Service();

                //Modify the stock
                try
                {
                    drinkService.ModifyStock(item.Id, stock);
                }
                catch (Exception ex)
                {
                    ErrorHandler.Instance.HandleError("Voorraad van " + item.Id + " kon niet aangepast worden!", "Voorraad niet aangepast", ex);

                    //Tell the ControlPanel form that the action didn't succeed
                    DialogResult = DialogResult.Cancel;
                }
            }
        }
Exemplo n.º 3
0
        private void bestelBtn_Click(object sender, EventArgs e)
        {
            orderService     = new Order_Service();
            tableService     = new Table_Service();
            order.EmployeeId = employee.Id;
            billService      = new Bill_Service();
            try
            {
                bill = billService.GetBillByTableId(tafel.Number);
            }
            catch (Exception d)
            {
                orders = new List <Order>();
                bill   = new Bill(DateTime.Now, tafel, orders, employee, false);
                billService.AddBill(bill);
                MessageBox.Show("Bestelling is geplaatst.", "Attentie", MessageBoxButtons.OK, MessageBoxIcon.Information);
                orderService.AddOrderWhereBillIdIs(order, bill.Id);
                tafel.Occupied = true;
                tableService.ModifyTable(tafel);
                return;
            }

            if (bill.Payed == false)
            {
                orderService.AddOrderWhereBillIdIs(order, bill.Id);
                MessageBox.Show("Bestelling is geplaatst.", "Attentie", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                orders = new List <Order>();
                bill   = new Bill(DateTime.Now, tafel, orders, employee, false);
                billService.AddBill(bill);
                MessageBox.Show("Bestelling is geplaatst.", "Attentie", MessageBoxButtons.OK, MessageBoxIcon.Information);
                orderService.AddOrderWhereBillIdIs(order, bill.Id);
                tafel.Occupied = true;
                tableService.ModifyTable(tafel);
            }

            foreach (Dish dish in order.Dishes)
            {
                dishService = new Dish_Service();
                dishService.ModifyStock(dish.Id, dish.Stock - 1);
            }

            foreach (Drink drink in order.Drinks)
            {
                drinkService = new Drink_Service();
                drinkService.ModifyStock(drink.Id, drink.Stock - 1);
            }

            order = new Order();
        }