private void ProductTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { Items itm = new Items(); DataTable dtItem = new DataTable(); string value = ProductTree.SelectedNode.Name; string type = value.Substring(0, 3); int len = value.Length - 3; int categoryId = Convert.ToInt32(value.Substring(3,len)); if (type == "cat") { dtItem = itm.GetItemsByCategory(categoryId); lblState.Text = "All Items under " + ProductTree.SelectedNode.Text + " Category"; } else if(type == "sub") { dtItem = itm.GetItemsBySubCategory(categoryId); lblState.Text = "All Items under " + ProductTree.SelectedNode.Text + " Sub Category"; catID = categoryId; } else if (type == "sup") { dtItem = itm.GetSupplyByCategory(categoryId); lblState.Text = "All Items under " + ProductTree.SelectedNode.Text + " Category"; catID = categoryId; } else if (type == "Als") { dtItem = itm.GetAllSupply(); lblState.Text = "All Items under " + ProductTree.SelectedNode.Text + " Category"; catID = categoryId; } else { dtItem = itm.GetAllItems(1); lblState.Text = "All Items"; } PopulateItemList(dtItem); }
/// <summary> /// Populates Item list based on the selected category in the treeCategory /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void treeCategory_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { DataRowView dr = (DataRowView)treeCategory.GetDataRecordByNode(treeCategory.Selection[0]); Items itm = new Items(); DataTable dtItem; //TODO: filter criteria; string value = dr["ID"].ToString(); string type = value.Substring(0,1); _catId = 0; int categoryId = Convert.ToInt32(value.Substring(1)); dtItem = itm.GetSupplyByCategory(categoryId); toolStripButtonAddItems.Enabled = true; _catId = categoryId; toolStripButtonEditItem.Enabled = false; _selectedSubCat = categoryId; PopulateItemList(dtItem); }