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

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