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

2740 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
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
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,
  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, detail.LocationCode AS Area,
  894. 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
  895. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  896. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  897. from ICSDeliveryNotice a
  898. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  899. LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  900. left join (
  901. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  902. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='7'
  903. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  904. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  905. -- inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  906. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  907. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  908. where a.DNType='1' and a.Status='2' and a.ASNCode is null
  909. ";
  910. sql = string.Format(sql, Figure);
  911. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  912. #endregion
  913. if (!string.IsNullOrWhiteSpace(queryJson))
  914. {
  915. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  916. {
  917. sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  918. }
  919. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  920. {
  921. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  922. }
  923. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  924. {
  925. sql += " and a.DepCode like '%" + queryParam["VenName"].ToString() + "%' ";
  926. }
  927. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  928. {
  929. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  930. }
  931. if (!string.IsNullOrWhiteSpace(queryParam["Location"].ToString()))
  932. {
  933. sql += " and a.WHCode like '%" + queryParam["Location"].ToString() + "%' ";
  934. }
  935. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  936. {
  937. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  938. }
  939. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  940. {
  941. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  942. }
  943. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  944. {
  945. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  946. }
  947. }
  948. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  949. {
  950. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  951. }
  952. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  953. {
  954. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  955. }
  956. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  957. }
  958. //审核委外到货单
  959. public DataTable GetGridJsonWWSHDH(string queryJson, ref Pagination jqgridparam)
  960. {
  961. DataTable dt = new DataTable();
  962. var queryParam = queryJson.ToJObject();
  963. List<DbParameter> parameter = new List<DbParameter>();
  964. object Figure = GetDecimalDigits();
  965. #region [SQL]
  966. 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,
  967. CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  968. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  969. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  970. from ICSODeliveryNotice a
  971. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  972. LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  973. left join (
  974. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  975. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='8'
  976. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  977. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  978. inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  979. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  980. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  981. where a.ODNType='1' and a.Status='2' and a.OASNCode is null";
  982. sql = string.Format(sql, Figure);
  983. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  984. #endregion
  985. if (!string.IsNullOrWhiteSpace(queryJson))
  986. {
  987. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  988. {
  989. sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  990. }
  991. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  992. {
  993. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  994. }
  995. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  996. {
  997. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  998. }
  999. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1000. {
  1001. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1002. }
  1003. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  1004. {
  1005. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  1006. }
  1007. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1008. {
  1009. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1010. }
  1011. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1012. {
  1013. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1014. }
  1015. }
  1016. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1017. {
  1018. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1019. }
  1020. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1021. {
  1022. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1023. }
  1024. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1025. }
  1026. //开立得成品入库单
  1027. public DataTable GetGridJsonKLCPRK(string queryJson, ref Pagination jqgridparam)
  1028. {
  1029. DataTable dt = new DataTable();
  1030. var queryParam = queryJson.ToJObject();
  1031. List<DbParameter> parameter = new List<DbParameter>();
  1032. object Figure = GetDecimalDigits();
  1033. #region [SQL]
  1034. string sql = @"
  1035. select a.ID,a.RCVCode,a.Sequence,a.WHCode,a.InvCode,a.EATTRIBUTE,a.WorkPoint,a.InvDescribe,a.OrderNumber,
  1036. a.OrderInvCode,a.OrderInvDescribe,a.BillType,a.Remarks,a.Unit,
  1037. 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 ,
  1038. 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
  1039. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1040. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1041. from ICSManufactureReceive a
  1042. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1043. LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  1044. left join (
  1045. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1046. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='9'
  1047. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1048. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1049. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1050. where a.Status='1' and a.Type='1'";
  1051. sql = string.Format(sql, Figure);
  1052. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1053. #endregion
  1054. if (!string.IsNullOrWhiteSpace(queryJson))
  1055. {
  1056. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1057. {
  1058. sql += " and a.RCVCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1059. }
  1060. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1061. {
  1062. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1063. }
  1064. if (!string.IsNullOrWhiteSpace(queryParam["OrderNumber"].ToString()))
  1065. {
  1066. sql += " and a.OrderNumber like '%" + queryParam["OrderNumber"].ToString() + "%' ";
  1067. }
  1068. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  1069. {
  1070. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  1071. }
  1072. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1073. {
  1074. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1075. }
  1076. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1077. {
  1078. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1079. }
  1080. }
  1081. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1082. {
  1083. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1084. }
  1085. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1086. {
  1087. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1088. }
  1089. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1090. }
  1091. /// <summary>
  1092. /// 点击审核委外到货单生成条码(审核委外到货单)
  1093. /// </summary>
  1094. public DataTable GetSubGridJsonWWSHDHByCreate(string ODNCode, string Sequence, string WorkPoint)
  1095. {
  1096. DataTable dt = new DataTable();
  1097. object Figure = GetDecimalDigits();
  1098. List<DbParameter> parameter = new List<DbParameter>();
  1099. 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,
  1100. 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
  1101. from ICSODeliveryNotice a
  1102. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1103. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1104. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1105. group by b.TransCode,b.TransSequence
  1106. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
  1107. WHERE 1 =1
  1108. and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
  1109. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1110. sql = string.Format(sql, Figure);
  1111. return Repository().FindTableBySql(sql.ToString());
  1112. }
  1113. /// <summary>
  1114. /// 点击开立成品入库生成条码(开立成品入库单)
  1115. /// </summary>
  1116. /// //--
  1117. public DataTable GetSubGridJsonKLCPRKByCreate(string RCVCode, string Sequence, string WorkPoint)
  1118. {
  1119. DataTable dt = new DataTable();
  1120. object Figure = GetDecimalDigits();
  1121. List<DbParameter> parameter = new List<DbParameter>();
  1122. 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,
  1123. 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
  1124. from ICSManufactureReceive a
  1125. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1126. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1127. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1128. group by b.TransCode,b.TransSequence
  1129. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence
  1130. WHERE 1 =1
  1131. and a.RCVCode='" + RCVCode + "' and a.Sequence='" + Sequence + "'";
  1132. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1133. sql = string.Format(sql, Figure);
  1134. return Repository().FindTableBySql(sql.ToString());
  1135. }
  1136. /// <summary>
  1137. /// 点击审核到货单生成条码(审核到货单)
  1138. /// </summary>
  1139. public DataTable GetSubGridJsonSHDHByCreate(string DNCode, string Sequence, string WorkPoint)
  1140. {
  1141. DataTable dt = new DataTable();
  1142. object Figure = GetDecimalDigits();
  1143. List<DbParameter> parameter = new List<DbParameter>();
  1144. 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,
  1145. 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
  1146. from ICSDeliveryNotice a
  1147. left join ICSExtension e ON e.ID=a.ExtensionID
  1148. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1149. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1150. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1151. group by b.TransCode,b.TransSequence
  1152. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
  1153. WHERE 1 =1
  1154. and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
  1155. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1156. sql = string.Format(sql, Figure);
  1157. return Repository().FindTableBySql(sql.ToString());
  1158. }
  1159. /// <summary>
  1160. /// 点击归还生成条码(归还)
  1161. /// </summary>
  1162. public DataTable GetSubGridJsonGuiHuanByCreate(string ReturnCode, string Sequence, string WorkPoint)
  1163. {
  1164. DataTable dt = new DataTable();
  1165. object Figure = GetDecimalDigits();
  1166. List<DbParameter> parameter = new List<DbParameter>();
  1167. 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,
  1168. 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
  1169. from ICSReturn a
  1170. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1171. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1172. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1173. group by b.TransCode,b.TransSequence
  1174. ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence
  1175. WHERE 1 =1
  1176. and a.ReturnCode='" + ReturnCode + "' and a.Sequence='" + Sequence + "'";
  1177. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1178. sql = string.Format(sql, Figure);
  1179. return Repository().FindTableBySql(sql.ToString());
  1180. }
  1181. /// <summary>
  1182. /// 归还单生成条码
  1183. /// </summary>
  1184. /// <param name="POCode"></param>
  1185. /// <param name="PORow"></param>
  1186. /// <param name="keyValue"></param>
  1187. /// 已改
  1188. /// <returns></returns>
  1189. public int SubmitFormGuiHuan(string ReturnCode, string Sequence, string keyValue, string WorkPoint)
  1190. {
  1191. var queryParam = keyValue.ToJObject();
  1192. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1193. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1194. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1195. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1196. decimal LOTQTY = minPackQty;
  1197. string Pre = "GH" + ReturnCode + Sequence;
  1198. string sql = string.Empty;
  1199. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1200. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1201. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1202. string sqls = string.Empty;
  1203. string Colspan = "";
  1204. for (int i = 0; i < createPageCount; i++)
  1205. {
  1206. if (i + 1 == createPageCount)
  1207. {
  1208. if (minPackQty * createPageCount > thisCreateQty)
  1209. {
  1210. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1211. }
  1212. }
  1213. 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();
  1214. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1215. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1216. if (ExtensionID == null)
  1217. {
  1218. ExtensionID = Guid.NewGuid();
  1219. 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)
  1220. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1221. 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(),
  1222. MUSER, MUSERNAME, WorkPoints);
  1223. }
  1224. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1225. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1226. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1227. LotNo, ReturnCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1228. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1229. //{
  1230. sql += string.Format(@"
  1231. insert into ICSInventoryLot
  1232. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1233. select
  1234. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','6','{3}','{4}', getdate(),'{5}','{9}'
  1235. from ICSReturn where ReturnCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1236. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ReturnCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1237. sql += "\r\n";
  1238. //}
  1239. }
  1240. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1241. return count;
  1242. }
  1243. /// <summary>
  1244. /// 审核到货单生成条码
  1245. /// </summary>
  1246. /// <param name="POCode"></param>
  1247. /// <param name="PORow"></param>
  1248. /// <param name="keyValue"></param>
  1249. /// 已改
  1250. /// <returns></returns>
  1251. public int SubmitFormSHDH(string DNCode, string Sequence, string INVCode, string keyValue, string WorkPoint)
  1252. {
  1253. try
  1254. {
  1255. string postUrlStr = System.Configuration.ConfigurationManager.AppSettings["HGDocpostUrlStr"].ToString();
  1256. var queryParam = keyValue.ToJObject();
  1257. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1258. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1259. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1260. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1261. decimal LOTQTY = minPackQty;
  1262. string Pre = "DN" + DNCode + Sequence;
  1263. string sql = string.Empty;
  1264. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1265. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1266. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1267. string sqls = string.Empty;
  1268. string Colspan = "";
  1269. string InspectJosn = "";
  1270. InspectJosn += "{";
  1271. InspectJosn += "\"IMP_ORDINI\":[";
  1272. InspectJosn += "{";
  1273. InspectJosn += "\"ORD_ORDINE\":\"" + DNCode + "\",";
  1274. InspectJosn += "\"ORD_DES\":\"采购入库-采购到货单\",";
  1275. InspectJosn += "\"ORD_TIPOOP\":\"V\",";
  1276. InspectJosn += "\"ORD_CLIENTE\":\"" + WorkPoint + "\"";
  1277. InspectJosn += "}";
  1278. InspectJosn += "],";
  1279. InspectJosn += "\"IMP_ORDINI_RIGHE\":[";
  1280. for (int i = 0; i < createPageCount; i++)
  1281. {
  1282. if (i + 1 == createPageCount)
  1283. {
  1284. if (minPackQty * createPageCount > thisCreateQty)
  1285. {
  1286. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1287. }
  1288. }
  1289. //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();
  1290. //sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1291. //object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1292. sqls = $@"SELECT TOP 1 ExtensionID FROM ICSDeliveryNotice WHERE DNCode='{DNCode}'";
  1293. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1294. if (ExtensionID == null)
  1295. {
  1296. ExtensionID = Guid.NewGuid();
  1297. 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)
  1298. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1299. 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(),
  1300. MUSER, MUSERNAME, WorkPoints);
  1301. }
  1302. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1303. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1304. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1305. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1306. sql += string.Format(@"insert into ICSInventoryLot
  1307. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1308. select
  1309. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','7','{3}','{4}', getdate(),'{5}','{9}'
  1310. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1311. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1312. sql += "\r\n";
  1313. if (i == createPageCount - 1)
  1314. {
  1315. InspectJosn += "{";
  1316. InspectJosn += "\"RIG_ORDINE\":\"" + DNCode + "\",";
  1317. InspectJosn += "\"RIG_ARTICOLO\": \"" + INVCode + "\",";
  1318. InspectJosn += "\"RIG_SUB1\": \"" + LotNo + "\",";
  1319. InspectJosn += "\"RIG_SUB2\": \"\",";
  1320. InspectJosn += "\"RIG_QTAR\": " + thisCreateQty + ",";
  1321. InspectJosn += "\"RIG_HOSTINF\": " + Sequence + "";
  1322. InspectJosn += "}";
  1323. }
  1324. else
  1325. {
  1326. InspectJosn += "{";
  1327. InspectJosn += "\"RIG_ORDINE\":\"" + DNCode + "\",";
  1328. InspectJosn += "\"RIG_ARTICOLO\": \"" + INVCode + "\",";
  1329. InspectJosn += "\"RIG_SUB1\": \"" + LotNo + "\",";
  1330. InspectJosn += "\"RIG_SUB2\": \"\",";
  1331. InspectJosn += "\"RIG_QTAR\": " + thisCreateQty + ",";
  1332. InspectJosn += "\"RIG_HOSTINF\": " + Sequence + "";
  1333. InspectJosn += "},";
  1334. }
  1335. }
  1336. InspectJosn += "]";
  1337. InspectJosn += "}";
  1338. string result = "";
  1339. #region 验证物料对应仓储区域,非货柜区域不调用接口向货柜传输数据
  1340. string LocationCode = "";
  1341. string InvWHCode = "";
  1342. string chksql = @"select LocationCode,WHCode from ICSInventoryDetail
  1343. where INVCode='{0}' and WHCode=(
  1344. select WHCode from ICSDeliveryNotice
  1345. where DNCode='{1}' and Sequence='{2}' and WorkPoint='{3}')";
  1346. chksql = string.Format(chksql, INVCode, DNCode, Sequence, WorkPoint);
  1347. DataTable chkdt = SqlHelper.GetDataTableBySql(chksql);
  1348. if (chkdt.Rows.Count == 0)
  1349. {
  1350. throw new Exception("当前选中行物料在对应库存地点没有维护有效的区域,无法生成条码,请确认!");
  1351. }
  1352. else
  1353. {
  1354. LocationCode = chkdt.Rows[0]["LocationCode"].ToString();
  1355. InvWHCode = chkdt.Rows[0]["WHCode"].ToString();
  1356. chksql = @"select F_Id from Sys_SRM_ItemsDetail
  1357. where F_Define3='HGAreaConfig' AND F_Define1='{0}' AND F_Define2='{1}' and F_Define4='{2}'";
  1358. chksql = string.Format(chksql, InvWHCode, LocationCode, WorkPoint);
  1359. chkdt = SqlHelper.GetDataTableBySql(chksql);
  1360. }
  1361. #endregion
  1362. if (chkdt.Rows.Count > 0 && Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UploadERP"]))
  1363. {
  1364. result = HTTPHelper.RestFulGet(InspectJosn, postUrlStr);
  1365. if (!result.Contains("successo"))
  1366. {
  1367. ICSHGResult hgresult = JsonConvert.DeserializeObject<ICSHGResult>(result.TrimStart('[').TrimEnd(']'));
  1368. throw new Exception("货柜单据传输接口调用报错,主要报错信息:" + hgresult.PrimaryError + ",次要报错信息:" + hgresult.SecondaryError + "");
  1369. }
  1370. }
  1371. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1372. return count;
  1373. }
  1374. catch (Exception ex)
  1375. {
  1376. throw new Exception(ex.Message);
  1377. }
  1378. }
  1379. /// <summary>
  1380. /// 审核委外到货单生成条码
  1381. /// </summary>
  1382. /// <param name="POCode"></param>
  1383. /// <param name="PORow"></param>
  1384. /// <param name="keyValue"></param>
  1385. /// 已改
  1386. /// <returns></returns>
  1387. public int SubmitFormWWSHDH(string ODNCode, string Sequence, string keyValue, string WorkPoint)
  1388. {
  1389. var queryParam = keyValue.ToJObject();
  1390. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1391. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1392. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1393. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1394. decimal LOTQTY = minPackQty;
  1395. string Pre = "ODN" + ODNCode + Sequence;
  1396. string sql = string.Empty;
  1397. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1398. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1399. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1400. string sqls = string.Empty;
  1401. string Colspan = "";
  1402. for (int i = 0; i < createPageCount; i++)
  1403. {
  1404. if (i + 1 == createPageCount)
  1405. {
  1406. if (minPackQty * createPageCount > thisCreateQty)
  1407. {
  1408. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1409. }
  1410. }
  1411. 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();
  1412. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1413. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1414. if (ExtensionID == null)
  1415. {
  1416. ExtensionID = Guid.NewGuid();
  1417. 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)
  1418. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1419. 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(),
  1420. MUSER, MUSERNAME, WorkPoints);
  1421. }
  1422. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1423. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1424. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1425. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1426. sql += string.Format(@"
  1427. insert into ICSInventoryLot
  1428. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1429. select
  1430. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','8','{3}','{4}', getdate(),'{5}','{9}'
  1431. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1432. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1433. sql += "\r\n";
  1434. }
  1435. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1436. return count;
  1437. }
  1438. /// <summary>
  1439. /// 开立成品入库单
  1440. /// </summary>
  1441. /// <param name="POCode"></param>
  1442. /// <param name="PORow"></param>
  1443. /// <param name="keyValue"></param>
  1444. /// 已改
  1445. /// <returns></returns>
  1446. public int SubmitFormKLCPRK(string RCVCode, string Sequence, string keyValue, string WorkPoint)
  1447. {
  1448. var queryParam = keyValue.ToJObject();
  1449. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1450. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1451. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1452. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1453. decimal LOTQTY = minPackQty;
  1454. string Pre = "KCP" + RCVCode + Sequence;
  1455. string sql = string.Empty;
  1456. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1457. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1458. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1459. string sqls = string.Empty;
  1460. string Colspan = "";
  1461. for (int i = 0; i < createPageCount; i++)
  1462. {
  1463. if (i + 1 == createPageCount)
  1464. {
  1465. if (minPackQty * createPageCount > thisCreateQty)
  1466. {
  1467. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1468. }
  1469. }
  1470. 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();
  1471. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1472. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1473. if (ExtensionID == null)
  1474. {
  1475. ExtensionID = Guid.NewGuid();
  1476. 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)
  1477. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1478. 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(),
  1479. MUSER, MUSERNAME, WorkPoints);
  1480. }
  1481. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1482. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1483. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1484. LotNo, RCVCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1485. sql += string.Format(@"
  1486. insert into ICSInventoryLot
  1487. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1488. select
  1489. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','9','{3}','{4}', getdate(),'{5}','{9}'
  1490. from ICSManufactureReceive where RCVCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1491. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, RCVCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1492. sql += "\r\n";
  1493. }
  1494. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1495. return count;
  1496. }
  1497. //委外拒收单
  1498. public DataTable GetGridJsonWWJSD(string queryJson, ref Pagination jqgridparam)
  1499. {
  1500. DataTable dt = new DataTable();
  1501. var queryParam = queryJson.ToJObject();
  1502. List<DbParameter> parameter = new List<DbParameter>();
  1503. object Figure = GetDecimalDigits();
  1504. #region [SQL]
  1505. 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,
  1506. 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
  1507. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1508. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1509. from ICSODeliveryNotice a
  1510. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1511. left join (
  1512. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1513. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='11'
  1514. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1515. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1516. --inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  1517. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1518. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1519. where a.ODNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
  1520. ";
  1521. sql = string.Format(sql, Figure);
  1522. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1523. #endregion
  1524. if (!string.IsNullOrWhiteSpace(queryJson))
  1525. {
  1526. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1527. {
  1528. sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1529. }
  1530. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1531. {
  1532. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1533. }
  1534. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1535. {
  1536. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1537. }
  1538. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1539. {
  1540. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1541. }
  1542. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1543. {
  1544. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1545. }
  1546. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1547. {
  1548. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1549. }
  1550. }
  1551. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1552. {
  1553. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1554. }
  1555. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1556. {
  1557. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1558. }
  1559. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1560. }
  1561. //拒收单
  1562. public DataTable GetGridJsonJSD(string queryJson, ref Pagination jqgridparam)
  1563. {
  1564. DataTable dt = new DataTable();
  1565. var queryParam = queryJson.ToJObject();
  1566. List<DbParameter> parameter = new List<DbParameter>();
  1567. object Figure = GetDecimalDigits();
  1568. #region [SQL]
  1569. string sql = @"select a.ID,a.DNCode ,a.Sequence ,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  1570. 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,
  1571. CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1572. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1573. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1574. from ICSDeliveryNotice a
  1575. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1576. left join (
  1577. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1578. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='10'
  1579. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1580. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1581. --inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  1582. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1583. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1584. where a.DNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
  1585. ";
  1586. sql = string.Format(sql, Figure);
  1587. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1588. #endregion
  1589. if (!string.IsNullOrWhiteSpace(queryJson))
  1590. {
  1591. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1592. {
  1593. sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1594. }
  1595. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1596. {
  1597. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1598. }
  1599. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1600. {
  1601. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1602. }
  1603. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1604. {
  1605. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1606. }
  1607. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1608. {
  1609. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1610. }
  1611. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1612. {
  1613. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1614. }
  1615. }
  1616. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1617. {
  1618. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1619. }
  1620. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1621. {
  1622. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1623. }
  1624. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1625. }
  1626. //领料申请退料
  1627. public DataTable GetGridJsonLLSQTL(string queryJson, ref Pagination jqgridparam)
  1628. {
  1629. DataTable dt = new DataTable();
  1630. var queryParam = queryJson.ToJObject();
  1631. List<DbParameter> parameter = new List<DbParameter>();
  1632. object Figure = GetDecimalDigits();
  1633. #region [SQL]
  1634. string sql = @"select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  1635. 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
  1636. ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1637. ,a.WHCode,detail.LocationCode AS Area,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1638. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1639. from ICSMOApplyNegDetail a
  1640. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1641. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1642. LEFT JOIN ICSInventoryDetail detail ON b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  1643. left join (
  1644. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1645. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='12'
  1646. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1647. )c
  1648. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1649. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1650. WHERE d.Type='2'";
  1651. sql = string.Format(sql, Figure);
  1652. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1653. #endregion
  1654. if (!string.IsNullOrWhiteSpace(queryJson))
  1655. {
  1656. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1657. {
  1658. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1659. }
  1660. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1661. {
  1662. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1663. }
  1664. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1665. {
  1666. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1667. }
  1668. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1669. {
  1670. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1671. }
  1672. if (!string.IsNullOrWhiteSpace(queryParam["Location"].ToString()))
  1673. {
  1674. sql += " and a.WHCode like '%" + queryParam["Location"].ToString() + "%' ";
  1675. }
  1676. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  1677. {
  1678. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  1679. }
  1680. }
  1681. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1682. {
  1683. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1684. }
  1685. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1686. {
  1687. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1688. }
  1689. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1690. }
  1691. /// <summary>
  1692. /// 拒收生成条码
  1693. /// </summary>
  1694. /// <param name="POCode"></param>
  1695. /// <param name="PORow"></param>
  1696. /// <param name="keyValue"></param>
  1697. /// <returns></returns>
  1698. public int SubmitFormJSD(string DNCode, string Sequence, string keyValue, string WorkPoint)
  1699. {
  1700. var queryParam = keyValue.ToJObject();
  1701. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1702. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1703. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1704. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1705. decimal LOTQTY = minPackQty;
  1706. string Pre = "JS" + DNCode + Sequence;
  1707. string sql = string.Empty;
  1708. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1709. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1710. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1711. string sqls = string.Empty;
  1712. string Colspan = "";
  1713. for (int i = 0; i < createPageCount; i++)
  1714. {
  1715. if (i + 1 == createPageCount)
  1716. {
  1717. if (minPackQty * createPageCount > thisCreateQty)
  1718. {
  1719. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1720. }
  1721. }
  1722. 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();
  1723. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1724. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1725. if (ExtensionID == null)
  1726. {
  1727. ExtensionID = Guid.NewGuid();
  1728. 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)
  1729. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1730. 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(),
  1731. MUSER, MUSERNAME, WorkPoints);
  1732. }
  1733. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1734. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1735. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1736. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1737. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1738. //{
  1739. sql += string.Format(@"
  1740. insert into ICSInventoryLot
  1741. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1742. select
  1743. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','10','{3}','{4}', getdate(),'{5}','{9}'
  1744. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1745. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1746. sql += "\r\n";
  1747. //}
  1748. }
  1749. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1750. return count;
  1751. }
  1752. /// <summary>
  1753. /// 委外拒收生成条码
  1754. /// </summary>
  1755. /// <param name="POCode"></param>
  1756. /// <param name="PORow"></param>
  1757. /// <param name="keyValue"></param>
  1758. /// <returns></returns>
  1759. public int SubmitFormWWJSD(string ODNCode, string Sequence, string keyValue, string WorkPoint)
  1760. {
  1761. var queryParam = keyValue.ToJObject();
  1762. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1763. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1764. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1765. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1766. decimal LOTQTY = minPackQty;
  1767. string Pre = "OJS" + ODNCode + Sequence;
  1768. string sql = string.Empty;
  1769. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1770. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1771. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1772. string sqls = string.Empty;
  1773. string Colspan = "";
  1774. for (int i = 0; i < createPageCount; i++)
  1775. {
  1776. if (i + 1 == createPageCount)
  1777. {
  1778. if (minPackQty * createPageCount > thisCreateQty)
  1779. {
  1780. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1781. }
  1782. }
  1783. 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();
  1784. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1785. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1786. if (ExtensionID == null)
  1787. {
  1788. ExtensionID = Guid.NewGuid();
  1789. 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)
  1790. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1791. 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(),
  1792. MUSER, MUSERNAME, WorkPoints);
  1793. }
  1794. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1795. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1796. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1797. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1798. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1799. //{
  1800. sql += string.Format(@"
  1801. insert into ICSInventoryLot
  1802. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1803. select
  1804. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','11','{3}','{4}', getdate(),'{5}','{9}'
  1805. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1806. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1807. sql += "\r\n";
  1808. //}
  1809. }
  1810. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1811. return count;
  1812. }
  1813. /// <summary>
  1814. /// 点击审核到货单生成条码(审核到货单)
  1815. /// </summary>
  1816. public DataTable GetSubGridJsonJSDByCreate(string DNCode, string Sequence, string WorkPoint)
  1817. {
  1818. DataTable dt = new DataTable();
  1819. object Figure = GetDecimalDigits();
  1820. List<DbParameter> parameter = new List<DbParameter>();
  1821. 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,
  1822. 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
  1823. from ICSDeliveryNotice a
  1824. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1825. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1826. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1827. group by b.TransCode,b.TransSequence
  1828. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
  1829. WHERE a.DNType='3'
  1830. and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
  1831. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1832. sql = string.Format(sql, Figure);
  1833. return Repository().FindTableBySql(sql.ToString());
  1834. }
  1835. /// <summary>
  1836. /// 点击审核委外到货单生成条码(审核委外到货单)
  1837. /// </summary>
  1838. public DataTable GetSubGridJsonWWJSDByCreate(string ODNCode, string Sequence, string WorkPoint)
  1839. {
  1840. DataTable dt = new DataTable();
  1841. object Figure = GetDecimalDigits();
  1842. List<DbParameter> parameter = new List<DbParameter>();
  1843. 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,
  1844. 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
  1845. from ICSODeliveryNotice a
  1846. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1847. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1848. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1849. group by b.TransCode,b.TransSequence
  1850. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
  1851. WHERE a.ODNType='3'
  1852. and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
  1853. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1854. sql = string.Format(sql, Figure);
  1855. return Repository().FindTableBySql(sql.ToString());
  1856. }
  1857. public DataTable GetSubGridJsonLLSQDByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  1858. {
  1859. DataTable dt = new DataTable();
  1860. object Figure = GetDecimalDigits();
  1861. List<DbParameter> parameter = new List<DbParameter>();
  1862. 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,
  1863. 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
  1864. from ICSMOApplyNegDetail a
  1865. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1866. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1867. left join (
  1868. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1869. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1870. group by b.TransCode,b.TransSequence
  1871. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  1872. WHERE d.Type='2'
  1873. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  1874. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1875. sql = string.Format(sql, Figure);
  1876. return Repository().FindTableBySql(sql.ToString());
  1877. }
  1878. //领料申请退料生成条码
  1879. public int SubmitFormLLSQTL(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  1880. {
  1881. var queryParam = keyValue.ToJObject();
  1882. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1883. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1884. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1885. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1886. decimal LOTQTY = minPackQty;
  1887. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1888. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  1889. string Pre = "MA" + ApplyNegCode + Sequence;
  1890. string sql = string.Empty;
  1891. //string VendorLot = queryParam["VendorLot"].ToString();
  1892. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1893. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1894. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1895. string sqls = string.Empty;
  1896. string Colspan = "";
  1897. for (int i = 0; i < createPageCount; i++)
  1898. {
  1899. if (i + 1 == createPageCount)
  1900. {
  1901. if (minPackQty * createPageCount > thisCreateQty)
  1902. {
  1903. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1904. }
  1905. }
  1906. 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();
  1907. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1908. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1909. if (ExtensionID == null)
  1910. {
  1911. ExtensionID = Guid.NewGuid();
  1912. 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)
  1913. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1914. 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(),
  1915. MUSER, MUSERNAME, WorkPoints);
  1916. }
  1917. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1918. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1919. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1920. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1921. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1922. //{
  1923. sql += string.Format(@"insert into ICSInventoryLot
  1924. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1925. select
  1926. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','12','{3}','{4}', getdate(),'{5}','{9}'
  1927. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1928. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1929. sql += "\r\n";
  1930. //}
  1931. }
  1932. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1933. return count;
  1934. }
  1935. //材料出库退料
  1936. public DataTable GetGridJsonCLCK(string queryJson, ref Pagination jqgridparam)
  1937. {
  1938. DataTable dt = new DataTable();
  1939. var queryParam = queryJson.ToJObject();
  1940. List<DbParameter> parameter = new List<DbParameter>();
  1941. object Figure = GetDecimalDigits();
  1942. #region [SQL]
  1943. string sql = @"
  1944. select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  1945. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity,
  1946. 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
  1947. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1948. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1949. from ICSMOApplyNegDetail a
  1950. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1951. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1952. left join (
  1953. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1954. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='13'
  1955. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1956. )c
  1957. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1958. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1959. WHERE d.Type='3'";
  1960. sql = string.Format(sql, Figure);
  1961. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1962. #endregion
  1963. if (!string.IsNullOrWhiteSpace(queryJson))
  1964. {
  1965. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1966. {
  1967. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1968. }
  1969. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1970. {
  1971. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1972. }
  1973. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1974. {
  1975. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1976. }
  1977. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1978. {
  1979. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1980. }
  1981. }
  1982. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1983. {
  1984. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1985. }
  1986. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1987. {
  1988. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1989. }
  1990. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1991. }
  1992. //材料出库退料
  1993. public DataTable GetSubGridJsonCLCKByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  1994. {
  1995. DataTable dt = new DataTable();
  1996. object Figure = GetDecimalDigits();
  1997. List<DbParameter> parameter = new List<DbParameter>();
  1998. 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,
  1999. 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
  2000. from ICSMOApplyNegDetail a
  2001. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  2002. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2003. left join (
  2004. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2005. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2006. group by b.TransCode,b.TransSequence
  2007. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2008. WHERE d.Type='3'
  2009. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2010. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2011. sql = string.Format(sql, Figure);
  2012. return Repository().FindTableBySql(sql.ToString());
  2013. }
  2014. //材料出库退料生成条码
  2015. public int SubmitFormCLCKT(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2016. {
  2017. var queryParam = keyValue.ToJObject();
  2018. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2019. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2020. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2021. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2022. decimal LOTQTY = minPackQty;
  2023. string Pre = "MD" + ApplyNegCode + Sequence;
  2024. string sql = string.Empty;
  2025. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2026. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2027. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2028. string sqls = string.Empty;
  2029. string Colspan = "";
  2030. for (int i = 0; i < createPageCount; i++)
  2031. {
  2032. if (i + 1 == createPageCount)
  2033. {
  2034. if (minPackQty * createPageCount > thisCreateQty)
  2035. {
  2036. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2037. }
  2038. }
  2039. 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();
  2040. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2041. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2042. if (ExtensionID == null)
  2043. {
  2044. ExtensionID = Guid.NewGuid();
  2045. 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)
  2046. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2047. 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(),
  2048. MUSER, MUSERNAME, WorkPoints);
  2049. }
  2050. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2051. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2052. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2053. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2054. sql += string.Format(@"insert into ICSInventoryLot
  2055. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2056. select
  2057. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','13','{3}','{4}', getdate(),'{5}','{9}'
  2058. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2059. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2060. sql += "\r\n";
  2061. }
  2062. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2063. return count;
  2064. }
  2065. public DataTable GetGridJsonWWLLTL(string queryJson, ref Pagination jqgridparam)
  2066. {
  2067. DataTable dt = new DataTable();
  2068. var queryParam = queryJson.ToJObject();
  2069. List<DbParameter> parameter = new List<DbParameter>();
  2070. object Figure = GetDecimalDigits();
  2071. #region [SQL]
  2072. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2073. 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
  2074. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2075. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2076. from ICSOApplyNegDetail a
  2077. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2078. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2079. left join (
  2080. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2081. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='14'
  2082. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2083. )c
  2084. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2085. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2086. WHERE d.Type='2'";
  2087. sql = string.Format(sql, Figure);
  2088. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2089. #endregion
  2090. if (!string.IsNullOrWhiteSpace(queryJson))
  2091. {
  2092. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2093. {
  2094. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2095. }
  2096. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2097. {
  2098. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2099. }
  2100. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2101. {
  2102. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2103. }
  2104. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2105. {
  2106. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2107. }
  2108. }
  2109. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2110. {
  2111. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2112. }
  2113. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2114. {
  2115. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2116. }
  2117. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2118. }
  2119. /// <summary>
  2120. /// 点击委外领料退料生成条码
  2121. /// </summary>
  2122. public DataTable GetSubGridJsonWWLLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  2123. {
  2124. DataTable dt = new DataTable();
  2125. object Figure = GetDecimalDigits();
  2126. List<DbParameter> parameter = new List<DbParameter>();
  2127. string sql = @"
  2128. 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,
  2129. 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
  2130. from ICSOApplyNegDetail a
  2131. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2132. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2133. left join (
  2134. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2135. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2136. group by b.TransCode,b.TransSequence
  2137. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2138. WHERE d.Type='2'
  2139. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2140. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2141. sql = string.Format(sql, Figure);
  2142. return Repository().FindTableBySql(sql.ToString());
  2143. }
  2144. //委外领料申请退料
  2145. public int SubmitFormWWLL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2146. {
  2147. var queryParam = keyValue.ToJObject();
  2148. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2149. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2150. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2151. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2152. decimal LOTQTY = minPackQty;
  2153. string Pre = "OMA" + OApplyNegCode + Sequence;
  2154. string sql = string.Empty;
  2155. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2156. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2157. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2158. string sqls = string.Empty;
  2159. string Colspan = "";
  2160. for (int i = 0; i < createPageCount; i++)
  2161. {
  2162. if (i + 1 == createPageCount)
  2163. {
  2164. if (minPackQty * createPageCount > thisCreateQty)
  2165. {
  2166. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2167. }
  2168. }
  2169. 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();
  2170. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2171. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2172. if (ExtensionID == null)
  2173. {
  2174. ExtensionID = Guid.NewGuid();
  2175. 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)
  2176. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2177. 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(),
  2178. MUSER, MUSERNAME, WorkPoints);
  2179. }
  2180. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2181. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2182. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2183. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2184. sql += string.Format(@"insert into ICSInventoryLot
  2185. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2186. select
  2187. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','14','{3}','{4}', getdate(),'{5}','{9}'
  2188. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2189. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2190. sql += "\r\n";
  2191. }
  2192. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2193. return count;
  2194. }
  2195. //委外材料出库
  2196. public DataTable GetGridJsonWWCLCK(string queryJson, ref Pagination jqgridparam)
  2197. {
  2198. DataTable dt = new DataTable();
  2199. var queryParam = queryJson.ToJObject();
  2200. List<DbParameter> parameter = new List<DbParameter>();
  2201. object Figure = GetDecimalDigits();
  2202. #region [SQL]
  2203. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2204. 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
  2205. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2206. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2207. from ICSOApplyNegDetail a
  2208. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2209. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2210. left join (
  2211. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2212. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='15'
  2213. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2214. )c
  2215. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2216. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2217. WHERE d.Type='3'";
  2218. sql = string.Format(sql, Figure);
  2219. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2220. #endregion
  2221. if (!string.IsNullOrWhiteSpace(queryJson))
  2222. {
  2223. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2224. {
  2225. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2226. }
  2227. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2228. {
  2229. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2230. }
  2231. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2232. {
  2233. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2234. }
  2235. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2236. {
  2237. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2238. }
  2239. }
  2240. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2241. {
  2242. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2243. }
  2244. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2245. {
  2246. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2247. }
  2248. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2249. }
  2250. //委外材料出库
  2251. public DataTable GetSubGridJsonWWCLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  2252. {
  2253. DataTable dt = new DataTable();
  2254. object Figure = GetDecimalDigits();
  2255. List<DbParameter> parameter = new List<DbParameter>();
  2256. string sql = @"
  2257. 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,
  2258. 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
  2259. from ICSOApplyNegDetail a
  2260. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2261. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2262. left join (
  2263. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2264. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2265. group by b.TransCode,b.TransSequence
  2266. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2267. WHERE d.Type='3'
  2268. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2269. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2270. sql = string.Format(sql, Figure);
  2271. return Repository().FindTableBySql(sql.ToString());
  2272. }
  2273. //委外材料出库
  2274. public int SubmitFormWWCL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2275. {
  2276. var queryParam = keyValue.ToJObject();
  2277. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2278. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2279. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2280. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2281. decimal LOTQTY = minPackQty;
  2282. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2283. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  2284. string Pre = "OMD" + OApplyNegCode + Sequence;
  2285. string sql = string.Empty;
  2286. //string VendorLot = queryParam["VendorLot"].ToString();
  2287. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2288. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2289. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2290. string sqls = string.Empty;
  2291. string Colspan = "";
  2292. for (int i = 0; i < createPageCount; i++)
  2293. {
  2294. if (i + 1 == createPageCount)
  2295. {
  2296. if (minPackQty * createPageCount > thisCreateQty)
  2297. {
  2298. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2299. }
  2300. }
  2301. 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();
  2302. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2303. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2304. if (ExtensionID == null)
  2305. {
  2306. ExtensionID = Guid.NewGuid();
  2307. 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)
  2308. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2309. 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(),
  2310. MUSER, MUSERNAME, WorkPoints);
  2311. }
  2312. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2313. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2314. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2315. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2316. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  2317. //{
  2318. sql += string.Format(@"insert into ICSInventoryLot
  2319. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2320. select
  2321. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','15','{3}','{4}', getdate(),'{5}','{9}'
  2322. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2323. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2324. sql += "\r\n";
  2325. //}
  2326. }
  2327. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2328. return count;
  2329. }
  2330. public DataTable SelectICSExtensionEnable(string BeginTime, string EndTime)
  2331. {
  2332. string sql = @"select ColCode from ICSExtensionEnable
  2333. where Enable=0
  2334. order by cast(EATTRIBUTE1 as int)";
  2335. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2336. return dt;
  2337. }
  2338. //返工工单
  2339. public DataTable GetGridJsonFGGD(string queryJson, ref Pagination jqgridparam)
  2340. {
  2341. DataTable dt = new DataTable();
  2342. var queryParam = queryJson.ToJObject();
  2343. List<DbParameter> parameter = new List<DbParameter>();
  2344. object Figure = GetDecimalDigits();
  2345. #region [SQL]
  2346. 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,
  2347. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  2348. 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
  2349. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2350. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2351. from ICSMOPick a
  2352. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint
  2353. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2354. left join (
  2355. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2356. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='16'
  2357. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2358. )c
  2359. on d.MOCode=c.TransCode and d.Sequence+'-'+a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2360. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2361. where a.EATTRIBUTE1='1' and d.EATTRIBUTE1='1'";
  2362. sql = string.Format(sql, Figure);
  2363. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2364. #endregion
  2365. if (!string.IsNullOrWhiteSpace(queryJson))
  2366. {
  2367. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2368. {
  2369. sql += " and d.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2370. }
  2371. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2372. {
  2373. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2374. }
  2375. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2376. {
  2377. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2378. }
  2379. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2380. {
  2381. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2382. }
  2383. }
  2384. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2385. {
  2386. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2387. }
  2388. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2389. {
  2390. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2391. }
  2392. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2393. }
  2394. public DataTable GetSubGridJsonFGGDCreate(string FGGDMOCode, string Sequence, string WorkPoint)
  2395. {
  2396. DataTable dt = new DataTable();
  2397. object Figure = GetDecimalDigits();
  2398. List<DbParameter> parameter = new List<DbParameter>();
  2399. string sql = @"
  2400. 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,
  2401. 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
  2402. from ICSMOPick a
  2403. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint
  2404. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2405. left join (
  2406. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2407. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2408. group by b.TransCode,b.TransSequence
  2409. ) c on d.MOCode=c.TransCode and d.Sequence+'-'+a.Sequence=c.TransSequence
  2410. WHERE 1=1
  2411. and d.MOCode='" + FGGDMOCode + "' and d.Sequence+'-'+a.Sequence='" + Sequence + "'";
  2412. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2413. sql = string.Format(sql, Figure);
  2414. return Repository().FindTableBySql(sql.ToString());
  2415. }
  2416. //返工工单
  2417. public int SubmitFormFGGD(string FGGDMOCode, string Sequence, string keyValue, string WorkPoint)
  2418. {
  2419. var queryParam = keyValue.ToJObject();
  2420. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2421. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2422. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2423. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2424. decimal LOTQTY = minPackQty;
  2425. string Pre = "FG" + FGGDMOCode + Sequence;
  2426. string sql = string.Empty;
  2427. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2428. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2429. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2430. string sqls = string.Empty;
  2431. string Colspan = "";
  2432. for (int i = 0; i < createPageCount; i++)
  2433. {
  2434. if (i + 1 == createPageCount)
  2435. {
  2436. if (minPackQty * createPageCount > thisCreateQty)
  2437. {
  2438. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2439. }
  2440. }
  2441. 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();
  2442. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2443. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2444. if (ExtensionID == null)
  2445. {
  2446. ExtensionID = Guid.NewGuid();
  2447. 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)
  2448. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2449. 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(),
  2450. MUSER, MUSERNAME, WorkPoints);
  2451. }
  2452. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2453. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2454. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2455. LotNo, FGGDMOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2456. sql += string.Format(@"insert into ICSInventoryLot
  2457. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2458. select
  2459. newid(),'{0}',a.InvCode,'{1}','{10}','{2}','{8}','16','{3}','{4}', getdate(),'{5}','{9}'
  2460. 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}' ",
  2461. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, FGGDMOCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2462. sql += "\r\n";
  2463. }
  2464. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2465. return count;
  2466. }
  2467. public object GetDecimalDigits()
  2468. {
  2469. try
  2470. {
  2471. string sql = string.Empty;
  2472. sql = @"select Figure from ICSConfiguration where Code='Figure001' and Enable='1'";
  2473. object Figure = SqlHelper.ExecuteScalar(sql);
  2474. return Figure;
  2475. }
  2476. catch (Exception ex)
  2477. {
  2478. throw new Exception(ex.Message.ToString());
  2479. }
  2480. }
  2481. public object GetQiSetNum(string keyValue)
  2482. {
  2483. int Num = 0;
  2484. string msg = "";
  2485. string APIURL = ConfigurationManager.ConnectionStrings["ERPAPIURL"].ConnectionString + "Complete/Approve";
  2486. string result = HttpPost(APIURL, keyValue);
  2487. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  2488. string MessAge = Obj["Message"].ToString();
  2489. string Success = Obj["Success"].ToString();
  2490. if (Success.ToUpper() == "FALSE")
  2491. {
  2492. msg = MessAge;
  2493. }
  2494. if (msg == "")
  2495. {
  2496. JArray res = (JArray)JsonConvert.DeserializeObject(Obj["Data"].ToString());
  2497. foreach (var item in res)
  2498. {
  2499. JObject jo = (JObject)item;
  2500. Num = Convert.ToInt32(jo["min_lotqty"].ToString());
  2501. }
  2502. }
  2503. var Header = new
  2504. {
  2505. msg = msg,
  2506. Num = Num,
  2507. };
  2508. return Header;
  2509. }
  2510. //接口api解析
  2511. public static string HttpPost(string url, string body)
  2512. {
  2513. try
  2514. {
  2515. Encoding encoding = Encoding.UTF8;
  2516. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  2517. request.Method = "POST";
  2518. request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
  2519. request.ContentType = "application/json; charset=utf-8";
  2520. byte[] buffer = encoding.GetBytes(body);
  2521. request.ContentLength = buffer.Length;
  2522. request.GetRequestStream().Write(buffer, 0, buffer.Length);
  2523. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  2524. using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
  2525. {
  2526. return reader.ReadToEnd();
  2527. }
  2528. }
  2529. catch (WebException ex)
  2530. {
  2531. throw new Exception(ex.Message);
  2532. }
  2533. }
  2534. }
  2535. }