private void WithdrawalButton_Click(object sender, EventArgs e) { if (ValidateTextBox()) { String name = (String)this.CurrentInvestmentsDataGridView.CurrentRow.Cells["Name"].Value; Investment selectedInvestment = SqlConnector.GetInvestment(name); UserInvestment ui = SqlConnector.GetUserInvestment(user.idUser, selectedInvestment.IdInvestment); double tempVal = Double.Parse(this.ValueToWithdrawTextBox.Text); if (ui.ValuePLN == tempVal) { SqlConnector.FinishInvestment(ui.IdUserInvestment); } else if (tempVal > 0 && tempVal < ui.ValuePLN) { double am = tempVal / selectedInvestment.Value; SqlConnector.AddHistoryInvestment(ui, tempVal, am); SqlConnector.WithdrawPartOfInvestment(ui.IdUserInvestment, tempVal); } else { MessageBox.Show("Incorret data! Try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } InitializeList(); } else { MessageBox.Show("Incorret data! Try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }