ConstItemDal.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using Cksoft.Data;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using DllEapEntity.Dtos;
  6. using System.Linq;
  7. namespace DllEapDal
  8. {
  9. public class ConstItemDal
  10. {
  11. private IDatabase CurrDb;
  12. public ConstItemDal(IDatabase db)
  13. {
  14. CurrDb = db;
  15. }
  16. public IEnumerable<SelectDto<int>> Get(string dicName)
  17. {
  18. string sql = $"select subId as value,Fname as label from constitem where preid=(select id from constdata where FName='{dicName}')";
  19. return CurrDb.FindList<SelectDto<int>>(sql);
  20. }
  21. public IEnumerable<SelectDto<object>> Get(int dicId)
  22. {
  23. string sql = $"select subId as value,Fname as label from constitem where preid={dicId}";
  24. return CurrDb.FindList<SelectDto<object>>(sql);
  25. }
  26. public IEnumerable<SelectDto<string>> GetProcess()
  27. {
  28. string sql = "select FCode as value,FName as label from TProcess";
  29. return CurrDb.FindList<SelectDto<string>>(sql);
  30. }
  31. /// <summary>
  32. /// 获取分组的select选项
  33. /// </summary>
  34. /// <returns></returns>
  35. public IEnumerable<SelectDto<string>> GetGroupedSelection()
  36. {
  37. var processDal = new TProcessDal(CurrDb);
  38. var processes = processDal.Get();
  39. var macmodelDal = new MacModelDal(CurrDb);
  40. var macmodels = macmodelDal.GetSecMacModels();
  41. var list = new List<SelectDto<string>>();
  42. for (var i = 0; i < processes.Count(); i++)
  43. {
  44. var process = processes.ElementAt(i);
  45. var children = macmodels.Where(c => c.TPCode == process.FCode);
  46. var group = process.FCode;
  47. if (children != null && children.Count() > 0)
  48. {
  49. foreach (var item in children)
  50. {
  51. if (list.Count == 0 || list.FirstOrDefault(c => c.Label == item.FCode) == null)
  52. {
  53. list.Add(new SelectDto<string>() { Label = item.FCode, Value = item.FCode, Group = group });
  54. }
  55. }
  56. }
  57. }
  58. return list;
  59. }
  60. }
  61. }