private void SubmitClicked(object obj)
 {
     // has a date been picked?
     if (Date != null)
     {
         // are the inputs valid?
         if (!Sanitizer.InvalidNewExpense(Amount, Date.Value) && !Category.Equals(DefaultCatMessage))
         {
             // strip the desscription of all non alpha-numeric characters
             string sanitizedDescription = Sanitizer.GetSanitizedDescription(Description);
             if (sanitizedDescription.Length > 100)
             {
                 currentUser.NewUserIncome.Add(new NewIncome(currentUser.UserID, Double.Parse(string.Format("{0:N2}", Double.Parse(Amount))),
                                                             Date.Value, Category, sanitizedDescription.Substring(0, 100)));
             }
             else
             {
                 currentUser.NewUserIncome.Add(new NewIncome(currentUser.UserID, Double.Parse(string.Format("{0:N2}", Double.Parse(Amount))),
                                                             Date.Value, Category, sanitizedDescription));
             }
             MessageBox.Show("Record entered successfully!", "Success");
             ClearInput();
         }
         else
         {
             MessageBox.Show("Invalid input! Be sure to check all entries.", "Invalid Input");
         }
     }
     else
     {
         MessageBox.Show("Invalid input! Be sure to check all entries.", "Invalid Input");
     }
 }
示例#2
0
 private void UpdateSelectedRecord()
 {
     selectedRecord.Amount   = double.Parse(txtAmount.Text);
     selectedRecord.Category = cmbCategory.Text;
     selectedRecord.Date     = dteDate.SelectedDate.Value;
     if (!txtDescription.Text.Equals(""))
     {
         string sanitizedDescription = Sanitizer.GetSanitizedDescription(txtDescription.Text);
         if (sanitizedDescription.Length < 100)
         {
             selectedRecord.Description = sanitizedDescription;
         }
         else
         {
             selectedRecord.Description = sanitizedDescription.Substring(0, 100);
         }
     }
 }