1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- 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<SelectDto<int>> 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<SelectDto<int>>(sql);
- }
- public IEnumerable<SelectDto<object>> Get(int dicId)
- {
- string sql = $"select subId as value,Fname as label from constitem where preid={dicId}";
- return CurrDb.FindList<SelectDto<object>>(sql);
- }
- public IEnumerable<SelectDto<string>> GetProcess()
- {
- string sql = "select FCode as value,FName as label from TProcess";
- return CurrDb.FindList<SelectDto<string>>(sql);
- }
- /// <summary>
- /// 获取分组的select选项
- /// </summary>
- /// <returns></returns>
- public IEnumerable<SelectDto<string>> GetGroupedSelection()
- {
- var processDal = new TProcessDal(CurrDb);
- var processes = processDal.Get();
- var macmodelDal = new MacModelDal(CurrDb);
- var macmodels = macmodelDal.GetSecMacModels();
- var list = new List<SelectDto<string>>();
- 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<string>() { Label = item.FCode, Value = item.FCode, Group = group });
- }
- }
- }
- }
- return list;
- }
- }
- }
|