纽威
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.

99 lines
3.6 KiB

3 years ago
  1. using NFine.Code;
  2. using NFine.Data.Extensions;
  3. using NFine.Domain.Entity.ProductManage;
  4. using NFine.Domain.IRepository.ProductManage;
  5. using NFine.Repository.ProductManage;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Linq;
  10. namespace NFine.Application.ProductManage
  11. {
  12. public class DiscountRateApp
  13. {
  14. private IICSDiscountRateRepository service = new DiscountRateRepository();
  15. public List<ICSDiscountRateEntity> GetList(Pagination pagination, string queryJson)
  16. {
  17. var expression = ExtLinq.True<ICSDiscountRateEntity>();
  18. var queryParam = queryJson.ToJObject();
  19. if (!queryParam["keyword"].IsEmpty())
  20. {
  21. string keyword = queryParam["keyword"].ToString();
  22. expression = expression.And(t => t.CusCode.Contains(keyword));
  23. }
  24. expression = expression.And(t => t.CusCode != "RapaPort");
  25. return service.FindList(expression, pagination).OrderBy(t => t.CusCode).ThenBy(t => t.WHType)
  26. .ThenBy(t => t.StartValue).ToList();
  27. }
  28. public DataTable GetListForCustomer()
  29. {
  30. DataTable dt = new DataTable();
  31. string sql = @"SELECT F_CusCode,F_CusName FROM Sys_Customer WHERE F_CusCode
  32. NOT IN (SELECT DISTINCT CusCode FROM ICSDiscountRate WHERE CusCode <> 'RapaPort')";
  33. dt = SqlHelper.GetDataTableBySql(sql);
  34. if (dt == null || dt.Rows.Count <= 0)
  35. throw new Exception("No exportable data.");
  36. return dt;
  37. }
  38. public List<ICSDiscountRateEntity> GetList2(Pagination pagination, string queryJson)
  39. {
  40. var expression = ExtLinq.True<ICSDiscountRateEntity>();
  41. var queryParam = queryJson.ToJObject();
  42. if (!queryParam["keyword"].IsEmpty())
  43. {
  44. string keyword = queryParam["keyword"].ToString();
  45. expression = expression.And(t => t.CusCode.Contains(keyword));
  46. }
  47. expression = expression.And(t => t.CusCode == "RapaPort");
  48. return service.FindList(expression, pagination).OrderBy(t => t.CusCode).ThenBy(t => t.WHType)
  49. .ThenBy(t => t.StartValue).ToList();
  50. }
  51. public ICSDiscountRateEntity GetForm(string keyValue)
  52. {
  53. return service.FindEntity(keyValue);
  54. }
  55. public void DeleteForm(string keyValue)
  56. {
  57. ICSDiscountRateEntity entity = service.FindEntity(t => t.F_Id == keyValue);
  58. service.Delete(t => t.CusCode == entity.CusCode);
  59. //service.Delete(t => t.F_Id == keyValue);
  60. }
  61. public void SubmitForm(ICSDiscountRateEntity productEntity, string keyValue)
  62. {
  63. if (!string.IsNullOrEmpty(keyValue))
  64. {
  65. productEntity.Modify(keyValue);
  66. service.Update(productEntity);
  67. }
  68. else
  69. {
  70. productEntity.Create();
  71. service.Insert(productEntity);
  72. }
  73. }
  74. public void SubmitForm(List<ICSDiscountRateEntity> discountrateListEntity, string keyValue)
  75. {
  76. foreach (ICSDiscountRateEntity discountrateEntity in discountrateListEntity)
  77. {
  78. if (!string.IsNullOrEmpty(keyValue))
  79. {
  80. discountrateEntity.Modify(keyValue);
  81. service.Update(discountrateEntity);
  82. }
  83. else
  84. {
  85. discountrateEntity.Create();
  86. service.Insert(discountrateEntity);
  87. }
  88. }
  89. }
  90. }
  91. }