/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { int id = Convert.ToInt16(e.NavigationParameter); DatabaseHelper help = new DatabaseHelper(); var ghichu = help.ReadContact(id); cbComplete.IsChecked = ghichu.Complete; if (ghichu.Complete) cbNhacNho.IsEnabled = false; else cbNhacNho.IsChecked = ghichu.Remind; this.DataContext = ghichu; time.Time = DateTime.ParseExact(ghichu.Time, "M/d/yyyy h:m:s tt", CultureInfo.InvariantCulture, DateTimeStyles.None).TimeOfDay; date.Date = DateTime.ParseExact(ghichu.Time, "M/d/yyyy h:m:s tt", CultureInfo.InvariantCulture, DateTimeStyles.None); }
private async void Image_Tapped(object sender, TappedRoutedEventArgs e) { if (tbxTitle.Text == "") { MessageDialog ms = new MessageDialog("Vui lòng nhập tiêu đề!"); await ms.ShowAsync(); return; } if (tbxContent.Text == "") { MessageDialog ms = new MessageDialog("Vui lòng nhập nội dung!"); await ms.ShowAsync(); return; } var t = time.Time; var d = String.Format("{0:d}", date.Date); var k = DateTime.ParseExact(d + " " + t, "M/d/yyyy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None); if (k <= DateTime.Now && cbComplete.IsChecked == false) { MessageDialog ms = new MessageDialog("Hạn chót phải sau thời điểm hiện tại!"); await ms.ShowAsync(); return; } IReadOnlyList<ScheduledToastNotification> scheduled = ToastNotificationManager.CreateToastNotifier().GetScheduledToastNotifications(); foreach (ScheduledToastNotification notify in scheduled) { if (notify.Id == ("T.note" + ((GhiChu)this.DataContext).Id)) { ToastNotificationManager.CreateToastNotifier().RemoveFromSchedule(notify); } } GhiChu u = new GhiChu(); u.Id = ((GhiChu)this.DataContext).Id; u.Title = tbxTitle.Text; u.Content = tbxContent.Text; u.Complete = (bool)cbComplete.IsChecked; u.Remind = (bool)cbNhacNho.IsChecked; u.Time = k.ToString(); DatabaseHelper help = new DatabaseHelper(); help.UpdateContact(u); if ((bool)cbNhacNho.IsChecked) { ToastTemplateType toastTemplate = ToastTemplateType.ToastImageAndText01; XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); XmlNodeList toastImageAttributes = toastXml.GetElementsByTagName("image"); ((XmlElement)toastImageAttributes[0]).SetAttribute("src", "/Assets/noteicon.png"); ((XmlElement)toastImageAttributes[0]).SetAttribute("alt", "alt text"); XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text"); if ((bool)cbComplete.IsChecked) toastTextElements[0].AppendChild(toastXml.CreateTextNode(u.Title + " Hoàn thành!")); else toastTextElements[0].AppendChild(toastXml.CreateTextNode(u.Title)); var dueTime = new DateTimeOffset(k); var toast = new Windows.UI.Notifications.ScheduledToastNotification(toastXml, dueTime); toast.Id = "T.note" + u.Id.ToString(); Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast); } if (Frame.CanGoBack) { Frame.GoBack(); } }
private void OkBtnClick(IUICommand command) { DatabaseHelper help = new DatabaseHelper(); IReadOnlyList<ScheduledToastNotification> scheduled = ToastNotificationManager.CreateToastNotifier().GetScheduledToastNotifications(); foreach (ScheduledToastNotification notify in scheduled) { if (notify.Id == ("T.note" + ((GhiChu)this.DataContext).Id)) { ToastNotificationManager.CreateToastNotifier().RemoveFromSchedule(notify); } } help.DeleteContact(((GhiChu)this.DataContext).Id); if (Frame.CanGoBack) { Frame.GoBack(); } }
private async void OkBtnClick1(IUICommand command) { ProgressRingGrid1.Visibility = Visibility.Visible; state.Visibility = Visibility.Visible; state.Text = "Đang đồng bộ..."; backButton.Visibility = Visibility.Collapsed; try { var query = await ParseObject.GetQuery("GhiChu").Where(x => x["user"] == userfb).FindAsync(); foreach (var gchu in query.ToList()) { await gchu.DeleteAsync(); } DatabaseHelper help = new DatabaseHelper(); var listghichu = help.ReadAllContacts(); foreach (var gc in listghichu) { ParseObject gameScore = new ParseObject("GhiChu"); gameScore["Title"] = gc.Title; gameScore["Content"] = gc.Content; gameScore["Time"] = gc.Time; gameScore["Remind"] = gc.Remind; gameScore["Complete"] = gc.Complete; gameScore["user"] = userfb; gameScore["Id"] = gc.Id; await gameScore.SaveAsync(); } var usersPosts = await ParseObject.GetQuery("GhiChu").WhereEqualTo("user", userfb).FindAsync(); if (usersPosts.Count() > 0) { ccc.Text = "Tài khoản facebook của bạn có " + usersPosts.Count().ToString() + " ghi chú."; btnDown.Visibility = Visibility.Visible; } else { ccc.Text = "Tài khoản facebook của bạn chưa có dữ liệu."; btnDown.Visibility = Visibility.Collapsed; } state.Text = "Đồng bộ thành công."; } catch { state.Text = "Đồng bộ thất bại."; } ProgressRingGrid1.Visibility = Visibility.Collapsed; backButton.Visibility = Visibility.Visible; }