using System; using System.Collections.Generic; using System.Linq; using System.Text; using Cksoft.Data; using DllEapEntity; namespace DllScan.DAL { public class OrderMstDal { public IDatabase CurrDb; public OrderMstDal(IDatabase db) { CurrDb = db; } public IEnumerable GetOrderMsts() { string errorinfo = string.Empty; return CurrDb.FindListForCondition(string.Empty, ref errorinfo); } public IEnumerable GetMacModels() { string errorinfo = string.Empty; return CurrDb.FindListForCondition(string.Empty, ref errorinfo); } /// /// 获取左侧树结构数据 /// /// public IEnumerable GetTreeModels() { var root = new TreeModel() { Id = 0, Name = "根节点", Open = false, IsParent = true }; var macModels = GetMacModels(); var ordermsts = GetOrderMsts(); if (macModels != null && macModels.Count() > 0) { var secendChildren = new List(); foreach (var item in macModels) { var macChild = new TreeModel() { Id = 0, Name = item.FCode, Open = false, IsParent = true }; var orders = ordermsts.Where(c => c.MModeID == item.ID); if (orders != null && orders.Count() > 0) { var thirds = new List(); foreach (var order in orders) { thirds.Add(new TreeModel { Id = order.ID, Name =order.FCode+"/"+ order.FName, Children = null }); } macChild.Children = thirds; } secendChildren.Add(macChild); } root.Children = secendChildren; } var firsts = new List(); firsts.Add(root); return firsts; } } }