コード例 #1
0
 private void cmbCategory_DropDownClosed(object sender, EventArgs e)
 {
     if (cmbCategory.SelectedItem != null)
     {
         _selectedTransactionCategory = _transactionCategoryManager.GetByName(cmbCategory.SelectedItem.ToString());
     }
 }
コード例 #2
0
 private void btnSaveChanges_Click(object sender, RoutedEventArgs e)
 {
     if (dpDate.SelectedDate.HasValue &&
         cmbExpenseOrIncome.SelectedItem != null &&
         cmbCategory.SelectedItem != null &&
         decimal.TryParse(txtAmount.Text, out decimal amount) &&
         amount > 0
         )
     {
         _transaction = new Transaction
         {
             TransactionId         = SelectedTransaction.TransactionId,
             TransactionCategoryId = _transactionCategoryManager.GetByName(cmbCategory.SelectedItem.ToString()).TransactionCategoryId,
             UserId          = SelectedTransaction.UserId,
             TransactionDate = dpDate.SelectedDate.Value,
             Sum             = amount
         };
         _transactionManager.Update(_transaction);
         MessageBox.Show("Entry updated!");
         cmbExpenseOrIncome.SelectedItem = null;
         cmbCategory.SelectedItem        = null;
         txtAmount.Text = string.Empty;
         btnSaveChanges_ClickHandler(sender, e);
     }
     else if (cmbExpenseOrIncome.SelectedItem == null)
     {
         MessageBox.Show("Expense/Income was not selected!");
     }
     else if (cmbCategory.SelectedItem == null)
     {
         MessageBox.Show("Category was not selected!");
     }
     else if (!decimal.TryParse(txtAmount.Text, out amount))
     {
         MessageBox.Show("Amount must be decimal number!");
     }
     else if (amount <= 0)
     {
         MessageBox.Show("Amount must be greater than 0!");
     }
     else
     {
         MessageBox.Show("Incorrect input!");
     }
 }