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

2625 lines
162 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
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
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
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
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
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
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
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
2 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
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
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
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
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. public DataTable GetGridJsonXiaoShou(string queryJson, ref Pagination jqgridparam)
  519. {
  520. DataTable dt = new DataTable();
  521. var queryParam = queryJson.ToJObject();
  522. List<DbParameter> parameter = new List<DbParameter>();
  523. object Figure = GetDecimalDigits();
  524. #region [SQL]
  525. string sql = @" select a.ID,a.SDNCode,a.Sequence,a.SOCode,a.SOSequence,a.CusCode,a.CusName,a.Type,a.ArriveDate,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  526. ,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
  527. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  528. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  529. from ICSSDN a
  530. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  531. left join (
  532. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  533. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='4'
  534. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  535. )c
  536. on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  537. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  538. where a.Type='2'";
  539. sql = string.Format(sql, Figure);
  540. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  541. #endregion
  542. if (!string.IsNullOrWhiteSpace(queryJson))
  543. {
  544. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  545. {
  546. sql += " and a.SDNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  547. }
  548. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  549. {
  550. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  551. }
  552. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  553. {
  554. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  555. }
  556. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  557. {
  558. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  559. }
  560. }
  561. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  562. {
  563. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  564. }
  565. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  566. {
  567. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  568. }
  569. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  570. }
  571. /// <summary>
  572. /// 点击销售退货生成条码(销售退货)
  573. /// </summary>
  574. public DataTable GetSubGridJsonXiaoShouByCreate(string SDNCode, string Sequence, string WorkPoint)
  575. {
  576. DataTable dt = new DataTable();
  577. object Figure = GetDecimalDigits();
  578. List<DbParameter> parameter = new List<DbParameter>();
  579. 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,
  580. 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
  581. from ICSSDN a
  582. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  583. left join (
  584. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  585. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  586. group by b.TransCode,b.TransSequence
  587. ) c on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence
  588. WHERE 1 =1
  589. and a.Type='2' and a.SDNCode='" + SDNCode + "' and a.Sequence='" + Sequence + "'";
  590. sql += " and a.WorkPoint='" + WorkPoint + "'";
  591. sql = string.Format(sql, Figure);
  592. return Repository().FindTableBySql(sql.ToString());
  593. }
  594. /// <summary>
  595. /// 销售退货生成条码
  596. /// </summary>
  597. /// <param name="POCode"></param>
  598. /// <param name="PORow"></param>
  599. /// <param name="keyValue"></param>
  600. /// 已改
  601. /// <returns></returns>
  602. public int SubmitFormXiaoShou(string SDNCode, string Sequence, string keyValue, string WorkPoint)
  603. {
  604. var queryParam = keyValue.ToJObject();
  605. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  606. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  607. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  608. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  609. decimal LOTQTY = minPackQty;
  610. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  611. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  612. string Pre = "SR" + SDNCode + Sequence;
  613. string sql = string.Empty;
  614. //string VendorLot = queryParam["VendorLot"].ToString();
  615. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  616. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  617. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  618. string sqls = string.Empty;
  619. string Colspan = "";
  620. for (int i = 0; i < createPageCount; i++)
  621. {
  622. if (i + 1 == createPageCount)
  623. {
  624. if (minPackQty * createPageCount > thisCreateQty)
  625. {
  626. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  627. }
  628. }
  629. 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();
  630. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  631. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  632. if (ExtensionID == null)
  633. {
  634. ExtensionID = Guid.NewGuid();
  635. 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)
  636. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  637. 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(),
  638. MUSER, MUSERNAME, WorkPoints);
  639. }
  640. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  641. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  642. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}')",
  643. LotNo, SDNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  644. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  645. //{
  646. sql += string.Format(@"
  647. insert into ICSInventoryLot
  648. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  649. select
  650. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','4','{3}','{4}', getdate(),'{5}','{9}'
  651. from ICSSDN where Type='2' and SDNCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  652. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, SDNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  653. sql += "\r\n";
  654. //}
  655. }
  656. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  657. return count;
  658. }
  659. public DataTable GetGridJsonQiTa(string queryJson, ref Pagination jqgridparam)
  660. {
  661. DataTable dt = new DataTable();
  662. var queryParam = queryJson.ToJObject();
  663. List<DbParameter> parameter = new List<DbParameter>();
  664. object Figure = GetDecimalDigits();
  665. #region [SQL]
  666. string sql = @" select a.ID,a.InCode,a.Sequence,a.WHCode,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  667. 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
  668. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  669. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  670. from ICSOtherIn a
  671. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  672. left join (
  673. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  674. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='5'
  675. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  676. )c
  677. on a.InCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  678. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  679. where a.Status='1'";
  680. sql = string.Format(sql, Figure);
  681. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  682. #endregion
  683. if (!string.IsNullOrWhiteSpace(queryJson))
  684. {
  685. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  686. {
  687. sql += " and a.InCode like '%" + queryParam["POCode"].ToString() + "%' ";
  688. }
  689. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  690. {
  691. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  692. }
  693. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  694. {
  695. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  696. }
  697. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  698. {
  699. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  700. }
  701. }
  702. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  703. {
  704. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  705. }
  706. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  707. {
  708. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  709. }
  710. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  711. }
  712. /// <summary>
  713. /// 点击销售退货生成条码(其他入库)
  714. /// </summary>
  715. public DataTable GetSubGridJsonQiTaByCreate(string InCode, string Sequence, string WorkPoint)
  716. {
  717. DataTable dt = new DataTable();
  718. object Figure = GetDecimalDigits();
  719. List<DbParameter> parameter = new List<DbParameter>();
  720. 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,
  721. 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
  722. from ICSOtherIn a
  723. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  724. left join (
  725. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  726. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  727. group by b.TransCode,b.TransSequence
  728. ) c on a.InCode=c.TransCode and a.Sequence=c.TransSequence
  729. WHERE 1 =1
  730. and a.InCode='" + InCode + "' and a.Sequence='" + Sequence + "'";
  731. sql += " and a.WorkPoint='" + WorkPoint + "'";
  732. sql = string.Format(sql, Figure);
  733. return Repository().FindTableBySql(sql.ToString());
  734. }
  735. /// <summary>
  736. /// 其他入库生成条码
  737. /// </summary>
  738. /// <param name="POCode"></param>
  739. /// <param name="PORow"></param>
  740. /// <param name="keyValue"></param>
  741. /// 已改
  742. /// <returns></returns>
  743. public int SubmitFormQiTa(string InCode, string Sequence, string keyValue, string WorkPoint)
  744. {
  745. var queryParam = keyValue.ToJObject();
  746. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  747. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  748. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  749. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  750. decimal LOTQTY = minPackQty;
  751. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  752. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  753. string Pre = "QT" + InCode + Sequence;
  754. string sql = string.Empty;
  755. //string VendorLot = queryParam["VendorLot"].ToString();
  756. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  757. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  758. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  759. string sqls = string.Empty;
  760. string Colspan = "";
  761. for (int i = 0; i < createPageCount; i++)
  762. {
  763. if (i + 1 == createPageCount)
  764. {
  765. if (minPackQty * createPageCount > thisCreateQty)
  766. {
  767. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  768. }
  769. }
  770. 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();
  771. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  772. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  773. if (ExtensionID == null)
  774. {
  775. ExtensionID = Guid.NewGuid();
  776. 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)
  777. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  778. 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(),
  779. MUSER, MUSERNAME, WorkPoints);
  780. }
  781. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  782. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  783. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  784. LotNo, InCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  785. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  786. //{
  787. sql += string.Format(@"
  788. insert into ICSInventoryLot
  789. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  790. select
  791. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','5','{3}','{4}', getdate(),'{5}','{9}'
  792. from ICSOtherIn where InCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  793. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, InCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  794. sql += "\r\n";
  795. //}
  796. }
  797. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  798. return count;
  799. }
  800. //归还
  801. public DataTable GetGridJsonGuiHuan(string queryJson, ref Pagination jqgridparam)
  802. {
  803. DataTable dt = new DataTable();
  804. var queryParam = queryJson.ToJObject();
  805. List<DbParameter> parameter = new List<DbParameter>();
  806. object Figure = GetDecimalDigits();
  807. #region [SQL]
  808. string sql = @"select a.ID,a.ReturnCode,a.Sequence,a.WHCode,a.InvCode, 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
  809. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  810. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10 from ICSReturn a
  811. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  812. left join (
  813. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  814. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='6'
  815. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  816. ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  817. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  818. where a.Status='2'";
  819. sql = string.Format(sql, Figure);
  820. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  821. #endregion
  822. if (!string.IsNullOrWhiteSpace(queryJson))
  823. {
  824. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  825. {
  826. sql += " and a.ReturnCode like '%" + queryParam["POCode"].ToString() + "%' ";
  827. }
  828. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  829. {
  830. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  831. }
  832. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  833. {
  834. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  835. }
  836. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  837. {
  838. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  839. }
  840. }
  841. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  842. {
  843. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  844. }
  845. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  846. {
  847. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  848. }
  849. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  850. }
  851. //审核到货单(采购订单需与审核到货单一起同步)
  852. public DataTable GetGridJsonSHDH(string queryJson, ref Pagination jqgridparam)
  853. {
  854. DataTable dt = new DataTable();
  855. var queryParam = queryJson.ToJObject();
  856. List<DbParameter> parameter = new List<DbParameter>();
  857. object Figure = GetDecimalDigits();
  858. #region [SQL]
  859. string sql = @"select a.ID, '' as 'POCode',-- d.POCode,d.Sequence as POSequence,
  860. '' as POSequence,
  861. a.DNCode,a.Sequence,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  862. 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
  863. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  864. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  865. from ICSDeliveryNotice a
  866. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  867. left join (
  868. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  869. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='7'
  870. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  871. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  872. -- inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  873. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  874. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  875. where a.DNType='1' and a.Status='2' and a.ASNCode is null
  876. ";
  877. sql = string.Format(sql, Figure);
  878. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  879. #endregion
  880. if (!string.IsNullOrWhiteSpace(queryJson))
  881. {
  882. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  883. {
  884. sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  885. }
  886. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  887. {
  888. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  889. }
  890. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  891. {
  892. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  893. }
  894. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  895. {
  896. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  897. }
  898. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  899. {
  900. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  901. }
  902. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  903. {
  904. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  905. }
  906. }
  907. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  908. {
  909. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  910. }
  911. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  912. {
  913. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  914. }
  915. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  916. }
  917. //审核委外到货单
  918. public DataTable GetGridJsonWWSHDH(string queryJson, ref Pagination jqgridparam)
  919. {
  920. DataTable dt = new DataTable();
  921. var queryParam = queryJson.ToJObject();
  922. List<DbParameter> parameter = new List<DbParameter>();
  923. object Figure = GetDecimalDigits();
  924. #region [SQL]
  925. 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,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,
  926. CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  927. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  928. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  929. from ICSODeliveryNotice a
  930. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  931. left join (
  932. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  933. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='8'
  934. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  935. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  936. inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  937. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  938. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  939. where a.ODNType='1' and a.Status='2' and a.OASNCode is null";
  940. sql = string.Format(sql, Figure);
  941. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  942. #endregion
  943. if (!string.IsNullOrWhiteSpace(queryJson))
  944. {
  945. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  946. {
  947. sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  948. }
  949. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  950. {
  951. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  952. }
  953. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  954. {
  955. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  956. }
  957. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  958. {
  959. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  960. }
  961. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  962. {
  963. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  964. }
  965. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  966. {
  967. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  968. }
  969. }
  970. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  971. {
  972. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  973. }
  974. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  975. {
  976. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  977. }
  978. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  979. }
  980. //开立得成品入库单
  981. public DataTable GetGridJsonKLCPRK(string queryJson, ref Pagination jqgridparam)
  982. {
  983. DataTable dt = new DataTable();
  984. var queryParam = queryJson.ToJObject();
  985. List<DbParameter> parameter = new List<DbParameter>();
  986. object Figure = GetDecimalDigits();
  987. #region [SQL]
  988. string sql = @"
  989. select a.ID,a.RCVCode,a.Sequence,a.WHCode,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,
  990. 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
  991. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  992. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  993. from ICSManufactureReceive a
  994. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  995. left join (
  996. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  997. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='9'
  998. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  999. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1000. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1001. where a.Status='1' and a.Type='1'";
  1002. sql = string.Format(sql, Figure);
  1003. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1004. #endregion
  1005. if (!string.IsNullOrWhiteSpace(queryJson))
  1006. {
  1007. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1008. {
  1009. sql += " and a.RCVCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1010. }
  1011. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1012. {
  1013. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1014. }
  1015. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1016. {
  1017. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1018. }
  1019. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1020. {
  1021. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1022. }
  1023. }
  1024. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1025. {
  1026. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1027. }
  1028. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1029. {
  1030. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1031. }
  1032. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1033. }
  1034. /// <summary>
  1035. /// 点击审核委外到货单生成条码(审核委外到货单)
  1036. /// </summary>
  1037. public DataTable GetSubGridJsonWWSHDHByCreate(string ODNCode, string Sequence, string WorkPoint)
  1038. {
  1039. DataTable dt = new DataTable();
  1040. object Figure = GetDecimalDigits();
  1041. List<DbParameter> parameter = new List<DbParameter>();
  1042. 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,
  1043. 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
  1044. from ICSODeliveryNotice a
  1045. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1046. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1047. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1048. group by b.TransCode,b.TransSequence
  1049. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
  1050. WHERE 1 =1
  1051. and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
  1052. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1053. sql = string.Format(sql, Figure);
  1054. return Repository().FindTableBySql(sql.ToString());
  1055. }
  1056. /// <summary>
  1057. /// 点击开立成品入库生成条码(开立成品入库单)
  1058. /// </summary>
  1059. /// //--
  1060. public DataTable GetSubGridJsonKLCPRKByCreate(string RCVCode, string Sequence, string WorkPoint)
  1061. {
  1062. DataTable dt = new DataTable();
  1063. object Figure = GetDecimalDigits();
  1064. List<DbParameter> parameter = new List<DbParameter>();
  1065. 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,
  1066. 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
  1067. from ICSManufactureReceive a
  1068. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1069. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1070. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1071. group by b.TransCode,b.TransSequence
  1072. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence
  1073. WHERE 1 =1
  1074. and a.RCVCode='" + RCVCode + "' and a.Sequence='" + Sequence + "'";
  1075. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1076. sql = string.Format(sql, Figure);
  1077. return Repository().FindTableBySql(sql.ToString());
  1078. }
  1079. /// <summary>
  1080. /// 点击审核到货单生成条码(审核到货单)
  1081. /// </summary>
  1082. public DataTable GetSubGridJsonSHDHByCreate(string DNCode, string Sequence, string WorkPoint)
  1083. {
  1084. DataTable dt = new DataTable();
  1085. object Figure = GetDecimalDigits();
  1086. List<DbParameter> parameter = new List<DbParameter>();
  1087. 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,
  1088. 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
  1089. from ICSDeliveryNotice a
  1090. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1091. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1092. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1093. group by b.TransCode,b.TransSequence
  1094. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
  1095. WHERE 1 =1
  1096. and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
  1097. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1098. sql = string.Format(sql, Figure);
  1099. return Repository().FindTableBySql(sql.ToString());
  1100. }
  1101. /// <summary>
  1102. /// 点击归还生成条码(归还)
  1103. /// </summary>
  1104. public DataTable GetSubGridJsonGuiHuanByCreate(string ReturnCode, string Sequence, string WorkPoint)
  1105. {
  1106. DataTable dt = new DataTable();
  1107. object Figure = GetDecimalDigits();
  1108. List<DbParameter> parameter = new List<DbParameter>();
  1109. 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,
  1110. 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
  1111. from ICSReturn a
  1112. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1113. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1114. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1115. group by b.TransCode,b.TransSequence
  1116. ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence
  1117. WHERE 1 =1
  1118. and a.ReturnCode='" + ReturnCode + "' and a.Sequence='" + Sequence + "'";
  1119. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1120. sql = string.Format(sql, Figure);
  1121. return Repository().FindTableBySql(sql.ToString());
  1122. }
  1123. /// <summary>
  1124. /// 归还单生成条码
  1125. /// </summary>
  1126. /// <param name="POCode"></param>
  1127. /// <param name="PORow"></param>
  1128. /// <param name="keyValue"></param>
  1129. /// 已改
  1130. /// <returns></returns>
  1131. public int SubmitFormGuiHuan(string ReturnCode, string Sequence, string keyValue, string WorkPoint)
  1132. {
  1133. var queryParam = keyValue.ToJObject();
  1134. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1135. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1136. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1137. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1138. decimal LOTQTY = minPackQty;
  1139. string Pre = "GH" + ReturnCode + Sequence;
  1140. string sql = string.Empty;
  1141. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1142. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1143. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1144. string sqls = string.Empty;
  1145. string Colspan = "";
  1146. for (int i = 0; i < createPageCount; i++)
  1147. {
  1148. if (i + 1 == createPageCount)
  1149. {
  1150. if (minPackQty * createPageCount > thisCreateQty)
  1151. {
  1152. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1153. }
  1154. }
  1155. 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();
  1156. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1157. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1158. if (ExtensionID == null)
  1159. {
  1160. ExtensionID = Guid.NewGuid();
  1161. 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)
  1162. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1163. 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(),
  1164. MUSER, MUSERNAME, WorkPoints);
  1165. }
  1166. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1167. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1168. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1169. LotNo, ReturnCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1170. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1171. //{
  1172. sql += string.Format(@"
  1173. insert into ICSInventoryLot
  1174. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1175. select
  1176. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','6','{3}','{4}', getdate(),'{5}','{9}'
  1177. from ICSReturn where ReturnCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1178. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ReturnCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1179. sql += "\r\n";
  1180. //}
  1181. }
  1182. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1183. return count;
  1184. }
  1185. /// <summary>
  1186. /// 审核到货单生成条码
  1187. /// </summary>
  1188. /// <param name="POCode"></param>
  1189. /// <param name="PORow"></param>
  1190. /// <param name="keyValue"></param>
  1191. /// 已改
  1192. /// <returns></returns>
  1193. public int SubmitFormSHDH(string DNCode, string Sequence, string INVCode, string keyValue, string WorkPoint)
  1194. {
  1195. try
  1196. {
  1197. string postUrlStr = System.Configuration.ConfigurationManager.AppSettings["HGDocpostUrlStr"].ToString();
  1198. var queryParam = keyValue.ToJObject();
  1199. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1200. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1201. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1202. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1203. decimal LOTQTY = minPackQty;
  1204. string Pre = "DN" + DNCode + Sequence;
  1205. string sql = string.Empty;
  1206. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1207. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1208. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1209. string sqls = string.Empty;
  1210. string Colspan = "";
  1211. string InspectJosn = "";
  1212. InspectJosn += "{";
  1213. InspectJosn += "\"IMP_ORDINI\":[";
  1214. InspectJosn += "{";
  1215. InspectJosn += "\"ORD_ORDINE\":\"" + DNCode + "\",";
  1216. InspectJosn += "\"ORD_DES\":\"\",";
  1217. InspectJosn += "\"ORD_TIPOOP\":\"P\"";
  1218. InspectJosn += "}";
  1219. InspectJosn += "],";
  1220. InspectJosn += "\"IMP_ORDINI_RIGHE\":[";
  1221. InspectJosn += "{";
  1222. InspectJosn += "\"RIG_ORDINE\":\"" + DNCode + "\",";
  1223. InspectJosn += "\"RIG_ARTICOLO\": \"" + INVCode + "\",";
  1224. InspectJosn += "\"RIG_SUB1\": \"\",";
  1225. InspectJosn += "\"RIG_SUB2\": \"\",";
  1226. InspectJosn += "\"RIG_QTAR\": " + thisCreateQty + ",";
  1227. InspectJosn += "\"RIG_HOSTINF\": " + Sequence + "";
  1228. InspectJosn += "}";
  1229. InspectJosn += "]";
  1230. InspectJosn += "}";
  1231. for (int i = 0; i < createPageCount; i++)
  1232. {
  1233. if (i + 1 == createPageCount)
  1234. {
  1235. if (minPackQty * createPageCount > thisCreateQty)
  1236. {
  1237. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1238. }
  1239. }
  1240. 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();
  1241. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1242. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1243. if (ExtensionID == null)
  1244. {
  1245. ExtensionID = Guid.NewGuid();
  1246. 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)
  1247. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1248. 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(),
  1249. MUSER, MUSERNAME, WorkPoints);
  1250. }
  1251. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1252. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1253. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1254. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1255. sql += string.Format(@"
  1256. insert into ICSInventoryLot
  1257. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1258. select
  1259. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','7','{3}','{4}', getdate(),'{5}','{9}'
  1260. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1261. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1262. sql += "\r\n";
  1263. }
  1264. string result = "";
  1265. if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UploadERP"]))
  1266. {
  1267. result = HTTPHelper.RestFulGet(InspectJosn, postUrlStr);
  1268. }
  1269. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1270. return count;
  1271. }
  1272. catch (Exception ex)
  1273. {
  1274. throw new Exception(ex.Message);
  1275. }
  1276. }
  1277. /// <summary>
  1278. /// 审核委外到货单生成条码
  1279. /// </summary>
  1280. /// <param name="POCode"></param>
  1281. /// <param name="PORow"></param>
  1282. /// <param name="keyValue"></param>
  1283. /// 已改
  1284. /// <returns></returns>
  1285. public int SubmitFormWWSHDH(string ODNCode, string Sequence, string keyValue, string WorkPoint)
  1286. {
  1287. var queryParam = keyValue.ToJObject();
  1288. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1289. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1290. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1291. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1292. decimal LOTQTY = minPackQty;
  1293. string Pre = "ODN" + ODNCode + Sequence;
  1294. string sql = string.Empty;
  1295. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1296. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1297. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1298. string sqls = string.Empty;
  1299. string Colspan = "";
  1300. for (int i = 0; i < createPageCount; i++)
  1301. {
  1302. if (i + 1 == createPageCount)
  1303. {
  1304. if (minPackQty * createPageCount > thisCreateQty)
  1305. {
  1306. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1307. }
  1308. }
  1309. 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();
  1310. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1311. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1312. if (ExtensionID == null)
  1313. {
  1314. ExtensionID = Guid.NewGuid();
  1315. 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)
  1316. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1317. 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(),
  1318. MUSER, MUSERNAME, WorkPoints);
  1319. }
  1320. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1321. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1322. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1323. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1324. sql += string.Format(@"
  1325. insert into ICSInventoryLot
  1326. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1327. select
  1328. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','8','{3}','{4}', getdate(),'{5}','{9}'
  1329. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1330. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1331. sql += "\r\n";
  1332. }
  1333. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1334. return count;
  1335. }
  1336. /// <summary>
  1337. /// 开立成品入库单
  1338. /// </summary>
  1339. /// <param name="POCode"></param>
  1340. /// <param name="PORow"></param>
  1341. /// <param name="keyValue"></param>
  1342. /// 已改
  1343. /// <returns></returns>
  1344. public int SubmitFormKLCPRK(string RCVCode, string Sequence, string keyValue, string WorkPoint)
  1345. {
  1346. var queryParam = keyValue.ToJObject();
  1347. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1348. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1349. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1350. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1351. decimal LOTQTY = minPackQty;
  1352. string Pre = "KCP" + RCVCode + Sequence;
  1353. string sql = string.Empty;
  1354. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1355. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1356. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1357. string sqls = string.Empty;
  1358. string Colspan = "";
  1359. for (int i = 0; i < createPageCount; i++)
  1360. {
  1361. if (i + 1 == createPageCount)
  1362. {
  1363. if (minPackQty * createPageCount > thisCreateQty)
  1364. {
  1365. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1366. }
  1367. }
  1368. 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();
  1369. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1370. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1371. if (ExtensionID == null)
  1372. {
  1373. ExtensionID = Guid.NewGuid();
  1374. 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)
  1375. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1376. 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(),
  1377. MUSER, MUSERNAME, WorkPoints);
  1378. }
  1379. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1380. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1381. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1382. LotNo, RCVCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1383. sql += string.Format(@"
  1384. insert into ICSInventoryLot
  1385. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1386. select
  1387. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','9','{3}','{4}', getdate(),'{5}','{9}'
  1388. from ICSManufactureReceive where RCVCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1389. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, RCVCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1390. sql += "\r\n";
  1391. }
  1392. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1393. return count;
  1394. }
  1395. //委外拒收单
  1396. public DataTable GetGridJsonWWJSD(string queryJson, ref Pagination jqgridparam)
  1397. {
  1398. DataTable dt = new DataTable();
  1399. var queryParam = queryJson.ToJObject();
  1400. List<DbParameter> parameter = new List<DbParameter>();
  1401. object Figure = GetDecimalDigits();
  1402. #region [SQL]
  1403. 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,
  1404. 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
  1405. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1406. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1407. from ICSODeliveryNotice a
  1408. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1409. left join (
  1410. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1411. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='11'
  1412. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1413. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1414. --inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  1415. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1416. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1417. where a.ODNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
  1418. ";
  1419. sql = string.Format(sql, Figure);
  1420. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1421. #endregion
  1422. if (!string.IsNullOrWhiteSpace(queryJson))
  1423. {
  1424. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1425. {
  1426. sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1427. }
  1428. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1429. {
  1430. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1431. }
  1432. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1433. {
  1434. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1435. }
  1436. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1437. {
  1438. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1439. }
  1440. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1441. {
  1442. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1443. }
  1444. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1445. {
  1446. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1447. }
  1448. }
  1449. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1450. {
  1451. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1452. }
  1453. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1454. {
  1455. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1456. }
  1457. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1458. }
  1459. //拒收单
  1460. public DataTable GetGridJsonJSD(string queryJson, ref Pagination jqgridparam)
  1461. {
  1462. DataTable dt = new DataTable();
  1463. var queryParam = queryJson.ToJObject();
  1464. List<DbParameter> parameter = new List<DbParameter>();
  1465. object Figure = GetDecimalDigits();
  1466. #region [SQL]
  1467. string sql = @"select a.ID,a.DNCode ,a.Sequence ,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  1468. 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,
  1469. CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1470. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1471. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1472. from ICSDeliveryNotice a
  1473. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1474. left join (
  1475. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1476. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='10'
  1477. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1478. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1479. --inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  1480. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1481. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1482. where a.DNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
  1483. ";
  1484. sql = string.Format(sql, Figure);
  1485. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1486. #endregion
  1487. if (!string.IsNullOrWhiteSpace(queryJson))
  1488. {
  1489. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1490. {
  1491. sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1492. }
  1493. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1494. {
  1495. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1496. }
  1497. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1498. {
  1499. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1500. }
  1501. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1502. {
  1503. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1504. }
  1505. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1506. {
  1507. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1508. }
  1509. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1510. {
  1511. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1512. }
  1513. }
  1514. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1515. {
  1516. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1517. }
  1518. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1519. {
  1520. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1521. }
  1522. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1523. }
  1524. //领料申请退料
  1525. public DataTable GetGridJsonLLSQTL(string queryJson, ref Pagination jqgridparam)
  1526. {
  1527. DataTable dt = new DataTable();
  1528. var queryParam = queryJson.ToJObject();
  1529. List<DbParameter> parameter = new List<DbParameter>();
  1530. object Figure = GetDecimalDigits();
  1531. #region [SQL]
  1532. string sql = @"select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  1533. 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
  1534. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1535. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1536. from ICSMOApplyNegDetail a
  1537. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1538. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1539. left join (
  1540. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1541. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='12'
  1542. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1543. )c
  1544. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1545. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1546. WHERE d.Type='2'";
  1547. sql = string.Format(sql, Figure);
  1548. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1549. #endregion
  1550. if (!string.IsNullOrWhiteSpace(queryJson))
  1551. {
  1552. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1553. {
  1554. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1555. }
  1556. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1557. {
  1558. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1559. }
  1560. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1561. {
  1562. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1563. }
  1564. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1565. {
  1566. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1567. }
  1568. }
  1569. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1570. {
  1571. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1572. }
  1573. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1574. {
  1575. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1576. }
  1577. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1578. }
  1579. /// <summary>
  1580. /// 拒收生成条码
  1581. /// </summary>
  1582. /// <param name="POCode"></param>
  1583. /// <param name="PORow"></param>
  1584. /// <param name="keyValue"></param>
  1585. /// <returns></returns>
  1586. public int SubmitFormJSD(string DNCode, string Sequence, string keyValue, string WorkPoint)
  1587. {
  1588. var queryParam = keyValue.ToJObject();
  1589. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1590. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1591. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1592. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1593. decimal LOTQTY = minPackQty;
  1594. string Pre = "JS" + DNCode + Sequence;
  1595. string sql = string.Empty;
  1596. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1597. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1598. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1599. string sqls = string.Empty;
  1600. string Colspan = "";
  1601. for (int i = 0; i < createPageCount; i++)
  1602. {
  1603. if (i + 1 == createPageCount)
  1604. {
  1605. if (minPackQty * createPageCount > thisCreateQty)
  1606. {
  1607. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1608. }
  1609. }
  1610. 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();
  1611. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1612. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1613. if (ExtensionID == null)
  1614. {
  1615. ExtensionID = Guid.NewGuid();
  1616. 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)
  1617. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1618. 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(),
  1619. MUSER, MUSERNAME, WorkPoints);
  1620. }
  1621. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1622. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1623. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1624. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1625. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1626. //{
  1627. sql += string.Format(@"
  1628. insert into ICSInventoryLot
  1629. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1630. select
  1631. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','10','{3}','{4}', getdate(),'{5}','{9}'
  1632. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1633. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1634. sql += "\r\n";
  1635. //}
  1636. }
  1637. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1638. return count;
  1639. }
  1640. /// <summary>
  1641. /// 委外拒收生成条码
  1642. /// </summary>
  1643. /// <param name="POCode"></param>
  1644. /// <param name="PORow"></param>
  1645. /// <param name="keyValue"></param>
  1646. /// <returns></returns>
  1647. public int SubmitFormWWJSD(string ODNCode, string Sequence, string keyValue, string WorkPoint)
  1648. {
  1649. var queryParam = keyValue.ToJObject();
  1650. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1651. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1652. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1653. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1654. decimal LOTQTY = minPackQty;
  1655. string Pre = "OJS" + ODNCode + Sequence;
  1656. string sql = string.Empty;
  1657. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1658. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1659. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1660. string sqls = string.Empty;
  1661. string Colspan = "";
  1662. for (int i = 0; i < createPageCount; i++)
  1663. {
  1664. if (i + 1 == createPageCount)
  1665. {
  1666. if (minPackQty * createPageCount > thisCreateQty)
  1667. {
  1668. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1669. }
  1670. }
  1671. 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();
  1672. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1673. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1674. if (ExtensionID == null)
  1675. {
  1676. ExtensionID = Guid.NewGuid();
  1677. 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)
  1678. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1679. 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(),
  1680. MUSER, MUSERNAME, WorkPoints);
  1681. }
  1682. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1683. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1684. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1685. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1686. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1687. //{
  1688. sql += string.Format(@"
  1689. insert into ICSInventoryLot
  1690. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1691. select
  1692. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','11','{3}','{4}', getdate(),'{5}','{9}'
  1693. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1694. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1695. sql += "\r\n";
  1696. //}
  1697. }
  1698. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1699. return count;
  1700. }
  1701. /// <summary>
  1702. /// 点击审核到货单生成条码(审核到货单)
  1703. /// </summary>
  1704. public DataTable GetSubGridJsonJSDByCreate(string DNCode, string Sequence, string WorkPoint)
  1705. {
  1706. DataTable dt = new DataTable();
  1707. object Figure = GetDecimalDigits();
  1708. List<DbParameter> parameter = new List<DbParameter>();
  1709. 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,
  1710. 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
  1711. from ICSDeliveryNotice a
  1712. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1713. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1714. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1715. group by b.TransCode,b.TransSequence
  1716. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
  1717. WHERE a.DNType='3'
  1718. and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
  1719. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1720. sql = string.Format(sql, Figure);
  1721. return Repository().FindTableBySql(sql.ToString());
  1722. }
  1723. /// <summary>
  1724. /// 点击审核委外到货单生成条码(审核委外到货单)
  1725. /// </summary>
  1726. public DataTable GetSubGridJsonWWJSDByCreate(string ODNCode, string Sequence, string WorkPoint)
  1727. {
  1728. DataTable dt = new DataTable();
  1729. object Figure = GetDecimalDigits();
  1730. List<DbParameter> parameter = new List<DbParameter>();
  1731. 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,
  1732. 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
  1733. from ICSODeliveryNotice a
  1734. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1735. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1736. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1737. group by b.TransCode,b.TransSequence
  1738. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
  1739. WHERE a.ODNType='3'
  1740. and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
  1741. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1742. sql = string.Format(sql, Figure);
  1743. return Repository().FindTableBySql(sql.ToString());
  1744. }
  1745. public DataTable GetSubGridJsonLLSQDByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  1746. {
  1747. DataTable dt = new DataTable();
  1748. object Figure = GetDecimalDigits();
  1749. List<DbParameter> parameter = new List<DbParameter>();
  1750. 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,
  1751. 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
  1752. from ICSMOApplyNegDetail a
  1753. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1754. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1755. left join (
  1756. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1757. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1758. group by b.TransCode,b.TransSequence
  1759. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  1760. WHERE d.Type='2'
  1761. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  1762. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1763. sql = string.Format(sql, Figure);
  1764. return Repository().FindTableBySql(sql.ToString());
  1765. }
  1766. //领料申请退料生成条码
  1767. public int SubmitFormLLSQTL(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  1768. {
  1769. var queryParam = keyValue.ToJObject();
  1770. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1771. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1772. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1773. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1774. decimal LOTQTY = minPackQty;
  1775. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1776. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  1777. string Pre = "MA" + ApplyNegCode + Sequence;
  1778. string sql = string.Empty;
  1779. //string VendorLot = queryParam["VendorLot"].ToString();
  1780. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1781. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1782. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1783. string sqls = string.Empty;
  1784. string Colspan = "";
  1785. for (int i = 0; i < createPageCount; i++)
  1786. {
  1787. if (i + 1 == createPageCount)
  1788. {
  1789. if (minPackQty * createPageCount > thisCreateQty)
  1790. {
  1791. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1792. }
  1793. }
  1794. 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();
  1795. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1796. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1797. if (ExtensionID == null)
  1798. {
  1799. ExtensionID = Guid.NewGuid();
  1800. 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)
  1801. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1802. 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(),
  1803. MUSER, MUSERNAME, WorkPoints);
  1804. }
  1805. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1806. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1807. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1808. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1809. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1810. //{
  1811. sql += string.Format(@"insert into ICSInventoryLot
  1812. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1813. select
  1814. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','12','{3}','{4}', getdate(),'{5}','{9}'
  1815. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1816. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1817. sql += "\r\n";
  1818. //}
  1819. }
  1820. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1821. return count;
  1822. }
  1823. //材料出库退料
  1824. public DataTable GetGridJsonCLCK(string queryJson, ref Pagination jqgridparam)
  1825. {
  1826. DataTable dt = new DataTable();
  1827. var queryParam = queryJson.ToJObject();
  1828. List<DbParameter> parameter = new List<DbParameter>();
  1829. object Figure = GetDecimalDigits();
  1830. #region [SQL]
  1831. string sql = @"
  1832. select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  1833. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  1834. 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
  1835. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1836. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1837. from ICSMOApplyNegDetail a
  1838. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1839. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1840. left join (
  1841. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1842. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='13'
  1843. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1844. )c
  1845. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1846. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1847. WHERE d.Type='3'";
  1848. sql = string.Format(sql, Figure);
  1849. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1850. #endregion
  1851. if (!string.IsNullOrWhiteSpace(queryJson))
  1852. {
  1853. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1854. {
  1855. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1856. }
  1857. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1858. {
  1859. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1860. }
  1861. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1862. {
  1863. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1864. }
  1865. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1866. {
  1867. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1868. }
  1869. }
  1870. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1871. {
  1872. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1873. }
  1874. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1875. {
  1876. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1877. }
  1878. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1879. }
  1880. //材料出库退料
  1881. public DataTable GetSubGridJsonCLCKByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  1882. {
  1883. DataTable dt = new DataTable();
  1884. object Figure = GetDecimalDigits();
  1885. List<DbParameter> parameter = new List<DbParameter>();
  1886. 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,
  1887. 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
  1888. from ICSMOApplyNegDetail a
  1889. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1890. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1891. left join (
  1892. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1893. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1894. group by b.TransCode,b.TransSequence
  1895. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  1896. WHERE d.Type='3'
  1897. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  1898. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1899. sql = string.Format(sql, Figure);
  1900. return Repository().FindTableBySql(sql.ToString());
  1901. }
  1902. //材料出库退料生成条码
  1903. public int SubmitFormCLCKT(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  1904. {
  1905. var queryParam = keyValue.ToJObject();
  1906. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1907. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1908. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1909. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1910. decimal LOTQTY = minPackQty;
  1911. string Pre = "MD" + ApplyNegCode + Sequence;
  1912. string sql = string.Empty;
  1913. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1914. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1915. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1916. string sqls = string.Empty;
  1917. string Colspan = "";
  1918. for (int i = 0; i < createPageCount; i++)
  1919. {
  1920. if (i + 1 == createPageCount)
  1921. {
  1922. if (minPackQty * createPageCount > thisCreateQty)
  1923. {
  1924. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1925. }
  1926. }
  1927. 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();
  1928. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1929. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1930. if (ExtensionID == null)
  1931. {
  1932. ExtensionID = Guid.NewGuid();
  1933. 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)
  1934. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1935. 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(),
  1936. MUSER, MUSERNAME, WorkPoints);
  1937. }
  1938. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1939. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1940. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1941. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1942. sql += string.Format(@"insert into ICSInventoryLot
  1943. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1944. select
  1945. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','13','{3}','{4}', getdate(),'{5}','{9}'
  1946. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1947. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1948. sql += "\r\n";
  1949. }
  1950. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1951. return count;
  1952. }
  1953. public DataTable GetGridJsonWWLLTL(string queryJson, ref Pagination jqgridparam)
  1954. {
  1955. DataTable dt = new DataTable();
  1956. var queryParam = queryJson.ToJObject();
  1957. List<DbParameter> parameter = new List<DbParameter>();
  1958. object Figure = GetDecimalDigits();
  1959. #region [SQL]
  1960. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  1961. 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
  1962. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1963. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1964. from ICSOApplyNegDetail a
  1965. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  1966. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1967. left join (
  1968. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1969. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='14'
  1970. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1971. )c
  1972. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1973. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1974. WHERE d.Type='2'";
  1975. sql = string.Format(sql, Figure);
  1976. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1977. #endregion
  1978. if (!string.IsNullOrWhiteSpace(queryJson))
  1979. {
  1980. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1981. {
  1982. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1983. }
  1984. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1985. {
  1986. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1987. }
  1988. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1989. {
  1990. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1991. }
  1992. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1993. {
  1994. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1995. }
  1996. }
  1997. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1998. {
  1999. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2000. }
  2001. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2002. {
  2003. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2004. }
  2005. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2006. }
  2007. /// <summary>
  2008. /// 点击委外领料退料生成条码
  2009. /// </summary>
  2010. public DataTable GetSubGridJsonWWLLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  2011. {
  2012. DataTable dt = new DataTable();
  2013. object Figure = GetDecimalDigits();
  2014. List<DbParameter> parameter = new List<DbParameter>();
  2015. string sql = @"
  2016. 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,
  2017. 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
  2018. from ICSOApplyNegDetail a
  2019. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2020. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2021. left join (
  2022. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2023. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2024. group by b.TransCode,b.TransSequence
  2025. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2026. WHERE d.Type='2'
  2027. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2028. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2029. sql = string.Format(sql, Figure);
  2030. return Repository().FindTableBySql(sql.ToString());
  2031. }
  2032. //委外领料申请退料
  2033. public int SubmitFormWWLL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2034. {
  2035. var queryParam = keyValue.ToJObject();
  2036. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2037. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2038. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2039. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2040. decimal LOTQTY = minPackQty;
  2041. string Pre = "OMA" + OApplyNegCode + Sequence;
  2042. string sql = string.Empty;
  2043. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2044. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2045. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2046. string sqls = string.Empty;
  2047. string Colspan = "";
  2048. for (int i = 0; i < createPageCount; i++)
  2049. {
  2050. if (i + 1 == createPageCount)
  2051. {
  2052. if (minPackQty * createPageCount > thisCreateQty)
  2053. {
  2054. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2055. }
  2056. }
  2057. 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();
  2058. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2059. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2060. if (ExtensionID == null)
  2061. {
  2062. ExtensionID = Guid.NewGuid();
  2063. 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)
  2064. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2065. 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(),
  2066. MUSER, MUSERNAME, WorkPoints);
  2067. }
  2068. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2069. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2070. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2071. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2072. sql += string.Format(@"insert into ICSInventoryLot
  2073. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2074. select
  2075. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','14','{3}','{4}', getdate(),'{5}','{9}'
  2076. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2077. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2078. sql += "\r\n";
  2079. }
  2080. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2081. return count;
  2082. }
  2083. //委外材料出库
  2084. public DataTable GetGridJsonWWCLCK(string queryJson, ref Pagination jqgridparam)
  2085. {
  2086. DataTable dt = new DataTable();
  2087. var queryParam = queryJson.ToJObject();
  2088. List<DbParameter> parameter = new List<DbParameter>();
  2089. object Figure = GetDecimalDigits();
  2090. #region [SQL]
  2091. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2092. 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
  2093. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2094. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2095. from ICSOApplyNegDetail a
  2096. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2097. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2098. left join (
  2099. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2100. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='15'
  2101. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2102. )c
  2103. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2104. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2105. WHERE d.Type='3'";
  2106. sql = string.Format(sql, Figure);
  2107. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2108. #endregion
  2109. if (!string.IsNullOrWhiteSpace(queryJson))
  2110. {
  2111. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2112. {
  2113. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2114. }
  2115. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2116. {
  2117. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2118. }
  2119. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2120. {
  2121. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2122. }
  2123. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2124. {
  2125. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2126. }
  2127. }
  2128. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2129. {
  2130. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2131. }
  2132. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2133. {
  2134. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2135. }
  2136. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2137. }
  2138. //委外材料出库
  2139. public DataTable GetSubGridJsonWWCLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  2140. {
  2141. DataTable dt = new DataTable();
  2142. object Figure = GetDecimalDigits();
  2143. List<DbParameter> parameter = new List<DbParameter>();
  2144. string sql = @"
  2145. 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,
  2146. 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
  2147. from ICSOApplyNegDetail a
  2148. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2149. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2150. left join (
  2151. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2152. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2153. group by b.TransCode,b.TransSequence
  2154. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2155. WHERE d.Type='3'
  2156. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2157. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2158. sql = string.Format(sql, Figure);
  2159. return Repository().FindTableBySql(sql.ToString());
  2160. }
  2161. //委外材料出库
  2162. public int SubmitFormWWCL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2163. {
  2164. var queryParam = keyValue.ToJObject();
  2165. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2166. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2167. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2168. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2169. decimal LOTQTY = minPackQty;
  2170. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2171. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  2172. string Pre = "OMD" + OApplyNegCode + Sequence;
  2173. string sql = string.Empty;
  2174. //string VendorLot = queryParam["VendorLot"].ToString();
  2175. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2176. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2177. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2178. string sqls = string.Empty;
  2179. string Colspan = "";
  2180. for (int i = 0; i < createPageCount; i++)
  2181. {
  2182. if (i + 1 == createPageCount)
  2183. {
  2184. if (minPackQty * createPageCount > thisCreateQty)
  2185. {
  2186. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2187. }
  2188. }
  2189. 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();
  2190. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2191. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2192. if (ExtensionID == null)
  2193. {
  2194. ExtensionID = Guid.NewGuid();
  2195. 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)
  2196. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2197. 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(),
  2198. MUSER, MUSERNAME, WorkPoints);
  2199. }
  2200. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2201. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2202. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2203. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2204. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  2205. //{
  2206. sql += string.Format(@"insert into ICSInventoryLot
  2207. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2208. select
  2209. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','15','{3}','{4}', getdate(),'{5}','{9}'
  2210. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2211. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2212. sql += "\r\n";
  2213. //}
  2214. }
  2215. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2216. return count;
  2217. }
  2218. public DataTable SelectICSExtensionEnable(string BeginTime, string EndTime)
  2219. {
  2220. string sql = @"select ColCode from ICSExtensionEnable
  2221. where Enable=0
  2222. order by cast(EATTRIBUTE1 as int)";
  2223. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2224. return dt;
  2225. }
  2226. //返工工单
  2227. public DataTable GetGridJsonFGGD(string queryJson, ref Pagination jqgridparam)
  2228. {
  2229. DataTable dt = new DataTable();
  2230. var queryParam = queryJson.ToJObject();
  2231. List<DbParameter> parameter = new List<DbParameter>();
  2232. object Figure = GetDecimalDigits();
  2233. #region [SQL]
  2234. 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,
  2235. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  2236. 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
  2237. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2238. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2239. from ICSMOPick a
  2240. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint
  2241. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2242. left join (
  2243. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2244. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='16'
  2245. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2246. )c
  2247. on d.MOCode=c.TransCode and d.Sequence+'-'+a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2248. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2249. where a.EATTRIBUTE1='1' and d.EATTRIBUTE1='1'";
  2250. sql = string.Format(sql, Figure);
  2251. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2252. #endregion
  2253. if (!string.IsNullOrWhiteSpace(queryJson))
  2254. {
  2255. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2256. {
  2257. sql += " and d.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2258. }
  2259. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2260. {
  2261. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2262. }
  2263. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2264. {
  2265. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2266. }
  2267. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2268. {
  2269. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2270. }
  2271. }
  2272. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2273. {
  2274. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2275. }
  2276. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2277. {
  2278. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2279. }
  2280. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2281. }
  2282. public DataTable GetSubGridJsonFGGDCreate(string FGGDMOCode, string Sequence, string WorkPoint)
  2283. {
  2284. DataTable dt = new DataTable();
  2285. object Figure = GetDecimalDigits();
  2286. List<DbParameter> parameter = new List<DbParameter>();
  2287. string sql = @"
  2288. 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,
  2289. 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
  2290. from ICSMOPick a
  2291. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint
  2292. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2293. left join (
  2294. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2295. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2296. group by b.TransCode,b.TransSequence
  2297. ) c on d.MOCode=c.TransCode and d.Sequence+'-'+a.Sequence=c.TransSequence
  2298. WHERE 1=1
  2299. and d.MOCode='" + FGGDMOCode + "' and d.Sequence+'-'+a.Sequence='" + Sequence + "'";
  2300. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2301. sql = string.Format(sql, Figure);
  2302. return Repository().FindTableBySql(sql.ToString());
  2303. }
  2304. //返工工单
  2305. public int SubmitFormFGGD(string FGGDMOCode, string Sequence, string keyValue, string WorkPoint)
  2306. {
  2307. var queryParam = keyValue.ToJObject();
  2308. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2309. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2310. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2311. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2312. decimal LOTQTY = minPackQty;
  2313. string Pre = "FG" + FGGDMOCode + Sequence;
  2314. string sql = string.Empty;
  2315. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2316. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2317. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2318. string sqls = string.Empty;
  2319. string Colspan = "";
  2320. for (int i = 0; i < createPageCount; i++)
  2321. {
  2322. if (i + 1 == createPageCount)
  2323. {
  2324. if (minPackQty * createPageCount > thisCreateQty)
  2325. {
  2326. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2327. }
  2328. }
  2329. 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();
  2330. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2331. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2332. if (ExtensionID == null)
  2333. {
  2334. ExtensionID = Guid.NewGuid();
  2335. 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)
  2336. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2337. 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(),
  2338. MUSER, MUSERNAME, WorkPoints);
  2339. }
  2340. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2341. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2342. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2343. LotNo, FGGDMOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2344. sql += string.Format(@"insert into ICSInventoryLot
  2345. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2346. select
  2347. newid(),'{0}',a.InvCode,'{1}','{10}','{2}','{8}','16','{3}','{4}', getdate(),'{5}','{9}'
  2348. 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}' ",
  2349. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, FGGDMOCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2350. sql += "\r\n";
  2351. }
  2352. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2353. return count;
  2354. }
  2355. public object GetDecimalDigits()
  2356. {
  2357. try
  2358. {
  2359. string sql = string.Empty;
  2360. sql = @"select Figure from ICSConfiguration where Code='Figure001' and Enable='1'";
  2361. object Figure = SqlHelper.ExecuteScalar(sql);
  2362. return Figure;
  2363. }
  2364. catch (Exception ex)
  2365. {
  2366. throw new Exception(ex.Message.ToString());
  2367. }
  2368. }
  2369. public object GetQiSetNum(string keyValue)
  2370. {
  2371. int Num = 0;
  2372. string msg = "";
  2373. string APIURL = ConfigurationManager.ConnectionStrings["ERPAPIURL"].ConnectionString + "Complete/Approve";
  2374. string result = HttpPost(APIURL, keyValue);
  2375. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  2376. string MessAge = Obj["Message"].ToString();
  2377. string Success = Obj["Success"].ToString();
  2378. if (Success.ToUpper() == "FALSE")
  2379. {
  2380. msg = MessAge;
  2381. }
  2382. if (msg == "")
  2383. {
  2384. JArray res = (JArray)JsonConvert.DeserializeObject(Obj["Data"].ToString());
  2385. foreach (var item in res)
  2386. {
  2387. JObject jo = (JObject)item;
  2388. Num = Convert.ToInt32(jo["min_lotqty"].ToString());
  2389. }
  2390. }
  2391. var Header = new
  2392. {
  2393. msg = msg,
  2394. Num = Num,
  2395. };
  2396. return Header;
  2397. }
  2398. //接口api解析
  2399. public static string HttpPost(string url, string body)
  2400. {
  2401. try
  2402. {
  2403. Encoding encoding = Encoding.UTF8;
  2404. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  2405. request.Method = "POST";
  2406. request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
  2407. request.ContentType = "application/json; charset=utf-8";
  2408. byte[] buffer = encoding.GetBytes(body);
  2409. request.ContentLength = buffer.Length;
  2410. request.GetRequestStream().Write(buffer, 0, buffer.Length);
  2411. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  2412. using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
  2413. {
  2414. return reader.ReadToEnd();
  2415. }
  2416. }
  2417. catch (WebException ex)
  2418. {
  2419. throw new Exception(ex.Message);
  2420. }
  2421. }
  2422. }
  2423. }