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

2635 lines
163 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
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.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  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\":\"P\"";
  1224. InspectJosn += "}";
  1225. InspectJosn += "],";
  1226. InspectJosn += "\"IMP_ORDINI_RIGHE\":[";
  1227. InspectJosn += "{";
  1228. InspectJosn += "\"RIG_ORDINE\":\"" + DNCode + "\",";
  1229. InspectJosn += "\"RIG_ARTICOLO\": \"" + INVCode + "\",";
  1230. InspectJosn += "\"RIG_SUB1\": \"\",";
  1231. InspectJosn += "\"RIG_SUB2\": \"\",";
  1232. InspectJosn += "\"RIG_QTAR\": " + thisCreateQty + ",";
  1233. InspectJosn += "\"RIG_HOSTINF\": " + Sequence + "";
  1234. InspectJosn += "}";
  1235. InspectJosn += "]";
  1236. InspectJosn += "}";
  1237. for (int i = 0; i < createPageCount; i++)
  1238. {
  1239. if (i + 1 == createPageCount)
  1240. {
  1241. if (minPackQty * createPageCount > thisCreateQty)
  1242. {
  1243. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1244. }
  1245. }
  1246. 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. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1248. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1249. if (ExtensionID == null)
  1250. {
  1251. ExtensionID = Guid.NewGuid();
  1252. 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)
  1253. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1254. 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(),
  1255. MUSER, MUSERNAME, WorkPoints);
  1256. }
  1257. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1258. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1259. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1260. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1261. sql += string.Format(@"
  1262. insert into ICSInventoryLot
  1263. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1264. select
  1265. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','7','{3}','{4}', getdate(),'{5}','{9}'
  1266. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1267. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1268. sql += "\r\n";
  1269. }
  1270. string result = "";
  1271. if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UploadERP"]))
  1272. {
  1273. result = HTTPHelper.RestFulGet(InspectJosn, postUrlStr);
  1274. if (result.Contains("Error"))
  1275. {
  1276. ICSHGResult hgresult = JsonConvert.DeserializeObject<ICSHGResult>(result.TrimStart('[').TrimEnd(']'));
  1277. throw new Exception("货柜单据传输接口调用报错,主要报错信息:" + hgresult.PrimaryError + ",次要报错信息:" + hgresult.SecondaryError + "");
  1278. }
  1279. }
  1280. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1281. return count;
  1282. }
  1283. catch (Exception ex)
  1284. {
  1285. throw new Exception(ex.Message);
  1286. }
  1287. }
  1288. /// <summary>
  1289. /// 审核委外到货单生成条码
  1290. /// </summary>
  1291. /// <param name="POCode"></param>
  1292. /// <param name="PORow"></param>
  1293. /// <param name="keyValue"></param>
  1294. /// 已改
  1295. /// <returns></returns>
  1296. public int SubmitFormWWSHDH(string ODNCode, string Sequence, string keyValue, string WorkPoint)
  1297. {
  1298. var queryParam = keyValue.ToJObject();
  1299. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1300. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1301. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1302. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1303. decimal LOTQTY = minPackQty;
  1304. string Pre = "ODN" + ODNCode + Sequence;
  1305. string sql = string.Empty;
  1306. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1307. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1308. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1309. string sqls = string.Empty;
  1310. string Colspan = "";
  1311. for (int i = 0; i < createPageCount; i++)
  1312. {
  1313. if (i + 1 == createPageCount)
  1314. {
  1315. if (minPackQty * createPageCount > thisCreateQty)
  1316. {
  1317. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1318. }
  1319. }
  1320. 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();
  1321. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1322. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1323. if (ExtensionID == null)
  1324. {
  1325. ExtensionID = Guid.NewGuid();
  1326. 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)
  1327. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1328. 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(),
  1329. MUSER, MUSERNAME, WorkPoints);
  1330. }
  1331. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1332. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1333. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1334. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1335. sql += string.Format(@"
  1336. insert into ICSInventoryLot
  1337. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1338. select
  1339. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','8','{3}','{4}', getdate(),'{5}','{9}'
  1340. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1341. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1342. sql += "\r\n";
  1343. }
  1344. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1345. return count;
  1346. }
  1347. /// <summary>
  1348. /// 开立成品入库单
  1349. /// </summary>
  1350. /// <param name="POCode"></param>
  1351. /// <param name="PORow"></param>
  1352. /// <param name="keyValue"></param>
  1353. /// 已改
  1354. /// <returns></returns>
  1355. public int SubmitFormKLCPRK(string RCVCode, string Sequence, string keyValue, string WorkPoint)
  1356. {
  1357. var queryParam = keyValue.ToJObject();
  1358. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1359. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1360. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1361. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1362. decimal LOTQTY = minPackQty;
  1363. string Pre = "KCP" + RCVCode + Sequence;
  1364. string sql = string.Empty;
  1365. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1366. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1367. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1368. string sqls = string.Empty;
  1369. string Colspan = "";
  1370. for (int i = 0; i < createPageCount; i++)
  1371. {
  1372. if (i + 1 == createPageCount)
  1373. {
  1374. if (minPackQty * createPageCount > thisCreateQty)
  1375. {
  1376. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1377. }
  1378. }
  1379. 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();
  1380. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1381. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1382. if (ExtensionID == null)
  1383. {
  1384. ExtensionID = Guid.NewGuid();
  1385. 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)
  1386. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1387. 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(),
  1388. MUSER, MUSERNAME, WorkPoints);
  1389. }
  1390. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1391. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1392. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1393. LotNo, RCVCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1394. sql += string.Format(@"
  1395. insert into ICSInventoryLot
  1396. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1397. select
  1398. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','9','{3}','{4}', getdate(),'{5}','{9}'
  1399. from ICSManufactureReceive where RCVCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1400. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, RCVCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1401. sql += "\r\n";
  1402. }
  1403. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1404. return count;
  1405. }
  1406. //委外拒收单
  1407. public DataTable GetGridJsonWWJSD(string queryJson, ref Pagination jqgridparam)
  1408. {
  1409. DataTable dt = new DataTable();
  1410. var queryParam = queryJson.ToJObject();
  1411. List<DbParameter> parameter = new List<DbParameter>();
  1412. object Figure = GetDecimalDigits();
  1413. #region [SQL]
  1414. 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,
  1415. 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
  1416. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1417. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1418. from ICSODeliveryNotice a
  1419. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1420. left join (
  1421. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1422. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='11'
  1423. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1424. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1425. --inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  1426. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1427. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1428. where a.ODNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
  1429. ";
  1430. sql = string.Format(sql, Figure);
  1431. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1432. #endregion
  1433. if (!string.IsNullOrWhiteSpace(queryJson))
  1434. {
  1435. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1436. {
  1437. sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1438. }
  1439. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1440. {
  1441. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1442. }
  1443. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1444. {
  1445. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1446. }
  1447. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1448. {
  1449. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1450. }
  1451. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1452. {
  1453. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1454. }
  1455. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1456. {
  1457. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1458. }
  1459. }
  1460. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1461. {
  1462. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1463. }
  1464. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1465. {
  1466. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1467. }
  1468. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1469. }
  1470. //拒收单
  1471. public DataTable GetGridJsonJSD(string queryJson, ref Pagination jqgridparam)
  1472. {
  1473. DataTable dt = new DataTable();
  1474. var queryParam = queryJson.ToJObject();
  1475. List<DbParameter> parameter = new List<DbParameter>();
  1476. object Figure = GetDecimalDigits();
  1477. #region [SQL]
  1478. string sql = @"select a.ID,a.DNCode ,a.Sequence ,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  1479. 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,
  1480. CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1481. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1482. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1483. from ICSDeliveryNotice a
  1484. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1485. left join (
  1486. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1487. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='10'
  1488. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1489. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1490. --inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  1491. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1492. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1493. where a.DNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
  1494. ";
  1495. sql = string.Format(sql, Figure);
  1496. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1497. #endregion
  1498. if (!string.IsNullOrWhiteSpace(queryJson))
  1499. {
  1500. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1501. {
  1502. sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1503. }
  1504. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1505. {
  1506. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1507. }
  1508. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1509. {
  1510. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1511. }
  1512. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1513. {
  1514. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1515. }
  1516. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1517. {
  1518. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1519. }
  1520. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1521. {
  1522. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1523. }
  1524. }
  1525. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1526. {
  1527. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1528. }
  1529. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1530. {
  1531. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1532. }
  1533. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1534. }
  1535. //领料申请退料
  1536. public DataTable GetGridJsonLLSQTL(string queryJson, ref Pagination jqgridparam)
  1537. {
  1538. DataTable dt = new DataTable();
  1539. var queryParam = queryJson.ToJObject();
  1540. List<DbParameter> parameter = new List<DbParameter>();
  1541. object Figure = GetDecimalDigits();
  1542. #region [SQL]
  1543. string sql = @"select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  1544. 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
  1545. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1546. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1547. from ICSMOApplyNegDetail a
  1548. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1549. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1550. left join (
  1551. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1552. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='12'
  1553. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1554. )c
  1555. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1556. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1557. WHERE d.Type='2'";
  1558. sql = string.Format(sql, Figure);
  1559. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1560. #endregion
  1561. if (!string.IsNullOrWhiteSpace(queryJson))
  1562. {
  1563. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1564. {
  1565. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1566. }
  1567. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1568. {
  1569. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1570. }
  1571. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1572. {
  1573. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1574. }
  1575. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1576. {
  1577. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1578. }
  1579. }
  1580. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1581. {
  1582. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1583. }
  1584. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1585. {
  1586. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1587. }
  1588. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1589. }
  1590. /// <summary>
  1591. /// 拒收生成条码
  1592. /// </summary>
  1593. /// <param name="POCode"></param>
  1594. /// <param name="PORow"></param>
  1595. /// <param name="keyValue"></param>
  1596. /// <returns></returns>
  1597. public int SubmitFormJSD(string DNCode, string Sequence, string keyValue, string WorkPoint)
  1598. {
  1599. var queryParam = keyValue.ToJObject();
  1600. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1601. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1602. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1603. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1604. decimal LOTQTY = minPackQty;
  1605. string Pre = "JS" + DNCode + Sequence;
  1606. string sql = string.Empty;
  1607. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1608. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1609. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1610. string sqls = string.Empty;
  1611. string Colspan = "";
  1612. for (int i = 0; i < createPageCount; i++)
  1613. {
  1614. if (i + 1 == createPageCount)
  1615. {
  1616. if (minPackQty * createPageCount > thisCreateQty)
  1617. {
  1618. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1619. }
  1620. }
  1621. 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();
  1622. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1623. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1624. if (ExtensionID == null)
  1625. {
  1626. ExtensionID = Guid.NewGuid();
  1627. 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)
  1628. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1629. 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(),
  1630. MUSER, MUSERNAME, WorkPoints);
  1631. }
  1632. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1633. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1634. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1635. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1636. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1637. //{
  1638. sql += string.Format(@"
  1639. insert into ICSInventoryLot
  1640. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1641. select
  1642. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','10','{3}','{4}', getdate(),'{5}','{9}'
  1643. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1644. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1645. sql += "\r\n";
  1646. //}
  1647. }
  1648. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1649. return count;
  1650. }
  1651. /// <summary>
  1652. /// 委外拒收生成条码
  1653. /// </summary>
  1654. /// <param name="POCode"></param>
  1655. /// <param name="PORow"></param>
  1656. /// <param name="keyValue"></param>
  1657. /// <returns></returns>
  1658. public int SubmitFormWWJSD(string ODNCode, string Sequence, string keyValue, string WorkPoint)
  1659. {
  1660. var queryParam = keyValue.ToJObject();
  1661. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1662. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1663. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1664. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1665. decimal LOTQTY = minPackQty;
  1666. string Pre = "OJS" + ODNCode + Sequence;
  1667. string sql = string.Empty;
  1668. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1669. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1670. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1671. string sqls = string.Empty;
  1672. string Colspan = "";
  1673. for (int i = 0; i < createPageCount; i++)
  1674. {
  1675. if (i + 1 == createPageCount)
  1676. {
  1677. if (minPackQty * createPageCount > thisCreateQty)
  1678. {
  1679. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1680. }
  1681. }
  1682. 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();
  1683. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1684. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1685. if (ExtensionID == null)
  1686. {
  1687. ExtensionID = Guid.NewGuid();
  1688. 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)
  1689. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1690. 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(),
  1691. MUSER, MUSERNAME, WorkPoints);
  1692. }
  1693. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1694. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1695. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1696. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1697. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1698. //{
  1699. sql += string.Format(@"
  1700. insert into ICSInventoryLot
  1701. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1702. select
  1703. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','11','{3}','{4}', getdate(),'{5}','{9}'
  1704. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1705. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1706. sql += "\r\n";
  1707. //}
  1708. }
  1709. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1710. return count;
  1711. }
  1712. /// <summary>
  1713. /// 点击审核到货单生成条码(审核到货单)
  1714. /// </summary>
  1715. public DataTable GetSubGridJsonJSDByCreate(string DNCode, string Sequence, string WorkPoint)
  1716. {
  1717. DataTable dt = new DataTable();
  1718. object Figure = GetDecimalDigits();
  1719. List<DbParameter> parameter = new List<DbParameter>();
  1720. 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,
  1721. 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
  1722. from ICSDeliveryNotice a
  1723. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1724. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1725. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1726. group by b.TransCode,b.TransSequence
  1727. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
  1728. WHERE a.DNType='3'
  1729. and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
  1730. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1731. sql = string.Format(sql, Figure);
  1732. return Repository().FindTableBySql(sql.ToString());
  1733. }
  1734. /// <summary>
  1735. /// 点击审核委外到货单生成条码(审核委外到货单)
  1736. /// </summary>
  1737. public DataTable GetSubGridJsonWWJSDByCreate(string ODNCode, string Sequence, string WorkPoint)
  1738. {
  1739. DataTable dt = new DataTable();
  1740. object Figure = GetDecimalDigits();
  1741. List<DbParameter> parameter = new List<DbParameter>();
  1742. 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,
  1743. 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
  1744. from ICSODeliveryNotice a
  1745. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1746. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1747. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1748. group by b.TransCode,b.TransSequence
  1749. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
  1750. WHERE a.ODNType='3'
  1751. and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
  1752. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1753. sql = string.Format(sql, Figure);
  1754. return Repository().FindTableBySql(sql.ToString());
  1755. }
  1756. public DataTable GetSubGridJsonLLSQDByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  1757. {
  1758. DataTable dt = new DataTable();
  1759. object Figure = GetDecimalDigits();
  1760. List<DbParameter> parameter = new List<DbParameter>();
  1761. 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,
  1762. 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
  1763. from ICSMOApplyNegDetail a
  1764. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1765. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1766. left join (
  1767. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1768. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1769. group by b.TransCode,b.TransSequence
  1770. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  1771. WHERE d.Type='2'
  1772. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  1773. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1774. sql = string.Format(sql, Figure);
  1775. return Repository().FindTableBySql(sql.ToString());
  1776. }
  1777. //领料申请退料生成条码
  1778. public int SubmitFormLLSQTL(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  1779. {
  1780. var queryParam = keyValue.ToJObject();
  1781. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1782. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1783. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1784. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1785. decimal LOTQTY = minPackQty;
  1786. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1787. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  1788. string Pre = "MA" + ApplyNegCode + Sequence;
  1789. string sql = string.Empty;
  1790. //string VendorLot = queryParam["VendorLot"].ToString();
  1791. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1792. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1793. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1794. string sqls = string.Empty;
  1795. string Colspan = "";
  1796. for (int i = 0; i < createPageCount; i++)
  1797. {
  1798. if (i + 1 == createPageCount)
  1799. {
  1800. if (minPackQty * createPageCount > thisCreateQty)
  1801. {
  1802. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1803. }
  1804. }
  1805. 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();
  1806. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1807. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1808. if (ExtensionID == null)
  1809. {
  1810. ExtensionID = Guid.NewGuid();
  1811. 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)
  1812. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1813. 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(),
  1814. MUSER, MUSERNAME, WorkPoints);
  1815. }
  1816. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1817. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1818. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1819. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1820. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1821. //{
  1822. sql += string.Format(@"insert into ICSInventoryLot
  1823. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1824. select
  1825. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','12','{3}','{4}', getdate(),'{5}','{9}'
  1826. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1827. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1828. sql += "\r\n";
  1829. //}
  1830. }
  1831. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1832. return count;
  1833. }
  1834. //材料出库退料
  1835. public DataTable GetGridJsonCLCK(string queryJson, ref Pagination jqgridparam)
  1836. {
  1837. DataTable dt = new DataTable();
  1838. var queryParam = queryJson.ToJObject();
  1839. List<DbParameter> parameter = new List<DbParameter>();
  1840. object Figure = GetDecimalDigits();
  1841. #region [SQL]
  1842. string sql = @"
  1843. select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  1844. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity,
  1845. 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
  1846. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1847. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1848. from ICSMOApplyNegDetail a
  1849. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1850. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1851. left join (
  1852. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1853. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='13'
  1854. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1855. )c
  1856. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1857. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1858. WHERE d.Type='3'";
  1859. sql = string.Format(sql, Figure);
  1860. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1861. #endregion
  1862. if (!string.IsNullOrWhiteSpace(queryJson))
  1863. {
  1864. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1865. {
  1866. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1867. }
  1868. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1869. {
  1870. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1871. }
  1872. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1873. {
  1874. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1875. }
  1876. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1877. {
  1878. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1879. }
  1880. }
  1881. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1882. {
  1883. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1884. }
  1885. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1886. {
  1887. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1888. }
  1889. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1890. }
  1891. //材料出库退料
  1892. public DataTable GetSubGridJsonCLCKByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  1893. {
  1894. DataTable dt = new DataTable();
  1895. object Figure = GetDecimalDigits();
  1896. List<DbParameter> parameter = new List<DbParameter>();
  1897. 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,
  1898. 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
  1899. from ICSMOApplyNegDetail a
  1900. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1901. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1902. left join (
  1903. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1904. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1905. group by b.TransCode,b.TransSequence
  1906. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  1907. WHERE d.Type='3'
  1908. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  1909. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1910. sql = string.Format(sql, Figure);
  1911. return Repository().FindTableBySql(sql.ToString());
  1912. }
  1913. //材料出库退料生成条码
  1914. public int SubmitFormCLCKT(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  1915. {
  1916. var queryParam = keyValue.ToJObject();
  1917. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1918. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1919. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1920. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1921. decimal LOTQTY = minPackQty;
  1922. string Pre = "MD" + ApplyNegCode + Sequence;
  1923. string sql = string.Empty;
  1924. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1925. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1926. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1927. string sqls = string.Empty;
  1928. string Colspan = "";
  1929. for (int i = 0; i < createPageCount; i++)
  1930. {
  1931. if (i + 1 == createPageCount)
  1932. {
  1933. if (minPackQty * createPageCount > thisCreateQty)
  1934. {
  1935. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1936. }
  1937. }
  1938. 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();
  1939. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1940. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1941. if (ExtensionID == null)
  1942. {
  1943. ExtensionID = Guid.NewGuid();
  1944. 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)
  1945. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1946. 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(),
  1947. MUSER, MUSERNAME, WorkPoints);
  1948. }
  1949. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1950. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1951. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1952. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1953. sql += string.Format(@"insert into ICSInventoryLot
  1954. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1955. select
  1956. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','13','{3}','{4}', getdate(),'{5}','{9}'
  1957. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1958. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1959. sql += "\r\n";
  1960. }
  1961. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1962. return count;
  1963. }
  1964. public DataTable GetGridJsonWWLLTL(string queryJson, ref Pagination jqgridparam)
  1965. {
  1966. DataTable dt = new DataTable();
  1967. var queryParam = queryJson.ToJObject();
  1968. List<DbParameter> parameter = new List<DbParameter>();
  1969. object Figure = GetDecimalDigits();
  1970. #region [SQL]
  1971. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  1972. 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
  1973. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1974. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1975. from ICSOApplyNegDetail a
  1976. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  1977. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1978. left join (
  1979. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1980. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='14'
  1981. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1982. )c
  1983. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1984. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1985. WHERE d.Type='2'";
  1986. sql = string.Format(sql, Figure);
  1987. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1988. #endregion
  1989. if (!string.IsNullOrWhiteSpace(queryJson))
  1990. {
  1991. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1992. {
  1993. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1994. }
  1995. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1996. {
  1997. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1998. }
  1999. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2000. {
  2001. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2002. }
  2003. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2004. {
  2005. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2006. }
  2007. }
  2008. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2009. {
  2010. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2011. }
  2012. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2013. {
  2014. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2015. }
  2016. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2017. }
  2018. /// <summary>
  2019. /// 点击委外领料退料生成条码
  2020. /// </summary>
  2021. public DataTable GetSubGridJsonWWLLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  2022. {
  2023. DataTable dt = new DataTable();
  2024. object Figure = GetDecimalDigits();
  2025. List<DbParameter> parameter = new List<DbParameter>();
  2026. string sql = @"
  2027. 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,
  2028. 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
  2029. from ICSOApplyNegDetail a
  2030. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2031. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2032. left join (
  2033. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2034. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2035. group by b.TransCode,b.TransSequence
  2036. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2037. WHERE d.Type='2'
  2038. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2039. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2040. sql = string.Format(sql, Figure);
  2041. return Repository().FindTableBySql(sql.ToString());
  2042. }
  2043. //委外领料申请退料
  2044. public int SubmitFormWWLL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2045. {
  2046. var queryParam = keyValue.ToJObject();
  2047. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2048. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2049. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2050. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2051. decimal LOTQTY = minPackQty;
  2052. string Pre = "OMA" + OApplyNegCode + Sequence;
  2053. string sql = string.Empty;
  2054. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2055. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2056. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2057. string sqls = string.Empty;
  2058. string Colspan = "";
  2059. for (int i = 0; i < createPageCount; i++)
  2060. {
  2061. if (i + 1 == createPageCount)
  2062. {
  2063. if (minPackQty * createPageCount > thisCreateQty)
  2064. {
  2065. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2066. }
  2067. }
  2068. 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();
  2069. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2070. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2071. if (ExtensionID == null)
  2072. {
  2073. ExtensionID = Guid.NewGuid();
  2074. 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)
  2075. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2076. 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(),
  2077. MUSER, MUSERNAME, WorkPoints);
  2078. }
  2079. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2080. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2081. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2082. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2083. sql += string.Format(@"insert into ICSInventoryLot
  2084. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2085. select
  2086. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','14','{3}','{4}', getdate(),'{5}','{9}'
  2087. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2088. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2089. sql += "\r\n";
  2090. }
  2091. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2092. return count;
  2093. }
  2094. //委外材料出库
  2095. public DataTable GetGridJsonWWCLCK(string queryJson, ref Pagination jqgridparam)
  2096. {
  2097. DataTable dt = new DataTable();
  2098. var queryParam = queryJson.ToJObject();
  2099. List<DbParameter> parameter = new List<DbParameter>();
  2100. object Figure = GetDecimalDigits();
  2101. #region [SQL]
  2102. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2103. 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
  2104. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2105. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2106. from ICSOApplyNegDetail a
  2107. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2108. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2109. left join (
  2110. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2111. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='15'
  2112. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2113. )c
  2114. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2115. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2116. WHERE d.Type='3'";
  2117. sql = string.Format(sql, Figure);
  2118. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2119. #endregion
  2120. if (!string.IsNullOrWhiteSpace(queryJson))
  2121. {
  2122. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2123. {
  2124. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2125. }
  2126. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2127. {
  2128. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2129. }
  2130. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2131. {
  2132. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2133. }
  2134. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2135. {
  2136. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2137. }
  2138. }
  2139. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2140. {
  2141. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2142. }
  2143. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2144. {
  2145. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2146. }
  2147. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2148. }
  2149. //委外材料出库
  2150. public DataTable GetSubGridJsonWWCLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  2151. {
  2152. DataTable dt = new DataTable();
  2153. object Figure = GetDecimalDigits();
  2154. List<DbParameter> parameter = new List<DbParameter>();
  2155. string sql = @"
  2156. 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,
  2157. 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
  2158. from ICSOApplyNegDetail a
  2159. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2160. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2161. left join (
  2162. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2163. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2164. group by b.TransCode,b.TransSequence
  2165. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2166. WHERE d.Type='3'
  2167. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2168. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2169. sql = string.Format(sql, Figure);
  2170. return Repository().FindTableBySql(sql.ToString());
  2171. }
  2172. //委外材料出库
  2173. public int SubmitFormWWCL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2174. {
  2175. var queryParam = keyValue.ToJObject();
  2176. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2177. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2178. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2179. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2180. decimal LOTQTY = minPackQty;
  2181. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2182. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  2183. string Pre = "OMD" + OApplyNegCode + Sequence;
  2184. string sql = string.Empty;
  2185. //string VendorLot = queryParam["VendorLot"].ToString();
  2186. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2187. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2188. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2189. string sqls = string.Empty;
  2190. string Colspan = "";
  2191. for (int i = 0; i < createPageCount; i++)
  2192. {
  2193. if (i + 1 == createPageCount)
  2194. {
  2195. if (minPackQty * createPageCount > thisCreateQty)
  2196. {
  2197. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2198. }
  2199. }
  2200. 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();
  2201. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2202. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2203. if (ExtensionID == null)
  2204. {
  2205. ExtensionID = Guid.NewGuid();
  2206. 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)
  2207. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2208. 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(),
  2209. MUSER, MUSERNAME, WorkPoints);
  2210. }
  2211. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2212. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2213. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2214. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2215. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  2216. //{
  2217. sql += string.Format(@"insert into ICSInventoryLot
  2218. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2219. select
  2220. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','15','{3}','{4}', getdate(),'{5}','{9}'
  2221. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2222. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2223. sql += "\r\n";
  2224. //}
  2225. }
  2226. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2227. return count;
  2228. }
  2229. public DataTable SelectICSExtensionEnable(string BeginTime, string EndTime)
  2230. {
  2231. string sql = @"select ColCode from ICSExtensionEnable
  2232. where Enable=0
  2233. order by cast(EATTRIBUTE1 as int)";
  2234. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2235. return dt;
  2236. }
  2237. //返工工单
  2238. public DataTable GetGridJsonFGGD(string queryJson, ref Pagination jqgridparam)
  2239. {
  2240. DataTable dt = new DataTable();
  2241. var queryParam = queryJson.ToJObject();
  2242. List<DbParameter> parameter = new List<DbParameter>();
  2243. object Figure = GetDecimalDigits();
  2244. #region [SQL]
  2245. 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,
  2246. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  2247. 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
  2248. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2249. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2250. from ICSMOPick a
  2251. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint
  2252. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2253. left join (
  2254. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2255. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='16'
  2256. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2257. )c
  2258. on d.MOCode=c.TransCode and d.Sequence+'-'+a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2259. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2260. where a.EATTRIBUTE1='1' and d.EATTRIBUTE1='1'";
  2261. sql = string.Format(sql, Figure);
  2262. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2263. #endregion
  2264. if (!string.IsNullOrWhiteSpace(queryJson))
  2265. {
  2266. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2267. {
  2268. sql += " and d.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2269. }
  2270. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2271. {
  2272. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2273. }
  2274. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2275. {
  2276. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2277. }
  2278. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2279. {
  2280. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2281. }
  2282. }
  2283. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2284. {
  2285. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2286. }
  2287. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2288. {
  2289. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2290. }
  2291. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2292. }
  2293. public DataTable GetSubGridJsonFGGDCreate(string FGGDMOCode, string Sequence, string WorkPoint)
  2294. {
  2295. DataTable dt = new DataTable();
  2296. object Figure = GetDecimalDigits();
  2297. List<DbParameter> parameter = new List<DbParameter>();
  2298. string sql = @"
  2299. 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,
  2300. 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
  2301. from ICSMOPick a
  2302. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint
  2303. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2304. left join (
  2305. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2306. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2307. group by b.TransCode,b.TransSequence
  2308. ) c on d.MOCode=c.TransCode and d.Sequence+'-'+a.Sequence=c.TransSequence
  2309. WHERE 1=1
  2310. and d.MOCode='" + FGGDMOCode + "' and d.Sequence+'-'+a.Sequence='" + Sequence + "'";
  2311. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2312. sql = string.Format(sql, Figure);
  2313. return Repository().FindTableBySql(sql.ToString());
  2314. }
  2315. //返工工单
  2316. public int SubmitFormFGGD(string FGGDMOCode, string Sequence, string keyValue, string WorkPoint)
  2317. {
  2318. var queryParam = keyValue.ToJObject();
  2319. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2320. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2321. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2322. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2323. decimal LOTQTY = minPackQty;
  2324. string Pre = "FG" + FGGDMOCode + Sequence;
  2325. string sql = string.Empty;
  2326. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2327. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2328. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2329. string sqls = string.Empty;
  2330. string Colspan = "";
  2331. for (int i = 0; i < createPageCount; i++)
  2332. {
  2333. if (i + 1 == createPageCount)
  2334. {
  2335. if (minPackQty * createPageCount > thisCreateQty)
  2336. {
  2337. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2338. }
  2339. }
  2340. 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();
  2341. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2342. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2343. if (ExtensionID == null)
  2344. {
  2345. ExtensionID = Guid.NewGuid();
  2346. 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)
  2347. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2348. 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(),
  2349. MUSER, MUSERNAME, WorkPoints);
  2350. }
  2351. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2352. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2353. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2354. LotNo, FGGDMOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2355. sql += string.Format(@"insert into ICSInventoryLot
  2356. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2357. select
  2358. newid(),'{0}',a.InvCode,'{1}','{10}','{2}','{8}','16','{3}','{4}', getdate(),'{5}','{9}'
  2359. 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}' ",
  2360. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, FGGDMOCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2361. sql += "\r\n";
  2362. }
  2363. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2364. return count;
  2365. }
  2366. public object GetDecimalDigits()
  2367. {
  2368. try
  2369. {
  2370. string sql = string.Empty;
  2371. sql = @"select Figure from ICSConfiguration where Code='Figure001' and Enable='1'";
  2372. object Figure = SqlHelper.ExecuteScalar(sql);
  2373. return Figure;
  2374. }
  2375. catch (Exception ex)
  2376. {
  2377. throw new Exception(ex.Message.ToString());
  2378. }
  2379. }
  2380. public object GetQiSetNum(string keyValue)
  2381. {
  2382. int Num = 0;
  2383. string msg = "";
  2384. string APIURL = ConfigurationManager.ConnectionStrings["ERPAPIURL"].ConnectionString + "Complete/Approve";
  2385. string result = HttpPost(APIURL, keyValue);
  2386. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  2387. string MessAge = Obj["Message"].ToString();
  2388. string Success = Obj["Success"].ToString();
  2389. if (Success.ToUpper() == "FALSE")
  2390. {
  2391. msg = MessAge;
  2392. }
  2393. if (msg == "")
  2394. {
  2395. JArray res = (JArray)JsonConvert.DeserializeObject(Obj["Data"].ToString());
  2396. foreach (var item in res)
  2397. {
  2398. JObject jo = (JObject)item;
  2399. Num = Convert.ToInt32(jo["min_lotqty"].ToString());
  2400. }
  2401. }
  2402. var Header = new
  2403. {
  2404. msg = msg,
  2405. Num = Num,
  2406. };
  2407. return Header;
  2408. }
  2409. //接口api解析
  2410. public static string HttpPost(string url, string body)
  2411. {
  2412. try
  2413. {
  2414. Encoding encoding = Encoding.UTF8;
  2415. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  2416. request.Method = "POST";
  2417. request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
  2418. request.ContentType = "application/json; charset=utf-8";
  2419. byte[] buffer = encoding.GetBytes(body);
  2420. request.ContentLength = buffer.Length;
  2421. request.GetRequestStream().Write(buffer, 0, buffer.Length);
  2422. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  2423. using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
  2424. {
  2425. return reader.ReadToEnd();
  2426. }
  2427. }
  2428. catch (WebException ex)
  2429. {
  2430. throw new Exception(ex.Message);
  2431. }
  2432. }
  2433. }
  2434. }