예제 #1
0
    protected void InitInfo()
    {
        categoryId = CECRequest.GetQueryInt("categoryid", 0);
        Action     = CECRequest.GetQueryString("action");

        if (Action.ToLower() == "del")
        {
            bool isDelete = ProductCategoryManage.Delete(categoryId);
            if (!isDelete)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "DelError", "alert('该分类可能有字分类,请先删掉子分类!');window.location.href='categorylist.aspx';", true);
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "DeleSuccess", "alert('删除成功!');window.location.href='categorylist.aspx';", true);
            }
            return;
        }

        this.ddlcategoryList.BuildTree(ProductCategoryManage.GetCategoryForTable(), "CategoryName", "CategoryId");
        this.ddlcategoryList.SelectedValue = categoryId.ToString();
        if (Action.ToLower() == "edit")
        {
            categoryInfo = ProductCategoryManage.GetCategoryInfo(categoryId);
            this.ddlcategoryList.SelectedValue = categoryInfo.ParentId.ToString();
        }
    }
예제 #2
0
    void InitInfo()
    {
        this.ddlcategoryList.BuildTree(ProductCategoryManage.GetCategoryForTable(), "CategoryName", "CategoryId");

        categoryId = CECRequest.GetQueryInt("CategoryId", 0);
        this.ddlcategoryList.SelectedValue = this.SqlDataSource_rptList.SelectParameters[0].DefaultValue = categoryId.ToString();
    }
예제 #3
0
    void btnSave_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(this.txtContent.Text))
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "SaveError", "alert('请输入内容!');", true);
            return;
        }
        if (Action.ToLower() == "edit")
        {
            categoryInfo = new ProductCategoryInfo();
            categoryInfo.CategoryName = txtName.Text;
            categoryInfo.Sort         = Convert.ToInt32(txtSort.Text);
            categoryInfo.CategoryId   = categoryId;
            categoryInfo.Content      = this.txtContent.Text;
            categoryInfo.LinkUrl      = this.txtLinkUrl.Text;
            ProductCategoryManage.Update(categoryInfo);
        }
        else
        {
            if (this.ddlcategoryList.SelectedValue != "0")
            {
                int _id = Utils.StrToInt(this.ddlcategoryList.SelectedValue, 0);
                categoryInfo = ProductCategoryManage.GetCategoryInfo(_id);
                if (categoryInfo != null)
                {
                    string parentIdList = string.Empty;
                    if (categoryInfo.ParentIdList == "0")
                    {
                        parentIdList = categoryInfo.CategoryId.ToString();
                    }
                    else
                    {
                        parentIdList = categoryInfo.ParentIdList + "," + categoryInfo.CategoryId;
                    }
                    int       maxOrder = 0;
                    DataTable dt       = ProductCategoryManage.GetSubCategoryListTable(_id);
                    if (dt.Rows.Count > 0)
                    {
                        maxOrder = TypeConverter.ObjectToInt(dt.Compute("Max(Sort)", ""));
                    }
                    else
                    {
                        maxOrder = categoryInfo.Sort;
                    }

                    InsertCategory(_id, categoryInfo.Layer + 1, parentIdList, 0, maxOrder, txtContent.Text);
                    ProductCategoryManage.UpdateSubCategoryCount(_id);
                }
            }
            else
            {
                int maxdisplayorder = TypeConverter.ObjectToInt(ProductCategoryManage.GetCategoryForTable().Compute("Max(Sort)", "")) + 1;
                InsertCategory(0, 0, "0", 0, maxdisplayorder, txtContent.Text);
            }
        }
        Page.ClientScript.RegisterStartupScript(this.GetType(), "SaveSuccess", "alert('添加成功!');window.location.href='postcategory.aspx';", true);
    }
예제 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         DataTable     dt    = ProductCategoryManage.GetCategoryForTable();
         StringBuilder sb    = new StringBuilder();
         string        blank = HttpUtility.HtmlDecode("‖—");
         sb.Append(BindNode("0", dt, blank));
         this.ShowTreeLabel.Text = sb.ToString();
     }
 }
예제 #5
0
    void InitInfo()
    {
        productId  = CECRequest.GetQueryInt("productId", 0);
        action     = CECRequest.GetQueryString("action");
        categoryId = CECRequest.GetQueryInt("categoryid", 0);

        if (action.ToLower() == "del")
        {
            ProductManage.Delete(productId);
            Response.Redirect("productlist.aspx");
            return;
        }
        this.ddlcategoryList.BuildTree(ProductCategoryManage.GetCategoryForTable(), "CategoryName", "CategoryId");
        this.ddlcategoryList.SelectedValue = categoryId.ToString();
    }
예제 #6
0
    void InsertCategory(int parentId, int layer, string parentIdList, int subCategoryCount, int order, string content)
    {
        categoryInfo                  = new ProductCategoryInfo();
        categoryInfo.CategoryId       = categoryId;
        categoryInfo.CategoryName     = txtName.Text;
        categoryInfo.ParentId         = parentId;
        categoryInfo.ParentIdList     = parentIdList;
        categoryInfo.Layer            = layer;
        categoryInfo.SubCategoryCount = subCategoryCount;
        categoryInfo.Sort             = order;
        categoryInfo.Content          = content;
        categoryInfo.LinkUrl          = txtLinkUrl.Text;

        ProductCategoryManage.Insert(categoryInfo);

        this.txtName.Text = string.Empty;
    }