Exemplo n.º 1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            string experimentName = txtExperimentName.Text.Trim();

            if (experimentName == string.Empty)
            {
                errInfo.Text = "实验名称不能为空。";
                return;
            }
            else if (System.Text.Encoding.Default.GetByteCount(experimentName) > 255)
            {
                errInfo.Text = "实验名称允许最大长度为127个汉字";
                return;
            }

            ExperimentController controller = new ExperimentController();

            if (controller.ExperimentNameExists(experimentName))
            {
                errInfo.Text = "实验名称\"" + txtExperimentName.Text + "\"已存在。";
                return;
            }
            ExperimentsInfo experimentsInfo = new ExperimentsInfo();

            experimentsInfo.ExperimentID       = WanTaiObjectService.NewSequentialGuid();
            experimentsInfo.ExperimentName     = experimentName;
            experimentsInfo.LoginName          = txtOrperatorName.Text;
            experimentsInfo.Remark             = txtRemark.Text;
            experimentsInfo.StartTime          = DateTime.Now;
            experimentsInfo.State              = (short)ExperimentStatus.Create;;
            SessionInfo.CurrentExperimentsInfo = experimentsInfo;
            if (controller.CreateExperiment(experimentsInfo))
            {
                SessionInfo.ExperimentID = experimentsInfo.ExperimentID;
                SessionInfo.RotationFormulaParameters = new Dictionary <Guid, FormulaParameters>();
                SessionInfo.PraperRotation            = null;
                LogInfoController.AddLogInfo(LogInfoLevelEnum.Operate, "新建实验 成功", SessionInfo.LoginName, this.GetType().Name, SessionInfo.ExperimentID);
                this.DialogResult = true;
                this.Close();
            }
            else
            {
                errInfo.Text = "添加实验失败。";
            }
        }