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.

117 lines
4.4 KiB

  1. using NFine.Data.Extensions;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using NFine.Code;
  9. using NFine.Repository;
  10. using System.Data.Common;
  11. using NFine.Domain._03_Entity.SRM;
  12. using ICS.Application.Entity;
  13. using Newtonsoft.Json;
  14. using System.Configuration;
  15. using System.Data.SqlClient;
  16. using ICS.Data;
  17. using Newtonsoft.Json.Linq;
  18. namespace NFine.Application.WMS
  19. {
  20. public class ZHYSalesDeliveryApp : RepositoryFactory<ICSVendor>
  21. {
  22. public DataTable GetGridJson(string queryJson, ref Pagination jqgridparam)
  23. {
  24. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  25. DataTable dt = new DataTable();
  26. var queryParam = queryJson.ToJObject();
  27. List<DbParameter> parameter = new List<DbParameter>();
  28. string sql = "";
  29. #region [SQL]
  30. sql = @"select a.SDNCode ,a.Sequence,a.SOCode,a.SOSequence,a.CusCode,a.CusName,
  31. a.InvCode,b.InvName,b.InvStd,a.Quantity,c.cFree1,b.InvUnit,b.AmountUnit,a.Amount,a.SDNQuantity,a.CreatePerson,a.CreateDateTime,a.MUSERName,a.MTIME,
  32. case when a.SDNQuantity=0 then '' when a.SDNQuantity=a.Quantity then '' else '' end as Status
  33. from ICSSDN a
  34. left join dbo.ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  35. left join dbo.ICSExtension c on a.ExtensionID=c.ID and a.WorkPoint=c.WorkPoint
  36. where a.Type='1' and a.Status='2' ";
  37. sql = string.Format(sql, WorkPoint);
  38. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  39. #endregion
  40. if (!string.IsNullOrWhiteSpace(queryJson))
  41. {
  42. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  43. {
  44. sql += " and a.SDNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  45. }
  46. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  47. {
  48. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  49. }
  50. if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
  51. {
  52. sql += " and convert(nvarchar(20),a.CreateDateTime,23) >= '" + queryParam["TimeFrom"].ToString() + "' ";
  53. }
  54. if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
  55. {
  56. sql += " and convert(nvarchar(20),a.CreateDateTime,23) <= '" + queryParam["TimeArrive"].ToString() + "' ";
  57. }
  58. if (!string.IsNullOrWhiteSpace(queryParam["Status"].ToString()))
  59. {
  60. string POStatus = queryParam["Status"].ToString();
  61. if (POStatus == "1")
  62. {
  63. sql += " and a.SDNQuantity=a.Quantity ";
  64. }
  65. else if (POStatus == "2")
  66. {
  67. sql += " and a.SDNQuantity=0";
  68. }
  69. else
  70. {
  71. sql += " and a.Quantity-a.SDNQuantity>0 and a.SDNQuantity<>0";
  72. }
  73. }
  74. }
  75. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  76. }
  77. public DataTable GetSalesDeliveryTemp(string queryJson, ref Pagination jqgridparam, string ID)
  78. {
  79. DataTable dt = new DataTable();
  80. string sql = @"select b.ID,b.LotNo,b.Quantity,d.InvUnit,c.Amount,d.AmountUnit,e.BatchCode,e.cFree1,b.MUSERName,b.MTIME from ICSSDN a
  81. inner join dbo.ICSWareHouseLotInfoLog b on a.SDNCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint and b.BusinessCode='19'
  82. left join dbo.ICSInventoryLot c on b.LotNo=c.LotNo and b.WorkPoint=c.WorkPoint
  83. left join dbo.ICSInventory d on c.InvCode=d.InvCode and c.WorkPoint=d.WorkPoint
  84. left join dbo.ICSExtension e on c.ExtensionID=e.ID and c.WorkPoint=e.WorkPoint
  85. where 1=1 ";
  86. if (ID=="")
  87. {
  88. sql+= " and a.SDNCode+a.Sequence='"+ ID + "' ";
  89. }
  90. else
  91. {
  92. sql += "and a.SDNCode+a.Sequence in (" + ID.TrimEnd(',') + ")";
  93. }
  94. return Repository().FindTableBySql(sql.ToString());
  95. }
  96. }
  97. }