Example #1
0
    protected void btnPost_Click(object sender, EventArgs e)
    {
        ProductCategory category = null;

        if (action == OperateType.Add)
        {
            category            = new ProductCategory();
            category.ParentID   = parentID;
            category.PropertyID = propertyID;
        }
        else
        {
            category = ProductCategories.GetCategory(id);
        }
        category.CategoryName = txtCategoryName.Text;
        category.CategoryDesc = txtCategoryDesc.Text;
        category.DisplayOrder = Convert.ToInt32(txtDisplayOrder.Text);
        if (action == OperateType.Add)
        {
            DataActionStatus status = ProductCategories.Create(category);
            switch (status)
            {
            case DataActionStatus.DuplicateName:
                mbMsg.ShowMsg("新增产品分类失败,存在同名产品分类!");
                break;

            case DataActionStatus.UnknownFailure:
                mbMsg.ShowMsg("新增产品分类失败,请联系管理员!");
                break;

            case DataActionStatus.Success:
            default:
                base.ExecuteJs("msg('操作成功,已成功增加一个新的产品分类!',true);", false);
                break;
            }
        }
        else
        {
            DataActionStatus status = ProductCategories.Update(category);
            switch (status)
            {
            case DataActionStatus.DuplicateName:
                mbMsg.ShowMsg("修改产品分类失败,存在同名产品分类!");
                break;

            case DataActionStatus.UnknownFailure:
                mbMsg.ShowMsg("修改产品分类失败,请联系管理员!");
                break;

            case DataActionStatus.Success:
            default:
                base.ExecuteJs("msg('操作成功,已成功修改产品分类信息!',true);", false);
                break;
            }
        }
    }