Esempio n. 1
0
        /// <summary>
        /// Load sequence with name
        /// </summary>
        /// <param name="SeqName"></param>
        /// <returns></returns>
        public bool LoadSequence(string SeqName)
        {
            bool ret = false;

            using (CDatabase db = new CDatabase())
            {
                if (db.GetTemperatureSequence(SeqName, out _Sequence))
                {
                    this.SequenceName = SeqName;
                    ret = true;
                }
                else
                {
                    strLastErr = db.LastError;
                    ret        = false;
                }
            }
            RaisePropertyChangedEvent("Sequence");
            return(ret);
        }
 /// <summary>
 /// Load sequence with name
 /// </summary>
 /// <param name="SeqName"></param>
 /// <returns></returns>
 public void LoadSequence(string SequenceName)
 {
     using (CDatabase db = new CDatabase())
     {
         CTemperatureSequence _Sequence;
         if (db.GetTemperatureSequence(SequenceName, out _Sequence))
         {
             this.Sequence = _Sequence;
             if (_Sequence == null)
             {
                 this.SelectedSeqName = "";
             }
             else
             {
                 this.SelectedSeqName = _Sequence.SequenceName;
             }
         }
         else
         {
         }
     }
 }
Esempio n. 3
0
        /// <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
            }
        }