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

3745 lines
162 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
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
  1. using NFine.Data.Extensions;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using 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. namespace NFine.Application.WMS
  20. {
  21. public class BasicSettingsApp : RepositoryFactory<ICSVendor>
  22. {
  23. /// <summary>
  24. /// 删除库位
  25. /// </summary>
  26. /// <param name="keyValue">传入ID</param>
  27. /// <returns></returns>
  28. public string DeleteStack(string keyValue)
  29. {
  30. //站点信息
  31. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  32. string msg = "";
  33. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  34. string sql = string.Empty;
  35. //sql = string.Format(@"DELETE FROM dbo.ICSLocation WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  36. sql = string.Format(@"IF EXISTS(SELECT ID FROM dbo.ICSLocation WHERE ID IN ({0}) and WorkPoint ='{1}' AND EATTRIBUTE1 is not null AND EATTRIBUTE1!='')
  37. BEGIN
  38. DELETE FROM dbo.ICSLocationOverLoad WHERE OverLoadLocationCode IN (
  39. SELECT EATTRIBUTE1 FROM dbo.ICSLocation WHERE ID IN ({0}) and WorkPoint ='{1}') and WorkPoint ='{1}'
  40. END;
  41. DELETE FROM dbo.ICSLocation WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  42. try
  43. {
  44. SqlHelper.CmdExecuteNonQueryLi(sql);
  45. }
  46. catch (Exception ex)
  47. {
  48. throw new Exception(ex.Message);
  49. }
  50. return msg;
  51. }
  52. /// <summary>
  53. /// 删除不良原因
  54. /// </summary>
  55. /// <param name="keyValue">传入ID</param>
  56. /// <returns></returns>
  57. public string DeleteBadCode(string keyValue)
  58. {
  59. //站点信息
  60. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  61. string msg = "";
  62. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  63. string sql = string.Empty;
  64. sql = string.Format(@"DELETE FROM dbo.ICSBadCode WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  65. try
  66. {
  67. SqlHelper.ExecuteNonQuery(sql);
  68. }
  69. catch (Exception ex)
  70. {
  71. throw new Exception(ex.Message);
  72. }
  73. return msg;
  74. }
  75. /// <summary>
  76. /// 获取库房信息
  77. /// </summary>
  78. /// <returns></returns>
  79. public DataTable GetWarehouse()
  80. {
  81. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  82. string sql = @"
  83. select '' as WarehouseCode,'' as WarehouseName
  84. union all
  85. SELECT [WarehouseCode],[WarehouseName] FROM [ICSWarehouse] WITH (NOLOCK) WHERE 1=1 ";
  86. //string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  87. //if (role != "admin")
  88. //{
  89. // sql += " and b.WorkPoint='" + WorkPoint + "'";
  90. //}
  91. sql += " and WorkPoint='" + WorkPoint + "'";
  92. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  93. return dt;
  94. }
  95. /// <summary>
  96. /// 获取库位信息
  97. /// </summary>
  98. /// <returns></returns>
  99. public DataTable GetLocationCode()
  100. {
  101. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  102. string sql = @"select '' as LocationCode
  103. union all
  104. SELECT a.LocationCode from ICSLocation a
  105. left join ICSLocationOverLoad b on b.WorkPoint=a.WorkPoint and a.LocationCode = b.LocationCode
  106. WHERE (a.EATTRIBUTE1 is null or a.EATTRIBUTE1='')
  107. AND b.ID is null ";
  108. //string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  109. //if (role != "admin")
  110. //{
  111. // sql += " and b.WorkPoint='" + WorkPoint + "'";
  112. //}
  113. sql += " and a.WorkPoint='" + WorkPoint + "'";
  114. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  115. return dt;
  116. }
  117. /// <summary>
  118. /// 新增库位
  119. /// </summary>
  120. /// <param name="queryJson"></param>
  121. /// <returns></returns>
  122. public string InsertStack(string keyValue)
  123. {
  124. var queryParam = keyValue.ToJObject();
  125. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  126. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  127. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  128. string msg = "";
  129. string StackSql = @"select * from ICSWarehouse where WarehouseCode='{0}' and WorkPoint='{1}'";
  130. StackSql = string.Format(StackSql, queryParam["Warehouse"].ToString(), WorkPoint);
  131. DataTable dt = SqlHelper.GetDataTableBySql(StackSql);
  132. string sql = string.Empty;
  133. sql = @"INSERT INTO dbo.ICSLocation
  134. ( ID ,LocationCode ,LocationName ,WHID ,MUSER ,
  135. MUSERName ,MTIME ,WorkPoint ,Region,Row,GoodsShelf ,Tier,Grid,StockInArea) Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',GETDATE(),'{5}','{6}','{7}','{8}','{9}','{10}','{11}')";
  136. sql = string.Format(sql, queryParam["StackCode"].ToString(), queryParam["StackName"].ToString(), dt.Rows[0]["ID"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["Qu"].ToString(), queryParam["Pai"].ToString(), queryParam["Jia"].ToString(), queryParam["Ceng"].ToString(), queryParam["Ge"].ToString(), queryParam["WarehouseArea"].ToString());
  137. try
  138. {
  139. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  140. {
  141. }
  142. else
  143. {
  144. msg = "新增失败";
  145. }
  146. }
  147. catch (Exception ex)
  148. {
  149. throw new Exception(ex.Message);
  150. }
  151. return msg;
  152. }
  153. /// <summary>
  154. /// 新增超托库位
  155. /// </summary>
  156. /// <param name="queryJson"></param>
  157. /// <returns></returns>
  158. public string InsertOverLoadStack(string keyValue)
  159. {
  160. try
  161. {
  162. var queryParam = keyValue.ToJObject();
  163. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  164. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  165. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  166. string msg = "";
  167. //验证数据是否符合要求
  168. string overLoadCode = queryParam["LocationCode1"].ToString() + "," + queryParam["LocationCode2"].ToString();
  169. //if (overLoadCode!=null&&overLoadCode.Count!=2)
  170. //{
  171. // msg = "请输入两个符合要求的库位信息";
  172. // return msg;
  173. //}
  174. string checkSql = $@"IF EXISTS (SELECT ID FROM ICSLocation WHERE LocationCode='{queryParam["StackCode"]}')
  175. BEGIN
  176. RAISERROR('',16,1);
  177. RETURN
  178. END;
  179. IF EXISTS (SELECT ID FROM ICSLocationOverLoad WHERE LocationCode='{queryParam["LocationCode1"]}')
  180. BEGIN
  181. RAISERROR('1',16,1);
  182. RETURN
  183. END
  184. IF EXISTS (SELECT ID FROM ICSLocationOverLoad WHERE LocationCode='{queryParam["LocationCode2"]}')
  185. BEGIN
  186. RAISERROR('2',16,1);
  187. RETURN
  188. END
  189. SELECT * from ICSLocation WHERE LocationCode='{queryParam["LocationCode1"]}';SELECT * from ICSLocation WHERE LocationCode='{queryParam["LocationCode2"]}';";
  190. var dataSet = SqlHelper.GetDataSetBySql(checkSql);
  191. if (dataSet.Tables[0].Rows.Count == 0)
  192. {
  193. msg = "库位1编号不存在!";
  194. return msg;
  195. }
  196. if (dataSet.Tables[1].Rows.Count == 0)
  197. {
  198. msg = "库位2编号不存在!";
  199. return msg;
  200. }
  201. if (queryParam["LocationCode1"].ToString() == queryParam["LocationCode2"].ToString())
  202. {
  203. msg = "选择重复的库位!";
  204. return msg;
  205. }
  206. string StackSql = @"select * from ICSWarehouse where WarehouseCode='{0}' and WorkPoint='{1}'";
  207. StackSql = string.Format(StackSql, queryParam["Warehouse"].ToString(), WorkPoint);
  208. DataTable dt = SqlHelper.GetDataTableBySql(StackSql);
  209. string sql = string.Empty;
  210. sql = $@"INSERT INTO dbo.ICSLocation
  211. ( ID ,LocationCode ,LocationName ,WHID ,MUSER ,MUSERName ,MTIME ,WorkPoint ,Region,Row,GoodsShelf ,Tier,Grid,EATTRIBUTE1,StockInArea)
  212. Values(NEWID(),'{queryParam["StackCode"]}','{queryParam["StackName"]}','{dt.Rows[0]["ID"]}','{MUSER}','{MUSERNAME}',GETDATE(),'{WorkPoint}','{queryParam["Qu"]}','{queryParam["Pai"]}','{queryParam["Jia"]}','{queryParam["Ceng"]}','{queryParam["Ge"]}','{overLoadCode}','{queryParam["WarehouseArea"]}');
  213. INSERT INTO [dbo].[ICSLocationOverLoad] ([ID], [LocationCode], [OverLoadLocationCode], [WorkPoint], [MTIME], [MUSER], [MUSERNAME])
  214. VALUES (NEWID(), '{queryParam["LocationCode1"]}', '{overLoadCode}', '{WorkPoint}', GETDATE(), '{MUSER}', '{MUSERNAME}');
  215. INSERT INTO [dbo].[ICSLocationOverLoad] ([ID], [LocationCode], [OverLoadLocationCode], [WorkPoint], [MTIME], [MUSER], [MUSERNAME])
  216. VALUES (NEWID(), '{queryParam["LocationCode2"]}','{overLoadCode}', '{WorkPoint}',GETDATE(),'{MUSER}', '{MUSERNAME}');";
  217. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  218. {
  219. }
  220. else
  221. {
  222. msg = "新增超托库位失败";
  223. }
  224. return msg;
  225. }
  226. catch (Exception ex)
  227. {
  228. //throw new Exception(ex.Message);
  229. return ex.Message;
  230. }
  231. }
  232. /// <summary>
  233. /// 新增不良代码
  234. /// </summary>
  235. /// <param name="queryJson"></param>
  236. /// <returns></returns>
  237. public string InsertBadCode(string keyValue)
  238. {
  239. var queryParam = keyValue.ToJObject();
  240. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  241. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  242. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  243. string msg = "";
  244. string sql = string.Empty;
  245. sql = @"INSERT INTO dbo.ICSBadCode
  246. ( ID ,BadCode ,BadDesc ,MUSER ,
  247. MUSERName ,MTIME ,WorkPoint,BCGroupID ) Values(NEWID(),'{0}','{1}','{2}','{3}',GETDATE(),'{4}','NULL')";
  248. sql = string.Format(sql, queryParam["BadCode"].ToString(), queryParam["BadDesc"].ToString(), MUSER, MUSERNAME, WorkPoint);
  249. try
  250. {
  251. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  252. {
  253. }
  254. else
  255. {
  256. msg = "新增失败";
  257. }
  258. }
  259. catch (Exception ex)
  260. {
  261. throw new Exception(ex.Message);
  262. }
  263. return msg;
  264. }
  265. /// <summary>
  266. /// 修改不良代码
  267. /// </summary>
  268. /// <param name="queryJson"></param>
  269. /// <returns></returns>
  270. public string UpdateBadCode(string keyValue)
  271. {
  272. var queryParam = keyValue.ToJObject();
  273. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  274. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  275. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  276. string msg = "";
  277. string sql = string.Empty;
  278. sql = @"UPDATE dbo.ICSBadCode set BadCode='{0}',BadDesc='{1}',MUSER='{2}',MUSERName='{3}',MTIME=GetDate(),WorkPoint='{4}' WHERE ID='{5}'";
  279. sql = string.Format(sql, queryParam["BadCode"].ToString(), queryParam["BadDesc"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  280. try
  281. {
  282. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  283. {
  284. }
  285. else
  286. {
  287. msg = "新增失败";
  288. }
  289. }
  290. catch (Exception ex)
  291. {
  292. throw new Exception(ex.Message);
  293. }
  294. return msg;
  295. }
  296. /// <summary>
  297. /// 修改库位
  298. /// </summary>
  299. /// <param name="queryJson"></param>
  300. /// <returns></returns>
  301. public string UpdateStack(string keyValue)
  302. {
  303. var queryParam = keyValue.ToJObject();
  304. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  305. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  306. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  307. string msg = "";
  308. string StackSql = @"select * from ICSWarehouse where WarehouseCode='{0}' and WorkPoint='{1}'";
  309. StackSql = string.Format(StackSql, queryParam["Warehouse"].ToString(), WorkPoint);
  310. DataTable dt = SqlHelper.GetDataTableBySql(StackSql);
  311. string sql = string.Empty;
  312. sql = @"UPDATE dbo.ICSLocation set LocationCode='{0}',LocationName='{1}',WHID='{2}',MUSER='{3}',MUSERName='{4}',MTIME=GETDATE(),WorkPoint='{5}',Region='{7}',Row='{8}',GoodsShelf ='{9}',Tier='{10}',Grid='{11}',StockInArea='{12}' WHERE ID='{6}'";
  313. sql = string.Format(sql, queryParam["StackCode"].ToString(), queryParam["StackName"].ToString(), dt.Rows[0]["ID"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString(), queryParam["Qu"].ToString(), queryParam["Pai"].ToString(), queryParam["Jia"].ToString(), queryParam["Ceng"].ToString(), queryParam["Ge"].ToString(), queryParam["WarehouseArea"].ToString());
  314. try
  315. {
  316. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  317. {
  318. }
  319. else
  320. {
  321. msg = "修改失败";
  322. }
  323. }
  324. catch (Exception ex)
  325. {
  326. throw new Exception(ex.Message);
  327. }
  328. return msg;
  329. }
  330. /// <summary>
  331. /// 修改超托库位
  332. /// </summary>
  333. /// <param name="queryJson"></param>
  334. /// <returns></returns>
  335. public string UpdateOverLoadStack(string keyValue)
  336. {
  337. var queryParam = keyValue.ToJObject();
  338. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  339. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  340. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  341. string msg = "";
  342. string overLoadCode = queryParam["LocationCode1"].ToString() + "," + queryParam["LocationCode2"].ToString();
  343. string StackSql = @"select * from ICSWarehouse where WarehouseCode='{0}' and WorkPoint='{1}'";
  344. StackSql = string.Format(StackSql, queryParam["Warehouse"].ToString(), WorkPoint);
  345. DataTable dt = SqlHelper.GetDataTableBySql(StackSql);
  346. string sql = string.Empty;
  347. sql = @"UPDATE dbo.ICSLocation set LocationCode='{0}',LocationName='{1}',WHID='{2}',MUSER='{3}',MUSERName='{4}',MTIME=GETDATE(),WorkPoint='{5}',Region='{7}',Row='{8}',GoodsShelf ='{9}',Tier='{10}',Grid='{11}',EATTRIBUTE1='{12}',StockInArea='{13}' WHERE ID='{6}'";
  348. sql = string.Format(sql, queryParam["StackCode"].ToString(), queryParam["StackName"].ToString(), dt.Rows[0]["ID"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString(), queryParam["Qu"].ToString(), queryParam["Pai"].ToString(), queryParam["Jia"].ToString(), queryParam["Ceng"].ToString(), queryParam["Ge"].ToString(), overLoadCode, queryParam["WarehouseArea"].ToString());
  349. sql += $@"DELETE FROM ICSLocationOverLoad WHERE OverLoadLocationCode='{overLoadCode}' AND WorkPoint='{WorkPoint}';
  350. INSERT INTO [dbo].[ICSLocationOverLoad] ([ID], [LocationCode], [OverLoadLocationCode], [WorkPoint], [MTIME], [MUSER], [MUSERNAME])
  351. VALUES (NEWID(), '{queryParam["LocationCode1"]}', '{overLoadCode}', '{WorkPoint}', GETDATE(), '{MUSER}', '{MUSERNAME}');
  352. INSERT INTO [dbo].[ICSLocationOverLoad] ([ID], [LocationCode], [OverLoadLocationCode], [WorkPoint], [MTIME], [MUSER], [MUSERNAME])
  353. VALUES (NEWID(), '{queryParam["LocationCode2"]}','{overLoadCode}', '{WorkPoint}',GETDATE(),'{MUSER}', '{MUSERNAME}');";
  354. try
  355. {
  356. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  357. {
  358. }
  359. else
  360. {
  361. msg = "修改失败";
  362. }
  363. }
  364. catch (Exception ex)
  365. {
  366. throw new Exception(ex.Message);
  367. }
  368. return msg;
  369. }
  370. /// <summary>
  371. /// 新增类型
  372. /// </summary>
  373. /// <param name="queryJson"></param>
  374. /// <returns></returns>
  375. public string InsertICSType(string keyValue)
  376. {
  377. var queryParam = keyValue.ToJObject();
  378. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  379. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  380. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  381. string msg = "";
  382. string sql = string.Empty;
  383. sql = @"INSERT INTO dbo.ICSType
  384. ( ID ,TableCode ,ColumnCode ,Code,Name, Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
  385. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',GETDATE(),'{5}','{6}','{7}')
  386. ";
  387. sql = string.Format(sql, queryParam["TableCode"].ToString(), queryParam["ColumnCode"].ToString(), queryParam["Code"].ToString(), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint);
  388. try
  389. {
  390. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  391. {
  392. }
  393. else
  394. {
  395. msg = "新增失败";
  396. }
  397. }
  398. catch (Exception ex)
  399. {
  400. throw new Exception(ex.Message);
  401. }
  402. return msg;
  403. }
  404. /// <summary>
  405. /// 修改类型
  406. /// </summary>
  407. /// <param name="queryJson"></param>
  408. /// <returns></returns>
  409. public string UpdateICSType(string keyValue)
  410. {
  411. var queryParam = keyValue.ToJObject();
  412. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  413. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  414. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  415. string msg = "";
  416. string sql = string.Empty;
  417. sql = @"UPDATE dbo.ICSType set TableCode='{0}',ColumnCode='{1}',Code='{2}',Name='{3}',Enable='{4}',MTIME=GETDATE(),MUSER='{5}',MUSERName='{6}',WorkPoint='{7}' WHERE ID='{8}'";
  418. sql = string.Format(sql, queryParam["TableCode"].ToString(), queryParam["ColumnCode"].ToString(), queryParam["Code"].ToString(), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  419. try
  420. {
  421. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  422. {
  423. }
  424. else
  425. {
  426. msg = "修改失败";
  427. }
  428. }
  429. catch (Exception ex)
  430. {
  431. throw new Exception(ex.Message);
  432. }
  433. return msg;
  434. }
  435. /// <summary>
  436. /// 删除类型
  437. /// </summary>
  438. /// <param name="keyValue">传入ID</param>
  439. /// <returns></returns>
  440. public string DeleteICSType(string keyValue)
  441. {
  442. //站点信息
  443. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  444. string msg = "";
  445. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  446. string sql = string.Empty;
  447. sql = string.Format(@"DELETE FROM dbo.ICSType WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  448. try
  449. {
  450. SqlHelper.ExecuteNonQuery(sql);
  451. }
  452. catch (Exception ex)
  453. {
  454. throw new Exception(ex.Message);
  455. }
  456. return msg;
  457. }
  458. /// <summary>
  459. /// 修改参数配置
  460. /// </summary>
  461. /// <param name="queryJson"></param>
  462. /// <returns></returns>
  463. public string UpdateICSConfiguration(string keyValue)
  464. {
  465. var queryParam = keyValue.ToJObject();
  466. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  467. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  468. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  469. string msg = "";
  470. string sql = string.Empty;
  471. sql = @"UPDATE dbo.ICSConfiguration set Code='{0}',Name='{1}',Enable='{2}',Figure='{3}',MTIME=GETDATE(),MUSER='{4}',MUSERName='{5}',WorkPoint='{6}' WHERE ID='{7}'";
  472. sql = string.Format(sql, queryParam["Code"].ToString(), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), queryParam["Figure"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  473. try
  474. {
  475. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  476. {
  477. }
  478. else
  479. {
  480. msg = "修改失败";
  481. }
  482. }
  483. catch (Exception ex)
  484. {
  485. throw new Exception(ex.Message);
  486. }
  487. return msg;
  488. }
  489. /// <summary>
  490. /// 新增参数配置
  491. /// </summary>
  492. /// <param name="queryJson"></param>
  493. /// <returns></returns>
  494. public string InsertICSConfiguration(string keyValue)
  495. {
  496. var queryParam = keyValue.ToJObject();
  497. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  498. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  499. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  500. string msg = "";
  501. string sql = string.Empty;
  502. sql = @"INSERT INTO dbo.ICSConfiguration
  503. ( ID ,Code ,Name ,Enable,Figure,MTIME,MUSER ,MUSERName ,WorkPoint )
  504. Values(NEWID(),'{0}','{1}','{2}','{3}',GETDATE(),'{4}','{5}','{6}')
  505. ";
  506. sql = string.Format(sql, queryParam["Code"].ToString(), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), queryParam["Figure"].ToString(), MUSER, MUSERNAME, WorkPoint);
  507. try
  508. {
  509. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  510. {
  511. }
  512. else
  513. {
  514. msg = "新增失败";
  515. }
  516. }
  517. catch (Exception ex)
  518. {
  519. throw new Exception(ex.Message);
  520. }
  521. return msg;
  522. }
  523. /// <summary>
  524. /// 删除参数配置
  525. /// </summary>
  526. /// <param name="keyValue">传入ID</param>
  527. /// <returns></returns>
  528. public string DeleteICSConfiguration(string keyValue)
  529. {
  530. //站点信息
  531. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  532. string msg = "";
  533. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  534. string sql = string.Empty;
  535. sql = string.Format(@"DELETE FROM dbo.ICSConfiguration WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  536. try
  537. {
  538. SqlHelper.ExecuteNonQuery(sql);
  539. }
  540. catch (Exception ex)
  541. {
  542. throw new Exception(ex.Message);
  543. }
  544. return msg;
  545. }
  546. /// <summary>
  547. /// 修改启用配置
  548. /// </summary>
  549. /// <param name="queryJson"></param>
  550. /// <returns></returns>
  551. public string UpdateICSExtensionEnable(string keyValue)
  552. {
  553. var queryParam = keyValue.ToJObject();
  554. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  555. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  556. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  557. string msg = "";
  558. string sql = string.Empty;
  559. sql = @"UPDATE dbo.ICSExtensionEnable set ColCode='{0}',ColName='{1}',Enable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
  560. sql = string.Format(sql, queryParam["ColCode"].ToString(), queryParam["ColName"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  561. try
  562. {
  563. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  564. {
  565. }
  566. else
  567. {
  568. msg = "修改失败";
  569. }
  570. }
  571. catch (Exception ex)
  572. {
  573. throw new Exception(ex.Message);
  574. }
  575. return msg;
  576. }
  577. /// <summary>
  578. /// 新增启用配置
  579. /// </summary>
  580. /// <param name="queryJson"></param>
  581. /// <returns></returns>
  582. public string InsertICSExtensionEnable(string keyValue)
  583. {
  584. var queryParam = keyValue.ToJObject();
  585. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  586. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  587. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  588. string msg = "";
  589. string sql = string.Empty;
  590. sql = @"INSERT INTO dbo.ICSExtensionEnable
  591. ( ID ,ColCode ,ColName ,Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
  592. Values(NEWID(),'{0}','{1}','{2}',GETDATE(),'{3}','{4}','{5}')
  593. ";
  594. sql = string.Format(sql, queryParam["ColCode"].ToString(), queryParam["ColName"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint);
  595. try
  596. {
  597. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  598. {
  599. }
  600. else
  601. {
  602. msg = "新增失败";
  603. }
  604. }
  605. catch (Exception ex)
  606. {
  607. throw new Exception(ex.Message);
  608. }
  609. return msg;
  610. }
  611. /// <summary>
  612. /// 删除启用配置
  613. /// </summary>
  614. /// <param name="keyValue">传入ID</param>
  615. /// <returns></returns>
  616. public string DeleteICSExtensionEnable(string keyValue)
  617. {
  618. //站点信息
  619. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  620. string msg = "";
  621. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  622. string sql = string.Empty;
  623. sql = string.Format(@"DELETE FROM dbo.ICSExtensionEnable WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  624. try
  625. {
  626. SqlHelper.ExecuteNonQuery(sql);
  627. }
  628. catch (Exception ex)
  629. {
  630. throw new Exception(ex.Message);
  631. }
  632. return msg;
  633. }
  634. //不良代码
  635. public DataTable GetICSBadCodeGroup(ref Pagination jqgridparam, string queryJson)
  636. {
  637. DataTable dt = new DataTable();
  638. var queryParam = queryJson.ToJObject();
  639. List<DbParameter> parameter = new List<DbParameter>();
  640. string sql = @" select ID,BCGCode,BCGDesc,MUSER,MUSERName,MTIME from ICSBadCodeGroup ";
  641. sql += " WHERE 1=1";
  642. if (!string.IsNullOrWhiteSpace(queryJson))
  643. {
  644. if (!string.IsNullOrWhiteSpace(queryParam["BadCode"].ToString()))
  645. {
  646. sql += " and BCGCode like '%" + queryParam["BadCode"].ToString() + "%' ";
  647. }
  648. if (!string.IsNullOrWhiteSpace(queryParam["BadCodeName"].ToString()))
  649. {
  650. sql += " and BCGDesc like '%" + queryParam["BadCodeName"].ToString() + "%' ";
  651. }
  652. }
  653. sql = string.Format(sql);
  654. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  655. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  656. }
  657. //不良原因
  658. public DataTable GetICSBadReasonGroup(ref Pagination jqgridparam, string queryJson)
  659. {
  660. DataTable dt = new DataTable();
  661. var queryParam = queryJson.ToJObject();
  662. List<DbParameter> parameter = new List<DbParameter>();
  663. string sql = @" select ID,BRGCode,BRGDesc,MUSER,MUSERName,MTIME from ICSBadReasonGroup ";
  664. sql += " WHERE 1=1";
  665. if (!string.IsNullOrWhiteSpace(queryJson))
  666. {
  667. if (!string.IsNullOrWhiteSpace(queryParam["BadReason"].ToString()))
  668. {
  669. sql += " and BRGCode like '%" + queryParam["BadReason"].ToString() + "%' ";
  670. }
  671. if (!string.IsNullOrWhiteSpace(queryParam["BadReasonName"].ToString()))
  672. {
  673. sql += " and BRGDesc like '%" + queryParam["BadReasonName"].ToString() + "%' ";
  674. }
  675. }
  676. sql = string.Format(sql);
  677. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  678. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  679. }
  680. //不良代码子表
  681. public DataTable GetICSBadCodeGroupdetil(string ID, ref Pagination jqgridparam)
  682. {
  683. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  684. DataTable dt = new DataTable();
  685. //var queryParam = queryJson.ToJObject();
  686. List<DbParameter> parameter = new List<DbParameter>();
  687. string sql = @"select BCGroupID,BadCode,BadDesc,MUSERName,MTIME from ICSBadCode
  688. where BCGroupID='" + ID + "' ";
  689. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  690. }
  691. public DataTable GetICSBadCode(string BRGCode, ref Pagination jqgridparam)
  692. {
  693. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  694. DataTable dt = new DataTable();
  695. //var queryParam = queryJson.ToJObject();
  696. List<DbParameter> parameter = new List<DbParameter>();
  697. string sql = @"select BRGroupID,BadReasonCode,BadReasonDesc,MUSERName,MTIME from ICSBadReason
  698. WHERE BRGroupID='" + BRGCode + "' ";
  699. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  700. }
  701. /// <summary>
  702. /// 不良原因子表查询
  703. /// </summary>
  704. /// <param name="queryJson"></param>
  705. /// <param name="jqgridparam"></param>
  706. /// <returns></returns>
  707. public DataTable GetICSBadReason(string BRGCode, ref Pagination jqgridparam)
  708. {
  709. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  710. DataTable dt = new DataTable();
  711. //var queryParam = queryJson.ToJObject();
  712. List<DbParameter> parameter = new List<DbParameter>();
  713. string sql = @"select BRGroupID,BadReasonCode,BadReasonDesc,MUSERName,MTIME from ICSBadReason
  714. WHERE BRGroupID='" + BRGCode + "' ";
  715. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  716. }
  717. /// <summary>
  718. /// 不良原因子表查询2
  719. /// </summary>
  720. /// <param name="queryJson"></param>
  721. /// <param name="jqgridparam"></param>
  722. /// <returns></returns>
  723. public DataTable GetICSBadReason2(string BRGCode, ref Pagination jqgridparam)
  724. {
  725. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  726. DataTable dt = new DataTable();
  727. //var queryParam = queryJson.ToJObject();
  728. List<DbParameter> parameter = new List<DbParameter>();
  729. string sql = @"select BRGroupID,BadReasonCode,BadReasonDesc,MUSERName,MTIME from ICSBadReason
  730. WHERE BRGroupID='" + BRGCode + "' ";
  731. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  732. }
  733. public void DeleteBCItem(string ID)
  734. {
  735. string sql = "DELETE FROM dbo.ICSBadCode WHERE ID='" + ID + "'";
  736. SqlHelper.ExecuteNonQuery(sql);
  737. }
  738. public void DeleteItem(string ID)
  739. {
  740. string sql = "DELETE FROM dbo.ICSBadReason WHERE ID='" + ID + "'";
  741. SqlHelper.ExecuteNonQuery(sql);
  742. }
  743. //不良代码新增
  744. public void SubICSBadCodeGroupAdd(ICSBadReason main, string BRGCode, string BRGDesc)
  745. {
  746. string sql = string.Empty;
  747. string sqls = string.Empty;
  748. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  749. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  750. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  751. string NewID = Common.GuId();
  752. List<ICSBadReason> list_Item1 = new List<ICSBadReason>();
  753. if (main.arrayShellFabricItem != null)
  754. {
  755. list_Item1 = JsonConvert.DeserializeObject<List<ICSBadReason>>(main.arrayShellFabricItem);
  756. }
  757. string connString = SqlHelper.DataCenterConnString;
  758. SqlConnection conn = new SqlConnection(connString);
  759. conn.Open();
  760. SqlTransaction sqlTran = conn.BeginTransaction();
  761. SqlCommand cmd = new SqlCommand();
  762. cmd.Transaction = sqlTran;
  763. cmd.Connection = conn;
  764. sql = @"IF EXISTS( select BCGCode from ICSBadCodeGroup where BCGCode='{0}')
  765. BEGIN
  766. RAISERROR('',16,1);
  767. RETURN
  768. END
  769. INSERT INTO dbo.ICSBadCodeGroup
  770. ( ID ,BCGCode ,BCGDesc, MTIME,MUSER ,MUSERName ,WorkPoint )
  771. Values('{5}','{0}','{1}',GETDATE(),'{2}','{3}','{4}')";
  772. sql = string.Format(sql, BRGCode, BRGDesc, MUSER, MUSERNAME, WorkPoint, NewID);
  773. try
  774. {
  775. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  776. {
  777. foreach (ICSBadReason Item in list_Item1)
  778. {
  779. sqls = @"IF EXISTS( select BadCode from ICSBadCode where BadCode=@BadReasonCode)
  780. BEGIN
  781. RAISERROR('',16,1);
  782. RETURN
  783. END
  784. INSERT INTO dbo.ICSBadCode
  785. ( ID ,BCGroupID,BadCode ,BadDesc, MTIME,MUSER ,MUSERName ,WorkPoint )
  786. Values(@ID,'{0}',@BadReasonCode,@BadReasonDesc,GETDATE(),'{1}','{2}','{3}')";
  787. sqls = string.Format(sqls, NewID, MUSER, MUSERNAME, WorkPoint);
  788. SqlParameter[] sp_Item =
  789. {
  790. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  791. new SqlParameter("@BadReasonCode",DbType.String){ Value= Item.BadReasonCode},
  792. new SqlParameter("@BadReasonDesc",DbType.String){ Value= Item.BadReasonDesc},
  793. };
  794. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  795. }
  796. cmd.Transaction.Commit();
  797. }
  798. }
  799. catch (Exception ex)
  800. {
  801. cmd.Transaction.Rollback();
  802. throw new Exception(ex.Message);
  803. }
  804. finally
  805. {
  806. if (conn.State == ConnectionState.Open)
  807. {
  808. conn.Close();
  809. }
  810. conn.Dispose();
  811. }
  812. }
  813. //不良原因新增
  814. public void SubICSBadReasonGroupAdd(ICSBadReason main, string BRGCode, string BRGDesc)
  815. {
  816. string sql = string.Empty;
  817. string sqls = string.Empty;
  818. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  819. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  820. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  821. string NewID = Common.GuId();
  822. List<ICSBadReason> list_Item1 = new List<ICSBadReason>();
  823. if (main.arrayShellFabricItem != null)
  824. {
  825. list_Item1 = JsonConvert.DeserializeObject<List<ICSBadReason>>(main.arrayShellFabricItem);
  826. }
  827. string connString = SqlHelper.DataCenterConnString;
  828. SqlConnection conn = new SqlConnection(connString);
  829. conn.Open();
  830. SqlTransaction sqlTran = conn.BeginTransaction();
  831. SqlCommand cmd = new SqlCommand();
  832. cmd.Transaction = sqlTran;
  833. cmd.Connection = conn;
  834. sql = @"IF EXISTS( select BRGCode from ICSBadReasonGroup where BRGCode='{0}')
  835. BEGIN
  836. RAISERROR('',16,1);
  837. RETURN
  838. end
  839. INSERT INTO dbo.ICSBadReasonGroup
  840. ( ID ,BRGCode ,BRGDesc, MTIME,MUSER ,MUSERName ,WorkPoint )
  841. Values('{5}','{0}','{1}',GETDATE(),'{2}','{3}','{4}')";
  842. sql = string.Format(sql, BRGCode, BRGDesc, MUSER, MUSERNAME, WorkPoint, NewID);
  843. try
  844. {
  845. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  846. {
  847. foreach (ICSBadReason Item in list_Item1)
  848. {
  849. sqls = @"IF EXISTS(select BadReasonCode from ICSBadReason where BadReasonCode=@BadReasonCode)
  850. BEGIN
  851. RAISERROR('',16,1);
  852. RETURN
  853. end
  854. INSERT INTO dbo.ICSBadReason
  855. ( ID ,BRGroupID,BadReasonCode ,BadReasonDesc, MTIME,MUSER ,MUSERName ,WorkPoint )
  856. Values(@ID,'{0}',@BadReasonCode,@BadReasonDesc,GETDATE(),'{1}','{2}','{3}')";
  857. sqls = string.Format(sqls, NewID, MUSER, MUSERNAME, WorkPoint);
  858. SqlParameter[] sp_Item = {
  859. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  860. new SqlParameter("@BadReasonCode",DbType.String){ Value= Item.BadReasonCode},
  861. new SqlParameter("@BadReasonDesc",DbType.String){ Value= Item.BadReasonDesc},
  862. };
  863. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  864. }
  865. cmd.Transaction.Commit();
  866. }
  867. }
  868. catch (Exception ex)
  869. {
  870. cmd.Transaction.Rollback();
  871. throw new Exception(ex.Message);
  872. }
  873. finally
  874. {
  875. if (conn.State == ConnectionState.Open)
  876. {
  877. conn.Close();
  878. }
  879. conn.Dispose();
  880. }
  881. }
  882. public DataTable GetICSBadCodeGroupdetil2(string ID)
  883. {
  884. string sql = string.Empty;
  885. DataTable dt = null;
  886. sql = string.Format(@"select * from ICSBadCode where BCGroupID='{0}'", ID);
  887. dt = SqlHelper.GetDataTableBySql(sql);
  888. return dt;
  889. }
  890. public DataTable GetICSBadReason2(string BRGCode)
  891. {
  892. string sql = string.Empty;
  893. DataTable dt = null;
  894. sql = string.Format(@"select * from ICSBadReason where BRGroupID='{0}'", BRGCode);
  895. dt = SqlHelper.GetDataTableBySql(sql);
  896. return dt;
  897. }
  898. public void UpdateICSBadCodeGroup(ICSBadReason main, string BID, string BRGCode, string BRGDesc)
  899. {
  900. string sql = string.Empty;
  901. string sqls = string.Empty;
  902. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  903. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  904. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  905. List<ICSBadReason> list_Item1 = new List<ICSBadReason>();
  906. if (main.arrayShellFabricItem != null)
  907. {
  908. list_Item1 = JsonConvert.DeserializeObject<List<ICSBadReason>>(main.arrayShellFabricItem);
  909. }
  910. string connString = SqlHelper.DataCenterConnString;
  911. SqlConnection conn = new SqlConnection(connString);
  912. conn.Open();
  913. SqlTransaction sqlTran = conn.BeginTransaction();
  914. SqlCommand cmd = new SqlCommand();
  915. cmd.Transaction = sqlTran;
  916. cmd.Connection = conn;
  917. sql = @"UPDATE dbo.ICSBadCodeGroup set BCGCode='{0}',BCGDesc='{1}',MTIME=GETDATE(),MUSER='{2}',MUSERName='{3}',WorkPoint='{4}' WHERE ID='{5}'";
  918. sql = string.Format(sql, BRGCode, BRGDesc, MUSER, MUSERNAME, WorkPoint, BID);
  919. try
  920. {
  921. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  922. {
  923. foreach (ICSBadReason Item in list_Item1)
  924. {
  925. sqls = @" IF NOT EXISTS(SELECT * FROM ICSBadCode WHERE ID=@ID)
  926. BEGIN
  927. INSERT INTO ICSBadCode( ID,BCGroupID,BadCode,BadDesc,MTIME,MUSER,MUSERName,WorkPoint)
  928. VALUES (@ID,'{0}',@BadReasonCode,@BadReasonDesc,getdate(),'{1}','{2}','{3}')
  929. END
  930. ELSE
  931. BEGIN
  932. UPDATE dbo.ICSBadCode set BCGroupID='{0}',BadCode=@BadReasonCode,BadDesc=@BadReasonDesc,MTIME=GETDATE(),MUSER='{1}',MUSERName='{2}',WorkPoint='{3}' WHERE ID=@ID
  933. end
  934. ";
  935. sqls = string.Format(sqls, BID, MUSER, MUSERNAME, WorkPoint);
  936. SqlParameter[] sp_Item = {
  937. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  938. new SqlParameter("@BadReasonCode",DbType.String){ Value= Item.BadReasonCode},
  939. new SqlParameter("@BadReasonDesc",DbType.String){ Value= Item.BadReasonDesc},
  940. };
  941. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  942. }
  943. cmd.Transaction.Commit();
  944. }
  945. }
  946. catch (Exception ex)
  947. {
  948. cmd.Transaction.Rollback();
  949. throw new Exception(ex.Message);
  950. }
  951. finally
  952. {
  953. if (conn.State == ConnectionState.Open)
  954. {
  955. conn.Close();
  956. }
  957. conn.Dispose();
  958. }
  959. }
  960. public void UpdateICSBadReasonGroup(ICSBadReason main, string BID, string BRGCode, string BRGDesc)
  961. {
  962. string sql = string.Empty;
  963. string sqls = string.Empty;
  964. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  965. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  966. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  967. List<ICSBadReason> list_Item1 = new List<ICSBadReason>();
  968. if (main.arrayShellFabricItem != null)
  969. {
  970. list_Item1 = JsonConvert.DeserializeObject<List<ICSBadReason>>(main.arrayShellFabricItem);
  971. }
  972. string connString = SqlHelper.DataCenterConnString;
  973. SqlConnection conn = new SqlConnection(connString);
  974. conn.Open();
  975. SqlTransaction sqlTran = conn.BeginTransaction();
  976. SqlCommand cmd = new SqlCommand();
  977. cmd.Transaction = sqlTran;
  978. cmd.Connection = conn;
  979. sql = @"UPDATE dbo.ICSBadReasonGroup set BRGCode='{0}',BRGDesc='{1}',MTIME=GETDATE(),MUSER='{2}',MUSERName='{3}',WorkPoint='{4}' WHERE ID='{5}'";
  980. sql = string.Format(sql, BRGCode, BRGDesc, MUSER, MUSERNAME, WorkPoint, BID);
  981. try
  982. {
  983. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  984. {
  985. foreach (ICSBadReason Item in list_Item1)
  986. {
  987. sqls = @" IF NOT EXISTS(SELECT * FROM ICSBadReason WHERE ID=@ID)
  988. BEGIN
  989. INSERT INTO ICSBadReason( ID,BRGroupID,BadReasonCode,BadReasonDesc,MTIME,MUSER,MUSERName,WorkPoint)
  990. VALUES (@ID,'{0}',@BadReasonCode,@BadReasonDesc,getdate(),'{1}','{2}','{3}')
  991. END
  992. ELSE
  993. BEGIN
  994. UPDATE dbo.ICSBadReason set BRGroupID='{0}',BadReasonCode=@BadReasonCode,BadReasonDesc=@BadReasonDesc,MTIME=GETDATE(),MUSER='{1}',MUSERName='{2}',WorkPoint='{3}' WHERE ID=@ID
  995. end
  996. ";
  997. sqls = string.Format(sqls, BID, MUSER, MUSERNAME, WorkPoint);
  998. SqlParameter[] sp_Item = {
  999. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  1000. new SqlParameter("@BadReasonCode",DbType.String){ Value= Item.BadReasonCode},
  1001. new SqlParameter("@BadReasonDesc",DbType.String){ Value= Item.BadReasonDesc},
  1002. };
  1003. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  1004. }
  1005. cmd.Transaction.Commit();
  1006. }
  1007. }
  1008. catch (Exception ex)
  1009. {
  1010. cmd.Transaction.Rollback();
  1011. throw new Exception(ex.Message);
  1012. }
  1013. finally
  1014. {
  1015. if (conn.State == ConnectionState.Open)
  1016. {
  1017. conn.Close();
  1018. }
  1019. conn.Dispose();
  1020. }
  1021. }
  1022. /// <summary>
  1023. /// 删除不良代码组
  1024. /// </summary>
  1025. /// <param name="keyValue">传入ID</param>
  1026. /// <returns></returns>
  1027. public string DeleteICSBadCodeGroup(string keyValue)
  1028. {
  1029. //站点信息
  1030. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1031. string msg = "";
  1032. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1033. string sql = string.Empty;
  1034. sql += string.Format(@"DELETE FROM dbo.ICSBadCodeGroup WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1035. sql += string.Format(@"DELETE FROM dbo.ICSBadCode WHERE BCGroupID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1036. try
  1037. {
  1038. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1039. {
  1040. }
  1041. }
  1042. catch (Exception ex)
  1043. {
  1044. throw new Exception(ex.Message);
  1045. }
  1046. return msg;
  1047. }
  1048. /// <summary>
  1049. /// 删除不良原因组
  1050. /// </summary>
  1051. /// <param name="keyValue">传入ID</param>
  1052. /// <returns></returns>
  1053. public string DeleteICSBadReasonGroup(string keyValue)
  1054. {
  1055. //站点信息
  1056. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1057. string msg = "";
  1058. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1059. string sql = string.Empty;
  1060. sql += string.Format(@"DELETE FROM dbo.ICSBadReasonGroup WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1061. sql += string.Format(@"DELETE FROM dbo.ICSBadReason WHERE BRGroupID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1062. try
  1063. {
  1064. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1065. {
  1066. }
  1067. }
  1068. catch (Exception ex)
  1069. {
  1070. throw new Exception(ex.Message);
  1071. }
  1072. return msg;
  1073. }
  1074. /// <summary>
  1075. /// 初次加载查询检验项目组
  1076. /// </summary>
  1077. /// <param name="jqgridparam"></param>
  1078. /// <returns></returns>
  1079. public DataTable GetICSInspectionGroup(ref Pagination jqgridparam, string queryJson)
  1080. {
  1081. DataTable dt = new DataTable();
  1082. var queryParam = queryJson.ToJObject();
  1083. List<DbParameter> parameter = new List<DbParameter>();
  1084. string sql = @"select ID,GroupCode,GroupName,Enable,MUSER,MUSERName,MTIME from ICSInspectionGroup ";
  1085. sql += " WHERE 1=1";
  1086. if (!string.IsNullOrWhiteSpace(queryJson))
  1087. {
  1088. if (!string.IsNullOrWhiteSpace(queryParam["ListCode"].ToString()))
  1089. {
  1090. sql += " and GroupCode like '%" + queryParam["ListCode"].ToString() + "%' ";
  1091. }
  1092. if (!string.IsNullOrWhiteSpace(queryParam["ListName"].ToString()))
  1093. {
  1094. sql += " and GroupName like '%" + queryParam["ListName"].ToString() + "%' ";
  1095. }
  1096. }
  1097. sql = string.Format(sql);
  1098. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1099. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1100. }
  1101. /// <summary>
  1102. /// 检验项目子表查询
  1103. /// </summary>
  1104. /// <param name="queryJson"></param>
  1105. /// <param name="jqgridparam"></param>
  1106. /// <returns></returns>
  1107. public DataTable ICSInspectionList(string GroupCode, ref Pagination jqgridparam)
  1108. {
  1109. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1110. DataTable dt = new DataTable();
  1111. //var queryParam = queryJson.ToJObject();
  1112. List<DbParameter> parameter = new List<DbParameter>();
  1113. string sql = @"select GroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable,MUSERName,MTIME from ICSInspectionList
  1114. WHERE GroupID='" + GroupCode + "' ";
  1115. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1116. }
  1117. /// <summary>
  1118. /// 根据id删除自动表
  1119. /// </summary>
  1120. /// <param name="ID"></param>
  1121. public void DeleteList(string ID)
  1122. {
  1123. string sql = "DELETE FROM dbo.ICSInspectionList WHERE ID='" + ID + "'";
  1124. SqlHelper.ExecuteNonQuery(sql);
  1125. }
  1126. /// <summary>
  1127. /// 检查项目组修改
  1128. /// </summary>
  1129. /// <param name="main"></param>
  1130. /// <param name="BID"></param>
  1131. /// <param name="GroupCode"></param>
  1132. /// <param name="GroupName"></param>
  1133. /// <param name="Enable"></param>
  1134. public void UpdateICSInspectionGroup(ICSInspectionList main, string BID, string GroupCode, string GroupName, string Enable)
  1135. {
  1136. string sql = string.Empty;
  1137. string sqls = string.Empty;
  1138. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1139. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1140. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1141. List<ICSInspectionList> list_Item1 = new List<ICSInspectionList>();
  1142. if (main.arrayShellFabricItem != null)
  1143. {
  1144. list_Item1 = JsonConvert.DeserializeObject<List<ICSInspectionList>>(main.arrayShellFabricItem);
  1145. }
  1146. string connString = SqlHelper.DataCenterConnString;
  1147. SqlConnection conn = new SqlConnection(connString);
  1148. conn.Open();
  1149. SqlTransaction sqlTran = conn.BeginTransaction();
  1150. SqlCommand cmd = new SqlCommand();
  1151. cmd.Transaction = sqlTran;
  1152. cmd.Connection = conn;
  1153. sql = @"UPDATE dbo.ICSInspectionGroup set GroupCode='{0}',GroupName='{1}',Enable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
  1154. sql = string.Format(sql, GroupCode, GroupName, Enable, MUSER, MUSERNAME, WorkPoint, BID);
  1155. try
  1156. {
  1157. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1158. {
  1159. foreach (ICSInspectionList Item in list_Item1)
  1160. {
  1161. sqls = @" IF NOT EXISTS(SELECT * FROM ICSInspectionList WHERE ID=@ID)
  1162. BEGIN
  1163. INSERT INTO ICSInspectionList( ID,GroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable,MTIME,MUSER,MUSERName,WorkPoint)
  1164. VALUES (@ID,'{0}',@ListCode,@ListName,@Unit,@SetValueMax,@SetValueMin,@Enable,getdate(),'{1}','{2}','{3}')
  1165. END
  1166. ELSE
  1167. BEGIN
  1168. UPDATE dbo.ICSInspectionList set GroupID='{0}',ListCode=@ListCode,ListName=@ListName,Unit=@Unit,SetValueMax=@SetValueMax,SetValueMin=@SetValueMin,Enable=@Enable,MTIME=GETDATE(),MUSER='{1}',MUSERName='{2}',WorkPoint='{3}' WHERE ID=@ID
  1169. end
  1170. ";
  1171. sqls = string.Format(sqls, BID, MUSER, MUSERNAME, WorkPoint);
  1172. SqlParameter[] sp_Item = {
  1173. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  1174. new SqlParameter("@ListCode",DbType.String){ Value= Item.ListCode},
  1175. new SqlParameter("@ListName",DbType.String){ Value= Item.ListName},
  1176. new SqlParameter("@Unit",DbType.String){ Value= Item.Unit},
  1177. new SqlParameter("@SetValueMax",DbType.String){ Value= Item.SetValueMax},
  1178. new SqlParameter("@SetValueMin",DbType.String){ Value= Item.SetValueMin},
  1179. new SqlParameter("@Enable",DbType.String){ Value= Item.Enable},
  1180. };
  1181. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  1182. }
  1183. cmd.Transaction.Commit();
  1184. }
  1185. }
  1186. catch (Exception ex)
  1187. {
  1188. cmd.Transaction.Rollback();
  1189. throw new Exception(ex.Message);
  1190. }
  1191. finally
  1192. {
  1193. if (conn.State == ConnectionState.Open)
  1194. {
  1195. conn.Close();
  1196. }
  1197. conn.Dispose();
  1198. }
  1199. }
  1200. /// <summary>
  1201. /// 检查项目组新增
  1202. /// </summary>
  1203. /// <param name="main"></param>
  1204. /// <param name="BRGCode"></param>
  1205. /// <param name="BRGDesc"></param>
  1206. public void ICSInspectionGroupAdd(ICSInspectionList main, string GroupCode, string GroupName, string Enable)
  1207. {
  1208. string sql = string.Empty;
  1209. string sqls = string.Empty;
  1210. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1211. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1212. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1213. string ID = Guid.NewGuid().ToString();
  1214. List<ICSInspectionList> list_Item1 = new List<ICSInspectionList>();
  1215. if (main.arrayShellFabricItem != null)
  1216. {
  1217. list_Item1 = JsonConvert.DeserializeObject<List<ICSInspectionList>>(main.arrayShellFabricItem);
  1218. }
  1219. string connString = SqlHelper.DataCenterConnString;
  1220. SqlConnection conn = new SqlConnection(connString);
  1221. conn.Open();
  1222. SqlTransaction sqlTran = conn.BeginTransaction();
  1223. SqlCommand cmd = new SqlCommand();
  1224. cmd.Transaction = sqlTran;
  1225. cmd.Connection = conn;
  1226. sql = @"
  1227. IF EXISTS(select GroupCode from ICSInspectionGroup where GroupCode='{0}')
  1228. BEGIN
  1229. RAISERROR('',16,1);
  1230. RETURN
  1231. end
  1232. INSERT INTO dbo.ICSInspectionGroup
  1233. ( ID ,GroupCode ,GroupName,Enable, MTIME,MUSER ,MUSERName ,WorkPoint )
  1234. Values('{6}','{0}','{1}','{2}',GETDATE(),'{3}','{4}','{5}')";
  1235. sql = string.Format(sql, GroupCode, GroupName, Enable, MUSER, MUSERNAME, WorkPoint, ID);
  1236. try
  1237. {
  1238. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1239. {
  1240. foreach (ICSInspectionList Item in list_Item1)
  1241. {
  1242. sqls = @"
  1243. IF EXISTS(select ListCode from ICSInspectionList where ListCode=@ListCode)
  1244. BEGIN
  1245. RAISERROR('',16,1);
  1246. RETURN
  1247. end
  1248. INSERT INTO dbo.ICSInspectionList
  1249. ( ID ,GroupID,ListCode ,ListName, Unit,SetValueMax ,SetValueMin,Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
  1250. Values(@ID,'{0}',@ListCode,@ListName,@Unit,@SetValueMax,@SetValueMin,@Enable,getdate(),'{1}','{2}','{3}')";
  1251. sqls = string.Format(sqls, ID, MUSER, MUSERNAME, WorkPoint);
  1252. SqlParameter[] sp_Item = {
  1253. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  1254. new SqlParameter("@ListCode",DbType.String){ Value= Item.ListCode},
  1255. new SqlParameter("@ListName",DbType.String){ Value= Item.ListName},
  1256. new SqlParameter("@Unit",DbType.String){ Value= Item.Unit},
  1257. new SqlParameter("@SetValueMax",DbType.String){ Value= Item.SetValueMax},
  1258. new SqlParameter("@SetValueMin",DbType.String){ Value= Item.SetValueMin},
  1259. new SqlParameter("@Enable",DbType.String){ Value= Item.Enable},
  1260. };
  1261. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  1262. }
  1263. cmd.Transaction.Commit();
  1264. }
  1265. }
  1266. catch (Exception ex)
  1267. {
  1268. cmd.Transaction.Rollback();
  1269. throw new Exception(ex.Message);
  1270. }
  1271. finally
  1272. {
  1273. if (conn.State == ConnectionState.Open)
  1274. {
  1275. conn.Close();
  1276. }
  1277. conn.Dispose();
  1278. }
  1279. }
  1280. /// <summary>
  1281. /// 动态子表修改加载页面
  1282. /// </summary>
  1283. /// <param name="GroupCode"></param>
  1284. /// <returns></returns>
  1285. public DataTable ICSInspectionList2(string GroupCode)
  1286. {
  1287. string sql = string.Empty;
  1288. DataTable dt = null;
  1289. sql = string.Format(@"SELECT ID,GroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,
  1290. case when Enable='1' then '是' else '否' end as Enable,
  1291. MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1 FROM
  1292. dbo.ICSInspectionList where GroupID='{0}'", GroupCode);
  1293. dt = SqlHelper.GetDataTableBySql(sql);
  1294. return dt;
  1295. }
  1296. /// <summary>
  1297. /// 删除不良原因组
  1298. /// </summary>
  1299. /// <param name="keyValue">传入ID</param>
  1300. /// <returns></returns>
  1301. public string DeleteICSInspectionGroup(string keyValue)
  1302. {
  1303. //站点信息
  1304. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1305. string msg = "";
  1306. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1307. string sql = string.Empty;
  1308. string sqls = string.Empty;
  1309. sql = string.Format(@"DELETE FROM dbo.ICSInspectionGroup WHERE GroupCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1310. try
  1311. {
  1312. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1313. {
  1314. sqls = string.Format(@"DELETE FROM dbo.ICSInspectionList WHERE GroupID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1315. SqlHelper.ExecuteNonQuery(sqls);
  1316. }
  1317. }
  1318. catch (Exception ex)
  1319. {
  1320. throw new Exception(ex.Message);
  1321. }
  1322. return msg;
  1323. }
  1324. /// <summary>
  1325. /// 新增料品属性
  1326. /// </summary>
  1327. /// <param name="queryJson"></param>
  1328. /// <returns></returns>
  1329. public string InsertICSInventory(string keyValue)
  1330. {
  1331. var queryParam = keyValue.ToJObject();
  1332. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1333. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1334. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1335. string msg = "";
  1336. string sql = string.Empty;
  1337. sql = @"INSERT INTO dbo.ICSInventory
  1338. ( ID ,InvCode ,InvName ,InvDesc,InvStd,InvUnit,AmountUnit ,ClassCode ,ClassName ,InvRate,InvVersion,InvBrand,InvIQC ,InvFQC ,EffectiveEnable,EffectiveDays,BatchEnable,LotEnable ,PrintEnable ,WHUser,MTIME,MUSER ,MUSERName ,WorkPoint )
  1339. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}',GETDATE(),'{19}','{20}','{21}')
  1340. ";
  1341. sql = string.Format(sql,
  1342. queryParam["InvCode"].ToString(),
  1343. queryParam["InvName"].ToString(),
  1344. queryParam["InvDesc"].ToString(),
  1345. queryParam["InvStd"].ToString(),
  1346. queryParam["InvUnit"].ToString(),
  1347. queryParam["AmountUnit"].ToString(),
  1348. queryParam["ClassCode"].ToString(),
  1349. queryParam["ClassName"].ToString(),
  1350. queryParam["InvRate"].ToString(),
  1351. queryParam["InvVersion"].ToString(),
  1352. queryParam["InvBrand"].ToString(),
  1353. queryParam["InvIQC"].ToString(),
  1354. queryParam["InvFQC"].ToString(),
  1355. queryParam["EffectiveEnable"].ToString(),
  1356. queryParam["EffectiveDays"].ToString(),
  1357. queryParam["BatchEnable"].ToString(),
  1358. queryParam["LotEnable"].ToString(),
  1359. queryParam["PrintEnable"].ToString(),
  1360. queryParam["WHUser"].ToString(),
  1361. MUSER, MUSERNAME, WorkPoint);
  1362. try
  1363. {
  1364. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1365. {
  1366. }
  1367. else
  1368. {
  1369. msg = "新增失败";
  1370. }
  1371. }
  1372. catch (Exception ex)
  1373. {
  1374. throw new Exception(ex.Message);
  1375. }
  1376. return msg;
  1377. }
  1378. /// <summary>
  1379. /// 修改料品属性
  1380. /// </summary>
  1381. /// <param name="queryJson"></param>
  1382. /// <returns></returns>
  1383. public string UpdateICSInventory(string keyValue)
  1384. {
  1385. var queryParam = keyValue.ToJObject();
  1386. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1387. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1388. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1389. string msg = "";
  1390. string sql = string.Empty;
  1391. sql = @"UPDATE dbo.ICSInventory set
  1392. InvCode='{0}'
  1393. ,InvName='{1}'
  1394. ,InvDesc='{2}'
  1395. ,InvStd='{3}'
  1396. ,InvUnit='{4}'
  1397. ,AmountUnit='{5}'
  1398. ,ClassCode='{6}'
  1399. ,ClassName='{7}'
  1400. ,InvRate='{8}'
  1401. ,InvVersion='{9}'
  1402. ,InvBrand='{10}'
  1403. ,InvIQC='{11}'
  1404. ,InvFQC='{12}'
  1405. ,EffectiveEnable='{13}'
  1406. ,EffectiveDays='{14}'
  1407. ,BatchEnable='{15}'
  1408. ,LotEnable='{16}'
  1409. ,PrintEnable='{17}'
  1410. ,WHUser='{18}'
  1411. ,MTIME=GETDATE()
  1412. ,MUSER='{19}'
  1413. ,MUSERName='{20}'
  1414. ,WorkPoint='{21}'
  1415. WHERE ID='{22}'";
  1416. sql = string.Format(sql,
  1417. queryParam["InvCode"].ToString(),
  1418. queryParam["InvName"].ToString(),
  1419. queryParam["InvDesc"].ToString(),
  1420. queryParam["InvStd"].ToString(),
  1421. queryParam["InvUnit"].ToString(),
  1422. queryParam["AmountUnit"].ToString(),
  1423. queryParam["ClassCode"].ToString(),
  1424. queryParam["ClassName"].ToString(),
  1425. queryParam["InvRate"].ToString(),
  1426. queryParam["InvVersion"].ToString(),
  1427. queryParam["InvBrand"].ToString(),
  1428. queryParam["InvIQC"].ToString(),
  1429. queryParam["InvFQC"].ToString(),
  1430. queryParam["EffectiveEnable"].ToString(),
  1431. queryParam["EffectiveDays"].ToString(),
  1432. queryParam["BatchEnable"].ToString(),
  1433. queryParam["LotEnable"].ToString(),
  1434. queryParam["PrintEnable"].ToString(),
  1435. queryParam["WHUser"].ToString(),
  1436. MUSER, MUSERNAME, WorkPoint,
  1437. queryParam["ID"].ToString());
  1438. try
  1439. {
  1440. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1441. {
  1442. }
  1443. else
  1444. {
  1445. msg = "修改失败";
  1446. }
  1447. }
  1448. catch (Exception ex)
  1449. {
  1450. throw new Exception(ex.Message);
  1451. }
  1452. return msg;
  1453. }
  1454. /// <summary>
  1455. /// 获取下拉料品号获取其他信息
  1456. /// </summary>
  1457. public DataTable GetInputValue(string ID)
  1458. {
  1459. try
  1460. {
  1461. DataTable dt = new DataTable();
  1462. //var queryParam = queryJson.ToJObject();
  1463. List<DbParameter> parameter = new List<DbParameter>();
  1464. string sql = @"select InvCode,InvName,InvDesc,InvStd,InvUnit,AmountUnit, ClassCode,ClassName,InvRate,InvVersion,InvBrand,InvIQC,
  1465. InvFQC,EffectiveEnable,EffectiveDays,BatchEnable,LotEnable,PrintEnable,WHUser
  1466. from ICSInventory
  1467. WHERE 1=1 AND ID='{0}' ";
  1468. sql = string.Format(sql, ID);
  1469. return Repository().FindTableBySql(sql.ToString());
  1470. }
  1471. catch (Exception ex)
  1472. {
  1473. throw new Exception(ex.Message.ToString());
  1474. }
  1475. }
  1476. /// <summary>
  1477. /// 删除料品属性
  1478. /// </summary>
  1479. /// <param name="keyValue">传入ID</param>
  1480. /// <returns></returns>
  1481. public string DeleteICSInventory(string keyValue)
  1482. {
  1483. //站点信息
  1484. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1485. string msg = "";
  1486. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1487. string sql = string.Empty;
  1488. sql = string.Format(@"DELETE FROM dbo.ICSInventory WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1489. try
  1490. {
  1491. SqlHelper.ExecuteNonQuery(sql);
  1492. }
  1493. catch (Exception ex)
  1494. {
  1495. throw new Exception(ex.Message);
  1496. }
  1497. return msg;
  1498. }
  1499. /// <summary>
  1500. /// 获取料品信息
  1501. /// </summary>
  1502. /// <param name="jqgridparam"></param>
  1503. /// <returns></returns>
  1504. public DataTable GetICSInventoryInfo(string queryJson, ref Pagination jqgridparam)
  1505. {
  1506. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1507. DataTable dt = new DataTable();
  1508. var queryParam = queryJson.ToJObject();
  1509. List<DbParameter> parameter = new List<DbParameter>();
  1510. string sql = @"select ID, InvCode,InvName,InvDesc,InvStd,InvUnit,AmountUnit,ClassCode,ClassName,InvRate,InvVersion,InvBrand,
  1511. InvIQC,InvFQC,EffectiveEnable,EffectiveDays,BatchEnable,LotEnable,PrintEnable,WHUser
  1512. from ICSInventory where WorkPoint='{0}' ";
  1513. sql = string.Format(sql, WorkPoint);
  1514. if (!string.IsNullOrWhiteSpace(queryJson))
  1515. {
  1516. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1517. {
  1518. sql += " and InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1519. }
  1520. }
  1521. // DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1522. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1523. }
  1524. /// <summary>
  1525. /// 获取仓库信息
  1526. /// </summary>
  1527. /// <param name="jqgridparam"></param>
  1528. /// <returns></returns>
  1529. public DataTable GetICSWarehouseInfo(string queryJson, ref Pagination jqgridparam)
  1530. {
  1531. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1532. DataTable dt = new DataTable();
  1533. var queryParam = queryJson.ToJObject();
  1534. List<DbParameter> parameter = new List<DbParameter>();
  1535. string sql = @"select ID,WarehouseCode,WarehouseName ,Enable,BatchEnable,Asset,Proxy,InCost from ICSWarehouse where WorkPoint='{0}' ";
  1536. sql = string.Format(sql, WorkPoint);
  1537. if (!string.IsNullOrWhiteSpace(queryJson))
  1538. {
  1539. if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString()))
  1540. {
  1541. sql += " and WarehouseCode like '%" + queryParam["WHCode"].ToString() + "%' ";
  1542. }
  1543. }
  1544. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1545. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1546. }
  1547. /// <summary>
  1548. /// 新增料品仓库批次关系
  1549. /// </summary>
  1550. /// <param name="queryJson"></param>
  1551. /// <returns></returns>
  1552. public string InsertICSInventoryBatchEnable(string keyValue, string keyValue2)
  1553. {
  1554. List<string> InvCodeList = keyValue.Substring(1, keyValue.Length - 3).Split(',').ToList<string>();
  1555. List<string> WarehouseCodeList = keyValue2.Substring(1, keyValue2.Length - 3).Split(',').ToList<string>();
  1556. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1557. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1558. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1559. string msg = "";
  1560. string sql = string.Empty;
  1561. foreach (var item in InvCodeList)
  1562. {
  1563. foreach (var itemwh in WarehouseCodeList)
  1564. {
  1565. sql += @"IF EXISTS(select InvCode,WHCode from ICSInventoryBatchEnable where InvCode={0} and WHCode={1})
  1566. BEGIN
  1567. RAISERROR('',16,1);
  1568. RETURN
  1569. end
  1570. INSERT INTO dbo.ICSInventoryBatchEnable
  1571. ( ID ,InvCode ,WHCode ,BatchEnable,MTIME,MUSER ,MUSERName ,WorkPoint )
  1572. Values(NEWID(),{0},{1},'{2}',GETDATE(),'{3}','{4}','{5}')
  1573. ";
  1574. sql = string.Format(sql, item, itemwh, '1'.ToString(), MUSER, MUSERNAME, WorkPoint);
  1575. }
  1576. }
  1577. try
  1578. {
  1579. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1580. {
  1581. }
  1582. else
  1583. {
  1584. msg = "新增失败";
  1585. }
  1586. }
  1587. catch (Exception ex)
  1588. {
  1589. msg = ex.Message;
  1590. }
  1591. return msg;
  1592. }
  1593. /// <summary>
  1594. /// 修改料品仓库批次关系
  1595. /// </summary>
  1596. /// <param name="queryJson"></param>
  1597. /// <returns></returns>
  1598. public string UpdateICSInventoryBatchEnable(string keyValue)
  1599. {
  1600. var queryParam = keyValue.ToJObject();
  1601. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1602. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1603. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1604. string msg = "";
  1605. string sql = string.Empty;
  1606. sql = @"UPDATE dbo.ICSInventoryBatchEnable set InvCode='{0}',WHCode='{1}',BatchEnable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
  1607. sql = string.Format(sql, queryParam["InvCode"].ToString(), queryParam["WHCode"].ToString(), queryParam["BatchEnable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  1608. try
  1609. {
  1610. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1611. {
  1612. }
  1613. else
  1614. {
  1615. msg = "修改失败";
  1616. }
  1617. }
  1618. catch (Exception ex)
  1619. {
  1620. throw new Exception(ex.Message);
  1621. }
  1622. return msg;
  1623. }
  1624. /// <summary>
  1625. /// 删除料品仓库批次关系
  1626. /// </summary>
  1627. /// <param name="keyValue">传入ID</param>
  1628. /// <returns></returns>
  1629. public string DeleteICSInventoryBatchEnable(string keyValue)
  1630. {
  1631. //站点信息
  1632. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1633. string msg = "";
  1634. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1635. string sql = string.Empty;
  1636. sql = string.Format(@"DELETE FROM dbo.ICSInventoryBatchEnable WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1637. try
  1638. {
  1639. SqlHelper.ExecuteNonQuery(sql);
  1640. }
  1641. catch (Exception ex)
  1642. {
  1643. throw new Exception(ex.Message);
  1644. }
  1645. return msg;
  1646. }
  1647. /// <summary>
  1648. /// 获取库位信息
  1649. /// </summary>
  1650. /// <param name="jqgridparam"></param>
  1651. /// <returns></returns>
  1652. public DataTable GetICSLocation(string queryJson, ref Pagination jqgridparam)
  1653. {
  1654. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1655. DataTable dt = new DataTable();
  1656. var queryParam = queryJson.ToJObject();
  1657. List<DbParameter> parameter = new List<DbParameter>();
  1658. string sql = @"select ID,LocationCode,LocationName,WHID,MUSER,MUSERName,MTIME,WorkPoint from ICSLocation where WorkPoint='{0}' ";
  1659. sql = string.Format(sql, WorkPoint);
  1660. if (!string.IsNullOrWhiteSpace(queryJson))
  1661. {
  1662. if (!string.IsNullOrWhiteSpace(queryParam["LocationCode"].ToString()))
  1663. {
  1664. sql += " and LocationCode like '%" + queryParam["LocationCode"].ToString() + "%' ";
  1665. }
  1666. }
  1667. //DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1668. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1669. }
  1670. /// <summary>
  1671. /// 新增料品仓库批次关系
  1672. /// </summary>
  1673. /// <param name="queryJson"></param>
  1674. /// <returns></returns>
  1675. public string InsertICSInventoryLocation(string keyValue, string keyValue2)
  1676. {
  1677. List<string> InvCodeList = keyValue.Substring(1, keyValue.Length - 3).Split(',').ToList<string>();
  1678. List<string> LocationCodeList = keyValue2.Substring(1, keyValue2.Length - 3).Split(',').ToList<string>();
  1679. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1680. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1681. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1682. string msg = "";
  1683. string sql = string.Empty;
  1684. try
  1685. {
  1686. foreach (var item in InvCodeList)
  1687. {
  1688. foreach (var itemwh in LocationCodeList)
  1689. {
  1690. sql += @"IF EXISTS(select InvCode,LocationCode from ICSInventoryLocation where InvCode={0} and LocationCode={1})
  1691. BEGIN
  1692. RAISERROR('',16,1);
  1693. RETURN
  1694. end
  1695. INSERT INTO dbo.ICSInventoryLocation
  1696. ( ID ,InvCode ,LocationCode ,Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
  1697. Values(NEWID(),{0},{1},'{2}',GETDATE(),'{3}','{4}','{5}')
  1698. ";
  1699. sql = string.Format(sql, item, itemwh, '1'.ToString(), MUSER, MUSERNAME, WorkPoint);
  1700. }
  1701. }
  1702. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1703. {
  1704. }
  1705. else
  1706. {
  1707. msg = "新增失败";
  1708. }
  1709. }
  1710. catch (Exception ex)
  1711. {
  1712. msg = ex.Message;
  1713. }
  1714. return msg;
  1715. }
  1716. /// <summary>
  1717. /// 修改料品库位绑定关系
  1718. /// </summary>
  1719. /// <param name="queryJson"></param>
  1720. /// <returns></returns>
  1721. public string UpdateICSInventoryLocation(string keyValue)
  1722. {
  1723. var queryParam = keyValue.ToJObject();
  1724. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1725. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1726. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1727. string msg = "";
  1728. string sql = string.Empty;
  1729. sql = @"UPDATE dbo.ICSInventoryLocation set InvCode='{0}',LocationCode='{1}',Enable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
  1730. sql = string.Format(sql, queryParam["InvCode"].ToString(), queryParam["LocationCode"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  1731. try
  1732. {
  1733. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1734. {
  1735. }
  1736. else
  1737. {
  1738. msg = "修改失败";
  1739. }
  1740. }
  1741. catch (Exception ex)
  1742. {
  1743. throw new Exception(ex.Message);
  1744. }
  1745. return msg;
  1746. }
  1747. /// <summary>
  1748. /// 删除料品仓库批次关系
  1749. /// </summary>
  1750. /// <param name="keyValue">传入ID</param>
  1751. /// <returns></returns>
  1752. public string DeleteICSInventoryLocation(string keyValue)
  1753. {
  1754. //站点信息
  1755. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1756. string msg = "";
  1757. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1758. string sql = string.Empty;
  1759. sql = string.Format(@"DELETE FROM dbo.ICSInventoryLocation WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1760. try
  1761. {
  1762. SqlHelper.ExecuteNonQuery(sql);
  1763. }
  1764. catch (Exception ex)
  1765. {
  1766. throw new Exception(ex.Message);
  1767. }
  1768. return msg;
  1769. }
  1770. /// <summary>
  1771. /// 新增包装、容器
  1772. /// </summary>
  1773. /// <param name="queryJson"></param>
  1774. /// <returns></returns>
  1775. public string InsertICSContainer(string keyValue)
  1776. {
  1777. string msg = "";
  1778. try
  1779. {
  1780. var queryParam = keyValue.ToJObject();
  1781. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1782. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1783. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1784. string sql = string.Empty;
  1785. sql = @"IF EXISTS(select ContainerCODE from ICSContainer where ContainerCODE='{1}' )
  1786. RAISERROR('{1}',16,1)
  1787. else
  1788. INSERT INTO dbo.ICSContainer
  1789. ( ID ,ContainerID ,ContainerCODE ,ContainerName,Memo,MTIME,MUSER ,MUSERName ,WorkPoint )
  1790. Values(NEWID(),'{0}','{1}','{2}','{3}',GETDATE(),'{4}','{5}','{6}')
  1791. ";
  1792. sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["ContainerCODE"].ToString(), queryParam["ContainerName"].ToString(), queryParam["Memo"].ToString(), MUSER, MUSERNAME, WorkPoint);
  1793. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1794. {
  1795. }
  1796. else
  1797. {
  1798. msg = "新增失败";
  1799. }
  1800. }
  1801. catch (Exception ex)
  1802. {
  1803. throw new Exception(ex.Message);
  1804. }
  1805. return msg;
  1806. }
  1807. /// <summary>
  1808. /// 修改包装、容器
  1809. /// </summary>
  1810. /// <param name="queryJson"></param>
  1811. /// <returns></returns>
  1812. public string UpdateICSContainer(string keyValue)
  1813. {
  1814. var queryParam = keyValue.ToJObject();
  1815. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1816. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1817. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1818. string msg = "";
  1819. string sql = string.Empty;
  1820. sql = @" IF EXISTS(select ContainerCODE from ICSContainer where ContainerCODE='{1}' )
  1821. RAISERROR('{1}',16,1)
  1822. UPDATE dbo.ICSContainer set ContainerID='{0}',ContainerCODE='{1}',ContainerName='{2}',Memo='{3}',MTIME=GETDATE(),MUSER='{4}',MUSERName='{5}',WorkPoint='{6}' WHERE ID='{7}'";
  1823. sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["ContainerCODE"].ToString(), queryParam["ContainerName"].ToString(), queryParam["Memo"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  1824. try
  1825. {
  1826. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1827. {
  1828. }
  1829. else
  1830. {
  1831. msg = "修改失败";
  1832. }
  1833. }
  1834. catch (Exception ex)
  1835. {
  1836. msg = ex.Message;
  1837. }
  1838. return msg;
  1839. }
  1840. /// <summary>
  1841. /// 删除包装、容器
  1842. /// </summary>
  1843. /// <param name="keyValue">传入ID</param>
  1844. /// <returns></returns>
  1845. public string DeleteICSContainer(string keyValue)
  1846. {
  1847. //站点信息
  1848. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1849. string msg = "";
  1850. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1851. string sql = string.Empty;
  1852. sql = string.Format(@"DELETE FROM dbo.ICSContainer WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1853. try
  1854. {
  1855. SqlHelper.ExecuteNonQuery(sql);
  1856. }
  1857. catch (Exception ex)
  1858. {
  1859. throw new Exception(ex.Message);
  1860. }
  1861. return msg;
  1862. }
  1863. /// <summary>
  1864. /// 新增包装、容器关联条码
  1865. /// </summary>
  1866. /// <param name="queryJson"></param>
  1867. /// <returns></returns>
  1868. public string InsertICSContainerLot(string keyValue)
  1869. {
  1870. var queryParam = keyValue.ToJObject();
  1871. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1872. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1873. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1874. string msg = "";
  1875. string sql = string.Empty;
  1876. sql = @"INSERT INTO dbo.ICSContainerLot
  1877. ( ID ,ContainerID ,LotNo ,MTIME,MUSER ,MUSERName ,WorkPoint )
  1878. Values(NEWID(),'{0}','{1}',getdate(),'{2}','{3}','{4}')
  1879. ";
  1880. sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["LotNo"].ToString(), MUSER, MUSERNAME, WorkPoint);
  1881. try
  1882. {
  1883. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1884. {
  1885. }
  1886. else
  1887. {
  1888. msg = "新增失败";
  1889. }
  1890. }
  1891. catch (Exception ex)
  1892. {
  1893. throw new Exception(ex.Message);
  1894. }
  1895. return msg;
  1896. }
  1897. /// <summary>
  1898. /// 修改包装、容器
  1899. /// </summary>
  1900. /// <param name="queryJson"></param>
  1901. /// <returns></returns>
  1902. public string UpdateICSContainerLot(string keyValue)
  1903. {
  1904. var queryParam = keyValue.ToJObject();
  1905. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1906. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1907. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1908. string msg = "";
  1909. string sql = string.Empty;
  1910. sql = @"UPDATE dbo.ICSContainerLot set ContainerID='{0}',LotNo='{1}',MTIME=GETDATE(),MUSER='{2}',MUSERName='{3}',WorkPoint='{4}' WHERE ID='{5}'";
  1911. sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["LotNo"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  1912. try
  1913. {
  1914. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1915. {
  1916. }
  1917. else
  1918. {
  1919. msg = "修改失败";
  1920. }
  1921. }
  1922. catch (Exception ex)
  1923. {
  1924. throw new Exception(ex.Message);
  1925. }
  1926. return msg;
  1927. }
  1928. /// <summary>
  1929. /// 删除包装、容器
  1930. /// </summary>
  1931. /// <param name="keyValue">传入ID</param>
  1932. /// <returns></returns>
  1933. public string DeleteICSContainerLot(string keyValue)
  1934. {
  1935. //站点信息
  1936. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1937. string msg = "";
  1938. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1939. string sql = string.Empty;
  1940. sql = string.Format(@"DELETE FROM dbo.ICSContainerLot WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1941. try
  1942. {
  1943. SqlHelper.ExecuteNonQuery(sql);
  1944. }
  1945. catch (Exception ex)
  1946. {
  1947. throw new Exception(ex.Message);
  1948. }
  1949. return msg;
  1950. }
  1951. /// <summary>
  1952. /// 获取料品信息
  1953. /// </summary>
  1954. /// <returns></returns>
  1955. public DataTable GetInvCode()
  1956. {
  1957. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1958. string sql = @"
  1959. select '' as InvCode,'' as InvName
  1960. union all
  1961. SELECT InvCode,InvName FROM ICSInventory WITH (NOLOCK) WHERE 1=1 ";
  1962. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  1963. if (role != "admin")
  1964. {
  1965. sql += " and b.WorkPoint='" + WorkPoint + "'";
  1966. }
  1967. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  1968. return dt;
  1969. }
  1970. /// <summary>
  1971. /// 获取不良代码信息
  1972. /// </summary>
  1973. /// <returns></returns>
  1974. public DataTable GetBCGroup()
  1975. {
  1976. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1977. string sql = @"select '' as ID,'' as BCGDesc
  1978. union all
  1979. SELECT ID,BCGDesc FROM ICSBadCodeGroup WITH (NOLOCK) WHERE 1=1 ";
  1980. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  1981. if (role != "admin")
  1982. {
  1983. sql += " and b.WorkPoint='" + WorkPoint + "'";
  1984. }
  1985. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  1986. return dt;
  1987. }
  1988. /// <summary>
  1989. /// 获取不良原因信息
  1990. /// </summary>
  1991. /// <returns></returns>
  1992. public DataTable BRGroupID()
  1993. {
  1994. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1995. string sql = @"select '' as ID,'' as BRGDesc
  1996. union all
  1997. SELECT ID,BRGDesc FROM ICSBadReasonGroup WITH (NOLOCK) WHERE 1=1 ";
  1998. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  1999. if (role != "admin")
  2000. {
  2001. sql += " and b.WorkPoint='" + WorkPoint + "'";
  2002. }
  2003. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2004. return dt;
  2005. }
  2006. /// <summary>
  2007. /// 新增料品不良信息
  2008. /// </summary>
  2009. /// <param name="queryJson"></param>
  2010. /// <returns></returns>
  2011. public string InsertInventoryBadGroup(string keyValue)
  2012. {
  2013. var queryParam = keyValue.ToJObject();
  2014. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2015. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2016. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2017. string msg = "";
  2018. string sql = string.Empty;
  2019. sql = @"INSERT INTO dbo.ICSInventoryBadGroup
  2020. ( ID,InvCode,BCGroupID,BRGroupID,Enable,MUSER,MUSERName,MTIME,WorkPoint)
  2021. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}',getdate(),'{6}')";
  2022. sql = string.Format(sql, queryParam["InvCode"].ToString(), queryParam["BCGroupID"].ToString(), queryParam["BRGroupID"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint);
  2023. try
  2024. {
  2025. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2026. {
  2027. }
  2028. else
  2029. {
  2030. msg = "新增失败";
  2031. }
  2032. }
  2033. catch (Exception ex)
  2034. {
  2035. throw new Exception(ex.Message);
  2036. }
  2037. return msg;
  2038. }
  2039. /// <summary>
  2040. /// 修改料品不良信息
  2041. /// </summary>
  2042. /// <param name="queryJson"></param>
  2043. /// <returns></returns>
  2044. public string UpdateInventoryBadGroup(string keyValue)
  2045. {
  2046. var queryParam = keyValue.ToJObject();
  2047. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2048. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2049. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2050. string msg = "";
  2051. string sql = string.Empty;
  2052. sql = @"UPDATE dbo.ICSInventoryBadGroup set BCGroupID='{0}',BRGroupID='{1}',Enable='{2}',MUSER='{3}',MUSERName='{4}',MTIME=GetDate(),WorkPoint='{5}' WHERE ID='{6}'";
  2053. sql = string.Format(sql, queryParam["BCGroupID"].ToString(), queryParam["BRGroupID"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  2054. try
  2055. {
  2056. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2057. {
  2058. }
  2059. else
  2060. {
  2061. msg = "修改失败";
  2062. }
  2063. }
  2064. catch (Exception ex)
  2065. {
  2066. throw new Exception(ex.Message);
  2067. }
  2068. return msg;
  2069. }
  2070. /// <summary>
  2071. /// 删除料品不良信息
  2072. /// </summary>
  2073. /// <param name="keyValue">传入ID</param>
  2074. /// <returns></returns>
  2075. public string DeleteInventoryBadGroup(string keyValue)
  2076. {
  2077. //站点信息
  2078. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2079. string msg = "";
  2080. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2081. string sql = string.Empty;
  2082. sql = string.Format(@"DELETE FROM dbo.ICSInventoryBadGroup WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2083. try
  2084. {
  2085. SqlHelper.ExecuteNonQuery(sql);
  2086. }
  2087. catch (Exception ex)
  2088. {
  2089. throw new Exception(ex.Message);
  2090. }
  2091. return msg;
  2092. }
  2093. //库位导入
  2094. public string SetData_PR(String savePath)
  2095. {
  2096. //数据获取
  2097. try
  2098. {
  2099. int index = 1;
  2100. string msg = "";
  2101. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2102. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2103. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2104. SqlConnection conn = SqlHelper.GetDataCenterConn();
  2105. string sql = "";
  2106. int count = 0;
  2107. DataTable data = FileToExcel.ExcelToTable(savePath);
  2108. foreach (DataRow dr in data.Rows)
  2109. {
  2110. index++;
  2111. var StackCode = "";
  2112. var StackName = "";
  2113. //string GUID = Guid.NewGuid().ToString();
  2114. string KuFang = dr["库房编码"].ToString().Trim().ToUpper();
  2115. string Qu = dr["区域"].ToString().Trim().ToUpper();
  2116. string Pai = dr["区"].ToString().Trim().ToUpper();
  2117. string Jia = dr["货架"].ToString().Trim().ToUpper();
  2118. string Ceng = dr["层"].ToString().Trim().ToUpper();
  2119. string Ge = dr["列"].ToString().Trim().ToUpper();
  2120. string WarehouseArea = dr["窄巷道待入库区域"].ToString().Trim().ToUpper();
  2121. string StackCode1 = dr["库位1"].ToString().Trim().ToUpper();
  2122. string StackCode2 = dr["库位2"].ToString().Trim().ToUpper();//CutStringToSecondOccurrence
  2123. if (StackCode1 == StackCode2 && StackCode1 != "" && StackCode1 != null && StackCode2 != "" && StackCode2 != null)
  2124. {
  2125. throw new Exception("第 " + index + " 行绑定的超托库位为相同库位!");
  2126. }
  2127. if (CutStringToSecondOccurrence(StackCode1, '-') != CutStringToSecondOccurrence(StackCode2, '-'))
  2128. {
  2129. throw new Exception("第 " + index + " 行绑定的超托库位仓库或区域不一致!");
  2130. }
  2131. if ((String.IsNullOrEmpty(StackCode1) && !String.IsNullOrEmpty(StackCode2)) || (String.IsNullOrEmpty(StackCode2) && !String.IsNullOrEmpty(StackCode1)))
  2132. {
  2133. throw new Exception("第 " + index + " 行必须导入两个库位进行超托库位绑定!");
  2134. }
  2135. //超托库位编码
  2136. string OverLoadStackCode = string.Empty;
  2137. if (StackCode1 != "" && StackCode1 != null && StackCode2 != "" && StackCode2 != null)
  2138. {
  2139. OverLoadStackCode = StackCode1 + "," + StackCode2;
  2140. }
  2141. if (KuFang == "" || KuFang == null)
  2142. {
  2143. throw new Exception("第 " + index + " 行库房编码不能为空!");
  2144. }
  2145. if (Qu == "" && Pai == "" && Jia == "" && Ceng == "" && Ge == "")
  2146. {
  2147. throw new Exception("第 " + index + " 行区域、区、货架、层、列至少填写一项!");
  2148. }
  2149. string sqlWH = @"select ID from ICSWarehouse where WarehouseCode='{0}' and WorkPoint='{1}'";
  2150. sqlWH = string.Format(sqlWH, KuFang, WorkPoint);
  2151. DataTable dd = SqlHelper.CmdExecuteDataTable(sqlWH);
  2152. if (dd == null || dd.Rows.Count <= 0)
  2153. {
  2154. throw new Exception("库房编码: " + KuFang + " 不存在!");
  2155. }
  2156. if (!String.IsNullOrEmpty(OverLoadStackCode))
  2157. {
  2158. string sqlLocationCode = $@"IF NOT EXISTS (SELECT ID FROM ICSLocation WHERE LocationCode='{StackCode1}')
  2159. BEGIN
  2160. RAISERROR('{StackCode1}',16,1)
  2161. RETURN
  2162. END;
  2163. IF NOT EXISTS (SELECT ID FROM ICSLocation WHERE LocationCode='{StackCode2}')
  2164. BEGIN
  2165. RAISERROR('{StackCode2}',16,1)
  2166. RETURN
  2167. END;
  2168. IF EXISTS (SELECT ID FROM ICSLocationOverLoad WHERE (LocationCode='{StackCode1}' OR LocationCode='{StackCode2}') and WorkPoint='{WorkPoint}')
  2169. BEGIN
  2170. RAISERROR('{index}',16,1)
  2171. RETURN
  2172. END; ";
  2173. SqlHelper.ExecuteNonQuery(sqlLocationCode);
  2174. }
  2175. string WHID = dd.Rows[0]["ID"].ToString();
  2176. StackCode = KuFang;
  2177. StackName = KuFang + "仓库";
  2178. if (Qu != "")
  2179. {
  2180. StackCode += "-" + Qu;
  2181. StackName += Qu + "区域";
  2182. }
  2183. if (Pai != "")
  2184. {
  2185. StackCode += "-" + Pai;
  2186. StackName += Pai + "区";
  2187. }
  2188. if (Jia != "")
  2189. {
  2190. StackCode += "-" + Jia;
  2191. StackName += Jia + "货架";
  2192. }
  2193. if (Ceng != "")
  2194. {
  2195. StackCode += "-" + Ceng;
  2196. StackName += Ceng + "层";
  2197. }
  2198. if (Ge != "")
  2199. {
  2200. StackCode += "-" + Ge;
  2201. StackName += Ge + "列";
  2202. }
  2203. string sqls = @"select LocationCode from ICSLocation where LocationCode='{0}' and WorkPoint='{1}'";
  2204. sqls = string.Format(sqls, StackCode, WorkPoint);
  2205. DataTable dnum = SqlHelper.CmdExecuteDataTable(sqls);
  2206. if (dnum != null && dnum.Rows.Count > 0)
  2207. {
  2208. throw new Exception("库位: " + StackCode + " 已存在!");
  2209. }
  2210. else
  2211. {
  2212. sql += $@"INSERT INTO [dbo].[ICSLocation] ([ID], [LocationCode], [LocationName], [WHID], [MUSER], [MUSERName], [MTIME], [WorkPoint], [EATTRIBUTE1], [Region], [Row], [GoodsShelf ], [Tier], [Grid], [StockInArea], [Isoccupy])
  2213. VALUES (NEWID(), '{StackCode}', '{StackName}', '{WHID}', '{MUSER}', '{MUSERNAME}', getdate(), '{WorkPoint}', '{OverLoadStackCode}', '{Qu}', '{Pai}', '{Jia}', '{Ceng}', '{Ge}', '{WarehouseArea}', '');"
  2214. ;
  2215. if (!String.IsNullOrEmpty(OverLoadStackCode))
  2216. {
  2217. sql += $@"INSERT INTO [dbo].[ICSLocationOverLoad] ([ID], [LocationCode], [OverLoadLocationCode], [WorkPoint], [MTIME], [MUSER], [MUSERNAME], [EATTRIBUTE1], [EATTRIBUTE2], [EATTRIBUTE3], [EATTRIBUTE4], [EATTRIBUTE5])
  2218. VALUES (NEWID(), '{StackCode1}', '{OverLoadStackCode}', '{WorkPoint}', getdate(), '{MUSER}', '{MUSERNAME}', NULL, NULL, NULL, NULL, NULL);
  2219. INSERT INTO [dbo].[ICSLocationOverLoad] ([ID], [LocationCode], [OverLoadLocationCode], [WorkPoint], [MTIME], [MUSER], [MUSERNAME], [EATTRIBUTE1], [EATTRIBUTE2], [EATTRIBUTE3], [EATTRIBUTE4], [EATTRIBUTE5])
  2220. VALUES (NEWID(), '{StackCode2}', '{OverLoadStackCode}', '{WorkPoint}', getdate(), '{MUSER}', '{MUSERNAME}', NULL, NULL, NULL, NULL, NULL);";
  2221. }
  2222. //sql += @"Insert INto ICSLocation Values (newid(),'{0}','{1}','{2}','{3}','{4}',getdate(),'{5}','{12}','{6}','{7}','{8}','{9}','{10}','{11}',NULL)";
  2223. }
  2224. //sql = string.Format(sql, StackCode, StackName, WHID, MUSER, MUSERNAME, WorkPoint,Qu,Pai,Jia,Ceng,Ge,WarehouseArea, OverLoadStackCode);
  2225. }
  2226. count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2227. if (count > 0)
  2228. {
  2229. msg = "导入成功";
  2230. }
  2231. else
  2232. {
  2233. return "无有效的导入数据。";
  2234. }
  2235. return msg;
  2236. }
  2237. catch (Exception ex)
  2238. {
  2239. return ex.Message;
  2240. }
  2241. }
  2242. /// <summary>
  2243. /// 字符串截取方法,截取第二次特定字符之前的字符串
  2244. /// </summary>
  2245. /// <param name="str">截取字符串</param>
  2246. /// <param name="ch">字符</param>
  2247. /// <returns></returns>
  2248. public string CutStringToSecondOccurrence(string str, char ch)
  2249. {
  2250. int index1 = str.IndexOf(ch);
  2251. if (index1 == -1)
  2252. return str;
  2253. int index2 = str.IndexOf(ch, index1 + 1);
  2254. if (index2 == -1)
  2255. return str.Substring(0, index1); // 如果只找到一次指定字符
  2256. return str.Substring(0, index2);
  2257. }
  2258. /// <summary>
  2259. ///启用的料品库位绑定关系
  2260. /// </summary>
  2261. public string EnableInventoryLocation(string keyValue)
  2262. {
  2263. //站点信息
  2264. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2265. string msg = "";
  2266. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2267. string sql = string.Empty;
  2268. sql = string.Format(@"update ICSInventoryLocation set Enable='1' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2269. try
  2270. {
  2271. SqlHelper.ExecuteNonQuery(sql);
  2272. }
  2273. catch (Exception ex)
  2274. {
  2275. throw new Exception(ex.Message);
  2276. }
  2277. return msg;
  2278. }
  2279. /// <summary>
  2280. ///禁用的料品库位绑定关系
  2281. /// </summary>
  2282. public string ForbiddenInventoryLocation(string keyValue)
  2283. {
  2284. //站点信息
  2285. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2286. string msg = "";
  2287. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2288. string sql = string.Empty;
  2289. sql = string.Format(@"update ICSInventoryLocation set Enable='0' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2290. try
  2291. {
  2292. SqlHelper.ExecuteNonQuery(sql);
  2293. }
  2294. catch (Exception ex)
  2295. {
  2296. throw new Exception(ex.Message);
  2297. }
  2298. return msg;
  2299. }
  2300. /// <summary>
  2301. ///启用的料品仓库绑定关系
  2302. /// </summary>
  2303. public string EnableBatchEnable(string keyValue)
  2304. {
  2305. //站点信息
  2306. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2307. string msg = "";
  2308. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2309. string sql = string.Empty;
  2310. sql = string.Format(@"update ICSInventoryBatchEnable set BatchEnable='1' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2311. try
  2312. {
  2313. SqlHelper.ExecuteNonQuery(sql);
  2314. }
  2315. catch (Exception ex)
  2316. {
  2317. throw new Exception(ex.Message);
  2318. }
  2319. return msg;
  2320. }
  2321. /// <summary>
  2322. ///禁用的料品仓库绑定关系
  2323. /// </summary>
  2324. public string ForbiddenBatchEnable(string keyValue)
  2325. {
  2326. //站点信息
  2327. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2328. string msg = "";
  2329. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2330. string sql = string.Empty;
  2331. sql = string.Format(@"update ICSInventoryBatchEnable set BatchEnable='0' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2332. try
  2333. {
  2334. SqlHelper.ExecuteNonQuery(sql);
  2335. }
  2336. catch (Exception ex)
  2337. {
  2338. throw new Exception(ex.Message);
  2339. }
  2340. return msg;
  2341. }
  2342. public string CreateLableDataSource(string Sys_LableDataSource)
  2343. {
  2344. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2345. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2346. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2347. string msg = "";
  2348. string sql = string.Empty;
  2349. string SqlTxt = "";
  2350. JArray res = (JArray)JsonConvert.DeserializeObject(Sys_LableDataSource);
  2351. foreach (var item in res)
  2352. {
  2353. JObject jo = (JObject)item;
  2354. if (jo["DbParas"].ToString().Trim() != "")
  2355. {
  2356. string[] dbvs = jo["DbParas"].ToString().Trim().Split(',');
  2357. List<string> vs = new List<string>();
  2358. foreach (string s in dbvs)
  2359. {
  2360. if (!string.IsNullOrEmpty(s))
  2361. {
  2362. vs.Add(s);
  2363. }
  2364. }
  2365. SqlTxt = string.Format(jo["FormatSqlTxt"].ToString(), vs.ToArray());
  2366. }
  2367. else
  2368. {
  2369. SqlTxt = jo["FormatSqlTxt"].ToString();
  2370. }
  2371. sql += @"INSERT INTO dbo.Sys_LableDataSource
  2372. (ID,WorkPointCode,OtherDataBaseID,WorkPointDataFlag,SysDataFlag,SqlTxt,SourceName,FormatSqlTxt,Paras,DbParas,LinkCols,CreateUserID,CreateDate,ModifyUserID,ModifyDate,Link2Cols )
  2373. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',getdate(),'{11}',getdate(),'{12}')";
  2374. sql = string.Format(sql, WorkPoint, jo["OtherDataBaseID"].ToString(), jo["WorkPointDataFlag"].ToString(), jo["SysDataSourceFlag"].ToString(), SqlTxt, jo["SourceName"].ToString(), jo["FormatSqlTxt"].ToString(), jo["Paras"].ToString(), jo["DbParas"].ToString(), jo["LinkCols"].ToString(), MUSER, MUSER, jo["Link2Cols"].ToString());
  2375. }
  2376. try
  2377. {
  2378. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2379. {
  2380. }
  2381. else
  2382. {
  2383. msg = "新增失败";
  2384. }
  2385. }
  2386. catch (Exception ex)
  2387. {
  2388. throw new Exception(ex.Message);
  2389. }
  2390. return msg;
  2391. }
  2392. public DataTable GetTXT(string ID)
  2393. {
  2394. DataTable dt = new DataTable();
  2395. //var queryParam = queryJson.ToJObject();
  2396. List<DbParameter> parameter = new List<DbParameter>();
  2397. string sql = @"SELECT
  2398. ID,
  2399. WorkPointCode,
  2400. OtherDataBaseID,
  2401. WorkPointDataFlag,
  2402. SysDataFlag,
  2403. SqlTxt,
  2404. SourceName,
  2405. FormatSqlTxt,
  2406. Paras,
  2407. DbParas,
  2408. LinkCols,
  2409. CreateUserID,
  2410. CreateDate,
  2411. ModifyUserID,
  2412. ModifyDate,
  2413. Link2Cols
  2414. FROM
  2415. dbo.Sys_LableDataSource where ID='" + ID + "'";
  2416. return Repository().FindTableBySql(sql.ToString());
  2417. }
  2418. public string updateLableDataSource(string Sys_LableDataSource)
  2419. {
  2420. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2421. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2422. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2423. string msg = "";
  2424. string sql = string.Empty;
  2425. string SqlTxt = "";
  2426. JArray res = (JArray)JsonConvert.DeserializeObject(Sys_LableDataSource);
  2427. foreach (var item in res)
  2428. {
  2429. JObject jo = (JObject)item;
  2430. if (jo["DbParas"].ToString().Trim() != "")
  2431. {
  2432. string[] dbvs = jo["DbParas"].ToString().Trim().Split(',');
  2433. List<string> vs = new List<string>();
  2434. foreach (string s in dbvs)
  2435. {
  2436. if (!string.IsNullOrEmpty(s))
  2437. {
  2438. vs.Add(s);
  2439. }
  2440. }
  2441. SqlTxt = string.Format(jo["FormatSqlTxt"].ToString(), vs.ToArray());
  2442. }
  2443. else
  2444. {
  2445. SqlTxt = jo["FormatSqlTxt"].ToString();
  2446. }
  2447. sql += @"UPDATE dbo.Sys_LableDataSource set WorkPointCode='{0}',OtherDataBaseID='{1}',WorkPointDataFlag='{2}',SysDataFlag='{3}',SqlTxt='{4}',SourceName='{5}',FormatSqlTxt='{6}',Paras='{7}',DbParas='{8}',LinkCols='{9}',ModifyUserID='{10}',ModifyDate=getdate(),Link2Cols='{11}' WHERE ID='{12}'";
  2448. sql = string.Format(sql, WorkPoint, jo["OtherDataBaseID"].ToString(), jo["WorkPointDataFlag"].ToString(), jo["SysDataSourceFlag"].ToString(), SqlTxt, jo["SourceName"].ToString(), jo["FormatSqlTxt"].ToString(), jo["Paras"].ToString(), jo["DbParas"].ToString(), jo["LinkCols"].ToString(), MUSER, jo["Link2Cols"].ToString(), jo["ID"].ToString());
  2449. }
  2450. try
  2451. {
  2452. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2453. {
  2454. }
  2455. else
  2456. {
  2457. msg = "修改失败";
  2458. }
  2459. }
  2460. catch (Exception ex)
  2461. {
  2462. throw new Exception(ex.Message);
  2463. }
  2464. return msg;
  2465. }
  2466. public string DeleteLableDataSource(string keyValue)
  2467. {
  2468. //站点信息
  2469. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2470. string msg = "";
  2471. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2472. string sql = string.Empty;
  2473. sql = string.Format(@"DELETE FROM dbo.Sys_LableDataSource WHERE ID IN ({0}) ", keyValue.TrimEnd(','));
  2474. try
  2475. {
  2476. SqlHelper.ExecuteNonQuery(sql);
  2477. }
  2478. catch (Exception ex)
  2479. {
  2480. throw new Exception(ex.Message);
  2481. }
  2482. return msg;
  2483. }
  2484. public DataTable GetLableType()
  2485. {
  2486. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2487. string sql = @"
  2488. select '' as F_ItemCode,'' as F_ItemName
  2489. union all
  2490. SELECT DISTINCT a.F_ItemCode,isnull(a.F_ItemName,'') as F_ItemName FROM dbo.Sys_SRM_ItemsDetail a left join Sys_SRM_Items b on a.F_ItemId=b.F_Id where b.F_EnCode='BQ001'";
  2491. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  2492. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2493. return dt;
  2494. }
  2495. public DataTable GetSys_LablesID()
  2496. {
  2497. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2498. string sql = @"
  2499. select '' as ID,'' as LableName
  2500. union all
  2501. select distinct ID,LableName from Sys_Lables";
  2502. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  2503. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2504. return dt;
  2505. }
  2506. public string CreateLables(string txtLableName, string sel_LableType, string sel_LableSourceID)
  2507. {
  2508. string UserId = NFine.Code.OperatorProvider.Provider.GetCurrent().UserId;
  2509. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2510. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2511. string msg = "";
  2512. string sql = string.Empty;
  2513. string LableCode = "";
  2514. string SqlTxt = string.Format(@"SELECT MAX(A.LableCode) AS LableCode FROM Sys_Lables A "); ;
  2515. DataSet ds = SqlHelper.GetDataSetBySql(SqlTxt);
  2516. DataTable dts = ds.Tables[0];
  2517. if (dts != null && dts.Rows.Count > 0)
  2518. {
  2519. string lot = dts.Rows[0]["LableCode"].ToString();
  2520. LableCode = (Convert.ToInt64(lot) + 1).ToString().PadLeft(5, '0');
  2521. }
  2522. else
  2523. {
  2524. LableCode = "00001";
  2525. }
  2526. sql += @" INSERT INTO dbo.Sys_Lables
  2527. (ID,WorkPointCode,LableType,LableCode,LableName,LableXml,LableSourceID,CreateUserID,CreateDate,ModifyUserID,ModifyDate,FileAddress )
  2528. Values(NEWID(),'{0}','{1}','{2}','{3}','','{4}','{5}',getdate(),'{6}',getdate(),'')";
  2529. sql = string.Format(sql, WorkPoint, sel_LableType, LableCode, txtLableName, sel_LableSourceID, UserId, UserId);
  2530. try
  2531. {
  2532. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2533. {
  2534. }
  2535. else
  2536. {
  2537. msg = "新增失败";
  2538. }
  2539. }
  2540. catch (Exception ex)
  2541. {
  2542. throw new Exception(ex.Message);
  2543. }
  2544. return msg;
  2545. }
  2546. public DataTable GetLabelTXT(string ID)
  2547. {
  2548. DataTable dt = new DataTable();
  2549. //var queryParam = queryJson.ToJObject();
  2550. List<DbParameter> parameter = new List<DbParameter>();
  2551. string sql = @"select ID,WorkPointCode,LableType,LableCode,LableName,LableXml,LableSourceID,CreateUserID,CreateDate,ModifyUserID,ModifyDate,FileAddress from Sys_Lables where ID='" + ID + "'";
  2552. return Repository().FindTableBySql(sql.ToString());
  2553. }
  2554. public string updateLables(string ID, string txtLableName, string sel_LableType, string sel_LableSourceID)
  2555. {
  2556. string UserId = NFine.Code.OperatorProvider.Provider.GetCurrent().UserId;
  2557. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2558. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2559. string msg = "";
  2560. string sql = string.Empty;
  2561. sql += @"update Sys_Lables set LableType='{0}' ,LableName='{1}' ,LableSourceID='{2}',ModifyUserID='{3}',ModifyDate=getdate() where ID='{4}'";
  2562. sql = string.Format(sql, sel_LableType, txtLableName, sel_LableSourceID, UserId, ID);
  2563. try
  2564. {
  2565. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2566. {
  2567. }
  2568. else
  2569. {
  2570. msg = "修改失败";
  2571. }
  2572. }
  2573. catch (Exception ex)
  2574. {
  2575. throw new Exception(ex.Message);
  2576. }
  2577. return msg;
  2578. }
  2579. public string DeleteICSLabelTemplate(string keyValue)
  2580. {
  2581. //站点信息
  2582. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2583. string msg = "";
  2584. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2585. string sql = string.Empty;
  2586. sql = string.Format(@"DELETE FROM dbo.Sys_Lables WHERE ID IN ({0}) ", keyValue.TrimEnd(','));
  2587. try
  2588. {
  2589. SqlHelper.ExecuteNonQuery(sql);
  2590. }
  2591. catch (Exception ex)
  2592. {
  2593. throw new Exception(ex.Message);
  2594. }
  2595. return msg;
  2596. }
  2597. //获取父容器
  2598. public DataTable GetContainerID()
  2599. {
  2600. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2601. string sql = @"
  2602. select '' as ID,'' as ContainerName
  2603. union all
  2604. SELECT DISTINCT a.ID,a.ContainerName FROM dbo.ICSContainer a ";
  2605. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  2606. if (role != "admin")
  2607. {
  2608. sql += " and b.WorkPoint in(" + WorkPoint + ")";
  2609. }
  2610. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2611. return dt;
  2612. }
  2613. public int UpLoadLabelFile(string ID, string fileName)
  2614. {
  2615. DataTable dt = new DataTable();
  2616. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2617. string sql = "";
  2618. sql = string.Format(@"update Sys_Lables set FileAddress='{0}'
  2619. where ID='{1}'",
  2620. fileName, ID);
  2621. StringBuilder Str = new StringBuilder(sql);
  2622. return Repository().ExecuteBySql(Str);
  2623. }
  2624. public int UpLoadFiles(string LotNo, string fileName)
  2625. {
  2626. DataTable dt = new DataTable();
  2627. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2628. string sql = "";
  2629. sql = string.Format(@"update ICSInspection set FileName='{0}'
  2630. where LotNo='{1}' and Enable='1'",
  2631. fileName, LotNo);
  2632. StringBuilder Str = new StringBuilder(sql);
  2633. return Repository().ExecuteBySql(Str);
  2634. }
  2635. //包装容器
  2636. public DataTable GetSendContainer(ref Pagination jqgridparam, string queryJson)
  2637. {
  2638. DataTable dt = new DataTable();
  2639. var queryParam = queryJson.ToJObject();
  2640. List<DbParameter> parameter = new List<DbParameter>();
  2641. string sql = @"select top 0 ID,ContainerID,ContainerCode,ContainerName,Memo,MUSER,MUSERName,MTIME,WorkPoint from ICSContainer";
  2642. sql += " WHERE 1=1";
  2643. sql = string.Format(sql);
  2644. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2645. }
  2646. public DataTable GetContainerInfo(string Code)
  2647. {
  2648. DataTable dt = new DataTable();
  2649. //var queryParam = queryJson.ToJObject();
  2650. List<DbParameter> parameter = new List<DbParameter>();
  2651. string sql = @" select ID,ContainerID,ContainerCode,ContainerName,Memo,MUSER,MUSERName,MTIME,WorkPoint from ICSContainer where ContainerCode='{0}'";
  2652. sql = string.Format(sql, Code);
  2653. return Repository().FindTableBySql(sql.ToString());
  2654. }
  2655. public DataTable GetBindContainerID(string SireCode)
  2656. {
  2657. DataTable dt = new DataTable();
  2658. //var queryParam = queryJson.ToJObject();
  2659. List<DbParameter> parameter = new List<DbParameter>();
  2660. string sql = @" select ID from ICSContainer where ContainerCode='{0}'";
  2661. sql = string.Format(sql, SireCode);
  2662. return Repository().FindTableBySql(sql.ToString());
  2663. }
  2664. public string BindingContainerID(string ICSMTDOC, string SireID)
  2665. {
  2666. string msg = "";
  2667. try
  2668. {
  2669. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2670. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2671. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2672. string sql = string.Empty;
  2673. JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
  2674. foreach (var item in res)
  2675. {
  2676. JObject jo = (JObject)item;
  2677. sql += @"
  2678. IF NOT EXISTS(SELECT ContainerCode FROM ICSContainer WHERE ContainerCode='{1}' )
  2679. BEGIN
  2680. RAISERROR('{1} ',16,1);
  2681. RETURN
  2682. END
  2683. IF EXISTS(select ContainerID from ICSContainer where ContainerCode='{1}' and isnull(ContainerID,'')<>'')
  2684. BEGIN
  2685. RAISERROR('{1}',16,1);
  2686. RETURN
  2687. END
  2688. update ICSContainer set ContainerID='{0}' WHERE ContainerCode = '{1}' and WorkPoint ='{2}'";
  2689. sql = string.Format(sql, SireID, jo["ContainerCode"].ToString(), WorkPoint);
  2690. }
  2691. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  2692. {
  2693. }
  2694. else
  2695. {
  2696. msg = "绑定失败";
  2697. }
  2698. }
  2699. catch (Exception ex)
  2700. {
  2701. msg = ex.Message;
  2702. }
  2703. return msg;
  2704. }
  2705. //包装容器关联条码
  2706. public DataTable GetSendContainerLot(ref Pagination jqgridparam, string queryJson)
  2707. {
  2708. DataTable dt = new DataTable();
  2709. var queryParam = queryJson.ToJObject();
  2710. List<DbParameter> parameter = new List<DbParameter>();
  2711. string sql = @"
  2712. select top 0 a.ID, a.LotNo,a.InvCode,b.InvName,b.InvStd,b.InvUnit, a.ProductDate,a.Quantity from ICSInventoryLot a
  2713. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint";
  2714. sql = string.Format(sql);
  2715. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2716. }
  2717. public DataTable GetContainerLotInfo(string LotNo)
  2718. {
  2719. DataTable dt = new DataTable();
  2720. //var queryParam = queryJson.ToJObject();
  2721. List<DbParameter> parameter = new List<DbParameter>();
  2722. string sql = @" select a.ID, a.LotNo,a.InvCode,b.InvName,b.InvStd,b.InvUnit, a.ProductDate,a.Quantity from ICSInventoryLot a
  2723. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint where a.LotNo='{0}'";
  2724. sql = string.Format(sql, LotNo);
  2725. return Repository().FindTableBySql(sql.ToString());
  2726. }
  2727. public string BindingContainerLotID(string ICSMTDOC, string SireID, string SireCode)
  2728. {
  2729. string msg = "";
  2730. try
  2731. {
  2732. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2733. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2734. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2735. string sql = string.Empty;
  2736. JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
  2737. foreach (var item in res)
  2738. {
  2739. JObject jo = (JObject)item;
  2740. sql += @"
  2741. IF NOT EXISTS(SELECT ContainerCode FROM ICSContainer WHERE ContainerCode='{5}')
  2742. BEGIN
  2743. RAISERROR('{5} ',16,1);
  2744. RETURN
  2745. END
  2746. IF NOT EXISTS(select LotNo from ICSInventoryLot where LotNo='{1}')
  2747. BEGIN
  2748. RAISERROR('{1}',16,1);
  2749. RETURN
  2750. END
  2751. IF EXISTS(select LotNo from ICSContainerLot where LotNo ='{1}')
  2752. BEGIN
  2753. RAISERROR('{1}',16,1);
  2754. RETURN
  2755. END
  2756. INSERT INTO ICSContainerLot
  2757. (ID,ContainerID,LotNo,MUSER,MUSERName,WorkPoint,MTIME )
  2758. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',getdate())";
  2759. sql = string.Format(sql, SireID, jo["LotNo"].ToString(), MUSER, MUSERNAME, WorkPoint, SireCode);
  2760. }
  2761. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  2762. {
  2763. }
  2764. else
  2765. {
  2766. msg = "绑定失败";
  2767. }
  2768. }
  2769. catch (Exception ex)
  2770. {
  2771. msg = ex.Message;
  2772. }
  2773. return msg;
  2774. }
  2775. /// <summary>
  2776. /// 删除站点
  2777. /// </summary>
  2778. /// <param name="keyValue">传入ID</param>
  2779. /// <returns></returns>
  2780. public string DeleteWorkPoint(string keyValue)
  2781. {
  2782. //站点信息
  2783. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2784. string msg = "";
  2785. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2786. string sql = string.Empty;
  2787. sql = string.Format(@"DELETE FROM dbo.sys_WorkPoint WHERE ID IN ({0}) ", keyValue.TrimEnd(','), WorkPoint);
  2788. try
  2789. {
  2790. SqlHelper.ExecuteNonQuery(sql);
  2791. }
  2792. catch (Exception ex)
  2793. {
  2794. throw new Exception(ex.Message);
  2795. }
  2796. return msg;
  2797. }
  2798. /// <summary>
  2799. /// 新增站点
  2800. /// </summary>
  2801. /// <param name="queryJson"></param>
  2802. /// <returns></returns>
  2803. public string InsertWorkPoint(string keyValue)
  2804. {
  2805. var queryParam = keyValue.ToJObject();
  2806. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2807. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2808. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2809. string msg = "";
  2810. string sql = string.Empty;
  2811. string pwd = SqlHelper.ToMd5(queryParam["DataBasePwd"].ToString());
  2812. sql = @"INSERT INTO dbo.sys_WorkPoint
  2813. ( ID ,WorkPointCode ,WorkPointName ,ServerName,DataBaseName,DataBaseUser,DataBasePwd, StartFlag,CreateDate,CreateUserCode )
  2814. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}',GETDATE(),'{7}')
  2815. ";
  2816. sql = string.Format(sql, queryParam["WorkPointCode"].ToString(), queryParam["WorkPointName"].ToString(), queryParam["ServerName"].ToString(),
  2817. queryParam["DataBaseName"].ToString(), queryParam["DataBaseUser"].ToString(), pwd, queryParam["StartFlag"].ToString(), MUSER);
  2818. try
  2819. {
  2820. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2821. {
  2822. }
  2823. else
  2824. {
  2825. msg = "新增失败";
  2826. }
  2827. }
  2828. catch (Exception ex)
  2829. {
  2830. throw new Exception(ex.Message);
  2831. }
  2832. return msg;
  2833. }
  2834. /// <summary>
  2835. /// 修改站点
  2836. /// </summary>
  2837. /// <param name="queryJson"></param>
  2838. /// <returns></returns>
  2839. public string UpdateWorkPoint(string keyValue)
  2840. {
  2841. var queryParam = keyValue.ToJObject();
  2842. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2843. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2844. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2845. string msg = "";
  2846. string pwd = SqlHelper.ToMd5(queryParam["DataBasePwd"].ToString());
  2847. string sql = string.Empty;
  2848. sql = @"UPDATE dbo.sys_WorkPoint set WorkPointCode='{0}',WorkPointName='{1}',ServerName='{2}',DataBaseName='{3}',StartFlag='{4}'
  2849. ,DataBaseUser='{5}',DataBasePwd='{6}',ModifyDate=GETDATE(),ModifyUserCode='{7}' WHERE ID='{8}'";
  2850. sql = string.Format(sql, queryParam["WorkPointCode"].ToString(), queryParam["WorkPointName"].ToString(), queryParam["ServerName"].ToString(),
  2851. queryParam["DataBaseName"].ToString(), queryParam["StartFlag"].ToString(), queryParam["DataBaseUser"].ToString(), pwd
  2852. , MUSER, queryParam["ID"].ToString());
  2853. try
  2854. {
  2855. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2856. {
  2857. }
  2858. else
  2859. {
  2860. msg = "修改失败";
  2861. }
  2862. }
  2863. catch (Exception ex)
  2864. {
  2865. throw new Exception(ex.Message);
  2866. }
  2867. return msg;
  2868. }
  2869. public Sys_WorkPoint GetWorkPoint(string Id)
  2870. {
  2871. Sys_WorkPoint model = new Sys_WorkPoint();
  2872. string sql = string.Empty;
  2873. sql = string.Format(@"SELECT ID,
  2874. WorkPointCode,
  2875. WorkPointName,
  2876. ServerName,
  2877. DataBaseName,
  2878. DataBaseUser,
  2879. DataBasePwd,
  2880. StartFlag,
  2881. CreateUserCode,
  2882. CreateDate,
  2883. ModifyUserCode,
  2884. ModifyDate
  2885. FROM Sys_WorkPoint
  2886. WHERE ID='{0}'", Id);
  2887. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2888. if (dt != null && dt.Rows.Count > 0)
  2889. {
  2890. model.ID = dt.Rows[0]["ID"].ToString();
  2891. model.WorkPointCode = dt.Rows[0]["WorkPointCode"].ToString();
  2892. model.WorkPointName = dt.Rows[0]["WorkPointName"].ToString();
  2893. model.ServerName = dt.Rows[0]["ServerName"].ToString();
  2894. model.DataBaseName = dt.Rows[0]["DataBaseName"].ToString();
  2895. model.DataBaseUser = dt.Rows[0]["DataBaseUser"].ToString();
  2896. model.DataBasePwd = SqlHelper.FromMd5(dt.Rows[0]["DataBasePwd"].ToString());
  2897. model.StartFlag = dt.Rows[0]["StartFlag"].ToString();
  2898. }
  2899. return model;
  2900. }
  2901. public DataTable GetICSInventoryLotInfo(string ID)
  2902. {
  2903. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2904. DataTable dt = new DataTable();
  2905. //var queryParam = queryJson.ToJObject();
  2906. List<DbParameter> parameter = new List<DbParameter>();
  2907. string sql = @" SELECT a.ID,
  2908. a.LotNo,
  2909. a.InvCode,
  2910. a.ProductDate,
  2911. a.ExpirationDate,
  2912. a.Quantity,
  2913. a.Amount,
  2914. a.ExtensionID,
  2915. a.Type,
  2916. a.PrintTimes,
  2917. a.LastPrintUser,
  2918. a.LastPrintTime,
  2919. a.MUSER,
  2920. a.MUSERName,
  2921. a.MTIME,
  2922. a.WorkPoint,
  2923. a.EATTRIBUTE1,
  2924. b.InvName,
  2925. b.InvUnit,
  2926. c.Enable
  2927. FROM
  2928. dbo.ICSInventoryLot a left join ICSInventory b on a.InvCode=b.InvCode AND a.WorkPoint=b.WorkPoint
  2929. left join ICSInspection c on a.LotNo=c.LotNo AND a.WorkPoint=b.WorkPoint and c.Enable='1'
  2930. WHERE a.ID='" + ID + "'";
  2931. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2932. return Repository().FindTableBySql(sql.ToString());
  2933. }
  2934. public int UpdateExpirationDate(string ID, string ExpirationDate, string Inv, string LotNo, string InvCode, string Quantity)
  2935. {
  2936. decimal QualifiedQuantity = 0;
  2937. decimal UnqualifiedQuantity = 0;
  2938. if (Inv == "1") { QualifiedQuantity = Convert.ToDecimal(Quantity); } else { UnqualifiedQuantity = Convert.ToDecimal(Quantity); }
  2939. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2940. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2941. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2942. string sqls = string.Empty;
  2943. sqls = @"update ICSInspection set Enable='0' WHERE LotNO='{0}' and Enable='1' and WorkPoint='{1}'";
  2944. sqls = string.Format(sqls, LotNo, WorkPoint);
  2945. SqlHelper.CmdExecuteNonQueryLi(sqls);
  2946. string sql = string.Empty;
  2947. sql += @"UPDATE ICSInventoryLot SET ExpirationDate='{0}' where ID='{1}' AND WorkPoint='{2}'";
  2948. sql += @"INSERT INTO dbo.ICSInspection
  2949. ( ID ,LotNo ,InvCode ,Quantity,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,Type,Result,ExpirationDate,Enable,MUSER,MUSERName,MTIME,WorkPoint )
  2950. Values(NEWID(),'{3}','{4}','{5}','{6}','{7}',0,'4','{8}','{0}','1','{9}','{10}',GETDATE(),'{2}')";
  2951. sql = string.Format(sql, ExpirationDate, ID, WorkPoint, LotNo, InvCode, Quantity, QualifiedQuantity, UnqualifiedQuantity, Inv, MUSER, MUSERNAME);
  2952. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2953. return count;
  2954. }
  2955. //修改多语言
  2956. public string UpdateSys_Language(string keyValue)
  2957. {
  2958. var queryParam = keyValue.ToJObject();
  2959. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2960. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2961. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2962. string msg = "";
  2963. string sql = string.Empty;
  2964. sql = @"UPDATE Sys_Language set Code='{0}',CnValue='{1}',TwValue='{2}',EnValue='{3}' WHERE ID='{4}'";
  2965. sql = string.Format(sql, queryParam["Code"].ToString(), queryParam["CnValue"].ToString(), queryParam["TwValue"].ToString(), queryParam["EnValue"].ToString(), queryParam["ID"].ToString());
  2966. try
  2967. {
  2968. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2969. {
  2970. }
  2971. else
  2972. {
  2973. msg = "修改失败";
  2974. }
  2975. }
  2976. catch (Exception ex)
  2977. {
  2978. throw new Exception(ex.Message);
  2979. }
  2980. return msg;
  2981. }
  2982. //新增多语言
  2983. public string InsertSys_Language(string keyValue)
  2984. {
  2985. var queryParam = keyValue.ToJObject();
  2986. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2987. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2988. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2989. string msg = "";
  2990. string sql = string.Empty;
  2991. sql = @" IF EXISTS(SELECT * FROM Sys_Language WHERE Code='{0}' )
  2992. begin
  2993. RAISERROR('',16,1)
  2994. end
  2995. INSERT INTO Sys_Language
  2996. ( ID ,Code ,CnValue ,TwValue,EnValue )
  2997. Values(NEWID(),'{0}','{1}','{2}','{3}')
  2998. ";
  2999. sql = string.Format(sql, queryParam["Code"].ToString(), queryParam["CnValue"].ToString(), queryParam["TwValue"].ToString(), queryParam["EnValue"].ToString());
  3000. try
  3001. {
  3002. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  3003. {
  3004. }
  3005. else
  3006. {
  3007. msg = "新增失败";
  3008. }
  3009. }
  3010. catch (Exception ex)
  3011. {
  3012. throw new Exception(ex.Message);
  3013. }
  3014. return msg;
  3015. }
  3016. public string GetSerialCode(string workPointCode, string tbName, string colName, string Pre, int numLen)
  3017. {
  3018. string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}";
  3019. sql = string.Format(sql, new object[] { workPointCode, tbName, colName, Pre, numLen });
  3020. return DbHelper.ExecuteScalar(CommandType.Text, sql).ToString();
  3021. }
  3022. public DataTable GetSys_Language(string ID)
  3023. {
  3024. DataTable dt = new DataTable();
  3025. //var queryParam = queryJson.ToJObject();
  3026. List<DbParameter> parameter = new List<DbParameter>();
  3027. string sql = @"select ID,Code,CnValue,TwValue,EnValue from Sys_Language
  3028. WHERE 1 =1 and ID='" + ID + "' ";
  3029. return Repository().FindTableBySql(sql.ToString());
  3030. }
  3031. /// <summary>
  3032. /// 删除多语言
  3033. /// </summary>
  3034. /// <param name="keyValue">传入ID</param>
  3035. /// <returns></returns>
  3036. public string DeleteSys_Language(string keyValue)
  3037. {
  3038. string msg = "";
  3039. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  3040. string sql = string.Empty;
  3041. sql = string.Format(@"DELETE FROM Sys_Language WHERE ID IN ({0})", keyValue.TrimEnd(','));
  3042. try
  3043. {
  3044. SqlHelper.ExecuteNonQuery(sql);
  3045. }
  3046. catch (Exception ex)
  3047. {
  3048. throw new Exception(ex.Message);
  3049. }
  3050. return msg;
  3051. }
  3052. //料品检验项目
  3053. public DataTable GetICSInventoryInspectionGroup(ref Pagination jqgridparam, string queryJson)
  3054. {
  3055. DataTable dt = new DataTable();
  3056. var queryParam = queryJson.ToJObject();
  3057. List<DbParameter> parameter = new List<DbParameter>();
  3058. string sql = @"select ID,InvCode,GroupCode,GroupName,
  3059. case when Enable='1' then '是' else '否' end as Enable,
  3060. MUSER,MUSERName,MTIME,WorkPoint from ICSInventoryInspectionGroup ";
  3061. sql += " WHERE 1=1";
  3062. if (!string.IsNullOrWhiteSpace(queryJson))
  3063. {
  3064. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  3065. {
  3066. sql += " and InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  3067. }
  3068. if (!string.IsNullOrWhiteSpace(queryParam["GroupCode"].ToString()))
  3069. {
  3070. sql += " and GroupCode like '%" + queryParam["GroupCode"].ToString() + "%' ";
  3071. }
  3072. if (!string.IsNullOrWhiteSpace(queryParam["GroupName"].ToString()))
  3073. {
  3074. sql += " and GroupName like '%" + queryParam["GroupName"].ToString() + "%' ";
  3075. }
  3076. }
  3077. sql = string.Format(sql);
  3078. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  3079. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  3080. }
  3081. //料品检验项目子表
  3082. public DataTable ICSInventoryInspectionList(string ID, ref Pagination jqgridparam)
  3083. {
  3084. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3085. DataTable dt = new DataTable();
  3086. //var queryParam = queryJson.ToJObject();
  3087. List<DbParameter> parameter = new List<DbParameter>();
  3088. string sql = @" select ID,InvGroupID,ListCode,ListName,Unit,SetValueMax, SetValueMin,
  3089. CASE WHEN Enable=0 THEN '否' else '是' END Enable,
  3090. MUSERName,MTIME,WorkPoint from ICSInventoryInspectionList
  3091. WHERE InvGroupID='" + ID + "'";
  3092. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  3093. }
  3094. // 删除料品检验项目子表
  3095. public string DeleteICSInventoryInspectionGroup(string keyValue)
  3096. {
  3097. //站点信息
  3098. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3099. string msg = "";
  3100. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  3101. string sql = string.Empty;
  3102. sql += string.Format(@"DELETE FROM dbo.ICSInventoryInspectionGroup WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  3103. sql += string.Format(@"DELETE FROM dbo.ICSInventoryInspectionList WHERE InvGroupID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  3104. try
  3105. {
  3106. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  3107. {
  3108. }
  3109. }
  3110. catch (Exception ex)
  3111. {
  3112. throw new Exception(ex.Message);
  3113. }
  3114. return msg;
  3115. }
  3116. public DataTable Getinv(string invcode, ref Pagination jqgridparam)
  3117. {
  3118. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3119. List<DbParameter> parameter = new List<DbParameter>();
  3120. DataTable table = new DataTable();
  3121. string wherestr = "";
  3122. if (!string.IsNullOrEmpty(invcode))
  3123. {
  3124. wherestr += " and invcode like '%" + invcode + "%'";
  3125. }
  3126. string sql = "select ID,InvCode,InvName,InvDesc,InvUnit,WorkPoint from ICSInventory where workpoint='" + WorkPoint + "'" + wherestr;
  3127. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  3128. }
  3129. public DataTable GetGroupCode()
  3130. {
  3131. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3132. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  3133. string sql = @"select '' as ID,'' as GroupName
  3134. union all
  3135. SELECT distinct ID,GroupName FROM ICSInspectionGroup where WorkPoint='{0}'";
  3136. sql = string.Format(sql, WorkPoint);
  3137. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  3138. return dt;
  3139. }
  3140. public void DeleteINvItem(string ID)
  3141. {
  3142. string sql = "DELETE FROM dbo.ICSInventoryInspectionList WHERE ID='" + ID + "'";
  3143. SqlHelper.ExecuteNonQuery(sql);
  3144. }
  3145. public DataTable GetICSInventoryInspectionList(string ListCode, ref Pagination jqgridparam)
  3146. {
  3147. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3148. DataTable dt = new DataTable();
  3149. //var queryParam = queryJson.ToJObject();
  3150. List<DbParameter> parameter = new List<DbParameter>();
  3151. string sql = @"select ID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable,MUSERName,MTIME from ICSInventoryInspectionList
  3152. WHERE ListCode='" + ListCode + "' ";
  3153. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  3154. }
  3155. public DataTable GetInspectionListInfo(string ID)
  3156. {
  3157. DataTable dt = new DataTable();
  3158. //var queryParam = queryJson.ToJObject();
  3159. List<DbParameter> parameter = new List<DbParameter>();
  3160. string sql = @"
  3161. select ID,ListCode,ListName,Unit,SetValueMax,SetValueMin, CASE WHEN Enable=0 THEN '否' else '是' END Enable
  3162. from ICSInspectionList where GroupID='{0}'";
  3163. sql = string.Format(sql, ID);
  3164. return Repository().FindTableBySql(sql.ToString());
  3165. }
  3166. //新增
  3167. public void SubICSInventoryInspectionGroupAdd(ICSInventoryInspectionGroup main, string ID, string InvCode)
  3168. {
  3169. string sql = string.Empty;
  3170. string sqls = string.Empty;
  3171. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3172. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3173. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3174. string NewID = Common.GuId();
  3175. List<ICSInventoryInspectionGroup> list_Item1 = new List<ICSInventoryInspectionGroup>();
  3176. if (main.arrayShellFabricItem != null)
  3177. {
  3178. list_Item1 = JsonConvert.DeserializeObject<List<ICSInventoryInspectionGroup>>(main.arrayShellFabricItem);
  3179. }
  3180. string connString = SqlHelper.DataCenterConnString;
  3181. SqlConnection conn = new SqlConnection(connString);
  3182. conn.Open();
  3183. SqlTransaction sqlTran = conn.BeginTransaction();
  3184. SqlCommand cmd = new SqlCommand();
  3185. cmd.Transaction = sqlTran;
  3186. cmd.Connection = conn;
  3187. sql = @"
  3188. INSERT INTO dbo.ICSInventoryInspectionGroup
  3189. ( ID ,InvCode ,GroupCode ,GroupName ,
  3190. Enable ,MUSER ,MUSERName ,MTIME ,WorkPoint )
  3191. SELECT '{0}','{1}',GroupCode,GroupName,Enable,'{2}','{3}',getdate(),'{4}'
  3192. FROM dbo.ICSInspectionGroup
  3193. WHERE ID='{5}'";
  3194. sql = string.Format(sql, NewID, InvCode, MUSER, MUSERNAME, WorkPoint, ID);
  3195. try
  3196. {
  3197. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  3198. {
  3199. foreach (ICSInventoryInspectionGroup Item in list_Item1)
  3200. {
  3201. sqls = @"
  3202. INSERT INTO dbo.ICSInventoryInspectionList
  3203. ( ID ,InvGroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable , MTIME,MUSER ,MUSERName ,WorkPoint )
  3204. Values(@ID,'{0}',@ListCode,@ListName,@Unit,@SetValueMax,@SetValueMin,@Enable,GETDATE(),'{1}','{2}','{3}')";
  3205. sqls = string.Format(sqls, NewID, MUSER, MUSERNAME, WorkPoint);
  3206. SqlParameter[] sp_Item = {
  3207. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  3208. new SqlParameter("@ListCode",DbType.String){ Value= Item.ListCode},
  3209. new SqlParameter("@ListName",DbType.String){ Value= Item.ListName},
  3210. new SqlParameter("@Unit",DbType.String){ Value= Item.Unit},
  3211. new SqlParameter("@SetValueMax",DbType.String){ Value= Item.SetValueMax},
  3212. new SqlParameter("@SetValueMin",DbType.String){ Value= Item.SetValueMin},
  3213. new SqlParameter("@Enable",DbType.String){ Value= Item.Enable},
  3214. };
  3215. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  3216. }
  3217. cmd.Transaction.Commit();
  3218. }
  3219. }
  3220. catch (Exception ex)
  3221. {
  3222. cmd.Transaction.Rollback();
  3223. throw new Exception(ex.Message);
  3224. }
  3225. finally
  3226. {
  3227. if (conn.State == ConnectionState.Open)
  3228. {
  3229. conn.Close();
  3230. }
  3231. conn.Dispose();
  3232. }
  3233. }
  3234. public DataTable GetICSInventoryInspectionList2(string BID)
  3235. {
  3236. string sql = string.Empty;
  3237. DataTable dt = null;
  3238. sql = string.Format(@" select ID,ListCode,ListName,Unit,SetValueMax,SetValueMin, CASE WHEN Enable='1' THEN '是' else '否' END Enable from ICSInventoryInspectionList where InvGroupID='{0}'", BID);
  3239. dt = SqlHelper.GetDataTableBySql(sql);
  3240. return dt;
  3241. }
  3242. //修改
  3243. public void UpdateICSInventoryInspectionGroup(ICSInventoryInspectionGroup main, string BID, string ID, string InvCode)
  3244. {
  3245. string sql = string.Empty;
  3246. string sqls = string.Empty;
  3247. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3248. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3249. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3250. List<ICSInventoryInspectionGroup> list_Item1 = new List<ICSInventoryInspectionGroup>();
  3251. if (main.arrayShellFabricItem != null)
  3252. {
  3253. list_Item1 = JsonConvert.DeserializeObject<List<ICSInventoryInspectionGroup>>(main.arrayShellFabricItem);
  3254. }
  3255. string connString = SqlHelper.DataCenterConnString;
  3256. SqlConnection conn = new SqlConnection(connString);
  3257. conn.Open();
  3258. SqlTransaction sqlTran = conn.BeginTransaction();
  3259. SqlCommand cmd = new SqlCommand();
  3260. cmd.Transaction = sqlTran;
  3261. cmd.Connection = conn;
  3262. sql = @"update b set b.InvCode='{0}',b.GroupCode=a.GroupCode,b.GroupName=a.GroupName,b.Enable=a.Enable,b.MTIME=GETDATE(),b.MUSER='{1}',b.MUSERName='{2}',b.WorkPoint='{3}' from ICSInspectionGroup a ,ICSInventoryInspectionGroup b where a.ID='{4}' and b.ID='{5}'";
  3263. sql = string.Format(sql, InvCode, MUSER, MUSERNAME, WorkPoint, ID, BID);
  3264. try
  3265. {
  3266. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  3267. {
  3268. foreach (ICSInventoryInspectionGroup Item in list_Item1)
  3269. {
  3270. sqls = @" IF NOT EXISTS(SELECT * FROM ICSInventoryInspectionList WHERE ID=@ID)
  3271. BEGIN
  3272. INSERT INTO dbo.ICSInventoryInspectionList
  3273. ( ID ,InvGroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable , MTIME,MUSER ,MUSERName ,WorkPoint )
  3274. Values(@ID,'{0}',@ListCode,@ListName,@Unit,@SetValueMax,@SetValueMin,@Enable,GETDATE(),'{1}','{2}','{3}')
  3275. END
  3276. ELSE
  3277. BEGIN
  3278. UPDATE dbo.ICSInventoryInspectionList set InvGroupID='{0}',ListCode=@ListCode,ListName=@ListName,Unit=@Unit,SetValueMax=@SetValueMax,SetValueMin=@SetValueMin,Enable=@Enable,MTIME=GETDATE(),MUSER='{1}',MUSERName='{2}',WorkPoint='{3}' WHERE ID=@ID
  3279. end
  3280. ";
  3281. sqls = string.Format(sqls, BID, MUSER, MUSERNAME, WorkPoint);
  3282. SqlParameter[] sp_Item = {
  3283. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  3284. new SqlParameter("@ListCode",DbType.String){ Value= Item.ListCode},
  3285. new SqlParameter("@ListName",DbType.String){ Value= Item.ListName},
  3286. new SqlParameter("@Unit",DbType.String){ Value= Item.Unit},
  3287. new SqlParameter("@SetValueMax",DbType.String){ Value= Item.SetValueMax},
  3288. new SqlParameter("@SetValueMin",DbType.String){ Value= Item.SetValueMin},
  3289. new SqlParameter("@Enable",DbType.String){ Value= Item.Enable},
  3290. };
  3291. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  3292. }
  3293. cmd.Transaction.Commit();
  3294. }
  3295. }
  3296. catch (Exception ex)
  3297. {
  3298. cmd.Transaction.Rollback();
  3299. throw new Exception(ex.Message);
  3300. }
  3301. finally
  3302. {
  3303. if (conn.State == ConnectionState.Open)
  3304. {
  3305. conn.Close();
  3306. }
  3307. conn.Dispose();
  3308. }
  3309. }
  3310. //同步检验合格单
  3311. public string SyncDNDoc(string DocNO, string StartDate)
  3312. {
  3313. DataTable dt = new DataTable();
  3314. var queryParam = "";
  3315. List<DbParameter> parameter = new List<DbParameter>();
  3316. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3317. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3318. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3319. string sql = "";
  3320. SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECK client = new SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECK();
  3321. SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECK1 Info = new SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECK1();
  3322. if (DocNO != "")
  3323. {
  3324. Info.PRUEFLOS = DocNO;
  3325. Info.CHG_DATE = "";
  3326. }
  3327. if (StartDate != "")
  3328. {
  3329. Info.PRUEFLOS = "";
  3330. Info.CHG_DATE = StartDate;
  3331. }
  3332. if (DocNO == "" && StartDate == "")
  3333. {
  3334. Info.PRUEFLOS = "";
  3335. Info.CHG_DATE = DateTime.Now.Year + "-" + DateTime.Now.Month.ToString().PadLeft(2, '0') + "-" + DateTime.Now.Day.ToString().PadLeft(2, '0');
  3336. }
  3337. Info.WERKS = WorkPoint;
  3338. Info.ZCHECK_HEAD = new SAPGetChkDocInfoZS.ZWMS_SK_CHECK_HEAD[1];
  3339. Info.ZCHECK_ITEM = new SAPGetChkDocInfoZS.ZWMS_SK_CHECK_ITEM[1];
  3340. SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECKResponse result = new SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECKResponse();
  3341. client.Timeout = 300000;
  3342. result = client.CallZWMS_SK_WS_CHECK(Info);
  3343. List<SAPGetChkDocInfoZS.ZWMS_SK_CHECK_ITEM> ItemInfoList = new List<SAPGetChkDocInfoZS.ZWMS_SK_CHECK_ITEM>();
  3344. ItemInfoList.AddRange(result.ZCHECK_ITEM);
  3345. foreach (SAPGetChkDocInfoZS.ZWMS_SK_CHECK_HEAD HeadInfo in result.ZCHECK_HEAD)
  3346. {
  3347. string LineNum = "10";
  3348. var ItemInfo = ItemInfoList.Where(a => a.PRUEFLOS == HeadInfo.PRUEFLOS);
  3349. foreach (SAPGetChkDocInfoZS.ZWMS_SK_CHECK_ITEM Item in ItemInfo)
  3350. {
  3351. string ExtensionID = "";
  3352. bool isNew = false;
  3353. string Colspan = "";
  3354. if (Item.SOBKZ == "E")
  3355. {
  3356. Colspan = Item.KDAUF + "~~~" + Item.KDPOS + "~~~~~~~~~~";
  3357. }
  3358. else
  3359. {
  3360. Colspan = "~~~~~~~~~~~~~";
  3361. }
  3362. string chksql = @"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'";
  3363. chksql = string.Format(chksql, Colspan, WorkPoint);
  3364. DataTable chkdt = SqlHelper.GetDataTableBySql(chksql);
  3365. if (chkdt.Rows.Count != 0)
  3366. {
  3367. ExtensionID = chkdt.Rows[0]["ID"].ToString();
  3368. }
  3369. else
  3370. {
  3371. ExtensionID = Common.GuId();
  3372. sql += @" insert into ICSExtension
  3373. (ID,BatchCode,Version,Brand,ProjectCode,Colspan,MTIME,MUSER,MUSERName,WorkPoint)
  3374. VALUES
  3375. ('{6}','','','{0}','{1}','{2}',GETDATE(),'{3}','{4}','{5}') ";
  3376. if (Item.SOBKZ == "E")
  3377. {
  3378. sql = string.Format(sql, Item.KDPOS, Item.KDAUF, Colspan, MUSER, MUSERNAME, WorkPoint, ExtensionID);
  3379. }
  3380. else
  3381. {
  3382. sql = string.Format(sql, "", "", Colspan, MUSER, MUSERNAME, WorkPoint, ExtensionID);
  3383. }
  3384. }
  3385. chksql = @"select ID from ICSDeliveryNotice where DNCode='{0}' AND InvCode='{1}' AND WorkPoint='{2}'";
  3386. chksql = string.Format(chksql, Item.PRUEFLOS, Item.MATNR.TrimStart('0'), WorkPoint);
  3387. chkdt = SqlHelper.GetDataTableBySql(chksql);
  3388. if (chkdt.Rows.Count == 0)
  3389. {
  3390. sql += @" INSERT INTO [dbo].[ICSDeliveryNotice]
  3391. ([ID],[DNCode],[Sequence],[SAPSequence],[VenCode],[DepCode],[DNType],[InvCode],[Quantity],[Amount],[RCVQuantity]
  3392. ,[Status],[CreatePerson],[CreateDateTime],[POID],[DNID],[DNDetailID],[ExtensionID]
  3393. ,[MUSER],[MUSERName],[MTIME],[WorkPoint],[EATTRIBUTE1],[WHCode],[InspectionType],[InvoDescribe]
  3394. ,[StockIndicator],[DepositArea],[Unity],[ModificationDate],[TrackingNumber],[NonconformingForm]
  3395. ,[EATTRIBUTE2])
  3396. VALUES
  3397. (NEWID(),'" + Item.PRUEFLOS + "','" + LineNum + "'," + Item.L_LME.ToString() + ",'" + HeadInfo.LIFNR + @"'
  3398. ,'" + HeadInfo.NAME1 + "','1','" + Item.MATNR.TrimStart('0') + "'," + Item.HGMENGE + @",0
  3399. ,0,2,'" + MUSER + "','" + Convert.ToDateTime(HeadInfo.VDATUM) + "','" + HeadInfo.AUFNR + @"'
  3400. ,'" + HeadInfo.EBELN + "','" + HeadInfo.EBELP + "','" + ExtensionID + "','" + MUSER + @"'
  3401. ,'" + MUSERNAME + "',GETDATE(),'" + WorkPoint + "','" + Item.MEMO + "','" + Item.LGORT.Trim() + @"'
  3402. ,'" + HeadInfo.ART + "','" + Item.MAKTX + "','" + Item.SOBKZ + "','" + Item.LTKZA + @"'
  3403. ,'" + Item.MEINS + "','" + HeadInfo.TEST1 + "','" + HeadInfo.TEST2 + "','" + HeadInfo.TEST3 + @"'
  3404. ,'" + HeadInfo.TEST4 + "')";
  3405. }
  3406. else
  3407. {
  3408. sql += @" Update ICSDeliveryNotice set VenCode='" + HeadInfo.LIFNR + "',DepCode='" + HeadInfo.NAME1 + @"',DNType=1
  3409. ,CreateDateTime='" + Convert.ToDateTime(HeadInfo.VDATUM) + "',POID='" + HeadInfo.AUFNR + @"'
  3410. ,DNID='" + HeadInfo.EBELN + "',DNDetailID='" + HeadInfo.EBELP + "',Quantity=" + Item.HGMENGE + @"
  3411. ,SAPSequence=" + Item.L_LME.ToString() + ",WHCode='" + Item.LGORT.Trim() + "',EATTRIBUTE1='" + Item.MEMO + @"'
  3412. ,ExtensionID='" + ExtensionID + "',InspectionType='" + HeadInfo.ART + "',InvoDescribe='" + Item.MAKTX + @"'
  3413. ,Unity='" + Item.MEINS + "',StockIndicator='" + Item.SOBKZ + "',DepositArea='" + Item.LTKZA + @"'
  3414. ,ModificationDate='" + HeadInfo.TEST1 + "',TrackingNumber='" + HeadInfo.TEST2 + @"'
  3415. ,NonconformingForm='" + HeadInfo.TEST3 + "',EATTRIBUTE2='" + HeadInfo.TEST4 + @"'
  3416. where DNCode='{0}' AND InvCode='{1}' AND WorkPoint='{2}' ";
  3417. sql = string.Format(sql, Item.PRUEFLOS, Item.MATNR.TrimStart('0'), WorkPoint);
  3418. }
  3419. }
  3420. }
  3421. try
  3422. {
  3423. if (sql != "")
  3424. {
  3425. SqlHelper.CmdExecuteNonQueryLi(sql);
  3426. }
  3427. }
  3428. catch (Exception ex)
  3429. {
  3430. throw new Exception(ex.Message);
  3431. }
  3432. return "";
  3433. }
  3434. }
  3435. }