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

1314 lines
67 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. using NFine.Data.Extensions;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using NFine.Code;
  9. using NFine.Repository;
  10. using System.Data.Common;
  11. using NFine.Domain._03_Entity.SRM;
  12. using ICS.Application.Entity;
  13. using Newtonsoft.Json;
  14. using System.Configuration;
  15. using System.Data.SqlClient;
  16. using ICS.Data;
  17. using Newtonsoft.Json.Linq;
  18. using NFine.Domain._03_Entity.WMS;
  19. using System.Net;
  20. using System.IO;
  21. namespace NFine.Application.WMS
  22. {
  23. public class WMSCreateItemLotApp : RepositoryFactory<ICSVendor>
  24. {
  25. public DataTable GetGridJson(string queryJson, ref Pagination jqgridparam)
  26. {
  27. DataTable dt = new DataTable();
  28. var queryParam = queryJson.ToJObject();
  29. List<DbParameter> parameter = new List<DbParameter>();
  30. #region [SQL]
  31. string sql = @"select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,a.Quantity,a.Amount,a.IssueNegQuantity,a.ExtensionID,a.MUSERName,a.MTIME ,c.LOTQTY,f.BatchCode
  32. from ICSMOApplyNegDetail a
  33. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  34. left join (
  35. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  36. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  37. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  38. )c
  39. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  40. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint";
  41. sql += " WHERE 1=1";
  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.POCode 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, ref Pagination jqgridparam)
  74. {
  75. DataTable dt = new DataTable();
  76. //var queryParam = queryJson.ToJObject();
  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,a.Quantity,a.MUSERName,a.MTIME from ICSInventoryLot a
  80. left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo
  81. group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
  82. left join ICSInventoryLotDetail c on a.LotNo=c.LotNo
  83. WHERE c.TransCode='" + ApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in ('" + WorkPoint + "')";
  84. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  85. }
  86. /// <summary>
  87. /// 点击生成条码
  88. /// </summary>
  89. public DataTable GetSubGridJsonByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  90. {
  91. DataTable dt = new DataTable();
  92. //var queryParam = queryJson.ToJObject();
  93. List<DbParameter> parameter = new List<DbParameter>();
  94. string sql = @" select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  95. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  96. from ICSMOApplyNegDetail a
  97. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  98. left join (
  99. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  100. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  101. group by b.TransCode,b.TransSequence
  102. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  103. WHERE 1 =1
  104. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  105. sql += " and a.WorkPoint='" + WorkPoint + "'";
  106. return Repository().FindTableBySql(sql.ToString());
  107. }
  108. public DataTable GetVendorLotNo(string VenCode, string WorkPoint)
  109. {
  110. DataTable dt = new DataTable();
  111. //var queryParam = queryJson.ToJObject();
  112. List<DbParameter> parameter = new List<DbParameter>();
  113. string dtPre = DateTime.Now.ToString("yyyyMMdd");
  114. string sql = @"EXEC Addins_GetSerialCode '" + WorkPoint + "','ICSITEMLotNo','VendorLotNo','" + VenCode + dtPre + "',2";
  115. return Repository().FindTableBySql(sql.ToString());
  116. }
  117. /// <summary>
  118. /// 生产退料生成条码
  119. /// </summary>
  120. /// <param name="POCode"></param>
  121. /// <param name="PORow"></param>
  122. /// <param name="keyValue"></param>
  123. /// 已改
  124. /// <returns></returns>
  125. public int CreateItemLotNo(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  126. {
  127. var queryParam = keyValue.ToJObject();
  128. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  129. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  130. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  131. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  132. decimal LOTQTY = minPackQty;
  133. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  134. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  135. string Pre = ApplyNegCode + Sequence;
  136. string sql = string.Empty;
  137. //string VendorLot = queryParam["VendorLot"].ToString();
  138. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  139. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  140. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  141. string sqls = string.Empty;
  142. for (int i = 0; i < createPageCount; i++)
  143. {
  144. if (i + 1 == createPageCount)
  145. {
  146. if (minPackQty * createPageCount > thisCreateQty)
  147. {
  148. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  149. }
  150. }
  151. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  152. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  153. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  154. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  155. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  156. //{
  157. sql += string.Format(@"insert into ICSInventoryLot
  158. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  159. select
  160. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'3','{3}','{4}', getdate(),'{5}'
  161. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  162. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence);
  163. sql += "\r\n";
  164. //}
  165. }
  166. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  167. return count;
  168. }
  169. public string GetSerialCode(string workPointCode, string tbName, string colName, string Pre, int numLen)
  170. {
  171. string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}";
  172. sql = string.Format(sql, new object[] { workPointCode, tbName, colName, Pre, numLen });
  173. return DbHelper.ExecuteScalar(CommandType.Text, sql).ToString();
  174. }
  175. /// <summary>
  176. /// 删除条码
  177. /// </summary>
  178. /// <param name="keyValue"></param>
  179. /// <returns></returns>
  180. public string DeleteItemLot(string keyValue)
  181. {
  182. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  183. string msg = string.Empty;
  184. string sql = string.Format(@"SELECT * FROM dbo.ICSInspection
  185. WHERE LotNo IN (SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  186. DataTable dtASN = SqlHelper.GetDataTableBySql(sql);
  187. if (dtASN != null && dtASN.Rows.Count > 0)
  188. {
  189. msg = "所选条码已生成检验单,无法删除!";
  190. }
  191. sql = string.Format(@"SELECT * FROM dbo.ICSWareHouseLotInfo WHERE LotNO IN
  192. (SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  193. DataTable dtCarton = SqlHelper.GetDataTableBySql(sql);
  194. if (dtCarton != null && dtCarton.Rows.Count > 0)
  195. {
  196. msg += "所选条码已入库,无法删除!";
  197. }
  198. if (string.IsNullOrEmpty(msg))
  199. {
  200. 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);
  201. sqls += string.Format("DELETE FROM dbo.ICSInventoryLot WHERE ID IN ({0}) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  202. SqlHelper.CmdExecuteNonQueryLi(sqls);
  203. }
  204. return msg;
  205. }
  206. public DataTable GetGridJsonWeiWai(string queryJson, ref Pagination jqgridparam)
  207. {
  208. DataTable dt = new DataTable();
  209. var queryParam = queryJson.ToJObject();
  210. List<DbParameter> parameter = new List<DbParameter>();
  211. #region [SQL]
  212. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,a.Quantity,a.Amount,a.IssueNegQuantity,a.ExtensionID,a.MUSERName,a.MTIME ,c.LOTQTY,f.BatchCode
  213. from ICSOApplyNegDetail a
  214. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  215. left join (
  216. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  217. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  218. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  219. )c
  220. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  221. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint ";
  222. sql += " WHERE 1=1";
  223. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  224. #endregion
  225. if (!string.IsNullOrWhiteSpace(queryJson))
  226. {
  227. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  228. {
  229. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  230. }
  231. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  232. {
  233. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  234. }
  235. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  236. {
  237. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  238. }
  239. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  240. {
  241. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  242. }
  243. }
  244. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  245. {
  246. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  247. }
  248. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  249. {
  250. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  251. }
  252. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  253. }
  254. public DataTable GetSubGridJsonWeiWai(string OApplyNegCode, string Sequence, ref Pagination jqgridparam)
  255. {
  256. DataTable dt = new DataTable();
  257. //var queryParam = queryJson.ToJObject();
  258. List<DbParameter> parameter = new List<DbParameter>();
  259. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  260. string sql = @" select c.TransCode,c.TransSequence ,a.ID,a.LotNo,a.Quantity from ICSInventoryLot a
  261. left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo
  262. group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
  263. left join ICSInventoryLotDetail c on a.LotNo=c.LotNo
  264. WHERE c.TransCode='" + OApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in (" + WorkPoint + ")";
  265. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  266. }
  267. /// <summary>
  268. /// 点击委外退料生成条码
  269. /// </summary>
  270. public DataTable GetSubGridJsonWeiWaiByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  271. {
  272. DataTable dt = new DataTable();
  273. //var queryParam = queryJson.ToJObject();
  274. List<DbParameter> parameter = new List<DbParameter>();
  275. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  276. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  277. from ICSOApplyNegDetail a
  278. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  279. left join (
  280. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  281. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  282. group by b.TransCode,b.TransSequence
  283. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  284. WHERE 1 =1
  285. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  286. sql += " and a.WorkPoint='" + WorkPoint + "'";
  287. return Repository().FindTableBySql(sql.ToString());
  288. }
  289. /// <summary>
  290. /// 委外退料生成条码
  291. /// </summary>
  292. /// <param name="POCode"></param>
  293. /// <param name="PORow"></param>
  294. /// <param name="keyValue"></param>
  295. /// 已改
  296. /// <returns></returns>
  297. public int SubmitFormWeiWai(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  298. {
  299. var queryParam = keyValue.ToJObject();
  300. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  301. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  302. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  303. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  304. decimal LOTQTY = minPackQty;
  305. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  306. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  307. string Pre = OApplyNegCode + Sequence;
  308. string sql = string.Empty;
  309. //string VendorLot = queryParam["VendorLot"].ToString();
  310. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  311. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  312. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  313. string sqls = string.Empty;
  314. for (int i = 0; i < createPageCount; i++)
  315. {
  316. if (i + 1 == createPageCount)
  317. {
  318. if (minPackQty * createPageCount > thisCreateQty)
  319. {
  320. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  321. }
  322. }
  323. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  324. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  325. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  326. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  327. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  328. //{
  329. sql += string.Format(@"insert into ICSInventoryLot
  330. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  331. select
  332. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'4','{3}','{4}', getdate(),'{5}'
  333. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  334. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence);
  335. sql += "\r\n";
  336. //}
  337. }
  338. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  339. return count;
  340. }
  341. public DataTable GetGridJsonChengPing(string queryJson, ref Pagination jqgridparam)
  342. {
  343. DataTable dt = new DataTable();
  344. var queryParam = queryJson.ToJObject();
  345. List<DbParameter> parameter = new List<DbParameter>();
  346. #region [SQL]
  347. string sql = @"select a.ID,a.MOCode,a.Sequence,a.RCVQuantity,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,a.Quantity,a.Amount,a.StartDate,a.DueDate,a.MOStatus,a.ExtensionID,a.MUSERName,a.MTIME ,c.LOTQTY,f.BatchCode
  348. from ICSMO a
  349. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  350. left join (
  351. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  352. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  353. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  354. )c
  355. on a.MOCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  356. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint ";
  357. sql += " WHERE 1=1";
  358. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  359. #endregion
  360. if (!string.IsNullOrWhiteSpace(queryJson))
  361. {
  362. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  363. {
  364. sql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  365. }
  366. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  367. {
  368. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  369. }
  370. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  371. {
  372. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  373. }
  374. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  375. {
  376. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  377. }
  378. }
  379. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  380. {
  381. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  382. }
  383. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  384. {
  385. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  386. }
  387. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  388. }
  389. /// <summary>
  390. /// 点击成品生成条码(成品)
  391. /// </summary>
  392. public DataTable GetSubGridJsonChengPingByCreate(string MOCode, string Sequence, string WorkPoint)
  393. {
  394. DataTable dt = new DataTable();
  395. //var queryParam = queryJson.ToJObject();
  396. List<DbParameter> parameter = new List<DbParameter>();
  397. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  398. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  399. from ICSMO a
  400. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  401. left join (
  402. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  403. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  404. group by b.TransCode,b.TransSequence
  405. ) c on a.MOCode=c.TransCode and a.Sequence=c.TransSequence
  406. WHERE 1 =1
  407. and a.MOCode='" + MOCode + "' and a.Sequence='" + Sequence + "'";
  408. sql += " and a.WorkPoint='" + WorkPoint + "'";
  409. return Repository().FindTableBySql(sql.ToString());
  410. }
  411. /// <summary>
  412. /// 成品生成条码
  413. /// </summary>
  414. /// <param name="POCode"></param>
  415. /// <param name="PORow"></param>
  416. /// <param name="keyValue"></param>
  417. /// 已改
  418. /// <returns></returns>
  419. public int SubmitFormChengPing(string MOCode, string Sequence, string keyValue, string WorkPoint)
  420. {
  421. var queryParam = keyValue.ToJObject();
  422. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  423. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  424. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  425. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  426. decimal LOTQTY = minPackQty;
  427. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  428. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  429. string Pre = MOCode + Sequence;
  430. string sql = string.Empty;
  431. //string VendorLot = queryParam["VendorLot"].ToString();
  432. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  433. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  434. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  435. string sqls = string.Empty;
  436. for (int i = 0; i < createPageCount; i++)
  437. {
  438. if (i + 1 == createPageCount)
  439. {
  440. if (minPackQty * createPageCount > thisCreateQty)
  441. {
  442. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  443. }
  444. }
  445. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  446. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  447. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  448. LotNo, MOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  449. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  450. //{
  451. sql += string.Format(@"insert into ICSInventoryLot
  452. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  453. select
  454. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
  455. from ICSMO where MOCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  456. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, MOCode, Sequence);
  457. sql += "\r\n";
  458. //}
  459. }
  460. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  461. return count;
  462. }
  463. public DataTable GetGridJsonXiaoShou(string queryJson, ref Pagination jqgridparam)
  464. {
  465. DataTable dt = new DataTable();
  466. var queryParam = queryJson.ToJObject();
  467. List<DbParameter> parameter = new List<DbParameter>();
  468. #region [SQL]
  469. 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,a.Quantity,a.Amount,a.SDNQuantity,a.Status,a.ExtensionID,a.CreatePerson,a.CreateDateTime ,c.LOTQTY,f.BatchCode
  470. from ICSSDN a
  471. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  472. left join (
  473. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  474. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  475. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  476. )c
  477. on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  478. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  479. where a.Type='2'";
  480. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  481. #endregion
  482. if (!string.IsNullOrWhiteSpace(queryJson))
  483. {
  484. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  485. {
  486. sql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  487. }
  488. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  489. {
  490. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  491. }
  492. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  493. {
  494. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  495. }
  496. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  497. {
  498. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  499. }
  500. }
  501. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  502. {
  503. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  504. }
  505. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  506. {
  507. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  508. }
  509. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  510. }
  511. /// <summary>
  512. /// 点击销售退货生成条码(销售退货)
  513. /// </summary>
  514. public DataTable GetSubGridJsonXiaoShouByCreate(string SDNCode, string Sequence, string WorkPoint)
  515. {
  516. DataTable dt = new DataTable();
  517. //var queryParam = queryJson.ToJObject();
  518. List<DbParameter> parameter = new List<DbParameter>();
  519. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  520. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  521. from ICSSDN a
  522. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  523. left join (
  524. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  525. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  526. group by b.TransCode,b.TransSequence
  527. ) c on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence
  528. WHERE 1 =1
  529. and a.Type='2' and a.SDNCode='" + SDNCode + "' and a.Sequence='" + Sequence + "'";
  530. sql += " and a.WorkPoint='" + WorkPoint + "'";
  531. return Repository().FindTableBySql(sql.ToString());
  532. }
  533. /// <summary>
  534. /// 销售退货生成条码
  535. /// </summary>
  536. /// <param name="POCode"></param>
  537. /// <param name="PORow"></param>
  538. /// <param name="keyValue"></param>
  539. /// 已改
  540. /// <returns></returns>
  541. public int SubmitFormXiaoShou(string SDNCode, string Sequence, string keyValue, string WorkPoint)
  542. {
  543. var queryParam = keyValue.ToJObject();
  544. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  545. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  546. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  547. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  548. decimal LOTQTY = minPackQty;
  549. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  550. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  551. string Pre = SDNCode + Sequence;
  552. string sql = string.Empty;
  553. //string VendorLot = queryParam["VendorLot"].ToString();
  554. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  555. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  556. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  557. string sqls = string.Empty;
  558. for (int i = 0; i < createPageCount; i++)
  559. {
  560. if (i + 1 == createPageCount)
  561. {
  562. if (minPackQty * createPageCount > thisCreateQty)
  563. {
  564. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  565. }
  566. }
  567. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  568. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  569. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}')",
  570. LotNo, SDNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  571. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  572. //{
  573. sql += string.Format(@"
  574. insert into ICSInventoryLot
  575. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  576. select
  577. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
  578. from ICSSDN where Type='2' and SDNCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  579. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, SDNCode, Sequence);
  580. sql += "\r\n";
  581. //}
  582. }
  583. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  584. return count;
  585. }
  586. public DataTable GetGridJsonQiTa(string queryJson, ref Pagination jqgridparam)
  587. {
  588. DataTable dt = new DataTable();
  589. var queryParam = queryJson.ToJObject();
  590. List<DbParameter> parameter = new List<DbParameter>();
  591. #region [SQL]
  592. string sql = @" select a.ID,a.InCode,a.Sequence,a.WHCode,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,a.Quantity,a.Amount,a.InQuantity,a.CreatePerson,a.CreateDateTime,c.LOTQTY,f.BatchCode
  593. from ICSOtherIn a
  594. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  595. left join (
  596. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  597. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  598. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  599. )c
  600. on a.InCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  601. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  602. where a.Status='1'";
  603. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  604. #endregion
  605. if (!string.IsNullOrWhiteSpace(queryJson))
  606. {
  607. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  608. {
  609. sql += " and a.InCode like '%" + queryParam["POCode"].ToString() + "%' ";
  610. }
  611. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  612. {
  613. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  614. }
  615. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  616. {
  617. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  618. }
  619. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  620. {
  621. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  622. }
  623. }
  624. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  625. {
  626. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  627. }
  628. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  629. {
  630. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  631. }
  632. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  633. }
  634. /// <summary>
  635. /// 点击销售退货生成条码(其他入库)
  636. /// </summary>
  637. public DataTable GetSubGridJsonQiTaByCreate(string InCode, string Sequence, string WorkPoint)
  638. {
  639. DataTable dt = new DataTable();
  640. //var queryParam = queryJson.ToJObject();
  641. List<DbParameter> parameter = new List<DbParameter>();
  642. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  643. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  644. from ICSOtherIn a
  645. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  646. left join (
  647. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  648. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  649. group by b.TransCode,b.TransSequence
  650. ) c on a.InCode=c.TransCode and a.Sequence=c.TransSequence
  651. WHERE 1 =1
  652. and a.InCode='" + InCode + "' and a.Sequence='" + Sequence + "'";
  653. sql += " and a.WorkPoint='" + WorkPoint + "'";
  654. return Repository().FindTableBySql(sql.ToString());
  655. }
  656. /// <summary>
  657. /// 其他入库生成条码
  658. /// </summary>
  659. /// <param name="POCode"></param>
  660. /// <param name="PORow"></param>
  661. /// <param name="keyValue"></param>
  662. /// 已改
  663. /// <returns></returns>
  664. public int SubmitFormQiTa(string InCode, string Sequence, string keyValue, string WorkPoint)
  665. {
  666. var queryParam = keyValue.ToJObject();
  667. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  668. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  669. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  670. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  671. decimal LOTQTY = minPackQty;
  672. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  673. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  674. string Pre = InCode + Sequence;
  675. string sql = string.Empty;
  676. //string VendorLot = queryParam["VendorLot"].ToString();
  677. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  678. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  679. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  680. string sqls = string.Empty;
  681. for (int i = 0; i < createPageCount; i++)
  682. {
  683. if (i + 1 == createPageCount)
  684. {
  685. if (minPackQty * createPageCount > thisCreateQty)
  686. {
  687. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  688. }
  689. }
  690. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  691. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  692. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  693. LotNo, InCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  694. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  695. //{
  696. sql += string.Format(@"
  697. insert into ICSInventoryLot
  698. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  699. select
  700. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
  701. from ICSOtherIn where InCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  702. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, InCode, Sequence);
  703. sql += "\r\n";
  704. //}
  705. }
  706. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  707. return count;
  708. }
  709. //归还
  710. public DataTable GetGridJsonGuiHuan(string queryJson, ref Pagination jqgridparam)
  711. {
  712. DataTable dt = new DataTable();
  713. var queryParam = queryJson.ToJObject();
  714. List<DbParameter> parameter = new List<DbParameter>();
  715. #region [SQL]
  716. string sql = @"select a.ID,a.ReturnCode,a.Sequence,a.WHCode,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,a.Quantity,a.Amount,a.ReturnQuantity,a.CreatePerson,a.CreateDateTime,c.LOTQTY ,f.BatchCode from ICSReturn a
  717. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  718. left join (
  719. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  720. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  721. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  722. ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  723. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  724. where a.Status='2'";
  725. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  726. #endregion
  727. if (!string.IsNullOrWhiteSpace(queryJson))
  728. {
  729. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  730. {
  731. sql += " and a.ReturnCode like '%" + queryParam["POCode"].ToString() + "%' ";
  732. }
  733. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  734. {
  735. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  736. }
  737. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  738. {
  739. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  740. }
  741. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  742. {
  743. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  744. }
  745. }
  746. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  747. {
  748. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  749. }
  750. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  751. {
  752. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  753. }
  754. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  755. }
  756. //审核到货单(采购订单需与审核到货单一起同步)
  757. public DataTable GetGridJsonSHDH(string queryJson, ref Pagination jqgridparam)
  758. {
  759. DataTable dt = new DataTable();
  760. var queryParam = queryJson.ToJObject();
  761. List<DbParameter> parameter = new List<DbParameter>();
  762. #region [SQL]
  763. 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,a.Quantity,a.Amount,a.RCVQuantity,a.UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,c.LOTQTY ,f.BatchCode
  764. from ICSDeliveryNotice a
  765. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  766. left join (
  767. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  768. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  769. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  770. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  771. inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  772. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  773. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  774. where a.Status='2' and a.ASNCode is null
  775. ";
  776. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  777. #endregion
  778. if (!string.IsNullOrWhiteSpace(queryJson))
  779. {
  780. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  781. {
  782. sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  783. }
  784. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  785. {
  786. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  787. }
  788. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  789. {
  790. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  791. }
  792. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  793. {
  794. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  795. }
  796. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  797. {
  798. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  799. }
  800. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  801. {
  802. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  803. }
  804. }
  805. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  806. {
  807. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  808. }
  809. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  810. {
  811. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  812. }
  813. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  814. }
  815. //审核委外到货单
  816. public DataTable GetGridJsonWWSHDH(string queryJson, ref Pagination jqgridparam)
  817. {
  818. DataTable dt = new DataTable();
  819. var queryParam = queryJson.ToJObject();
  820. List<DbParameter> parameter = new List<DbParameter>();
  821. #region [SQL]
  822. string sql = @"select a.ID, d.OOCode,d.Sequence as OOSequence,a.ODNCode,a.Sequence,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvName,b.InvStd,b.InvDesc,b.InvUnit,a.Quantity,a.Amount,a.RCVQuantity,a.UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,c.LOTQTY ,f.BatchCode
  823. from ICSODeliveryNotice a
  824. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  825. left join (
  826. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  827. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  828. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  829. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  830. inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  831. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  832. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  833. where a.ODNType='1' and a.Status='2' and a.OASNCode is null";
  834. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  835. #endregion
  836. if (!string.IsNullOrWhiteSpace(queryJson))
  837. {
  838. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  839. {
  840. sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  841. }
  842. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  843. {
  844. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  845. }
  846. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  847. {
  848. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  849. }
  850. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  851. {
  852. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  853. }
  854. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  855. {
  856. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  857. }
  858. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  859. {
  860. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  861. }
  862. }
  863. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  864. {
  865. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  866. }
  867. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  868. {
  869. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  870. }
  871. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  872. }
  873. //开立得成品入库单
  874. public DataTable GetGridJsonKLCPRK(string queryJson, ref Pagination jqgridparam)
  875. {
  876. DataTable dt = new DataTable();
  877. var queryParam = queryJson.ToJObject();
  878. List<DbParameter> parameter = new List<DbParameter>();
  879. #region [SQL]
  880. string sql = @"
  881. select a.ID,a.RCVCode,a.Sequence,a.WHCode,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,a.Quantity,a.Amount,a.RCVQuantity,a.CreatePerson,a.CreateDateTime,c.LOTQTY,f.BatchCode
  882. from ICSManufactureReceive a
  883. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  884. left join (
  885. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  886. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  887. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  888. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  889. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  890. where a.Status='1' and a.Type='1'";
  891. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  892. #endregion
  893. if (!string.IsNullOrWhiteSpace(queryJson))
  894. {
  895. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  896. {
  897. sql += " and a.RCVCode like '%" + queryParam["POCode"].ToString() + "%' ";
  898. }
  899. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  900. {
  901. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  902. }
  903. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  904. {
  905. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  906. }
  907. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  908. {
  909. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  910. }
  911. }
  912. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  913. {
  914. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  915. }
  916. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  917. {
  918. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  919. }
  920. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  921. }
  922. /// <summary>
  923. /// 点击审核委外到货单生成条码(审核委外到货单)
  924. /// </summary>
  925. public DataTable GetSubGridJsonWWSHDHByCreate(string ODNCode, string Sequence, string WorkPoint)
  926. {
  927. DataTable dt = new DataTable();
  928. //var queryParam = queryJson.ToJObject();
  929. List<DbParameter> parameter = new List<DbParameter>();
  930. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  931. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  932. from ICSODeliveryNotice a
  933. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  934. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  935. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  936. group by b.TransCode,b.TransSequence
  937. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
  938. WHERE 1 =1
  939. and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
  940. sql += " and a.WorkPoint='" + WorkPoint + "'";
  941. return Repository().FindTableBySql(sql.ToString());
  942. }
  943. /// <summary>
  944. /// 点击开立成品入库生成条码(开立成品入库单)
  945. /// </summary>
  946. public DataTable GetSubGridJsonKLCPRKByCreate(string RCVCode, string Sequence, string WorkPoint)
  947. {
  948. DataTable dt = new DataTable();
  949. //var queryParam = queryJson.ToJObject();
  950. List<DbParameter> parameter = new List<DbParameter>();
  951. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  952. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  953. from ICSManufactureReceive a
  954. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  955. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  956. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  957. group by b.TransCode,b.TransSequence
  958. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence
  959. WHERE 1 =1
  960. and a.RCVCode='" + RCVCode + "' and a.Sequence='" + Sequence + "'";
  961. sql += " and a.WorkPoint='" + WorkPoint + "'";
  962. return Repository().FindTableBySql(sql.ToString());
  963. }
  964. /// <summary>
  965. /// 点击审核到货单生成条码(审核到货单)
  966. /// </summary>
  967. public DataTable GetSubGridJsonSHDHByCreate(string DNCode, string Sequence, string WorkPoint)
  968. {
  969. DataTable dt = new DataTable();
  970. //var queryParam = queryJson.ToJObject();
  971. List<DbParameter> parameter = new List<DbParameter>();
  972. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  973. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  974. from ICSDeliveryNotice a
  975. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  976. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  977. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  978. group by b.TransCode,b.TransSequence
  979. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
  980. WHERE 1 =1
  981. and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
  982. sql += " and a.WorkPoint='" + WorkPoint + "'";
  983. return Repository().FindTableBySql(sql.ToString());
  984. }
  985. /// <summary>
  986. /// 点击归还生成条码(归还)
  987. /// </summary>
  988. public DataTable GetSubGridJsonGuiHuanByCreate(string ReturnCode, string Sequence, string WorkPoint)
  989. {
  990. DataTable dt = new DataTable();
  991. //var queryParam = queryJson.ToJObject();
  992. List<DbParameter> parameter = new List<DbParameter>();
  993. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  994. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  995. from ICSReturn a
  996. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  997. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  998. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  999. group by b.TransCode,b.TransSequence
  1000. ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence
  1001. WHERE 1 =1
  1002. and a.ReturnCode='" + ReturnCode + "' and a.Sequence='" + Sequence + "'";
  1003. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1004. return Repository().FindTableBySql(sql.ToString());
  1005. }
  1006. /// <summary>
  1007. /// 归还单生成条码
  1008. /// </summary>
  1009. /// <param name="POCode"></param>
  1010. /// <param name="PORow"></param>
  1011. /// <param name="keyValue"></param>
  1012. /// 已改
  1013. /// <returns></returns>
  1014. public int SubmitFormGuiHuan(string ReturnCode, string Sequence, string keyValue, string WorkPoint)
  1015. {
  1016. var queryParam = keyValue.ToJObject();
  1017. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1018. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1019. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1020. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1021. decimal LOTQTY = minPackQty;
  1022. string Pre = ReturnCode + Sequence;
  1023. string sql = string.Empty;
  1024. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1025. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1026. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1027. string sqls = string.Empty;
  1028. for (int i = 0; i < createPageCount; i++)
  1029. {
  1030. if (i + 1 == createPageCount)
  1031. {
  1032. if (minPackQty * createPageCount > thisCreateQty)
  1033. {
  1034. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1035. }
  1036. }
  1037. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1038. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1039. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1040. LotNo, ReturnCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1041. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1042. //{
  1043. sql += string.Format(@"
  1044. insert into ICSInventoryLot
  1045. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  1046. select
  1047. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
  1048. from ICSReturn where ReturnCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1049. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ReturnCode, Sequence);
  1050. sql += "\r\n";
  1051. //}
  1052. }
  1053. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1054. return count;
  1055. }
  1056. /// <summary>
  1057. /// 审核到货单生成条码
  1058. /// </summary>
  1059. /// <param name="POCode"></param>
  1060. /// <param name="PORow"></param>
  1061. /// <param name="keyValue"></param>
  1062. /// 已改
  1063. /// <returns></returns>
  1064. public int SubmitFormSHDH(string DNCode, string Sequence, string keyValue, string WorkPoint)
  1065. {
  1066. var queryParam = keyValue.ToJObject();
  1067. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1068. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1069. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1070. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1071. decimal LOTQTY = minPackQty;
  1072. string Pre = DNCode + Sequence;
  1073. string sql = string.Empty;
  1074. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1075. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1076. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1077. string sqls = string.Empty;
  1078. for (int i = 0; i < createPageCount; i++)
  1079. {
  1080. if (i + 1 == createPageCount)
  1081. {
  1082. if (minPackQty * createPageCount > thisCreateQty)
  1083. {
  1084. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1085. }
  1086. }
  1087. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1088. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1089. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1090. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1091. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1092. //{
  1093. sql += string.Format(@"
  1094. insert into ICSInventoryLot
  1095. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  1096. select
  1097. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
  1098. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1099. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence);
  1100. sql += "\r\n";
  1101. //}
  1102. }
  1103. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1104. return count;
  1105. }
  1106. /// <summary>
  1107. /// 审核委外到货单生成条码
  1108. /// </summary>
  1109. /// <param name="POCode"></param>
  1110. /// <param name="PORow"></param>
  1111. /// <param name="keyValue"></param>
  1112. /// 已改
  1113. /// <returns></returns>
  1114. public int SubmitFormWWSHDH(string ODNCode, string Sequence, string keyValue, string WorkPoint)
  1115. {
  1116. var queryParam = keyValue.ToJObject();
  1117. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1118. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1119. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1120. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1121. decimal LOTQTY = minPackQty;
  1122. string Pre = ODNCode + Sequence;
  1123. string sql = string.Empty;
  1124. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1125. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1126. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1127. string sqls = string.Empty;
  1128. for (int i = 0; i < createPageCount; i++)
  1129. {
  1130. if (i + 1 == createPageCount)
  1131. {
  1132. if (minPackQty * createPageCount > thisCreateQty)
  1133. {
  1134. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1135. }
  1136. }
  1137. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1138. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1139. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1140. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1141. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1142. //{
  1143. sql += string.Format(@"
  1144. insert into ICSInventoryLot
  1145. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  1146. select
  1147. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
  1148. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1149. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence);
  1150. sql += "\r\n";
  1151. //}
  1152. }
  1153. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1154. return count;
  1155. }
  1156. /// <summary>
  1157. /// 开立成品入库单
  1158. /// </summary>
  1159. /// <param name="POCode"></param>
  1160. /// <param name="PORow"></param>
  1161. /// <param name="keyValue"></param>
  1162. /// 已改
  1163. /// <returns></returns>
  1164. public int SubmitFormKLCPRK(string RCVCode, string Sequence, string keyValue, string WorkPoint)
  1165. {
  1166. var queryParam = keyValue.ToJObject();
  1167. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1168. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1169. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1170. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1171. decimal LOTQTY = minPackQty;
  1172. string Pre = RCVCode + Sequence;
  1173. string sql = string.Empty;
  1174. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1175. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1176. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1177. string sqls = string.Empty;
  1178. for (int i = 0; i < createPageCount; i++)
  1179. {
  1180. if (i + 1 == createPageCount)
  1181. {
  1182. if (minPackQty * createPageCount > thisCreateQty)
  1183. {
  1184. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1185. }
  1186. }
  1187. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1188. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1189. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1190. LotNo, RCVCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1191. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1192. //{
  1193. sql += string.Format(@"
  1194. insert into ICSInventoryLot
  1195. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  1196. select
  1197. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
  1198. from ICSManufactureReceive where RCVCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1199. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, RCVCode, Sequence);
  1200. sql += "\r\n";
  1201. //}
  1202. }
  1203. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1204. return count;
  1205. }
  1206. }
  1207. }