private async void Period_pickerFlyout_TimePicked(TimePickerFlyout sender, TimePickedEventArgs args)
        {
            if (Convert.ToInt32(sender.Time.TotalMinutes) != 0)
            {
                Period_picker_tamp.TIME_PERIOD = Convert.ToInt32(sender.Time.TotalMinutes);
                Period_picker_tamp.TIMESTART   = DateTime.Now.ToString("s");
                Period_picker_tamp.TIMEEND     = DateTime.Now.AddMinutes(Period_picker_tamp.TIME_PERIOD).ToString("s");
                DB_Controller db = new DB_Controller();
                await db.update_TimePeriodList(Period_picker_tamp);

                foreach (ScheduledToastNotification s in ToastNotificationManager.CreateToastNotifier().GetScheduledToastNotifications())
                {
                    if (s.Id == "Period" + Period_picker_tamp.ID.ToString())
                    {
                        ScheduledToastNotification recurringToast = new ScheduledToastNotification(s.Content, DateTime.Parse(Period_picker_tamp.TIMEEND));
                        ToastNotificationManager.CreateToastNotifier().RemoveFromSchedule(s);
                        ToastNotificationManager.CreateToastNotifier().AddToSchedule(recurringToast);
                        break;
                    }
                }

                foreach (DB_TimePeriodList s in timePeriodListData)
                {
                    if (s.ID == Period_picker_tamp.ID)
                    {
                        s.TIME_PERIOD      = Period_picker_tamp.TIME_PERIOD;
                        s.TIMESTART        = Period_picker_tamp.TIMESTART;
                        s.TIMEEND          = Period_picker_tamp.TIMEEND;
                        Period_picker_tamp = null;
                        break;
                    }
                }
            }
        }
        private async void timePeriod_IsWork_Click(object sender, RoutedEventArgs e)
        {
            DB_TimePeriodList selectedTimePeriod = ((Coding4Fun.Toolkit.Controls.OpacityToggleButton)sender).DataContext as DB_TimePeriodList;

            if (((ToggleButton)sender).IsChecked == true & timePeriodWorkMutexCheck())
            {
                selectedTimePeriod.TIMESTART           = DateTime.Now.ToString("s");
                selectedTimePeriod.IS_WORK             = true;
                selectedTimePeriod.TimePeriod_barValue = 0;
                selectedTimePeriod.TIMEEND             = DateTime.Parse(selectedTimePeriod.TIMESTART).AddMinutes(selectedTimePeriod.TIME_PERIOD).ToString("s");
                foreach (DB_TimePeriodList s in timePeriodListData)
                {
                    if (s.ID == selectedTimePeriod.ID)
                    {
                        timePeriodListData[timePeriodListData.IndexOf(s)] = selectedTimePeriod;
                        break;
                    }
                }
                DB_Controller db = new DB_Controller();
                await db.update_TimePeriodList(selectedTimePeriod);

                XmlDocument toastXml      = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
                XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text");
                toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode("Time is up"));
                toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode("Time Period toast test"));
                ScheduledToastNotification recurringToast = new ScheduledToastNotification(toastXml, DateTime.Parse(selectedTimePeriod.TIMEEND));
                recurringToast.Id = "Period" + selectedTimePeriod.ID.ToString();
                ToastNotificationManager.CreateToastNotifier().AddToSchedule(recurringToast);

                dispatcherTimer.Start();
            }
            else if (((ToggleButton)sender).IsChecked == false)
            {
                selectedTimePeriod.IS_WORK = false;
                DB_Controller db = new DB_Controller();
                await db.update_TimePeriodList(selectedTimePeriod);

                DB_Controller db_test = new DB_Controller();
                await db_test.reflesh_timePeriod();

                List <DB_TimePeriodList> test_list = db_test.get_timePeriodList;
                dispatcherTimer.Stop();
                foreach (ScheduledToastNotification s in ToastNotificationManager.CreateToastNotifier().GetScheduledToastNotifications())
                {
                    if (s.Id == "Period" + selectedTimePeriod.ID.ToString())
                    {
                        ToastNotificationManager.CreateToastNotifier().RemoveFromSchedule(s);
                        break;
                    }
                }
            }
            else
            {
                ((ToggleButton)sender).IsChecked = false;
                Coding4Fun.Toolkit.Controls.ToastPrompt toast = new Coding4Fun.Toolkit.Controls.ToastPrompt();
                toast.Message = "一心不可二用poi";
                toast.Show();
            }
        }
        private void confirm_Click(object sender, RoutedEventArgs e)
        {
            DB_TimePeriodList timePeriodList = new DB_TimePeriodList(__name.Text, Convert.ToInt32(((ComboBoxItem)__time.SelectedItem).Content.ToString()), (bool)__is_work.IsChecked);
            DB_Controller     DB             = new DB_Controller();

            DB.insert_TimePeriodList(timePeriodList);
            toGoodNightPage();
        }
        private async void timePoint_check_Click(object sender, RoutedEventArgs e)
        {
            DB_TimePointList selectedTimePoint = ((CheckBox)sender).DataContext as DB_TimePointList;

            if (((CheckBox)sender).IsChecked == true)
            {
                selectedTimePoint.IS_WORK = true;
                foreach (DB_TimePointList s in timePointListData)
                {
                    if (s.ID == selectedTimePoint.ID)
                    {
                        s.IS_WORK = selectedTimePoint.IS_WORK;
                        break;
                    }
                }
                DB_Controller db = new DB_Controller();
                await db.update_TimePointList(selectedTimePoint);

                DateTime now = DateTime.Now;
                DateTime notificationTime = new DateTime(now.Year, now.Month, now.Day, (int)selectedTimePoint.TIME_POINT.Hours, (int)selectedTimePoint.TIME_POINT.Minutes, 0);
                if (isTimePassed(selectedTimePoint.TIME_POINT))
                {
                    return;
                }
                XmlDocument toastXml      = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
                XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text");
                toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode("Time is up"));
                toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode("Time Point toast test"));
                ScheduledToastNotification recurringToast = new ScheduledToastNotification(toastXml, notificationTime);
                recurringToast.Id = "Point" + selectedTimePoint.ID.ToString();
                ToastNotificationManager.CreateToastNotifier().AddToSchedule(recurringToast);
            }
            else
            {
                selectedTimePoint.IS_WORK = false;
                foreach (DB_TimePointList s in timePointListData)
                {
                    if (s.ID == selectedTimePoint.ID)
                    {
                        s.IS_WORK = selectedTimePoint.IS_WORK;
                        break;
                    }
                }
                DB_Controller db = new DB_Controller();
                await db.update_TimePointList(selectedTimePoint);

                foreach (ScheduledToastNotification s in ToastNotificationManager.CreateToastNotifier().GetScheduledToastNotifications())
                {
                    if (s.Id == "Point" + selectedTimePoint.ID.ToString())
                    {
                        ToastNotificationManager.CreateToastNotifier().RemoveFromSchedule(s);
                        break;
                    }
                }
            }
        }
        async void dispatcherTimer_Tick(object sender, object e)
        {
            DB_Controller DB = new DB_Controller();
            await DB.reflesh_timePeriod();

            foreach (DB_TimePeriodList s in timePeriodListData)
            {
                s.TimePeriod_barValue = s.get_timePeriod_barValue();
            }
        }
        private async void timePoint_delete_Click(object sender, RoutedEventArgs e)
        {
            DB_TimePointList selectedTimePoint = ((MenuFlyoutItem)sender).DataContext as DB_TimePointList;
            DB_Controller    DB = new DB_Controller();

            DB.delete_TimePointList(selectedTimePoint);
            await DB.reflesh_timePoint();

            timePointListData            = DB.get_timePointList;
            time_points_list.ItemsSource = timePointListData;
        }
        private bool timePeriodWorkMutexCheck()
        {
            DB_Controller db = new DB_Controller();

            foreach (DB_TimePeriodList s in timePeriodListData)
            {
                if (s.IS_WORK == true)
                {
                    return(false);
                }
            }
            return(true);
        }
        private async void InitializationDB()
        {
            DB_Controller DB_myGoodnight = new DB_Controller();
            await DB_myGoodnight.CreatTable();

            timePeriodListData = DB_myGoodnight.get_timePeriodList;
            timePointListData  = DB_myGoodnight.get_timePointList;
            this.time_points_list.ItemsSource = timePointListData;
            time_Period_list.ItemsSource      = timePeriodListData;
            foreach (DB_TimePeriodList s in timePeriodListData)
            {
                if (s.IS_WORK == true)
                {
                    dispatcherTimer.Start();
                    break;
                }
            }
            Test_More();
        }