using Cksoft.Data; using System; using System.Collections.Generic; using System.Text; using DllEapEntity.Dtos; using System.Linq; namespace DllEapDal { public class ConstItemDal { private IDatabase CurrDb; public ConstItemDal(IDatabase db) { CurrDb = db; } public IEnumerable> Get(string dicName) { string sql = $"select subId as value,Fname as label from constitem where preid=(select id from constdata where FName='{dicName}')"; return CurrDb.FindList>(sql); } public IEnumerable> Get(int dicId) { string sql = $"select subId as value,Fname as label from constitem where preid={dicId}"; return CurrDb.FindList>(sql); } public IEnumerable> GetProcess() { string sql = "select FCode as value,FName as label from TProcess"; return CurrDb.FindList>(sql); } /// /// 获取分组的select选项 /// /// public IEnumerable> GetGroupedSelection() { var processDal = new TProcessDal(CurrDb); var processes = processDal.Get(); var macmodelDal = new MacModelDal(CurrDb); var macmodels = macmodelDal.GetSecMacModels(); var list = new List>(); for (var i = 0; i < processes.Count(); i++) { var process = processes.ElementAt(i); var children = macmodels.Where(c => c.TPCode == process.FCode); var group = process.FCode; if (children != null && children.Count() > 0) { foreach (var item in children) { if (list.Count == 0 || list.FirstOrDefault(c => c.Label == item.FCode) == null) { list.Add(new SelectDto() { Label = item.FCode, Value = item.FCode, Group = group }); } } } } return list; } } }