Ejemplo n.º 1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text == "")
            {
                MessageBox.Show("名称不能为空!", "系统信息");
                return;
            }
            Model.TB_StandardInfo info = new Model.TB_StandardInfo();
            bool result;

            if (!isAdd)
            {
                StandardInfo.Stand_Name = txtName.Text;
                result = standardInfoBLL.Update(StandardInfo);
                standardParamsBLL.Update(standardParam);
            }
            else
            {
                info.Stand_Name = txtName.Text;
                if (StandardInfo.Stand_Level == -1)
                {
                    info.Stand_Level    = 1;
                    info.Stand_ParentID = 0;
                }
                else
                {
                    info.Stand_Level    = 2;
                    info.Stand_ParentID = StandardInfo.ID;
                }

                result = standardInfoBLL.Add(info);
                int maxStandInfoId = standardInfoBLL.GetMaxId();
                standardParam.StandID = maxStandInfoId;
                standardParamsBLL.Add(standardParam);
            }
            if (!result)
            {
                MessageBox.Show("保存到数据库出错,请稍后重试!", "系统错误");
            }
            else
            {
                if (isAdd)
                {
                    RaiseEvent(new RoutedEventArgs(AddOrUpdateLevel2.AddSuccessRoutedEvent, this));
                    string desc = "添加成功!\r\n";
                    if (StandardInfo.Stand_Level == -1)
                    {
                        desc += "是否继续添加参考值类别?";
                    }
                    else
                    {
                        desc += "是否继续为" + StandardInfo.Stand_Name + "添加子参考值?";
                    }
                    if (MessageBox.Show(desc, "系统信息", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        standardParam = new Model.TB_StandardParams();
                        txtName.Text  = "";
                        init();
                    }
                    else
                    {
                        this.DialogResult = true;
                        this.Close();
                    }
                }
                else
                {
                    this.DialogResult = true;
                    this.Close();
                }
            }
        }