Пример #1
0
 private void Add_Click(object sender, EventArgs e)
 {
     if(tbxTitle.Text=="")
     {
         MessageBox.Show("Vui lòng nhập tiêu đề.");
         return;
     }
     GhiChu u = new GhiChu();
     u.Title = tbxTitle.Text;
     u.Content = tbxContent.Text;
     string date = String.Format("{0:d}", datePicker.Value) + " " + String.Format("{0:t}", timePicker.Value);
     u.Time = DateTime.ParseExact(date, "M/d/yyyy h:m tt", CultureInfo.InvariantCulture, DateTimeStyles.None);
     if (u.Time <= DateTime.Now)
     {
         MessageBox.Show("Hạn chót phải sau thời điểm hiện tại.");
         return;
     }
     u.Complete = false;
     DatabaseHelper help = new DatabaseHelper();
     help.Insert(u);
     if (u.Title.Length > 35)
     {
         u.Title = u.Title.Substring(0, 35) + "...";
     }
     Reminder reminder = new Reminder(u.Id.ToString());
     reminder.Title = u.Title;
     reminder.Content = u.Content;
     reminder.BeginTime = u.Time;
     reminder.NavigationUri = new Uri("/DetailPage.xaml?id=" + u.Id, UriKind.Relative);
     ScheduledActionService.Add(reminder);
     NavigationService.GoBack();
 }
Пример #2
0
 private void Delete_Click(object sender, EventArgs e)
 {
     DatabaseHelper help = new DatabaseHelper();
     help.DeleteContact(id);
     if (ScheduledActionService.Find(ghichu.Id.ToString()) != null)
     {
         ScheduledActionService.Remove(ghichu.Id.ToString());
     }
     //NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
     NavigationService.GoBack();
 }
Пример #3
0
 private void Update_Click(object sender, EventArgs e)
 {
     if (tbxTitle.Text == "")
     {
         MessageBox.Show("Vui lòng nhập tiêu đề.");
         return;
     }
     GhiChu u = new GhiChu();
     u.Id = id;
     u.Title = tbxTitle.Text;
     u.Content = tbxContent.Text;
     string date = String.Format("{0:d}", datePicker.Value) + " " + String.Format("{0:t}", timePicker.Value);
     u.Time = DateTime.ParseExact(date, "M/d/yyyy h:m tt", CultureInfo.InvariantCulture, DateTimeStyles.None);
     if (cbComplete.IsChecked == true)
     {
         if (ScheduledActionService.Find(ghichu.Id.ToString()) != null)
         {
             ScheduledActionService.Remove(ghichu.Id.ToString());
         }
         u.Complete = true;
         DatabaseHelper help = new DatabaseHelper();
         help.UpdateContact(u);
     }
     else
     {
         if (u.Time <= DateTime.Now)
         {
             MessageBox.Show("Hạn chót phải sau thời điểm hiện tại.");
             return;
         }
         DatabaseHelper help = new DatabaseHelper();
         u.Complete = false;
         help.UpdateContact(u);
         Reminder reminder = new Reminder(u.Id.ToString());
         if (u.Title.Length > 35)
         {
             //u.Title = u.Title.Substring(0, u.Title.IndexOfAny(new char[] { ' ' }, 20)) + "...";
             u.Title = u.Title.Substring(0, 35) + "...";
         }
         reminder.Title = u.Title;
         reminder.Content = u.Content;
         reminder.BeginTime = u.Time;
         reminder.ExpirationTime = u.Time.AddMinutes(5);
         reminder.NavigationUri = new Uri("/DetailPage.xaml?id=" + u.Id, UriKind.Relative);
         if (ScheduledActionService.Find(ghichu.Id.ToString()) != null)
         {
             ScheduledActionService.Remove(ghichu.Id.ToString());
         }
         ScheduledActionService.Add(reminder);
     }
     //NavigationService.Navigate(new Uri("/MainPage.xaml",UriKind.Relative));
     NavigationService.GoBack();
 }
Пример #4
0
 private void tbSearch_TextChanged(object sender, TextChangedEventArgs e)
 {
     if(tbSearch.Text=="")
     {
         List.ItemsSource.Clear();
     }
     else
     {
         DatabaseHelper h = new DatabaseHelper();
         List.ItemsSource = h.SearchContacts(tbSearch.Text);
     }
 }
Пример #5
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (tbSearch.Text == "")
     {
         return;
     }
     else
     {
         DatabaseHelper h = new DatabaseHelper();
         List.ItemsSource = h.SearchContacts(tbSearch.Text);
     }
 }
Пример #6
0
 void MainPage_Loaded(object sender, RoutedEventArgs e)
 {
     DatabaseHelper help = new DatabaseHelper();
     var l = help.ReadContacts();
     foreach (var gc in l.ToArray())
     {
         if (gc.Time < DateTime.Now)
         {
             if (ScheduledActionService.Find(gc.Id.ToString()) != null)
             {
                 ScheduledActionService.Remove(gc.Id.ToString());
             }
         }
     }
     List.ItemsSource = l;
     ListLS.ItemsSource = help.ReadContactsComplete();
 }
Пример #7
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (first == 0)
     {
         string pm;
         NavigationContext.QueryString.TryGetValue("id", out pm);
         DatabaseHelper help = new DatabaseHelper();
         ghichu = help.ReadContact(Convert.ToInt32(pm));
         first = 1;
         id = ghichu.Id;
         tbxTitle.Text = ghichu.Title;
         tbxContent.Text = ghichu.Content;
         cbComplete.IsChecked = ghichu.Complete;
         datePicker.Value = ghichu.Time;
         timePicker.Value = ghichu.Time;
     }
 }