//private void TextBox_GotFocus(object sender, RoutedEventArgs e)
        //{
        //    if (this.bookname.Text.Equals("书名"))
        //    {
        //        this.bookname.Text = "";
        //        this.bookname.Foreground = new SolidColorBrush(Color.FromArgb(255,0,0,0));
        //    }
        //}



        private void save_clicked(object sender, EventArgs e)
        {
            int index = booknamelist.SelectedIndex;

            Debug.WriteLine("index :" + index);
            if (index >= 0)
            {
                List <ReadingPlan> items = bookService.searchReadingPlanByISBN(bl[booknamelist.SelectedIndex].ISBN, phoneAppServeice.State["username"].ToString());
                Debug.WriteLine("the count of items is :" + items.Count);
                if (items.Count > 0)
                {
                    MessageBox.Show("这本书已在计划列表,如需要修改,可以选择编辑按钮");
                    return;
                }
                ReadingPlan plan = new ReadingPlan();
                plan.UserId = phoneAppServeice.State["username"].ToString();
                plan.ISBN   = bl[booknamelist.SelectedIndex].ISBN;

                plan.Title      = (string)this.booknamelist.SelectedItem;
                plan.DatePicker = this.datePicker.ValueString;
                //plan.DatePicker = this.datePicker.Value.ToString();
                plan.Priority   = (string)this.prioritylist.SelectedItem;
                plan.IsReminder = (bool)this.toggle.IsChecked;
                plan.RingTime   = this.timepicker.ValueString;
                //plan.RingTime = this.timepicker.Value.ToString();
                plan.Detail = this.detail.Text.ToString();

                if (plan.IsReminder)
                {
                    plan.Image = "/Icon/feature.alarm.png";
                    string clockname = "alarm" + plan.ISBN;
                    Alarm  clock     = new Alarm(clockname);
                    //开始时间
                    DateTime beginTime = (DateTime)this.timepicker.Value;
                    TimeSpan timespan  = beginTime.TimeOfDay;
                    if (beginTime < DateTime.Now)
                    {
                        DateTime date = DateTime.Now.AddDays(1).Date;

                        beginTime = date + timespan;

                        Debug.WriteLine("[Debug]date:" + date + "timespan" + timespan + "beginTime.TimeOfDay" + beginTime);
                    }
                    clock.BeginTime = beginTime;
                    //结束时间
                    //clock.ExpirationTime = clock.BeginTime + new TimeSpan(0, 0, 30);

                    DateTime expirationtime = (DateTime)this.datePicker.Value + timespan;
                    Debug.WriteLine("[Debug]expirationtime:" + expirationtime);

                    if (expirationtime < beginTime)
                    {
                        MessageBox.Show("截止提醒时间已过,请修改截止时间或提醒时间");
                        return;
                    }
                    clock.ExpirationTime = expirationtime;

                    //提醒内容
                    clock.Content = "别忘了今天要读<<" + plan.Title + ">>.";


                    //提醒铃声
                    clock.Sound = new Uri("/SleepAway.mp3", UriKind.Relative);

                    //提醒类型
                    clock.RecurrenceType = RecurrenceInterval.Daily;

                    ScheduledActionService.Add(clock);

                    Debug.WriteLine("[DEBUG]clock.BeginTime: " + clock.BeginTime + "  clock.ExpirationTime;" + clock.ExpirationTime + "  clock.Content:" + clock.Content +
                                    "  clock.Sound:" + clock.Sound + "  clock.RecurrenceType;" + clock.RecurrenceType);
                }
                else
                {
                    plan.Image = "";
                }

                Debug.WriteLine("[DEBUG]plan.userid: " + plan.UserId + "  plan.ISBN;" + plan.ISBN + "  plan.title:" + plan.Title +
                                "  plan.dataPicker:" + plan.DatePicker + "  plan.priority;" + plan.Priority + "  plan.IsReminder:" + plan.IsReminder + "  plan.ringtime:" + plan.RingTime
                                + "  plan.Detail:" + plan.Detail);

                bool result = bookService.insertPlan(plan);
                if (result)
                {
                    //MessageBox.Show("succeed!");

                    //NavigationService.Navigate(new Uri("/MainPage.xaml",UriKind.Relative));
                    NavigationService.GoBack();
                }
                else
                {
                    MessageBox.Show("failed!");
                }
            }
            else
            {
                MessageBox.Show("请先添加书到\"在读的书\"列表中");
            }
        }