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.

129 lines
5.5 KiB

3 weeks ago
  1. using NFine.Data.Extensions;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Text;
  6. using NFine.Repository;
  7. using System.Data.Common;
  8. using NFine.Domain._03_Entity.SRM;
  9. using Newtonsoft.Json;
  10. using System.Configuration;
  11. using Newtonsoft.Json.Linq;
  12. using System.Net;
  13. using System.IO;
  14. using NFine.Domain._03_Entity.WMS;
  15. namespace NFine.Application.WMS
  16. {
  17. public class DeleteArrivalDocApp : RepositoryFactory<ICSVendor>
  18. {
  19. //删除采购到货单
  20. public string DeleteICSDeliveryNotice(string keyValue)
  21. {
  22. //站点信息
  23. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  24. string msg = "";
  25. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  26. string sql = string.Empty;
  27. string sqlSeach = string.Format(@"SELECT h.* FROM ICSDeliveryNotice a
  28. inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
  29. inner JOIN ICSInspection h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint
  30. WHERE a.DNCode IN ({0}) and a.WorkPoint in ('{1}')
  31. ", keyValue.TrimEnd(','), WorkPoint);
  32. DataTable dtASN = SqlHelper.GetDataTableBySql(sqlSeach);
  33. if (dtASN != null && dtASN.Rows.Count > 0)
  34. {
  35. msg = "所选单据已生成检验单,无法删除!";
  36. }
  37. sqlSeach = string.Format(@"SELECT h.* FROM ICSDeliveryNotice a
  38. inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
  39. inner JOIN ICSWareHouseLotInfo h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint
  40. WHERE a.DNCode IN ({0}) and a.WorkPoint in ('{1}')
  41. ", keyValue.TrimEnd(','), WorkPoint);
  42. DataTable dtCarton = SqlHelper.GetDataTableBySql(sqlSeach);
  43. if (dtCarton != null && dtCarton.Rows.Count > 0)
  44. {
  45. msg += "所选单据已入库,无法删除!";
  46. }
  47. sql += string.Format(@" update b set b.DNQuantity=0,b.DNAmount=0
  48. from ICSDeliveryNotice a
  49. inner join ICSASNDetail b on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
  50. where a.DNCode IN ({0}) and a.WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  51. sql += string.Format(@"DELETE FROM dbo.ICSDeliveryNotice WHERE DNCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  52. try
  53. {
  54. SqlHelper.ExecuteNonQuery(sql);
  55. }
  56. catch (Exception ex)
  57. {
  58. throw new Exception(ex.Message);
  59. }
  60. return msg;
  61. }
  62. //删除委外采购到货单
  63. public string DeleteICSODeliveryNotice(string keyValue)
  64. {
  65. //站点信息
  66. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  67. string msg = "";
  68. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  69. string sql = string.Empty;
  70. string sqlSeach = string.Format(@"SELECT h.* FROM ICSODeliveryNotice a
  71. inner JOIN ICSOASNDetail b ON a.OASNCode=b.OASNCode AND a.WorkPoint=b.WorkPoint
  72. inner JOIN ICSInspection h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint
  73. WHERE a.ODNCode IN ({0}) and a.WorkPoint in ('{1}')
  74. ", keyValue.TrimEnd(','), WorkPoint);
  75. DataTable dtASN = SqlHelper.GetDataTableBySql(sqlSeach);
  76. if (dtASN != null && dtASN.Rows.Count > 0)
  77. {
  78. msg = "所选单据已生成检验单,无法删除!";
  79. }
  80. sqlSeach = string.Format(@"SELECT h.* FROM ICSODeliveryNotice a
  81. inner JOIN ICSOASNDetail b ON a.OASNCode=b.OASNCode AND a.WorkPoint=b.WorkPoint
  82. inner JOIN ICSWareHouseLotInfo h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint
  83. WHERE a.ODNCode IN ({0}) and a.WorkPoint in ('{1}')
  84. ", keyValue.TrimEnd(','), WorkPoint);
  85. DataTable dtCarton = SqlHelper.GetDataTableBySql(sqlSeach);
  86. if (dtCarton != null && dtCarton.Rows.Count > 0)
  87. {
  88. msg = "所选单据已入库,无法删除!";
  89. }
  90. sql += string.Format(@" update b set b.ODNQuantity=0,b.ODNAmount=0
  91. from ICSODeliveryNotice a
  92. inner join ICSOASNDetail b on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPoint
  93. where a.ODNCode IN ({0}) and a.WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  94. sql += string.Format(@"DELETE FROM dbo.ICSODeliveryNotice WHERE ODNCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  95. try
  96. {
  97. SqlHelper.ExecuteNonQuery(sql);
  98. }
  99. catch (Exception ex)
  100. {
  101. throw new Exception(ex.Message);
  102. }
  103. return msg;
  104. }
  105. }
  106. }