Example #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string CateName   = this.txtCateName.Text.Trim();
            string GradeAlias = this.txtGradeField.Text.Trim();

            if (string.IsNullOrEmpty(CateName))
            {
                function.WriteErrMsg("分类名称不能为空!");
            }
            else
            {
                if (string.IsNullOrEmpty(GradeAlias))
                {
                    function.WriteErrMsg("分级选项别名不能为空!");
                }
                else
                {
                    GradeAlias = GradeAlias.Replace("\r\n", "|");
                    string[] AliasArr = GradeAlias.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    if (AliasArr.Length < 2)
                    {
                        function.WriteErrMsg("分级选项别名不能少于2个!");
                    }
                    else
                    {
                        int CateID = DataConverter.CLng(this.HdnCateID.Value);
                        if (CateID > 0)
                        {
                            M_GradeCate info = gradeBll.GetCate(CateID);
                            info.CateID     = CateID;
                            info.CateName   = CateName;
                            info.Remark     = this.txtRemark.Text.Trim();
                            info.GradeAlias = GradeAlias;
                            B_GradeOption.UpdateCate(info);
                        }
                        else
                        {
                            M_GradeCate info = new M_GradeCate();
                            info.CateID     = 0;
                            info.CateName   = CateName;
                            info.Remark     = this.txtRemark.Text.Trim();
                            info.GradeAlias = GradeAlias;
                            B_GradeOption.AddCate(info);
                        }
                        this.txtCateName.Text   = "";
                        this.txtRemark.Text     = "";
                        this.txtGradeField.Text = "";
                        this.HdnCateID.Value    = "0";
                        this.btnSave.Text       = "添加";
                        dBind();
                    }
                }
            }
        }