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

1842 lines
96 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
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 ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  34. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  35. left join (
  36. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  37. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  38. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  39. )c
  40. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  41. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  42. where d.Type='1'";
  43. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  44. #endregion
  45. if (!string.IsNullOrWhiteSpace(queryJson))
  46. {
  47. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  48. {
  49. sql += " and a.POCode like '%" + queryParam["POCode"].ToString() + "%' ";
  50. }
  51. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  52. {
  53. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  54. }
  55. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  56. {
  57. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  58. }
  59. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  60. {
  61. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  62. }
  63. }
  64. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  65. {
  66. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  67. }
  68. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  69. {
  70. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  71. }
  72. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  73. }
  74. public DataTable GetSubGridJson(string ApplyNegCode, string Sequence, ref Pagination jqgridparam)
  75. {
  76. DataTable dt = new DataTable();
  77. //var queryParam = queryJson.ToJObject();
  78. List<DbParameter> parameter = new List<DbParameter>();
  79. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  80. string sql = @" select c.TransCode,c.TransSequence ,a.ID,a.LotNo,a.Quantity,a.MUSERName,a.MTIME from ICSInventoryLot a
  81. left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo
  82. group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
  83. left join ICSInventoryLotDetail c on a.LotNo=c.LotNo
  84. WHERE c.TransCode='" + ApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in ('" + WorkPoint + "')";
  85. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  86. }
  87. /// <summary>
  88. /// 点击生成条码
  89. /// </summary>
  90. public DataTable GetSubGridJsonByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  91. {
  92. DataTable dt = new DataTable();
  93. //var queryParam = queryJson.ToJObject();
  94. List<DbParameter> parameter = new List<DbParameter>();
  95. string sql = @" select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  96. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  97. from ICSMOApplyNegDetail a
  98. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  99. left join (
  100. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  101. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  102. group by b.TransCode,b.TransSequence
  103. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  104. WHERE 1 =1
  105. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  106. sql += " and a.WorkPoint='" + WorkPoint + "'";
  107. return Repository().FindTableBySql(sql.ToString());
  108. }
  109. public DataTable GetVendorLotNo(string VenCode, string WorkPoint)
  110. {
  111. DataTable dt = new DataTable();
  112. //var queryParam = queryJson.ToJObject();
  113. List<DbParameter> parameter = new List<DbParameter>();
  114. string dtPre = DateTime.Now.ToString("yyyyMMdd");
  115. string sql = @"EXEC Addins_GetSerialCode '" + WorkPoint + "','ICSITEMLotNo','VendorLotNo','" + VenCode + dtPre + "',2";
  116. return Repository().FindTableBySql(sql.ToString());
  117. }
  118. /// <summary>
  119. /// 生产退料生成条码
  120. /// </summary>
  121. /// <param name="POCode"></param>
  122. /// <param name="PORow"></param>
  123. /// <param name="keyValue"></param>
  124. /// 已改
  125. /// <returns></returns>
  126. public int CreateItemLotNo(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  127. {
  128. var queryParam = keyValue.ToJObject();
  129. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  130. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  131. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  132. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  133. decimal LOTQTY = minPackQty;
  134. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  135. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  136. string Pre = ApplyNegCode + Sequence;
  137. string sql = string.Empty;
  138. //string VendorLot = queryParam["VendorLot"].ToString();
  139. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  140. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  141. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  142. string sqls = string.Empty;
  143. for (int i = 0; i < createPageCount; i++)
  144. {
  145. if (i + 1 == createPageCount)
  146. {
  147. if (minPackQty * createPageCount > thisCreateQty)
  148. {
  149. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  150. }
  151. }
  152. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  153. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  154. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  155. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  156. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  157. //{
  158. sql += string.Format(@"insert into ICSInventoryLot
  159. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  160. select
  161. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'3','{3}','{4}', getdate(),'{5}'
  162. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  163. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence);
  164. sql += "\r\n";
  165. //}
  166. }
  167. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  168. return count;
  169. }
  170. public string GetSerialCode(string workPointCode, string tbName, string colName, string Pre, int numLen)
  171. {
  172. string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}";
  173. sql = string.Format(sql, new object[] { workPointCode, tbName, colName, Pre, numLen });
  174. return DbHelper.ExecuteScalar(CommandType.Text, sql).ToString();
  175. }
  176. /// <summary>
  177. /// 删除条码
  178. /// </summary>
  179. /// <param name="keyValue"></param>
  180. /// <returns></returns>
  181. public string DeleteItemLot(string keyValue)
  182. {
  183. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  184. string msg = string.Empty;
  185. string sql = string.Format(@"SELECT * FROM dbo.ICSInspection
  186. WHERE LotNo IN (SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  187. DataTable dtASN = SqlHelper.GetDataTableBySql(sql);
  188. if (dtASN != null && dtASN.Rows.Count > 0)
  189. {
  190. msg = "所选条码已生成检验单,无法删除!";
  191. }
  192. sql = string.Format(@"SELECT * FROM dbo.ICSWareHouseLotInfo WHERE LotNO IN
  193. (SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  194. DataTable dtCarton = SqlHelper.GetDataTableBySql(sql);
  195. if (dtCarton != null && dtCarton.Rows.Count > 0)
  196. {
  197. msg += "所选条码已入库,无法删除!";
  198. }
  199. if (string.IsNullOrEmpty(msg))
  200. {
  201. 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);
  202. sqls += string.Format("DELETE FROM dbo.ICSInventoryLot WHERE ID IN ({0}) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  203. SqlHelper.CmdExecuteNonQueryLi(sqls);
  204. }
  205. return msg;
  206. }
  207. public DataTable GetGridJsonWeiWai(string queryJson, ref Pagination jqgridparam)
  208. {
  209. DataTable dt = new DataTable();
  210. var queryParam = queryJson.ToJObject();
  211. List<DbParameter> parameter = new List<DbParameter>();
  212. #region [SQL]
  213. 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
  214. from ICSOApplyNegDetail a
  215. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  216. left join (
  217. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  218. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  219. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  220. )c
  221. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  222. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint ";
  223. sql += " WHERE 1=1";
  224. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  225. #endregion
  226. if (!string.IsNullOrWhiteSpace(queryJson))
  227. {
  228. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  229. {
  230. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  231. }
  232. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  233. {
  234. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  235. }
  236. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  237. {
  238. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  239. }
  240. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  241. {
  242. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  243. }
  244. }
  245. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  246. {
  247. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  248. }
  249. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  250. {
  251. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  252. }
  253. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  254. }
  255. public DataTable GetSubGridJsonWeiWai(string OApplyNegCode, string Sequence, ref Pagination jqgridparam)
  256. {
  257. DataTable dt = new DataTable();
  258. //var queryParam = queryJson.ToJObject();
  259. List<DbParameter> parameter = new List<DbParameter>();
  260. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  261. string sql = @" select c.TransCode,c.TransSequence ,a.ID,a.LotNo,a.Quantity from ICSInventoryLot a
  262. left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo
  263. group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
  264. left join ICSInventoryLotDetail c on a.LotNo=c.LotNo
  265. WHERE c.TransCode='" + OApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in (" + WorkPoint + ")";
  266. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  267. }
  268. /// <summary>
  269. /// 点击委外退料生成条码
  270. /// </summary>
  271. public DataTable GetSubGridJsonWeiWaiByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  272. {
  273. DataTable dt = new DataTable();
  274. //var queryParam = queryJson.ToJObject();
  275. List<DbParameter> parameter = new List<DbParameter>();
  276. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  277. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  278. from ICSOApplyNegDetail a
  279. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  280. left join (
  281. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  282. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  283. group by b.TransCode,b.TransSequence
  284. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  285. WHERE 1 =1
  286. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  287. sql += " and a.WorkPoint='" + WorkPoint + "'";
  288. return Repository().FindTableBySql(sql.ToString());
  289. }
  290. /// <summary>
  291. /// 委外退料生成条码
  292. /// </summary>
  293. /// <param name="POCode"></param>
  294. /// <param name="PORow"></param>
  295. /// <param name="keyValue"></param>
  296. /// 已改
  297. /// <returns></returns>
  298. public int SubmitFormWeiWai(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  299. {
  300. var queryParam = keyValue.ToJObject();
  301. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  302. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  303. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  304. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  305. decimal LOTQTY = minPackQty;
  306. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  307. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  308. string Pre = OApplyNegCode + Sequence;
  309. string sql = string.Empty;
  310. //string VendorLot = queryParam["VendorLot"].ToString();
  311. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  312. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  313. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  314. string sqls = string.Empty;
  315. for (int i = 0; i < createPageCount; i++)
  316. {
  317. if (i + 1 == createPageCount)
  318. {
  319. if (minPackQty * createPageCount > thisCreateQty)
  320. {
  321. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  322. }
  323. }
  324. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  325. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  326. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  327. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  328. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  329. //{
  330. sql += string.Format(@"insert into ICSInventoryLot
  331. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  332. select
  333. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'4','{3}','{4}', getdate(),'{5}'
  334. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  335. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence);
  336. sql += "\r\n";
  337. //}
  338. }
  339. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  340. return count;
  341. }
  342. public DataTable GetGridJsonChengPing(string queryJson, ref Pagination jqgridparam)
  343. {
  344. DataTable dt = new DataTable();
  345. var queryParam = queryJson.ToJObject();
  346. List<DbParameter> parameter = new List<DbParameter>();
  347. #region [SQL]
  348. 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
  349. from ICSMO a
  350. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  351. left join (
  352. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  353. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  354. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  355. )c
  356. on a.MOCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  357. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint ";
  358. sql += " WHERE 1=1";
  359. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  360. #endregion
  361. if (!string.IsNullOrWhiteSpace(queryJson))
  362. {
  363. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  364. {
  365. sql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  366. }
  367. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  368. {
  369. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  370. }
  371. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  372. {
  373. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  374. }
  375. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  376. {
  377. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  378. }
  379. }
  380. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  381. {
  382. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  383. }
  384. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  385. {
  386. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  387. }
  388. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  389. }
  390. /// <summary>
  391. /// 点击成品生成条码(成品)
  392. /// </summary>
  393. public DataTable GetSubGridJsonChengPingByCreate(string MOCode, string Sequence, string WorkPoint)
  394. {
  395. DataTable dt = new DataTable();
  396. //var queryParam = queryJson.ToJObject();
  397. List<DbParameter> parameter = new List<DbParameter>();
  398. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  399. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  400. from ICSMO a
  401. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  402. left join (
  403. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  404. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  405. group by b.TransCode,b.TransSequence
  406. ) c on a.MOCode=c.TransCode and a.Sequence=c.TransSequence
  407. WHERE 1 =1
  408. and a.MOCode='" + MOCode + "' and a.Sequence='" + Sequence + "'";
  409. sql += " and a.WorkPoint='" + WorkPoint + "'";
  410. return Repository().FindTableBySql(sql.ToString());
  411. }
  412. /// <summary>
  413. /// 成品生成条码
  414. /// </summary>
  415. /// <param name="POCode"></param>
  416. /// <param name="PORow"></param>
  417. /// <param name="keyValue"></param>
  418. /// 已改
  419. /// <returns></returns>
  420. public int SubmitFormChengPing(string MOCode, string Sequence, string keyValue, string WorkPoint)
  421. {
  422. var queryParam = keyValue.ToJObject();
  423. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  424. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  425. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  426. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  427. decimal LOTQTY = minPackQty;
  428. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  429. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  430. string Pre = MOCode + Sequence;
  431. string sql = string.Empty;
  432. //string VendorLot = queryParam["VendorLot"].ToString();
  433. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  434. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  435. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  436. string sqls = string.Empty;
  437. for (int i = 0; i < createPageCount; i++)
  438. {
  439. if (i + 1 == createPageCount)
  440. {
  441. if (minPackQty * createPageCount > thisCreateQty)
  442. {
  443. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  444. }
  445. }
  446. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  447. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  448. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  449. LotNo, MOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  450. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  451. //{
  452. sql += string.Format(@"insert into ICSInventoryLot
  453. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  454. select
  455. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
  456. from ICSMO where MOCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  457. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, MOCode, Sequence);
  458. sql += "\r\n";
  459. //}
  460. }
  461. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  462. return count;
  463. }
  464. public DataTable GetGridJsonXiaoShou(string queryJson, ref Pagination jqgridparam)
  465. {
  466. DataTable dt = new DataTable();
  467. var queryParam = queryJson.ToJObject();
  468. List<DbParameter> parameter = new List<DbParameter>();
  469. #region [SQL]
  470. 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
  471. from ICSSDN a
  472. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  473. left join (
  474. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  475. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  476. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  477. )c
  478. on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  479. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  480. where a.Type='2'";
  481. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  482. #endregion
  483. if (!string.IsNullOrWhiteSpace(queryJson))
  484. {
  485. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  486. {
  487. sql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  488. }
  489. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  490. {
  491. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  492. }
  493. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  494. {
  495. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  496. }
  497. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  498. {
  499. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  500. }
  501. }
  502. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  503. {
  504. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  505. }
  506. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  507. {
  508. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  509. }
  510. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  511. }
  512. /// <summary>
  513. /// 点击销售退货生成条码(销售退货)
  514. /// </summary>
  515. public DataTable GetSubGridJsonXiaoShouByCreate(string SDNCode, string Sequence, string WorkPoint)
  516. {
  517. DataTable dt = new DataTable();
  518. //var queryParam = queryJson.ToJObject();
  519. List<DbParameter> parameter = new List<DbParameter>();
  520. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  521. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  522. from ICSSDN a
  523. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  524. left join (
  525. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  526. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  527. group by b.TransCode,b.TransSequence
  528. ) c on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence
  529. WHERE 1 =1
  530. and a.Type='2' and a.SDNCode='" + SDNCode + "' and a.Sequence='" + Sequence + "'";
  531. sql += " and a.WorkPoint='" + WorkPoint + "'";
  532. return Repository().FindTableBySql(sql.ToString());
  533. }
  534. /// <summary>
  535. /// 销售退货生成条码
  536. /// </summary>
  537. /// <param name="POCode"></param>
  538. /// <param name="PORow"></param>
  539. /// <param name="keyValue"></param>
  540. /// 已改
  541. /// <returns></returns>
  542. public int SubmitFormXiaoShou(string SDNCode, string Sequence, string keyValue, string WorkPoint)
  543. {
  544. var queryParam = keyValue.ToJObject();
  545. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  546. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  547. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  548. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  549. decimal LOTQTY = minPackQty;
  550. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  551. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  552. string Pre = SDNCode + Sequence;
  553. string sql = string.Empty;
  554. //string VendorLot = queryParam["VendorLot"].ToString();
  555. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  556. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  557. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  558. string sqls = string.Empty;
  559. for (int i = 0; i < createPageCount; i++)
  560. {
  561. if (i + 1 == createPageCount)
  562. {
  563. if (minPackQty * createPageCount > thisCreateQty)
  564. {
  565. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  566. }
  567. }
  568. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  569. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  570. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}')",
  571. LotNo, SDNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  572. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  573. //{
  574. sql += string.Format(@"
  575. insert into ICSInventoryLot
  576. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  577. select
  578. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
  579. from ICSSDN where Type='2' and SDNCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  580. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, SDNCode, Sequence);
  581. sql += "\r\n";
  582. //}
  583. }
  584. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  585. return count;
  586. }
  587. public DataTable GetGridJsonQiTa(string queryJson, ref Pagination jqgridparam)
  588. {
  589. DataTable dt = new DataTable();
  590. var queryParam = queryJson.ToJObject();
  591. List<DbParameter> parameter = new List<DbParameter>();
  592. #region [SQL]
  593. 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
  594. from ICSOtherIn a
  595. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  596. left join (
  597. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  598. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  599. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  600. )c
  601. on a.InCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  602. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  603. where a.Status='1'";
  604. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  605. #endregion
  606. if (!string.IsNullOrWhiteSpace(queryJson))
  607. {
  608. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  609. {
  610. sql += " and a.InCode like '%" + queryParam["POCode"].ToString() + "%' ";
  611. }
  612. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  613. {
  614. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  615. }
  616. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  617. {
  618. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  619. }
  620. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  621. {
  622. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  623. }
  624. }
  625. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  626. {
  627. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  628. }
  629. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  630. {
  631. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  632. }
  633. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  634. }
  635. /// <summary>
  636. /// 点击销售退货生成条码(其他入库)
  637. /// </summary>
  638. public DataTable GetSubGridJsonQiTaByCreate(string InCode, string Sequence, string WorkPoint)
  639. {
  640. DataTable dt = new DataTable();
  641. //var queryParam = queryJson.ToJObject();
  642. List<DbParameter> parameter = new List<DbParameter>();
  643. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  644. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  645. from ICSOtherIn a
  646. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  647. left join (
  648. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  649. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  650. group by b.TransCode,b.TransSequence
  651. ) c on a.InCode=c.TransCode and a.Sequence=c.TransSequence
  652. WHERE 1 =1
  653. and a.InCode='" + InCode + "' and a.Sequence='" + Sequence + "'";
  654. sql += " and a.WorkPoint='" + WorkPoint + "'";
  655. return Repository().FindTableBySql(sql.ToString());
  656. }
  657. /// <summary>
  658. /// 其他入库生成条码
  659. /// </summary>
  660. /// <param name="POCode"></param>
  661. /// <param name="PORow"></param>
  662. /// <param name="keyValue"></param>
  663. /// 已改
  664. /// <returns></returns>
  665. public int SubmitFormQiTa(string InCode, string Sequence, string keyValue, string WorkPoint)
  666. {
  667. var queryParam = keyValue.ToJObject();
  668. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  669. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  670. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  671. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  672. decimal LOTQTY = minPackQty;
  673. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  674. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  675. string Pre = InCode + Sequence;
  676. string sql = string.Empty;
  677. //string VendorLot = queryParam["VendorLot"].ToString();
  678. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  679. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  680. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  681. string sqls = string.Empty;
  682. for (int i = 0; i < createPageCount; i++)
  683. {
  684. if (i + 1 == createPageCount)
  685. {
  686. if (minPackQty * createPageCount > thisCreateQty)
  687. {
  688. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  689. }
  690. }
  691. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  692. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  693. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  694. LotNo, InCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  695. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  696. //{
  697. sql += string.Format(@"
  698. insert into ICSInventoryLot
  699. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  700. select
  701. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
  702. from ICSOtherIn where InCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  703. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, InCode, Sequence);
  704. sql += "\r\n";
  705. //}
  706. }
  707. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  708. return count;
  709. }
  710. //归还
  711. public DataTable GetGridJsonGuiHuan(string queryJson, ref Pagination jqgridparam)
  712. {
  713. DataTable dt = new DataTable();
  714. var queryParam = queryJson.ToJObject();
  715. List<DbParameter> parameter = new List<DbParameter>();
  716. #region [SQL]
  717. 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
  718. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  719. left join (
  720. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  721. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  722. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  723. ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  724. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  725. where a.Status='2'";
  726. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  727. #endregion
  728. if (!string.IsNullOrWhiteSpace(queryJson))
  729. {
  730. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  731. {
  732. sql += " and a.ReturnCode like '%" + queryParam["POCode"].ToString() + "%' ";
  733. }
  734. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  735. {
  736. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  737. }
  738. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  739. {
  740. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  741. }
  742. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  743. {
  744. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  745. }
  746. }
  747. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  748. {
  749. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  750. }
  751. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  752. {
  753. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  754. }
  755. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  756. }
  757. //审核到货单(采购订单需与审核到货单一起同步)
  758. public DataTable GetGridJsonSHDH(string queryJson, ref Pagination jqgridparam)
  759. {
  760. DataTable dt = new DataTable();
  761. var queryParam = queryJson.ToJObject();
  762. List<DbParameter> parameter = new List<DbParameter>();
  763. #region [SQL]
  764. 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
  765. from ICSDeliveryNotice a
  766. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  767. left join (
  768. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  769. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  770. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  771. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  772. inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  773. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  774. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  775. where a.DNType='1' and a.Status='2' and a.ASNCode is null
  776. ";
  777. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  778. #endregion
  779. if (!string.IsNullOrWhiteSpace(queryJson))
  780. {
  781. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  782. {
  783. sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  784. }
  785. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  786. {
  787. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  788. }
  789. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  790. {
  791. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  792. }
  793. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  794. {
  795. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  796. }
  797. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  798. {
  799. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  800. }
  801. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  802. {
  803. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  804. }
  805. }
  806. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  807. {
  808. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  809. }
  810. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  811. {
  812. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  813. }
  814. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  815. }
  816. //审核委外到货单
  817. public DataTable GetGridJsonWWSHDH(string queryJson, ref Pagination jqgridparam)
  818. {
  819. DataTable dt = new DataTable();
  820. var queryParam = queryJson.ToJObject();
  821. List<DbParameter> parameter = new List<DbParameter>();
  822. #region [SQL]
  823. 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
  824. from ICSODeliveryNotice a
  825. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  826. left join (
  827. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  828. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  829. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  830. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  831. inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  832. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  833. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  834. where a.ODNType='1' and a.Status='2' and a.OASNCode is null";
  835. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  836. #endregion
  837. if (!string.IsNullOrWhiteSpace(queryJson))
  838. {
  839. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  840. {
  841. sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  842. }
  843. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  844. {
  845. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  846. }
  847. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  848. {
  849. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  850. }
  851. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  852. {
  853. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  854. }
  855. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  856. {
  857. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  858. }
  859. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  860. {
  861. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  862. }
  863. }
  864. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  865. {
  866. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  867. }
  868. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  869. {
  870. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  871. }
  872. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  873. }
  874. //开立得成品入库单
  875. public DataTable GetGridJsonKLCPRK(string queryJson, ref Pagination jqgridparam)
  876. {
  877. DataTable dt = new DataTable();
  878. var queryParam = queryJson.ToJObject();
  879. List<DbParameter> parameter = new List<DbParameter>();
  880. #region [SQL]
  881. string sql = @"
  882. 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
  883. from ICSManufactureReceive a
  884. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  885. left join (
  886. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  887. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  888. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  889. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  890. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  891. where a.Status='1' and a.Type='1'";
  892. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  893. #endregion
  894. if (!string.IsNullOrWhiteSpace(queryJson))
  895. {
  896. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  897. {
  898. sql += " and a.RCVCode like '%" + queryParam["POCode"].ToString() + "%' ";
  899. }
  900. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  901. {
  902. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  903. }
  904. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  905. {
  906. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  907. }
  908. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  909. {
  910. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  911. }
  912. }
  913. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  914. {
  915. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  916. }
  917. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  918. {
  919. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  920. }
  921. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  922. }
  923. /// <summary>
  924. /// 点击审核委外到货单生成条码(审核委外到货单)
  925. /// </summary>
  926. public DataTable GetSubGridJsonWWSHDHByCreate(string ODNCode, string Sequence, string WorkPoint)
  927. {
  928. DataTable dt = new DataTable();
  929. //var queryParam = queryJson.ToJObject();
  930. List<DbParameter> parameter = new List<DbParameter>();
  931. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  932. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  933. from ICSODeliveryNotice a
  934. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  935. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  936. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  937. group by b.TransCode,b.TransSequence
  938. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
  939. WHERE 1 =1
  940. and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
  941. sql += " and a.WorkPoint='" + WorkPoint + "'";
  942. return Repository().FindTableBySql(sql.ToString());
  943. }
  944. /// <summary>
  945. /// 点击开立成品入库生成条码(开立成品入库单)
  946. /// </summary>
  947. public DataTable GetSubGridJsonKLCPRKByCreate(string RCVCode, string Sequence, string WorkPoint)
  948. {
  949. DataTable dt = new DataTable();
  950. //var queryParam = queryJson.ToJObject();
  951. List<DbParameter> parameter = new List<DbParameter>();
  952. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  953. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  954. from ICSManufactureReceive a
  955. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  956. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  957. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  958. group by b.TransCode,b.TransSequence
  959. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence
  960. WHERE 1 =1
  961. and a.RCVCode='" + RCVCode + "' and a.Sequence='" + Sequence + "'";
  962. sql += " and a.WorkPoint='" + WorkPoint + "'";
  963. return Repository().FindTableBySql(sql.ToString());
  964. }
  965. /// <summary>
  966. /// 点击审核到货单生成条码(审核到货单)
  967. /// </summary>
  968. public DataTable GetSubGridJsonSHDHByCreate(string DNCode, string Sequence, string WorkPoint)
  969. {
  970. DataTable dt = new DataTable();
  971. //var queryParam = queryJson.ToJObject();
  972. List<DbParameter> parameter = new List<DbParameter>();
  973. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  974. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  975. from ICSDeliveryNotice a
  976. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  977. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  978. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  979. group by b.TransCode,b.TransSequence
  980. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
  981. WHERE 1 =1
  982. and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
  983. sql += " and a.WorkPoint='" + WorkPoint + "'";
  984. return Repository().FindTableBySql(sql.ToString());
  985. }
  986. /// <summary>
  987. /// 点击归还生成条码(归还)
  988. /// </summary>
  989. public DataTable GetSubGridJsonGuiHuanByCreate(string ReturnCode, string Sequence, string WorkPoint)
  990. {
  991. DataTable dt = new DataTable();
  992. //var queryParam = queryJson.ToJObject();
  993. List<DbParameter> parameter = new List<DbParameter>();
  994. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  995. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  996. from ICSReturn a
  997. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  998. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  999. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1000. group by b.TransCode,b.TransSequence
  1001. ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence
  1002. WHERE 1 =1
  1003. and a.ReturnCode='" + ReturnCode + "' and a.Sequence='" + Sequence + "'";
  1004. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1005. return Repository().FindTableBySql(sql.ToString());
  1006. }
  1007. /// <summary>
  1008. /// 归还单生成条码
  1009. /// </summary>
  1010. /// <param name="POCode"></param>
  1011. /// <param name="PORow"></param>
  1012. /// <param name="keyValue"></param>
  1013. /// 已改
  1014. /// <returns></returns>
  1015. public int SubmitFormGuiHuan(string ReturnCode, string Sequence, string keyValue, string WorkPoint)
  1016. {
  1017. var queryParam = keyValue.ToJObject();
  1018. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1019. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1020. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1021. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1022. decimal LOTQTY = minPackQty;
  1023. string Pre = ReturnCode + Sequence;
  1024. string sql = string.Empty;
  1025. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1026. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1027. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1028. string sqls = string.Empty;
  1029. for (int i = 0; i < createPageCount; i++)
  1030. {
  1031. if (i + 1 == createPageCount)
  1032. {
  1033. if (minPackQty * createPageCount > thisCreateQty)
  1034. {
  1035. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1036. }
  1037. }
  1038. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1039. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1040. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1041. LotNo, ReturnCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1042. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1043. //{
  1044. sql += string.Format(@"
  1045. insert into ICSInventoryLot
  1046. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  1047. select
  1048. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
  1049. from ICSReturn where ReturnCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1050. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ReturnCode, Sequence);
  1051. sql += "\r\n";
  1052. //}
  1053. }
  1054. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1055. return count;
  1056. }
  1057. /// <summary>
  1058. /// 审核到货单生成条码
  1059. /// </summary>
  1060. /// <param name="POCode"></param>
  1061. /// <param name="PORow"></param>
  1062. /// <param name="keyValue"></param>
  1063. /// 已改
  1064. /// <returns></returns>
  1065. public int SubmitFormSHDH(string DNCode, string Sequence, string keyValue, string WorkPoint)
  1066. {
  1067. var queryParam = keyValue.ToJObject();
  1068. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1069. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1070. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1071. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1072. decimal LOTQTY = minPackQty;
  1073. string Pre = DNCode + Sequence;
  1074. string sql = string.Empty;
  1075. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1076. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1077. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1078. string sqls = string.Empty;
  1079. for (int i = 0; i < createPageCount; i++)
  1080. {
  1081. if (i + 1 == createPageCount)
  1082. {
  1083. if (minPackQty * createPageCount > thisCreateQty)
  1084. {
  1085. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1086. }
  1087. }
  1088. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1089. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1090. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1091. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1092. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1093. //{
  1094. sql += string.Format(@"
  1095. insert into ICSInventoryLot
  1096. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  1097. select
  1098. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
  1099. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1100. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence);
  1101. sql += "\r\n";
  1102. //}
  1103. }
  1104. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1105. return count;
  1106. }
  1107. /// <summary>
  1108. /// 审核委外到货单生成条码
  1109. /// </summary>
  1110. /// <param name="POCode"></param>
  1111. /// <param name="PORow"></param>
  1112. /// <param name="keyValue"></param>
  1113. /// 已改
  1114. /// <returns></returns>
  1115. public int SubmitFormWWSHDH(string ODNCode, string Sequence, string keyValue, string WorkPoint)
  1116. {
  1117. var queryParam = keyValue.ToJObject();
  1118. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1119. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1120. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1121. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1122. decimal LOTQTY = minPackQty;
  1123. string Pre = ODNCode + Sequence;
  1124. string sql = string.Empty;
  1125. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1126. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1127. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1128. string sqls = string.Empty;
  1129. for (int i = 0; i < createPageCount; i++)
  1130. {
  1131. if (i + 1 == createPageCount)
  1132. {
  1133. if (minPackQty * createPageCount > thisCreateQty)
  1134. {
  1135. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1136. }
  1137. }
  1138. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1139. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1140. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1141. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1142. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1143. //{
  1144. sql += string.Format(@"
  1145. insert into ICSInventoryLot
  1146. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  1147. select
  1148. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
  1149. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1150. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence);
  1151. sql += "\r\n";
  1152. //}
  1153. }
  1154. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1155. return count;
  1156. }
  1157. /// <summary>
  1158. /// 开立成品入库单
  1159. /// </summary>
  1160. /// <param name="POCode"></param>
  1161. /// <param name="PORow"></param>
  1162. /// <param name="keyValue"></param>
  1163. /// 已改
  1164. /// <returns></returns>
  1165. public int SubmitFormKLCPRK(string RCVCode, string Sequence, string keyValue, string WorkPoint)
  1166. {
  1167. var queryParam = keyValue.ToJObject();
  1168. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1169. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1170. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1171. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1172. decimal LOTQTY = minPackQty;
  1173. string Pre = RCVCode + Sequence;
  1174. string sql = string.Empty;
  1175. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1176. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1177. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1178. string sqls = string.Empty;
  1179. for (int i = 0; i < createPageCount; i++)
  1180. {
  1181. if (i + 1 == createPageCount)
  1182. {
  1183. if (minPackQty * createPageCount > thisCreateQty)
  1184. {
  1185. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1186. }
  1187. }
  1188. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1189. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1190. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1191. LotNo, RCVCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1192. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1193. //{
  1194. sql += string.Format(@"
  1195. insert into ICSInventoryLot
  1196. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  1197. select
  1198. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
  1199. from ICSManufactureReceive where RCVCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1200. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, RCVCode, Sequence);
  1201. sql += "\r\n";
  1202. //}
  1203. }
  1204. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1205. return count;
  1206. }
  1207. //委外拒收单
  1208. public DataTable GetGridJsonWWJSD(string queryJson, ref Pagination jqgridparam)
  1209. {
  1210. DataTable dt = new DataTable();
  1211. var queryParam = queryJson.ToJObject();
  1212. List<DbParameter> parameter = new List<DbParameter>();
  1213. #region [SQL]
  1214. string sql = @"select a.ID, a.ODNCode OOCode,a.Sequence OOSequence,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
  1215. from ICSODeliveryNotice a
  1216. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1217. left join (
  1218. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1219. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  1220. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1221. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1222. --inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  1223. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1224. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1225. where a.ODNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null";
  1226. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1227. #endregion
  1228. if (!string.IsNullOrWhiteSpace(queryJson))
  1229. {
  1230. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1231. {
  1232. sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1233. }
  1234. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1235. {
  1236. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1237. }
  1238. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1239. {
  1240. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1241. }
  1242. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1243. {
  1244. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1245. }
  1246. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1247. {
  1248. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1249. }
  1250. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1251. {
  1252. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1253. }
  1254. }
  1255. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1256. {
  1257. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1258. }
  1259. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1260. {
  1261. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1262. }
  1263. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1264. }
  1265. //拒收单
  1266. public DataTable GetGridJsonJSD(string queryJson, ref Pagination jqgridparam)
  1267. {
  1268. DataTable dt = new DataTable();
  1269. var queryParam = queryJson.ToJObject();
  1270. List<DbParameter> parameter = new List<DbParameter>();
  1271. #region [SQL]
  1272. string sql = @"select a.ID,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
  1273. from ICSDeliveryNotice a
  1274. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1275. left join (
  1276. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1277. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  1278. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1279. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1280. --inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  1281. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1282. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1283. where a.DNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
  1284. ";
  1285. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1286. #endregion
  1287. if (!string.IsNullOrWhiteSpace(queryJson))
  1288. {
  1289. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1290. {
  1291. sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1292. }
  1293. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1294. {
  1295. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1296. }
  1297. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1298. {
  1299. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1300. }
  1301. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1302. {
  1303. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1304. }
  1305. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1306. {
  1307. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1308. }
  1309. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1310. {
  1311. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1312. }
  1313. }
  1314. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1315. {
  1316. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1317. }
  1318. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1319. {
  1320. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1321. }
  1322. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1323. }
  1324. //领料申请退料
  1325. public DataTable GetGridJsonLLSQTL(string queryJson, ref Pagination jqgridparam)
  1326. {
  1327. DataTable dt = new DataTable();
  1328. var queryParam = queryJson.ToJObject();
  1329. List<DbParameter> parameter = new List<DbParameter>();
  1330. #region [SQL]
  1331. string sql = @"
  1332. 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
  1333. from ICSMOApplyNegDetail a
  1334. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1335. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1336. left join (
  1337. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1338. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  1339. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1340. )c
  1341. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1342. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1343. WHERE d.Type='2'";
  1344. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1345. #endregion
  1346. if (!string.IsNullOrWhiteSpace(queryJson))
  1347. {
  1348. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1349. {
  1350. sql += " and a.RCVCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1351. }
  1352. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1353. {
  1354. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1355. }
  1356. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1357. {
  1358. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1359. }
  1360. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1361. {
  1362. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1363. }
  1364. }
  1365. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1366. {
  1367. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1368. }
  1369. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1370. {
  1371. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1372. }
  1373. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1374. }
  1375. /// <summary>
  1376. /// 审核到货单生成条码
  1377. /// </summary>
  1378. /// <param name="POCode"></param>
  1379. /// <param name="PORow"></param>
  1380. /// <param name="keyValue"></param>
  1381. /// <returns></returns>
  1382. public int SubmitFormJSD(string DNCode, string Sequence, string keyValue, string WorkPoint)
  1383. {
  1384. var queryParam = keyValue.ToJObject();
  1385. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1386. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1387. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1388. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1389. decimal LOTQTY = minPackQty;
  1390. string Pre = DNCode + Sequence;
  1391. string sql = string.Empty;
  1392. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1393. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1394. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1395. string sqls = string.Empty;
  1396. for (int i = 0; i < createPageCount; i++)
  1397. {
  1398. if (i + 1 == createPageCount)
  1399. {
  1400. if (minPackQty * createPageCount > thisCreateQty)
  1401. {
  1402. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1403. }
  1404. }
  1405. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1406. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1407. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1408. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1409. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1410. //{
  1411. sql += string.Format(@"
  1412. insert into ICSInventoryLot
  1413. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  1414. select
  1415. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'12','{3}','{4}', getdate(),'{5}'
  1416. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1417. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence);
  1418. sql += "\r\n";
  1419. //}
  1420. }
  1421. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1422. return count;
  1423. }
  1424. /// <summary>
  1425. /// 审核委外到货单生成条码
  1426. /// </summary>
  1427. /// <param name="POCode"></param>
  1428. /// <param name="PORow"></param>
  1429. /// <param name="keyValue"></param>
  1430. /// <returns></returns>
  1431. public int SubmitFormWWJSD(string ODNCode, string Sequence, string keyValue, string WorkPoint)
  1432. {
  1433. var queryParam = keyValue.ToJObject();
  1434. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1435. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1436. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1437. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1438. decimal LOTQTY = minPackQty;
  1439. string Pre = ODNCode + Sequence;
  1440. string sql = string.Empty;
  1441. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1442. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1443. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1444. string sqls = string.Empty;
  1445. for (int i = 0; i < createPageCount; i++)
  1446. {
  1447. if (i + 1 == createPageCount)
  1448. {
  1449. if (minPackQty * createPageCount > thisCreateQty)
  1450. {
  1451. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1452. }
  1453. }
  1454. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1455. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1456. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1457. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1458. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1459. //{
  1460. sql += string.Format(@"
  1461. insert into ICSInventoryLot
  1462. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  1463. select
  1464. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'13','{3}','{4}', getdate(),'{5}'
  1465. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1466. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence);
  1467. sql += "\r\n";
  1468. //}
  1469. }
  1470. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1471. return count;
  1472. }
  1473. /// <summary>
  1474. /// 点击审核到货单生成条码(审核到货单)
  1475. /// </summary>
  1476. public DataTable GetSubGridJsonJSDByCreate(string DNCode, string Sequence, string WorkPoint)
  1477. {
  1478. DataTable dt = new DataTable();
  1479. //var queryParam = queryJson.ToJObject();
  1480. List<DbParameter> parameter = new List<DbParameter>();
  1481. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  1482. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  1483. from ICSDeliveryNotice a
  1484. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1485. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1486. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1487. group by b.TransCode,b.TransSequence
  1488. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
  1489. WHERE a.DNType='3'
  1490. and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
  1491. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1492. return Repository().FindTableBySql(sql.ToString());
  1493. }
  1494. /// <summary>
  1495. /// 点击审核委外到货单生成条码(审核委外到货单)
  1496. /// </summary>
  1497. public DataTable GetSubGridJsonWWJSDByCreate(string ODNCode, string Sequence, string WorkPoint)
  1498. {
  1499. DataTable dt = new DataTable();
  1500. //var queryParam = queryJson.ToJObject();
  1501. List<DbParameter> parameter = new List<DbParameter>();
  1502. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  1503. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  1504. from ICSODeliveryNotice a
  1505. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1506. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1507. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1508. group by b.TransCode,b.TransSequence
  1509. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
  1510. WHERE a.ODNType='3'
  1511. and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
  1512. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1513. return Repository().FindTableBySql(sql.ToString());
  1514. }
  1515. public DataTable GetSubGridJsonLLSQDByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  1516. {
  1517. DataTable dt = new DataTable();
  1518. //var queryParam = queryJson.ToJObject();
  1519. List<DbParameter> parameter = new List<DbParameter>();
  1520. string sql = @" select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  1521. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  1522. from ICSMOApplyNegDetail a
  1523. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1524. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1525. left join (
  1526. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1527. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1528. group by b.TransCode,b.TransSequence
  1529. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  1530. WHERE d.Type='2'
  1531. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  1532. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1533. return Repository().FindTableBySql(sql.ToString());
  1534. }
  1535. //领料申请退料生成条码
  1536. public int SubmitFormLLSQTL(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  1537. {
  1538. var queryParam = keyValue.ToJObject();
  1539. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1540. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1541. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1542. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1543. decimal LOTQTY = minPackQty;
  1544. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1545. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  1546. string Pre = ApplyNegCode + Sequence;
  1547. string sql = string.Empty;
  1548. //string VendorLot = queryParam["VendorLot"].ToString();
  1549. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1550. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1551. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1552. string sqls = string.Empty;
  1553. for (int i = 0; i < createPageCount; i++)
  1554. {
  1555. if (i + 1 == createPageCount)
  1556. {
  1557. if (minPackQty * createPageCount > thisCreateQty)
  1558. {
  1559. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1560. }
  1561. }
  1562. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1563. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1564. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1565. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1566. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1567. //{
  1568. sql += string.Format(@"insert into ICSInventoryLot
  1569. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  1570. select
  1571. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'3','{3}','{4}', getdate(),'{5}'
  1572. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1573. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence);
  1574. sql += "\r\n";
  1575. //}
  1576. }
  1577. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1578. return count;
  1579. }
  1580. //材料出库退料
  1581. public DataTable GetGridJsonCLCK(string queryJson, ref Pagination jqgridparam)
  1582. {
  1583. DataTable dt = new DataTable();
  1584. var queryParam = queryJson.ToJObject();
  1585. List<DbParameter> parameter = new List<DbParameter>();
  1586. #region [SQL]
  1587. string sql = @"
  1588. 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
  1589. from ICSMOApplyNegDetail a
  1590. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1591. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1592. left join (
  1593. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1594. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
  1595. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1596. )c
  1597. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1598. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1599. WHERE d.Type='3'";
  1600. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1601. #endregion
  1602. if (!string.IsNullOrWhiteSpace(queryJson))
  1603. {
  1604. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1605. {
  1606. sql += " and a.RCVCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1607. }
  1608. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1609. {
  1610. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1611. }
  1612. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1613. {
  1614. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1615. }
  1616. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1617. {
  1618. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1619. }
  1620. }
  1621. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1622. {
  1623. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1624. }
  1625. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1626. {
  1627. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1628. }
  1629. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1630. }
  1631. //材料出库退料
  1632. public DataTable GetSubGridJsonCLCKByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  1633. {
  1634. DataTable dt = new DataTable();
  1635. //var queryParam = queryJson.ToJObject();
  1636. List<DbParameter> parameter = new List<DbParameter>();
  1637. string sql = @" select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
  1638. (a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
  1639. from ICSMOApplyNegDetail a
  1640. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1641. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1642. left join (
  1643. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1644. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1645. group by b.TransCode,b.TransSequence
  1646. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  1647. WHERE d.Type='3'
  1648. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  1649. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1650. return Repository().FindTableBySql(sql.ToString());
  1651. }
  1652. //材料出库退料生成条码
  1653. public int SubmitFormCLCKT(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  1654. {
  1655. var queryParam = keyValue.ToJObject();
  1656. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1657. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1658. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1659. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1660. decimal LOTQTY = minPackQty;
  1661. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1662. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  1663. string Pre = ApplyNegCode + Sequence;
  1664. string sql = string.Empty;
  1665. //string VendorLot = queryParam["VendorLot"].ToString();
  1666. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1667. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1668. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1669. string sqls = string.Empty;
  1670. for (int i = 0; i < createPageCount; i++)
  1671. {
  1672. if (i + 1 == createPageCount)
  1673. {
  1674. if (minPackQty * createPageCount > thisCreateQty)
  1675. {
  1676. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1677. }
  1678. }
  1679. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1680. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1681. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1682. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1683. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1684. //{
  1685. sql += string.Format(@"insert into ICSInventoryLot
  1686. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
  1687. select
  1688. newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'3','{3}','{4}', getdate(),'{5}'
  1689. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1690. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence);
  1691. sql += "\r\n";
  1692. //}
  1693. }
  1694. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1695. return count;
  1696. }
  1697. }
  1698. }