private void LoadAllCategories() { DataTable dtCategories = ItemCategoryDAL.GetAllCategories(); if (dtCategories.Rows.Count == 0) { return; } this.treeViewAllCategories.Nodes.Clear(); foreach (DataRow dr in dtCategories.Rows) { int catId = StringUtil.GetSafeInt(dr["CategoryId"]); int parentCatId = StringUtil.GetSafeInt(dr["ParentCategoryId"]); string catName = StringUtil.GetSafeString(dr["CategoryName"]); string catSkuPrefix = StringUtil.GetSafeString(dr["CategorySkuPrefix"]); ItemCategoryType catType = new ItemCategoryType(); catType.CategoryId = catId; catType.ParentCategoryId = parentCatId; catType.CategoryName = catName; catType.CategorySkuPrefix = catSkuPrefix; TreeNode newNode = new TreeNode(); newNode.Tag = catType; newNode.Text = catName; newNode.Name = catId.ToString(); if (parentCatId == -1) { this.treeViewAllCategories.Nodes.Add(newNode); } else { TreeNode[] parentNodes = this.treeViewAllCategories.Nodes.Find(parentCatId.ToString(), true); if (parentNodes.Length == 1) { parentNodes[0].Nodes.Add(newNode); } } int catSkuPrefixVal = -1; if (Int32.TryParse(catSkuPrefix, out catSkuPrefixVal) && catSkuPrefixVal > maxSkuPrefix) { maxSkuPrefix = catSkuPrefixVal; } } this.treeViewAllCategories.ExpandAll(); return; }
} // class ItemCompactInfo private void LoadAllCategories() { DataTable dtCategories = ItemCategoryDAL.GetAllCategories(); if (dtCategories.Rows.Count == 0) { return; } this.treeViewItems.Nodes.Clear(); for (int itNum = 0; itNum < 2; ++itNum) { foreach (DataRow dr in dtCategories.Rows) { int catId = (int)dr["CategoryId"]; int parentCatId = (int)dr["ParentCategoryId"]; string catName = dr["CategoryName"].ToString(); ItemCategoryType catType = new ItemCategoryType(); catType.CategoryId = catId; catType.ParentCategoryId = parentCatId; catType.CategoryName = catName; TreeNode newNode = new TreeNode(); newNode.Tag = catType; newNode.Text = catName; newNode.Name = catId.ToString(); if (parentCatId == -1 && itNum == 0) { this.treeViewItems.Nodes.Add(newNode); } else if (parentCatId != -1 && itNum == 1) { TreeNode[] parentNodes = this.treeViewItems.Nodes.Find(parentCatId.ToString(), true); if (parentNodes.Length == 1) { parentNodes[0].Nodes.Add(newNode); } } } } this.treeViewItems.ExpandAll(); return; }