コード例 #1
0
    // not used
    public static ArrayList getChildCats(int catId, ArrayList arrCurrentChilds)
    {

        DataView dv = (DataView)HttpContext.Current.Application["dvvisiblecategoriesorderbyparent"];

        ArrayList arrChilds;
        if (arrCurrentChilds == null)
        {
            arrChilds = new ArrayList();
        }
        else
            arrChilds = arrCurrentChilds;



        DataRowView [] foundrows = dv.FindRows(catId);




        ArrayList arrTmpChilds = new ArrayList();
        foreach (DataRowView row in foundrows)
        {
            Category cat = new Category();
            cat.Id = Convert.ToInt32(row["CAT_ID"].ToString());
            cat.Name = row["CAT_NOME"].ToString();
            cat.ParentId = catId;
            arrTmpChilds.Add(cat);
        }



        foreach (Category cat in arrTmpChilds)
        {
            arrChilds.Add(cat);
            getChildCats(cat.Id, arrChilds);
        }

        return arrChilds;
    }
コード例 #2
0
    public static ArrayList getPathCat(int catId, ArrayList currentPath)
    {





        ArrayList arrPath;
        if (currentPath == null)
        {
            arrPath = new ArrayList();
        }
        else
            arrPath = currentPath;





        DataView dv = (DataView)HttpContext.Current.Application["dvvisiblecategoriesorderbyid"];

        if (dv == null)
        {


        }

        int indicefound = dv.Find(catId);
        DataRowView rigafound = dv[indicefound];

        Category cat = new Category();
        cat.Id = catId;
        cat.Name = rigafound["cat_nome"].ToString();
        cat.ParentId = Convert.ToInt32(rigafound["cat_idpadre"]);
        arrPath.Add(cat);
        if (cat.ParentId > 0)
        {
            getPathCat(cat.ParentId, arrPath);
        }
        


        ArrayList tmpPath = new ArrayList();
        Category root = new Category();
        root.Id = 0;
        tmpPath.Add(root);		// add root path
        for (int i = 0; i < arrPath.Count; i++)
        {
            tmpPath.Add(arrPath[arrPath.Count - 1 - i]);
        }

        arrPath = tmpPath;
        return arrPath;
    }
コード例 #3
0
    public static ArrayList getPathCat(int catId, ArrayList currentPath)
    {


        ArrayList arrPath;
        if (currentPath == null)
        {
            arrPath = new ArrayList();
        }
        else
            arrPath = currentPath;



        string sql = "select * from tcategorie where cat_id=@idpadre";
        DataTable dt = simplestecommerce.helpDb.getDataTable(sql, new SqlParameter("idpadre", catId));
        DataRow dr = dt.Rows[0];


        Category cat = new Category();
        cat.Id = catId;
        cat.Name = dr["cat_nome"].ToString();
        cat.ParentId = Convert.ToInt32(dr["cat_idpadre"]);
        arrPath.Add(cat);
        if (cat.ParentId > 0)
        {
            getPathCat(cat.ParentId, arrPath);
        }
        


        ArrayList tmpPath = new ArrayList();
        Category root = new Category();
        root.Id = 0;
        tmpPath.Add(root);		// add root path
        for (int i = 0; i < arrPath.Count; i++)
        {
            tmpPath.Add(arrPath[arrPath.Count - 1 - i]);
        }

        arrPath = tmpPath;
        return arrPath;
    }
コード例 #4
0
            public static ArrayList GetCategoriesTree(Category cat, ArrayList arrCat, int excludedId)
            {


                if (arrCat==null) {
                    
                    arrCat = new ArrayList();
                }


                if (cat == null)
                {

                    cat = new Category();
                    cat.Id = 0;

                }


                string sql = "select * from tcategorie where cat_idpadre=@idcat and cat_id<>@excludedid order by cat_nome";
                DataTable dt = simplestecommerce.helpDb.getDataTable(
                    sql,
                    new SqlParameter("idcat", cat.Id),
                    new SqlParameter("excludedid", excludedId)
                    );
                
                
                foreach (DataRow riga in dt.Rows)
                {

                    Category c = new Category();

                    

                    c.Id = (int)riga["cat_id"]; ;







                    c.Name += cat.Name;

                    if (c.Name.Length > 0) c.Name += "-->";
                    
                    c.Name+=simplestecommerce.lingua.getinadminlanguagefromdb(riga["cat_nome"].ToString());

                    arrCat.Add(c);


                    
                    GetCategoriesTree(c, arrCat, excludedId);
                }
             




                return arrCat;
            }
コード例 #5
0
            // ricorsiva
            public static ArrayList getRamo(int parentId, ArrayList arrCat)
            {
                
                                
                if ( arrCat==null) arrCat = new ArrayList();


                string sql = "select * from tcategorie where cat_idpadre=@idpadre";
                DataTable dt = simplestecommerce.helpDb.getDataTable(sql, new SqlParameter("idpadre", parentId));
                
                              

                foreach ( DataRow riga in dt.Rows) 
                {
                    Category cat = new Category();
                    cat.Id = Convert.ToInt32(riga["CAT_ID"].ToString());
                    cat.ParentId = parentId;
                    cat.Name = riga["CAT_NOME"].ToString();
                    cat.img = riga["cat_img"].ToString();
                    cat.Level = (parentId == 0 ? 0 : 1);
                    cat.visibile = !(bool)(riga["cat_nascondi"]);
                    arrCat.Add(cat);

                    getRamo(cat.Id, arrCat);
                }




                return arrCat;
            }