/// <summary>
        /// 保存温度序列
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Save_Click(object sender, RoutedEventArgs e)
        {
            /* 如果Sequence为空,即还没有编辑Sequence,则提示并且不保存 */
            if(_vm.Sequence.Count == 0)
            {
                MessageBox.Show("当前温度序列为空", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            /* 检查总时间是否超过60分钟 */
            if(_vm.Sequence.TotalTime > CPublicVariables.Configuration.MaxCureTimeAllowed)
            {
                MessageBox.Show("总治疗时间不能超过60分钟", "警告", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            SequenceNameInput f = new SequenceNameInput();
            bool? r = f.ShowDialog();
            if(r.HasValue && r.Value == true)
            {
                /* 保存Sequence到数据库 */
                using(CDatabase db = new CDatabase())
                {
                    /* 检查名称是否已经存在 */
                    CTemperatureSequence seq;
                    r = db.GetTemperatureSequence(f.SequenceName, out seq);
                    if(r == false)  // 查询时发生错误
                    {
                        MessageBox.Show("查询温度序列时发生错误\r\n" + db.LastError, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        if(seq != null && seq.Count > 0)   // 如果当前Sequence name已存在,询问用户是否覆盖
                        {
                            // 如果不覆盖,则退出保存过程
                            if(MessageBox.Show(string.Format("{0}已存在,是否覆盖?", f.SequenceName), "警告", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                            {
                                return;
                            }
                                // 如果覆盖,则先删除旧的Sequence,再保存
                            else
                            {
                                /* 删除Sequence */
                                r = db.DeleteTemperatureSequence(f.SequenceName);
                                if(r == false)
                                {
                                    MessageBox.Show("删除温度序列时发生错误\r\n" + db.LastError, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                                    return;
                                }
                            }
                        }

                        /* 保存Sequence */
                        r = db.SaveTemperatureSequence(f.SequenceName, _vm.Sequence);
                        if (r == false)  // 如果发生错误
                        {
                            MessageBox.Show("保存温度序列时发生错误\r\n" + db.LastError, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            /* 重新加载Sequence Names列表 */
                            bgw_Init.RunWorkerAsync(f.SequenceName);
                        }
                    }

                }
            }
            else
            {
                // Do Nothing
            }
        }
 private void btn_Delete_Click(object sender, RoutedEventArgs e)
 {
     if(_vm.Sequence.Count > 0)
     {
         if (MessageBox.Show(string.Format("是否删除温度序列{0}?", _vm.SequenceName), "警告", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
         {
             using(CDatabase db = new CDatabase())
             {
                 bool r = db.DeleteTemperatureSequence(_vm.SequenceName);
                 if(r == false)  // 删除失败
                 {
                     MessageBox.Show("删除温度序列时发生错误\r\n" + db.LastError, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                 }
                 else            // 删除成功
                 {
                     MessageBox.Show("删除成功", "信息", MessageBoxButton.OK, MessageBoxImage.Information);
                     bgw_Init.RunWorkerAsync();
                 }
             }
         }
     }
 }