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

2588 lines
161 KiB

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