public void InitChild(IEnumerable <ProductCategoryDto> childInfos, int psn = 0, int grade = 1) { var result = childInfos.Where(o => o.CategoryPSN == psn && o.Grade == grade); foreach (var item in result) { var child = new TreeViewItemForMenuModel() { CategoryPSN = item.CategoryPSN, CategorySN = item.CategorySN, Content = "[" + item.CategorySN.ToString("00") + "] " + item.Title, Grade = item.Grade, EnableShowCheckBox = System.Windows.Visibility.Visible }; child.InitChild(childInfos, item.CategorySN, grade + 1); Children.Add(child); } this.SetChildrenChanged(); }
public BarcodePrintModel() { PageIndex = 1; PageSize = 50; if (string.IsNullOrEmpty(SystemConfiguration.Current.ServerUrl)) { MessageBox.Show("未能获取服务器位置。"); return; } categoryTreeModel = new List <TreeViewItemForMenuModel>() { new TreeViewItemForMenuModel() { CategoryPSN = -1, CategorySN = -1, Content = "全部", EnableShowCheckBox = System.Windows.Visibility.Visible } }; new HttpRequestHelper().GetRequst <List <ProductCategoryDto> >(SystemConfiguration.Current.ServerUrl + getProductCategoryUrl, null, null, new Action <IEnumerable <ProductCategoryDto> >((o) => { Application.Current.Dispatcher.Invoke(new Action(() => { var tree = new TreeViewItemForMenuModel() { CategoryPSN = -1, CategorySN = -1, Content = "全部", Grade = -1, EnableShowCheckBox = System.Windows.Visibility.Visible }; tree.Children.Add(new TreeViewItemForMenuModel() { CategoryPSN = -10, CategorySN = -10, Content = "捆绑商品", Grade = -10, EnableShowCheckBox = System.Windows.Visibility.Visible }); tree.InitChild(o); CategoryTreeModel = new List <TreeViewItemForMenuModel>() { tree }; })); })); new HttpRequestHelper().GetRequst <List <StoreDto> >(SystemConfiguration.Current.ServerUrl + getSupplierUrl, null, null, new Action <IEnumerable <StoreDto> >((o) => { Application.Current.Dispatcher.Invoke(new Action(() => { List <StoreDto> result = new List <StoreDto>() { new StoreDto() { StoreId = "-1", Title = "全部" } }; Store = "-1"; if (o != null && o.Count() > 0) { result.AddRange(o); } StoresSelectItem = result; this.OnPropertyChanged(p => p.StoresSelectItem); this.OnPropertyChanged(p => p.Store); })); })); new HttpRequestHelper().GetRequst <List <ProductBrandDto> >(SystemConfiguration.Current.ServerUrl + getProductBrand, null, null, new Action <IEnumerable <ProductBrandDto> >((o) => { Application.Current.Dispatcher.Invoke(new Action(() => { List <ProductBrandDto> result = new List <ProductBrandDto>() { new ProductBrandDto() { BrandSN = -1, Title = "全部" } }; ProductBrand = -1; if (o != null && o.Count() > 0) { result.AddRange(o); } ProductBrandSelectItem = result; this.OnPropertyChanged(p => p.ProductBrandSelectItem); this.OnPropertyChanged(p => p.ProductBrand); })); })); }