private void PopulateCatTree() { ProductTree.Nodes.Clear(); if (Convert.ToInt32(lkCommodityTypes.EditValue) == BLL.Type.Constants.Pharmacuticals) { Category cat = new Category(); SubCategory subCat = new SubCategory(); Product prod = new Product(); cat.LoadAll(); cat.Sort = "CategoryName"; ProductTree.Nodes.Add("All0", "All"); foreach (DataRowView dv in cat.DefaultView) { TreeNode nodes = new TreeNode(); nodes.Name = "cat" + dv["ID"].ToString(); nodes.Text = dv["CategoryName"].ToString() + " (" + dv["CategoryCode"].ToString() + ")"; nodes.ToolTipText = "Double Click to List"; subCat.GetSubCategory(Convert.ToInt32(dv["ID"])); subCat.Sort = "SubCategoryName"; foreach (DataRowView subDv in subCat.DefaultView) { TreeNode subNodes = new TreeNode(); subNodes.Name = "sub" + subDv["ID"].ToString(); subNodes.Text = subDv["SubCategoryName"].ToString() + " (" + subDv["SubCategoryCode"].ToString() + ")"; subNodes.ToolTipText = "Double Click to List"; nodes.Nodes.Add(subNodes); } ProductTree.Nodes[0].Nodes.Add(nodes); } ProductTree.Nodes[0].Expand(); } else { SupplyCategory scat = new SupplyCategory(); scat.LoadAll(); scat.Sort = "Name"; ProductTree.Nodes.Add("Als0", "All"); foreach (DataRowView dv in scat.DefaultView) { TreeNode nodes = new TreeNode(); nodes.Name = "sup" + dv["ID"].ToString(); nodes.Text = dv["Name"].ToString(); nodes.ToolTipText = "Double Click to List"; ProductTree.Nodes[0].Nodes.Add(nodes); } ProductTree.Nodes[0].Expand(); } }
private void PopulateCatTree(String Type) { if (Type == "Drug") { Category cat = new Category(); treeCategory.DataSource = cat.GetCategoryTree(); } else { SupplyCategory subCat = new SupplyCategory(); treeCategory.DataSource = subCat.GetAllSupplyCategories(); } }
/// <summary> /// Handles the saving of supply category /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSaveSupCat_Click(object sender, EventArgs e) { if (txtSupCat.Text != "") { SupplyCategory supCat = new SupplyCategory(); if (_supCatId == 0) supCat.AddNew(); else supCat.LoadByPrimaryKey(_supCatId); supCat.Name = txtSupCat.Text; supCat.Code = txtSupCode.Text; supCat.ParentId = ((cboSupCat.Visible) ? Convert.ToInt32(cboSupCat.SelectedValue) : 0); supCat.Save(); PopulateSupplyCatTree(); } }
/// <summary> /// Populates the CatTree /// </summary> private void PopulateCatTree() { SupplyCategory suppCategory = new SupplyCategory(); treeCategory.DataSource = suppCategory.GetAllSupplyCategories(); }
/// <summary> /// Handles the treeSupCategory focused node changed and updates the form accordingly /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void treeSupCategory_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { SupplyCategory supCat = new SupplyCategory(); string value = treeSupCategory.Selection[0].GetValue("ID").ToString(); int categoryId = Convert.ToInt32(value.Substring(1)); supCat.LoadByPrimaryKey(categoryId); if (supCat.ParentId != 0) { cboSupCat.Visible = true; lblSupCat.Text = "Sub Category"; cboSupCat.SelectedValue = Convert.ToInt32(supCat.ParentId); } else { cboSupCat.Visible = false; lblSupCat.Text = "Main Category"; } txtSupCat.Text = supCat.Name; txtSupCode.Text = supCat.Code; _supCatId = supCat.ID; btnSave.Text = "Update"; }