示例#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;
            }
        }
        //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));
        }
示例#3
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;
            }
        }