コード例 #1
0
ファイル: Category.cs プロジェクト: kent10636/E-Commerce
        public bool InsertCategory(L_CategoryInfo info)
        {
            string sqlStr = "insert into Category(productCategoryName,parentID,categoryDepth) values('{0}',{1},{2})";

            sqlStr = string.Format(sqlStr, info.ProductCategoryName, info.ParentID, info.CategoryDepth);
            if (SqlHelper.ExecuteNonQuery(CommandType.Text, sqlStr, null) != 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
    protected void btnAddCategory_Click(object sender, EventArgs e)
    {
        L_CategoryInfo info = new L_CategoryInfo();

        info.ProductCategoryName = txtCategoryName.Text;
        info.CategoryDepth       = Convert.ToInt32(ddlLevel.SelectedValue.Split(',')[0]) + 1;
        info.ParentID            = Convert.ToInt32(ddlLevel.SelectedValue.Split(',')[1]);
        if (category.InsertCategory(info))
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", WebUnitily.AlertUrl("添加类别成功"));
            ReSetPage();
        }
        txtCategoryName.Text = "";
    }
コード例 #3
0
    protected void btnedit_Click(object sender, EventArgs e)
    {
        L_CategoryInfo info = new L_CategoryInfo();

        info.ProductCategoryID   = Convert.ToInt32(Request.Form["lbdivid"].ToString());
        info.ProductCategoryName = Request.Form["tbname"].ToString();
        info.CategoryDepth       = Convert.ToInt32(ddldiv.SelectedValue.Split(',')[0]) + 1;
        info.ParentID            = Convert.ToInt32(ddldiv.SelectedValue.Split(',')[1]);
        int step = info.CategoryDepth - Convert.ToInt32(Request.Form["olddepth"].ToString()) - 1;

        if (category.UpdateCategoryByID(info, step))
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", WebUnitily.AlertUrl("修改类别成功"));
            ReSetPage();
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", WebUnitily.AlertUrl("修改类别成功"));
        }
    }
コード例 #4
0
ファイル: Category.cs プロジェクト: kent10636/E-Commerce
        public Collection <L_CategoryInfo> GetSubCategoryById(int categoryID)
        {
            string sqlStr = "select * from Category where parentID={0}";

            sqlStr = string.Format(sqlStr, categoryID);
            DataTable dt = SqlHelper.ExecuteDateSet(CommandType.Text, sqlStr, null).Tables[0];
            Collection <L_CategoryInfo> allCategory = new Collection <L_CategoryInfo>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                L_CategoryInfo categoryinfo = new L_CategoryInfo();
                categoryinfo.ProductCategoryID   = Convert.ToInt32(dt.Rows[i]["productCategoryID"]);
                categoryinfo.ProductCategoryName = dt.Rows[i]["productCategoryName"].ToString();
                categoryinfo.ParentID            = Convert.ToInt32(dt.Rows[i]["parentID"]);
                categoryinfo.CategoryDepth       = Convert.ToInt32(dt.Rows[i]["categoryDepth"]);
                categoryinfo.CategoryDetail      = dt.Rows[i]["categoryDepth"].ToString() + ',' + dt.Rows[i]["productCategoryID"];
                allCategory.Add(categoryinfo);
            }
            return(allCategory);
        }
コード例 #5
0
ファイル: Category.cs プロジェクト: kent10636/E-Commerce
        public bool UpdateCategoryByID(L_CategoryInfo category, int step)
        {
            Collection <L_CategoryInfo> allCategory = new Collection <L_CategoryInfo>();

            GetCategory(allCategory, category.ProductCategoryID);
            try
            {
                string sqlStr = "Update category set ProductCategoryName='{0}',parentID={1},categoryDepth={2} where ProductCategoryID={3}";
                sqlStr = string.Format(sqlStr, category.ProductCategoryName, category.ParentID, category.CategoryDepth, category.ProductCategoryID);
                SqlHelper.ExecuteNonQuery(CommandType.Text, sqlStr, null);
                foreach (L_CategoryInfo categoryinfo in allCategory)
                {
                    sqlStr = "Update category set categoryDepth={0} wher productCategoryID={1}";
                    sqlStr = string.Format(sqlStr, categoryinfo.CategoryDepth + step, categoryinfo.ProductCategoryID);
                    SqlHelper.ExecuteNonQuery(CommandType.Text, sqlStr, null);
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #6
0
 public bool UpdateCategoryByID(L_CategoryInfo categoryAll, int step)
 {
     return(category.UpdateCategoryByID(categoryAll, step));
 }
コード例 #7
0
 public bool InsertCategory(L_CategoryInfo info)
 {
     return(category.InsertCategory(info));
 }