private void AddInvestmentButton_Click(object sender, EventArgs e) { if (ValidateUserInvestment()) { try { Investment i = (Investment)this.NameComboBox.SelectedItem; UserInvestment ui = new UserInvestment(); ui.IdInvestment = i.IdInvestment; ui.idUser = this.user.idUser; ui.ValuePLN = Double.Parse(this.InvValueTextBox.Text); ui.ValuePurcharsed = Double.Parse(this.RateTextBox.Text); ui.Amount = Double.Parse(this.AmountTextBox.Text); ui.DatePurchased = this.InvestDateTimePicker.Value; if (!FindInvestment(i.IdInvestment)) { ui = SqlConnector.AddUserInvestment(ui); } else { SqlConnector.EditUserInvestment(ui); } } catch (Exception) { MessageBox.Show("Something went wrong", "Duplicate error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Incorret data! Try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.InvValueTextBox.Text = ""; this.RateTextBox.Text = ""; this.AmountTextBox.Text = ""; this.InvestDateTimePicker.Value = DateTime.Today; }