Example #1
0
 public static List <MealCombination> readCombos(string type)
 {
     try
     {
         writeFileNameToProperty(type);
         using (var reader = new StreamReader(_filePath + _fileName))
             using (var csv = new CsvReader(reader))
             {
                 var records = new List <MealCombination>();
                 csv.Read();
                 csv.ReadHeader();
                 while (csv.Read())
                 {
                     var record = new MealCombination();
                     record.guid           = csv.GetField <Guid>("guid");
                     record.mainMealGUID   = csv.GetField <Guid>("mainMealGUID");
                     record.secondMealGUID = csv.GetField <Guid>("secondMealGUID");
                     record.mainMealName   = csv.GetField <string>("mainMealName");
                     record.secondMealName = csv.GetField <string>("secondMealName");
                     record.totalPrice     = csv.GetField <decimal>("totalPrice");
                     records.Add(record);
                 }
                 return(records);
             }
     }
     catch (Exception ex)
     {
         ExceptionHandler.Log(ex);
         return(new List <MealCombination>());
     }
 }
Example #2
0
        protected void mainMealButton_click(object sender, EventArgs e)
        {
            Button button   = sender as Button;
            var    mainMeal = button.Tag as MainMeal;

            if (mainMeal.insertable)
            {
                secondMealChooser smc = new secondMealChooser(mainMeal);
                smc.Owner = this;
                if (smc.ShowDialog() == false)
                {
                    MealCombination combo = smc._mealCombo;
                    if (combo != null)
                    {
                        updateTotalPriceTxtBox(combo.totalPrice);
                        addMealCombosToDataGrid(combo);
                    }
                }
            }
            else
            {
                addSingleMainMealToDataGrid(mainMeal);
            }
            bntPrint.IsEnabled = true;
        }
        protected void secondMealButton_click(object sender, EventArgs e)
        {
            Button button = sender as Button;

            _mealCombo = button.Tag as MealCombination;
            this.Close();
        }
Example #4
0
        public static void updateCSV(MealCombination combo)
        {
            List <MealCombination> mealCombos = readCombos("BonDrucker.MealCombination");
            // Suche Index des zu aktualisierenden Element ueber die GUID
            int index = mealCombos.FindIndex(x => x.guid == combo.guid);

            mealCombos[index] = combo;
            write(mealCombos);
        }
Example #5
0
        public static void addToCSV(MealCombination mealCombo)
        {
            string type = mealCombo.GetType().ToString();

            writeFileNameToProperty(type);
            var mealList = readCombos(type);

            mealList.Add(mealCombo);
            write(mealList);
        }
Example #6
0
 static public void Print(List <MealCombination> mealCombos)
 {
     foreach (var combo in mealCombos)
     {
         var doc = new PrintDocument();
         _combo         = combo;
         doc.PrintPage += new PrintPageEventHandler(ProvideContent);
         doc.Print();
     }
 }
Example #7
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);
        }
        // TODO: Die bestehenden MealCombos werden so immer überschrieben -> Preise weg -.-
        private void generateMealCombos(MainMeal mainMeal)
        {
            List <IMeal>           secondMeals = getSecondMealsFromCSV();
            List <MealCombination> mealCombos  = new List <MealCombination>();
            MealCombination        mealCombo;

            foreach (SecondMeal secondMeal in secondMeals)
            {
                mealCombo = MealCombination.getMealCombination(mainMeal, secondMeal);
                mealCombos.Add(mealCombo);
            }
            CSVHandler.addToCSV(mealCombos);
        }
Example #9
0
 private void addMealCombosToDataGrid(MealCombination combo)
 {
     _mealCombos.Add(combo);
     dataGrid.Items.Refresh();
 }