private void addAmalToReminder(AmalItem item, RecurrenceInterval recurrence) { DateTime now = DateTime.Now.Date; DateTime beginTime = now + item.WaktuAmal.TimeOfDay; DateTime expireTime = now + item.WaktuAmal.TimeOfDay + new TimeSpan(1, 0, 0); String title; String name; if (item.ItemName.Length > 63) { title = item.ItemName.Substring(0, 60) + "..."; name = item.ItemName.Substring(0, 63); } else { title = name = item.ItemName; } if (ScheduledActionService.Find(name) == null) { Reminder reminder = new Reminder(name); reminder.Title = title; reminder.Content = "Jangan lupa amalnya!";// item.ItemName; reminder.BeginTime = moveTime(beginTime, recurrence); reminder.ExpirationTime = moveTime(expireTime, reminder.BeginTime, recurrence); reminder.RecurrenceType = recurrence; reminder.NavigationUri = new Uri("/LamanAmal1.xaml?id=" + item.AmalItemId, UriKind.Relative); // Register the reminder with the system. ScheduledActionService.Add(reminder); } else { Reminder reminder = ScheduledActionService.Find(name) as Reminder; reminder.BeginTime = moveTime(beginTime, recurrence); reminder.ExpirationTime = moveTime(expireTime, reminder.BeginTime, recurrence); ScheduledActionService.Replace(reminder); } }
// Remove a to-do task item from the database and collections. public void DeleteAmalItem(AmalItem amalForDelete) { // Remove the to-do item from the "all" observable collection. AllAmalItems.Remove(amalForDelete); // Remove the to-do item from the data context. _amalDB.Items.DeleteOnSubmit(amalForDelete); // Remove the to-do item from the appropriate category. switch (amalForDelete.Category.Name) { case "Pagi": PagiAmalItems.Remove(amalForDelete); break; case "Siang": SiangAmalItems.Remove(amalForDelete); break; case "Malam": MalamAmalItems.Remove(amalForDelete); break; case "Lain": LainAmalItems.Remove(amalForDelete); break; default: break; } // Save changes to the database. _amalDB.SubmitChanges(); }
// Called during a remove operation private void detach_Amal(AmalItem amal) { NotifyPropertyChanging("AmalItem"); amal.Category = null; }
// Add a to-do item to the database and collections. public void AddAmalItem(AmalItem newToDoItem) { // Add a to-do item to the data context. _amalDB.Items.InsertOnSubmit(newToDoItem); // Save changes to the database. _amalDB.SubmitChanges(); // Add a to-do item to the "all" observable collection. AllAmalItems.Add(newToDoItem); // Add a to-do item to the appropriate filtered collection. switch (newToDoItem.Category.Name) { case "Pagi": PagiAmalItems.Add(newToDoItem); break; case "Siang": SiangAmalItems.Add(newToDoItem); break; case "Malam": MalamAmalItems.Add(newToDoItem); break; case "Lain": LainAmalItems.Add(newToDoItem); break; default: break; } }
// Called during an add operation private void attach_Amal(AmalItem amal) { NotifyPropertyChanging("AmalItem"); amal.Category = this; }