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

2653 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
  1560. ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1561. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1562. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1563. from ICSMOApplyNegDetail a
  1564. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1565. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1566. left join (
  1567. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1568. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='12'
  1569. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1570. )c
  1571. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1572. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1573. WHERE d.Type='2'";
  1574. sql = string.Format(sql, Figure);
  1575. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1576. #endregion
  1577. if (!string.IsNullOrWhiteSpace(queryJson))
  1578. {
  1579. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1580. {
  1581. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1582. }
  1583. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1584. {
  1585. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1586. }
  1587. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1588. {
  1589. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1590. }
  1591. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1592. {
  1593. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1594. }
  1595. }
  1596. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1597. {
  1598. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1599. }
  1600. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1601. {
  1602. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1603. }
  1604. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1605. }
  1606. /// <summary>
  1607. /// 拒收生成条码
  1608. /// </summary>
  1609. /// <param name="POCode"></param>
  1610. /// <param name="PORow"></param>
  1611. /// <param name="keyValue"></param>
  1612. /// <returns></returns>
  1613. public int SubmitFormJSD(string DNCode, string Sequence, string keyValue, string WorkPoint)
  1614. {
  1615. var queryParam = keyValue.ToJObject();
  1616. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1617. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1618. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1619. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1620. decimal LOTQTY = minPackQty;
  1621. string Pre = "JS" + DNCode + Sequence;
  1622. string sql = string.Empty;
  1623. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1624. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1625. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1626. string sqls = string.Empty;
  1627. string Colspan = "";
  1628. for (int i = 0; i < createPageCount; i++)
  1629. {
  1630. if (i + 1 == createPageCount)
  1631. {
  1632. if (minPackQty * createPageCount > thisCreateQty)
  1633. {
  1634. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1635. }
  1636. }
  1637. 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();
  1638. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1639. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1640. if (ExtensionID == null)
  1641. {
  1642. ExtensionID = Guid.NewGuid();
  1643. 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)
  1644. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1645. 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(),
  1646. MUSER, MUSERNAME, WorkPoints);
  1647. }
  1648. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1649. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1650. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1651. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1652. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1653. //{
  1654. sql += string.Format(@"
  1655. insert into ICSInventoryLot
  1656. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1657. select
  1658. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','10','{3}','{4}', getdate(),'{5}','{9}'
  1659. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1660. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1661. sql += "\r\n";
  1662. //}
  1663. }
  1664. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1665. return count;
  1666. }
  1667. /// <summary>
  1668. /// 委外拒收生成条码
  1669. /// </summary>
  1670. /// <param name="POCode"></param>
  1671. /// <param name="PORow"></param>
  1672. /// <param name="keyValue"></param>
  1673. /// <returns></returns>
  1674. public int SubmitFormWWJSD(string ODNCode, string Sequence, string keyValue, string WorkPoint)
  1675. {
  1676. var queryParam = keyValue.ToJObject();
  1677. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1678. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1679. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1680. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1681. decimal LOTQTY = minPackQty;
  1682. string Pre = "OJS" + ODNCode + Sequence;
  1683. string sql = string.Empty;
  1684. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1685. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1686. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1687. string sqls = string.Empty;
  1688. string Colspan = "";
  1689. for (int i = 0; i < createPageCount; i++)
  1690. {
  1691. if (i + 1 == createPageCount)
  1692. {
  1693. if (minPackQty * createPageCount > thisCreateQty)
  1694. {
  1695. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1696. }
  1697. }
  1698. 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();
  1699. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1700. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1701. if (ExtensionID == null)
  1702. {
  1703. ExtensionID = Guid.NewGuid();
  1704. 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)
  1705. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1706. 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(),
  1707. MUSER, MUSERNAME, WorkPoints);
  1708. }
  1709. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1710. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1711. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1712. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1713. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1714. //{
  1715. sql += string.Format(@"
  1716. insert into ICSInventoryLot
  1717. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1718. select
  1719. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','11','{3}','{4}', getdate(),'{5}','{9}'
  1720. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1721. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1722. sql += "\r\n";
  1723. //}
  1724. }
  1725. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1726. return count;
  1727. }
  1728. /// <summary>
  1729. /// 点击审核到货单生成条码(审核到货单)
  1730. /// </summary>
  1731. public DataTable GetSubGridJsonJSDByCreate(string DNCode, string Sequence, string WorkPoint)
  1732. {
  1733. DataTable dt = new DataTable();
  1734. object Figure = GetDecimalDigits();
  1735. List<DbParameter> parameter = new List<DbParameter>();
  1736. 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,
  1737. 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
  1738. from ICSDeliveryNotice a
  1739. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1740. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1741. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1742. group by b.TransCode,b.TransSequence
  1743. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
  1744. WHERE a.DNType='3'
  1745. and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
  1746. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1747. sql = string.Format(sql, Figure);
  1748. return Repository().FindTableBySql(sql.ToString());
  1749. }
  1750. /// <summary>
  1751. /// 点击审核委外到货单生成条码(审核委外到货单)
  1752. /// </summary>
  1753. public DataTable GetSubGridJsonWWJSDByCreate(string ODNCode, string Sequence, string WorkPoint)
  1754. {
  1755. DataTable dt = new DataTable();
  1756. object Figure = GetDecimalDigits();
  1757. List<DbParameter> parameter = new List<DbParameter>();
  1758. 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,
  1759. 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
  1760. from ICSODeliveryNotice a
  1761. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1762. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1763. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1764. group by b.TransCode,b.TransSequence
  1765. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
  1766. WHERE a.ODNType='3'
  1767. and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
  1768. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1769. sql = string.Format(sql, Figure);
  1770. return Repository().FindTableBySql(sql.ToString());
  1771. }
  1772. public DataTable GetSubGridJsonLLSQDByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  1773. {
  1774. DataTable dt = new DataTable();
  1775. object Figure = GetDecimalDigits();
  1776. List<DbParameter> parameter = new List<DbParameter>();
  1777. 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,
  1778. 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
  1779. from ICSMOApplyNegDetail a
  1780. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1781. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1782. left join (
  1783. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1784. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1785. group by b.TransCode,b.TransSequence
  1786. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  1787. WHERE d.Type='2'
  1788. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  1789. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1790. sql = string.Format(sql, Figure);
  1791. return Repository().FindTableBySql(sql.ToString());
  1792. }
  1793. //领料申请退料生成条码
  1794. public int SubmitFormLLSQTL(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  1795. {
  1796. var queryParam = keyValue.ToJObject();
  1797. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1798. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1799. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1800. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1801. decimal LOTQTY = minPackQty;
  1802. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1803. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  1804. string Pre = "MA" + ApplyNegCode + Sequence;
  1805. string sql = string.Empty;
  1806. //string VendorLot = queryParam["VendorLot"].ToString();
  1807. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1808. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1809. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1810. string sqls = string.Empty;
  1811. string Colspan = "";
  1812. for (int i = 0; i < createPageCount; i++)
  1813. {
  1814. if (i + 1 == createPageCount)
  1815. {
  1816. if (minPackQty * createPageCount > thisCreateQty)
  1817. {
  1818. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1819. }
  1820. }
  1821. 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();
  1822. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1823. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1824. if (ExtensionID == null)
  1825. {
  1826. ExtensionID = Guid.NewGuid();
  1827. 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)
  1828. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1829. 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(),
  1830. MUSER, MUSERNAME, WorkPoints);
  1831. }
  1832. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1833. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1834. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1835. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1836. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1837. //{
  1838. sql += string.Format(@"insert into ICSInventoryLot
  1839. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1840. select
  1841. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','12','{3}','{4}', getdate(),'{5}','{9}'
  1842. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1843. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1844. sql += "\r\n";
  1845. //}
  1846. }
  1847. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1848. return count;
  1849. }
  1850. //材料出库退料
  1851. public DataTable GetGridJsonCLCK(string queryJson, ref Pagination jqgridparam)
  1852. {
  1853. DataTable dt = new DataTable();
  1854. var queryParam = queryJson.ToJObject();
  1855. List<DbParameter> parameter = new List<DbParameter>();
  1856. object Figure = GetDecimalDigits();
  1857. #region [SQL]
  1858. string sql = @"
  1859. select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  1860. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity,
  1861. 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
  1862. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1863. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1864. from ICSMOApplyNegDetail a
  1865. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1866. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1867. left join (
  1868. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1869. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='13'
  1870. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1871. )c
  1872. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1873. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1874. WHERE d.Type='3'";
  1875. sql = string.Format(sql, Figure);
  1876. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1877. #endregion
  1878. if (!string.IsNullOrWhiteSpace(queryJson))
  1879. {
  1880. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1881. {
  1882. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1883. }
  1884. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1885. {
  1886. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1887. }
  1888. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1889. {
  1890. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1891. }
  1892. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1893. {
  1894. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1895. }
  1896. }
  1897. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1898. {
  1899. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1900. }
  1901. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1902. {
  1903. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1904. }
  1905. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1906. }
  1907. //材料出库退料
  1908. public DataTable GetSubGridJsonCLCKByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  1909. {
  1910. DataTable dt = new DataTable();
  1911. object Figure = GetDecimalDigits();
  1912. List<DbParameter> parameter = new List<DbParameter>();
  1913. 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,
  1914. 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
  1915. from ICSMOApplyNegDetail a
  1916. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1917. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1918. left join (
  1919. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1920. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1921. group by b.TransCode,b.TransSequence
  1922. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  1923. WHERE d.Type='3'
  1924. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  1925. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1926. sql = string.Format(sql, Figure);
  1927. return Repository().FindTableBySql(sql.ToString());
  1928. }
  1929. //材料出库退料生成条码
  1930. public int SubmitFormCLCKT(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  1931. {
  1932. var queryParam = keyValue.ToJObject();
  1933. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1934. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1935. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1936. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1937. decimal LOTQTY = minPackQty;
  1938. string Pre = "MD" + ApplyNegCode + Sequence;
  1939. string sql = string.Empty;
  1940. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1941. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1942. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1943. string sqls = string.Empty;
  1944. string Colspan = "";
  1945. for (int i = 0; i < createPageCount; i++)
  1946. {
  1947. if (i + 1 == createPageCount)
  1948. {
  1949. if (minPackQty * createPageCount > thisCreateQty)
  1950. {
  1951. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1952. }
  1953. }
  1954. 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();
  1955. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1956. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1957. if (ExtensionID == null)
  1958. {
  1959. ExtensionID = Guid.NewGuid();
  1960. 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)
  1961. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1962. 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(),
  1963. MUSER, MUSERNAME, WorkPoints);
  1964. }
  1965. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1966. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1967. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1968. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1969. sql += string.Format(@"insert into ICSInventoryLot
  1970. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1971. select
  1972. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','13','{3}','{4}', getdate(),'{5}','{9}'
  1973. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1974. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1975. sql += "\r\n";
  1976. }
  1977. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1978. return count;
  1979. }
  1980. public DataTable GetGridJsonWWLLTL(string queryJson, ref Pagination jqgridparam)
  1981. {
  1982. DataTable dt = new DataTable();
  1983. var queryParam = queryJson.ToJObject();
  1984. List<DbParameter> parameter = new List<DbParameter>();
  1985. object Figure = GetDecimalDigits();
  1986. #region [SQL]
  1987. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  1988. 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
  1989. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1990. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1991. from ICSOApplyNegDetail a
  1992. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  1993. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1994. left join (
  1995. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1996. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='14'
  1997. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1998. )c
  1999. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2000. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2001. WHERE d.Type='2'";
  2002. sql = string.Format(sql, Figure);
  2003. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2004. #endregion
  2005. if (!string.IsNullOrWhiteSpace(queryJson))
  2006. {
  2007. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2008. {
  2009. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2010. }
  2011. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2012. {
  2013. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2014. }
  2015. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2016. {
  2017. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2018. }
  2019. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2020. {
  2021. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2022. }
  2023. }
  2024. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2025. {
  2026. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2027. }
  2028. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2029. {
  2030. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2031. }
  2032. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2033. }
  2034. /// <summary>
  2035. /// 点击委外领料退料生成条码
  2036. /// </summary>
  2037. public DataTable GetSubGridJsonWWLLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  2038. {
  2039. DataTable dt = new DataTable();
  2040. object Figure = GetDecimalDigits();
  2041. List<DbParameter> parameter = new List<DbParameter>();
  2042. string sql = @"
  2043. 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,
  2044. 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
  2045. from ICSOApplyNegDetail a
  2046. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2047. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2048. left join (
  2049. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2050. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2051. group by b.TransCode,b.TransSequence
  2052. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2053. WHERE d.Type='2'
  2054. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2055. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2056. sql = string.Format(sql, Figure);
  2057. return Repository().FindTableBySql(sql.ToString());
  2058. }
  2059. //委外领料申请退料
  2060. public int SubmitFormWWLL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2061. {
  2062. var queryParam = keyValue.ToJObject();
  2063. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2064. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2065. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2066. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2067. decimal LOTQTY = minPackQty;
  2068. string Pre = "OMA" + OApplyNegCode + Sequence;
  2069. string sql = string.Empty;
  2070. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2071. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2072. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2073. string sqls = string.Empty;
  2074. string Colspan = "";
  2075. for (int i = 0; i < createPageCount; i++)
  2076. {
  2077. if (i + 1 == createPageCount)
  2078. {
  2079. if (minPackQty * createPageCount > thisCreateQty)
  2080. {
  2081. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2082. }
  2083. }
  2084. 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();
  2085. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2086. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2087. if (ExtensionID == null)
  2088. {
  2089. ExtensionID = Guid.NewGuid();
  2090. 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)
  2091. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2092. 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(),
  2093. MUSER, MUSERNAME, WorkPoints);
  2094. }
  2095. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2096. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2097. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2098. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2099. sql += string.Format(@"insert into ICSInventoryLot
  2100. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2101. select
  2102. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','14','{3}','{4}', getdate(),'{5}','{9}'
  2103. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2104. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2105. sql += "\r\n";
  2106. }
  2107. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2108. return count;
  2109. }
  2110. //委外材料出库
  2111. public DataTable GetGridJsonWWCLCK(string queryJson, ref Pagination jqgridparam)
  2112. {
  2113. DataTable dt = new DataTable();
  2114. var queryParam = queryJson.ToJObject();
  2115. List<DbParameter> parameter = new List<DbParameter>();
  2116. object Figure = GetDecimalDigits();
  2117. #region [SQL]
  2118. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2119. 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
  2120. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2121. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2122. from ICSOApplyNegDetail a
  2123. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2124. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2125. left join (
  2126. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2127. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='15'
  2128. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2129. )c
  2130. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2131. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2132. WHERE d.Type='3'";
  2133. sql = string.Format(sql, Figure);
  2134. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2135. #endregion
  2136. if (!string.IsNullOrWhiteSpace(queryJson))
  2137. {
  2138. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2139. {
  2140. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2141. }
  2142. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2143. {
  2144. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2145. }
  2146. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2147. {
  2148. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2149. }
  2150. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2151. {
  2152. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2153. }
  2154. }
  2155. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2156. {
  2157. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2158. }
  2159. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2160. {
  2161. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2162. }
  2163. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2164. }
  2165. //委外材料出库
  2166. public DataTable GetSubGridJsonWWCLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  2167. {
  2168. DataTable dt = new DataTable();
  2169. object Figure = GetDecimalDigits();
  2170. List<DbParameter> parameter = new List<DbParameter>();
  2171. string sql = @"
  2172. 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,
  2173. 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
  2174. from ICSOApplyNegDetail a
  2175. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2176. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2177. left join (
  2178. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2179. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2180. group by b.TransCode,b.TransSequence
  2181. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2182. WHERE d.Type='3'
  2183. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2184. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2185. sql = string.Format(sql, Figure);
  2186. return Repository().FindTableBySql(sql.ToString());
  2187. }
  2188. //委外材料出库
  2189. public int SubmitFormWWCL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2190. {
  2191. var queryParam = keyValue.ToJObject();
  2192. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2193. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2194. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2195. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2196. decimal LOTQTY = minPackQty;
  2197. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2198. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  2199. string Pre = "OMD" + OApplyNegCode + Sequence;
  2200. string sql = string.Empty;
  2201. //string VendorLot = queryParam["VendorLot"].ToString();
  2202. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2203. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2204. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2205. string sqls = string.Empty;
  2206. string Colspan = "";
  2207. for (int i = 0; i < createPageCount; i++)
  2208. {
  2209. if (i + 1 == createPageCount)
  2210. {
  2211. if (minPackQty * createPageCount > thisCreateQty)
  2212. {
  2213. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2214. }
  2215. }
  2216. 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();
  2217. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2218. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2219. if (ExtensionID == null)
  2220. {
  2221. ExtensionID = Guid.NewGuid();
  2222. 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)
  2223. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2224. 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(),
  2225. MUSER, MUSERNAME, WorkPoints);
  2226. }
  2227. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2228. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2229. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2230. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2231. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  2232. //{
  2233. sql += string.Format(@"insert into ICSInventoryLot
  2234. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2235. select
  2236. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','15','{3}','{4}', getdate(),'{5}','{9}'
  2237. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2238. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2239. sql += "\r\n";
  2240. //}
  2241. }
  2242. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2243. return count;
  2244. }
  2245. public DataTable SelectICSExtensionEnable(string BeginTime, string EndTime)
  2246. {
  2247. string sql = @"select ColCode from ICSExtensionEnable
  2248. where Enable=0
  2249. order by cast(EATTRIBUTE1 as int)";
  2250. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2251. return dt;
  2252. }
  2253. //返工工单
  2254. public DataTable GetGridJsonFGGD(string queryJson, ref Pagination jqgridparam)
  2255. {
  2256. DataTable dt = new DataTable();
  2257. var queryParam = queryJson.ToJObject();
  2258. List<DbParameter> parameter = new List<DbParameter>();
  2259. object Figure = GetDecimalDigits();
  2260. #region [SQL]
  2261. 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,
  2262. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  2263. 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
  2264. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2265. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2266. from ICSMOPick a
  2267. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint
  2268. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2269. left join (
  2270. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2271. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='16'
  2272. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2273. )c
  2274. on d.MOCode=c.TransCode and d.Sequence+'-'+a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2275. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2276. where a.EATTRIBUTE1='1' and d.EATTRIBUTE1='1'";
  2277. sql = string.Format(sql, Figure);
  2278. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2279. #endregion
  2280. if (!string.IsNullOrWhiteSpace(queryJson))
  2281. {
  2282. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2283. {
  2284. sql += " and d.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2285. }
  2286. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2287. {
  2288. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2289. }
  2290. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2291. {
  2292. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2293. }
  2294. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2295. {
  2296. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2297. }
  2298. }
  2299. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2300. {
  2301. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2302. }
  2303. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2304. {
  2305. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2306. }
  2307. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2308. }
  2309. public DataTable GetSubGridJsonFGGDCreate(string FGGDMOCode, string Sequence, string WorkPoint)
  2310. {
  2311. DataTable dt = new DataTable();
  2312. object Figure = GetDecimalDigits();
  2313. List<DbParameter> parameter = new List<DbParameter>();
  2314. string sql = @"
  2315. 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,
  2316. 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
  2317. from ICSMOPick a
  2318. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint
  2319. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2320. left join (
  2321. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2322. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2323. group by b.TransCode,b.TransSequence
  2324. ) c on d.MOCode=c.TransCode and d.Sequence+'-'+a.Sequence=c.TransSequence
  2325. WHERE 1=1
  2326. and d.MOCode='" + FGGDMOCode + "' and d.Sequence+'-'+a.Sequence='" + Sequence + "'";
  2327. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2328. sql = string.Format(sql, Figure);
  2329. return Repository().FindTableBySql(sql.ToString());
  2330. }
  2331. //返工工单
  2332. public int SubmitFormFGGD(string FGGDMOCode, string Sequence, string keyValue, string WorkPoint)
  2333. {
  2334. var queryParam = keyValue.ToJObject();
  2335. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2336. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2337. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2338. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2339. decimal LOTQTY = minPackQty;
  2340. string Pre = "FG" + FGGDMOCode + Sequence;
  2341. string sql = string.Empty;
  2342. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2343. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2344. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2345. string sqls = string.Empty;
  2346. string Colspan = "";
  2347. for (int i = 0; i < createPageCount; i++)
  2348. {
  2349. if (i + 1 == createPageCount)
  2350. {
  2351. if (minPackQty * createPageCount > thisCreateQty)
  2352. {
  2353. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2354. }
  2355. }
  2356. 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();
  2357. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2358. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2359. if (ExtensionID == null)
  2360. {
  2361. ExtensionID = Guid.NewGuid();
  2362. 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)
  2363. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2364. 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(),
  2365. MUSER, MUSERNAME, WorkPoints);
  2366. }
  2367. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2368. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2369. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2370. LotNo, FGGDMOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2371. sql += string.Format(@"insert into ICSInventoryLot
  2372. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2373. select
  2374. newid(),'{0}',a.InvCode,'{1}','{10}','{2}','{8}','16','{3}','{4}', getdate(),'{5}','{9}'
  2375. 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}' ",
  2376. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, FGGDMOCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2377. sql += "\r\n";
  2378. }
  2379. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2380. return count;
  2381. }
  2382. public object GetDecimalDigits()
  2383. {
  2384. try
  2385. {
  2386. string sql = string.Empty;
  2387. sql = @"select Figure from ICSConfiguration where Code='Figure001' and Enable='1'";
  2388. object Figure = SqlHelper.ExecuteScalar(sql);
  2389. return Figure;
  2390. }
  2391. catch (Exception ex)
  2392. {
  2393. throw new Exception(ex.Message.ToString());
  2394. }
  2395. }
  2396. public object GetQiSetNum(string keyValue)
  2397. {
  2398. int Num = 0;
  2399. string msg = "";
  2400. string APIURL = ConfigurationManager.ConnectionStrings["ERPAPIURL"].ConnectionString + "Complete/Approve";
  2401. string result = HttpPost(APIURL, keyValue);
  2402. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  2403. string MessAge = Obj["Message"].ToString();
  2404. string Success = Obj["Success"].ToString();
  2405. if (Success.ToUpper() == "FALSE")
  2406. {
  2407. msg = MessAge;
  2408. }
  2409. if (msg == "")
  2410. {
  2411. JArray res = (JArray)JsonConvert.DeserializeObject(Obj["Data"].ToString());
  2412. foreach (var item in res)
  2413. {
  2414. JObject jo = (JObject)item;
  2415. Num = Convert.ToInt32(jo["min_lotqty"].ToString());
  2416. }
  2417. }
  2418. var Header = new
  2419. {
  2420. msg = msg,
  2421. Num = Num,
  2422. };
  2423. return Header;
  2424. }
  2425. //接口api解析
  2426. public static string HttpPost(string url, string body)
  2427. {
  2428. try
  2429. {
  2430. Encoding encoding = Encoding.UTF8;
  2431. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  2432. request.Method = "POST";
  2433. request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
  2434. request.ContentType = "application/json; charset=utf-8";
  2435. byte[] buffer = encoding.GetBytes(body);
  2436. request.ContentLength = buffer.Length;
  2437. request.GetRequestStream().Write(buffer, 0, buffer.Length);
  2438. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  2439. using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
  2440. {
  2441. return reader.ReadToEnd();
  2442. }
  2443. }
  2444. catch (WebException ex)
  2445. {
  2446. throw new Exception(ex.Message);
  2447. }
  2448. }
  2449. }
  2450. }