private void Button_Performance_Click(object sender, RoutedEventArgs e) { PerformanceWindow performanceWindow = new PerformanceWindow(); performanceWindow.Show(); Close(); }
private async void Search_Click(object sender, RoutedEventArgs e) { db = new ApplicationContext(); List <TradeTransaction> tradeTransactions = new List <TradeTransaction>(); List <TradeTransaction> list = db.TradeTransactions.ToList(); //tradeTransactions.Add(new TradeTransaction()); month = monthList.Text; year = yearsList.Text; await Task.Run(() => { list = db.TradeTransactions.ToList(); int sum = 0; bool locked = true; for (int j = 1; j <= 31; j++) { locked = true; foreach (var i in list) { if (i.Day == j && i.Month.ToString() == month && i.Year.ToString() == year) { tradeTransactions.Add(i); locked = false; } } if (locked) { tradeTransactions.Add(new TradeTransaction() { Amount = int.MinValue, Day = j, Month = Convert.ToInt32(month) }); } } //size проверочный день //sum это переменная через которую прогоняем сумму //cost запоминает сколько повторяющихся дней //IdSave запоминает индекс первого попавшегося дня //locker блокирует idSave int size = 1, cost = 0, idSave = 0, locker = 0; List <TradeTransaction> listRemove = new List <TradeTransaction>(); while (size <= 31) { cost = 0; locker = 0; idSave = 0; for (int i = 0; i < tradeTransactions.Count; i++) { if (tradeTransactions[i].Day == size) { if (locker == 0) { idSave = i; locker = -1; } if (tradeTransactions[i].Amount == int.MinValue) { tradeTransactions[i].Amount = sum; } else { sum += tradeTransactions[i].Amount; } tradeTransactions[idSave].Amount = sum; if (cost != 0) { listRemove.Add(tradeTransactions[i]); } cost++; } } //if (cost == 0) //{ // tradeTransactions.Add(new TradeTransaction() { Amount = sum, Day = size, Month = Convert.ToInt32(month) }); //} size++; } //Удаление ненужных элементов foreach (var i in listRemove) { tradeTransactions.Remove(i); } }); ChartValues <int> result = new ChartValues <int>(); foreach (var i in tradeTransactions) { result.Add(i.Amount); } Values2 = result; PerformanceWindow performanceWindow = new PerformanceWindow(Values2); performanceWindow.Show(); Close(); }