爱思开
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.7 KiB

2 years ago
  1. using NFine.Domain.Entity.SystemManage;
  2. using NFine.Domain.IRepository.SystemManage;
  3. using NFine.Repository;
  4. using NFine.Repository.SystemManage;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Linq;
  9. namespace NFine.Application.SystemManage
  10. {
  11. public class OrganizeApp : RepositoryFactory<OrganizeEntity>
  12. {
  13. private IOrganizeRepository service = new OrganizeRepository();
  14. public List<OrganizeEntity> GetList()
  15. {
  16. List<OrganizeEntity> List = service.IQueryable().OrderBy(t => t.F_CreatorTime).ToList();
  17. DataTable dt = GetOrganizeType();
  18. Dictionary<string, string> type = new Dictionary<string, string>();
  19. if (dt != null && dt.Rows.Count > 0)
  20. {
  21. foreach (DataRow dr in dt.Rows)
  22. {
  23. type.Add(dr["F_ItemCode"].ToString(), dr["F_ItemName"].ToString());
  24. }
  25. }
  26. if (List != null && List.Count > 0)
  27. {
  28. for (int i = 0; i < List.Count; i++)
  29. {
  30. List[i].F_CategoryId = type[List[i].F_CategoryId];
  31. }
  32. }
  33. return List;
  34. }
  35. public OrganizeEntity GetForm(string keyValue)
  36. {
  37. return service.FindEntity(keyValue);
  38. }
  39. public DataTable GetOrganizeType()
  40. {
  41. DataTable dt = new DataTable();
  42. string sql = @" SELECT detail.F_ItemCode F_ItemCode ,detail.F_ItemName F_ItemName
  43. FROM Sys_SRM_Items item
  44. inner join Sys_SRM_ItemsDetail detail on detail.F_ItemId=item.F_Id
  45. WHERE item.F_EnCode='OrganizeType'
  46. and detail.F_EnabledMark='1'
  47. order BY detail.F_SortCode
  48. ";
  49. return Repository().FindTableBySql(sql);
  50. }
  51. public void DeleteForm(string keyValue)
  52. {
  53. if (service.IQueryable().Count(t => t.F_ParentId.Equals(keyValue)) > 0)
  54. {
  55. throw new Exception("删除失败!操作的对象包含了下级数据。");
  56. }
  57. else
  58. {
  59. service.Delete(t => t.F_Id == keyValue);
  60. }
  61. }
  62. public void SubmitForm(OrganizeEntity organizeEntity, string keyValue)
  63. {
  64. if (!string.IsNullOrEmpty(keyValue))
  65. {
  66. organizeEntity.Modify(keyValue);
  67. service.Update(organizeEntity);
  68. }
  69. else
  70. {
  71. organizeEntity.Create();
  72. service.Insert(organizeEntity);
  73. }
  74. }
  75. }
  76. }