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

2755 lines
170 KiB

3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
  1. using NFine.Data.Extensions;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using NFine.Code;
  6. using NFine.Repository;
  7. using System.Data.Common;
  8. using NFine.Domain._03_Entity.SRM;
  9. using System.Configuration;
  10. using System.Text;
  11. using System.Net;
  12. using Newtonsoft.Json.Linq;
  13. using Newtonsoft.Json;
  14. using System.IO;
  15. using NFine.Domain._03_Entity.WMS;
  16. namespace NFine.Application.WMS
  17. {
  18. public class WMSCreateItemLotApp : RepositoryFactory<ICSVendor>
  19. {
  20. public DataTable GetGridJson(string queryJson, ref Pagination jqgridparam)
  21. {
  22. DataTable dt = new DataTable();
  23. var queryParam = queryJson.ToJObject();
  24. List<DbParameter> parameter = new List<DbParameter>();
  25. object Figure = GetDecimalDigits();
  26. #region [SQL]
  27. string sql = @"select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  28. ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount , CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME , CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  29. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  30. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  31. from ICSMOApplyNegDetail a
  32. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  33. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  34. left join (
  35. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  36. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='1'
  37. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  38. )c
  39. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  40. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  41. where d.Type='1'";
  42. sql = string.Format(sql, Figure);
  43. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  44. #endregion
  45. if (!string.IsNullOrWhiteSpace(queryJson))
  46. {
  47. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  48. {
  49. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  50. }
  51. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  52. {
  53. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  54. }
  55. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  56. {
  57. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  58. }
  59. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  60. {
  61. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  62. }
  63. }
  64. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  65. {
  66. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  67. }
  68. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  69. {
  70. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  71. }
  72. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  73. }
  74. public DataTable GetSubGridJson(string ApplyNegCode, string Sequence, string Type, ref Pagination jqgridparam)
  75. {
  76. DataTable dt = new DataTable();
  77. object Figure = GetDecimalDigits();
  78. List<DbParameter> parameter = new List<DbParameter>();
  79. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  80. string sql = @" select c.TransCode,c.TransSequence ,a.ID,a.LotNo, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity ,a.MUSERName,a.MTIME
  81. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  82. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  83. from ICSInventoryLot a
  84. left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo
  85. group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
  86. left join ICSInventoryLotDetail c on a.LotNo=c.LotNo and a.WorkPoint=c.WorkPoint
  87. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  88. WHERE a.Type='" + Type + "' and c.TransCode='" + ApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in ('" + WorkPoint + "')";
  89. sql = string.Format(sql, Figure);
  90. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  91. }
  92. /// <summary>
  93. /// 点击生成条码
  94. /// </summary>
  95. public DataTable GetSubGridJsonByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  96. {
  97. DataTable dt = new DataTable();
  98. object Figure = GetDecimalDigits();
  99. List<DbParameter> parameter = new List<DbParameter>();
  100. string sql = @" select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity, CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty ,
  101. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  102. from ICSMOApplyNegDetail a
  103. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  104. left join (
  105. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  106. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  107. group by b.TransCode,b.TransSequence
  108. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  109. WHERE 1 =1
  110. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  111. sql += " and a.WorkPoint='" + WorkPoint + "'";
  112. sql = string.Format(sql, Figure);
  113. return Repository().FindTableBySql(sql.ToString());
  114. }
  115. public DataTable GetVendorLotNo(string VenCode, string WorkPoint)
  116. {
  117. DataTable dt = new DataTable();
  118. //var queryParam = queryJson.ToJObject();
  119. List<DbParameter> parameter = new List<DbParameter>();
  120. string dtPre = DateTime.Now.ToString("yyyyMMdd");
  121. string sql = @"EXEC Addins_GetSerialCode '" + WorkPoint + "','ICSITEMLotNo','VendorLotNo','" + VenCode + dtPre + "',2";
  122. return Repository().FindTableBySql(sql.ToString());
  123. }
  124. /// <summary>
  125. /// 生产退料生成条码
  126. /// </summary>
  127. /// <param name="POCode"></param>
  128. /// <param name="PORow"></param>
  129. /// <param name="keyValue"></param>
  130. /// 已改
  131. /// <returns></returns>
  132. public int CreateItemLotNo(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  133. {
  134. var queryParam = keyValue.ToJObject();
  135. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  136. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  137. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  138. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  139. decimal LOTQTY = minPackQty;
  140. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  141. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  142. string Pre = "MDN" + ApplyNegCode + Sequence;
  143. string sql = string.Empty;
  144. //string VendorLot = queryParam["VendorLot"].ToString();
  145. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  146. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  147. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  148. string Colspan = "";
  149. string sqls = string.Empty;
  150. for (int i = 0; i < createPageCount; i++)
  151. {
  152. if (i + 1 == createPageCount)
  153. {
  154. if (minPackQty * createPageCount > thisCreateQty)
  155. {
  156. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  157. }
  158. }
  159. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  160. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  161. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  162. if (ExtensionID == null)
  163. {
  164. ExtensionID = Guid.NewGuid();
  165. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  166. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  167. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  168. MUSER, MUSERNAME, WorkPoints);
  169. }
  170. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  171. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  172. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  173. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  174. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  175. //{
  176. sql += string.Format(@"insert into ICSInventoryLot
  177. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  178. select
  179. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','1','{3}','{4}', getdate(),'{5}','{9}'
  180. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  181. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  182. sql += "\r\n";
  183. //}
  184. }
  185. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  186. return count;
  187. }
  188. public string GetSerialCode(string workPointCode, string tbName, string colName, string Pre, int numLen)
  189. {
  190. string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}";
  191. sql = string.Format(sql, new object[] { workPointCode, tbName, colName, Pre, numLen });
  192. return DbHelper.ExecuteScalar(CommandType.Text, sql).ToString();
  193. }
  194. /// <summary>
  195. /// 删除条码
  196. /// </summary>
  197. /// <param name="keyValue"></param>
  198. /// <returns></returns>
  199. public string DeleteItemLot(string keyValue)
  200. {
  201. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  202. string msg = string.Empty;
  203. string sql = string.Format(@"SELECT * FROM dbo.ICSInspection
  204. WHERE LotNo IN (SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  205. DataTable dtASN = SqlHelper.GetDataTableBySql(sql);
  206. if (dtASN != null && dtASN.Rows.Count > 0)
  207. {
  208. msg = "所选条码已生成检验单,无法删除!";
  209. }
  210. sql = string.Format(@"SELECT * FROM dbo.ICSWareHouseLotInfo WHERE LotNO IN
  211. (SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  212. DataTable dtCarton = SqlHelper.GetDataTableBySql(sql);
  213. if (dtCarton != null && dtCarton.Rows.Count > 0)
  214. {
  215. msg += "所选条码已入库,无法删除!";
  216. }
  217. if (string.IsNullOrEmpty(msg))
  218. {
  219. string sqls = string.Format("DELETE FROM ICSInventoryLotDetail WHERE LotNO IN (select LotNO from ICSInventoryLot where ID in ({0}) ) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  220. sqls += string.Format("DELETE FROM dbo.ICSInventoryLot WHERE ID IN ({0}) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  221. SqlHelper.CmdExecuteNonQueryLi(sqls);
  222. }
  223. return msg;
  224. }
  225. public DataTable GetGridJsonWeiWai(string queryJson, ref Pagination jqgridparam)
  226. {
  227. DataTable dt = new DataTable();
  228. var queryParam = queryJson.ToJObject();
  229. List<DbParameter> parameter = new List<DbParameter>();
  230. object Figure = GetDecimalDigits();
  231. #region [SQL]
  232. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  233. ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount , CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity,a.ExtensionID,a.MUSERName,a.MTIME ,
  234. CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  235. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  236. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  237. from ICSOApplyNegDetail a
  238. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  239. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  240. left join (
  241. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  242. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='2'
  243. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  244. )c
  245. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  246. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  247. WHERE d.Type='1' ";
  248. sql = string.Format(sql, Figure);
  249. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  250. #endregion
  251. if (!string.IsNullOrWhiteSpace(queryJson))
  252. {
  253. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  254. {
  255. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  256. }
  257. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  258. {
  259. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  260. }
  261. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  262. {
  263. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  264. }
  265. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  266. {
  267. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  268. }
  269. }
  270. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  271. {
  272. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  273. }
  274. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  275. {
  276. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  277. }
  278. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  279. }
  280. public DataTable GetSubGridJsonWeiWai(string OApplyNegCode, string Sequence, ref Pagination jqgridparam)
  281. {
  282. DataTable dt = new DataTable();
  283. object Figure = GetDecimalDigits();
  284. //var queryParam = queryJson.ToJObject();
  285. List<DbParameter> parameter = new List<DbParameter>();
  286. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  287. string sql = @" select c.TransCode,c.TransSequence ,a.ID,a.LotNo,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity from ICSInventoryLot a
  288. left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo
  289. group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
  290. left join ICSInventoryLotDetail c on a.LotNo=c.LotNo
  291. WHERE c.TransCode='" + OApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in (" + WorkPoint + ")";
  292. sql = string.Format(sql, Figure);
  293. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  294. }
  295. /// <summary>
  296. /// 点击委外退料生成条码
  297. /// </summary>
  298. public DataTable GetSubGridJsonWeiWaiByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  299. {
  300. DataTable dt = new DataTable();
  301. object Figure = GetDecimalDigits();
  302. List<DbParameter> parameter = new List<DbParameter>();
  303. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  304. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  305. from ICSOApplyNegDetail a
  306. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  307. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  308. left join (
  309. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  310. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  311. group by b.TransCode,b.TransSequence
  312. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  313. WHERE d.Type='1'
  314. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  315. sql += " and a.WorkPoint='" + WorkPoint + "'";
  316. sql = string.Format(sql, Figure);
  317. return Repository().FindTableBySql(sql.ToString());
  318. }
  319. /// <summary>
  320. /// 委外退料生成条码
  321. /// </summary>
  322. /// <param name="POCode"></param>
  323. /// <param name="PORow"></param>
  324. /// <param name="keyValue"></param>
  325. /// 已改
  326. /// <returns></returns>
  327. public int SubmitFormWeiWai(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  328. {
  329. var queryParam = keyValue.ToJObject();
  330. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  331. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  332. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  333. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  334. decimal LOTQTY = minPackQty;
  335. string Pre = "OI" + OApplyNegCode + Sequence;
  336. string sql = string.Empty;
  337. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  338. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  339. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  340. string sqls = string.Empty;
  341. string Colspan = "";
  342. for (int i = 0; i < createPageCount; i++)
  343. {
  344. if (i + 1 == createPageCount)
  345. {
  346. if (minPackQty * createPageCount > thisCreateQty)
  347. {
  348. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  349. }
  350. }
  351. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  352. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  353. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  354. if (ExtensionID == null)
  355. {
  356. ExtensionID = Guid.NewGuid();
  357. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  358. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  359. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  360. MUSER, MUSERNAME, WorkPoints);
  361. }
  362. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  363. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  364. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  365. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  366. sql += string.Format(@"insert into ICSInventoryLot
  367. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  368. select
  369. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','2','{3}','{4}', getdate(),'{5}','{9}'
  370. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  371. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  372. sql += "\r\n";
  373. }
  374. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  375. return count;
  376. }
  377. public DataTable GetGridJsonChengPing(string queryJson, ref Pagination jqgridparam)
  378. {
  379. DataTable dt = new DataTable();
  380. var queryParam = queryJson.ToJObject();
  381. List<DbParameter> parameter = new List<DbParameter>();
  382. object Figure = GetDecimalDigits();
  383. #region [SQL]
  384. string sql = @" select a.ID, a.MODetailID,a.MOCode,a.Sequence, CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity ,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,a.StartDate
  385. ,a.DueDate,a.MOStatus,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  386. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  387. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  388. from ICSMO a
  389. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  390. left join (
  391. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  392. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='3'
  393. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  394. )c
  395. on a.MOCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  396. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint ";
  397. sql += " WHERE 1=1";
  398. sql = string.Format(sql, Figure);
  399. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  400. #endregion
  401. if (!string.IsNullOrWhiteSpace(queryJson))
  402. {
  403. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  404. {
  405. sql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  406. }
  407. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  408. {
  409. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  410. }
  411. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  412. {
  413. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  414. }
  415. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  416. {
  417. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  418. }
  419. }
  420. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  421. {
  422. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  423. }
  424. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  425. {
  426. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  427. }
  428. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  429. }
  430. /// <summary>
  431. /// 点击成品生成条码(成品)
  432. /// </summary>
  433. public DataTable GetSubGridJsonChengPingByCreate(string MOCode, string Sequence, string WorkPoint)
  434. {
  435. DataTable dt = new DataTable();
  436. object Figure = GetDecimalDigits();
  437. List<DbParameter> parameter = new List<DbParameter>();
  438. string sql = @"select d.Enable, a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  439. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  440. from ICSMO a
  441. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  442. left join (
  443. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  444. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  445. group by b.TransCode,b.TransSequence
  446. ) c on a.MOCode=c.TransCode and a.Sequence=c.TransSequence
  447. left join ICSConfiguration d on d.Code='CompleteVerification'
  448. WHERE 1 =1
  449. and a.MOCode='" + MOCode + "' and a.Sequence='" + Sequence + "'";
  450. sql += " and a.WorkPoint='" + WorkPoint + "'";
  451. sql = string.Format(sql, Figure);
  452. return Repository().FindTableBySql(sql.ToString());
  453. }
  454. /// <summary>
  455. /// 成品生成条码
  456. /// </summary>
  457. /// <param name="POCode"></param>
  458. /// <param name="PORow"></param>
  459. /// <param name="keyValue"></param>
  460. /// 已改
  461. /// <returns></returns>
  462. public int SubmitFormChengPing(string MOCode, string Sequence, string keyValue, string WorkPoint)
  463. {
  464. var queryParam = keyValue.ToJObject();
  465. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  466. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  467. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  468. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  469. decimal LOTQTY = minPackQty;
  470. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  471. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  472. string Pre = "CP" + MOCode + Sequence;
  473. string sql = string.Empty;
  474. //string VendorLot = queryParam["VendorLot"].ToString();
  475. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  476. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  477. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  478. string sqls = string.Empty;
  479. string Colspan = "";
  480. for (int i = 0; i < createPageCount; i++)
  481. {
  482. if (i + 1 == createPageCount)
  483. {
  484. if (minPackQty * createPageCount > thisCreateQty)
  485. {
  486. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  487. }
  488. }
  489. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  490. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  491. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  492. if (ExtensionID == null)
  493. {
  494. ExtensionID = Guid.NewGuid();
  495. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  496. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  497. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  498. MUSER, MUSERNAME, WorkPoints);
  499. }
  500. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  501. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  502. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  503. LotNo, MOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  504. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  505. //{
  506. sql += string.Format(@"insert into ICSInventoryLot
  507. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  508. select
  509. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','3','{3}','{4}', getdate(),'{5}','{9}'
  510. from ICSMO where MOCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  511. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, MOCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  512. sql += "\r\n";
  513. //}
  514. }
  515. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  516. return count;
  517. }
  518. /// <summary>
  519. /// 销售退货单
  520. /// </summary>
  521. /// <param name="queryJson"></param>
  522. /// <param name="jqgridparam"></param>
  523. /// <returns></returns>
  524. public DataTable GetGridJsonXiaoShou(string queryJson, ref Pagination jqgridparam)
  525. {
  526. DataTable dt = new DataTable();
  527. var queryParam = queryJson.ToJObject();
  528. List<DbParameter> parameter = new List<DbParameter>();
  529. object Figure = GetDecimalDigits();
  530. #region [SQL]
  531. string sql = @" select a.ID,a.SDNCode,a.Sequence,a.SOCode,a.SOSequence,a.CusCode,a.CusName,a.Type,a.ArriveDate,a.InvCode,a.WHCode,detail.LocationCode AS Area,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  532. ,cast(a.Amount as decimal(18,{0})) as Amount, CAST(a.SDNQuantity AS DECIMAL(18,{0})) as SDNQuantity ,a.Status,a.ExtensionID,a.CreatePerson,a.CreateDateTime ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  533. ,a.WorkPoint,a.Points,a.DeliveryType,a.DeliveryDescribe,a.InvDescribe,a.OtherDescribe,a.SalesUnit,a.StockIndicator,a.IsSerialNumber
  534. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  535. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  536. from ICSSDN a
  537. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  538. LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  539. left join (
  540. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  541. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='4'
  542. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  543. )c
  544. on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  545. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  546. where a.Type='2'";
  547. sql = string.Format(sql, Figure);
  548. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  549. #endregion
  550. if (!string.IsNullOrWhiteSpace(queryJson))
  551. {
  552. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  553. {
  554. sql += " and a.SDNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  555. }
  556. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  557. {
  558. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  559. }
  560. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  561. {
  562. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  563. }
  564. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  565. {
  566. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  567. }
  568. if (!string.IsNullOrWhiteSpace(queryParam["Location"].ToString()))
  569. {
  570. sql += " and a.WHCode like '%" + queryParam["Location"].ToString() + "%' ";
  571. }
  572. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  573. {
  574. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  575. }
  576. }
  577. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  578. {
  579. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  580. }
  581. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  582. {
  583. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  584. }
  585. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  586. }
  587. /// <summary>
  588. /// 点击销售退货生成条码(销售退货)
  589. /// </summary>
  590. public DataTable GetSubGridJsonXiaoShouByCreate(string SDNCode, string Sequence, string WorkPoint)
  591. {
  592. DataTable dt = new DataTable();
  593. object Figure = GetDecimalDigits();
  594. List<DbParameter> parameter = new List<DbParameter>();
  595. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  596. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  597. from ICSSDN a
  598. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  599. left join (
  600. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  601. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  602. group by b.TransCode,b.TransSequence
  603. ) c on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence
  604. WHERE 1 =1
  605. and a.Type='2' and a.SDNCode='" + SDNCode + "' and a.Sequence='" + Sequence + "'";
  606. sql += " and a.WorkPoint='" + WorkPoint + "'";
  607. sql = string.Format(sql, Figure);
  608. return Repository().FindTableBySql(sql.ToString());
  609. }
  610. /// <summary>
  611. /// 销售退货生成条码
  612. /// </summary>
  613. /// <param name="POCode"></param>
  614. /// <param name="PORow"></param>
  615. /// <param name="keyValue"></param>
  616. /// 已改
  617. /// <returns></returns>
  618. public int SubmitFormXiaoShou(string SDNCode, string Sequence, string keyValue, string WorkPoint)
  619. {
  620. var queryParam = keyValue.ToJObject();
  621. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  622. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  623. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  624. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  625. decimal LOTQTY = minPackQty;
  626. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  627. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  628. string Pre = "SR" + SDNCode + Sequence;
  629. string sql = string.Empty;
  630. //string VendorLot = queryParam["VendorLot"].ToString();
  631. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  632. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  633. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  634. string sqls = string.Empty;
  635. string Colspan = "";
  636. for (int i = 0; i < createPageCount; i++)
  637. {
  638. if (i + 1 == createPageCount)
  639. {
  640. if (minPackQty * createPageCount > thisCreateQty)
  641. {
  642. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  643. }
  644. }
  645. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  646. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  647. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  648. if (ExtensionID == null)
  649. {
  650. ExtensionID = Guid.NewGuid();
  651. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  652. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  653. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  654. MUSER, MUSERNAME, WorkPoints);
  655. }
  656. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  657. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  658. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}')",
  659. LotNo, SDNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  660. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  661. //{
  662. sql += string.Format(@"
  663. insert into ICSInventoryLot
  664. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  665. select
  666. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','4','{3}','{4}', getdate(),'{5}','{9}'
  667. from ICSSDN where Type='2' and SDNCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  668. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, SDNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  669. sql += "\r\n";
  670. //}
  671. }
  672. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  673. return count;
  674. }
  675. public DataTable GetGridJsonQiTa(string queryJson, ref Pagination jqgridparam)
  676. {
  677. DataTable dt = new DataTable();
  678. var queryParam = queryJson.ToJObject();
  679. List<DbParameter> parameter = new List<DbParameter>();
  680. object Figure = GetDecimalDigits();
  681. #region [SQL]
  682. string sql = @" select a.ID,a.InCode,a.Sequence,a.WHCode,a.InvCode,a.WorkPoint,a.OrderType,
  683. a.TypeDescribe,a.CostCenter,a.Remarks,a.PersonNumber,a.InvDescribe,
  684. a.Unit,a.StockIndicator,detail.LocationCode AS Area, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  685. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST(a.Amount AS DECIMAL(18,{0})) as Amount, CAST(a.InQuantity AS DECIMAL(18,{0})) as InQuantity,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  686. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  687. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  688. from ICSOtherIn a
  689. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  690. LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  691. left join (
  692. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  693. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='5'
  694. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  695. )c
  696. on a.InCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  697. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  698. where a.Status='1'";
  699. sql = string.Format(sql, Figure);
  700. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  701. #endregion
  702. if (!string.IsNullOrWhiteSpace(queryJson))
  703. {
  704. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  705. {
  706. sql += " and a.InCode like '%" + queryParam["POCode"].ToString() + "%' ";
  707. }
  708. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  709. {
  710. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  711. }
  712. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  713. {
  714. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  715. }
  716. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  717. {
  718. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  719. }
  720. if (!string.IsNullOrWhiteSpace(queryParam["Location"].ToString()))
  721. {
  722. sql += " and a.WHCode like '%" + queryParam["Location"].ToString() + "%' ";
  723. }
  724. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  725. {
  726. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  727. }
  728. }
  729. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  730. {
  731. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  732. }
  733. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  734. {
  735. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  736. }
  737. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  738. }
  739. /// <summary>
  740. /// 点击销售退货生成条码(其他入库)
  741. /// </summary>
  742. public DataTable GetSubGridJsonQiTaByCreate(string InCode, string Sequence, string WorkPoint)
  743. {
  744. DataTable dt = new DataTable();
  745. object Figure = GetDecimalDigits();
  746. List<DbParameter> parameter = new List<DbParameter>();
  747. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  748. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  749. from ICSOtherIn a
  750. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  751. left join (
  752. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  753. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  754. group by b.TransCode,b.TransSequence
  755. ) c on a.InCode=c.TransCode and a.Sequence=c.TransSequence
  756. WHERE 1 =1
  757. and a.InCode='" + InCode + "' and a.Sequence='" + Sequence + "'";
  758. sql += " and a.WorkPoint='" + WorkPoint + "'";
  759. sql = string.Format(sql, Figure);
  760. return Repository().FindTableBySql(sql.ToString());
  761. }
  762. /// <summary>
  763. /// 其他入库生成条码
  764. /// </summary>
  765. /// <param name="POCode"></param>
  766. /// <param name="PORow"></param>
  767. /// <param name="keyValue"></param>
  768. /// 已改
  769. /// <returns></returns>
  770. public int SubmitFormQiTa(string InCode, string Sequence, string keyValue, string WorkPoint)
  771. {
  772. var queryParam = keyValue.ToJObject();
  773. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  774. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  775. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  776. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  777. decimal LOTQTY = minPackQty;
  778. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  779. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  780. string Pre = "QT" + InCode + Sequence;
  781. string sql = string.Empty;
  782. //string VendorLot = queryParam["VendorLot"].ToString();
  783. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  784. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  785. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  786. string sqls = string.Empty;
  787. string Colspan = "";
  788. for (int i = 0; i < createPageCount; i++)
  789. {
  790. if (i + 1 == createPageCount)
  791. {
  792. if (minPackQty * createPageCount > thisCreateQty)
  793. {
  794. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  795. }
  796. }
  797. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  798. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  799. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  800. if (ExtensionID == null)
  801. {
  802. ExtensionID = Guid.NewGuid();
  803. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  804. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  805. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  806. MUSER, MUSERNAME, WorkPoints);
  807. }
  808. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  809. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  810. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  811. LotNo, InCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  812. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  813. //{
  814. sql += string.Format(@"
  815. insert into ICSInventoryLot
  816. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  817. select
  818. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','5','{3}','{4}', getdate(),'{5}','{9}'
  819. from ICSOtherIn where InCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  820. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, InCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  821. sql += "\r\n";
  822. //}
  823. }
  824. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  825. return count;
  826. }
  827. //归还
  828. public DataTable GetGridJsonGuiHuan(string queryJson, ref Pagination jqgridparam)
  829. {
  830. DataTable dt = new DataTable();
  831. var queryParam = queryJson.ToJObject();
  832. List<DbParameter> parameter = new List<DbParameter>();
  833. object Figure = GetDecimalDigits();
  834. #region [SQL]
  835. string sql = @"select a.ID,a.ReturnCode,a.Sequence,a.WHCode,a.InvCode, detail.LocationCode AS Area, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount, CAST(a.ReturnQuantity AS DECIMAL(18,{0})) as ReturnQuantity,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  836. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  837. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10 from ICSReturn a
  838. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  839. LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  840. left join (
  841. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  842. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='6'
  843. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  844. ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  845. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  846. where a.Status='2'";
  847. sql = string.Format(sql, Figure);
  848. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  849. #endregion
  850. if (!string.IsNullOrWhiteSpace(queryJson))
  851. {
  852. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  853. {
  854. sql += " and a.ReturnCode like '%" + queryParam["POCode"].ToString() + "%' ";
  855. }
  856. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  857. {
  858. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  859. }
  860. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  861. {
  862. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  863. }
  864. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  865. {
  866. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  867. }
  868. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  869. {
  870. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  871. }
  872. }
  873. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  874. {
  875. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  876. }
  877. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  878. {
  879. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  880. }
  881. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  882. }
  883. //审核到货单(采购订单需与审核到货单一起同步)
  884. public DataTable GetGridJsonSHDH(string queryJson, ref Pagination jqgridparam)
  885. {
  886. DataTable dt = new DataTable();
  887. var queryParam = queryJson.ToJObject();
  888. List<DbParameter> parameter = new List<DbParameter>();
  889. object Figure = GetDecimalDigits();
  890. #region [SQL]
  891. string sql = @"select a.ID, '' as 'POCode',-- d.POCode,d.Sequence as POSequence,
  892. '' as POSequence,a.ModificationDate,a.TrackingNumber,a.NonconformingForm,
  893. a.DNCode,a.Sequence,a.VenCode,a.DepCode AS VenName,a.WHCode,a.InvCode,a.DNID,a.DNDetailID,a.WorkPoint,a.InspectionType,a.InvoDescribe,a.Unity,a.StockIndicator, b.InvName,b.InvStd,b.InvDesc,b.InvUnit, b.DrawingNo,
  894. b.Version AS Version1, detail.LocationCode AS Area,
  895. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  896. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  897. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  898. from ICSDeliveryNotice a
  899. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  900. LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  901. left join (
  902. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  903. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='7'
  904. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  905. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  906. -- inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  907. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  908. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  909. where a.DNType='1' and a.Status='2' and a.ASNCode is null
  910. ";
  911. sql = string.Format(sql, Figure);
  912. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  913. #endregion
  914. if (!string.IsNullOrWhiteSpace(queryJson))
  915. {
  916. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  917. {
  918. sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  919. }
  920. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  921. {
  922. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  923. }
  924. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  925. {
  926. sql += " and a.DepCode like '%" + queryParam["VenName"].ToString() + "%' ";
  927. }
  928. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  929. {
  930. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  931. }
  932. if (!string.IsNullOrWhiteSpace(queryParam["Location"].ToString()))
  933. {
  934. sql += " and a.WHCode like '%" + queryParam["Location"].ToString() + "%' ";
  935. }
  936. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  937. {
  938. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  939. }
  940. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  941. {
  942. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  943. }
  944. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  945. {
  946. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  947. }
  948. }
  949. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  950. {
  951. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  952. }
  953. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  954. {
  955. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  956. }
  957. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  958. }
  959. //审核委外到货单
  960. public DataTable GetGridJsonWWSHDH(string queryJson, ref Pagination jqgridparam)
  961. {
  962. DataTable dt = new DataTable();
  963. var queryParam = queryJson.ToJObject();
  964. List<DbParameter> parameter = new List<DbParameter>();
  965. object Figure = GetDecimalDigits();
  966. #region [SQL]
  967. string sql = @"select a.ID, d.OOCode,d.Sequence as OOSequence,a.ODNCode,a.Sequence,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,detail.LocationCode AS Area,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,
  968. CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  969. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  970. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  971. from ICSODeliveryNotice a
  972. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  973. LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  974. left join (
  975. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  976. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='8'
  977. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  978. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  979. inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  980. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  981. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  982. where a.ODNType='1' and a.Status='2' and a.OASNCode is null";
  983. sql = string.Format(sql, Figure);
  984. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  985. #endregion
  986. if (!string.IsNullOrWhiteSpace(queryJson))
  987. {
  988. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  989. {
  990. sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  991. }
  992. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  993. {
  994. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  995. }
  996. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  997. {
  998. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  999. }
  1000. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1001. {
  1002. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1003. }
  1004. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  1005. {
  1006. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  1007. }
  1008. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1009. {
  1010. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1011. }
  1012. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1013. {
  1014. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1015. }
  1016. }
  1017. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1018. {
  1019. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1020. }
  1021. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1022. {
  1023. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1024. }
  1025. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1026. }
  1027. //开立得成品入库单
  1028. public DataTable GetGridJsonKLCPRK(string queryJson, ref Pagination jqgridparam)
  1029. {
  1030. DataTable dt = new DataTable();
  1031. var queryParam = queryJson.ToJObject();
  1032. List<DbParameter> parameter = new List<DbParameter>();
  1033. object Figure = GetDecimalDigits();
  1034. #region [SQL]
  1035. string sql = @"
  1036. select a.ID,a.RCVCode,a.Sequence,a.WHCode,a.InvCode,a.EATTRIBUTE,a.WorkPoint,a.InvDescribe,a.OrderNumber,
  1037. a.OrderInvCode,a.OrderInvDescribe,a.BillType,a.Remarks,a.Unit,
  1038. a.StockIndicator,a.RemarksTerm,detail.LocationCode AS Area, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,
  1039. CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity ,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1040. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1041. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1042. from ICSManufactureReceive a
  1043. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1044. LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  1045. left join (
  1046. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1047. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='9'
  1048. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1049. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1050. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1051. where a.Status='1' and a.Type='1'";
  1052. sql = string.Format(sql, Figure);
  1053. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1054. #endregion
  1055. if (!string.IsNullOrWhiteSpace(queryJson))
  1056. {
  1057. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1058. {
  1059. sql += " and a.RCVCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1060. }
  1061. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1062. {
  1063. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1064. }
  1065. if (!string.IsNullOrWhiteSpace(queryParam["OrderNumber"].ToString()))
  1066. {
  1067. sql += " and a.OrderNumber like '%" + queryParam["OrderNumber"].ToString() + "%' ";
  1068. }
  1069. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  1070. {
  1071. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  1072. }
  1073. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1074. {
  1075. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1076. }
  1077. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1078. {
  1079. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1080. }
  1081. }
  1082. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1083. {
  1084. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1085. }
  1086. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1087. {
  1088. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1089. }
  1090. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1091. }
  1092. /// <summary>
  1093. /// 点击审核委外到货单生成条码(审核委外到货单)
  1094. /// </summary>
  1095. public DataTable GetSubGridJsonWWSHDHByCreate(string ODNCode, string Sequence, string WorkPoint)
  1096. {
  1097. DataTable dt = new DataTable();
  1098. object Figure = GetDecimalDigits();
  1099. List<DbParameter> parameter = new List<DbParameter>();
  1100. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1101. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1102. from ICSODeliveryNotice a
  1103. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1104. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1105. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1106. group by b.TransCode,b.TransSequence
  1107. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
  1108. WHERE 1 =1
  1109. and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
  1110. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1111. sql = string.Format(sql, Figure);
  1112. return Repository().FindTableBySql(sql.ToString());
  1113. }
  1114. /// <summary>
  1115. /// 点击开立成品入库生成条码(开立成品入库单)
  1116. /// </summary>
  1117. /// //--
  1118. public DataTable GetSubGridJsonKLCPRKByCreate(string RCVCode, string Sequence, string WorkPoint)
  1119. {
  1120. DataTable dt = new DataTable();
  1121. object Figure = GetDecimalDigits();
  1122. List<DbParameter> parameter = new List<DbParameter>();
  1123. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1124. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1125. from ICSManufactureReceive a
  1126. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1127. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1128. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1129. group by b.TransCode,b.TransSequence
  1130. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence
  1131. WHERE 1 =1
  1132. and a.RCVCode='" + RCVCode + "' and a.Sequence='" + Sequence + "'";
  1133. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1134. sql = string.Format(sql, Figure);
  1135. return Repository().FindTableBySql(sql.ToString());
  1136. }
  1137. /// <summary>
  1138. /// 点击审核到货单生成条码(审核到货单)
  1139. /// </summary>
  1140. public DataTable GetSubGridJsonSHDHByCreate(string DNCode, string Sequence, string WorkPoint)
  1141. {
  1142. DataTable dt = new DataTable();
  1143. object Figure = GetDecimalDigits();
  1144. List<DbParameter> parameter = new List<DbParameter>();
  1145. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1146. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays ,e.BatchCode,e.Brand,e.ProjectCode
  1147. from ICSDeliveryNotice a
  1148. left join ICSExtension e ON e.ID=a.ExtensionID
  1149. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1150. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1151. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1152. group by b.TransCode,b.TransSequence
  1153. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
  1154. WHERE 1 =1
  1155. and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
  1156. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1157. sql = string.Format(sql, Figure);
  1158. return Repository().FindTableBySql(sql.ToString());
  1159. }
  1160. /// <summary>
  1161. /// 点击归还生成条码(归还)
  1162. /// </summary>
  1163. public DataTable GetSubGridJsonGuiHuanByCreate(string ReturnCode, string Sequence, string WorkPoint)
  1164. {
  1165. DataTable dt = new DataTable();
  1166. object Figure = GetDecimalDigits();
  1167. List<DbParameter> parameter = new List<DbParameter>();
  1168. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1169. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1170. from ICSReturn a
  1171. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1172. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1173. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1174. group by b.TransCode,b.TransSequence
  1175. ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence
  1176. WHERE 1 =1
  1177. and a.ReturnCode='" + ReturnCode + "' and a.Sequence='" + Sequence + "'";
  1178. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1179. sql = string.Format(sql, Figure);
  1180. return Repository().FindTableBySql(sql.ToString());
  1181. }
  1182. /// <summary>
  1183. /// 归还单生成条码
  1184. /// </summary>
  1185. /// <param name="POCode"></param>
  1186. /// <param name="PORow"></param>
  1187. /// <param name="keyValue"></param>
  1188. /// 已改
  1189. /// <returns></returns>
  1190. public int SubmitFormGuiHuan(string ReturnCode, string Sequence, string keyValue, string WorkPoint)
  1191. {
  1192. var queryParam = keyValue.ToJObject();
  1193. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1194. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1195. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1196. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1197. decimal LOTQTY = minPackQty;
  1198. string Pre = "GH" + ReturnCode + Sequence;
  1199. string sql = string.Empty;
  1200. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1201. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1202. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1203. string sqls = string.Empty;
  1204. string Colspan = "";
  1205. for (int i = 0; i < createPageCount; i++)
  1206. {
  1207. if (i + 1 == createPageCount)
  1208. {
  1209. if (minPackQty * createPageCount > thisCreateQty)
  1210. {
  1211. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1212. }
  1213. }
  1214. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1215. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1216. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1217. if (ExtensionID == null)
  1218. {
  1219. ExtensionID = Guid.NewGuid();
  1220. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1221. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1222. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1223. MUSER, MUSERNAME, WorkPoints);
  1224. }
  1225. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1226. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1227. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1228. LotNo, ReturnCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1229. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1230. //{
  1231. sql += string.Format(@"
  1232. insert into ICSInventoryLot
  1233. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1234. select
  1235. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','6','{3}','{4}', getdate(),'{5}','{9}'
  1236. from ICSReturn where ReturnCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1237. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ReturnCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1238. sql += "\r\n";
  1239. //}
  1240. }
  1241. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1242. return count;
  1243. }
  1244. /// <summary>
  1245. /// 审核到货单生成条码
  1246. /// </summary>
  1247. /// <param name="POCode"></param>
  1248. /// <param name="PORow"></param>
  1249. /// <param name="keyValue"></param>
  1250. /// 已改
  1251. /// <returns></returns>
  1252. public int SubmitFormSHDH(string DNCode, string Sequence, string INVCode, string keyValue, string WorkPoint)
  1253. {
  1254. try
  1255. {
  1256. string postUrlStr = System.Configuration.ConfigurationManager.AppSettings["HGDocpostUrlStr"].ToString();
  1257. var queryParam = keyValue.ToJObject();
  1258. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1259. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1260. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1261. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1262. decimal LOTQTY = minPackQty;
  1263. string Pre = "DN" + DNCode + Sequence;
  1264. string sql = string.Empty;
  1265. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1266. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1267. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1268. string sqls = string.Empty;
  1269. string Colspan = "";
  1270. string InspectJosn = "";
  1271. InspectJosn += "{";
  1272. InspectJosn += "\"IMP_ORDINI\":[";
  1273. InspectJosn += "{";
  1274. InspectJosn += "\"ORD_ORDINE\":\"" + DNCode + "\",";
  1275. InspectJosn += "\"ORD_DES\":\"采购入库-采购到货单\",";
  1276. InspectJosn += "\"ORD_TIPOOP\":\"V\",";
  1277. InspectJosn += "\"ORD_CLIENTE\":\"" + WorkPoint + "\"";
  1278. InspectJosn += "}";
  1279. InspectJosn += "],";
  1280. InspectJosn += "\"IMP_ORDINI_RIGHE\":[";
  1281. for (int i = 0; i < createPageCount; i++)
  1282. {
  1283. if (i + 1 == createPageCount)
  1284. {
  1285. if (minPackQty * createPageCount > thisCreateQty)
  1286. {
  1287. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1288. }
  1289. }
  1290. //Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1291. //sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1292. //object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1293. sqls = $@"SELECT TOP 1 ExtensionID FROM ICSDeliveryNotice WHERE DNCode='{DNCode}'";
  1294. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1295. if (ExtensionID == null)
  1296. {
  1297. ExtensionID = Guid.NewGuid();
  1298. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1299. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1300. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1301. MUSER, MUSERNAME, WorkPoints);
  1302. }
  1303. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1304. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1305. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1306. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1307. sql += string.Format(@"insert into ICSInventoryLot
  1308. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1309. select
  1310. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','7','{3}','{4}', getdate(),'{5}','{9}'
  1311. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1312. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1313. sql += "\r\n";
  1314. if (i == createPageCount - 1)
  1315. {
  1316. InspectJosn += "{";
  1317. InspectJosn += "\"RIG_ORDINE\":\"" + DNCode + "\",";
  1318. InspectJosn += "\"RIG_ARTICOLO\": \"" + INVCode + "\",";
  1319. InspectJosn += "\"RIG_SUB1\": \"" + LotNo + "\",";
  1320. InspectJosn += "\"RIG_SUB2\": \"\",";
  1321. InspectJosn += "\"RIG_QTAR\": " + thisCreateQty + ",";
  1322. InspectJosn += "\"RIG_HOSTINF\": " + Sequence + "";
  1323. InspectJosn += "}";
  1324. }
  1325. else
  1326. {
  1327. InspectJosn += "{";
  1328. InspectJosn += "\"RIG_ORDINE\":\"" + DNCode + "\",";
  1329. InspectJosn += "\"RIG_ARTICOLO\": \"" + INVCode + "\",";
  1330. InspectJosn += "\"RIG_SUB1\": \"" + LotNo + "\",";
  1331. InspectJosn += "\"RIG_SUB2\": \"\",";
  1332. InspectJosn += "\"RIG_QTAR\": " + thisCreateQty + ",";
  1333. InspectJosn += "\"RIG_HOSTINF\": " + Sequence + "";
  1334. InspectJosn += "},";
  1335. }
  1336. }
  1337. InspectJosn += "]";
  1338. InspectJosn += "}";
  1339. string result = "";
  1340. #region 验证物料对应仓储区域,非货柜区域不调用接口向货柜传输数据
  1341. string LocationCode = "";
  1342. string InvWHCode = "";
  1343. string chksql = @"select LocationCode,WHCode from ICSInventoryDetail
  1344. where INVCode='{0}' and WHCode=(
  1345. select WHCode from ICSDeliveryNotice
  1346. where DNCode='{1}' and Sequence='{2}' and WorkPoint='{3}')";
  1347. chksql = string.Format(chksql, INVCode, DNCode, Sequence, WorkPoint);
  1348. DataTable chkdt = SqlHelper.GetDataTableBySql(chksql);
  1349. if (chkdt.Rows.Count == 0)
  1350. {
  1351. throw new Exception("当前选中行物料在对应库存地点没有维护有效的区域,无法生成条码,请确认!");
  1352. }
  1353. else
  1354. {
  1355. LocationCode = chkdt.Rows[0]["LocationCode"].ToString();
  1356. InvWHCode = chkdt.Rows[0]["WHCode"].ToString();
  1357. chksql = @"select F_Id from Sys_SRM_ItemsDetail
  1358. where F_Define3='HGAreaConfig' AND F_Define1='{0}' AND F_Define2='{1}' and F_Define4='{2}'";
  1359. chksql = string.Format(chksql, InvWHCode, LocationCode, WorkPoint);
  1360. chkdt = SqlHelper.GetDataTableBySql(chksql);
  1361. }
  1362. #endregion
  1363. #region 货柜接口调用前日志
  1364. object logID = Guid.NewGuid();
  1365. string logsql = @"insert into ICSWMS_HGLog
  1366. values
  1367. ('{0}',GETDATE(),'{1}','{2}','{3}','{4}','{5}')";
  1368. logsql = string.Format(logsql, logID, InspectJosn, "", WorkPoint, MUSER, MUSERNAME);
  1369. SqlHelper.CmdExecuteNonQueryLi(logsql);
  1370. #endregion
  1371. if (chkdt.Rows.Count > 0 && Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UploadERP"]))
  1372. {
  1373. result = HTTPHelper.RestFulGet(InspectJosn, postUrlStr);
  1374. #region 货柜接口调用后日志
  1375. logsql = @"update ICSWMS_HGLog set ReturnResult='{0}'
  1376. where ID='{1}'";
  1377. logsql = string.Format(logsql, result, logID);
  1378. SqlHelper.CmdExecuteNonQueryLi(logsql);
  1379. #endregion
  1380. if (!result.Contains("successo"))
  1381. {
  1382. ICSHGResult hgresult = JsonConvert.DeserializeObject<ICSHGResult>(result.TrimStart('[').TrimEnd(']'));
  1383. throw new Exception("货柜单据传输接口调用报错,主要报错信息:" + hgresult.PrimaryError + ",次要报错信息:" + hgresult.SecondaryError + "");
  1384. }
  1385. }
  1386. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1387. return count;
  1388. }
  1389. catch (Exception ex)
  1390. {
  1391. throw new Exception(ex.Message);
  1392. }
  1393. }
  1394. /// <summary>
  1395. /// 审核委外到货单生成条码
  1396. /// </summary>
  1397. /// <param name="POCode"></param>
  1398. /// <param name="PORow"></param>
  1399. /// <param name="keyValue"></param>
  1400. /// 已改
  1401. /// <returns></returns>
  1402. public int SubmitFormWWSHDH(string ODNCode, string Sequence, string keyValue, string WorkPoint)
  1403. {
  1404. var queryParam = keyValue.ToJObject();
  1405. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1406. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1407. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1408. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1409. decimal LOTQTY = minPackQty;
  1410. string Pre = "ODN" + ODNCode + Sequence;
  1411. string sql = string.Empty;
  1412. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1413. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1414. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1415. string sqls = string.Empty;
  1416. string Colspan = "";
  1417. for (int i = 0; i < createPageCount; i++)
  1418. {
  1419. if (i + 1 == createPageCount)
  1420. {
  1421. if (minPackQty * createPageCount > thisCreateQty)
  1422. {
  1423. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1424. }
  1425. }
  1426. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1427. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1428. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1429. if (ExtensionID == null)
  1430. {
  1431. ExtensionID = Guid.NewGuid();
  1432. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1433. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1434. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1435. MUSER, MUSERNAME, WorkPoints);
  1436. }
  1437. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1438. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1439. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1440. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1441. sql += string.Format(@"
  1442. insert into ICSInventoryLot
  1443. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1444. select
  1445. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','8','{3}','{4}', getdate(),'{5}','{9}'
  1446. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1447. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1448. sql += "\r\n";
  1449. }
  1450. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1451. return count;
  1452. }
  1453. /// <summary>
  1454. /// 开立成品入库单
  1455. /// </summary>
  1456. /// <param name="POCode"></param>
  1457. /// <param name="PORow"></param>
  1458. /// <param name="keyValue"></param>
  1459. /// 已改
  1460. /// <returns></returns>
  1461. public int SubmitFormKLCPRK(string RCVCode, string Sequence, string keyValue, string WorkPoint)
  1462. {
  1463. var queryParam = keyValue.ToJObject();
  1464. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1465. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1466. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1467. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1468. decimal LOTQTY = minPackQty;
  1469. string Pre = "KCP" + RCVCode + Sequence;
  1470. string sql = string.Empty;
  1471. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1472. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1473. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1474. string sqls = string.Empty;
  1475. string Colspan = "";
  1476. for (int i = 0; i < createPageCount; i++)
  1477. {
  1478. if (i + 1 == createPageCount)
  1479. {
  1480. if (minPackQty * createPageCount > thisCreateQty)
  1481. {
  1482. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1483. }
  1484. }
  1485. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1486. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1487. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1488. if (ExtensionID == null)
  1489. {
  1490. ExtensionID = Guid.NewGuid();
  1491. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1492. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1493. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1494. MUSER, MUSERNAME, WorkPoints);
  1495. }
  1496. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1497. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1498. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1499. LotNo, RCVCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1500. sql += string.Format(@"
  1501. insert into ICSInventoryLot
  1502. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1503. select
  1504. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','9','{3}','{4}', getdate(),'{5}','{9}'
  1505. from ICSManufactureReceive where RCVCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1506. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, RCVCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1507. sql += "\r\n";
  1508. }
  1509. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1510. return count;
  1511. }
  1512. //委外拒收单
  1513. public DataTable GetGridJsonWWJSD(string queryJson, ref Pagination jqgridparam)
  1514. {
  1515. DataTable dt = new DataTable();
  1516. var queryParam = queryJson.ToJObject();
  1517. List<DbParameter> parameter = new List<DbParameter>();
  1518. object Figure = GetDecimalDigits();
  1519. #region [SQL]
  1520. string sql = @"select a.ID, a.ODNCode OOCode,a.Sequence OOSequence,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  1521. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1522. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1523. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1524. from ICSODeliveryNotice a
  1525. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1526. left join (
  1527. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1528. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='11'
  1529. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1530. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1531. --inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  1532. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1533. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1534. where a.ODNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
  1535. ";
  1536. sql = string.Format(sql, Figure);
  1537. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1538. #endregion
  1539. if (!string.IsNullOrWhiteSpace(queryJson))
  1540. {
  1541. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1542. {
  1543. sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1544. }
  1545. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1546. {
  1547. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1548. }
  1549. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1550. {
  1551. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1552. }
  1553. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1554. {
  1555. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1556. }
  1557. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1558. {
  1559. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1560. }
  1561. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1562. {
  1563. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1564. }
  1565. }
  1566. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1567. {
  1568. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1569. }
  1570. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1571. {
  1572. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1573. }
  1574. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1575. }
  1576. //拒收单
  1577. public DataTable GetGridJsonJSD(string queryJson, ref Pagination jqgridparam)
  1578. {
  1579. DataTable dt = new DataTable();
  1580. var queryParam = queryJson.ToJObject();
  1581. List<DbParameter> parameter = new List<DbParameter>();
  1582. object Figure = GetDecimalDigits();
  1583. #region [SQL]
  1584. string sql = @"select a.ID,a.DNCode ,a.Sequence ,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  1585. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST( a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,
  1586. CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1587. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1588. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1589. from ICSDeliveryNotice a
  1590. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1591. left join (
  1592. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1593. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='10'
  1594. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1595. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1596. --inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  1597. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1598. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1599. where a.DNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
  1600. ";
  1601. sql = string.Format(sql, Figure);
  1602. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1603. #endregion
  1604. if (!string.IsNullOrWhiteSpace(queryJson))
  1605. {
  1606. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1607. {
  1608. sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1609. }
  1610. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1611. {
  1612. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1613. }
  1614. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1615. {
  1616. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1617. }
  1618. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1619. {
  1620. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1621. }
  1622. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1623. {
  1624. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1625. }
  1626. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1627. {
  1628. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1629. }
  1630. }
  1631. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1632. {
  1633. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1634. }
  1635. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1636. {
  1637. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1638. }
  1639. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1640. }
  1641. //领料申请退料
  1642. public DataTable GetGridJsonLLSQTL(string queryJson, ref Pagination jqgridparam)
  1643. {
  1644. DataTable dt = new DataTable();
  1645. var queryParam = queryJson.ToJObject();
  1646. List<DbParameter> parameter = new List<DbParameter>();
  1647. object Figure = GetDecimalDigits();
  1648. #region [SQL]
  1649. string sql = @"select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,d.CreateDateTime,
  1650. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity
  1651. ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1652. ,a.WHCode,detail.LocationCode AS Area,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1653. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1654. from ICSMOApplyNegDetail a
  1655. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1656. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1657. LEFT JOIN ICSInventoryDetail detail ON b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  1658. left join (
  1659. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1660. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='12'
  1661. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1662. )c
  1663. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1664. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1665. WHERE d.Type='2'";
  1666. sql = string.Format(sql, Figure);
  1667. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1668. #endregion
  1669. if (!string.IsNullOrWhiteSpace(queryJson))
  1670. {
  1671. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1672. {
  1673. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1674. }
  1675. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1676. {
  1677. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1678. }
  1679. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1680. {
  1681. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1682. }
  1683. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1684. {
  1685. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1686. }
  1687. if (!string.IsNullOrWhiteSpace(queryParam["Location"].ToString()))
  1688. {
  1689. sql += " and a.WHCode like '%" + queryParam["Location"].ToString() + "%' ";
  1690. }
  1691. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  1692. {
  1693. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  1694. }
  1695. }
  1696. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1697. {
  1698. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1699. }
  1700. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1701. {
  1702. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1703. }
  1704. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1705. }
  1706. /// <summary>
  1707. /// 拒收生成条码
  1708. /// </summary>
  1709. /// <param name="POCode"></param>
  1710. /// <param name="PORow"></param>
  1711. /// <param name="keyValue"></param>
  1712. /// <returns></returns>
  1713. public int SubmitFormJSD(string DNCode, string Sequence, string keyValue, string WorkPoint)
  1714. {
  1715. var queryParam = keyValue.ToJObject();
  1716. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1717. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1718. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1719. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1720. decimal LOTQTY = minPackQty;
  1721. string Pre = "JS" + DNCode + Sequence;
  1722. string sql = string.Empty;
  1723. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1724. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1725. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1726. string sqls = string.Empty;
  1727. string Colspan = "";
  1728. for (int i = 0; i < createPageCount; i++)
  1729. {
  1730. if (i + 1 == createPageCount)
  1731. {
  1732. if (minPackQty * createPageCount > thisCreateQty)
  1733. {
  1734. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1735. }
  1736. }
  1737. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1738. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1739. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1740. if (ExtensionID == null)
  1741. {
  1742. ExtensionID = Guid.NewGuid();
  1743. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1744. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1745. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1746. MUSER, MUSERNAME, WorkPoints);
  1747. }
  1748. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1749. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1750. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1751. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1752. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1753. //{
  1754. sql += string.Format(@"
  1755. insert into ICSInventoryLot
  1756. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1757. select
  1758. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','10','{3}','{4}', getdate(),'{5}','{9}'
  1759. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1760. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1761. sql += "\r\n";
  1762. //}
  1763. }
  1764. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1765. return count;
  1766. }
  1767. /// <summary>
  1768. /// 委外拒收生成条码
  1769. /// </summary>
  1770. /// <param name="POCode"></param>
  1771. /// <param name="PORow"></param>
  1772. /// <param name="keyValue"></param>
  1773. /// <returns></returns>
  1774. public int SubmitFormWWJSD(string ODNCode, string Sequence, string keyValue, string WorkPoint)
  1775. {
  1776. var queryParam = keyValue.ToJObject();
  1777. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1778. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1779. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1780. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1781. decimal LOTQTY = minPackQty;
  1782. string Pre = "OJS" + ODNCode + Sequence;
  1783. string sql = string.Empty;
  1784. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1785. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1786. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1787. string sqls = string.Empty;
  1788. string Colspan = "";
  1789. for (int i = 0; i < createPageCount; i++)
  1790. {
  1791. if (i + 1 == createPageCount)
  1792. {
  1793. if (minPackQty * createPageCount > thisCreateQty)
  1794. {
  1795. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1796. }
  1797. }
  1798. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1799. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1800. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1801. if (ExtensionID == null)
  1802. {
  1803. ExtensionID = Guid.NewGuid();
  1804. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1805. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1806. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1807. MUSER, MUSERNAME, WorkPoints);
  1808. }
  1809. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1810. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1811. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1812. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1813. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1814. //{
  1815. sql += string.Format(@"
  1816. insert into ICSInventoryLot
  1817. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1818. select
  1819. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','11','{3}','{4}', getdate(),'{5}','{9}'
  1820. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1821. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1822. sql += "\r\n";
  1823. //}
  1824. }
  1825. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1826. return count;
  1827. }
  1828. /// <summary>
  1829. /// 点击审核到货单生成条码(审核到货单)
  1830. /// </summary>
  1831. public DataTable GetSubGridJsonJSDByCreate(string DNCode, string Sequence, string WorkPoint)
  1832. {
  1833. DataTable dt = new DataTable();
  1834. object Figure = GetDecimalDigits();
  1835. List<DbParameter> parameter = new List<DbParameter>();
  1836. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1837. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1838. from ICSDeliveryNotice a
  1839. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1840. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1841. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1842. group by b.TransCode,b.TransSequence
  1843. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
  1844. WHERE a.DNType='3'
  1845. and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
  1846. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1847. sql = string.Format(sql, Figure);
  1848. return Repository().FindTableBySql(sql.ToString());
  1849. }
  1850. /// <summary>
  1851. /// 点击审核委外到货单生成条码(审核委外到货单)
  1852. /// </summary>
  1853. public DataTable GetSubGridJsonWWJSDByCreate(string ODNCode, string Sequence, string WorkPoint)
  1854. {
  1855. DataTable dt = new DataTable();
  1856. object Figure = GetDecimalDigits();
  1857. List<DbParameter> parameter = new List<DbParameter>();
  1858. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1859. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1860. from ICSODeliveryNotice a
  1861. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1862. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1863. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1864. group by b.TransCode,b.TransSequence
  1865. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
  1866. WHERE a.ODNType='3'
  1867. and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
  1868. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1869. sql = string.Format(sql, Figure);
  1870. return Repository().FindTableBySql(sql.ToString());
  1871. }
  1872. public DataTable GetSubGridJsonLLSQDByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  1873. {
  1874. DataTable dt = new DataTable();
  1875. object Figure = GetDecimalDigits();
  1876. List<DbParameter> parameter = new List<DbParameter>();
  1877. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1878. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1879. from ICSMOApplyNegDetail a
  1880. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1881. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1882. left join (
  1883. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1884. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1885. group by b.TransCode,b.TransSequence
  1886. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  1887. WHERE d.Type='2'
  1888. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  1889. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1890. sql = string.Format(sql, Figure);
  1891. return Repository().FindTableBySql(sql.ToString());
  1892. }
  1893. //领料申请退料生成条码
  1894. public int SubmitFormLLSQTL(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  1895. {
  1896. var queryParam = keyValue.ToJObject();
  1897. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1898. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1899. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1900. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1901. decimal LOTQTY = minPackQty;
  1902. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1903. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  1904. string Pre = "MA" + ApplyNegCode + Sequence;
  1905. string sql = string.Empty;
  1906. //string VendorLot = queryParam["VendorLot"].ToString();
  1907. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1908. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1909. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1910. string sqls = string.Empty;
  1911. string Colspan = "";
  1912. for (int i = 0; i < createPageCount; i++)
  1913. {
  1914. if (i + 1 == createPageCount)
  1915. {
  1916. if (minPackQty * createPageCount > thisCreateQty)
  1917. {
  1918. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1919. }
  1920. }
  1921. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1922. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1923. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1924. if (ExtensionID == null)
  1925. {
  1926. ExtensionID = Guid.NewGuid();
  1927. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1928. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1929. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1930. MUSER, MUSERNAME, WorkPoints);
  1931. }
  1932. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1933. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1934. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1935. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1936. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1937. //{
  1938. sql += string.Format(@"insert into ICSInventoryLot
  1939. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1940. select
  1941. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','12','{3}','{4}', getdate(),'{5}','{9}'
  1942. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1943. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1944. sql += "\r\n";
  1945. //}
  1946. }
  1947. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1948. return count;
  1949. }
  1950. //材料出库退料
  1951. public DataTable GetGridJsonCLCK(string queryJson, ref Pagination jqgridparam)
  1952. {
  1953. DataTable dt = new DataTable();
  1954. var queryParam = queryJson.ToJObject();
  1955. List<DbParameter> parameter = new List<DbParameter>();
  1956. object Figure = GetDecimalDigits();
  1957. #region [SQL]
  1958. string sql = @"
  1959. select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  1960. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity,
  1961. CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1962. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1963. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1964. from ICSMOApplyNegDetail a
  1965. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1966. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1967. left join (
  1968. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1969. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='13'
  1970. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1971. )c
  1972. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1973. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1974. WHERE d.Type='3'";
  1975. sql = string.Format(sql, Figure);
  1976. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1977. #endregion
  1978. if (!string.IsNullOrWhiteSpace(queryJson))
  1979. {
  1980. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1981. {
  1982. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1983. }
  1984. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1985. {
  1986. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1987. }
  1988. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1989. {
  1990. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1991. }
  1992. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1993. {
  1994. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1995. }
  1996. }
  1997. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1998. {
  1999. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2000. }
  2001. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2002. {
  2003. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2004. }
  2005. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2006. }
  2007. //材料出库退料
  2008. public DataTable GetSubGridJsonCLCKByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  2009. {
  2010. DataTable dt = new DataTable();
  2011. object Figure = GetDecimalDigits();
  2012. List<DbParameter> parameter = new List<DbParameter>();
  2013. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2014. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2015. from ICSMOApplyNegDetail a
  2016. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  2017. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2018. left join (
  2019. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2020. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2021. group by b.TransCode,b.TransSequence
  2022. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2023. WHERE d.Type='3'
  2024. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2025. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2026. sql = string.Format(sql, Figure);
  2027. return Repository().FindTableBySql(sql.ToString());
  2028. }
  2029. //材料出库退料生成条码
  2030. public int SubmitFormCLCKT(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2031. {
  2032. var queryParam = keyValue.ToJObject();
  2033. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2034. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2035. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2036. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2037. decimal LOTQTY = minPackQty;
  2038. string Pre = "MD" + ApplyNegCode + Sequence;
  2039. string sql = string.Empty;
  2040. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2041. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2042. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2043. string sqls = string.Empty;
  2044. string Colspan = "";
  2045. for (int i = 0; i < createPageCount; i++)
  2046. {
  2047. if (i + 1 == createPageCount)
  2048. {
  2049. if (minPackQty * createPageCount > thisCreateQty)
  2050. {
  2051. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2052. }
  2053. }
  2054. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  2055. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2056. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2057. if (ExtensionID == null)
  2058. {
  2059. ExtensionID = Guid.NewGuid();
  2060. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  2061. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2062. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  2063. MUSER, MUSERNAME, WorkPoints);
  2064. }
  2065. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2066. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2067. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2068. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2069. sql += string.Format(@"insert into ICSInventoryLot
  2070. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2071. select
  2072. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','13','{3}','{4}', getdate(),'{5}','{9}'
  2073. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2074. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2075. sql += "\r\n";
  2076. }
  2077. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2078. return count;
  2079. }
  2080. public DataTable GetGridJsonWWLLTL(string queryJson, ref Pagination jqgridparam)
  2081. {
  2082. DataTable dt = new DataTable();
  2083. var queryParam = queryJson.ToJObject();
  2084. List<DbParameter> parameter = new List<DbParameter>();
  2085. object Figure = GetDecimalDigits();
  2086. #region [SQL]
  2087. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2088. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  2089. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2090. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2091. from ICSOApplyNegDetail a
  2092. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2093. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2094. left join (
  2095. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2096. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='14'
  2097. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2098. )c
  2099. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2100. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2101. WHERE d.Type='2'";
  2102. sql = string.Format(sql, Figure);
  2103. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2104. #endregion
  2105. if (!string.IsNullOrWhiteSpace(queryJson))
  2106. {
  2107. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2108. {
  2109. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2110. }
  2111. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2112. {
  2113. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2114. }
  2115. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2116. {
  2117. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2118. }
  2119. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2120. {
  2121. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2122. }
  2123. }
  2124. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2125. {
  2126. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2127. }
  2128. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2129. {
  2130. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2131. }
  2132. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2133. }
  2134. /// <summary>
  2135. /// 点击委外领料退料生成条码
  2136. /// </summary>
  2137. public DataTable GetSubGridJsonWWLLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  2138. {
  2139. DataTable dt = new DataTable();
  2140. object Figure = GetDecimalDigits();
  2141. List<DbParameter> parameter = new List<DbParameter>();
  2142. string sql = @"
  2143. select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2144. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2145. from ICSOApplyNegDetail a
  2146. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2147. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2148. left join (
  2149. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2150. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2151. group by b.TransCode,b.TransSequence
  2152. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2153. WHERE d.Type='2'
  2154. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2155. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2156. sql = string.Format(sql, Figure);
  2157. return Repository().FindTableBySql(sql.ToString());
  2158. }
  2159. //委外领料申请退料
  2160. public int SubmitFormWWLL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2161. {
  2162. var queryParam = keyValue.ToJObject();
  2163. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2164. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2165. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2166. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2167. decimal LOTQTY = minPackQty;
  2168. string Pre = "OMA" + OApplyNegCode + Sequence;
  2169. string sql = string.Empty;
  2170. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2171. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2172. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2173. string sqls = string.Empty;
  2174. string Colspan = "";
  2175. for (int i = 0; i < createPageCount; i++)
  2176. {
  2177. if (i + 1 == createPageCount)
  2178. {
  2179. if (minPackQty * createPageCount > thisCreateQty)
  2180. {
  2181. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2182. }
  2183. }
  2184. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  2185. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2186. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2187. if (ExtensionID == null)
  2188. {
  2189. ExtensionID = Guid.NewGuid();
  2190. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  2191. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2192. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  2193. MUSER, MUSERNAME, WorkPoints);
  2194. }
  2195. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2196. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2197. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2198. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2199. sql += string.Format(@"insert into ICSInventoryLot
  2200. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2201. select
  2202. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','14','{3}','{4}', getdate(),'{5}','{9}'
  2203. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2204. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2205. sql += "\r\n";
  2206. }
  2207. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2208. return count;
  2209. }
  2210. //委外材料出库
  2211. public DataTable GetGridJsonWWCLCK(string queryJson, ref Pagination jqgridparam)
  2212. {
  2213. DataTable dt = new DataTable();
  2214. var queryParam = queryJson.ToJObject();
  2215. List<DbParameter> parameter = new List<DbParameter>();
  2216. object Figure = GetDecimalDigits();
  2217. #region [SQL]
  2218. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2219. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  2220. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2221. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2222. from ICSOApplyNegDetail a
  2223. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2224. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2225. left join (
  2226. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2227. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='15'
  2228. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2229. )c
  2230. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2231. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2232. WHERE d.Type='3'";
  2233. sql = string.Format(sql, Figure);
  2234. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2235. #endregion
  2236. if (!string.IsNullOrWhiteSpace(queryJson))
  2237. {
  2238. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2239. {
  2240. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2241. }
  2242. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2243. {
  2244. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2245. }
  2246. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2247. {
  2248. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2249. }
  2250. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2251. {
  2252. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2253. }
  2254. }
  2255. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2256. {
  2257. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2258. }
  2259. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2260. {
  2261. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2262. }
  2263. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2264. }
  2265. //委外材料出库
  2266. public DataTable GetSubGridJsonWWCLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  2267. {
  2268. DataTable dt = new DataTable();
  2269. object Figure = GetDecimalDigits();
  2270. List<DbParameter> parameter = new List<DbParameter>();
  2271. string sql = @"
  2272. select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2273. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2274. from ICSOApplyNegDetail a
  2275. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2276. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2277. left join (
  2278. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2279. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2280. group by b.TransCode,b.TransSequence
  2281. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2282. WHERE d.Type='3'
  2283. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2284. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2285. sql = string.Format(sql, Figure);
  2286. return Repository().FindTableBySql(sql.ToString());
  2287. }
  2288. //委外材料出库
  2289. public int SubmitFormWWCL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2290. {
  2291. var queryParam = keyValue.ToJObject();
  2292. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2293. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2294. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2295. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2296. decimal LOTQTY = minPackQty;
  2297. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2298. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  2299. string Pre = "OMD" + OApplyNegCode + Sequence;
  2300. string sql = string.Empty;
  2301. //string VendorLot = queryParam["VendorLot"].ToString();
  2302. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2303. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2304. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2305. string sqls = string.Empty;
  2306. string Colspan = "";
  2307. for (int i = 0; i < createPageCount; i++)
  2308. {
  2309. if (i + 1 == createPageCount)
  2310. {
  2311. if (minPackQty * createPageCount > thisCreateQty)
  2312. {
  2313. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2314. }
  2315. }
  2316. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  2317. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2318. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2319. if (ExtensionID == null)
  2320. {
  2321. ExtensionID = Guid.NewGuid();
  2322. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  2323. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2324. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  2325. MUSER, MUSERNAME, WorkPoints);
  2326. }
  2327. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2328. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2329. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2330. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2331. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  2332. //{
  2333. sql += string.Format(@"insert into ICSInventoryLot
  2334. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2335. select
  2336. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','15','{3}','{4}', getdate(),'{5}','{9}'
  2337. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2338. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2339. sql += "\r\n";
  2340. //}
  2341. }
  2342. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2343. return count;
  2344. }
  2345. public DataTable SelectICSExtensionEnable(string BeginTime, string EndTime)
  2346. {
  2347. string sql = @"select ColCode from ICSExtensionEnable
  2348. where Enable=0
  2349. order by cast(EATTRIBUTE1 as int)";
  2350. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2351. return dt;
  2352. }
  2353. //返工工单
  2354. public DataTable GetGridJsonFGGD(string queryJson, ref Pagination jqgridparam)
  2355. {
  2356. DataTable dt = new DataTable();
  2357. var queryParam = queryJson.ToJObject();
  2358. List<DbParameter> parameter = new List<DbParameter>();
  2359. object Figure = GetDecimalDigits();
  2360. #region [SQL]
  2361. string sql = @"select a.ID,d.MOCode,d.Sequence+'-'+ a.Sequence as Sequence,a.PickID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2362. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  2363. CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueQuantity AS DECIMAL(18,{0})) as IssueQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  2364. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2365. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2366. from ICSMOPick a
  2367. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint
  2368. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2369. left join (
  2370. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2371. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='16'
  2372. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2373. )c
  2374. on d.MOCode=c.TransCode and d.Sequence+'-'+a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2375. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2376. where a.EATTRIBUTE1='1' and d.EATTRIBUTE1='1'";
  2377. sql = string.Format(sql, Figure);
  2378. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2379. #endregion
  2380. if (!string.IsNullOrWhiteSpace(queryJson))
  2381. {
  2382. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2383. {
  2384. sql += " and d.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2385. }
  2386. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2387. {
  2388. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2389. }
  2390. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2391. {
  2392. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2393. }
  2394. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2395. {
  2396. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2397. }
  2398. }
  2399. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2400. {
  2401. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2402. }
  2403. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2404. {
  2405. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2406. }
  2407. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2408. }
  2409. public DataTable GetSubGridJsonFGGDCreate(string FGGDMOCode, string Sequence, string WorkPoint)
  2410. {
  2411. DataTable dt = new DataTable();
  2412. object Figure = GetDecimalDigits();
  2413. List<DbParameter> parameter = new List<DbParameter>();
  2414. string sql = @"
  2415. select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2416. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2417. from ICSMOPick a
  2418. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint
  2419. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2420. left join (
  2421. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2422. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2423. group by b.TransCode,b.TransSequence
  2424. ) c on d.MOCode=c.TransCode and d.Sequence+'-'+a.Sequence=c.TransSequence
  2425. WHERE 1=1
  2426. and d.MOCode='" + FGGDMOCode + "' and d.Sequence+'-'+a.Sequence='" + Sequence + "'";
  2427. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2428. sql = string.Format(sql, Figure);
  2429. return Repository().FindTableBySql(sql.ToString());
  2430. }
  2431. //返工工单
  2432. public int SubmitFormFGGD(string FGGDMOCode, string Sequence, string keyValue, string WorkPoint)
  2433. {
  2434. var queryParam = keyValue.ToJObject();
  2435. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2436. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2437. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2438. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2439. decimal LOTQTY = minPackQty;
  2440. string Pre = "FG" + FGGDMOCode + Sequence;
  2441. string sql = string.Empty;
  2442. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2443. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2444. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2445. string sqls = string.Empty;
  2446. string Colspan = "";
  2447. for (int i = 0; i < createPageCount; i++)
  2448. {
  2449. if (i + 1 == createPageCount)
  2450. {
  2451. if (minPackQty * createPageCount > thisCreateQty)
  2452. {
  2453. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2454. }
  2455. }
  2456. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  2457. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2458. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2459. if (ExtensionID == null)
  2460. {
  2461. ExtensionID = Guid.NewGuid();
  2462. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  2463. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2464. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  2465. MUSER, MUSERNAME, WorkPoints);
  2466. }
  2467. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2468. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2469. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2470. LotNo, FGGDMOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2471. sql += string.Format(@"insert into ICSInventoryLot
  2472. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2473. select
  2474. newid(),'{0}',a.InvCode,'{1}','{10}','{2}','{8}','16','{3}','{4}', getdate(),'{5}','{9}'
  2475. from ICSMOPick a left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint where d.MOCode='{6}' and d.Sequence+'-'+a.Sequence='{7}' and a.WorkPoint='{5}' ",
  2476. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, FGGDMOCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2477. sql += "\r\n";
  2478. }
  2479. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2480. return count;
  2481. }
  2482. public object GetDecimalDigits()
  2483. {
  2484. try
  2485. {
  2486. string sql = string.Empty;
  2487. sql = @"select Figure from ICSConfiguration where Code='Figure001' and Enable='1'";
  2488. object Figure = SqlHelper.ExecuteScalar(sql);
  2489. return Figure;
  2490. }
  2491. catch (Exception ex)
  2492. {
  2493. throw new Exception(ex.Message.ToString());
  2494. }
  2495. }
  2496. public object GetQiSetNum(string keyValue)
  2497. {
  2498. int Num = 0;
  2499. string msg = "";
  2500. string APIURL = ConfigurationManager.ConnectionStrings["ERPAPIURL"].ConnectionString + "Complete/Approve";
  2501. string result = HttpPost(APIURL, keyValue);
  2502. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  2503. string MessAge = Obj["Message"].ToString();
  2504. string Success = Obj["Success"].ToString();
  2505. if (Success.ToUpper() == "FALSE")
  2506. {
  2507. msg = MessAge;
  2508. }
  2509. if (msg == "")
  2510. {
  2511. JArray res = (JArray)JsonConvert.DeserializeObject(Obj["Data"].ToString());
  2512. foreach (var item in res)
  2513. {
  2514. JObject jo = (JObject)item;
  2515. Num = Convert.ToInt32(jo["min_lotqty"].ToString());
  2516. }
  2517. }
  2518. var Header = new
  2519. {
  2520. msg = msg,
  2521. Num = Num,
  2522. };
  2523. return Header;
  2524. }
  2525. //接口api解析
  2526. public static string HttpPost(string url, string body)
  2527. {
  2528. try
  2529. {
  2530. Encoding encoding = Encoding.UTF8;
  2531. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  2532. request.Method = "POST";
  2533. request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
  2534. request.ContentType = "application/json; charset=utf-8";
  2535. byte[] buffer = encoding.GetBytes(body);
  2536. request.ContentLength = buffer.Length;
  2537. request.GetRequestStream().Write(buffer, 0, buffer.Length);
  2538. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  2539. using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
  2540. {
  2541. return reader.ReadToEnd();
  2542. }
  2543. }
  2544. catch (WebException ex)
  2545. {
  2546. throw new Exception(ex.Message);
  2547. }
  2548. }
  2549. }
  2550. }