public void CalculateOutcome() { List <InvestmentView> availableInvestments = SqlConnector.GetInvestmentView_All(); double sum = 0; double sumInvested = 0; double percent; foreach (InvestmentView iv in availableInvestments) { sum += iv.Profit; sumInvested += iv.ValuePLN; } percent = (100 * (sumInvested + sum) / sumInvested) - 100; this.OutcomeValueLabel.Text = $"{sum.ToString("0.00")} ({percent.ToString("0.00")}%)"; if (sum > 0) { OutcomeValueLabel.ForeColor = Color.Green; } else { OutcomeValueLabel.ForeColor = Color.Red; } }
private void InitializeList() { this.CurrentInvestmentsDataGridView.DataSource = null; availableInvestments = SqlConnector.GetInvestmentView_All(); this.CurrentInvestmentsDataGridView.DataSource = availableInvestments; }