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.

879 lines
48 KiB

9 months ago
9 months ago
4 days ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
9 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
9 months ago
10 months ago
9 months ago
9 months ago
10 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
2 days ago
9 months ago
  1. using NFine.Data.Extensions;
  2. using System;
  3. using NFine.Repository;
  4. using NFine.Domain._03_Entity.SRM;
  5. using Newtonsoft.Json;
  6. using Newtonsoft.Json.Linq;
  7. namespace NFine.Application.WMS
  8. {
  9. public class RevokeBusinessApp : RepositoryFactory<ICSVendor>
  10. {
  11. //采购入库撤销
  12. public string RevocationPurchase(string keyValue)
  13. {
  14. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  15. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  16. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  17. string msg = "";
  18. string sql = string.Empty;
  19. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  20. foreach (var item in res)
  21. {
  22. JObject jo = (JObject)item;
  23. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
  24. sql += string.Format(@"update ICSPurchaseOrder set InQuantity =InQuantity-'{0}' where POCode='{1}' and Sequence='{2}' and WorkPoint='{3}'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  25. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", jo["ID"].ToString(), WorkPoint);
  26. }
  27. try
  28. {
  29. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  30. {
  31. }
  32. }
  33. catch (Exception ex)
  34. {
  35. msg = ex.Message;
  36. }
  37. return msg;
  38. }
  39. //采购入库-采购到货单撤销
  40. public string RevocationDeliveryNotice(string keyValue)
  41. {
  42. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  43. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  44. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  45. string msg = "";
  46. string sql = string.Empty;
  47. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  48. foreach (var item in res)
  49. {
  50. JObject jo = (JObject)item;
  51. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
  52. sql += string.Format(@"update ICSDeliveryNotice set RCVQuantity =RCVQuantity-'{0}' where DNCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and DNType='1'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  53. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", jo["ID"].ToString(), WorkPoint);
  54. }
  55. try
  56. {
  57. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  58. {
  59. }
  60. }
  61. catch (Exception ex)
  62. {
  63. msg = ex.Message;
  64. }
  65. return msg;
  66. }
  67. public string RevocationWWFLBLB(string keyValue)
  68. {
  69. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  70. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  71. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  72. string msg = "";
  73. string sql = string.Empty;
  74. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  75. foreach (var item in res)
  76. {
  77. JObject jo = (JObject)item;
  78. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  79. sql += string.Format(@"update a set IssueQuantity =IssueQuantity-'{0}'
  80. from ICSOOPick a
  81. left join ICSOutsourcingOrder b on a.OODetailID=b.OODetailID and a.WorkPoint=b.WorkPoint
  82. where b.OOCode='{1}' and b.Sequence+'~'+a.Sequence='{2}' and a.WorkPoint='{3}'",
  83. jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  84. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  85. }
  86. try
  87. {
  88. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  89. {
  90. }
  91. }
  92. catch (Exception ex)
  93. {
  94. msg = ex.Message;
  95. }
  96. return msg;
  97. }
  98. //生产订单备料表
  99. public string RevocationPicking(string keyValue)
  100. {
  101. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  102. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  103. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  104. string msg = "";
  105. string sql = string.Empty;
  106. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  107. foreach (var item in res)
  108. {
  109. JObject jo = (JObject)item;
  110. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  111. sql += string.Format(@"update a set IssueQuantity =IssueQuantity-'{0}' from ICSMOPick a left join ICSMO b on a.MODetailID=b.MODetailID and a.WorkPoint=b.WorkPoint
  112. where b.MOCode='{1}' and b.Sequence+'~'+a.Sequence='{2}' and a.WorkPoint='{3}'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  113. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", jo["ID"].ToString(), WorkPoint);
  114. }
  115. try
  116. {
  117. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  118. {
  119. }
  120. }
  121. catch (Exception ex)
  122. {
  123. msg = ex.Message;
  124. }
  125. return msg;
  126. }
  127. //领料申请单
  128. public string RevocationMOApply(string keyValue)
  129. {
  130. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  131. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  132. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  133. string msg = "";
  134. string sql = string.Empty;
  135. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  136. foreach (var item in res)
  137. {
  138. JObject jo = (JObject)item;
  139. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  140. sql += string.Format(@"update ICSMOApply set IssueQuantity =IssueQuantity-'{0}' where ApplyCode='{1}' and Sequence='{2}' and WorkPoint='{3}' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  141. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", jo["ID"].ToString(), WorkPoint);
  142. }
  143. try
  144. {
  145. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  146. {
  147. }
  148. }
  149. catch (Exception ex)
  150. {
  151. msg = ex.Message;
  152. }
  153. return msg;
  154. }
  155. //材料出库
  156. public string RevocationMOIssue(string keyValue)
  157. {
  158. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  159. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  160. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  161. string msg = "";
  162. string sql = string.Empty;
  163. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  164. foreach (var item in res)
  165. {
  166. JObject jo = (JObject)item;
  167. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  168. sql += string.Format(@"update ICSMOIssue set IssueQuantity =IssueQuantity-'{0}' where IssueCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='1' and Status='2'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  169. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", jo["ID"].ToString(), WorkPoint);
  170. }
  171. try
  172. {
  173. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  174. {
  175. }
  176. }
  177. catch (Exception ex)
  178. {
  179. msg = ex.Message;
  180. }
  181. return msg;
  182. }
  183. //产成品入库-生产订单
  184. public string RevocationFinished(string keyValue)
  185. {
  186. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  187. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  188. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  189. string msg = "";
  190. string sql = string.Empty;
  191. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  192. foreach (var item in res)
  193. {
  194. JObject jo = (JObject)item;
  195. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  196. sql += string.Format(@"update ICSMO set RCVQuantity =RCVQuantity-'{0}' where MOCode='{1}' and Sequence='{2}' and WorkPoint='{3}'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  197. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", jo["ID"].ToString(), WorkPoint);
  198. }
  199. try
  200. {
  201. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  202. {
  203. }
  204. }
  205. catch (Exception ex)
  206. {
  207. msg = ex.Message;
  208. }
  209. return msg;
  210. }
  211. //产成品入库-产成品入库单
  212. public string RevocationManufactureReceive(string keyValue)
  213. {
  214. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  215. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  216. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  217. string msg = "";
  218. string sql = string.Empty;
  219. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  220. foreach (var item in res)
  221. {
  222. JObject jo = (JObject)item;
  223. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  224. sql += string.Format(@" update ICSManufactureReceive set RCVQuantity =RCVQuantity-'{0}' where RCVCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='1' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  225. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  226. }
  227. try
  228. {
  229. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  230. {
  231. }
  232. }
  233. catch (Exception ex)
  234. {
  235. msg = ex.Message;
  236. }
  237. return msg;
  238. }
  239. //一步调拨
  240. public string RevocationICSTransfer(string keyValue)
  241. {
  242. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  243. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  244. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  245. string msg = "";
  246. string sql = string.Empty;
  247. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  248. foreach (var item in res)
  249. {
  250. JObject jo = (JObject)item;
  251. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MUSER='{1}',MUSERName='{2}',WarehouseCode='{5}',LocationCode='{6}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint, jo["FromWarehouseCode"].ToString(), jo["FromLocationCode"].ToString());
  252. sql += string.Format(@" update ICSTransfer set TransferQuantity =TransferQuantity-'{0}' where TransferNO='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='1' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  253. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  254. }
  255. try
  256. {
  257. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  258. {
  259. }
  260. }
  261. catch (Exception ex)
  262. {
  263. msg = ex.Message;
  264. }
  265. return msg;
  266. }
  267. //销售出库
  268. public string RevocationMarket(string keyValue)
  269. {
  270. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  271. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  272. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  273. string msg = "";
  274. string sql = string.Empty;
  275. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  276. foreach (var item in res)
  277. {
  278. JObject jo = (JObject)item;
  279. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  280. sql += string.Format(@" update ICSSDN set SDNQuantity =SDNQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  281. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  282. }
  283. try
  284. {
  285. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  286. {
  287. }
  288. }
  289. catch (Exception ex)
  290. {
  291. msg = ex.Message;
  292. }
  293. return msg;
  294. }
  295. //生产退料-生产退料单
  296. public string RevocationProduceStripping(string keyValue)
  297. {
  298. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  299. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  300. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  301. string msg = "";
  302. string sql = string.Empty;
  303. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  304. foreach (var item in res)
  305. {
  306. JObject jo = (JObject)item;
  307. string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='"+ jo["LotNo"].ToString() + "'";
  308. object LotNoType= SqlHelper.ExecuteScalar(sqlseach);
  309. if (LotNoType.ToString()== "1")
  310. {
  311. //新条码退
  312. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  313. sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  314. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", jo["ID"].ToString(), WorkPoint);
  315. sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  316. FROM ICSInventoryLot a
  317. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  318. INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  319. INNER JOIN ICSMOApplyNeg d ON c.ApplyNegCode=d.ApplyNegCode AND c.WorkPoint=d.WorkPoint
  320. INNER JOIN ICSMOPick e ON c.SourceDetailID=e.PickID AND c.WorkPoint=e.WorkPoint
  321. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='1'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
  322. }
  323. else
  324. {
  325. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  326. // sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  327. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", jo["ID"].ToString(), WorkPoint);
  328. sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  329. FROM ICSWareHouseLotInfoLog a
  330. INNER JOIN ICSMO b ON a.TransCode=b.MOCode AND a.WorkPoint=b.WorkPoint
  331. INNER JOIN ICSMOPick c ON b.MODetailID = c.MODetailID AND b.WorkPoint = c.WorkPoint AND a.TransSequence = b.Sequence + '~' + c.Sequence
  332. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
  333. }
  334. }
  335. try
  336. {
  337. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  338. {
  339. }
  340. }
  341. catch (Exception ex)
  342. {
  343. msg = ex.Message;
  344. }
  345. return msg;
  346. }
  347. //生产退料-生产退料单-领料申请单
  348. public string RevocationProduceStrippingLL(string keyValue)
  349. {
  350. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  351. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  352. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  353. string msg = "";
  354. string sql = string.Empty;
  355. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  356. foreach (var item in res)
  357. {
  358. JObject jo = (JObject)item;
  359. string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='" + jo["LotNo"].ToString() + "'";
  360. object LotNoType = SqlHelper.ExecuteScalar(sqlseach);
  361. if (LotNoType.ToString() == "1")
  362. {
  363. //新条码退
  364. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  365. sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  366. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  367. sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  368. FROM ICSInventoryLot a
  369. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  370. INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  371. INNER JOIN ICSMOApplyNeg d ON c.ApplyNegCode=d.ApplyNegCode AND c.WorkPoint=d.WorkPoint
  372. INNER JOIN ICSMOApply e ON c.SourceDetailID=e.ApplyDetailID AND c.WorkPoint=e.WorkPoint
  373. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='2'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
  374. }
  375. else
  376. {
  377. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  378. // sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  379. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  380. sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  381. FROM ICSWareHouseLotInfoLog a
  382. INNER JOIN ICSMOApply c ON a.TransCode=c.ApplyCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  383. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
  384. }
  385. }
  386. try
  387. {
  388. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  389. {
  390. }
  391. }
  392. catch (Exception ex)
  393. {
  394. msg = ex.Message;
  395. }
  396. return msg;
  397. }
  398. //生产退料-生产退料单-材料出库单
  399. public string RevocationProduceStrippingCLCK(string keyValue)
  400. {
  401. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  402. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  403. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  404. string msg = "";
  405. string sql = string.Empty;
  406. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  407. foreach (var item in res)
  408. {
  409. JObject jo = (JObject)item;
  410. string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='" + jo["LotNo"].ToString() + "'";
  411. object LotNoType = SqlHelper.ExecuteScalar(sqlseach);
  412. if (LotNoType.ToString() == "1")
  413. {
  414. //新条码退
  415. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  416. sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  417. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  418. sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  419. FROM ICSInventoryLot a
  420. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  421. INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  422. INNER JOIN ICSMOApplyNeg d ON c.ApplyNegCode=d.ApplyNegCode AND c.WorkPoint=d.WorkPoint
  423. INNER JOIN ICSMOIssue e ON c.SourceDetailID=e.IssueDetailID AND c.WorkPoint=e.WorkPoint
  424. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='3'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
  425. }
  426. else
  427. {
  428. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  429. // sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  430. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  431. sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  432. FROM ICSWareHouseLotInfoLog a
  433. INNER JOIN ICSMOIssue c ON a.TransCode=c.IssueCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  434. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
  435. }
  436. }
  437. try
  438. {
  439. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  440. {
  441. }
  442. }
  443. catch (Exception ex)
  444. {
  445. msg = ex.Message;
  446. }
  447. return msg;
  448. }
  449. //其他出库(杂发)
  450. public string RevocationOtheOutboundr(string keyValue)
  451. {
  452. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  453. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  454. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  455. string msg = "";
  456. string sql = string.Empty;
  457. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  458. foreach (var item in res)
  459. {
  460. JObject jo = (JObject)item;
  461. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  462. sql += string.Format(@" update ICSOtherOut set OutQuantity =OutQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where OutCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  463. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  464. }
  465. try
  466. {
  467. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  468. {
  469. }
  470. }
  471. catch (Exception ex)
  472. {
  473. msg = ex.Message;
  474. }
  475. return msg;
  476. }
  477. //其他入库(杂收)
  478. public string RevocationOtheWarehousing(string keyValue)
  479. {
  480. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  481. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  482. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  483. string msg = "";
  484. string sql = string.Empty;
  485. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  486. foreach (var item in res)
  487. {
  488. JObject jo = (JObject)item;
  489. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  490. sql += string.Format(@" update ICSOtherIn set InQuantity =InQuantity-'{0}' where InCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='1' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  491. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  492. }
  493. try
  494. {
  495. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  496. {
  497. }
  498. }
  499. catch (Exception ex)
  500. {
  501. msg = ex.Message;
  502. }
  503. return msg;
  504. }
  505. //无源头调拨
  506. public string RevocationICSTransfer2(string keyValue)
  507. {
  508. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  509. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  510. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  511. string msg = "";
  512. string sql = string.Empty;
  513. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  514. foreach (var item in res)
  515. {
  516. JObject jo = (JObject)item;
  517. sql += string.Format(@"update ICSWareHouseLotInfo set WarehouseCode='{5}',LocationCode='{6}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint, jo["FromWarehouseCode"].ToString(), jo["FromLocationCode"].ToString());
  518. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  519. }
  520. try
  521. {
  522. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  523. {
  524. }
  525. }
  526. catch (Exception ex)
  527. {
  528. msg = ex.Message;
  529. }
  530. return msg;
  531. }
  532. //撤销事件
  533. public string RevocationAll(string keyValue, string tableName, string columnCode, string columnQuantity, string opration)
  534. {
  535. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  536. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  537. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  538. string msg = "";
  539. string sql = string.Empty;
  540. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  541. foreach (var item in res)
  542. {
  543. JObject jo = (JObject)item;
  544. sql += $@"update ICSWareHouseLotInfo set Quantity=Quantity {opration} '{jo["Quantity"]}',MTIME=getdate(),MUSER='{MUSER}',MUSERName='{MUSERNAME}' where LotNo='{jo["LotNo"]}' and WorkPoint='{WorkPoint}'; update {tableName} set {columnQuantity} ={columnQuantity} - '{jo["Quantity"]}' , MTIME=getdate(),MUSER='{MUSER}',MUSERName='{MUSERNAME}' where {columnCode}='{jo["TransCode"]}' and Sequence='{jo["TransSequence"]}' and WorkPoint='{WorkPoint}';
  545. update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{MUSER}',MUSERName='{MUSERNAME}' where ID='{jo["ID"]}' and WorkPoint='{WorkPoint}'; ";
  546. }
  547. try
  548. {
  549. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  550. {
  551. }
  552. }
  553. catch (Exception ex)
  554. {
  555. msg = ex.Message;
  556. }
  557. return msg;
  558. }
  559. //物料调拨(开立调拨申请单)
  560. public string RevocationICSTransferApplication(string keyValue)
  561. {
  562. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  563. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  564. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  565. string msg = "";
  566. string sql = string.Empty;
  567. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  568. foreach (var item in res)
  569. {
  570. JObject jo = (JObject)item;
  571. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',WarehouseCode='{5}',LocationCode='{6}',MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint, jo["LotNo"].ToString(), jo["LotNo"].ToString(), jo["FromWarehouseCode"].ToString(), jo["FromLocationCode"].ToString());
  572. sql += string.Format(@" update ICSTransferApplication set TransferQuantity =TransferQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where TransferNO='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  573. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  574. }
  575. try
  576. {
  577. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  578. {
  579. }
  580. }
  581. catch (Exception ex)
  582. {
  583. msg = ex.Message;
  584. }
  585. return msg;
  586. }
  587. //委外退料-委外退料单
  588. public string RevocationWWProduceStripping(string keyValue)
  589. {
  590. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  591. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  592. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  593. string msg = "";
  594. string sql = string.Empty;
  595. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  596. foreach (var item in res)
  597. {
  598. JObject jo = (JObject)item;
  599. string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='" + jo["LotNo"].ToString() + "'";
  600. object LotNoType = SqlHelper.ExecuteScalar(sqlseach);
  601. if (LotNoType.ToString() == "1")
  602. {
  603. //新条码退
  604. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  605. sql += string.Format(@" update ICSOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  606. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", jo["ID"].ToString(), WorkPoint);
  607. sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  608. FROM ICSInventoryLot a
  609. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  610. INNER JOIN ICSOApplyNegDetail c ON b.TransCode=c.OApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  611. INNER JOIN ICSOApplyNeg d ON c.OApplyNegCode=d.OApplyNegCode AND c.WorkPoint=d.WorkPoint
  612. INNER JOIN ICSOOPick e ON c.SourceDetailID=e.PickID AND c.WorkPoint=e.WorkPoint
  613. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='1'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
  614. }
  615. else
  616. {
  617. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  618. // sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  619. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", jo["ID"].ToString(), WorkPoint);
  620. sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  621. FROM ICSWareHouseLotInfoLog a
  622. INNER JOIN ICSOutsourcingOrder b ON a.TransCode=b.OOCode AND a.WorkPoint=b.WorkPoint
  623. INNER JOIN ICSMOPick c ON b.OODetailID = c.OODetailID AND b.WorkPoint = c.WorkPoint AND a.TransSequence = b.Sequence + '~' + c.Sequence
  624. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
  625. }
  626. }
  627. try
  628. {
  629. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  630. {
  631. }
  632. }
  633. catch (Exception ex)
  634. {
  635. msg = ex.Message;
  636. }
  637. return msg;
  638. }
  639. //委外退料-委外退料单-委外申请单
  640. public string RevocationWWProduceStrippingLL(string keyValue)
  641. {
  642. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  643. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  644. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  645. string msg = "";
  646. string sql = string.Empty;
  647. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  648. foreach (var item in res)
  649. {
  650. JObject jo = (JObject)item;
  651. string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='" + jo["LotNo"].ToString() + "'";
  652. object LotNoType = SqlHelper.ExecuteScalar(sqlseach);
  653. if (LotNoType.ToString() == "1")
  654. {
  655. //新条码退
  656. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  657. sql += string.Format(@" update ICSOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  658. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  659. sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  660. FROM ICSInventoryLot a
  661. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  662. INNER JOIN ICSOApplyNegDetail c ON b.TransCode=c.OApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  663. INNER JOIN ICSOApplyNeg d ON c.OApplyNegCode=d.OApplyNegCode AND c.WorkPoint=d.WorkPoint
  664. INNER JOIN ICSOApply e ON c.SourceDetailID=e.ApplyDetailID AND c.WorkPoint=e.WorkPoint
  665. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='2'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
  666. }
  667. else
  668. {
  669. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  670. // sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  671. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  672. sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  673. FROM ICSWareHouseLotInfoLog a
  674. INNER JOIN ICSOApply c ON a.TransCode=c.ApplyCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  675. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
  676. }
  677. }
  678. try
  679. {
  680. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  681. {
  682. }
  683. }
  684. catch (Exception ex)
  685. {
  686. msg = ex.Message;
  687. }
  688. return msg;
  689. }
  690. //委外退料-委外退料单-委外材料出库单
  691. public string RevocationWWProduceStrippingCLCK(string keyValue)
  692. {
  693. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  694. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  695. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  696. string msg = "";
  697. string sql = string.Empty;
  698. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  699. foreach (var item in res)
  700. {
  701. JObject jo = (JObject)item;
  702. string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='" + jo["LotNo"].ToString() + "'";
  703. object LotNoType = SqlHelper.ExecuteScalar(sqlseach);
  704. if (LotNoType.ToString() == "1")
  705. {
  706. //新条码退
  707. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  708. sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  709. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  710. sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  711. FROM ICSInventoryLot a
  712. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  713. INNER JOIN ICSOApplyNegDetail c ON b.TransCode=c.OApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  714. INNER JOIN ICSOApplyNeg d ON c.OApplyNegCode=d.OApplyNegCode AND c.WorkPoint=d.WorkPoint
  715. INNER JOIN ICSOIssue e ON c.SourceDetailID=e.IssueDetailID AND c.WorkPoint=e.WorkPoint
  716. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='3'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
  717. }
  718. else
  719. {
  720. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  721. // sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  722. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  723. sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  724. FROM ICSWareHouseLotInfoLog a
  725. INNER JOIN ICSOIssue c ON a.TransCode=c.IssueCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  726. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
  727. }
  728. }
  729. try
  730. {
  731. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  732. {
  733. }
  734. }
  735. catch (Exception ex)
  736. {
  737. msg = ex.Message;
  738. }
  739. return msg;
  740. }
  741. }
  742. }