Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
0
        //Clear the stocks of an item
        private void CP_Voorraad_btnEmptyItem_Click(object sender, EventArgs e)
        {
            //Make sure a item is selected
            if (CP_Voorraad_listView.SelectedItems.Count == 0)
            {
                MessageBox.Show("U moet een item selecteren", "Selecteer 1 item", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //Verify if the user really wants to clear these stocks
            CP_Popup_Sure popup = new CP_Popup_Sure();

            if (CP_Voorraad_listView.SelectedItems.Count > 1)
            {
                popup.SetAsEmptyStock(CP_Voorraad_listView.SelectedItems.Count);
            }
            else
            {
                if (((Item)CP_Voorraad_listView.SelectedItems[0].Tag).Stock == 0)
                {
                    return;
                }

                popup.SetAsEmptyStock(((Item)CP_Voorraad_listView.SelectedItems[0].Tag).Name);
            }

            //Show the popup and check if Ok is clickec
            popup.ShowDialog();

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

            //Empty all selected stocks of the shown menu
            if (shownMenu == MenuType.Drinksmenu)
            {
                foreach (ListViewItem item in CP_Voorraad_listView.SelectedItems)
                {
                    drinkService.EmptyStock(((Drink)item.Tag).Id);
                }
            }
            else
            {
                foreach (ListViewItem item in CP_Voorraad_listView.SelectedItems)
                {
                    dishService.EmptyStock(((Dish)item.Tag).Id);
                }
            }

            //Reload the voorraad list and give the user feedback
            new CP_Feedback("Voorraad(en) succesvol geleegd", 2500).Show();
            LoadListViewVoorraad();
        }
        //When the user presses OK, modify the employee
        public override void OnClickOK(object sender, EventArgs e)
        {
            //Check that the user really wants to edit
            CP_Popup_Sure popup = new CP_Popup_Sure();

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

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

            //Edit the employee. Use the values from the input boxes
            Employee_Service employeeService = new Employee_Service();

            string       firstName  = CP_PopopEditEmployee_txtFirstName.Text;
            string       lastName   = CP_PopupEditEmployee_txtLastName.Text;
            DateTime     birthDate  = CP_PopopEditEmployee_dtpBirthdate.Value;
            DateTime     employment = CP_PopopEditEmployee_dtpEmployment.Value;
            Gender       gender;
            string       password = CP_PopopEditEmployee_txtPassword.Text;
            EmployeeType employeeType;

            if (CP_PopopEditEmployee_rbtnMale.Checked)
            {
                gender = Gender.Male;
            }
            else
            {
                gender = Gender.Female;
            }

            if (CP_PopupEditEmployee_rbtnWaiter.Checked)
            {
                employeeType = EmployeeType.Waiter;
            }
            else if (CP_PopupEditEmployee_rbtnOwner.Checked)
            {
                employeeType = EmployeeType.Owner;
            }
            else if (CP_PopupEditEmployee_rbtnBartender.Checked)
            {
                employeeType = EmployeeType.Bartender;
            }
            else
            {
                employeeType = EmployeeType.Chef;
            }

            employeeService.ModifyEmployee(new Employee(id, firstName, lastName, birthDate, employment, gender, password, employeeType));
        }
Ejemplo n.º 5
0
        public override void OnClickOK(object sender, EventArgs e)
        {
            CP_Popup_Sure popup = new CP_Popup_Sure();

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

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

            Drink_Service drinkService = new Drink_Service();

            //Store the values of all of the inputs
            string name = CP_Popop_EditDrinksMenu_txtName.Text;
            bool   alcoholic;

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

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

            if (CP_Popup_EditDrinksMenu_cboxAlcoholic.Checked)
            {
                alcoholic = true;
            }
            else
            {
                alcoholic = false;
            }


            //Add a new dish to the system
            try
            {
                drinkService.ModifyDrink(new Drink(id, name, alcoholic, price, stock));
            }
            catch (Exception ex)
            {
                ErrorHandler.Instance.HandleError("Drank met id " + id + " kon niet aangepast worden!", "Gerecht niet aangepast", ex);

                //Tell the ControlPanel form that the action didn't succeed
                DialogResult = DialogResult.Cancel;
            }
        }
Ejemplo n.º 6
0
        //Remove the selected employee(s)
        private void CP_Medewerkers_btnVerwijderen_Click(object sender, EventArgs e)
        {
            //Make sure an employee is selected
            if (CP_Medewerkers_listView.SelectedItems.Count == 0)
            {
                MessageBox.Show("U moet een medewerker selecteren", "Selecteer 1 medewerker", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //Verify if the user really wants to remove these items
            CP_Popup_Sure popup = new CP_Popup_Sure();

            if (CP_Medewerkers_listView.SelectedItems.Count > 1)
            {
                popup.SetAsRemoveEmployee(CP_Medewerkers_listView.SelectedItems.Count);
            }
            else
            {
                popup.SetAsRemoveEmployee(((Employee)CP_Medewerkers_listView.SelectedItems[0].Tag).FirstName);
            }

            popup.ShowDialog();

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

            //Remove all selected employee's
            foreach (ListViewItem item in CP_Medewerkers_listView.SelectedItems)
            {
                bool success = int.TryParse(item.Text, out int id);
                if (success)
                {
                    employeeService.DeleteEmployee(id);
                }
            }

            //Show the succesfull bar
            new CP_Feedback("Medewerker(s) succesvol verwijderd", 2500).Show();

            //Reload the employee list
            LoadEmployeeList();
        }
Ejemplo n.º 7
0
        //Remove 1 or more items from the menu
        private void CP_Menukaarten_btnDeleteItem_Click(object sender, EventArgs e)
        {
            //Make sure a single item is selected
            if (CP_Menukaarten_listView.SelectedItems.Count == 0)
            {
                MessageBox.Show("U moet een item selecteren", "Selecteer 1 item", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //Verify if the user really wants to remove these items
            CP_Popup_Sure popup = new CP_Popup_Sure();

            if (CP_Menukaarten_listView.SelectedItems.Count > 1)
            {
                if (shownMenu == MenuType.Drinksmenu)
                {
                    popup.SetAsRemoveDrink(CP_Menukaarten_listView.SelectedItems.Count);
                }
                else
                {
                    popup.SetAsRemoveDish(CP_Menukaarten_listView.SelectedItems.Count);
                }
            }
            else
            {
                if (shownMenu == MenuType.Drinksmenu)
                {
                    popup.SetAsRemoveDrink(((Drink)CP_Menukaarten_listView.SelectedItems[0].Tag).Name);
                }
                else
                {
                    popup.SetAsRemoveDish(((Dish)CP_Menukaarten_listView.SelectedItems[0].Tag).Name);
                }
            }

            popup.ShowDialog();

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

            //Remove all selected items
            if (shownMenu == MenuType.Drinksmenu)
            {
                foreach (ListViewItem item in CP_Menukaarten_listView.SelectedItems)
                {
                    drinkService.RemoveDrink(((Drink)item.Tag).Id);
                }
            }
            else
            {
                foreach (ListViewItem item in CP_Menukaarten_listView.SelectedItems)
                {
                    dishService.RemoveDish(((Dish)item.Tag).Id);
                }
            }

            //Reload the menu list
            new CP_Feedback("Item(s) succesvol verwijderd", 2500).Show();
            LoadListViewMenus();
        }