//Clear text boxes and errors, send focus back to Date private void ClearUserInput() { DatePicker.Value = DateTime.Today; DepositRadioButton.Checked = true; AmountTextBox.Text = ""; PayeeTextBox.Text = ""; CheckTextBox.Text = ""; ValidationErrorProvider.Clear(); DepositRadioButton.Focus(); }
//Collect user input, validate input, update balance if validation passed, clear form private void AddTransButton_Click(object sender, EventArgs e) { ValidationErrorProvider.Clear(); //Clear previous errors if (UserInputCompleted()) //User input is in correct format { decimal TempAmount = decimal.Parse(AmountTextBox.Text); if (Transaction.DecimalExcedeZero(TempAmount))//Amount is greater than Zero { //Create Transaction Transaction NewTransaction = new Transaction(DatePicker.Value, TempAmount, SelectedType, PayeeTextBox.Text, CheckTextBox.Text); Transactions.Add(NewTransaction); //Add Transaction to TransactionList UpdateBalanceLabel(); //Display new balance TransListBox.Items.Add(NewTransaction.ToString()); //Add transaction to listbox } } }