Example #1
0
        private void addSingleMainMealToDataGrid(MainMeal mainMeal)
        {
            SecondMeal secondMeal = new SecondMeal();

            secondMeal.price    = 0;
            secondMeal.mealName = "ohne";
            MealCombination mc = MealCombination.getMealCombination(mainMeal, secondMeal);

            updateTotalPriceTxtBox(mainMeal.price);
            addMealCombosToDataGrid(mc);
        }
 private void deleteSecondMeal(DataGrid mealList)
 {
     if (mealList.SelectedItem != null && mealList.SelectedIndex >= 0)
     {
         SecondMeal meal = mealList.SelectedItem as SecondMeal;
         secondMeals.RemoveAt(secondMeals.FindIndex(x => x.guid == meal.guid));
         CSVHandler.deleteRow(meal);
         CSVHandler.deleteComboRows(meal);
         secondMealList.Items.Refresh();
     }
 }
        // ##############################################################
        //                      Second Meal:
        // ##############################################################

        private void btnSafeNewSecondMeal_Click(object sender, RoutedEventArgs e)
        {
            SecondMeal meal = getSecondMealFromTextBox();

            if (meal != null)
            {
                clearAllSecondMealTextBoxes();
                addSecondMealToDataGrid(meal);
                generateMealCombos(meal);
                CSVHandler.addToCSV(meal);
            }
        }
        private void generateMealCombos(SecondMeal secondMeal)
        {
            List <IMeal>           mainMeals  = getMainMealsFromCSV();
            List <MealCombination> mealCombos = new List <MealCombination>();
            MealCombination        mealCombo;

            foreach (MainMeal mainMeal in mainMeals)
            {
                mealCombo = MealCombination.getMealCombination(mainMeal, secondMeal);
                mealCombos.Add(mealCombo);
            }
            CSVHandler.addToCSV(mealCombos);
        }
 private SecondMeal getSecondMealFromTextBox()
 {
     try
     {
         SecondMeal meal = new SecondMeal();
         meal.mealName = txtBoxSecondMeal.Text;
         meal.price    = Convert.ToDecimal(txtBoxSecondMealSinglePrice.Text);
         return(meal);
     }
     catch (Exception ex)
     {
         ExceptionHandler.Log(ex);
         return(null);
     }
 }