protected void btnAdd_Click(object sender, EventArgs e)
        {
            string ErrorMessage = String.Empty;
            if (String.IsNullOrEmpty(txtCateName.Text))
            {
                ErrorMessage += "分类名称不可为空";
            }
            if (!String.IsNullOrEmpty(ErrorMessage))
            {
                MessageBox.Show(this,ErrorMessage);
                return;
            }

            MagicCategoryModel model = new MagicCategoryModel();
            MagicCategoryModel ParentModel = bll.GetModel(ParentID);

            model.CategoryID = CommDataHelper.GetNewSerialNum(AppType.MagicWorld) ;
            model.CategoryLevel = ParentModel==null?0:ParentModel.CategoryLevel+1;
            model.CategoryName = txtCateName.Text;
            model.CategoryPath = ParentModel==null?model.CategoryID.ToString():ParentModel.CategoryPath+"/"+model.CategoryID;
            model.IsHide = chkIsHide.Checked;
            model.ParentID = ParentID;
            model.ShowOrder = model.CategoryID;
            model.Status = 0;

            bll.Add(model);

            MessageBox.Show(this,"添加成功!");
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script type=\"text/javascript\">window.parent.location=window.parent.location+'?_=" + DateTime.Now.Ticks + "'</script>");
        }
        public void Update(MagicCategoryModel model)
        {
            DbCommand Command = dbw.GetStoredProcCommand("UP_mwCategory_Update");

            dbw.AddInParameter(Command,"@CategoryID",DbType.Int32,model.CategoryID);
            dbw.AddInParameter(Command,"@CategoryName",DbType.String,model.CategoryName);
            dbw.AddInParameter(Command,"@CategoryPath",DbType.String,model.CategoryPath);
            dbw.AddInParameter(Command,"@Status",DbType.Int16,model.Status);
            dbw.AddInParameter(Command,"@IsHide",DbType.Boolean,model.IsHide);
            dbw.AddInParameter(Command,"@CategoryLevel",DbType.Int32,model.CategoryLevel);
            dbw.AddInParameter(Command,"@ParentID",DbType.Int32,model.ParentID);
            dbw.AddInParameter(Command,"@ShowOrder",DbType.Int32,model.ShowOrder);

            dbw.ExecuteNonQuery(Command);
        }
        private MagicCategoryModel BindModel(DataRow row)
        {
            MagicCategoryModel model = new MagicCategoryModel();

            model.CategoryID = Convert.ToInt32(row["categoryid"]);
            model.CategoryLevel = Convert.ToInt32(row["categorylevel"]);
            model.CategoryName = Convert.ToString(row["categoryname"]);
            model.CategoryPath = Convert.ToString(row["categorypath"]);
            model.IsHide = Convert.ToBoolean(row["ishide"]);
            model.ParentID = Convert.ToInt32(row["parentid"]);
            model.ShowOrder = Convert.ToInt32(row["showorder"]);
            model.Status = Convert.ToInt32(row["status"]);

            return model;
        }