/// <summary> /// Deletes CurrEntry in Table and Data /// </summary> private void DeleteCurrEntry() { GetCurrEntry(); if (IdInput.Text != "" && AmountInput.Text != "" && OnTheHouseInput.Text != "" && NumInput.Text != "") { bool suc = false; //to stop the loop foreach (Day d in Buchhaltung.CurrWeek.DaysInWeek) { if (d.Name == Buchhaltung.CurrDay) { for (int i = 0; i < d.Entrys.Count; i++) { //compares the original entry with the entrys in the mainProgramm if (_originalEntry.ProductForEntry.Id == (d.Entrys[i].ProductForEntry.Id) && _originalEntry.Amount == (d.Entrys[i].Amount)) { d.Entrys.RemoveAt(i); suc = true; break; } } } if (suc) { break; } } Buchhaltung.SaveEntrys(); Close(); } }
private void SaveEntry() { try { foreach (Product p in Buchhaltung.Products) { if (p.Id != Convert.ToInt32(InputId.Text)) { continue; } Entry e; if (InputAmountOnTheHouse.Text == "") { _actualAmount = Convert.ToInt32(InputAmount.Text); e = new Entry(p, _actualAmount, 0, _priceInUse); } else { _actualAmount = Convert.ToInt32(p.Amount * Convert.ToInt32(InputAmount.Text) + Convert.ToInt32(InputAmountOnTheHouse.Text)); e = new Entry(p, _actualAmount, Convert.ToInt32(InputAmountOnTheHouse.Text), _priceInUse); } //Adds at the currentWeek and the current Day the entry Buchhaltung.CurrWeek.GetCurrentDayAndAddEntry(e); break; } } catch (Exception e) { Buchhaltung.Log(e.Message); Buchhaltung.SaveErrorMsg(e); } Buchhaltung.SaveEntrys(); }
private void SaveEntry() { try { foreach (Product p in Buchhaltung.products) { if (p.ID != Convert.ToInt32(inputID.Text)) { continue; } Entry e; if (inputAmountOnTheHouse.Text == "") { // Convert.ToInt32(p.Amount * Falls Probleme auftreten wieder probieren actualAmount = Convert.ToInt32(inputAmount.Text); e = new Entry(p, actualAmount, 0, priceInUse); } else { actualAmount = Convert.ToInt32(p.Amount * Convert.ToInt32(inputAmount.Text) + Convert.ToInt32(inputAmountOnTheHouse.Text)); e = new Entry(p, actualAmount, Convert.ToInt32(inputAmountOnTheHouse.Text), priceInUse); } //Adds at the currentWeek and the current Day the entry Buchhaltung.currWeek.GetCurrentDayAndAddEntry(e); break; } } catch (Exception e) { Buchhaltung.Log(e.Message); Buchhaltung.SaveErrorMsg(e); } Buchhaltung.SaveEntrys(); }
/// <summary> /// Edits data In Table and Data /// </summary> private void EditDataAndSave() { if (IdInput.Text != "" && AmountInput.Text != "" && OnTheHouseInput.Text != "" && NumInput.Text != "") { bool stopIt = false; //to stop the loop try { foreach (Day dummy in Buchhaltung.CurrWeek.DaysInWeek) { foreach (Product t in Buchhaltung.Products) { if (IdInput.Text == Convert.ToString(t.Id)) //Checks the id of the product { //Gives the newEntry the correct information Product pNew = t; _newEntry.ProductForEntry = pNew; _newEntry.Amount = Convert.ToInt32(AmountInput.Text); _newEntry.AmountOnTheHouse = Convert.ToInt32(OnTheHouseInput.Text); _newEntry.Price = _originalEntry.Amount * _originalEntry.ProductForEntry.Price; stopIt = true; break; } } if (stopIt) //stopsLoop { break; } } OverridesEntryInMainProgramm(); Buchhaltung.SaveEntrys(); Close(); } catch (Exception e) { Buchhaltung.Log(e.Message); Buchhaltung.SaveErrorMsg(e); } } else { Buchhaltung.Log("Es wurden Felder leer gelassen!"); } }
//edits the data private void EditDataAndSave() { if (id_input.Text != "" && amount_input.Text != "" && onTheHouse_input.Text != "" && num_input.Text != "") { bool stopIt = false; //to stop the loop try { foreach (Day d in Buchhaltung.currWeek.DaysInWeek) { Product pNew; for (int i = 0; i < Buchhaltung.products.Count; i++) { if (id_input.Text == Convert.ToString(Buchhaltung.products[i].ID)) //Checks the id of the product { //Gives the newEntry the correct information pNew = Buchhaltung.products[i]; //generates new Product for the entry _newEntry.ProductForEntry = pNew; _newEntry.Amount = Convert.ToInt32(amount_input.Text); _newEntry.AmountOnTheHouse = Convert.ToInt32(onTheHouse_input.Text); _newEntry.Price = _originalEntry.Amount * _originalEntry.ProductForEntry.Price; //schon verhaut stopIt = true; break; } } if (stopIt) //stopsLoop { break; } } OverridesEntryInMainProgramm(); Buchhaltung.SaveEntrys(); this.Close(); } catch (Exception e) { Buchhaltung.Log(e.Message); Buchhaltung.SaveErrorMsg(e); } } else { Buchhaltung.Log("Es wurden Felder leer gelassen"); } }