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

2652 lines
164 KiB

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