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>()); } }
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(); }
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); }
public static void addToCSV(MealCombination mealCombo) { string type = mealCombo.GetType().ToString(); writeFileNameToProperty(type); var mealList = readCombos(type); mealList.Add(mealCombo); write(mealList); }
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(); } }
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); }
private void addMealCombosToDataGrid(MealCombination combo) { _mealCombos.Add(combo); dataGrid.Items.Refresh(); }