private void SubmitButton_Click(object sender, EventArgs e) { try { string nameTextBoxValue = this.NameTextBox.Text; decimal amountTextBoxValue = Convert.ToDecimal(this.AmountTextBox.Text); int? budgetComboBoxValue = null; if (this.BudgetComboBox.Text != "none") { budgetComboBoxValue = Convert.ToInt16(this.BudgetComboBox.Text.Split('.')[0]); } DateTime dateDateTimePickerValue = this.DateDateTimePicker.Value; string categoryComboBoxValue = this.CategoryComboBox.Text == "none" ? null : this.CategoryComboBox.Text; Database.Transaction newTransactionValues = new Database.Transaction(); newTransactionValues.Amount = amountTextBoxValue; newTransactionValues.Name = nameTextBoxValue; newTransactionValues.BudgetId = budgetComboBoxValue; newTransactionValues.Id = DatabaseHelpers.GetCurrentTransactionId(true); DatabaseHelpers.Transactions.Add(newTransactionValues); this.Close(); } catch (Exception ex) { this.label6.Visible = true; } }
private void SubmitButton_Click(object sender, EventArgs e) { try { string nameTextBoxValue = this.NameTextBox.Text; decimal amountTextBoxValue = Convert.ToDecimal(this.AmountTextBox.Text); int? budgetComboBoxValue = null; if (this.BudgetComboBox.Text != "none") { budgetComboBoxValue = Convert.ToInt16(this.BudgetComboBox.Text.Split('.')[0]); } DateTime dateDateTimePickerValue = this.DateDateTimePicker.Value; string categoryComboBoxValue = this.CategoryComboBox.Text == "none" ? null : this.CategoryComboBox.Text; Database.Transaction newTransactionValues = (from transaction in DatabaseHelpers.Transactions where transaction.Id == currentTransaction select transaction).Single(); int listLocation = DatabaseHelpers.Transactions.IndexOf(newTransactionValues); newTransactionValues.Amount = amountTextBoxValue; newTransactionValues.Name = nameTextBoxValue; newTransactionValues.BudgetId = budgetComboBoxValue; DatabaseHelpers.Transactions[listLocation] = newTransactionValues; this.Close(); } catch (Exception ex) { this.label6.Visible = true; } }