// Add a new entry to the database and collections. public void AddEntry(ReceiptEntry newEntry) { // Add a new entry to the data context. receiptDatabase.entries.InsertOnSubmit(newEntry); // Save changes to the database. receiptDatabase.SubmitChanges(); // Add a new entry to the "all" observable collection. AllReceiptEntries.Add(newEntry); if (newEntry.EntryDate.Month == DateTime.Today.Month) { ThisMonthEntries.Add(newEntry); } if (Helper.IsThisWeek(newEntry.EntryDate)) { ThisWeekEntries.Add(newEntry); } if (DateTime.Compare(newEntry.EntryDate, DateTime.Today) == 0) { TodayEntries.Add(newEntry); } }
// Called during a remove operation private void detach_Entry(ReceiptEntry entry) { NotifyPropertyChanging("ReceiptEntry"); entry.EntryCategory = null; }
// Called during an add operation private void attach_Entry(ReceiptEntry entry) { NotifyPropertyChanging("ReceiptEntry"); entry.EntryCategory = this; }
// Add a new entry to the database and collections. public void AddEntry(ReceiptEntry newEntry) { // Add a new entry to the data context. receiptDatabase.entries.InsertOnSubmit(newEntry); // Save changes to the database. receiptDatabase.SubmitChanges(); // Add a new entry to the "all" observable collection. AllReceiptEntries.Add(newEntry); if (newEntry.EntryDate.Month == DateTime.Today.Month) ThisMonthEntries.Add(newEntry); if (Helper.IsThisWeek(newEntry.EntryDate)) ThisWeekEntries.Add(newEntry); if (DateTime.Compare(newEntry.EntryDate, DateTime.Today) == 0) TodayEntries.Add(newEntry); }