Example #1
0
 private void SaveFood()
 {
     if (ValidateControl())
     {
         Food f = new Food()
         {
             FoodID   = foodController.GetNextId(),
             Name     = txtFoodName.Text,
             Amount   = double.Parse(txtAmount.Text),
             Calories = double.Parse(txtCalories.Text),
             Carbs    = double.Parse(txtCarbs.Text),
             Protein  = double.Parse(txtProtein.Text),
             Fat      = double.Parse(txtFat.Text)
         };
         f.FoodVitamins = GetAllVitamins(f);
         if (foodController.AddFood(f) && foodController.AddFoodVitamin(f.FoodVitamins))
         {
             MessageBoxInformationType(Resources.FoodAddedWithSuccess);
         }
     }
 }