private void AddCategoryMenuItem_Click(object sender, EventArgs e) { try { Category category = new Category(); category.CategoryName = "新类别"; if (CurrentNode.Level != 0) { category.Parent = (Category)CurrentNode.Tag; } else { category.Parent = null; } SystemVariable.CategoryService.Add(category); System.Windows.Forms.TreeNode node = TreeViewManager.AddNode(category, CurrentNode, false); CurrentNode.Expand(); node.BeginEdit(); } catch (Exception ex) { Toast.Show(ex.Message); } }
/// <summary> /// 添加节点 /// </summary> /// <param name="category">类别</param> /// <param name="parent">父节点</param> /// <param name="isIteration">是否循环迭代添加子节点</param> /// <returns></returns> public static TreeNode AddNode(Category category, TreeNode parent, bool isIteration) { TreeNode newNode = new TreeNode(category.CategoryName); newNode.Tag = category; parent.Nodes.Add(newNode); if (isIteration) { foreach (var item in SystemVariable.CategoryList) { if (item.Parent == category) { AddNode(item, newNode, true); } } } return newNode; }
private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { try { if (e.Node.Level != 0) { Category = (Category)e.Node.Tag; this.DialogResult = DialogResult.OK; this.Hide(); } } catch (Exception ex) { Toast.Show(ex.Message); } }
private void LoadProductList(Category category,string productNumber,string barcode) { try { List<DataFilter> filters = new List<DataFilter>(); productListDataGridView.DataSource = SystemVariable.ProductService.GetProductViewList(null, filters); } catch (Exception ex) { Toast.Show(ex.Message); } }