private void DataBinding(List <VarorModel> list) { shoppingListListBoxBinding.DataSource = list; shoppingListListBox.DataSource = shoppingListListBoxBinding; shoppingListListBox.ValueMember = "Display"; shoppingListListBox.DisplayMember = "Display"; dyrasteBinding.DataSource = VarorProcessor.MostExpensive(list); dyrasteListBox.DataSource = dyrasteBinding; billigasteBinding.DataSource = VarorProcessor.Cheapest(list); billigasteListBox.DataSource = billigasteBinding; dyrasteListBox.ValueMember = "Display"; dyrasteListBox.DisplayMember = "Display"; billigasteListBox.ValueMember = "Display"; billigasteListBox.DisplayMember = "Display"; summaBinding.DataSource = VarorProcessor.Sum(list); summaListBox.DataSource = summaBinding; shoppingListListBoxBinding.ResetBindings(false); dyrasteBinding.ResetBindings(false); billigasteBinding.ResetBindings(false); }
private void DeleteVara_Click(object sender, RoutedEventArgs e) { VarorProcessor.DeleteVara(VarorModel.listOfVaror, varorListBox); DataBinding(VarorModel.listOfVaror); var newList = VarorModel.listOfVaror.Where(x => x.Price > 0); varorListBox.ItemsSource = newList; }
private void DataBinding(List <VarorModel> list) { varorListBox.ItemsSource = list; varorListBox.DisplayMemberPath = "Display"; var mostExpensive = VarorProcessor.MostExpensiveModel(list); dyrasteVara.Text = $"{mostExpensive.Name} - Pris: {mostExpensive.Price} kr"; var cheapest = VarorProcessor.CheapestModel(list); billigasteVara.Text = $"{cheapest.Name} - Pris: {cheapest.Price} kr"; summaTextBox.Text = $"{VarorProcessor.Sum(list).ToString()} kr"; }
private void AddVaraButton_Click(object sender, RoutedEventArgs e) { bool inmatning = ValidateInputClass.ValidateInput(varansNamnTextBox.Text, varansPrisTextBox.Text); if (inmatning) { VarorProcessor.AddVara(VarorModel.listOfVaror, varansNamnTextBox.Text, varansPrisTextBox.Text); DataBinding(VarorModel.listOfVaror); ClearTextFields(varansNamnTextBox, varansPrisTextBox); var newList = VarorModel.listOfVaror.Where(x => x.Price > 0); varorListBox.ItemsSource = newList; } }
private void CreateVara() { //Validate Input bool inmatning = ValidateInputClass.ValidateInput(varansNamnTextBox.Text, varansPrisTextBox.Text); if (inmatning) { //Add new vara VarorProcessor.AddVara(VarorModel.listOfVaror, varansNamnTextBox.Text, varansPrisTextBox.Text); ClearTextFields(varansNamnTextBox, varansPrisTextBox); DataBinding(VarorModel.listOfVaror); } }
public static void OutputSumCheapestExpensive() { Console.WriteLine($"\nSumma i korgen: {VarorProcessor.Sum(VarorModel.listOfVaror)} kr"); Console.WriteLine($"\nBilligaste vara/varor:"); foreach (var item in VarorProcessor.Cheapest(VarorModel.listOfVaror)) { Console.WriteLine($"{item.Name} - Pris: {item.Price}"); } Console.WriteLine($"\nDyraste vara/varor:"); foreach (var item in VarorProcessor.MostExpensive(VarorModel.listOfVaror)) { Console.WriteLine($"{item.Name} - Pris: {item.Price}"); } }
public static string CreateVara() { Console.WriteLine("\nNamn på vara (exit för att avsluta): "); nameOfVara = Console.ReadLine(); if (nameOfVara != "exit") { bool outcomeOfParse = false; while (!outcomeOfParse) { Console.WriteLine("Ange Pris: "); priceOfVara = Console.ReadLine(); outcomeOfParse = decimal.TryParse(priceOfVara, out decimal tryPrice); } VarorProcessor.AddVara(VarorModel.listOfVaror, nameOfVara, priceOfVara); } return(nameOfVara); }
private void DeleteVaraButton_Click(object sender, EventArgs e) { VarorProcessor.DeleteVara(VarorModel.listOfVaror, shoppingListListBox); DataBinding(VarorModel.listOfVaror); }