private void Button_Click_1(object sender, RoutedEventArgs e) { TransactionsListView.Items.Clear(); DbMenagmentProvider db = new DbMenagmentProvider(); List <Transaction> transactionsList; try { transactionsList = db.GetTransactionsList(); } catch (FileNotFoundException exce) { MessageBox.Show("Nie odnaleziono na dysku pliku z listą tranzakcji. {0}", exce.Message); return; } catch (Exception exce) { MessageBox.Show(string.Format("Nieoczekiwany błąd: {0}", exce.Message)); return; } foreach (var item in transactionsList) { this.TransactionsListView.Items.Add(item); } LoadTransactionsListButton.Content = "Odśwież"; }
public void Filter_test() { DbMenagmentProvider db = new DbMenagmentProvider(); List <Transaction> transactionsList = db.GetTransactionsList(); var newTransactionsList = (from transaction in transactionsList where transaction.Amount >= 200 && transaction.Amount <= 300 select transaction).ToList(); Assert.AreEqual(newTransactionsList.Count, 2); }
private void SearchButton_Click(object sender, RoutedEventArgs e) { TransactionsListView.Items.Clear(); DbMenagmentProvider db = new DbMenagmentProvider(); List <Transaction> transactionsList; try { transactionsList = db.GetTransactionsList(); } catch (FileNotFoundException exce) { MessageBox.Show(string.Format("Błąd: {0}", exce.Message.ToString())); return; } catch (Exception exce) { MessageBox.Show(string.Format("Nieoczekiwany błąd podczas filtrowania listy tranzakcji {0}", exce.Message)); return; } string currencyValue = CurrencyFilterComboBox.Text; int fromValue = 0, toValue = Int32.MaxValue; string date = ""; string status; string reciver = ""; string cardId = ""; string currency = ""; //obsługa zakresu tranzakcji try { fromValue = Int32.Parse(MinValueFilterTextBox.Text); } catch (FormatException) { fromValue = 0; } try { toValue = Int32.Parse(MaxValueFilterTextBox.Text); } catch (FormatException) { toValue = Int32.MaxValue; } transactionsList = transactionsList.Where(x => x.Amount >= fromValue && x.Amount <= toValue).ToList(); //obsluga kalendarza if (DayOfTransactionCalendar.SelectedDate.HasValue) { date = DayOfTransactionCalendar.SelectedDate.Value.ToShortDateString(); transactionsList = transactionsList.Where(x => x.DateTime == date).ToList(); } //obsługa zaakceptowanie/niezaakceptowane if (StatusCheckBox.IsChecked.Value) { status = "Accepted"; //MessageBox.Show("checked"); transactionsList = transactionsList.Where(x => x.IfAccepted == status).ToList(); } //obsługa obiorcy if (ReciverFilterTextBox.Text != reciver) { reciver = ReciverFilterTextBox.Text; transactionsList = transactionsList.Where(x => x.ReciverOfAmount == reciver).ToList(); } //obsługa nr id karty if (CardIdFilterTextBox.Text != cardId) { cardId = CardIdFilterTextBox.Text; transactionsList = transactionsList.Where(x => x.UsedCardId == cardId).ToList(); } //obsługa waluty if (CurrencyFilterComboBox.Text != "Dowolna") { currency = CurrencyFilterComboBox.Text; transactionsList = transactionsList.Where(x => x.Currency == currency).ToList(); } foreach (var item in transactionsList) { this.TransactionsListView.Items.Add(item); } }