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.

4850 lines
204 KiB

  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. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  34. //keyValue = keyValue.Substring(1, keyValue.Length - 2);
  35. string sql = string.Empty;
  36. foreach (var item in res)
  37. {
  38. JObject jo = (JObject)item;
  39. sql = string.Format(@"
  40. IF EXISTS(SELECT * FROM dbo.ICSWareHouseLotInfo a
  41. LEFT JOIN dbo.ICSLocation b ON a.LocationCode=b.LocationCode and a.WorkPoint=b.WorkPoint
  42. where b.ID = '{0}' and a.Quantity>0)
  43. BEGIN
  44. RAISERROR('{2}!',16,1);
  45. RETURN
  46. END
  47. DELETE FROM dbo.ICSLocation WHERE ID = '{0}' and WorkPoint ='{1}'", jo["ID"].ToString(), WorkPoint,jo["LocationCode"].ToString());
  48. try
  49. {
  50. SqlHelper.ExecuteNonQuery(sql);
  51. }
  52. catch (Exception ex)
  53. {
  54. msg = ex.Message;
  55. //throw new Exception(ex.Message);
  56. }
  57. }
  58. return msg;
  59. }
  60. /// <summary>
  61. /// 删除周转箱
  62. /// </summary>
  63. /// <param name="keyValue">传入ID</param>
  64. /// <returns></returns>
  65. public string DeleteBoxes(string keyValue)
  66. {
  67. //站点信息
  68. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  69. string msg = "";
  70. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  71. //keyValue = keyValue.Substring(1, keyValue.Length - 2);
  72. string sql = string.Empty;
  73. foreach (var item in res)
  74. {
  75. JObject jo = (JObject)item;
  76. sql = $@"
  77. IF EXISTS(SELECT * FROM dbo.ICSWorkingCapitalBoxAccount a
  78. where a.BoxNumber='{jo["BoxNumber"]}' )
  79. BEGIN
  80. RAISERROR('!', 16, 1);
  81. RETURN
  82. END
  83. DELETE FROM dbo.ICSWorkingCapitalBox WHERE ID = '{jo["ID"]}' ";
  84. try
  85. {
  86. SqlHelper.ExecuteNonQuery(sql);
  87. }
  88. catch (Exception ex)
  89. {
  90. msg = ex.Message;
  91. //throw new Exception(ex.Message);
  92. }
  93. }
  94. return msg;
  95. }
  96. /// <summary>
  97. /// 删除模具档案
  98. /// </summary>
  99. /// <param name="keyValue">传入ID</param>
  100. /// <returns></returns>
  101. public string DeleteMould(string keyValue)
  102. {
  103. //站点信息
  104. string msg = "";
  105. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  106. //keyValue = keyValue.Substring(1, keyValue.Length - 2);
  107. string sql = string.Empty;
  108. foreach (var item in res)
  109. {
  110. JObject jo = (JObject)item;
  111. sql = $@"
  112. IF EXISTS(SELECT Id FROM dbo.ICSMouldAccount a
  113. where a.MouldNumber='{jo["MouldNumber"]}')
  114. BEGIN
  115. RAISERROR('!', 16, 1);
  116. RETURN
  117. END
  118. DELETE FROM dbo.ICSMould WHERE ID = '{jo["ID"]}' ";
  119. try
  120. {
  121. SqlHelper.ExecuteNonQuery(sql);
  122. }
  123. catch (Exception ex)
  124. {
  125. msg = ex.Message;
  126. //throw new Exception(ex.Message);
  127. }
  128. }
  129. return msg;
  130. }
  131. /// <summary>
  132. /// 删除模具台账
  133. /// </summary>
  134. /// <param name="keyValue">传入ID</param>
  135. /// <returns></returns>
  136. public string DeleteMouldAccount(string keyValue)
  137. {
  138. //站点信息
  139. string msg = "";
  140. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  141. //keyValue = keyValue.Substring(1, keyValue.Length - 2);
  142. string sql = string.Empty;
  143. foreach (var item in res)
  144. {
  145. JObject jo = (JObject)item;
  146. sql = $@"
  147. IF EXISTS(SELECT Id FROM dbo.ICSMouldLog a
  148. where a.MouldCode='{jo["MouldCode"]}')
  149. BEGIN
  150. RAISERROR('使!', 16, 1);
  151. RETURN
  152. END
  153. DELETE FROM dbo.ICSMouldAccount WHERE ID = '{jo["ID"]}' ";
  154. try
  155. {
  156. SqlHelper.ExecuteNonQuery(sql);
  157. }
  158. catch (Exception ex)
  159. {
  160. msg = ex.Message;
  161. //throw new Exception(ex.Message);
  162. }
  163. }
  164. return msg;
  165. }
  166. /// <summary>
  167. /// 删除不良原因
  168. /// </summary>
  169. /// <param name="keyValue">传入ID</param>
  170. /// <returns></returns>
  171. public string DeleteBadCode(string keyValue)
  172. {
  173. //站点信息
  174. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  175. string msg = "";
  176. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  177. string sql = string.Empty;
  178. sql = string.Format(@"DELETE FROM dbo.ICSBadCode WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  179. try
  180. {
  181. SqlHelper.ExecuteNonQuery(sql);
  182. }
  183. catch (Exception ex)
  184. {
  185. throw new Exception(ex.Message);
  186. }
  187. return msg;
  188. }
  189. /// <summary>
  190. /// 获取库房信息
  191. /// </summary>
  192. /// <returns></returns>
  193. public DataTable GetWarehouse()
  194. {
  195. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  196. string sql = @"
  197. select '' as WarehouseCode,'' as WarehouseName
  198. union all
  199. SELECT [WarehouseCode],[WarehouseName] FROM [ICSWarehouse] WITH (NOLOCK) WHERE 1=1 ";
  200. //string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  201. //if (role != "admin")
  202. //{
  203. // sql += " and b.WorkPoint='" + WorkPoint + "'";
  204. //}
  205. sql += " and WorkPoint='" + WorkPoint + "'";
  206. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  207. return dt;
  208. }
  209. /// <summary>
  210. /// 获取周转箱类型
  211. /// </summary>
  212. /// <returns></returns>
  213. public DataTable GetType(string tableName)
  214. {
  215. string sql =$@"
  216. select '' as Type,'' as TypeName
  217. union all
  218. SELECT Code AS Type,Name as TypeName FROM [ICSType] WITH (NOLOCK) WHERE TableCode='{tableName}' AND ColumnCode='Type' ";
  219. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  220. return dt;
  221. }
  222. /// <summary>
  223. /// 获取周转箱编码信息
  224. /// </summary>
  225. /// <returns></returns>
  226. public DataTable GetBoxNumber()
  227. {
  228. string sql = @"select '' as BoxNumber
  229. union all
  230. SELECT BoxNumber FROM [ICSWorkingCapitalBox] ";
  231. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  232. return dt;
  233. }
  234. /// <summary>
  235. /// 获取模具编码信息
  236. /// </summary>
  237. /// <returns></returns>
  238. public DataTable GetMouldNumber()
  239. {
  240. string sql = @"select '' as MouldNumber
  241. union all
  242. SELECT MouldNumber FROM [ICSMould] ";
  243. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  244. return dt;
  245. }
  246. /// <summary>
  247. /// 获取模具代码信息
  248. /// </summary>
  249. /// <returns></returns>
  250. public DataTable GetMouldCode()
  251. {
  252. string sql = @"select '' as MouldCode
  253. union all
  254. SELECT MouldCode FROM [ICSMouldAccount] ";
  255. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  256. return dt;
  257. }
  258. /// <summary>
  259. /// 新增库位
  260. /// </summary>
  261. /// <param name="queryJson"></param>
  262. /// <returns></returns>
  263. public string InsertStack(string keyValue)
  264. {
  265. var queryParam = keyValue.ToJObject();
  266. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  267. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  268. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  269. string msg = "";
  270. string StackSql = @"select * from ICSWarehouse where WarehouseCode='{0}' and WorkPoint='{1}'";
  271. StackSql = string.Format(StackSql, queryParam["Warehouse"].ToString(), WorkPoint);
  272. DataTable dt = SqlHelper.GetDataTableBySql(StackSql);
  273. string sql = string.Empty;
  274. sql = @"IF ((SELECT 1 FROM ICSLocation WHERE LocationCode='{0}' AND LocationName='{1}' AND WHID='{2}' AND WorkPoint='{5}' ) IS NULL)
  275. BEGIN
  276. INSERT INTO dbo.ICSLocation
  277. ( ID ,LocationCode ,LocationName ,WHID ,MUSER ,
  278. MUSERName ,MTIME ,WorkPoint ,Region,Row,GoodsShelf ,Tier,Grid) Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',GETDATE(),'{5}','{6}','{7}','{8}','{9}','{10}')
  279. END
  280. ELSE
  281. BEGIN
  282. RAISERROR('',16,1);
  283. END ";
  284. 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());
  285. try
  286. {
  287. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  288. {
  289. }
  290. else
  291. {
  292. msg = "新增失败";
  293. }
  294. }
  295. catch (Exception ex)
  296. {
  297. msg = ex.Message;
  298. return msg;
  299. }
  300. return msg;
  301. }
  302. /// <summary>
  303. /// 周转箱信息
  304. /// </summary>
  305. /// <param name="queryJson"></param>
  306. /// <returns></returns>
  307. public string InsertBoxes(string keyValue)
  308. {
  309. var queryParam = keyValue.ToJObject();
  310. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  311. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  312. string msg = "";
  313. string sql = string.Empty;
  314. sql = $@"IF ((SELECT 1 FROM ICSWorkingCapitalBox WHERE BoxNumber='{queryParam["BoxNumber"]}') IS NULL)
  315. BEGIN
  316. INSERT INTO [dbo].[ICSWorkingCapitalBox] ([ID], [BoxNumber], [BoxName], [Type], [Version], [Specification], [Describe], [FirstCleanCycle], [SecondCleanCycle], [ThirdCleanCycle], [MTIME], [MUser], [MUSERName])
  317. VALUES (NEWID(), '{queryParam["BoxNumber"]}', '{queryParam["BoxName"]}', '{queryParam["Type"]}', '{queryParam["Version"]}', '{queryParam["Specification"]}', '{queryParam["Describe"]}', {queryParam["FirstCleanCycle"]}, {queryParam["SecondCleanCycle"]}, {queryParam["ThirdCleanCycle"]}, GETDATE(), '{MUSER}', '{MUSERNAME}');
  318. END
  319. ELSE
  320. BEGIN
  321. RAISERROR('',16,1);
  322. END ";
  323. try
  324. {
  325. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  326. {
  327. }
  328. else
  329. {
  330. msg = "新增失败";
  331. }
  332. }
  333. catch (Exception ex)
  334. {
  335. msg = ex.Message;
  336. return msg;
  337. }
  338. return msg;
  339. }
  340. /// <summary>
  341. /// 新增模具信息
  342. /// </summary>
  343. /// <param name="queryJson"></param>
  344. /// <returns></returns>
  345. public string InsertMould(string keyValue)
  346. {
  347. var queryParam = keyValue.ToJObject();
  348. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  349. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  350. string msg = "";
  351. string sql = string.Empty;
  352. sql = $@"IF ((SELECT 1 FROM ICSMould WHERE MouldNumber='{queryParam["MouldNumber"]}') IS NULL)
  353. BEGIN
  354. INSERT INTO [dbo].[ICSMould] ([ID], [MouldNumber], [MouldName], [Type], [Specification], [Unit],[EATTRIBUTE1], [MTIME], [MUser], [MUSERName])
  355. VALUES (NEWID(), '{queryParam["MouldNumber"]}', '{queryParam["MouldName"]}', '{queryParam["Type"]}', '{queryParam["Specification"]}', '{queryParam["Unit"]}', '{queryParam["Phone"]}',GETDATE(), '{MUSER}', '{MUSERNAME}');
  356. END
  357. ELSE
  358. BEGIN
  359. RAISERROR('',16,1);
  360. END ";
  361. try
  362. {
  363. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  364. {
  365. }
  366. else
  367. {
  368. msg = "新增失败";
  369. }
  370. }
  371. catch (Exception ex)
  372. {
  373. msg = ex.Message;
  374. return msg;
  375. }
  376. return msg;
  377. }
  378. /// <summary>
  379. /// 新增不良代码
  380. /// </summary>
  381. /// <param name="queryJson"></param>
  382. /// <returns></returns>
  383. public string InsertBadCode(string keyValue)
  384. {
  385. var queryParam = keyValue.ToJObject();
  386. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  387. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  388. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  389. string msg = "";
  390. string sql = string.Empty;
  391. sql = @"INSERT INTO dbo.ICSBadCode
  392. ( ID ,BadCode ,BadDesc ,MUSER ,
  393. MUSERName ,MTIME ,WorkPoint,BCGroupID ) Values(NEWID(),'{0}','{1}','{2}','{3}',GETDATE(),'{4}','NULL')";
  394. sql = string.Format(sql, queryParam["BadCode"].ToString(), queryParam["BadDesc"].ToString(), MUSER, MUSERNAME, WorkPoint);
  395. try
  396. {
  397. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  398. {
  399. }
  400. else
  401. {
  402. msg = "新增失败";
  403. }
  404. }
  405. catch (Exception ex)
  406. {
  407. throw new Exception(ex.Message);
  408. }
  409. return msg;
  410. }
  411. /// <summary>
  412. /// 修改不良代码
  413. /// </summary>
  414. /// <param name="queryJson"></param>
  415. /// <returns></returns>
  416. public string UpdateBadCode(string keyValue)
  417. {
  418. var queryParam = keyValue.ToJObject();
  419. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  420. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  421. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  422. string msg = "";
  423. string sql = string.Empty;
  424. sql = @"UPDATE dbo.ICSBadCode set BadCode='{0}',BadDesc='{1}',MUSER='{2}',MUSERName='{3}',MTIME=GetDate(),WorkPoint='{4}' WHERE ID='{5}'";
  425. sql = string.Format(sql, queryParam["BadCode"].ToString(), queryParam["BadDesc"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  426. try
  427. {
  428. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  429. {
  430. }
  431. else
  432. {
  433. msg = "新增失败";
  434. }
  435. }
  436. catch (Exception ex)
  437. {
  438. throw new Exception(ex.Message);
  439. }
  440. return msg;
  441. }
  442. /// <summary>
  443. /// 修改库位
  444. /// </summary>
  445. /// <param name="queryJson"></param>
  446. /// <returns></returns>
  447. public string UpdateStack(string keyValue)
  448. {
  449. var queryParam = keyValue.ToJObject();
  450. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  451. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  452. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  453. string msg = "";
  454. string StackSql = @"select * from ICSWarehouse where WarehouseCode='{0}'";
  455. StackSql = string.Format(StackSql, queryParam["Warehouse"].ToString());
  456. DataTable dt = SqlHelper.GetDataTableBySql(StackSql);
  457. string sql = string.Empty;
  458. 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}' WHERE ID='{6}'";
  459. 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());
  460. try
  461. {
  462. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  463. {
  464. }
  465. else
  466. {
  467. msg = "修改失败";
  468. }
  469. }
  470. catch (Exception ex)
  471. {
  472. throw new Exception(ex.Message);
  473. }
  474. return msg;
  475. }
  476. /// <summary>
  477. /// 修改周转箱信息
  478. /// </summary>
  479. /// <param name="queryJson"></param>
  480. /// <returns></returns>
  481. public string UpdateBoxes(string keyValue)
  482. {
  483. var queryParam = keyValue.ToJObject();
  484. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  485. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  486. string msg = "";
  487. string sql = string.Empty;
  488. sql = $@"UPDATE [dbo].[ICSWorkingCapitalBox] SET [BoxName] = '{queryParam["BoxName"]}', [Type] = '{queryParam["Type"]}', [Version] = '{queryParam["Version"]}', [Specification] = '{queryParam["Specification"]}', [Describe] = '{queryParam["Describe"]}', [FirstCleanCycle] = {queryParam["FirstCleanCycle"]}, [SecondCleanCycle] = {queryParam["SecondCleanCycle"]}, [ThirdCleanCycle] = {queryParam["ThirdCleanCycle"]}, [MTIME] = GETDATE(), [MUser] = '{MUSER}', [MUSERName] = '{MUSERNAME}' WHERE ID='{queryParam["ID"]}';";
  489. try
  490. {
  491. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  492. {
  493. }
  494. else
  495. {
  496. msg = "修改失败";
  497. }
  498. }
  499. catch (Exception ex)
  500. {
  501. throw new Exception(ex.Message);
  502. }
  503. return msg;
  504. }
  505. /// <summary>
  506. /// 修改模具信息
  507. /// </summary>
  508. /// <param name="queryJson"></param>
  509. /// <returns></returns>
  510. public string UpdateMould(string keyValue)
  511. {
  512. var queryParam = keyValue.ToJObject();
  513. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  514. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  515. string msg = "";
  516. string sql = string.Empty;
  517. sql = $@"UPDATE [dbo].[ICSMould] SET [MouldName] = '{queryParam["MouldName"]}', [Type] = '{queryParam["Type"]}', [Unit] = '{queryParam["Unit"]}', [Specification] = '{queryParam["Specification"]}', [EATTRIBUTE1] = '{queryParam["Phone"]}', [MTIME] = GETDATE(), [MUser] = '{MUSER}', [MUSERName] = '{MUSERNAME}' WHERE ID='{queryParam["ID"]}';";
  518. try
  519. {
  520. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  521. {
  522. }
  523. else
  524. {
  525. msg = "修改失败";
  526. }
  527. }
  528. catch (Exception ex)
  529. {
  530. throw new Exception(ex.Message);
  531. }
  532. return msg;
  533. }
  534. /// <summary>
  535. /// 修改模具状态信息
  536. /// </summary>
  537. /// <param name="queryJson"></param>
  538. /// <returns></returns>
  539. public string UpdateMouldStatus(string keyValue)
  540. {
  541. var queryParam = keyValue.ToJObject();
  542. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  543. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  544. string msg = "";
  545. string sql = string.Empty;
  546. sql = $@"UPDATE [dbo].[ICSMouldAccount] SET [MajorStates] = '禁用', [SubStates] = '{queryParam["Status"]}' WHERE ID='{queryParam["ID"]}';
  547. INSERT INTO [dbo].[ICSMouldLog] ([ID], [MouldCode], [MouldNumber], [Status], [DailyUses], [StartDate], [MTIME], [MUser], [MUSERName], [UsageCount]) SELECT NEWID(),MouldCode,MouldNumber,'{queryParam["Status"]}',0,GETDATE(),GETDATE(),'{MUSER}','{MUSERNAME}',0 FROM ICSMouldAccount WHERE ID='{queryParam["ID"]}';";
  548. try
  549. {
  550. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  551. {
  552. }
  553. else
  554. {
  555. msg = "修改失败";
  556. }
  557. }
  558. catch (Exception ex)
  559. {
  560. throw new Exception(ex.Message);
  561. }
  562. return msg;
  563. }
  564. /// <summary>
  565. /// 新增类型
  566. /// </summary>
  567. /// <param name="queryJson"></param>
  568. /// <returns></returns>
  569. public string InsertICSType(string keyValue)
  570. {
  571. var queryParam = keyValue.ToJObject();
  572. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  573. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  574. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  575. string msg = "";
  576. string sql = string.Empty;
  577. sql = @"INSERT INTO dbo.ICSType
  578. ( ID ,TableCode ,ColumnCode ,Code,Name, Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
  579. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',GETDATE(),'{5}','{6}','{7}')
  580. ";
  581. sql = string.Format(sql, queryParam["TableCode"].ToString(), queryParam["ColumnCode"].ToString(), queryParam["Code"].ToString(), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint);
  582. try
  583. {
  584. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  585. {
  586. }
  587. else
  588. {
  589. msg = "新增失败";
  590. }
  591. }
  592. catch (Exception ex)
  593. {
  594. throw new Exception(ex.Message);
  595. }
  596. return msg;
  597. }
  598. /// <summary>
  599. /// 修改类型
  600. /// </summary>
  601. /// <param name="queryJson"></param>
  602. /// <returns></returns>
  603. public string UpdateICSType(string keyValue)
  604. {
  605. var queryParam = keyValue.ToJObject();
  606. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  607. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  608. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  609. string msg = "";
  610. string sql = string.Empty;
  611. 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}'";
  612. 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());
  613. try
  614. {
  615. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  616. {
  617. }
  618. else
  619. {
  620. msg = "修改失败";
  621. }
  622. }
  623. catch (Exception ex)
  624. {
  625. throw new Exception(ex.Message);
  626. }
  627. return msg;
  628. }
  629. /// <summary>
  630. /// 删除类型
  631. /// </summary>
  632. /// <param name="keyValue">传入ID</param>
  633. /// <returns></returns>
  634. public string DeleteICSType(string keyValue)
  635. {
  636. //站点信息
  637. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  638. string msg = "";
  639. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  640. string sql = string.Empty;
  641. sql = string.Format(@"DELETE FROM dbo.ICSType WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  642. try
  643. {
  644. SqlHelper.ExecuteNonQuery(sql);
  645. }
  646. catch (Exception ex)
  647. {
  648. throw new Exception(ex.Message);
  649. }
  650. return msg;
  651. }
  652. /// <summary>
  653. /// 修改参数配置
  654. /// </summary>
  655. /// <param name="queryJson"></param>
  656. /// <returns></returns>
  657. public string UpdateICSConfiguration(string keyValue)
  658. {
  659. var queryParam = keyValue.ToJObject();
  660. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  661. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  662. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  663. string msg = "";
  664. string sql = string.Empty;
  665. sql = @"UPDATE dbo.ICSConfiguration set Code='{0}',Name='{1}',Enable='{2}',Figure='{3}',MTIME=GETDATE(),MUSER='{4}',MUSERName='{5}',WorkPoint='{6}' WHERE ID='{7}'";
  666. sql = string.Format(sql, queryParam["Code"].ToString(), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), queryParam["Figure"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  667. try
  668. {
  669. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  670. {
  671. }
  672. else
  673. {
  674. msg = "修改失败";
  675. }
  676. }
  677. catch (Exception ex)
  678. {
  679. throw new Exception(ex.Message);
  680. }
  681. return msg;
  682. }
  683. /// <summary>
  684. /// 新增参数配置
  685. /// </summary>
  686. /// <param name="queryJson"></param>
  687. /// <returns></returns>
  688. public string InsertICSConfiguration(string keyValue)
  689. {
  690. var queryParam = keyValue.ToJObject();
  691. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  692. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  693. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  694. string msg = "";
  695. string sql = string.Empty;
  696. sql = @"INSERT INTO dbo.ICSConfiguration
  697. ( ID ,Code ,Name ,Enable,Figure,MTIME,MUSER ,MUSERName ,WorkPoint )
  698. Values(NEWID(),'{0}','{1}','{2}','{3}',GETDATE(),'{4}','{5}','{6}')
  699. ";
  700. sql = string.Format(sql, queryParam["Code"].ToString(), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), queryParam["Figure"].ToString(), MUSER, MUSERNAME, WorkPoint);
  701. try
  702. {
  703. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  704. {
  705. }
  706. else
  707. {
  708. msg = "新增失败";
  709. }
  710. }
  711. catch (Exception ex)
  712. {
  713. throw new Exception(ex.Message);
  714. }
  715. return msg;
  716. }
  717. /// <summary>
  718. /// 删除参数配置
  719. /// </summary>
  720. /// <param name="keyValue">传入ID</param>
  721. /// <returns></returns>
  722. public string DeleteICSConfiguration(string keyValue)
  723. {
  724. //站点信息
  725. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  726. string msg = "";
  727. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  728. string sql = string.Empty;
  729. sql = string.Format(@"DELETE FROM dbo.ICSConfiguration WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  730. try
  731. {
  732. SqlHelper.ExecuteNonQuery(sql);
  733. }
  734. catch (Exception ex)
  735. {
  736. throw new Exception(ex.Message);
  737. }
  738. return msg;
  739. }
  740. /// <summary>
  741. /// 修改启用配置
  742. /// </summary>
  743. /// <param name="queryJson"></param>
  744. /// <returns></returns>
  745. public string UpdateICSExtensionEnable(string keyValue)
  746. {
  747. var queryParam = keyValue.ToJObject();
  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 msg = "";
  752. string sql = string.Empty;
  753. sql = @"UPDATE dbo.ICSExtensionEnable set ColCode='{0}',ColName='{1}',Enable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
  754. sql = string.Format(sql, queryParam["ColCode"].ToString(), queryParam["ColName"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  755. try
  756. {
  757. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  758. {
  759. }
  760. else
  761. {
  762. msg = "修改失败";
  763. }
  764. }
  765. catch (Exception ex)
  766. {
  767. throw new Exception(ex.Message);
  768. }
  769. return msg;
  770. }
  771. /// <summary>
  772. /// 修改启用配置
  773. /// </summary>
  774. /// <param name="queryJson"></param>
  775. /// <returns></returns>
  776. public string UpdateICSColumnEnable(string keyValue)
  777. {
  778. var queryParam = keyValue.ToJObject();
  779. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  780. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  781. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  782. string msg = "";
  783. string sql = string.Empty;
  784. sql = @"UPDATE dbo.ICSColumnEnable set TableCode = '{0}',ColumnCode='{1}',Code='{2}',Name='{3}',Enable='{4}',MTIME=GETDATE(),MUSER='{5}',MUSERName='{6}',WorkPoint='{7}' WHERE ID='{8}'";
  785. sql = string.Format(sql, queryParam["TableCode"].ToString(), queryParam["ColumnCode"].ToString(), queryParam["Code"].ToString().Replace("EATTRIBUTE", ""), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  786. try
  787. {
  788. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  789. {
  790. }
  791. else
  792. {
  793. msg = "修改失败";
  794. }
  795. }
  796. catch (Exception ex)
  797. {
  798. throw new Exception(ex.Message);
  799. }
  800. return msg;
  801. }
  802. /// <summary>
  803. /// 新增启用配置
  804. /// </summary>
  805. /// <param name="queryJson"></param>
  806. /// <returns></returns>
  807. public string InsertICSExtensionEnable(string keyValue)
  808. {
  809. var queryParam = keyValue.ToJObject();
  810. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  811. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  812. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  813. string msg = "";
  814. string sql = string.Empty;
  815. sql = @"INSERT INTO dbo.ICSExtensionEnable
  816. ( ID ,ColCode ,ColName ,Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
  817. Values(NEWID(),'{0}','{1}','{2}',GETDATE(),'{3}','{4}','{5}')
  818. ";
  819. sql = string.Format(sql, queryParam["ColCode"].ToString(), queryParam["ColName"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint);
  820. try
  821. {
  822. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  823. {
  824. }
  825. else
  826. {
  827. msg = "新增失败";
  828. }
  829. }
  830. catch (Exception ex)
  831. {
  832. throw new Exception(ex.Message);
  833. }
  834. return msg;
  835. }
  836. /// <summary>
  837. /// 新增启用配置
  838. /// </summary>
  839. /// <param name="queryJson"></param>
  840. /// <returns></returns>
  841. public string InsertICSColumnEnable(string keyValue)
  842. {
  843. var queryParam = keyValue.ToJObject();
  844. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  845. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  846. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  847. string msg = "";
  848. string sql = string.Empty;
  849. sql = @"INSERT INTO dbo.ICSColumnEnable
  850. ( ID ,TableCode,ColumnCode,Code ,Name ,Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
  851. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',GETDATE(),'{5}','{6}','{7}')
  852. ";
  853. sql = string.Format(sql, queryParam["TableCode"].ToString(),queryParam["Code"].ToString(), queryParam["Code"].ToString().Replace("EATTRIBUTE", ""), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint);
  854. try
  855. {
  856. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  857. {
  858. }
  859. else
  860. {
  861. msg = "新增失败";
  862. }
  863. }
  864. catch (Exception ex)
  865. {
  866. throw new Exception(ex.Message);
  867. }
  868. return msg;
  869. }
  870. /// <summary>
  871. /// 删除启用配置
  872. /// </summary>
  873. /// <param name="keyValue">传入ID</param>
  874. /// <returns></returns>
  875. public string DeleteICSExtensionEnable(string keyValue)
  876. {
  877. //站点信息
  878. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  879. string msg = "";
  880. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  881. string sql = string.Empty;
  882. sql = string.Format(@"DELETE FROM dbo.ICSExtensionEnable WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  883. try
  884. {
  885. SqlHelper.ExecuteNonQuery(sql);
  886. }
  887. catch (Exception ex)
  888. {
  889. throw new Exception(ex.Message);
  890. }
  891. return msg;
  892. }
  893. /// <summary>
  894. /// 删除单据启用配置
  895. /// </summary>
  896. /// <param name="keyValue">传入ID</param>
  897. /// <returns></returns>
  898. public string DeleteICSColumnEnable(string keyValue)
  899. {
  900. //站点信息
  901. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  902. string msg = "";
  903. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  904. string sql = string.Empty;
  905. sql = string.Format(@"DELETE FROM dbo.ICSColumnEnable WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  906. try
  907. {
  908. SqlHelper.ExecuteNonQuery(sql);
  909. }
  910. catch (Exception ex)
  911. {
  912. throw new Exception(ex.Message);
  913. }
  914. return msg;
  915. }
  916. //不良代码
  917. public DataTable GetICSBadCodeGroup(ref Pagination jqgridparam, string queryJson)
  918. {
  919. DataTable dt = new DataTable();
  920. var queryParam = queryJson.ToJObject();
  921. List<DbParameter> parameter = new List<DbParameter>();
  922. string sql = @" select ID,BCGCode,BCGDesc,MUSER,MUSERName,MTIME,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,
  923. EATTRIBUTE9,EATTRIBUTE10 from ICSBadCodeGroup ";
  924. sql += " WHERE 1=1";
  925. if (!string.IsNullOrWhiteSpace(queryJson))
  926. {
  927. if (!string.IsNullOrWhiteSpace(queryParam["BadCode"].ToString()))
  928. {
  929. sql += " and BCGCode like '%" + queryParam["BadCode"].ToString() + "%' ";
  930. }
  931. if (!string.IsNullOrWhiteSpace(queryParam["BadCodeName"].ToString()))
  932. {
  933. sql += " and BCGDesc like '%" + queryParam["BadCodeName"].ToString() + "%' ";
  934. }
  935. }
  936. sql = string.Format(sql);
  937. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  938. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  939. }
  940. //不良原因
  941. public DataTable GetICSBadReasonGroup(ref Pagination jqgridparam, string queryJson)
  942. {
  943. DataTable dt = new DataTable();
  944. var queryParam = queryJson.ToJObject();
  945. List<DbParameter> parameter = new List<DbParameter>();
  946. string sql = @" select ID,BRGCode,BRGDesc,MUSER,MUSERName,MTIME,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,
  947. EATTRIBUTE9,EATTRIBUTE10 from ICSBadReasonGroup ";
  948. sql += " WHERE 1=1";
  949. if (!string.IsNullOrWhiteSpace(queryJson))
  950. {
  951. if (!string.IsNullOrWhiteSpace(queryParam["BadReason"].ToString()))
  952. {
  953. sql += " and BRGCode like '%" + queryParam["BadReason"].ToString() + "%' ";
  954. }
  955. if (!string.IsNullOrWhiteSpace(queryParam["BadReasonName"].ToString()))
  956. {
  957. sql += " and BRGDesc like '%" + queryParam["BadReasonName"].ToString() + "%' ";
  958. }
  959. }
  960. sql = string.Format(sql);
  961. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  962. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  963. }
  964. //不良代码子表
  965. public DataTable GetICSBadCodeGroupdetil(string ID, ref Pagination jqgridparam)
  966. {
  967. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  968. DataTable dt = new DataTable();
  969. //var queryParam = queryJson.ToJObject();
  970. List<DbParameter> parameter = new List<DbParameter>();
  971. string sql = @"select BCGroupID,BadCode,BadDesc,MUSERName,MTIME,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,
  972. EATTRIBUTE9,EATTRIBUTE10 from ICSBadCode
  973. where BCGroupID='" + ID + "' ";
  974. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  975. }
  976. public DataTable GetICSBadCode(string BRGCode, ref Pagination jqgridparam)
  977. {
  978. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  979. DataTable dt = new DataTable();
  980. //var queryParam = queryJson.ToJObject();
  981. List<DbParameter> parameter = new List<DbParameter>();
  982. string sql = @"select BRGroupID,BadReasonCode,BadReasonDesc,MUSERName,MTIME from ICSBadReason
  983. WHERE BRGroupID='" + BRGCode + "' ";
  984. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  985. }
  986. /// <summary>
  987. /// 不良原因子表查询
  988. /// </summary>
  989. /// <param name="queryJson"></param>
  990. /// <param name="jqgridparam"></param>
  991. /// <returns></returns>
  992. public DataTable GetICSBadReason(string BRGroupID, ref Pagination jqgridparam)
  993. {
  994. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  995. DataTable dt = new DataTable();
  996. //var queryParam = queryJson.ToJObject();
  997. List<DbParameter> parameter = new List<DbParameter>();
  998. string sql = @"select BRGroupID,BadReasonCode,BadReasonDesc,MUSERName,MTIME,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,
  999. EATTRIBUTE9,EATTRIBUTE10 from ICSBadReason
  1000. WHERE BRGroupID='" + BRGroupID + "' ";
  1001. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1002. }
  1003. /// <summary>
  1004. /// 不良原因子表查询2
  1005. /// </summary>
  1006. /// <param name="queryJson"></param>
  1007. /// <param name="jqgridparam"></param>
  1008. /// <returns></returns>
  1009. public DataTable GetICSBadReason2(string BRGCode, ref Pagination jqgridparam)
  1010. {
  1011. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1012. DataTable dt = new DataTable();
  1013. //var queryParam = queryJson.ToJObject();
  1014. List<DbParameter> parameter = new List<DbParameter>();
  1015. string sql = @"select BRGroupID,BadReasonCode,BadReasonDesc,MUSERName,MTIME from ICSBadReason
  1016. WHERE BRGroupID='" + BRGCode + "' ";
  1017. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1018. }
  1019. public void DeleteBCItem(string ID)
  1020. {
  1021. string sql = "DELETE FROM dbo.ICSBadCode WHERE ID='" + ID + "'";
  1022. SqlHelper.ExecuteNonQuery(sql);
  1023. }
  1024. public void DeleteItem(string ID)
  1025. {
  1026. string sql = "DELETE FROM dbo.ICSBadReason WHERE ID='" + ID + "'";
  1027. SqlHelper.ExecuteNonQuery(sql);
  1028. }
  1029. //不良代码新增
  1030. public void SubICSBadCodeGroupAdd(ICSBadReason main, string BRGCode, string BRGDesc)
  1031. {
  1032. string sql = string.Empty;
  1033. string sqls = string.Empty;
  1034. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1035. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1036. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1037. string NewID = Common.GuId();
  1038. List<ICSBadReason> list_Item1 = new List<ICSBadReason>();
  1039. if (main.arrayShellFabricItem != null)
  1040. {
  1041. list_Item1 = JsonConvert.DeserializeObject<List<ICSBadReason>>(main.arrayShellFabricItem);
  1042. }
  1043. string connString = SqlHelper.DataCenterConnString;
  1044. SqlConnection conn = new SqlConnection(connString);
  1045. conn.Open();
  1046. SqlTransaction sqlTran = conn.BeginTransaction();
  1047. SqlCommand cmd = new SqlCommand();
  1048. cmd.Transaction = sqlTran;
  1049. cmd.Connection = conn;
  1050. sql = @"IF EXISTS( select BCGCode from ICSBadCodeGroup where BCGCode='{0}')
  1051. BEGIN
  1052. RAISERROR('',16,1);
  1053. RETURN
  1054. END
  1055. INSERT INTO dbo.ICSBadCodeGroup
  1056. ( ID ,BCGCode ,BCGDesc, MTIME,MUSER ,MUSERName ,WorkPoint )
  1057. Values('{5}','{0}','{1}',GETDATE(),'{2}','{3}','{4}')";
  1058. sql = string.Format(sql, BRGCode, BRGDesc, MUSER, MUSERNAME, WorkPoint, NewID);
  1059. try
  1060. {
  1061. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1062. {
  1063. foreach (ICSBadReason Item in list_Item1)
  1064. {
  1065. sqls = @"IF EXISTS( select BadCode from ICSBadCode where BadCode=@BadReasonCode)
  1066. BEGIN
  1067. RAISERROR('',16,1);
  1068. RETURN
  1069. END
  1070. INSERT INTO dbo.ICSBadCode
  1071. ( ID ,BCGroupID,BadCode ,BadDesc, MTIME,MUSER ,MUSERName ,WorkPoint )
  1072. Values(@ID,'{0}',@BadReasonCode,@BadReasonDesc,GETDATE(),'{1}','{2}','{3}')";
  1073. sqls = string.Format(sqls, NewID, MUSER, MUSERNAME, WorkPoint);
  1074. SqlParameter[] sp_Item =
  1075. {
  1076. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  1077. new SqlParameter("@BadReasonCode",DbType.String){ Value= Item.BadReasonCode},
  1078. new SqlParameter("@BadReasonDesc",DbType.String){ Value= Item.BadReasonDesc},
  1079. };
  1080. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  1081. }
  1082. cmd.Transaction.Commit();
  1083. }
  1084. }
  1085. catch (Exception ex)
  1086. {
  1087. cmd.Transaction.Rollback();
  1088. throw new Exception(ex.Message);
  1089. }
  1090. finally
  1091. {
  1092. if (conn.State == ConnectionState.Open)
  1093. {
  1094. conn.Close();
  1095. }
  1096. conn.Dispose();
  1097. }
  1098. }
  1099. //不良原因新增
  1100. public void SubICSBadReasonGroupAdd(ICSBadReason main, string BRGCode, string BRGDesc)
  1101. {
  1102. string sql = string.Empty;
  1103. string sqls = string.Empty;
  1104. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1105. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1106. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1107. string NewID = Common.GuId();
  1108. List<ICSBadReason> list_Item1 = new List<ICSBadReason>();
  1109. if (main.arrayShellFabricItem != null)
  1110. {
  1111. list_Item1 = JsonConvert.DeserializeObject<List<ICSBadReason>>(main.arrayShellFabricItem);
  1112. }
  1113. string connString = SqlHelper.DataCenterConnString;
  1114. SqlConnection conn = new SqlConnection(connString);
  1115. conn.Open();
  1116. SqlTransaction sqlTran = conn.BeginTransaction();
  1117. SqlCommand cmd = new SqlCommand();
  1118. cmd.Transaction = sqlTran;
  1119. cmd.Connection = conn;
  1120. sql = @"IF EXISTS( select BRGCode from ICSBadReasonGroup where BRGCode='{0}')
  1121. BEGIN
  1122. RAISERROR('',16,1);
  1123. RETURN
  1124. end
  1125. INSERT INTO dbo.ICSBadReasonGroup
  1126. ( ID ,BRGCode ,BRGDesc, MTIME,MUSER ,MUSERName ,WorkPoint )
  1127. Values('{5}','{0}','{1}',GETDATE(),'{2}','{3}','{4}')";
  1128. sql = string.Format(sql, BRGCode, BRGDesc, MUSER, MUSERNAME, WorkPoint, NewID);
  1129. try
  1130. {
  1131. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1132. {
  1133. foreach (ICSBadReason Item in list_Item1)
  1134. {
  1135. sqls = @"IF EXISTS(select BadReasonCode from ICSBadReason where BadReasonCode=@BadReasonCode)
  1136. BEGIN
  1137. RAISERROR('',16,1);
  1138. RETURN
  1139. end
  1140. INSERT INTO dbo.ICSBadReason
  1141. ( ID ,BRGroupID,BadReasonCode ,BadReasonDesc, MTIME,MUSER ,MUSERName ,WorkPoint )
  1142. Values(@ID,'{0}',@BadReasonCode,@BadReasonDesc,GETDATE(),'{1}','{2}','{3}')";
  1143. sqls = string.Format(sqls, NewID, MUSER, MUSERNAME, WorkPoint);
  1144. SqlParameter[] sp_Item = {
  1145. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  1146. new SqlParameter("@BadReasonCode",DbType.String){ Value= Item.BadReasonCode},
  1147. new SqlParameter("@BadReasonDesc",DbType.String){ Value= Item.BadReasonDesc},
  1148. };
  1149. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  1150. }
  1151. cmd.Transaction.Commit();
  1152. }
  1153. }
  1154. catch (Exception ex)
  1155. {
  1156. cmd.Transaction.Rollback();
  1157. throw new Exception(ex.Message);
  1158. }
  1159. finally
  1160. {
  1161. if (conn.State == ConnectionState.Open)
  1162. {
  1163. conn.Close();
  1164. }
  1165. conn.Dispose();
  1166. }
  1167. }
  1168. public DataTable GetICSBadCodeGroupdetil2(string ID)
  1169. {
  1170. string sql = string.Empty;
  1171. DataTable dt = null;
  1172. sql = string.Format(@"select * from ICSBadCode where BCGroupID='{0}'", ID);
  1173. dt = SqlHelper.GetDataTableBySql(sql);
  1174. return dt;
  1175. }
  1176. public DataTable GetICSBadReason2(string BID)
  1177. {
  1178. string sql = string.Empty;
  1179. DataTable dt = null;
  1180. sql = string.Format(@"select * from ICSBadReason where BRGroupID='{0}'", BID);
  1181. dt = SqlHelper.GetDataTableBySql(sql);
  1182. return dt;
  1183. }
  1184. public void UpdateICSBadCodeGroup(ICSBadReason main, string BID, string BRGCode, string BRGDesc)
  1185. {
  1186. string sql = string.Empty;
  1187. string sqls = string.Empty;
  1188. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1189. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1190. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1191. List<ICSBadReason> list_Item1 = new List<ICSBadReason>();
  1192. if (main.arrayShellFabricItem != null)
  1193. {
  1194. list_Item1 = JsonConvert.DeserializeObject<List<ICSBadReason>>(main.arrayShellFabricItem);
  1195. }
  1196. string connString = SqlHelper.DataCenterConnString;
  1197. SqlConnection conn = new SqlConnection(connString);
  1198. conn.Open();
  1199. SqlTransaction sqlTran = conn.BeginTransaction();
  1200. SqlCommand cmd = new SqlCommand();
  1201. cmd.Transaction = sqlTran;
  1202. cmd.Connection = conn;
  1203. sql = @"UPDATE dbo.ICSBadCodeGroup set BCGCode='{0}',BCGDesc='{1}',MTIME=GETDATE(),MUSER='{2}',MUSERName='{3}',WorkPoint='{4}' WHERE ID='{5}'";
  1204. sql = string.Format(sql, BRGCode, BRGDesc, MUSER, MUSERNAME, WorkPoint, BID);
  1205. try
  1206. {
  1207. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1208. {
  1209. foreach (ICSBadReason Item in list_Item1)
  1210. {
  1211. sqls = @" IF NOT EXISTS(SELECT * FROM ICSBadCode WHERE ID=@ID)
  1212. BEGIN
  1213. INSERT INTO ICSBadCode( ID,BCGroupID,BadCode,BadDesc,MTIME,MUSER,MUSERName,WorkPoint)
  1214. VALUES (@ID,'{0}',@BadReasonCode,@BadReasonDesc,getdate(),'{1}','{2}','{3}')
  1215. END
  1216. ELSE
  1217. BEGIN
  1218. UPDATE dbo.ICSBadCode set BCGroupID='{0}',BadCode=@BadReasonCode,BadDesc=@BadReasonDesc,MTIME=GETDATE(),MUSER='{1}',MUSERName='{2}',WorkPoint='{3}' WHERE ID=@ID
  1219. end
  1220. ";
  1221. sqls = string.Format(sqls, BID, MUSER, MUSERNAME, WorkPoint);
  1222. SqlParameter[] sp_Item = {
  1223. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  1224. new SqlParameter("@BadReasonCode",DbType.String){ Value= Item.BadReasonCode},
  1225. new SqlParameter("@BadReasonDesc",DbType.String){ Value= Item.BadReasonDesc},
  1226. };
  1227. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  1228. }
  1229. cmd.Transaction.Commit();
  1230. }
  1231. }
  1232. catch (Exception ex)
  1233. {
  1234. cmd.Transaction.Rollback();
  1235. throw new Exception(ex.Message);
  1236. }
  1237. finally
  1238. {
  1239. if (conn.State == ConnectionState.Open)
  1240. {
  1241. conn.Close();
  1242. }
  1243. conn.Dispose();
  1244. }
  1245. }
  1246. /// <summary>
  1247. /// 周转箱使用记录查询
  1248. /// </summary>
  1249. /// <param name="queryJson"></param>
  1250. /// <param name="jqgridparam"></param>
  1251. /// <returns></returns>
  1252. public DataTable GetBoxesRecord(string queryJson, ref Pagination jqgridparam)
  1253. {
  1254. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1255. var queryParam = queryJson.ToJObject();
  1256. DataTable dt = new DataTable();
  1257. //var queryParam = queryJson.ToJObject();
  1258. List<DbParameter> parameter = new List<DbParameter>();
  1259. string sql = @"SELECT a.BoxCode ,a.BoxNumber,a.Picture,a.MTIME,a.MUSERName,b.BoxName FROM ICSWorkingCapitalBoxLog a
  1260. left JOIN ICSWorkingCapitalBoxAccount b ON a.BoxCode=b.BoxCode WHERE 1=1 ";
  1261. if (queryParam["BoxCode"]!=null&& queryParam["BoxCode"].ToString()!="")
  1262. {
  1263. sql = sql + $@"and a.BoxCode='{queryParam["BoxCode"]}' ";
  1264. }
  1265. if (queryParam["BoxName"] != null && queryParam["BoxName"].ToString() != "")
  1266. {
  1267. sql = sql + $@" and a.BoxCode='{queryParam["BoxName"]}'";
  1268. }
  1269. if (queryParam["BoxNumber"] != null && queryParam["BoxNumber"].ToString() != "")
  1270. {
  1271. sql = sql + $@" and a.BoxNumber='{queryParam["BoxNumber"]}'";
  1272. }
  1273. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1274. }
  1275. /// <summary>
  1276. /// 周转箱台账信息
  1277. /// </summary>
  1278. /// <param name="queryJson"></param>
  1279. /// <param name="jqgridparam"></param>
  1280. /// <returns></returns>
  1281. public DataTable GetBoxesAccountRecord(string queryJson, ref Pagination jqgridparam)
  1282. {
  1283. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1284. var queryParam = queryJson.ToJObject();
  1285. DataTable dt = new DataTable();
  1286. //var queryParam = queryJson.ToJObject();
  1287. List<DbParameter> parameter = new List<DbParameter>();
  1288. string sql = @"SELECT [ID], [BoxCode], [BoxNumber], [BoxName], [States], [Describe], [DailyUses], [TotalUses], [TotalClearn], [CleanDate], [Cleaner], [Picture], [MUser], [MUSERName], [MTIME] from ICSWorkingCapitalBoxAccount WHERE 1=1 ";
  1289. if (queryParam["BoxCode"] != null && queryParam["BoxCode"].ToString() != "")
  1290. {
  1291. sql = sql + $@"and a.BoxCode='{queryParam["BoxCode"]}' ";
  1292. }
  1293. if (queryParam["BoxName"] != null && queryParam["BoxName"].ToString() != "")
  1294. {
  1295. sql = sql + $@" and a.BoxCode='{queryParam["BoxName"]}'";
  1296. }
  1297. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1298. }
  1299. /// <summary>
  1300. /// 模具使用记录查询
  1301. /// </summary>
  1302. /// <param name="queryJson"></param>
  1303. /// <param name="jqgridparam"></param>
  1304. /// <returns></returns>
  1305. public DataTable GetMouldRecord(string queryJson, ref Pagination jqgridparam)
  1306. {
  1307. var queryParam = queryJson.ToJObject();
  1308. DataTable dt = new DataTable();
  1309. //var queryParam = queryJson.ToJObject();
  1310. List<DbParameter> parameter = new List<DbParameter>();
  1311. string sql = @"SELECT a.MouldCode,a.Status,a.EOPCode,a.Picture ,a.MouldNumber,a.DailyUses,b.MouldName,
  1312. (case when a.status = '' then a.StartDate else null end) as MaintenanceDate,
  1313. (case when a.status = '' then a.MUSERName else null end) as MaintenancePerson,
  1314. (case when a.status = '' then a.StartDate else null end) as MaintainDate,
  1315. (case when a.status = '' then a.MUSERName else null end) as MaintainPerson,
  1316. (case when a.status not in('','') then a.MTime else null end) as UseDate,
  1317. (case when a.status not in('','') then a.MUSERName else null end) as UsePerson
  1318. FROM ICSMouldLog a
  1319. left JOIN ICSMouldAccount b ON a.MouldCode=b.MouldCode WHERE 1=1 ";
  1320. if (queryParam["MouldCode"] != null && queryParam["MouldCode"].ToString() != "")
  1321. {
  1322. sql = sql + $@"and a.MouldCode='{queryParam["MouldCode"]}' ";
  1323. }
  1324. if (queryParam["MouldNumber"] != null && queryParam["MouldNumber"].ToString() != "")
  1325. {
  1326. sql = sql + $@"and a.MouldNumber='{queryParam["MouldNumber"]}' ";
  1327. }
  1328. if (queryParam["MouldName"] != null && queryParam["MouldName"].ToString() != "")
  1329. {
  1330. sql = sql + $@" and a.MouldCode='{queryParam["MouldName"]}'";
  1331. }
  1332. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1333. }
  1334. /// <summary>
  1335. /// 模具台账信息
  1336. /// </summary>
  1337. /// <param name="queryJson"></param>
  1338. /// <param name="jqgridparam"></param>
  1339. /// <returns></returns>
  1340. public DataTable GetMouldAccountRecord(string queryJson, ref Pagination jqgridparam)
  1341. {
  1342. var queryParam = queryJson.ToJObject();
  1343. DataTable dt = new DataTable();
  1344. //var queryParam = queryJson.ToJObject();
  1345. List<DbParameter> parameter = new List<DbParameter>();
  1346. string sql = @"SELECT [ID], [MouldCode], [MouldNumber], [MouldName], [MajorStates], [SubStates], [UpperLimit], [LowerLimit], [DailyUses],
  1347. [TotalUses], [Users], [UserDate], [Picture], [MUser], [MUSERName], [MTIME], [EATTRIBUTE1] FROM ICSMouldAccount WHERE 1=1 ";
  1348. if (queryParam["MouldCode"] != null && queryParam["MouldCode"].ToString() != "")
  1349. {
  1350. sql = sql + $@"and MouldCode='{queryParam["MouldCode"]}' ";
  1351. }
  1352. if (queryParam["MouldNumber"] != null && queryParam["MouldNumber"].ToString() != "")
  1353. {
  1354. sql = sql + $@"and MouldNumber='{queryParam["MouldNumber"]}' ";
  1355. }
  1356. if (queryParam["MouldName"] != null && queryParam["MouldName"].ToString() != "")
  1357. {
  1358. sql = sql + $@" and MouldCode='{queryParam["MouldName"]}'";
  1359. }
  1360. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1361. }
  1362. public void UpdateICSBadReasonGroup(ICSBadReason main, string BID, string BRGCode, string BRGDesc)
  1363. {
  1364. string sql = string.Empty;
  1365. string sqls = string.Empty;
  1366. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1367. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1368. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1369. List<ICSBadReason> list_Item1 = new List<ICSBadReason>();
  1370. if (main.arrayShellFabricItem != null)
  1371. {
  1372. list_Item1 = JsonConvert.DeserializeObject<List<ICSBadReason>>(main.arrayShellFabricItem);
  1373. }
  1374. string connString = SqlHelper.DataCenterConnString;
  1375. SqlConnection conn = new SqlConnection(connString);
  1376. conn.Open();
  1377. SqlTransaction sqlTran = conn.BeginTransaction();
  1378. SqlCommand cmd = new SqlCommand();
  1379. cmd.Transaction = sqlTran;
  1380. cmd.Connection = conn;
  1381. sql = @"UPDATE dbo.ICSBadReasonGroup set BRGCode='{0}',BRGDesc='{1}',MTIME=GETDATE(),MUSER='{2}',MUSERName='{3}',WorkPoint='{4}' WHERE ID='{5}'";
  1382. sql = string.Format(sql, BRGCode, BRGDesc, MUSER, MUSERNAME, WorkPoint, BID);
  1383. try
  1384. {
  1385. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1386. {
  1387. foreach (ICSBadReason Item in list_Item1)
  1388. {
  1389. sqls = @" IF NOT EXISTS(SELECT * FROM ICSBadReason WHERE ID=@ID)
  1390. BEGIN
  1391. INSERT INTO ICSBadReason( ID,BRGroupID,BadReasonCode,BadReasonDesc,MTIME,MUSER,MUSERName,WorkPoint)
  1392. VALUES (@ID,'{0}',@BadReasonCode,@BadReasonDesc,getdate(),'{1}','{2}','{3}')
  1393. END
  1394. ELSE
  1395. BEGIN
  1396. UPDATE dbo.ICSBadReason set BRGroupID='{0}',BadReasonCode=@BadReasonCode,BadReasonDesc=@BadReasonDesc,MTIME=GETDATE(),MUSER='{1}',MUSERName='{2}',WorkPoint='{3}' WHERE ID=@ID
  1397. end
  1398. ";
  1399. sqls = string.Format(sqls, BID, MUSER, MUSERNAME, WorkPoint);
  1400. SqlParameter[] sp_Item = {
  1401. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  1402. new SqlParameter("@BadReasonCode",DbType.String){ Value= Item.BadReasonCode},
  1403. new SqlParameter("@BadReasonDesc",DbType.String){ Value= Item.BadReasonDesc},
  1404. };
  1405. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  1406. }
  1407. cmd.Transaction.Commit();
  1408. }
  1409. }
  1410. catch (Exception ex)
  1411. {
  1412. cmd.Transaction.Rollback();
  1413. throw new Exception(ex.Message);
  1414. }
  1415. finally
  1416. {
  1417. if (conn.State == ConnectionState.Open)
  1418. {
  1419. conn.Close();
  1420. }
  1421. conn.Dispose();
  1422. }
  1423. }
  1424. /// <summary>
  1425. /// 删除不良代码组
  1426. /// </summary>
  1427. /// <param name="keyValue">传入ID</param>
  1428. /// <returns></returns>
  1429. public string DeleteICSBadCodeGroup(string keyValue)
  1430. {
  1431. //站点信息
  1432. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1433. string msg = "";
  1434. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1435. string sql = string.Empty;
  1436. sql += string.Format(@"DELETE FROM dbo.ICSBadCodeGroup WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1437. sql += string.Format(@"DELETE FROM dbo.ICSBadCode WHERE BCGroupID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1438. try
  1439. {
  1440. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1441. {
  1442. }
  1443. }
  1444. catch (Exception ex)
  1445. {
  1446. throw new Exception(ex.Message);
  1447. }
  1448. return msg;
  1449. }
  1450. /// <summary>
  1451. /// 删除不良原因组
  1452. /// </summary>
  1453. /// <param name="keyValue">传入ID</param>
  1454. /// <returns></returns>
  1455. public string DeleteICSBadReasonGroup(string keyValue)
  1456. {
  1457. //站点信息
  1458. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1459. string msg = "";
  1460. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1461. string sql = string.Empty;
  1462. sql += string.Format(@"DELETE FROM dbo.ICSBadReasonGroup WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1463. sql += string.Format(@"DELETE FROM dbo.ICSBadReason WHERE BRGroupID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1464. try
  1465. {
  1466. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1467. {
  1468. }
  1469. }
  1470. catch (Exception ex)
  1471. {
  1472. throw new Exception(ex.Message);
  1473. }
  1474. return msg;
  1475. }
  1476. /// <summary>
  1477. /// 初次加载查询检验项目组
  1478. /// </summary>
  1479. /// <param name="jqgridparam"></param>
  1480. /// <returns></returns>
  1481. public DataTable GetICSInspectionGroup(ref Pagination jqgridparam, string queryJson)
  1482. {
  1483. DataTable dt = new DataTable();
  1484. var queryParam = queryJson.ToJObject();
  1485. List<DbParameter> parameter = new List<DbParameter>();
  1486. string sql = @"select ID,GroupCode,GroupName,Enable,MUSER,MUSERName,MTIME from ICSInspectionGroup ";
  1487. sql += " WHERE 1=1";
  1488. if (!string.IsNullOrWhiteSpace(queryJson))
  1489. {
  1490. if (!string.IsNullOrWhiteSpace(queryParam["ListCode"].ToString()))
  1491. {
  1492. sql += " and GroupCode like '%" + queryParam["ListCode"].ToString() + "%' ";
  1493. }
  1494. if (!string.IsNullOrWhiteSpace(queryParam["ListName"].ToString()))
  1495. {
  1496. sql += " and GroupName like '%" + queryParam["ListName"].ToString() + "%' ";
  1497. }
  1498. }
  1499. sql = string.Format(sql);
  1500. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1501. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1502. }
  1503. /// <summary>
  1504. /// 检验项目子表查询
  1505. /// </summary>
  1506. /// <param name="queryJson"></param>
  1507. /// <param name="jqgridparam"></param>
  1508. /// <returns></returns>
  1509. public DataTable ICSInspectionList(string GroupCode, ref Pagination jqgridparam)
  1510. {
  1511. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1512. DataTable dt = new DataTable();
  1513. //var queryParam = queryJson.ToJObject();
  1514. List<DbParameter> parameter = new List<DbParameter>();
  1515. string sql = @"select GroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable,MUSERName,MTIME,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,
  1516. EATTRIBUTE9,EATTRIBUTE10
  1517. from ICSInspectionList
  1518. WHERE GroupID='" + GroupCode + "' ";
  1519. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1520. }
  1521. /// <summary>
  1522. /// 根据id删除自动表
  1523. /// </summary>
  1524. /// <param name="ID"></param>
  1525. public void DeleteList(string ID)
  1526. {
  1527. string sql = "DELETE FROM dbo.ICSInspectionList WHERE ID='" + ID + "'";
  1528. SqlHelper.ExecuteNonQuery(sql);
  1529. }
  1530. /// <summary>
  1531. /// 检查项目组修改
  1532. /// </summary>
  1533. /// <param name="main"></param>
  1534. /// <param name="BID"></param>
  1535. /// <param name="GroupCode"></param>
  1536. /// <param name="GroupName"></param>
  1537. /// <param name="Enable"></param>
  1538. public void UpdateICSInspectionGroup(ICSInspectionList main, string BID, string GroupCode, string GroupName, string Enable)
  1539. {
  1540. string sql = string.Empty;
  1541. string sqls = string.Empty;
  1542. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1543. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1544. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1545. List<ICSInspectionList> list_Item1 = new List<ICSInspectionList>();
  1546. if (main.arrayShellFabricItem != null)
  1547. {
  1548. list_Item1 = JsonConvert.DeserializeObject<List<ICSInspectionList>>(main.arrayShellFabricItem);
  1549. }
  1550. string connString = SqlHelper.DataCenterConnString;
  1551. SqlConnection conn = new SqlConnection(connString);
  1552. conn.Open();
  1553. SqlTransaction sqlTran = conn.BeginTransaction();
  1554. SqlCommand cmd = new SqlCommand();
  1555. cmd.Transaction = sqlTran;
  1556. cmd.Connection = conn;
  1557. sql = @"UPDATE dbo.ICSInspectionGroup set GroupCode='{0}',GroupName='{1}',Enable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
  1558. sql = string.Format(sql, GroupCode, GroupName, Enable, MUSER, MUSERNAME, WorkPoint, BID);
  1559. try
  1560. {
  1561. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1562. {
  1563. foreach (ICSInspectionList Item in list_Item1)
  1564. {
  1565. sqls = @" IF NOT EXISTS(SELECT * FROM ICSInspectionList WHERE ID=@ID)
  1566. BEGIN
  1567. INSERT INTO ICSInspectionList( ID,GroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable,MTIME,MUSER,MUSERName,WorkPoint)
  1568. VALUES (@ID,'{0}',@ListCode,@ListName,@Unit,@SetValueMax,@SetValueMin,@Enable,getdate(),'{1}','{2}','{3}')
  1569. END
  1570. ELSE
  1571. BEGIN
  1572. 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
  1573. end
  1574. ";
  1575. sqls = string.Format(sqls, BID, MUSER, MUSERNAME, WorkPoint);
  1576. SqlParameter[] sp_Item = {
  1577. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  1578. new SqlParameter("@ListCode",DbType.String){ Value= Item.ListCode},
  1579. new SqlParameter("@ListName",DbType.String){ Value= Item.ListName},
  1580. new SqlParameter("@Unit",DbType.String){ Value= Item.Unit},
  1581. new SqlParameter("@SetValueMax",DbType.String){ Value= Item.SetValueMax},
  1582. new SqlParameter("@SetValueMin",DbType.String){ Value= Item.SetValueMin},
  1583. new SqlParameter("@Enable",DbType.String){ Value= Item.Enable},
  1584. };
  1585. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  1586. }
  1587. cmd.Transaction.Commit();
  1588. }
  1589. }
  1590. catch (Exception ex)
  1591. {
  1592. cmd.Transaction.Rollback();
  1593. throw new Exception(ex.Message);
  1594. }
  1595. finally
  1596. {
  1597. if (conn.State == ConnectionState.Open)
  1598. {
  1599. conn.Close();
  1600. }
  1601. conn.Dispose();
  1602. }
  1603. }
  1604. /// <summary>
  1605. /// 检查项目组新增
  1606. /// </summary>
  1607. /// <param name="main"></param>
  1608. /// <param name="BRGCode"></param>
  1609. /// <param name="BRGDesc"></param>
  1610. public void ICSInspectionGroupAdd(ICSInspectionList main, string GroupCode, string GroupName, string Enable)
  1611. {
  1612. string sql = string.Empty;
  1613. string sqls = string.Empty;
  1614. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1615. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1616. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1617. string ID = Guid.NewGuid().ToString();
  1618. List<ICSInspectionList> list_Item1 = new List<ICSInspectionList>();
  1619. if (main.arrayShellFabricItem != null)
  1620. {
  1621. list_Item1 = JsonConvert.DeserializeObject<List<ICSInspectionList>>(main.arrayShellFabricItem);
  1622. }
  1623. string connString = SqlHelper.DataCenterConnString;
  1624. SqlConnection conn = new SqlConnection(connString);
  1625. conn.Open();
  1626. SqlTransaction sqlTran = conn.BeginTransaction();
  1627. SqlCommand cmd = new SqlCommand();
  1628. cmd.Transaction = sqlTran;
  1629. cmd.Connection = conn;
  1630. sql = @"
  1631. IF EXISTS(select GroupCode from ICSInspectionGroup where GroupCode='{0}')
  1632. BEGIN
  1633. RAISERROR('',16,1);
  1634. RETURN
  1635. end
  1636. INSERT INTO dbo.ICSInspectionGroup
  1637. ( ID ,GroupCode ,GroupName,Enable, MTIME,MUSER ,MUSERName ,WorkPoint )
  1638. Values('{6}','{0}','{1}','{2}',GETDATE(),'{3}','{4}','{5}')";
  1639. sql = string.Format(sql, GroupCode, GroupName, Enable, MUSER, MUSERNAME, WorkPoint,ID);
  1640. try
  1641. {
  1642. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1643. {
  1644. foreach (ICSInspectionList Item in list_Item1)
  1645. {
  1646. sqls = @"
  1647. IF EXISTS(select ListCode from ICSInspectionList where ListCode=@ListCode)
  1648. BEGIN
  1649. RAISERROR('',16,1);
  1650. RETURN
  1651. end
  1652. INSERT INTO dbo.ICSInspectionList
  1653. ( ID ,GroupID,ListCode ,ListName, Unit,SetValueMax ,SetValueMin,Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
  1654. Values(@ID,'{0}',@ListCode,@ListName,@Unit,@SetValueMax,@SetValueMin,@Enable,getdate(),'{1}','{2}','{3}')";
  1655. sqls = string.Format(sqls, ID, MUSER, MUSERNAME, WorkPoint);
  1656. SqlParameter[] sp_Item = {
  1657. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  1658. new SqlParameter("@ListCode",DbType.String){ Value= Item.ListCode},
  1659. new SqlParameter("@ListName",DbType.String){ Value= Item.ListName},
  1660. new SqlParameter("@Unit",DbType.String){ Value= Item.Unit},
  1661. new SqlParameter("@SetValueMax",DbType.String){ Value= Item.SetValueMax},
  1662. new SqlParameter("@SetValueMin",DbType.String){ Value= Item.SetValueMin},
  1663. new SqlParameter("@Enable",DbType.String){ Value= Item.Enable},
  1664. };
  1665. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  1666. }
  1667. cmd.Transaction.Commit();
  1668. }
  1669. }
  1670. catch (Exception ex)
  1671. {
  1672. cmd.Transaction.Rollback();
  1673. throw new Exception(ex.Message);
  1674. }
  1675. finally
  1676. {
  1677. if (conn.State == ConnectionState.Open)
  1678. {
  1679. conn.Close();
  1680. }
  1681. conn.Dispose();
  1682. }
  1683. }
  1684. /// <summary>
  1685. /// 动态子表修改加载页面
  1686. /// </summary>
  1687. /// <param name="GroupCode"></param>
  1688. /// <returns></returns>
  1689. public DataTable ICSInspectionList2(string GroupCode)
  1690. {
  1691. string sql = string.Empty;
  1692. DataTable dt = null;
  1693. sql = string.Format(@"SELECT ID,GroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,
  1694. case when Enable='1' then '是' else '否' end as Enable,
  1695. MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1 FROM
  1696. dbo.ICSInspectionList where GroupID='{0}'", GroupCode);
  1697. dt = SqlHelper.GetDataTableBySql(sql);
  1698. return dt;
  1699. }
  1700. /// <summary>
  1701. /// 删除不良原因组
  1702. /// </summary>
  1703. /// <param name="keyValue">传入ID</param>
  1704. /// <returns></returns>
  1705. public string DeleteICSInspectionGroup(string keyValue)
  1706. {
  1707. //站点信息
  1708. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1709. string msg = "";
  1710. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1711. string sql = string.Empty;
  1712. string sqls = string.Empty;
  1713. sql = string.Format(@"DELETE FROM dbo.ICSInspectionGroup WHERE GroupCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1714. try
  1715. {
  1716. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1717. {
  1718. sqls = string.Format(@"DELETE FROM dbo.ICSInspectionList WHERE GroupID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1719. SqlHelper.ExecuteNonQuery(sqls);
  1720. }
  1721. }
  1722. catch (Exception ex)
  1723. {
  1724. throw new Exception(ex.Message);
  1725. }
  1726. return msg;
  1727. }
  1728. /// <summary>
  1729. /// 新增料品属性
  1730. /// </summary>
  1731. /// <param name="queryJson"></param>
  1732. /// <returns></returns>
  1733. public string InsertICSInventory(string keyValue)
  1734. {
  1735. var queryParam = keyValue.ToJObject();
  1736. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1737. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1738. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1739. string msg = "";
  1740. string sql = string.Empty;
  1741. sql = @"INSERT INTO dbo.ICSInventory
  1742. ( ID ,InvCode ,InvName ,InvDesc,InvStd,InvUnit,AmountUnit ,ClassCode ,ClassName ,InvRate,InvVersion,InvBrand,InvIQC ,InvFQC ,EffectiveEnable,EffectiveDays,BatchEnable,LotEnable ,PrintEnable ,WHUser,MTIME,MUSER ,MUSERName ,WorkPoint ,AmountEnable)
  1743. 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}','{22}')
  1744. ";
  1745. sql = string.Format(sql,
  1746. queryParam["InvCode"].ToString(),
  1747. queryParam["InvName"].ToString(),
  1748. queryParam["InvDesc"].ToString(),
  1749. queryParam["InvStd"].ToString(),
  1750. queryParam["InvUnit"].ToString(),
  1751. queryParam["AmountUnit"].ToString(),
  1752. queryParam["ClassCode"].ToString(),
  1753. queryParam["ClassName"].ToString(),
  1754. queryParam["InvRate"].ToString(),
  1755. queryParam["InvVersion"].ToString(),
  1756. queryParam["InvBrand"].ToString(),
  1757. queryParam["InvIQC"].ToString(),
  1758. queryParam["InvFQC"].ToString(),
  1759. queryParam["EffectiveEnable"].ToString(),
  1760. queryParam["EffectiveDays"].ToString(),
  1761. queryParam["BatchEnable"].ToString(),
  1762. queryParam["LotEnable"].ToString(),
  1763. queryParam["PrintEnable"].ToString(),
  1764. queryParam["WHUser"].ToString(),
  1765. MUSER, MUSERNAME, WorkPoint, queryParam["AmountEnable"].ToString());
  1766. try
  1767. {
  1768. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1769. {
  1770. }
  1771. else
  1772. {
  1773. msg = "新增失败";
  1774. }
  1775. }
  1776. catch (Exception ex)
  1777. {
  1778. throw new Exception(ex.Message);
  1779. }
  1780. return msg;
  1781. }
  1782. /// <summary>
  1783. /// 新增周转箱台账信息
  1784. /// </summary>
  1785. /// <param name="queryJson"></param>
  1786. /// <returns></returns>
  1787. public string InsertBoxAccount(string keyValue)
  1788. {
  1789. var queryParam = keyValue.ToJObject();
  1790. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1791. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1792. string msg = "";
  1793. string sql = string.Empty;
  1794. sql = $@"IF ((SELECT 1 FROM ICSWorkingCapitalBoxAccount WHERE BoxCode='{queryParam["BoxCode"]}') IS NULL)
  1795. BEGIN
  1796. INSERT INTO[dbo].[ICSWorkingCapitalBoxAccount]([ID], [BoxCode], [BoxNumber], [BoxName], [States], [Describe], [DailyUses], [TotalUses], [TotalClearn], [MUser], [MUSERName], [MTIME]) VALUES(NEWID(), '{queryParam["BoxCode"]}', '{queryParam["BoxNumber"]}', '{queryParam["BoxName"]}', '', '{queryParam["Describe"]}', 0, 0, 0, '{MUSER}', '{MUSERNAME}', GETDATE())
  1797. END
  1798. ELSE
  1799. BEGIN
  1800. RAISERROR('', 16, 1);
  1801. END ";
  1802. try
  1803. {
  1804. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1805. {
  1806. }
  1807. else
  1808. {
  1809. msg = "新增失败";
  1810. }
  1811. }
  1812. catch (Exception ex)
  1813. {
  1814. throw new Exception(ex.Message);
  1815. }
  1816. return msg;
  1817. }
  1818. /// <summary>
  1819. /// 新增模具账信息
  1820. /// </summary>
  1821. /// <param name="queryJson"></param>
  1822. /// <returns></returns>
  1823. public string InsertMouldAccount(string keyValue)
  1824. {
  1825. var queryParam = keyValue.ToJObject();
  1826. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1827. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1828. string msg = "";
  1829. string sql = string.Empty;
  1830. sql = $@"IF ((SELECT 1 FROM ICSMouldAccount WHERE MouldCode='{queryParam["MouldCode"]}') IS NULL)
  1831. BEGIN
  1832. INSERT INTO[dbo].[ICSMouldAccount]([ID], [MouldCode], [MouldNumber], [MouldName], [MajorStates],[UpperLimit], [LowerLimit], [Picture], [MUser], [MUSERName], [MTIME],[DailyUses],[TotalUses]) VALUES(NEWID(), '{queryParam["MouldCode"]}', '{queryParam["MouldNumber"]}', '{queryParam["MouldName"]}','{queryParam["Status"]}',{queryParam["UpperLimit"]}, {queryParam["LowerLimit"]},'{queryParam["Picture"]}','{MUSER}', '{MUSERNAME}', GETDATE(),0,0)
  1833. END
  1834. ELSE
  1835. BEGIN
  1836. RAISERROR('', 16, 1);
  1837. END ";
  1838. try
  1839. {
  1840. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1841. {
  1842. }
  1843. else
  1844. {
  1845. msg = "新增失败";
  1846. }
  1847. }
  1848. catch (Exception ex)
  1849. {
  1850. throw new Exception(ex.Message);
  1851. }
  1852. return msg;
  1853. }
  1854. /// <summary>
  1855. /// 修改料品属性
  1856. /// </summary>
  1857. /// <param name="queryJson"></param>
  1858. /// <returns></returns>
  1859. public string UpdateICSInventory(string keyValue)
  1860. {
  1861. var queryParam = keyValue.ToJObject();
  1862. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1863. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1864. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1865. string msg = "";
  1866. string sql = string.Empty;
  1867. sql = @"UPDATE dbo.ICSInventory set
  1868. InvCode='{0}'
  1869. ,InvName='{1}'
  1870. ,InvDesc='{2}'
  1871. ,InvStd='{3}'
  1872. ,InvUnit='{4}'
  1873. ,AmountUnit='{5}'
  1874. ,ClassCode='{6}'
  1875. ,ClassName='{7}'
  1876. ,InvRate='{8}'
  1877. ,InvVersion='{9}'
  1878. ,InvBrand='{10}'
  1879. ,InvIQC='{11}'
  1880. ,InvFQC='{12}'
  1881. ,EffectiveEnable='{13}'
  1882. ,EffectiveDays='{14}'
  1883. ,BatchEnable='{15}'
  1884. ,LotEnable='{16}'
  1885. ,PrintEnable='{17}'
  1886. ,AmountEnable='{23}'
  1887. ,WHUser='{18}'
  1888. ,MTIME=GETDATE()
  1889. ,MUSER='{19}'
  1890. ,MUSERName='{20}'
  1891. ,WorkPoint='{21}'
  1892. WHERE ID='{22}'";
  1893. sql = string.Format(sql,
  1894. queryParam["InvCode"].ToString(),
  1895. queryParam["InvName"].ToString(),
  1896. queryParam["InvDesc"].ToString(),
  1897. queryParam["InvStd"].ToString(),
  1898. queryParam["InvUnit"].ToString(),
  1899. queryParam["AmountUnit"].ToString(),
  1900. queryParam["ClassCode"].ToString(),
  1901. queryParam["ClassName"].ToString(),
  1902. queryParam["InvRate"].ToString(),
  1903. queryParam["InvVersion"].ToString(),
  1904. queryParam["InvBrand"].ToString(),
  1905. queryParam["InvIQC"].ToString(),
  1906. queryParam["InvFQC"].ToString(),
  1907. queryParam["EffectiveEnable"].ToString(),
  1908. queryParam["EffectiveDays"].ToString(),
  1909. queryParam["BatchEnable"].ToString(),
  1910. queryParam["LotEnable"].ToString(),
  1911. queryParam["PrintEnable"].ToString(),
  1912. queryParam["WHUser"].ToString(),
  1913. MUSER, MUSERNAME, WorkPoint,
  1914. queryParam["ID"].ToString(), queryParam["AmountEnable"].ToString());
  1915. try
  1916. {
  1917. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1918. {
  1919. }
  1920. else
  1921. {
  1922. msg = "修改失败";
  1923. }
  1924. }
  1925. catch (Exception ex)
  1926. {
  1927. throw new Exception(ex.Message);
  1928. }
  1929. return msg;
  1930. }
  1931. /// <summary>
  1932. /// 修改周转箱台账
  1933. /// </summary>
  1934. /// <param name="queryJson"></param>
  1935. /// <returns></returns>
  1936. public string UpdateBoxAccount(string keyValue)
  1937. {
  1938. var queryParam = keyValue.ToJObject();
  1939. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1940. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1941. string msg = "";
  1942. string sql = string.Empty;
  1943. sql = $@"UPDATE [dbo].[ICSWorkingCapitalBoxAccount] SET [BoxNumber] = '{queryParam["BoxNumber"]}', [BoxName] = '{queryParam["BoxName"]}', [Describe] = '{queryParam["Describe"]}' WHERE ID='{queryParam["ID"]}'";
  1944. try
  1945. {
  1946. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1947. {
  1948. }
  1949. else
  1950. {
  1951. msg = "修改失败";
  1952. }
  1953. }
  1954. catch (Exception ex)
  1955. {
  1956. throw new Exception(ex.Message);
  1957. }
  1958. return msg;
  1959. }
  1960. /// <summary>
  1961. /// 修改模具台账
  1962. /// </summary>
  1963. /// <param name="queryJson"></param>
  1964. /// <returns></returns>
  1965. public string UpdateMouldAccount(string keyValue)
  1966. {
  1967. var queryParam = keyValue.ToJObject();
  1968. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1969. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1970. string msg = "";
  1971. string sql = string.Empty;
  1972. if (!string.IsNullOrEmpty(queryParam["Picture"].ToString()))
  1973. {
  1974. sql = $@"UPDATE [dbo].[ICSMouldAccount] SET [MouldNumber] = '{queryParam["MouldNumber"]}', [MouldName] = '{queryParam["MouldName"]}', [MajorStates] = '{queryParam["Status"]}', [UpperLimit] = {queryParam["UpperLimit"]}, [LowerLimit] = {queryParam["LowerLimit"]}, [Picture] = '{queryParam["Picture"]}' WHERE ID='{queryParam["ID"]}'";
  1975. }
  1976. else
  1977. {
  1978. sql = $@"UPDATE [dbo].[ICSMouldAccount] SET [MouldNumber] = '{queryParam["MouldNumber"]}', [MouldName] = '{queryParam["MouldName"]}', [MajorStates] = '{queryParam["Status"]}', [UpperLimit] = {queryParam["UpperLimit"]}, [LowerLimit] = {queryParam["LowerLimit"]} WHERE ID='{queryParam["ID"]}'";
  1979. }
  1980. try
  1981. {
  1982. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1983. {
  1984. }
  1985. else
  1986. {
  1987. msg = "修改失败";
  1988. }
  1989. }
  1990. catch (Exception ex)
  1991. {
  1992. throw new Exception(ex.Message);
  1993. }
  1994. return msg;
  1995. }
  1996. /// <summary>
  1997. /// 修改PDA版本
  1998. /// </summary>
  1999. /// <param name="queryJson"></param>
  2000. /// <returns></returns>
  2001. public string UpdatePDAVersion(string keyValue)
  2002. {
  2003. var queryParam = keyValue.ToJObject();
  2004. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2005. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2006. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2007. string msg = "";
  2008. string sql = string.Empty;
  2009. sql = @"UPDATE ICSVersions SET Version='{2}',URL='{3}',MUSERCode='{4}',MUSERName='{5}',MTIME=CONVERT(nvarchar(50),GETDATE(),120) WHERE guid='{0}' AND WorkPointCode IN('{1}')";
  2010. sql = string.Format(sql,
  2011. queryParam["guid"].ToString(),
  2012. WorkPoint,
  2013. queryParam["Version"].ToString(),
  2014. queryParam["URL"].ToString(),
  2015. MUSER,
  2016. MUSERNAME);
  2017. try
  2018. {
  2019. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2020. {
  2021. }
  2022. else
  2023. {
  2024. msg = "修改失败";
  2025. }
  2026. }
  2027. catch (Exception ex)
  2028. {
  2029. throw new Exception(ex.Message);
  2030. }
  2031. return msg;
  2032. }
  2033. /// <summary>
  2034. /// 获取下拉料品号获取其他信息
  2035. /// </summary>
  2036. public DataTable GetInputValue(string ID)
  2037. {
  2038. try
  2039. {
  2040. DataTable dt = new DataTable();
  2041. //var queryParam = queryJson.ToJObject();
  2042. List<DbParameter> parameter = new List<DbParameter>();
  2043. string sql = @"select InvCode,InvName,InvDesc,InvStd,InvUnit,AmountUnit, ClassCode,ClassName,InvRate,InvVersion,InvBrand,InvIQC,
  2044. InvFQC,EffectiveEnable,EffectiveDays,BatchEnable,LotEnable,PrintEnable,WHUser,AmountEnable
  2045. from ICSInventory
  2046. WHERE 1=1 AND ID='{0}' ";
  2047. sql = string.Format(sql, ID);
  2048. return Repository().FindTableBySql(sql.ToString());
  2049. }
  2050. catch (Exception ex)
  2051. {
  2052. throw new Exception(ex.Message.ToString());
  2053. }
  2054. }
  2055. /// <summary>
  2056. /// 删除料品属性
  2057. /// </summary>
  2058. /// <param name="keyValue">传入ID</param>
  2059. /// <returns></returns>
  2060. public string DeleteICSInventory(string keyValue)
  2061. {
  2062. //站点信息
  2063. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2064. string msg = "";
  2065. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2066. string sql = string.Empty;
  2067. sql = string.Format(@"DELETE FROM dbo.ICSInventory WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2068. try
  2069. {
  2070. SqlHelper.ExecuteNonQuery(sql);
  2071. }
  2072. catch (Exception ex)
  2073. {
  2074. throw new Exception(ex.Message);
  2075. }
  2076. return msg;
  2077. }
  2078. /// <summary>
  2079. /// 删除条码
  2080. /// </summary>
  2081. /// <param name="keyValue">传入ID</param>
  2082. /// <returns></returns>
  2083. public string DeleteICSLotNo(string keyValue)
  2084. {
  2085. //站点信息
  2086. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2087. string msg = "";
  2088. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2089. string sql = string.Empty;
  2090. sql = string.Format(@"DELETE FROM dbo.ICSInventoryLot WHERE LotNo IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2091. try
  2092. {
  2093. SqlHelper.ExecuteNonQuery(sql);
  2094. }
  2095. catch (Exception ex)
  2096. {
  2097. throw new Exception(ex.Message);
  2098. }
  2099. return msg;
  2100. }
  2101. /// <summary>
  2102. /// 删除周转箱台账信息
  2103. /// </summary>
  2104. /// <param name="keyValue">传入ID</param>
  2105. /// <returns></returns>
  2106. public string DeleteBoxAccount(string keyValue)
  2107. {
  2108. //站点信息
  2109. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2110. string msg = "";
  2111. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2112. string sql = string.Empty;
  2113. sql = string.Format(@"DELETE FROM dbo.ICSWorkingCapitalBoxAccount WHERE ID IN ({0})", keyValue.TrimEnd(','));
  2114. try
  2115. {
  2116. SqlHelper.ExecuteNonQuery(sql);
  2117. }
  2118. catch (Exception ex)
  2119. {
  2120. throw new Exception(ex.Message);
  2121. }
  2122. return msg;
  2123. }
  2124. /// <summary>
  2125. /// 获取料品信息
  2126. /// </summary>
  2127. /// <param name="jqgridparam"></param>
  2128. /// <returns></returns>
  2129. public DataTable GetICSInventoryInfo(string queryJson, ref Pagination jqgridparam)
  2130. {
  2131. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2132. DataTable dt = new DataTable();
  2133. var queryParam = queryJson.ToJObject();
  2134. List<DbParameter> parameter = new List<DbParameter>();
  2135. string sql = @"select ID, InvCode,InvName,InvDesc,InvStd,InvUnit,AmountUnit,ClassCode,ClassName,InvRate,InvVersion,InvBrand,
  2136. InvIQC,InvFQC,EffectiveEnable,EffectiveDays,BatchEnable,LotEnable,PrintEnable,WHUser
  2137. from ICSInventory where WorkPoint='{0}' ";
  2138. sql = string.Format(sql, WorkPoint);
  2139. if (!string.IsNullOrWhiteSpace(queryJson))
  2140. {
  2141. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2142. {
  2143. sql += " and InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2144. }
  2145. }
  2146. // DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2147. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2148. }
  2149. /// <summary>
  2150. /// 获取仓库信息
  2151. /// </summary>
  2152. /// <param name="jqgridparam"></param>
  2153. /// <returns></returns>
  2154. public DataTable GetICSWarehouseInfo(string queryJson, ref Pagination jqgridparam)
  2155. {
  2156. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2157. DataTable dt = new DataTable();
  2158. var queryParam = queryJson.ToJObject();
  2159. List<DbParameter> parameter = new List<DbParameter>();
  2160. string sql = @"select ID,WarehouseCode,WarehouseName ,Enable,BatchEnable,Asset,Proxy,InCost from ICSWarehouse where WorkPoint='{0}' ";
  2161. sql = string.Format(sql, WorkPoint);
  2162. if (!string.IsNullOrWhiteSpace(queryJson))
  2163. {
  2164. if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString()))
  2165. {
  2166. sql += " and WarehouseCode like '%" + queryParam["WHCode"].ToString() + "%' ";
  2167. }
  2168. }
  2169. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2170. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2171. }
  2172. /// <summary>
  2173. /// 新增料品仓库批次关系
  2174. /// </summary>
  2175. /// <param name="queryJson"></param>
  2176. /// <returns></returns>
  2177. public string InsertICSInventoryBatchEnable(string keyValue, string keyValue2)
  2178. {
  2179. List<string> InvCodeList = keyValue.Substring(1, keyValue.Length - 3).Split(',').ToList<string>();
  2180. List<string> WarehouseCodeList = keyValue2.Substring(1, keyValue2.Length - 3).Split(',').ToList<string>();
  2181. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2182. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2183. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2184. string msg = "";
  2185. string sql = string.Empty;
  2186. foreach (var item in InvCodeList)
  2187. {
  2188. foreach (var itemwh in WarehouseCodeList)
  2189. {
  2190. sql += @"IF EXISTS(select InvCode,WHCode from ICSInventoryBatchEnable where InvCode={0} and WHCode={1})
  2191. BEGIN
  2192. RAISERROR('',16,1);
  2193. RETURN
  2194. end
  2195. INSERT INTO dbo.ICSInventoryBatchEnable
  2196. ( ID ,InvCode ,WHCode ,BatchEnable,MTIME,MUSER ,MUSERName ,WorkPoint )
  2197. Values(NEWID(),{0},{1},'{2}',GETDATE(),'{3}','{4}','{5}')
  2198. ";
  2199. sql = string.Format(sql, item, itemwh, '1'.ToString(), MUSER, MUSERNAME, WorkPoint);
  2200. }
  2201. }
  2202. try
  2203. {
  2204. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2205. {
  2206. }
  2207. else
  2208. {
  2209. msg = "新增失败";
  2210. }
  2211. }
  2212. catch (Exception ex)
  2213. {
  2214. msg = ex.Message;
  2215. }
  2216. return msg;
  2217. }
  2218. /// <summary>
  2219. /// 修改料品仓库批次关系
  2220. /// </summary>
  2221. /// <param name="queryJson"></param>
  2222. /// <returns></returns>
  2223. public string UpdateICSInventoryBatchEnable(string keyValue)
  2224. {
  2225. var queryParam = keyValue.ToJObject();
  2226. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2227. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2228. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2229. string msg = "";
  2230. string sql = string.Empty;
  2231. sql = @"UPDATE dbo.ICSInventoryBatchEnable set InvCode='{0}',WHCode='{1}',BatchEnable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
  2232. sql = string.Format(sql, queryParam["InvCode"].ToString(), queryParam["WHCode"].ToString(), queryParam["BatchEnable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  2233. try
  2234. {
  2235. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2236. {
  2237. }
  2238. else
  2239. {
  2240. msg = "修改失败";
  2241. }
  2242. }
  2243. catch (Exception ex)
  2244. {
  2245. throw new Exception(ex.Message);
  2246. }
  2247. return msg;
  2248. }
  2249. /// <summary>
  2250. /// 删除料品仓库批次关系
  2251. /// </summary>
  2252. /// <param name="keyValue">传入ID</param>
  2253. /// <returns></returns>
  2254. public string DeleteICSInventoryBatchEnable(string keyValue)
  2255. {
  2256. //站点信息
  2257. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2258. string msg = "";
  2259. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2260. string sql = string.Empty;
  2261. sql = string.Format(@"DELETE FROM dbo.ICSInventoryBatchEnable WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2262. try
  2263. {
  2264. SqlHelper.ExecuteNonQuery(sql);
  2265. }
  2266. catch (Exception ex)
  2267. {
  2268. throw new Exception(ex.Message);
  2269. }
  2270. return msg;
  2271. }
  2272. /// <summary>
  2273. /// 获取库位信息
  2274. /// </summary>
  2275. /// <param name="jqgridparam"></param>
  2276. /// <returns></returns>
  2277. public DataTable GetICSLocation(string queryJson, ref Pagination jqgridparam)
  2278. {
  2279. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2280. DataTable dt = new DataTable();
  2281. var queryParam = queryJson.ToJObject();
  2282. List<DbParameter> parameter = new List<DbParameter>();
  2283. string sql = @"select ID,LocationCode,LocationName,WHID,MUSER,MUSERName,MTIME,WorkPoint from ICSLocation where WorkPoint='{0}' ";
  2284. sql = string.Format(sql, WorkPoint);
  2285. if (!string.IsNullOrWhiteSpace(queryJson))
  2286. {
  2287. if (!string.IsNullOrWhiteSpace(queryParam["LocationCode"].ToString()))
  2288. {
  2289. sql += " and LocationCode like '%" + queryParam["LocationCode"].ToString() + "%' ";
  2290. }
  2291. }
  2292. //DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2293. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2294. }
  2295. /// <summary>
  2296. /// 新增料品仓库批次关系
  2297. /// </summary>
  2298. /// <param name="queryJson"></param>
  2299. /// <returns></returns>
  2300. public string InsertICSInventoryLocation(string keyValue, string keyValue2)
  2301. {
  2302. List<string> InvCodeList = keyValue.Substring(1, keyValue.Length - 3).Split(',').ToList<string>();
  2303. List<string> LocationCodeList = keyValue2.Substring(1, keyValue2.Length - 3).Split(',').ToList<string>();
  2304. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2305. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2306. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2307. string msg = "";
  2308. string sql = string.Empty;
  2309. try
  2310. {
  2311. foreach (var item in InvCodeList)
  2312. {
  2313. foreach (var itemwh in LocationCodeList)
  2314. {
  2315. sql += @"IF EXISTS(select InvCode,LocationCode from ICSInventoryLocation where InvCode={0} and LocationCode={1})
  2316. BEGIN
  2317. RAISERROR('',16,1);
  2318. RETURN
  2319. end
  2320. INSERT INTO dbo.ICSInventoryLocation
  2321. ( ID ,InvCode ,LocationCode ,Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
  2322. Values(NEWID(),{0},{1},'{2}',GETDATE(),'{3}','{4}','{5}')
  2323. ";
  2324. sql = string.Format(sql, item, itemwh, '1'.ToString(), MUSER, MUSERNAME, WorkPoint);
  2325. }
  2326. }
  2327. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2328. {
  2329. }
  2330. else
  2331. {
  2332. msg = "新增失败";
  2333. }
  2334. }
  2335. catch (Exception ex)
  2336. {
  2337. msg = ex.Message;
  2338. }
  2339. return msg;
  2340. }
  2341. /// <summary>
  2342. /// 修改料品库位绑定关系
  2343. /// </summary>
  2344. /// <param name="queryJson"></param>
  2345. /// <returns></returns>
  2346. public string UpdateICSInventoryLocation(string keyValue)
  2347. {
  2348. var queryParam = keyValue.ToJObject();
  2349. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2350. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2351. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2352. string msg = "";
  2353. string sql = string.Empty;
  2354. sql = @"UPDATE dbo.ICSInventoryLocation set InvCode='{0}',LocationCode='{1}',Enable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
  2355. sql = string.Format(sql, queryParam["InvCode"].ToString(), queryParam["LocationCode"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  2356. try
  2357. {
  2358. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2359. {
  2360. }
  2361. else
  2362. {
  2363. msg = "修改失败";
  2364. }
  2365. }
  2366. catch (Exception ex)
  2367. {
  2368. throw new Exception(ex.Message);
  2369. }
  2370. return msg;
  2371. }
  2372. /// <summary>
  2373. /// 删除料品仓库批次关系
  2374. /// </summary>
  2375. /// <param name="keyValue">传入ID</param>
  2376. /// <returns></returns>
  2377. public string DeleteICSInventoryLocation(string keyValue)
  2378. {
  2379. //站点信息
  2380. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2381. string msg = "";
  2382. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2383. string sql = string.Empty;
  2384. sql = string.Format(@"DELETE FROM dbo.ICSInventoryLocation WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2385. try
  2386. {
  2387. SqlHelper.ExecuteNonQuery(sql);
  2388. }
  2389. catch (Exception ex)
  2390. {
  2391. throw new Exception(ex.Message);
  2392. }
  2393. return msg;
  2394. }
  2395. /// <summary>
  2396. /// 新增包装、容器
  2397. /// </summary>
  2398. /// <param name="queryJson"></param>
  2399. /// <returns></returns>
  2400. /// 20230717 lacy.xu Modifly 新增允许料品混装、允许项目号混装、允许批次混装、允许复用
  2401. public string InsertICSContainer(string keyValue)
  2402. {
  2403. string msg = "";
  2404. try
  2405. {
  2406. var queryParam = keyValue.ToJObject();
  2407. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2408. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2409. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2410. string sql = string.Empty;
  2411. sql = @"IF EXISTS(select ContainerCODE from ICSContainer where ContainerCODE='{1}' )
  2412. RAISERROR('{1}',16,1)
  2413. else
  2414. INSERT INTO dbo.ICSContainer
  2415. ( ID ,ContainerID ,ContainerCODE ,ContainerName,Memo,MTIME,MUSER ,MUSERName ,WorkPoint
  2416. ,InventoryMixed,ProjectMixed,BatchMixed,Multiplex,ContainerType)
  2417. Values(NEWID(),'{0}','{1}','{2}','{3}',GETDATE(),'{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')
  2418. ";
  2419. sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["ContainerCODE"].ToString(), queryParam["ContainerName"].ToString(), queryParam["Memo"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["InventoryMixed"].ToString(), queryParam["ProjectMixed"].ToString(), queryParam["BatchMixed"].ToString(), queryParam["Multiplex"].ToString(), queryParam["ContainerType"].ToString());
  2420. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2421. {
  2422. }
  2423. else
  2424. {
  2425. msg = "新增失败";
  2426. }
  2427. }
  2428. catch (Exception ex)
  2429. {
  2430. throw new Exception(ex.Message);
  2431. }
  2432. return msg;
  2433. }
  2434. /// <summary>
  2435. /// 修改包装、容器
  2436. /// </summary>
  2437. /// <param name="queryJson"></param>
  2438. /// <returns></returns>
  2439. /// 20230717 lacy.xu Modifly 新增允许料品混装、允许项目号混装、允许批次混装、允许复用
  2440. public string UpdateICSContainer(string keyValue)
  2441. {
  2442. var queryParam = keyValue.ToJObject();
  2443. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2444. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2445. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2446. string msg = "";
  2447. string sql = string.Empty;
  2448. // sql = @" IF EXISTS(select ContainerCODE from ICSContainer where ContainerCODE='{1}' )
  2449. // RAISERROR('容器:{1},已存在!',16,1)
  2450. //UPDATE dbo.ICSContainer set ContainerID='{0}',ContainerCODE='{1}',ContainerName='{2}',Memo='{3}',MTIME=GETDATE(),MUSER='{4}',MUSERName='{5}',WorkPoint='{6}',InventoryMixed='{8}',ProjectMixed='{9}',BatchMixed='{10}',Multiplex='{11}' WHERE ID='{7}'";
  2451. sql = @"UPDATE dbo.ICSContainer set ContainerID='{0}',ContainerCODE='{1}',ContainerName='{2}',Memo='{3}',MTIME=GETDATE(),MUSER='{4}',MUSERName='{5}',WorkPoint='{6}',InventoryMixed='{8}',ProjectMixed='{9}',BatchMixed='{10}',Multiplex='{11}',ContainerType='{12}' WHERE ID='{7}'";
  2452. sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["ContainerCODE"].ToString(), queryParam["ContainerName"].ToString(), queryParam["Memo"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString(), queryParam["InventoryMixed"].ToString(), queryParam["ProjectMixed"].ToString(), queryParam["BatchMixed"].ToString(), queryParam["Multiplex"].ToString(), queryParam["ContainerType"].ToString());
  2453. try
  2454. {
  2455. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2456. {
  2457. }
  2458. else
  2459. {
  2460. msg = "修改失败";
  2461. }
  2462. }
  2463. catch (Exception ex)
  2464. {
  2465. msg = ex.Message;
  2466. }
  2467. return msg;
  2468. }
  2469. /// <summary>
  2470. /// 删除包装、容器
  2471. /// </summary>
  2472. /// <param name="keyValue">传入ID</param>
  2473. /// <returns></returns>
  2474. public string DeleteICSContainer(string keyValue)
  2475. {
  2476. ////站点信息
  2477. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2478. //string msg = "";
  2479. //keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2480. //string sql = string.Empty;
  2481. //sql = string.Format(@"DELETE FROM dbo.ICSContainer WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2482. //try
  2483. //{
  2484. // SqlHelper.ExecuteNonQuery(sql);
  2485. //}
  2486. //catch (Exception ex)
  2487. //{
  2488. // throw new Exception(ex.Message);
  2489. //}
  2490. //return msg;
  2491. string msg = "";
  2492. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "ICSContainerCon/Untie";
  2493. string result =DeciliterApp.HttpPost(APIURL, keyValue);
  2494. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  2495. string MessAge = Obj["Message"].ToString();
  2496. string Success = Obj["Success"].ToString();
  2497. if (Success.ToUpper() == "FALSE")
  2498. {
  2499. msg = MessAge;
  2500. }
  2501. return msg;
  2502. }
  2503. /// <summary>
  2504. /// 新增包装、容器关联条码
  2505. /// </summary>
  2506. /// <param name="queryJson"></param>
  2507. /// <returns></returns>
  2508. public string InsertICSContainerLot(string keyValue)
  2509. {
  2510. var queryParam = keyValue.ToJObject();
  2511. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2512. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2513. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2514. string msg = "";
  2515. string sql = string.Empty;
  2516. sql = @"INSERT INTO dbo.ICSContainerLot
  2517. ( ID ,ContainerID ,LotNo ,MTIME,MUSER ,MUSERName ,WorkPoint )
  2518. Values(NEWID(),'{0}','{1}',getdate(),'{2}','{3}','{4}')
  2519. ";
  2520. sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["LotNo"].ToString(), MUSER, MUSERNAME, WorkPoint);
  2521. try
  2522. {
  2523. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2524. {
  2525. }
  2526. else
  2527. {
  2528. msg = "新增失败";
  2529. }
  2530. }
  2531. catch (Exception ex)
  2532. {
  2533. throw new Exception(ex.Message);
  2534. }
  2535. return msg;
  2536. }
  2537. /// <summary>
  2538. /// 修改包装、容器
  2539. /// </summary>
  2540. /// <param name="queryJson"></param>
  2541. /// <returns></returns>
  2542. public string UpdateICSContainerLot(string keyValue)
  2543. {
  2544. var queryParam = keyValue.ToJObject();
  2545. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2546. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2547. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2548. string msg = "";
  2549. string sql = string.Empty;
  2550. sql = @"UPDATE dbo.ICSContainerLot set ContainerID='{0}',LotNo='{1}',MTIME=GETDATE(),MUSER='{2}',MUSERName='{3}',WorkPoint='{4}' WHERE ID='{5}'";
  2551. sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["LotNo"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  2552. try
  2553. {
  2554. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2555. {
  2556. }
  2557. else
  2558. {
  2559. msg = "修改失败";
  2560. }
  2561. }
  2562. catch (Exception ex)
  2563. {
  2564. throw new Exception(ex.Message);
  2565. }
  2566. return msg;
  2567. }
  2568. /// <summary>
  2569. /// 删除包装、容器
  2570. /// </summary>
  2571. /// <param name="keyValue">传入ID</param>
  2572. /// <returns></returns>
  2573. public string DeleteICSContainerLot(string keyValue)
  2574. {
  2575. ////站点信息
  2576. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2577. //string msg = "";
  2578. //keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2579. //string sql = string.Empty;
  2580. //sql = string.Format(@"DELETE FROM dbo.ICSContainerLot WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2581. //try
  2582. //{
  2583. // SqlHelper.ExecuteNonQuery(sql);
  2584. //}
  2585. //catch (Exception ex)
  2586. //{
  2587. // throw new Exception(ex.Message);
  2588. //}
  2589. //return msg;
  2590. string msg = "";
  2591. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "ICSContainerLot/Untie";
  2592. string result = DeciliterApp.HttpPost(APIURL, keyValue);
  2593. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  2594. string MessAge = Obj["Message"].ToString();
  2595. string Success = Obj["Success"].ToString();
  2596. if (Success.ToUpper() == "FALSE")
  2597. {
  2598. msg = MessAge;
  2599. }
  2600. return msg;
  2601. }
  2602. /// <summary>
  2603. /// 获取料品信息
  2604. /// </summary>
  2605. /// <returns></returns>
  2606. public DataTable GetInvCode()
  2607. {
  2608. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2609. string sql = @"
  2610. select '' as InvCode,'' as InvName
  2611. union all
  2612. SELECT InvCode,InvName FROM ICSInventory WITH (NOLOCK) WHERE 1=1 ";
  2613. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  2614. if (role != "admin")
  2615. {
  2616. sql += " and b.WorkPoint='" + WorkPoint + "'";
  2617. }
  2618. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2619. return dt;
  2620. }
  2621. /// <summary>
  2622. /// 获取不良代码信息
  2623. /// </summary>
  2624. /// <returns></returns>
  2625. public DataTable GetBCGroup()
  2626. {
  2627. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2628. string sql = @"select '' as ID,'' as BCGDesc
  2629. union all
  2630. SELECT ID,BCGDesc FROM ICSBadCodeGroup WITH (NOLOCK) WHERE 1=1 ";
  2631. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  2632. if (role != "admin")
  2633. {
  2634. sql += " and b.WorkPoint='" + WorkPoint + "'";
  2635. }
  2636. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2637. return dt;
  2638. }
  2639. /// <summary>
  2640. /// 获取不良原因信息
  2641. /// </summary>
  2642. /// <returns></returns>
  2643. public DataTable BRGroupID()
  2644. {
  2645. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2646. string sql = @"select '' as ID,'' as BRGDesc
  2647. union all
  2648. SELECT ID,BRGDesc FROM ICSBadReasonGroup WITH (NOLOCK) WHERE 1=1 ";
  2649. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  2650. if (role != "admin")
  2651. {
  2652. sql += " and b.WorkPoint='" + WorkPoint + "'";
  2653. }
  2654. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2655. return dt;
  2656. }
  2657. /// <summary>
  2658. /// 新增料品不良信息
  2659. /// </summary>
  2660. /// <param name="queryJson"></param>
  2661. /// <returns></returns>
  2662. public string InsertInventoryBadGroup(string keyValue)
  2663. {
  2664. var queryParam = keyValue.ToJObject();
  2665. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2666. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2667. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2668. string msg = "";
  2669. string sql = string.Empty;
  2670. sql = @"INSERT INTO dbo.ICSInventoryBadGroup
  2671. ( ID,InvCode,BCGroupID,BRGroupID,Enable,MUSER,MUSERName,MTIME,WorkPoint)
  2672. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}',getdate(),'{6}')";
  2673. sql = string.Format(sql, queryParam["InvCode"].ToString(), queryParam["BCGroupID"].ToString(), queryParam["BRGroupID"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint);
  2674. try
  2675. {
  2676. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2677. {
  2678. }
  2679. else
  2680. {
  2681. msg = "新增失败";
  2682. }
  2683. }
  2684. catch (Exception ex)
  2685. {
  2686. throw new Exception(ex.Message);
  2687. }
  2688. return msg;
  2689. }
  2690. /// <summary>
  2691. /// 修改料品不良信息
  2692. /// </summary>
  2693. /// <param name="queryJson"></param>
  2694. /// <returns></returns>
  2695. public string UpdateInventoryBadGroup(string keyValue)
  2696. {
  2697. var queryParam = keyValue.ToJObject();
  2698. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2699. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2700. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2701. string msg = "";
  2702. string sql = string.Empty;
  2703. sql = @"UPDATE dbo.ICSInventoryBadGroup set BCGroupID='{0}',BRGroupID='{1}',Enable='{2}',MUSER='{3}',MUSERName='{4}',MTIME=GetDate(),WorkPoint='{5}' WHERE ID='{6}'";
  2704. sql = string.Format(sql, queryParam["BCGroupID"].ToString(), queryParam["BRGroupID"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  2705. try
  2706. {
  2707. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2708. {
  2709. }
  2710. else
  2711. {
  2712. msg = "修改失败";
  2713. }
  2714. }
  2715. catch (Exception ex)
  2716. {
  2717. throw new Exception(ex.Message);
  2718. }
  2719. return msg;
  2720. }
  2721. /// <summary>
  2722. /// 删除料品不良信息
  2723. /// </summary>
  2724. /// <param name="keyValue">传入ID</param>
  2725. /// <returns></returns>
  2726. public string DeleteInventoryBadGroup(string keyValue)
  2727. {
  2728. //站点信息
  2729. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2730. string msg = "";
  2731. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2732. string sql = string.Empty;
  2733. sql = string.Format(@"DELETE FROM dbo.ICSInventoryBadGroup WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2734. try
  2735. {
  2736. SqlHelper.ExecuteNonQuery(sql);
  2737. }
  2738. catch (Exception ex)
  2739. {
  2740. throw new Exception(ex.Message);
  2741. }
  2742. return msg;
  2743. }
  2744. //库位导入
  2745. public string SetData_PR(String savePath)
  2746. {
  2747. //数据获取
  2748. try
  2749. {
  2750. int index = 1;
  2751. string msg = "";
  2752. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2753. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2754. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2755. SqlConnection conn = SqlHelper.GetDataCenterConn();
  2756. string sql = "";
  2757. int count = 0;
  2758. DataTable data = FileToExcel.ExcelToTable(savePath);
  2759. foreach (DataRow dr in data.Rows)
  2760. {
  2761. index++;
  2762. var StackCode = "";
  2763. var StackName = "";
  2764. //string GUID = Guid.NewGuid().ToString();
  2765. string KuFang = dr["库房编码"].ToString().Trim().ToUpper();
  2766. string Qu = dr["区"].ToString().Trim().ToUpper();
  2767. string Pai = dr["排"].ToString().Trim().ToUpper();
  2768. string Jia = dr["货架"].ToString().Trim().ToUpper();
  2769. string Ceng = dr["层"].ToString().Trim().ToUpper();
  2770. string Ge = dr["格"].ToString().Trim().ToUpper();
  2771. if (KuFang == "" || KuFang == null)
  2772. {
  2773. throw new Exception("第 " + index + " 行库房编码不能为空!");
  2774. }
  2775. if (Qu == "" && Pai == "" && Jia == "" && Ceng == "" && Ge == "")
  2776. {
  2777. throw new Exception("第 " + index + " 区、排、货架、层、格至少填写一项!");
  2778. }
  2779. string sqlWH = @"select ID from ICSWarehouse where WarehouseCode='{0}' and WorkPoint='{1}'";
  2780. sqlWH = string.Format(sqlWH, KuFang, WorkPoint);
  2781. DataTable dd = SqlHelper.CmdExecuteDataTable(sqlWH);
  2782. if (dd == null || dd.Rows.Count <= 0)
  2783. {
  2784. throw new Exception("库房编码: " + KuFang + " 不存在!");
  2785. }
  2786. string WHID = dd.Rows[0]["ID"].ToString();
  2787. StackCode = KuFang;
  2788. StackName = KuFang + "仓库";
  2789. if (Qu != "")
  2790. {
  2791. StackCode += "-" + Qu;
  2792. StackName += Qu + "区";
  2793. }
  2794. if (Pai != "")
  2795. {
  2796. StackCode += "-" + Pai;
  2797. StackName += Pai + "排";
  2798. }
  2799. if (Jia != "")
  2800. {
  2801. StackCode += "-" + Jia;
  2802. StackName += Jia + "货架";
  2803. }
  2804. if (Ceng != "")
  2805. {
  2806. StackCode += "-" + Ceng;
  2807. StackName += Ceng + "层";
  2808. }
  2809. if (Ge != "")
  2810. {
  2811. StackCode += "-" + Ge;
  2812. StackName += Ge + "格";
  2813. }
  2814. string sqls = @"select LocationCode from ICSLocation where LocationCode='{0}' and WorkPoint='{1}'";
  2815. sqls = string.Format(sqls, StackCode, WorkPoint);
  2816. DataTable dnum = SqlHelper.CmdExecuteDataTable(sqls);
  2817. if (dnum != null && dnum.Rows.Count > 0)
  2818. {
  2819. throw new Exception("库位: " + StackCode + " 已存在!");
  2820. }
  2821. else
  2822. {
  2823. sql += @"Insert INto ICSLocation
  2824. ( ID, LocationCode, LocationName, WHID, MUSER, MUSERName, MTIME, WorkPoint, EATTRIBUTE1, Region, Row, GoodsShelf, Tier, Grid)
  2825. Values (newid(),'{0}','{1}','{2}','{3}','{4}',getdate(),'{5}','','{6}','{7}','{8}','{9}','{10}')";
  2826. }
  2827. sql = string.Format(sql, StackCode, StackName, WHID, MUSER, MUSERNAME, WorkPoint, Qu, Pai, Jia, Ceng, Ge);
  2828. }
  2829. count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2830. if (count > 0)
  2831. {
  2832. msg = "导入成功";
  2833. }
  2834. else
  2835. {
  2836. return "无有效的导入数据。";
  2837. }
  2838. return msg;
  2839. }
  2840. catch (Exception ex)
  2841. {
  2842. return ex.Message;
  2843. }
  2844. }
  2845. //周转箱导入
  2846. public string SetDataBoxes(String savePath)
  2847. {
  2848. //数据获取
  2849. try
  2850. {
  2851. int index = 1;
  2852. string msg = "";
  2853. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2854. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2855. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2856. SqlConnection conn = SqlHelper.GetDataCenterConn();
  2857. string sql = "";
  2858. int count = 0;
  2859. DataTable data = FileToExcel.ExcelToTable(savePath);
  2860. foreach (DataRow dr in data.Rows)
  2861. {
  2862. index++;
  2863. string BoxNumber = dr["周转箱编码"].ToString().Trim().ToUpper();
  2864. string BoxName = dr["周转箱名称"].ToString().Trim().ToUpper();
  2865. string Type = dr["类型"].ToString().Trim().ToUpper();
  2866. string Version = dr["型号"].ToString().Trim().ToUpper();
  2867. string Specification = dr["规格"].ToString().Trim().ToUpper();
  2868. string Describe = dr["描述"].ToString().Trim().ToUpper();
  2869. string FirstCleanCycle = dr["第一次清洗周期"].ToString().Trim().ToUpper();
  2870. string SecondCleanCycle = dr["第二次清洗周期"].ToString().Trim().ToUpper();
  2871. string ThirdCleanCycle = dr["第三次清洗周期"].ToString().Trim().ToUpper();
  2872. if (BoxNumber == "" || BoxNumber == null)
  2873. {
  2874. throw new Exception("第 " + index + " 周转箱编码不能为空!");
  2875. }
  2876. if (BoxName == "" || BoxNumber == null)
  2877. {
  2878. throw new Exception("第 " + index + " 周转箱名称不能为空");
  2879. }
  2880. if (Type == "" || Type == null)
  2881. {
  2882. throw new Exception("第 " + index + " 周转类型不能伟空");
  2883. }
  2884. if (FirstCleanCycle == "" || FirstCleanCycle == null|| SecondCleanCycle == "" || SecondCleanCycle == null || ThirdCleanCycle == "" || ThirdCleanCycle == null)
  2885. {
  2886. throw new Exception("第 " + index + "清洗周期不能为空");
  2887. }
  2888. string sqlWH = $@"select id from ICSWorkingCapitalBox where BoxNumber='{BoxNumber}'";
  2889. DataTable dd = SqlHelper.CmdExecuteDataTable(sqlWH);
  2890. if (dd != null && dd.Rows.Count > 0)
  2891. {
  2892. throw new Exception("周转箱编码: " + BoxNumber + " 已存在!");
  2893. }
  2894. sql += $@"INSERT INTO [dbo].[ICSWorkingCapitalBox] ([ID], [BoxNumber], [BoxName], [Type], [Version], [Specification], [Describe], [FirstCleanCycle], [SecondCleanCycle], [ThirdCleanCycle], [MTIME], [MUser], [MUSERName])
  2895. VALUES (NEWID(), '{BoxNumber}', '{BoxName}', '{Type}', '{Version}', '{Specification}', '{Describe}', {FirstCleanCycle}, {SecondCleanCycle}, {ThirdCleanCycle}, GETDATE(), '{MUSER}', '{MUSERNAME}'); ";
  2896. }
  2897. count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2898. if (count > 0)
  2899. {
  2900. msg = "导入成功";
  2901. }
  2902. else
  2903. {
  2904. return "无有效的导入数据。";
  2905. }
  2906. return msg;
  2907. }
  2908. catch (Exception ex)
  2909. {
  2910. return ex.Message;
  2911. }
  2912. }
  2913. //周转箱台账导入
  2914. public string SetDataBoxAccount(String savePath)
  2915. {
  2916. //数据获取
  2917. try
  2918. {
  2919. int index = 1;
  2920. string msg = "";
  2921. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2922. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2923. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2924. SqlConnection conn = SqlHelper.GetDataCenterConn();
  2925. string sql = "";
  2926. int count = 0;
  2927. DataTable data = FileToExcel.ExcelToTable(savePath);
  2928. foreach (DataRow dr in data.Rows)
  2929. {
  2930. index++;
  2931. string BoxNumber = dr["周转箱编码"].ToString().Trim().ToUpper();
  2932. string BoxName = dr["名称"].ToString().Trim().ToUpper();
  2933. string BoxCode = dr["周转箱代码"].ToString().Trim().ToUpper();
  2934. string Describe = dr["描述"].ToString().Trim().ToUpper();
  2935. if (BoxNumber == "" || BoxNumber == null)
  2936. {
  2937. throw new Exception("第 " + index + " 周转箱编码不能为空!");
  2938. }
  2939. if (BoxName == "" || BoxNumber == null)
  2940. {
  2941. throw new Exception("第 " + index + " 周转箱名称不能为空");
  2942. }
  2943. if (BoxCode == "" || BoxCode == null)
  2944. {
  2945. throw new Exception("第 " + index + " 周转代码不能伟空");
  2946. }
  2947. string sqlWH = $@"select id from ICSWorkingCapitalBox where BoxNumber='{BoxNumber}'";
  2948. DataTable dd = SqlHelper.CmdExecuteDataTable(sqlWH);
  2949. if (dd == null || dd.Rows.Count <= 0)
  2950. {
  2951. throw new Exception("周转箱编码: " + BoxNumber + " 不存在!");
  2952. }
  2953. string sqlCode = $@"select id from ICSWorkingCapitalBoxAccount where BoxCode='{BoxCode}'";
  2954. DataTable code = SqlHelper.CmdExecuteDataTable(sqlCode);
  2955. if (code != null && code.Rows.Count > 0)
  2956. {
  2957. throw new Exception("周转箱代码: " + BoxCode + " 已存在!");
  2958. }
  2959. sql += $@"INSERT INTO [dbo].[ICSWorkingCapitalBoxAccount] ([ID], [BoxCode], [BoxNumber], [BoxName], [States], [Describe], [DailyUses], [TotalUses], [TotalClearn], [MUser], [MUSERName], [MTIME]) VALUES (NEWID(), '{BoxCode}', '{BoxNumber}', '{BoxName}', '正常', '{Describe}',0, 0, 0, '{MUSER}', '{MUSERNAME}', GETDATE());";
  2960. }
  2961. count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2962. if (count > 0)
  2963. {
  2964. msg = "导入成功";
  2965. }
  2966. else
  2967. {
  2968. return "无有效的导入数据。";
  2969. }
  2970. return msg;
  2971. }
  2972. catch (Exception ex)
  2973. {
  2974. return ex.Message;
  2975. }
  2976. }
  2977. //模具档案导入
  2978. public string SetDataMould(String savePath)
  2979. {
  2980. //数据获取
  2981. try
  2982. {
  2983. int index = 1;
  2984. string msg = "";
  2985. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2986. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2987. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2988. SqlConnection conn = SqlHelper.GetDataCenterConn();
  2989. string sql = "";
  2990. int count = 0;
  2991. DataTable data = FileToExcel.ExcelToTable(savePath);
  2992. foreach (DataRow dr in data.Rows)
  2993. {
  2994. index++;
  2995. string MouldNumber = dr["模具编码"].ToString().Trim().ToUpper();
  2996. string MouldName = dr["模具名称"].ToString().Trim().ToUpper();
  2997. string Type = dr["类型"].ToString().Trim().ToUpper();
  2998. string Specification = dr["规格"].ToString().Trim().ToUpper();
  2999. string Unit = dr["单位"].ToString().Trim().ToUpper();
  3000. string Phone = dr["联系电话"].ToString().Trim().ToUpper();
  3001. if (MouldNumber == "" || MouldNumber == null)
  3002. {
  3003. throw new Exception("第 " + index + " 模具编码不能为空!");
  3004. }
  3005. if (MouldName == "" || MouldName == null)
  3006. {
  3007. throw new Exception("第 " + index + " 模具名称不能为空");
  3008. }
  3009. if (Type == "" || Type == null)
  3010. {
  3011. throw new Exception("第 " + index + " 类型不能伟空");
  3012. }
  3013. if (Specification == "" || Specification == null)
  3014. {
  3015. throw new Exception("第 " + index + "规格不能为空!");
  3016. }
  3017. if (Unit == "" || Unit == null)
  3018. {
  3019. throw new Exception("第 " + index + " 单位不能为空");
  3020. }
  3021. string sqlWH = $@"select id from ICSMould where MouldNumber='{MouldNumber}'";
  3022. DataTable dd = SqlHelper.CmdExecuteDataTable(sqlWH);
  3023. if (dd != null && dd.Rows.Count > 0)
  3024. {
  3025. throw new Exception("模具编码: " + MouldNumber + " 已存在!");
  3026. }
  3027. sql += $@"INSERT INTO [dbo].[ICSMould] ([ID], [MouldNumber], [MouldName], [Type], [Specification], [Unit], [MTIME], [MUser], [MUSERName], [EATTRIBUTE1]) VALUES (NEWID(), '{MouldNumber}', '{MouldName}', '{Type}', '{Specification}', '{Unit}',GETDATE(), '{MUSER}', '{MUSERNAME}','{Phone}');";
  3028. }
  3029. count = SqlHelper.CmdExecuteNonQueryLi(sql);
  3030. if (count > 0)
  3031. {
  3032. msg = "导入成功";
  3033. }
  3034. else
  3035. {
  3036. return "无有效的导入数据。";
  3037. }
  3038. return msg;
  3039. }
  3040. catch (Exception ex)
  3041. {
  3042. return ex.Message;
  3043. }
  3044. }
  3045. //模具台账导入
  3046. public string SetDataMouldAccount(String savePath)
  3047. {
  3048. //数据获取
  3049. try
  3050. {
  3051. int index = 1;
  3052. string msg = "";
  3053. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3054. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3055. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3056. SqlConnection conn = SqlHelper.GetDataCenterConn();
  3057. string sql = "";
  3058. int count = 0;
  3059. DataTable data = FileToExcel.ExcelToTable(savePath);
  3060. foreach (DataRow dr in data.Rows)
  3061. {
  3062. index++;
  3063. string MouldNumber = dr["模具编码"].ToString().Trim().ToUpper();
  3064. string MouldName = dr["模具名称"].ToString().Trim().ToUpper();
  3065. string Status = dr["状态"].ToString().Trim().ToUpper();
  3066. string MouldCode = dr["模具代码"].ToString().Trim().ToUpper();
  3067. string Limit = dr["下限值"].ToString().Trim().ToUpper();
  3068. string Upper = dr["上限值"].ToString().Trim().ToUpper();
  3069. if (MouldNumber == "" || MouldNumber == null)
  3070. {
  3071. throw new Exception("第 " + index + " 模具编码不能为空!");
  3072. }
  3073. if (MouldName == "" || MouldName == null)
  3074. {
  3075. throw new Exception("第 " + index + " 模具名称不能为空");
  3076. }
  3077. if (Status == "" || Status == null)
  3078. {
  3079. throw new Exception("第 " + index + " 状态不能为空");
  3080. }
  3081. if (MouldCode == "" || MouldCode == null)
  3082. {
  3083. throw new Exception("第 " + index + "模具代码不能为空!");
  3084. }
  3085. if (Limit == "" || Limit == null)
  3086. {
  3087. throw new Exception("第 " + index + " 上限不能为空");
  3088. }
  3089. if (Upper == "" || Upper == null)
  3090. {
  3091. throw new Exception("第 " + index + " 下限不能为空");
  3092. }
  3093. string sqlWH = $@"select id from ICSMould where MouldNumber='{MouldNumber}'";
  3094. DataTable dd = SqlHelper.CmdExecuteDataTable(sqlWH);
  3095. if (dd == null || dd.Rows.Count <= 0)
  3096. {
  3097. throw new Exception("模具编码: " + MouldNumber + " 不存在!");
  3098. }
  3099. string salCode = $@"select id from ICSMouldAccount where MouldCode='{MouldCode}'";
  3100. DataTable ddCode = SqlHelper.CmdExecuteDataTable(salCode);
  3101. if (ddCode != null && ddCode.Rows.Count > 0)
  3102. {
  3103. throw new Exception("模具代码: " + MouldNumber + " 已存在!");
  3104. }
  3105. sql += $@"INSERT INTO [dbo].[ICSMouldAccount] ([ID], [MouldCode], [MouldNumber], [MouldName], [MajorStates], [SubStates], [UpperLimit], [LowerLimit], [DailyUses], [TotalUses], [Users], [UserDate], [Picture], [MUser], [MUSERName], [MTIME]) VALUES (NEWID(), '{MouldCode}', '{MouldNumber}', '{MouldName}', '{Status}', null, {Upper}, {Limit}, 0, 0, null, null, null, '{MUSER}', '{MUSERNAME}', GETDATE());";
  3106. }
  3107. count = SqlHelper.CmdExecuteNonQueryLi(sql);
  3108. if (count > 0)
  3109. {
  3110. msg = "导入成功";
  3111. }
  3112. else
  3113. {
  3114. return "无有效的导入数据。";
  3115. }
  3116. return msg;
  3117. }
  3118. catch (Exception ex)
  3119. {
  3120. return ex.Message;
  3121. }
  3122. }
  3123. /// <summary>
  3124. ///启用的料品库位绑定关系
  3125. /// </summary>
  3126. public string EnableInventoryLocation(string keyValue)
  3127. {
  3128. //站点信息
  3129. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3130. string msg = "";
  3131. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  3132. string sql = string.Empty;
  3133. sql = string.Format(@"update ICSInventoryLocation set Enable='1' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
  3134. try
  3135. {
  3136. SqlHelper.ExecuteNonQuery(sql);
  3137. }
  3138. catch (Exception ex)
  3139. {
  3140. throw new Exception(ex.Message);
  3141. }
  3142. return msg;
  3143. }
  3144. /// <summary>
  3145. ///禁用的料品库位绑定关系
  3146. /// </summary>
  3147. public string ForbiddenInventoryLocation(string keyValue)
  3148. {
  3149. //站点信息
  3150. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3151. string msg = "";
  3152. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  3153. string sql = string.Empty;
  3154. sql = string.Format(@"update ICSInventoryLocation set Enable='0' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
  3155. try
  3156. {
  3157. SqlHelper.ExecuteNonQuery(sql);
  3158. }
  3159. catch (Exception ex)
  3160. {
  3161. throw new Exception(ex.Message);
  3162. }
  3163. return msg;
  3164. }
  3165. /// <summary>
  3166. ///启用的料品仓库绑定关系
  3167. /// </summary>
  3168. public string EnableBatchEnable(string keyValue)
  3169. {
  3170. //站点信息
  3171. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3172. string msg = "";
  3173. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  3174. string sql = string.Empty;
  3175. sql = string.Format(@"update ICSInventoryBatchEnable set BatchEnable='1' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
  3176. try
  3177. {
  3178. SqlHelper.ExecuteNonQuery(sql);
  3179. }
  3180. catch (Exception ex)
  3181. {
  3182. throw new Exception(ex.Message);
  3183. }
  3184. return msg;
  3185. }
  3186. /// <summary>
  3187. ///禁用的料品仓库绑定关系
  3188. /// </summary>
  3189. public string ForbiddenBatchEnable(string keyValue)
  3190. {
  3191. //站点信息
  3192. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3193. string msg = "";
  3194. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  3195. string sql = string.Empty;
  3196. sql = string.Format(@"update ICSInventoryBatchEnable set BatchEnable='0' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
  3197. try
  3198. {
  3199. SqlHelper.ExecuteNonQuery(sql);
  3200. }
  3201. catch (Exception ex)
  3202. {
  3203. throw new Exception(ex.Message);
  3204. }
  3205. return msg;
  3206. }
  3207. public string CreateLableDataSource(string Sys_LableDataSource)
  3208. {
  3209. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3210. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3211. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3212. string msg = "";
  3213. string sql = string.Empty;
  3214. string SqlTxt = "";
  3215. JArray res = (JArray)JsonConvert.DeserializeObject(Sys_LableDataSource);
  3216. foreach (var item in res)
  3217. {
  3218. JObject jo = (JObject)item;
  3219. if (jo["DbParas"].ToString().Trim() != "")
  3220. {
  3221. string[] dbvs = jo["DbParas"].ToString().Trim().Split(',');
  3222. List<string> vs = new List<string>();
  3223. foreach (string s in dbvs)
  3224. {
  3225. if (!string.IsNullOrEmpty(s))
  3226. {
  3227. vs.Add(s);
  3228. }
  3229. }
  3230. SqlTxt = string.Format(jo["FormatSqlTxt"].ToString(), vs.ToArray());
  3231. }
  3232. else
  3233. {
  3234. SqlTxt = jo["FormatSqlTxt"].ToString();
  3235. }
  3236. sql += @"INSERT INTO dbo.Sys_LableDataSource
  3237. (ID,WorkPointCode,OtherDataBaseID,WorkPointDataFlag,SysDataFlag,SqlTxt,SourceName,FormatSqlTxt,Paras,DbParas,LinkCols,CreateUserID,CreateDate,ModifyUserID,ModifyDate,Link2Cols )
  3238. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',getdate(),'{11}',getdate(),'{12}')";
  3239. 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());
  3240. }
  3241. try
  3242. {
  3243. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  3244. {
  3245. }
  3246. else
  3247. {
  3248. msg = "新增失败";
  3249. }
  3250. }
  3251. catch (Exception ex)
  3252. {
  3253. //throw new Exception(ex.Message);
  3254. msg = ex.Message;
  3255. }
  3256. return msg;
  3257. }
  3258. public DataTable GetTXT(string ID)
  3259. {
  3260. DataTable dt = new DataTable();
  3261. //var queryParam = queryJson.ToJObject();
  3262. List<DbParameter> parameter = new List<DbParameter>();
  3263. string sql = @"SELECT
  3264. ID,
  3265. WorkPointCode,
  3266. OtherDataBaseID,
  3267. WorkPointDataFlag,
  3268. SysDataFlag,
  3269. SqlTxt,
  3270. SourceName,
  3271. FormatSqlTxt,
  3272. Paras,
  3273. DbParas,
  3274. LinkCols,
  3275. CreateUserID,
  3276. CreateDate,
  3277. ModifyUserID,
  3278. ModifyDate,
  3279. Link2Cols
  3280. FROM
  3281. dbo.Sys_LableDataSource where ID='" + ID + "'";
  3282. return Repository().FindTableBySql(sql.ToString());
  3283. }
  3284. public string updateLableDataSource(string Sys_LableDataSource)
  3285. {
  3286. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3287. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3288. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3289. string msg = "";
  3290. string sql = string.Empty;
  3291. string SqlTxt = "";
  3292. JArray res = (JArray)JsonConvert.DeserializeObject(Sys_LableDataSource);
  3293. foreach (var item in res)
  3294. {
  3295. JObject jo = (JObject)item;
  3296. if (jo["DbParas"].ToString().Trim() != "")
  3297. {
  3298. string[] dbvs = jo["DbParas"].ToString().Trim().Split(',');
  3299. List<string> vs = new List<string>();
  3300. foreach (string s in dbvs)
  3301. {
  3302. if (!string.IsNullOrEmpty(s))
  3303. {
  3304. vs.Add(s);
  3305. }
  3306. }
  3307. SqlTxt = string.Format(jo["FormatSqlTxt"].ToString(), vs.ToArray());
  3308. }
  3309. else
  3310. {
  3311. SqlTxt = jo["FormatSqlTxt"].ToString();
  3312. }
  3313. 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}'";
  3314. 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());
  3315. }
  3316. try
  3317. {
  3318. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  3319. {
  3320. }
  3321. else
  3322. {
  3323. msg = "修改失败";
  3324. }
  3325. }
  3326. catch (Exception ex)
  3327. {
  3328. throw new Exception(ex.Message);
  3329. }
  3330. return msg;
  3331. }
  3332. public string DeleteLableDataSource(string keyValue)
  3333. {
  3334. //站点信息
  3335. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3336. string msg = "";
  3337. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  3338. string sql = string.Empty;
  3339. sql = string.Format(@"DELETE FROM dbo.Sys_LableDataSource WHERE ID IN ({0}) ", keyValue.TrimEnd(','));
  3340. try
  3341. {
  3342. SqlHelper.ExecuteNonQuery(sql);
  3343. }
  3344. catch (Exception ex)
  3345. {
  3346. throw new Exception(ex.Message);
  3347. }
  3348. return msg;
  3349. }
  3350. public DataTable GetLableType()
  3351. {
  3352. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  3353. string sql = @"
  3354. select '' as F_ItemCode,'' as F_ItemName
  3355. union all
  3356. 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'";
  3357. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  3358. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  3359. return dt;
  3360. }
  3361. public DataTable GetSys_LablesID()
  3362. {
  3363. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  3364. string sql = @"
  3365. select '' as ID,'' as LableName
  3366. union all
  3367. select distinct ID,LableName from Sys_Lables";
  3368. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  3369. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  3370. return dt;
  3371. }
  3372. public string CreateLables(string txtLableName, string sel_LableType, string sel_LableSourceID)
  3373. {
  3374. string UserId = NFine.Code.OperatorProvider.Provider.GetCurrent().UserId;
  3375. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3376. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3377. string msg = "";
  3378. string sql = string.Empty;
  3379. string LableCode = "";
  3380. string SqlTxt = string.Format(@"SELECT MAX(A.LableCode) AS LableCode FROM Sys_Lables A "); ;
  3381. DataSet ds = SqlHelper.GetDataSetBySql(SqlTxt);
  3382. DataTable dts = ds.Tables[0];
  3383. if (dts != null && dts.Rows.Count > 0)
  3384. {
  3385. string lot = dts.Rows[0]["LableCode"].ToString();
  3386. LableCode = (Convert.ToInt64(lot) + 1).ToString().PadLeft(5, '0');
  3387. }
  3388. else
  3389. {
  3390. LableCode = "00001";
  3391. }
  3392. sql += @" INSERT INTO dbo.Sys_Lables
  3393. (ID,WorkPointCode,LableType,LableCode,LableName,LableXml,LableSourceID,CreateUserID,CreateDate,ModifyUserID,ModifyDate,FileAddress )
  3394. Values(NEWID(),'{0}','{1}','{2}','{3}','','{4}','{5}',getdate(),'{6}',getdate(),'')";
  3395. sql = string.Format(sql, WorkPoint, sel_LableType, LableCode, txtLableName, sel_LableSourceID, UserId, UserId);
  3396. try
  3397. {
  3398. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  3399. {
  3400. }
  3401. else
  3402. {
  3403. msg = "新增失败";
  3404. }
  3405. }
  3406. catch (Exception ex)
  3407. {
  3408. throw new Exception(ex.Message);
  3409. }
  3410. return msg;
  3411. }
  3412. public DataTable GetLabelTXT(string ID)
  3413. {
  3414. DataTable dt = new DataTable();
  3415. //var queryParam = queryJson.ToJObject();
  3416. List<DbParameter> parameter = new List<DbParameter>();
  3417. string sql = @"select ID,WorkPointCode,LableType,LableCode,LableName,LableXml,LableSourceID,CreateUserID,CreateDate,ModifyUserID,ModifyDate,FileAddress from Sys_Lables where ID='" + ID + "'";
  3418. return Repository().FindTableBySql(sql.ToString());
  3419. }
  3420. public string updateLables(string ID, string txtLableName, string sel_LableType, string sel_LableSourceID)
  3421. {
  3422. string UserId = NFine.Code.OperatorProvider.Provider.GetCurrent().UserId;
  3423. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3424. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3425. string msg = "";
  3426. string sql = string.Empty;
  3427. sql += @"update Sys_Lables set LableType='{0}' ,LableName='{1}' ,LableSourceID='{2}',ModifyUserID='{3}',ModifyDate=getdate() where ID='{4}'";
  3428. sql = string.Format(sql, sel_LableType, txtLableName, sel_LableSourceID, UserId, ID);
  3429. try
  3430. {
  3431. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  3432. {
  3433. }
  3434. else
  3435. {
  3436. msg = "修改失败";
  3437. }
  3438. }
  3439. catch (Exception ex)
  3440. {
  3441. throw new Exception(ex.Message);
  3442. }
  3443. return msg;
  3444. }
  3445. public string DeleteICSLabelTemplate(string keyValue)
  3446. {
  3447. //站点信息
  3448. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3449. string msg = "";
  3450. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  3451. string sql = string.Empty;
  3452. sql = string.Format(@"DELETE FROM dbo.Sys_Lables WHERE ID IN ({0}) ", keyValue.TrimEnd(','));
  3453. try
  3454. {
  3455. SqlHelper.ExecuteNonQuery(sql);
  3456. }
  3457. catch (Exception ex)
  3458. {
  3459. throw new Exception(ex.Message);
  3460. }
  3461. return msg;
  3462. }
  3463. //获取父容器
  3464. public DataTable GetContainerID()
  3465. {
  3466. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  3467. string sql = @"
  3468. select '' as ID,'' as ContainerName
  3469. union all
  3470. SELECT DISTINCT a.ID,a.ContainerName FROM dbo.ICSContainer a ";
  3471. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  3472. if (role != "admin")
  3473. {
  3474. sql += " and b.WorkPoint in(" + WorkPoint + ")";
  3475. }
  3476. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  3477. return dt;
  3478. }
  3479. //获取父容器
  3480. public DataTable GetContainerType()
  3481. {
  3482. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  3483. string sql = @"
  3484. select '' as F_ItemName,'' as F_ItemCode
  3485. union all
  3486. SELECT a.F_ItemName,a.F_ItemCode FROM Sys_SRM_ItemsDetail a
  3487. LEFT JOIN Sys_SRM_Items b ON a.F_ItemId = b.F_Id
  3488. WHERE b.F_EnCode = 'ContainerType' and a.F_EnabledMark='1' ";
  3489. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  3490. if (role != "admin")
  3491. {
  3492. sql += " and b.WorkPoint in(" + WorkPoint + ")";
  3493. }
  3494. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  3495. return dt;
  3496. }
  3497. public int UpLoadLabelFile(string ID, string fileName)
  3498. {
  3499. DataTable dt = new DataTable();
  3500. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  3501. string sql = "";
  3502. sql = string.Format(@"update Sys_Lables set FileAddress='{0}'
  3503. where ID='{1}'",
  3504. fileName, ID);
  3505. StringBuilder Str = new StringBuilder(sql);
  3506. return Repository().ExecuteBySql(Str);
  3507. }
  3508. public int UpLoadFiles(string LotNo, string fileName)
  3509. {
  3510. DataTable dt = new DataTable();
  3511. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  3512. string sql = "";
  3513. sql = string.Format(@"update ICSInspection set FileName='{0}'
  3514. where LotNo='{1}' and Enable='1'",
  3515. fileName, LotNo);
  3516. StringBuilder Str = new StringBuilder(sql);
  3517. return Repository().ExecuteBySql(Str);
  3518. }
  3519. //包装容器
  3520. public DataTable GetSendContainer(ref Pagination jqgridparam, string queryJson)
  3521. {
  3522. DataTable dt = new DataTable();
  3523. var queryParam = queryJson.ToJObject();
  3524. List<DbParameter> parameter = new List<DbParameter>();
  3525. string sql = @"select top 0 ID,ContainerID,ContainerCode,ContainerName,Memo,MUSER,MUSERName,MTIME,WorkPoint from ICSContainer";
  3526. sql += " WHERE 1=1";
  3527. sql = string.Format(sql);
  3528. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  3529. }
  3530. public DataTable GetContainerInfo(string Code)
  3531. {
  3532. DataTable dt = new DataTable();
  3533. //var queryParam = queryJson.ToJObject();
  3534. List<DbParameter> parameter = new List<DbParameter>();
  3535. string sql = @" select ID,ContainerID,ContainerCode,ContainerName,Memo,MUSER,MUSERName,MTIME,WorkPoint from ICSContainer where ContainerCode='{0}'";
  3536. sql = string.Format(sql, Code);
  3537. return Repository().FindTableBySql(sql.ToString());
  3538. }
  3539. public DataTable GetBindContainerID(string SireCode)
  3540. {
  3541. DataTable dt = new DataTable();
  3542. //var queryParam = queryJson.ToJObject();
  3543. List<DbParameter> parameter = new List<DbParameter>();
  3544. string sql = @" select ID from ICSContainer where ContainerCode='{0}'";
  3545. sql = string.Format(sql, SireCode);
  3546. return Repository().FindTableBySql(sql.ToString());
  3547. }
  3548. public string BindingContainerID(string keyValue)
  3549. {
  3550. // string msg = "";
  3551. // try
  3552. // {
  3553. // string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3554. // string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3555. // string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3556. // string sql = string.Empty;
  3557. // JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
  3558. // foreach (var item in res)
  3559. // {
  3560. // JObject jo = (JObject)item;
  3561. // sql += @"
  3562. // IF NOT EXISTS(SELECT ContainerCode FROM ICSContainer WHERE ContainerCode='{1}' )
  3563. // BEGIN
  3564. // RAISERROR('容器:{1} 不存在!',16,1);
  3565. // RETURN
  3566. // END
  3567. // IF EXISTS(select ContainerID from ICSContainer where ContainerCode='{1}' and isnull(ContainerID,'')<>'')
  3568. // BEGIN
  3569. // RAISERROR('容器:{1},已绑定父容器!',16,1);
  3570. // RETURN
  3571. // END
  3572. // update ICSContainer set ContainerID='{0}' WHERE ContainerCode = '{1}' and WorkPoint ='{2}'";
  3573. // sql = string.Format(sql, SireID, jo["ContainerCode"].ToString(), WorkPoint);
  3574. // }
  3575. // if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  3576. // {
  3577. // }
  3578. // else
  3579. // {
  3580. // msg = "绑定失败";
  3581. // }
  3582. // }
  3583. // catch (Exception ex)
  3584. // {
  3585. // msg = ex.Message;
  3586. // }
  3587. // return msg;
  3588. string msg = "";
  3589. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "ICSContainerCon/Create";
  3590. string result = DeciliterApp.HttpPost(APIURL, keyValue);
  3591. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  3592. string MessAge = Obj["Message"].ToString();
  3593. string Success = Obj["Success"].ToString();
  3594. if (Success.ToUpper() == "FALSE")
  3595. {
  3596. msg = MessAge;
  3597. }
  3598. return msg;
  3599. }
  3600. //包装容器关联条码
  3601. public DataTable GetSendContainerLot(ref Pagination jqgridparam, string queryJson)
  3602. {
  3603. DataTable dt = new DataTable();
  3604. var queryParam = queryJson.ToJObject();
  3605. List<DbParameter> parameter = new List<DbParameter>();
  3606. string sql = @"
  3607. select top 0 a.ID, a.LotNo,a.InvCode,b.InvName,b.InvStd,b.InvUnit, a.ProductDate,a.Quantity from ICSInventoryLot a
  3608. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint";
  3609. sql = string.Format(sql);
  3610. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  3611. }
  3612. /// <summary>
  3613. /// 回车后获取信息
  3614. /// </summary>
  3615. /// <param name="LotNo"></param>
  3616. /// <returns>20230719 lacy.xu modifly 增加自由项</returns>
  3617. public DataTable GetContainerLotInfo(string LotNo)
  3618. {
  3619. DataTable dt = new DataTable();
  3620. //var queryParam = queryJson.ToJObject();
  3621. List<DbParameter> parameter = new List<DbParameter>();
  3622. string sql = @" select a.ID, a.LotNo,a.InvCode,b.InvName,b.InvStd,b.InvUnit, a.ProductDate,a.Quantity
  3623. ,c.ProjectCode,c.BatchCode,Version,Brand,c.cFree1,c.cFree2,c.cFree3,c.cFree4,c.cFree5,c.cFree6,c.cFree7
  3624. ,c.cFree8,c.cFree9,c.cFree10
  3625. from ICSInventoryLot a
  3626. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  3627. LEFT JOIN dbo.ICSExtension c ON a.ExtensionID=c.ID AND a.WorkPoint=c.WorkPoint
  3628. where a.LotNo='{0}'";
  3629. sql = string.Format(sql, LotNo);
  3630. return Repository().FindTableBySql(sql.ToString());
  3631. }
  3632. public string BindingContainerLotID(string keyValue)
  3633. {
  3634. // string msg = "";
  3635. // try
  3636. // {
  3637. // string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3638. // string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3639. // string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3640. // string sql = string.Empty;
  3641. // JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
  3642. // foreach (var item in res)
  3643. // {
  3644. // JObject jo = (JObject)item;
  3645. // sql += @"
  3646. // IF NOT EXISTS(SELECT ContainerCode FROM ICSContainer WHERE ContainerCode='{5}')
  3647. // BEGIN
  3648. // RAISERROR('容器:{5} 不存在!',16,1);
  3649. // RETURN
  3650. // END
  3651. // IF NOT EXISTS(select LotNo from ICSInventoryLot where LotNo='{1}')
  3652. // BEGIN
  3653. // RAISERROR('条码:{1},不存在!',16,1);
  3654. // RETURN
  3655. // END
  3656. // IF EXISTS(select LotNo from ICSContainerLot where LotNo ='{1}')
  3657. // BEGIN
  3658. // RAISERROR('条码:{1},已绑定容器!',16,1);
  3659. // RETURN
  3660. // END
  3661. // INSERT INTO ICSContainerLot
  3662. // (ID,ContainerID,LotNo,MUSER,MUSERName,WorkPoint,MTIME )
  3663. // Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',getdate())";
  3664. // sql = string.Format(sql, SireID, jo["LotNo"].ToString(), MUSER, MUSERNAME, WorkPoint, SireCode);
  3665. // }
  3666. // if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  3667. // {
  3668. // }
  3669. // else
  3670. // {
  3671. // msg = "绑定失败";
  3672. // }
  3673. // }
  3674. // catch (Exception ex)
  3675. // {
  3676. // msg = ex.Message;
  3677. // }
  3678. // return msg;
  3679. string msg = "";
  3680. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "ICSContainerLot/Create";
  3681. string result = DeciliterApp.HttpPost(APIURL, keyValue);
  3682. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  3683. string MessAge = Obj["Message"].ToString();
  3684. string Success = Obj["Success"].ToString();
  3685. if (Success.ToUpper() == "FALSE")
  3686. {
  3687. msg = MessAge;
  3688. }
  3689. return msg;
  3690. }
  3691. /// <summary>
  3692. /// 删除站点
  3693. /// </summary>
  3694. /// <param name="keyValue">传入ID</param>
  3695. /// <returns></returns>
  3696. public string DeleteWorkPoint(string keyValue)
  3697. {
  3698. //站点信息
  3699. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3700. string msg = "";
  3701. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  3702. string sql = string.Empty;
  3703. sql = string.Format(@"DELETE FROM dbo.sys_WorkPoint WHERE ID IN ({0}) ", keyValue.TrimEnd(','), WorkPoint);
  3704. try
  3705. {
  3706. SqlHelper.ExecuteNonQuery(sql);
  3707. }
  3708. catch (Exception ex)
  3709. {
  3710. throw new Exception(ex.Message);
  3711. }
  3712. return msg;
  3713. }
  3714. /// <summary>
  3715. /// 新增站点
  3716. /// </summary>
  3717. /// <param name="queryJson"></param>
  3718. /// <returns></returns>
  3719. public string InsertWorkPoint(string keyValue)
  3720. {
  3721. var queryParam = keyValue.ToJObject();
  3722. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3723. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3724. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3725. string msg = "";
  3726. string sql = string.Empty;
  3727. string pwd = SqlHelper.ToMd5(queryParam["DataBasePwd"].ToString());
  3728. sql = @"INSERT INTO dbo.sys_WorkPoint
  3729. ( ID ,WorkPointCode ,WorkPointName ,ServerName,DataBaseName,DataBaseUser,DataBasePwd, StartFlag,CreateDate,CreateUserCode )
  3730. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}',GETDATE(),'{7}')
  3731. ";
  3732. sql = string.Format(sql, queryParam["WorkPointCode"].ToString(), queryParam["WorkPointName"].ToString(), queryParam["ServerName"].ToString(),
  3733. queryParam["DataBaseName"].ToString(), queryParam["DataBaseUser"].ToString(), pwd, queryParam["StartFlag"].ToString(), MUSER);
  3734. try
  3735. {
  3736. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  3737. {
  3738. }
  3739. else
  3740. {
  3741. msg = "新增失败";
  3742. }
  3743. }
  3744. catch (Exception ex)
  3745. {
  3746. throw new Exception(ex.Message);
  3747. }
  3748. return msg;
  3749. }
  3750. /// <summary>
  3751. /// 修改站点
  3752. /// </summary>
  3753. /// <param name="queryJson"></param>
  3754. /// <returns></returns>
  3755. public string UpdateWorkPoint(string keyValue)
  3756. {
  3757. var queryParam = keyValue.ToJObject();
  3758. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3759. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3760. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3761. string msg = "";
  3762. string pwd = SqlHelper.ToMd5(queryParam["DataBasePwd"].ToString());
  3763. string sql = string.Empty;
  3764. sql = @"UPDATE dbo.sys_WorkPoint set WorkPointCode='{0}',WorkPointName='{1}',ServerName='{2}',DataBaseName='{3}',StartFlag='{4}'
  3765. ,DataBaseUser='{5}',DataBasePwd='{6}',ModifyDate=GETDATE(),ModifyUserCode='{7}' WHERE ID='{8}'";
  3766. sql = string.Format(sql, queryParam["WorkPointCode"].ToString(), queryParam["WorkPointName"].ToString(), queryParam["ServerName"].ToString(),
  3767. queryParam["DataBaseName"].ToString(), queryParam["StartFlag"].ToString(), queryParam["DataBaseUser"].ToString(), pwd
  3768. , MUSER, queryParam["ID"].ToString());
  3769. try
  3770. {
  3771. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  3772. {
  3773. }
  3774. else
  3775. {
  3776. msg = "修改失败";
  3777. }
  3778. }
  3779. catch (Exception ex)
  3780. {
  3781. throw new Exception(ex.Message);
  3782. }
  3783. return msg;
  3784. }
  3785. public Sys_WorkPoint GetWorkPoint(string Id)
  3786. {
  3787. Sys_WorkPoint model = new Sys_WorkPoint();
  3788. string sql = string.Empty;
  3789. sql = string.Format(@"SELECT ID,
  3790. WorkPointCode,
  3791. WorkPointName,
  3792. ServerName,
  3793. DataBaseName,
  3794. DataBaseUser,
  3795. DataBasePwd,
  3796. StartFlag,
  3797. CreateUserCode,
  3798. CreateDate,
  3799. ModifyUserCode,
  3800. ModifyDate
  3801. FROM Sys_WorkPoint
  3802. WHERE ID='{0}'", Id);
  3803. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  3804. if (dt != null && dt.Rows.Count > 0)
  3805. {
  3806. model.ID = dt.Rows[0]["ID"].ToString();
  3807. model.WorkPointCode = dt.Rows[0]["WorkPointCode"].ToString();
  3808. model.WorkPointName = dt.Rows[0]["WorkPointName"].ToString();
  3809. model.ServerName = dt.Rows[0]["ServerName"].ToString();
  3810. model.DataBaseName = dt.Rows[0]["DataBaseName"].ToString();
  3811. model.DataBaseUser = dt.Rows[0]["DataBaseUser"].ToString();
  3812. model.DataBasePwd = SqlHelper.FromMd5(dt.Rows[0]["DataBasePwd"].ToString());
  3813. model.StartFlag = dt.Rows[0]["StartFlag"].ToString();
  3814. }
  3815. return model;
  3816. }
  3817. public DataTable GetICSInventoryLotInfo(string ID)
  3818. {
  3819. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3820. DataTable dt = new DataTable();
  3821. //var queryParam = queryJson.ToJObject();
  3822. List<DbParameter> parameter = new List<DbParameter>();
  3823. string sql = @" SELECT a.ID,
  3824. a.LotNo,
  3825. a.InvCode,
  3826. a.ProductDate,
  3827. a.ExpirationDate,
  3828. a.Quantity,
  3829. a.Amount,
  3830. a.ExtensionID,
  3831. a.Type,
  3832. a.PrintTimes,
  3833. a.LastPrintUser,
  3834. a.LastPrintTime,
  3835. a.MUSER,
  3836. a.MUSERName,
  3837. a.MTIME,
  3838. a.WorkPoint,
  3839. a.EATTRIBUTE1,
  3840. b.InvName,
  3841. b.InvUnit,
  3842. c.Enable
  3843. FROM
  3844. dbo.ICSInventoryLot a left join ICSInventory b on a.InvCode=b.InvCode AND a.WorkPoint=b.WorkPoint
  3845. left join ICSInspection c on a.LotNo=c.LotNo AND a.WorkPoint=b.WorkPoint and c.Enable='1'
  3846. WHERE a.ID='" + ID + "'";
  3847. sql += " and a.WorkPoint='" + WorkPoint + "'";
  3848. return Repository().FindTableBySql(sql.ToString());
  3849. }
  3850. public int UpdateExpirationDate(string ID, string ExpirationDate, string Inv,string LotNo, string InvCode, string Quantity)
  3851. {
  3852. decimal QualifiedQuantity = 0;
  3853. decimal UnqualifiedQuantity = 0;
  3854. if (Inv=="1"){QualifiedQuantity = Convert.ToDecimal(Quantity);}else {UnqualifiedQuantity = Convert.ToDecimal(Quantity); }
  3855. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3856. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3857. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3858. string sqls = string.Empty;
  3859. sqls = @"update ICSInspection set Enable='0' WHERE LotNO='{0}' and Enable='1' and WorkPoint='{1}'";
  3860. sqls = string.Format(sqls, LotNo, WorkPoint);
  3861. SqlHelper.CmdExecuteNonQueryLi(sqls);
  3862. string sql = string.Empty;
  3863. sql += @"UPDATE ICSInventoryLot SET ExpirationDate='{0}' where ID='{1}' AND WorkPoint='{2}'";
  3864. sql += @"INSERT INTO dbo.ICSInspection
  3865. ( ID ,LotNo ,InvCode ,Quantity,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,Type,Result,ExpirationDate,Enable,MUSER,MUSERName,MTIME,WorkPoint )
  3866. Values(NEWID(),'{3}','{4}','{5}','{6}','{7}',0,'4','{8}','{0}','1','{9}','{10}',GETDATE(),'{2}')";
  3867. sql = string.Format(sql, ExpirationDate,ID, WorkPoint, LotNo, InvCode, Quantity, QualifiedQuantity, UnqualifiedQuantity, Inv, MUSER, MUSERNAME);
  3868. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  3869. return count;
  3870. }
  3871. //修改多语言
  3872. public string UpdateSys_Language(string keyValue)
  3873. {
  3874. var queryParam = keyValue.ToJObject();
  3875. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3876. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3877. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3878. string msg = "";
  3879. string sql = string.Empty;
  3880. sql = @"UPDATE Sys_Language set Code='{0}',CnValue='{1}',TwValue='{2}',EnValue='{3}' WHERE ID='{4}'";
  3881. sql = string.Format(sql, queryParam["Code"].ToString(), queryParam["CnValue"].ToString(), queryParam["TwValue"].ToString(), queryParam["EnValue"].ToString(), queryParam["ID"].ToString());
  3882. try
  3883. {
  3884. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  3885. {
  3886. }
  3887. else
  3888. {
  3889. msg = "修改失败";
  3890. }
  3891. }
  3892. catch (Exception ex)
  3893. {
  3894. throw new Exception(ex.Message);
  3895. }
  3896. return msg;
  3897. }
  3898. //新增多语言
  3899. public string InsertSys_Language(string keyValue)
  3900. {
  3901. var queryParam = keyValue.ToJObject();
  3902. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3903. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3904. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3905. string msg = "";
  3906. string sql = string.Empty;
  3907. sql = @" IF EXISTS(SELECT * FROM Sys_Language WHERE Code='{0}' )
  3908. begin
  3909. RAISERROR('',16,1)
  3910. end
  3911. INSERT INTO Sys_Language
  3912. ( ID ,Code ,CnValue ,TwValue,EnValue )
  3913. Values(NEWID(),'{0}','{1}','{2}','{3}')
  3914. ";
  3915. sql = string.Format(sql, queryParam["Code"].ToString(), queryParam["CnValue"].ToString(), queryParam["TwValue"].ToString(), queryParam["EnValue"].ToString());
  3916. try
  3917. {
  3918. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  3919. {
  3920. }
  3921. else
  3922. {
  3923. msg = "新增失败";
  3924. }
  3925. }
  3926. catch (Exception ex)
  3927. {
  3928. throw new Exception(ex.Message);
  3929. }
  3930. return msg;
  3931. }
  3932. public string GetSerialCode(string workPointCode, string tbName, string colName, string Pre, int numLen)
  3933. {
  3934. string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}";
  3935. sql = string.Format(sql, new object[] { workPointCode, tbName, colName, Pre, numLen });
  3936. return DbHelper.ExecuteScalar(CommandType.Text, sql).ToString();
  3937. }
  3938. public DataTable GetSys_Language(string ID)
  3939. {
  3940. DataTable dt = new DataTable();
  3941. //var queryParam = queryJson.ToJObject();
  3942. List<DbParameter> parameter = new List<DbParameter>();
  3943. string sql = @"select ID,Code,CnValue,TwValue,EnValue from Sys_Language
  3944. WHERE 1 =1 and ID='" + ID + "' ";
  3945. return Repository().FindTableBySql(sql.ToString());
  3946. }
  3947. /// <summary>
  3948. /// 删除多语言
  3949. /// </summary>
  3950. /// <param name="keyValue">传入ID</param>
  3951. /// <returns></returns>
  3952. public string DeleteSys_Language(string keyValue)
  3953. {
  3954. string msg = "";
  3955. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  3956. string sql = string.Empty;
  3957. sql = string.Format(@"DELETE FROM Sys_Language WHERE ID IN ({0})", keyValue.TrimEnd(','));
  3958. try
  3959. {
  3960. SqlHelper.ExecuteNonQuery(sql);
  3961. }
  3962. catch (Exception ex)
  3963. {
  3964. throw new Exception(ex.Message);
  3965. }
  3966. return msg;
  3967. }
  3968. //料品检验项目
  3969. public DataTable GetICSInventoryInspectionGroup(ref Pagination jqgridparam, string queryJson)
  3970. {
  3971. DataTable dt = new DataTable();
  3972. var queryParam = queryJson.ToJObject();
  3973. List<DbParameter> parameter = new List<DbParameter>();
  3974. string sql = @"select ID,InvCode,GroupCode,GroupName,
  3975. case when Enable='1' then '是' else '否' end as Enable,
  3976. EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,
  3977. EATTRIBUTE9,EATTRIBUTE10
  3978. MUSER,MUSERName,MTIME,WorkPoint from ICSInventoryInspectionGroup ";
  3979. sql += " WHERE 1=1";
  3980. if (!string.IsNullOrWhiteSpace(queryJson))
  3981. {
  3982. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  3983. {
  3984. sql += " and InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  3985. }
  3986. if (!string.IsNullOrWhiteSpace(queryParam["GroupCode"].ToString()))
  3987. {
  3988. sql += " and GroupCode like '%" + queryParam["GroupCode"].ToString() + "%' ";
  3989. }
  3990. if (!string.IsNullOrWhiteSpace(queryParam["GroupName"].ToString()))
  3991. {
  3992. sql += " and GroupName like '%" + queryParam["GroupName"].ToString() + "%' ";
  3993. }
  3994. }
  3995. sql = string.Format(sql);
  3996. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  3997. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  3998. }
  3999. //料品检验项目子表
  4000. public DataTable ICSInventoryInspectionList(string ID, ref Pagination jqgridparam)
  4001. {
  4002. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4003. DataTable dt = new DataTable();
  4004. //var queryParam = queryJson.ToJObject();
  4005. List<DbParameter> parameter = new List<DbParameter>();
  4006. string sql = @" select ID,InvGroupID,ListCode,ListName,Unit,SetValueMax, SetValueMin,
  4007. CASE WHEN Enable=0 THEN '否' else '是' END Enable,
  4008. MUSERName,MTIME,WorkPoint from ICSInventoryInspectionList
  4009. WHERE InvGroupID='" + ID + "'";
  4010. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  4011. }
  4012. // 删除料品检验项目子表
  4013. public string DeleteICSInventoryInspectionGroup(string keyValue)
  4014. {
  4015. //站点信息
  4016. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4017. string msg = "";
  4018. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  4019. string sql = string.Empty;
  4020. sql += string.Format(@"DELETE FROM dbo.ICSInventoryInspectionGroup WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  4021. sql += string.Format(@"DELETE FROM dbo.ICSInventoryInspectionList WHERE InvGroupID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  4022. try
  4023. {
  4024. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  4025. {
  4026. }
  4027. }
  4028. catch (Exception ex)
  4029. {
  4030. throw new Exception(ex.Message);
  4031. }
  4032. return msg;
  4033. }
  4034. public DataTable Getinv(string invcode, ref Pagination jqgridparam)
  4035. {
  4036. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4037. List<DbParameter> parameter = new List<DbParameter>();
  4038. DataTable table = new DataTable();
  4039. string wherestr = "";
  4040. if (!string.IsNullOrEmpty(invcode))
  4041. {
  4042. wherestr += " and invcode like '%" + invcode + "%'";
  4043. }
  4044. string sql = "select ID,InvCode,InvName,InvDesc,InvUnit,WorkPoint from ICSInventory where workpoint='" + WorkPoint + "'" + wherestr;
  4045. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  4046. }
  4047. public DataTable GetGroupCode()
  4048. {
  4049. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4050. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  4051. string sql = @"select '' as ID,'' as GroupName
  4052. union all
  4053. SELECT distinct ID,GroupName FROM ICSInspectionGroup where WorkPoint='{0}'";
  4054. sql = string.Format(sql, WorkPoint);
  4055. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  4056. return dt;
  4057. }
  4058. public void DeleteINvItem(string ID)
  4059. {
  4060. string sql = "DELETE FROM dbo.ICSInventoryInspectionList WHERE ID='" + ID + "'";
  4061. SqlHelper.ExecuteNonQuery(sql);
  4062. }
  4063. public DataTable GetICSInventoryInspectionList(string ListCode, ref Pagination jqgridparam)
  4064. {
  4065. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4066. DataTable dt = new DataTable();
  4067. //var queryParam = queryJson.ToJObject();
  4068. List<DbParameter> parameter = new List<DbParameter>();
  4069. string sql = @"select ID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable,MUSERName,MTIME from ICSInventoryInspectionList
  4070. WHERE ListCode='" + ListCode + "' ";
  4071. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  4072. }
  4073. public DataTable GetInspectionListInfo(string ID)
  4074. {
  4075. DataTable dt = new DataTable();
  4076. //var queryParam = queryJson.ToJObject();
  4077. List<DbParameter> parameter = new List<DbParameter>();
  4078. string sql = @"
  4079. select ID,ListCode,ListName,Unit,SetValueMax,SetValueMin, CASE WHEN Enable=0 THEN '否' else '是' END Enable
  4080. from ICSInspectionList where GroupID='{0}'";
  4081. sql = string.Format(sql, ID);
  4082. return Repository().FindTableBySql(sql.ToString());
  4083. }
  4084. //新增
  4085. public void SubICSInventoryInspectionGroupAdd(ICSInventoryInspectionGroup main, string ID, string InvCode)
  4086. {
  4087. string sql = string.Empty;
  4088. string sqls = string.Empty;
  4089. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  4090. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  4091. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4092. string NewID = Common.GuId();
  4093. List<ICSInventoryInspectionGroup> list_Item1 = new List<ICSInventoryInspectionGroup>();
  4094. if (main.arrayShellFabricItem != null)
  4095. {
  4096. list_Item1 = JsonConvert.DeserializeObject<List<ICSInventoryInspectionGroup>>(main.arrayShellFabricItem);
  4097. }
  4098. string connString = SqlHelper.DataCenterConnString;
  4099. SqlConnection conn = new SqlConnection(connString);
  4100. conn.Open();
  4101. SqlTransaction sqlTran = conn.BeginTransaction();
  4102. SqlCommand cmd = new SqlCommand();
  4103. cmd.Transaction = sqlTran;
  4104. cmd.Connection = conn;
  4105. sql = @"
  4106. INSERT INTO dbo.ICSInventoryInspectionGroup
  4107. ( ID ,InvCode ,GroupCode ,GroupName ,
  4108. Enable ,MUSER ,MUSERName ,MTIME ,WorkPoint )
  4109. SELECT '{0}','{1}',GroupCode,GroupName,Enable,'{2}','{3}',getdate(),'{4}'
  4110. FROM dbo.ICSInspectionGroup
  4111. WHERE ID='{5}'";
  4112. sql = string.Format(sql, NewID, InvCode, MUSER, MUSERNAME, WorkPoint, ID);
  4113. try
  4114. {
  4115. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  4116. {
  4117. foreach (ICSInventoryInspectionGroup Item in list_Item1)
  4118. {
  4119. sqls = @"
  4120. INSERT INTO dbo.ICSInventoryInspectionList
  4121. ( ID ,InvGroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable , MTIME,MUSER ,MUSERName ,WorkPoint )
  4122. Values(newid(),'{0}',@ListCode,@ListName,@Unit,@SetValueMax,@SetValueMin,@Enable,GETDATE(),'{1}','{2}','{3}')";
  4123. sqls = string.Format(sqls, NewID, MUSER, MUSERNAME, WorkPoint);
  4124. SqlParameter[] sp_Item = {
  4125. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  4126. new SqlParameter("@ListCode",DbType.String){ Value= Item.ListCode},
  4127. new SqlParameter("@ListName",DbType.String){ Value= Item.ListName},
  4128. new SqlParameter("@Unit",DbType.String){ Value= Item.Unit},
  4129. new SqlParameter("@SetValueMax",DbType.String){ Value= Item.SetValueMax},
  4130. new SqlParameter("@SetValueMin",DbType.String){ Value= Item.SetValueMin},
  4131. new SqlParameter("@Enable",DbType.String){ Value= Item.Enable},
  4132. };
  4133. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  4134. }
  4135. cmd.Transaction.Commit();
  4136. }
  4137. }
  4138. catch (Exception ex)
  4139. {
  4140. cmd.Transaction.Rollback();
  4141. throw new Exception(ex.Message);
  4142. }
  4143. finally
  4144. {
  4145. if (conn.State == ConnectionState.Open)
  4146. {
  4147. conn.Close();
  4148. }
  4149. conn.Dispose();
  4150. }
  4151. }
  4152. public DataTable GetICSInventoryInspectionList2(string BID)
  4153. {
  4154. string sql = string.Empty;
  4155. DataTable dt = null;
  4156. sql = string.Format(@" select ID,ListCode,ListName,Unit,SetValueMax,SetValueMin, CASE WHEN Enable='1' THEN '是' else '否' END Enable from ICSInventoryInspectionList where InvGroupID='{0}'", BID);
  4157. dt = SqlHelper.GetDataTableBySql(sql);
  4158. return dt;
  4159. }
  4160. //修改
  4161. public void UpdateICSInventoryInspectionGroup(ICSInventoryInspectionGroup main, string BID, string ID, string InvCode)
  4162. {
  4163. string sql = string.Empty;
  4164. string sqls = string.Empty;
  4165. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  4166. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  4167. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4168. List<ICSInventoryInspectionGroup> list_Item1 = new List<ICSInventoryInspectionGroup>();
  4169. if (main.arrayShellFabricItem != null)
  4170. {
  4171. list_Item1 = JsonConvert.DeserializeObject<List<ICSInventoryInspectionGroup>>(main.arrayShellFabricItem);
  4172. }
  4173. string connString = SqlHelper.DataCenterConnString;
  4174. SqlConnection conn = new SqlConnection(connString);
  4175. conn.Open();
  4176. SqlTransaction sqlTran = conn.BeginTransaction();
  4177. SqlCommand cmd = new SqlCommand();
  4178. cmd.Transaction = sqlTran;
  4179. cmd.Connection = conn;
  4180. 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}'";
  4181. sql = string.Format(sql, InvCode, MUSER, MUSERNAME, WorkPoint, ID,BID);
  4182. try
  4183. {
  4184. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  4185. {
  4186. foreach (ICSInventoryInspectionGroup Item in list_Item1)
  4187. {
  4188. sqls = @" IF NOT EXISTS(SELECT * FROM ICSInventoryInspectionList WHERE ID=@ID)
  4189. BEGIN
  4190. INSERT INTO dbo.ICSInventoryInspectionList
  4191. ( ID ,InvGroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable , MTIME,MUSER ,MUSERName ,WorkPoint )
  4192. Values(@ID,'{0}',@ListCode,@ListName,@Unit,@SetValueMax,@SetValueMin,@Enable,GETDATE(),'{1}','{2}','{3}')
  4193. END
  4194. ELSE
  4195. BEGIN
  4196. 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
  4197. end
  4198. ";
  4199. sqls = string.Format(sqls, BID, MUSER, MUSERNAME, WorkPoint);
  4200. SqlParameter[] sp_Item = {
  4201. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  4202. new SqlParameter("@ListCode",DbType.String){ Value= Item.ListCode},
  4203. new SqlParameter("@ListName",DbType.String){ Value= Item.ListName},
  4204. new SqlParameter("@Unit",DbType.String){ Value= Item.Unit},
  4205. new SqlParameter("@SetValueMax",DbType.String){ Value= Item.SetValueMax},
  4206. new SqlParameter("@SetValueMin",DbType.String){ Value= Item.SetValueMin},
  4207. new SqlParameter("@Enable",DbType.String){ Value= Item.Enable},
  4208. };
  4209. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  4210. }
  4211. cmd.Transaction.Commit();
  4212. }
  4213. }
  4214. catch (Exception ex)
  4215. {
  4216. cmd.Transaction.Rollback();
  4217. throw new Exception(ex.Message);
  4218. }
  4219. finally
  4220. {
  4221. if (conn.State == ConnectionState.Open)
  4222. {
  4223. conn.Close();
  4224. }
  4225. conn.Dispose();
  4226. }
  4227. }
  4228. //库位导入
  4229. public string UploadFileInvBadGroup(String savePath)
  4230. {
  4231. //数据获取
  4232. try
  4233. {
  4234. int index = 1;
  4235. string msg = "";
  4236. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  4237. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  4238. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4239. string MTIME = DateTime.Now.ToString();
  4240. SqlConnection conn = SqlHelper.GetDataCenterConn();
  4241. string sql = "";
  4242. int count = 0;
  4243. DataTable data = FileToExcel.ExcelToTable(savePath);
  4244. foreach (DataRow dr in data.Rows)
  4245. {
  4246. index++;
  4247. var Enable = "";
  4248. string InvCode = dr["料品代码"].ToString().Trim().ToUpper();
  4249. string BCGroupCode = dr["不良代码组代码"].ToString().Trim().ToUpper();
  4250. string BRGroupCode = dr["不良原因组代码"].ToString().Trim().ToUpper();
  4251. string Enables = dr["是否启用"].ToString().Trim().ToUpper();
  4252. if (InvCode == "" || InvCode == null)
  4253. {
  4254. throw new Exception("第 " + index + " 行料品代码不能为空!");
  4255. }
  4256. if (BCGroupCode == "" || BCGroupCode == null)
  4257. {
  4258. throw new Exception("第 " + index + " 行不良代码组代码不能为空!");
  4259. }
  4260. if (BRGroupCode == "" || BRGroupCode == null)
  4261. {
  4262. throw new Exception("第 " + index + " 行不良原因组代码不能为空!");
  4263. }
  4264. if (Enables == "" || Enables == null)
  4265. {
  4266. throw new Exception("第 " + index + " 行是否启用不能为空!");
  4267. }
  4268. string sqlWH = @"select ID from dbo.ICSInventory where InvCode='{0}' and WorkPoint='{1}'";
  4269. sqlWH += @" select ID from ICSBadCodeGroup where BCGCode='{2}' and WorkPoint='{1}'";
  4270. sqlWH += @" select ID from ICSBadReasonGroup where BRGCode='{3}' and WorkPoint='{1}'";
  4271. sqlWH += @" select a.ID from ICSInventoryBadGroup a
  4272. inner join ICSBadCodeGroup b on a.BCGroupID=b.ID and a.WorkPoint=b.WorkPoint
  4273. inner join ICSBadReasonGroup c on a.BRGroupID=c.ID and a.WorkPoint=b.WorkPoint
  4274. where a.InvCode='{0}' and b.BCGCode='{2}'and c.BRGCode='{3}' and a.WorkPoint='{1}'";
  4275. sqlWH = string.Format(sqlWH, InvCode, WorkPoint, BCGroupCode, BRGroupCode);
  4276. DataSet ds = SqlHelper.GetDataSetBySql(sqlWH);
  4277. if (ds.Tables[0] == null || ds.Tables[0].Rows.Count <= 0)
  4278. {
  4279. throw new Exception("料品代码: " + InvCode + " 不存在!");
  4280. }
  4281. if (ds.Tables[1] == null || ds.Tables[1].Rows.Count <= 0)
  4282. {
  4283. throw new Exception("不良代码组代码: " + BCGroupCode + " 不存在!");
  4284. }
  4285. if (ds.Tables[2] == null || ds.Tables[2].Rows.Count <= 0)
  4286. {
  4287. throw new Exception("不良原因组代码: " + BRGroupCode + " 不存在!");
  4288. }
  4289. if (ds.Tables[3].Rows.Count > 0)
  4290. {
  4291. throw new Exception("第 " + index + " 行,料品: " + InvCode + " 已绑定相同不良信息!");
  4292. }
  4293. if (Enables=="是")
  4294. {
  4295. Enable = "1";
  4296. }
  4297. else
  4298. {
  4299. Enable = "0";
  4300. }
  4301. sql += @"INSERT INTO dbo.ICSInventoryBadGroup
  4302. ( ID,InvCode,BCGroupID,BRGroupID,Enable,MUSER,MUSERName,MTIME,WorkPoint)
  4303. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')";
  4304. sql = string.Format(sql, InvCode, ds.Tables[1].Rows[0]["ID"].ToString(), ds.Tables[2].Rows[0]["ID"].ToString(), Enable, MUSER, MUSERNAME, MTIME, WorkPoint);
  4305. }
  4306. count = SqlHelper.CmdExecuteNonQueryLi(sql);
  4307. if (count > 0)
  4308. {
  4309. msg = "导入成功";
  4310. }
  4311. else
  4312. {
  4313. return "无有效的导入数据。";
  4314. }
  4315. return msg;
  4316. }
  4317. catch (Exception ex)
  4318. {
  4319. return ex.Message;
  4320. }
  4321. }
  4322. /// <summary>
  4323. /// 根据ID获取其他站点
  4324. /// </summary>
  4325. /// <returns></returns>
  4326. public DataTable GetWorkPointNotInID(string WorkPointCode)
  4327. {
  4328. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4329. string sql = @"select '' as WorkPointCode,'' as WorkPointName union all
  4330. SELECT WorkPointCode,WorkPointName FROM dbo.Sys_WorkPoint WITH (NOLOCK) WHERE WorkPointCode <>'{0}'
  4331. ";
  4332. sql = string.Format(sql, WorkPointCode.TrimEnd(','));
  4333. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  4334. return dt;
  4335. }
  4336. public string CloneWorkPointByCode(string WorkPoint, string WorkPointCode)
  4337. {
  4338. string msg = "";
  4339. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4340. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  4341. string MUSERName = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  4342. string sql = string.Empty;
  4343. var ID = Guid.NewGuid();
  4344. //克隆参数配置表
  4345. sql += @"INSERT INTO ICSConfiguration(ID, Code, Name, Enable, Figure, MTIME, MUSER, MUSERName, WorkPoint)
  4346. SELECT newid(),Code,Name,Enable,Figure,getdate(),'{0}','{1}','{2}'
  4347. FROM ICSConfiguration
  4348. where WorkPoint='{3}'
  4349. ";
  4350. //克隆列类型
  4351. sql += @"INSERT INTO ICSType(ID, TableCode, ColumnCode, Code, Name, Enable, MTIME, MUSER, MUSERName, WorkPoint)
  4352. SELECT newid(),TableCode,ColumnCode,Code,Name,Enable,getdate(),'{0}','{1}','{2}'
  4353. FROM ICSType
  4354. where WorkPoint='{3}'
  4355. ";
  4356. //克隆admin
  4357. sql += @"INSERT INTO Sys_SRM_User( F_Id, F_Account, F_RealName,F_NickName,F_HeadIcon,F_Gender,F_Birthday,F_MobilePhone,F_Email,F_WeChat,F_ManagerId,F_SecurityLevel,F_Signature,F_OrganizeId,F_DepartmentId,F_RoleId,F_DutyId,F_IsAdministrator,F_SortCode,F_DeleteMark,F_EnabledMark,F_Description,F_CreatorTime,F_CreatorUserId,F_LastModifyTime,F_LastModifyUserId,F_DeleteTime,F_DeleteUserId,F_Location,F_VenCode)
  4358. SELECT '{4}',F_Account,F_RealName,F_NickName,F_HeadIcon,F_Gender,F_Birthday,F_MobilePhone,F_Email,F_WeChat,F_ManagerId,F_SecurityLevel,F_Signature,F_OrganizeId,F_DepartmentId,F_RoleId,F_DutyId,F_IsAdministrator,F_SortCode,F_DeleteMark,F_EnabledMark,F_Description,getdate(),F_CreatorUserId,F_LastModifyTime,F_LastModifyUserId,F_DeleteTime,F_DeleteUserId,'{2}',F_VenCode
  4359. FROM Sys_SRM_User
  4360. where F_Location='{3}' and F_Account='admin'
  4361. ";
  4362. //克隆admin登陆
  4363. sql += @"INSERT INTO Sys_SRM_UserLogOn( F_Id, F_UserId, F_UserPassword, F_UserSecretkey, F_AllowStartTime, F_AllowEndTime, F_LockStartDate, F_LockEndDate, F_FirstVisitTime, F_PreviousVisitTime, F_LastVisitTime, F_ChangePasswordDate, F_MultiUserLogin, F_LogOnCount, F_UserOnLine, F_Question, F_AnswerQuestion, F_CheckIPAddress, F_Language, F_Theme)
  4364. SELECT '{4}','{4}',F_UserPassword,F_UserSecretkey,F_AllowStartTime,F_AllowEndTime,F_LockStartDate,F_LockEndDate,F_FirstVisitTime,F_PreviousVisitTime,F_LastVisitTime,F_ChangePasswordDate,F_MultiUserLogin,F_LogOnCount,F_UserOnLine,F_Question,F_AnswerQuestion,F_CheckIPAddress,F_Language,F_Theme
  4365. from dbo.Sys_SRM_UserLogOn a
  4366. left join dbo.Sys_SRM_User b on a.F_UserId=b.F_Id
  4367. where b.F_Account='admin' and b.F_Location='{3}'
  4368. ";
  4369. sql = string.Format(sql, MUSER, MUSERName, WorkPointCode, WorkPoint, ID);
  4370. try
  4371. {
  4372. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  4373. {
  4374. }
  4375. else
  4376. {
  4377. msg = "克隆失败";
  4378. }
  4379. }
  4380. catch (Exception ex)
  4381. {
  4382. throw new Exception(ex.Message);
  4383. }
  4384. return msg;
  4385. }
  4386. public string DeleteTableByCode(string TableCode)
  4387. {
  4388. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  4389. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  4390. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4391. string msg = "";
  4392. string sql = string.Empty;
  4393. JArray res = (JArray)JsonConvert.DeserializeObject(TableCode);
  4394. foreach (var item in res)
  4395. {
  4396. JObject jo = (JObject)item;
  4397. sql += @" delete "+ jo["Code"].ToString() + " where WorkPoint='"+ WorkPoint + "' ";
  4398. }
  4399. try
  4400. {
  4401. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  4402. {
  4403. }
  4404. else
  4405. {
  4406. msg = "清除失败";
  4407. }
  4408. }
  4409. catch (Exception ex)
  4410. {
  4411. //throw new Exception(ex.Message);
  4412. msg = ex.Message;
  4413. }
  4414. return msg;
  4415. }
  4416. }
  4417. }