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

2782 lines
113 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  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. namespace NFine.Application.WMS
  19. {
  20. public class BasicSettingsApp : RepositoryFactory<ICSVendor>
  21. {
  22. /// <summary>
  23. /// 删除库位
  24. /// </summary>
  25. /// <param name="keyValue">传入ID</param>
  26. /// <returns></returns>
  27. public string DeleteStack(string keyValue)
  28. {
  29. //站点信息
  30. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  31. string msg = "";
  32. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  33. string sql = string.Empty;
  34. sql = string.Format(@"DELETE FROM dbo.ICSLocation WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  35. try
  36. {
  37. SqlHelper.ExecuteNonQuery(sql);
  38. }
  39. catch (Exception ex)
  40. {
  41. throw new Exception(ex.Message);
  42. }
  43. return msg;
  44. }
  45. /// <summary>
  46. /// 删除不良原因
  47. /// </summary>
  48. /// <param name="keyValue">传入ID</param>
  49. /// <returns></returns>
  50. public string DeleteBadCode(string keyValue)
  51. {
  52. //站点信息
  53. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  54. string msg = "";
  55. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  56. string sql = string.Empty;
  57. sql = string.Format(@"DELETE FROM dbo.ICSBadCode WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  58. try
  59. {
  60. SqlHelper.ExecuteNonQuery(sql);
  61. }
  62. catch (Exception ex)
  63. {
  64. throw new Exception(ex.Message);
  65. }
  66. return msg;
  67. }
  68. /// <summary>
  69. /// 获取库房信息
  70. /// </summary>
  71. /// <returns></returns>
  72. public DataTable GetWarehouse()
  73. {
  74. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  75. string sql = @"
  76. select '' as WarehouseCode,'' as WarehouseName
  77. union all
  78. SELECT [WarehouseCode],[WarehouseName] FROM [ICSWarehouse] WITH (NOLOCK) WHERE 1=1 ";
  79. //string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  80. //if (role != "admin")
  81. //{
  82. // sql += " and b.WorkPoint='" + WorkPoint + "'";
  83. //}
  84. sql += " and WorkPoint='" + WorkPoint + "'";
  85. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  86. return dt;
  87. }
  88. /// <summary>
  89. /// 新增库位
  90. /// </summary>
  91. /// <param name="queryJson"></param>
  92. /// <returns></returns>
  93. public string InsertStack(string keyValue)
  94. {
  95. var queryParam = keyValue.ToJObject();
  96. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  97. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  98. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  99. string msg = "";
  100. string StackSql = @"select * from ICSWarehouse where WarehouseCode='{0}' and WorkPoint='{1}'";
  101. StackSql = string.Format(StackSql, queryParam["Warehouse"].ToString(), WorkPoint);
  102. DataTable dt = SqlHelper.GetDataTableBySql(StackSql);
  103. string sql = string.Empty;
  104. sql = @"INSERT INTO dbo.ICSLocation
  105. ( ID ,LocationCode ,LocationName ,WHID ,MUSER ,
  106. MUSERName ,MTIME ,WorkPoint ) Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',GETDATE(),'{5}')";
  107. sql = string.Format(sql, queryParam["StackCode"].ToString(), queryParam["StackName"].ToString(), dt.Rows[0]["ID"].ToString(), MUSER, MUSERNAME, WorkPoint);
  108. try
  109. {
  110. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  111. {
  112. }
  113. else
  114. {
  115. msg = "新增失败";
  116. }
  117. }
  118. catch (Exception ex)
  119. {
  120. throw new Exception(ex.Message);
  121. }
  122. return msg;
  123. }
  124. /// <summary>
  125. /// 新增不良代码
  126. /// </summary>
  127. /// <param name="queryJson"></param>
  128. /// <returns></returns>
  129. public string InsertBadCode(string keyValue)
  130. {
  131. var queryParam = keyValue.ToJObject();
  132. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  133. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  134. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  135. string msg = "";
  136. string sql = string.Empty;
  137. sql = @"INSERT INTO dbo.ICSBadCode
  138. ( ID ,BadCode ,BadDesc ,MUSER ,
  139. MUSERName ,MTIME ,WorkPoint,BCGroupID ) Values(NEWID(),'{0}','{1}','{2}','{3}',GETDATE(),'{4}','NULL')";
  140. sql = string.Format(sql, queryParam["BadCode"].ToString(), queryParam["BadDesc"].ToString(), MUSER, MUSERNAME, WorkPoint);
  141. try
  142. {
  143. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  144. {
  145. }
  146. else
  147. {
  148. msg = "新增失败";
  149. }
  150. }
  151. catch (Exception ex)
  152. {
  153. throw new Exception(ex.Message);
  154. }
  155. return msg;
  156. }
  157. /// <summary>
  158. /// 修改不良代码
  159. /// </summary>
  160. /// <param name="queryJson"></param>
  161. /// <returns></returns>
  162. public string UpdateBadCode(string keyValue)
  163. {
  164. var queryParam = keyValue.ToJObject();
  165. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  166. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  167. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  168. string msg = "";
  169. string sql = string.Empty;
  170. sql = @"UPDATE dbo.ICSBadCode set BadCode='{0}',BadDesc='{1}',MUSER='{2}',MUSERName='{3}',MTIME=GetDate(),WorkPoint='{4}' WHERE ID='{5}'";
  171. sql = string.Format(sql, queryParam["BadCode"].ToString(), queryParam["BadDesc"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  172. try
  173. {
  174. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  175. {
  176. }
  177. else
  178. {
  179. msg = "新增失败";
  180. }
  181. }
  182. catch (Exception ex)
  183. {
  184. throw new Exception(ex.Message);
  185. }
  186. return msg;
  187. }
  188. /// <summary>
  189. /// 修改库位
  190. /// </summary>
  191. /// <param name="queryJson"></param>
  192. /// <returns></returns>
  193. public string UpdateStack(string keyValue)
  194. {
  195. var queryParam = keyValue.ToJObject();
  196. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  197. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  198. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  199. string msg = "";
  200. string StackSql = @"select * from ICSWarehouse where WarehouseCode='{0}'";
  201. StackSql = string.Format(StackSql, queryParam["Warehouse"].ToString());
  202. DataTable dt = SqlHelper.GetDataTableBySql(StackSql);
  203. string sql = string.Empty;
  204. sql = @"UPDATE dbo.ICSLocation set LocationCode='{0}',LocationName='{1}',WHID='{2}',MUSER='{3}',MUSERName='{4}',MTIME=GETDATE(),WorkPoint='{5}' WHERE ID='{6}'";
  205. sql = string.Format(sql, queryParam["StackCode"].ToString(), queryParam["StackName"].ToString(), dt.Rows[0]["ID"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  206. try
  207. {
  208. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  209. {
  210. }
  211. else
  212. {
  213. msg = "修改失败";
  214. }
  215. }
  216. catch (Exception ex)
  217. {
  218. throw new Exception(ex.Message);
  219. }
  220. return msg;
  221. }
  222. /// <summary>
  223. /// 新增类型
  224. /// </summary>
  225. /// <param name="queryJson"></param>
  226. /// <returns></returns>
  227. public string InsertICSType(string keyValue)
  228. {
  229. var queryParam = keyValue.ToJObject();
  230. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  231. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  232. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  233. string msg = "";
  234. string sql = string.Empty;
  235. sql = @"INSERT INTO dbo.ICSType
  236. ( ID ,TableCode ,ColumnCode ,Code,Name, Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
  237. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',GETDATE(),'{5}','{6}','{7}')
  238. ";
  239. sql = string.Format(sql, queryParam["TableCode"].ToString(), queryParam["ColumnCode"].ToString(), queryParam["Code"].ToString(), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint);
  240. try
  241. {
  242. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  243. {
  244. }
  245. else
  246. {
  247. msg = "新增失败";
  248. }
  249. }
  250. catch (Exception ex)
  251. {
  252. throw new Exception(ex.Message);
  253. }
  254. return msg;
  255. }
  256. /// <summary>
  257. /// 修改类型
  258. /// </summary>
  259. /// <param name="queryJson"></param>
  260. /// <returns></returns>
  261. public string UpdateICSType(string keyValue)
  262. {
  263. var queryParam = keyValue.ToJObject();
  264. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  265. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  266. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  267. string msg = "";
  268. string sql = string.Empty;
  269. 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}'";
  270. 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());
  271. try
  272. {
  273. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  274. {
  275. }
  276. else
  277. {
  278. msg = "修改失败";
  279. }
  280. }
  281. catch (Exception ex)
  282. {
  283. throw new Exception(ex.Message);
  284. }
  285. return msg;
  286. }
  287. /// <summary>
  288. /// 删除类型
  289. /// </summary>
  290. /// <param name="keyValue">传入ID</param>
  291. /// <returns></returns>
  292. public string DeleteICSType(string keyValue)
  293. {
  294. //站点信息
  295. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  296. string msg = "";
  297. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  298. string sql = string.Empty;
  299. sql = string.Format(@"DELETE FROM dbo.ICSType WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  300. try
  301. {
  302. SqlHelper.ExecuteNonQuery(sql);
  303. }
  304. catch (Exception ex)
  305. {
  306. throw new Exception(ex.Message);
  307. }
  308. return msg;
  309. }
  310. /// <summary>
  311. /// 修改参数配置
  312. /// </summary>
  313. /// <param name="queryJson"></param>
  314. /// <returns></returns>
  315. public string UpdateICSConfiguration(string keyValue)
  316. {
  317. var queryParam = keyValue.ToJObject();
  318. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  319. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  320. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  321. string msg = "";
  322. string sql = string.Empty;
  323. sql = @"UPDATE dbo.ICSConfiguration set Code='{0}',Name='{1}',Enable='{2}',Figure='{3}',MTIME=GETDATE(),MUSER='{4}',MUSERName='{5}',WorkPoint='{6}' WHERE ID='{7}'";
  324. sql = string.Format(sql, queryParam["Code"].ToString(), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), queryParam["Figure"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  325. try
  326. {
  327. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  328. {
  329. }
  330. else
  331. {
  332. msg = "修改失败";
  333. }
  334. }
  335. catch (Exception ex)
  336. {
  337. throw new Exception(ex.Message);
  338. }
  339. return msg;
  340. }
  341. /// <summary>
  342. /// 新增参数配置
  343. /// </summary>
  344. /// <param name="queryJson"></param>
  345. /// <returns></returns>
  346. public string InsertICSConfiguration(string keyValue)
  347. {
  348. var queryParam = keyValue.ToJObject();
  349. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  350. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  351. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  352. string msg = "";
  353. string sql = string.Empty;
  354. sql = @"INSERT INTO dbo.ICSConfiguration
  355. ( ID ,Code ,Name ,Enable,Figure,MTIME,MUSER ,MUSERName ,WorkPoint )
  356. Values(NEWID(),'{0}','{1}','{2}','{3}',GETDATE(),'{4}','{5}','{6}')
  357. ";
  358. sql = string.Format(sql, queryParam["Code"].ToString(), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), queryParam["Figure"].ToString(), MUSER, MUSERNAME, WorkPoint);
  359. try
  360. {
  361. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  362. {
  363. }
  364. else
  365. {
  366. msg = "新增失败";
  367. }
  368. }
  369. catch (Exception ex)
  370. {
  371. throw new Exception(ex.Message);
  372. }
  373. return msg;
  374. }
  375. /// <summary>
  376. /// 删除参数配置
  377. /// </summary>
  378. /// <param name="keyValue">传入ID</param>
  379. /// <returns></returns>
  380. public string DeleteICSConfiguration(string keyValue)
  381. {
  382. //站点信息
  383. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  384. string msg = "";
  385. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  386. string sql = string.Empty;
  387. sql = string.Format(@"DELETE FROM dbo.ICSConfiguration WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  388. try
  389. {
  390. SqlHelper.ExecuteNonQuery(sql);
  391. }
  392. catch (Exception ex)
  393. {
  394. throw new Exception(ex.Message);
  395. }
  396. return msg;
  397. }
  398. /// <summary>
  399. /// 修改启用配置
  400. /// </summary>
  401. /// <param name="queryJson"></param>
  402. /// <returns></returns>
  403. public string UpdateICSExtensionEnable(string keyValue)
  404. {
  405. var queryParam = keyValue.ToJObject();
  406. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  407. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  408. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  409. string msg = "";
  410. string sql = string.Empty;
  411. sql = @"UPDATE dbo.ICSExtensionEnable set ColCode='{0}',ColName='{1}',Enable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
  412. sql = string.Format(sql, queryParam["ColCode"].ToString(), queryParam["ColName"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  413. try
  414. {
  415. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  416. {
  417. }
  418. else
  419. {
  420. msg = "修改失败";
  421. }
  422. }
  423. catch (Exception ex)
  424. {
  425. throw new Exception(ex.Message);
  426. }
  427. return msg;
  428. }
  429. /// <summary>
  430. /// 新增启用配置
  431. /// </summary>
  432. /// <param name="queryJson"></param>
  433. /// <returns></returns>
  434. public string InsertICSExtensionEnable(string keyValue)
  435. {
  436. var queryParam = keyValue.ToJObject();
  437. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  438. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  439. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  440. string msg = "";
  441. string sql = string.Empty;
  442. sql = @"INSERT INTO dbo.ICSExtensionEnable
  443. ( ID ,ColCode ,ColName ,Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
  444. Values(NEWID(),'{0}','{1}','{2}',GETDATE(),'{3}','{4}','{5}')
  445. ";
  446. sql = string.Format(sql, queryParam["ColCode"].ToString(), queryParam["ColName"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint);
  447. try
  448. {
  449. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  450. {
  451. }
  452. else
  453. {
  454. msg = "新增失败";
  455. }
  456. }
  457. catch (Exception ex)
  458. {
  459. throw new Exception(ex.Message);
  460. }
  461. return msg;
  462. }
  463. /// <summary>
  464. /// 删除启用配置
  465. /// </summary>
  466. /// <param name="keyValue">传入ID</param>
  467. /// <returns></returns>
  468. public string DeleteICSExtensionEnable(string keyValue)
  469. {
  470. //站点信息
  471. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  472. string msg = "";
  473. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  474. string sql = string.Empty;
  475. sql = string.Format(@"DELETE FROM dbo.ICSExtensionEnable WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  476. try
  477. {
  478. SqlHelper.ExecuteNonQuery(sql);
  479. }
  480. catch (Exception ex)
  481. {
  482. throw new Exception(ex.Message);
  483. }
  484. return msg;
  485. }
  486. //不良代码
  487. public DataTable GetICSBadCodeGroup(ref Pagination jqgridparam, string queryJson)
  488. {
  489. DataTable dt = new DataTable();
  490. var queryParam = queryJson.ToJObject();
  491. List<DbParameter> parameter = new List<DbParameter>();
  492. string sql = @" select ID,BCGCode,BCGDesc,MUSER,MUSERName,MTIME from ICSBadCodeGroup ";
  493. sql += " WHERE 1=1";
  494. if (!string.IsNullOrWhiteSpace(queryJson))
  495. {
  496. if (!string.IsNullOrWhiteSpace(queryParam["BadCode"].ToString()))
  497. {
  498. sql += " and BCGCode like '%" + queryParam["BadCode"].ToString() + "%' ";
  499. }
  500. if (!string.IsNullOrWhiteSpace(queryParam["BadCodeName"].ToString()))
  501. {
  502. sql += " and BCGDesc like '%" + queryParam["BadCodeName"].ToString() + "%' ";
  503. }
  504. }
  505. sql = string.Format(sql);
  506. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  507. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  508. }
  509. //不良原因
  510. public DataTable GetICSBadReasonGroup(ref Pagination jqgridparam, string queryJson)
  511. {
  512. DataTable dt = new DataTable();
  513. var queryParam = queryJson.ToJObject();
  514. List<DbParameter> parameter = new List<DbParameter>();
  515. string sql = @" select ID,BRGCode,BRGDesc,MUSER,MUSERName,MTIME from ICSBadReasonGroup ";
  516. sql += " WHERE 1=1";
  517. if (!string.IsNullOrWhiteSpace(queryJson))
  518. {
  519. if (!string.IsNullOrWhiteSpace(queryParam["BadReason"].ToString()))
  520. {
  521. sql += " and BRGCode like '%" + queryParam["BadReason"].ToString() + "%' ";
  522. }
  523. if (!string.IsNullOrWhiteSpace(queryParam["BadReasonName"].ToString()))
  524. {
  525. sql += " and BRGDesc like '%" + queryParam["BadReasonName"].ToString() + "%' ";
  526. }
  527. }
  528. sql = string.Format(sql);
  529. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  530. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  531. }
  532. //不良代码子表
  533. public DataTable GetICSBadCodeGroupdetil(string ID, ref Pagination jqgridparam)
  534. {
  535. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  536. DataTable dt = new DataTable();
  537. //var queryParam = queryJson.ToJObject();
  538. List<DbParameter> parameter = new List<DbParameter>();
  539. string sql = @"select BCGroupID,BadCode,BadDesc,MUSERName,MTIME from ICSBadCode
  540. where BCGroupID='" + ID + "' ";
  541. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  542. }
  543. public DataTable GetICSBadCode(string BRGCode, ref Pagination jqgridparam)
  544. {
  545. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  546. DataTable dt = new DataTable();
  547. //var queryParam = queryJson.ToJObject();
  548. List<DbParameter> parameter = new List<DbParameter>();
  549. string sql = @"select BRGroupID,BadReasonCode,BadReasonDesc,MUSERName,MTIME from ICSBadReason
  550. WHERE BRGroupID='" + BRGCode + "' ";
  551. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  552. }
  553. /// <summary>
  554. /// 不良原因子表查询
  555. /// </summary>
  556. /// <param name="queryJson"></param>
  557. /// <param name="jqgridparam"></param>
  558. /// <returns></returns>
  559. public DataTable GetICSBadReason(string BRGCode, ref Pagination jqgridparam)
  560. {
  561. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  562. DataTable dt = new DataTable();
  563. //var queryParam = queryJson.ToJObject();
  564. List<DbParameter> parameter = new List<DbParameter>();
  565. string sql = @"select BRGroupID,BadReasonCode,BadReasonDesc,MUSERName,MTIME from ICSBadReason
  566. WHERE BRGroupID='" + BRGCode + "' ";
  567. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  568. }
  569. /// <summary>
  570. /// 不良原因子表查询2
  571. /// </summary>
  572. /// <param name="queryJson"></param>
  573. /// <param name="jqgridparam"></param>
  574. /// <returns></returns>
  575. public DataTable GetICSBadReason2(string BRGCode, ref Pagination jqgridparam)
  576. {
  577. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  578. DataTable dt = new DataTable();
  579. //var queryParam = queryJson.ToJObject();
  580. List<DbParameter> parameter = new List<DbParameter>();
  581. string sql = @"select BRGroupID,BadReasonCode,BadReasonDesc,MUSERName,MTIME from ICSBadReason
  582. WHERE BRGroupID='" + BRGCode + "' ";
  583. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  584. }
  585. public void DeleteBCItem(string ID)
  586. {
  587. string sql = "DELETE FROM dbo.ICSBadCode WHERE ID='" + ID + "'";
  588. SqlHelper.ExecuteNonQuery(sql);
  589. }
  590. public void DeleteItem(string ID)
  591. {
  592. string sql = "DELETE FROM dbo.ICSBadReason WHERE ID='" + ID + "'";
  593. SqlHelper.ExecuteNonQuery(sql);
  594. }
  595. //不良代码新增
  596. public void SubICSBadCodeGroupAdd(ICSBadReason main, string BRGCode, string BRGDesc)
  597. {
  598. string sql = string.Empty;
  599. string sqls = string.Empty;
  600. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  601. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  602. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  603. string NewID = Common.GuId();
  604. List<ICSBadReason> list_Item1 = new List<ICSBadReason>();
  605. if (main.arrayShellFabricItem != null)
  606. {
  607. list_Item1 = JsonConvert.DeserializeObject<List<ICSBadReason>>(main.arrayShellFabricItem);
  608. }
  609. string connString = SqlHelper.DataCenterConnString;
  610. SqlConnection conn = new SqlConnection(connString);
  611. conn.Open();
  612. SqlTransaction sqlTran = conn.BeginTransaction();
  613. SqlCommand cmd = new SqlCommand();
  614. cmd.Transaction = sqlTran;
  615. cmd.Connection = conn;
  616. sql = @"IF EXISTS( select BCGCode from ICSBadCodeGroup where BCGCode='{0}')
  617. BEGIN
  618. RAISERROR('',16,1);
  619. RETURN
  620. END
  621. INSERT INTO dbo.ICSBadCodeGroup
  622. ( ID ,BCGCode ,BCGDesc, MTIME,MUSER ,MUSERName ,WorkPoint )
  623. Values('{5}','{0}','{1}',GETDATE(),'{2}','{3}','{4}')";
  624. sql = string.Format(sql, BRGCode, BRGDesc, MUSER, MUSERNAME, WorkPoint, NewID);
  625. try
  626. {
  627. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  628. {
  629. foreach (ICSBadReason Item in list_Item1)
  630. {
  631. sqls = @"IF EXISTS( select BadCode from ICSBadCode where BadCode=@BadReasonCode)
  632. BEGIN
  633. RAISERROR('',16,1);
  634. RETURN
  635. END
  636. INSERT INTO dbo.ICSBadCode
  637. ( ID ,BCGroupID,BadCode ,BadDesc, MTIME,MUSER ,MUSERName ,WorkPoint )
  638. Values(@ID,'{0}',@BadReasonCode,@BadReasonDesc,GETDATE(),'{1}','{2}','{3}')";
  639. sqls = string.Format(sqls,NewID, MUSER, MUSERNAME, WorkPoint);
  640. SqlParameter[] sp_Item =
  641. {
  642. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  643. new SqlParameter("@BadReasonCode",DbType.String){ Value= Item.BadReasonCode},
  644. new SqlParameter("@BadReasonDesc",DbType.String){ Value= Item.BadReasonDesc},
  645. };
  646. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  647. }
  648. cmd.Transaction.Commit();
  649. }
  650. }
  651. catch (Exception ex)
  652. {
  653. cmd.Transaction.Rollback();
  654. throw new Exception(ex.Message);
  655. }
  656. finally
  657. {
  658. if (conn.State == ConnectionState.Open)
  659. {
  660. conn.Close();
  661. }
  662. conn.Dispose();
  663. }
  664. }
  665. //不良原因新增
  666. public void SubICSBadReasonGroupAdd(ICSBadReason main, string BRGCode, string BRGDesc)
  667. {
  668. string sql = string.Empty;
  669. string sqls = string.Empty;
  670. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  671. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  672. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  673. string NewID = Common.GuId();
  674. List<ICSBadReason> list_Item1 = new List<ICSBadReason>();
  675. if (main.arrayShellFabricItem != null)
  676. {
  677. list_Item1 = JsonConvert.DeserializeObject<List<ICSBadReason>>(main.arrayShellFabricItem);
  678. }
  679. string connString = SqlHelper.DataCenterConnString;
  680. SqlConnection conn = new SqlConnection(connString);
  681. conn.Open();
  682. SqlTransaction sqlTran = conn.BeginTransaction();
  683. SqlCommand cmd = new SqlCommand();
  684. cmd.Transaction = sqlTran;
  685. cmd.Connection = conn;
  686. sql = @"IF EXISTS( select BRGCode from ICSBadReasonGroup where BRGCode='{0}')
  687. BEGIN
  688. RAISERROR('',16,1);
  689. RETURN
  690. end
  691. INSERT INTO dbo.ICSBadReasonGroup
  692. ( ID ,BRGCode ,BRGDesc, MTIME,MUSER ,MUSERName ,WorkPoint )
  693. Values('{5}','{0}','{1}',GETDATE(),'{2}','{3}','{4}')";
  694. sql = string.Format(sql, BRGCode, BRGDesc, MUSER, MUSERNAME, WorkPoint, NewID);
  695. try
  696. {
  697. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  698. {
  699. foreach (ICSBadReason Item in list_Item1)
  700. {
  701. sqls = @"IF EXISTS(select BadReasonCode from ICSBadReason where BadReasonCode=@BadReasonCode)
  702. BEGIN
  703. RAISERROR('',16,1);
  704. RETURN
  705. end
  706. INSERT INTO dbo.ICSBadReason
  707. ( ID ,BRGroupID,BadReasonCode ,BadReasonDesc, MTIME,MUSER ,MUSERName ,WorkPoint )
  708. Values(@ID,'{0}',@BadReasonCode,@BadReasonDesc,GETDATE(),'{1}','{2}','{3}')";
  709. sqls = string.Format(sqls, NewID, MUSER, MUSERNAME, WorkPoint);
  710. SqlParameter[] sp_Item = {
  711. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  712. new SqlParameter("@BadReasonCode",DbType.String){ Value= Item.BadReasonCode},
  713. new SqlParameter("@BadReasonDesc",DbType.String){ Value= Item.BadReasonDesc},
  714. };
  715. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  716. }
  717. cmd.Transaction.Commit();
  718. }
  719. }
  720. catch (Exception ex)
  721. {
  722. cmd.Transaction.Rollback();
  723. throw new Exception(ex.Message);
  724. }
  725. finally
  726. {
  727. if (conn.State == ConnectionState.Open)
  728. {
  729. conn.Close();
  730. }
  731. conn.Dispose();
  732. }
  733. }
  734. public DataTable GetICSBadCodeGroupdetil2(string ID)
  735. {
  736. string sql = string.Empty;
  737. DataTable dt = null;
  738. sql = string.Format(@"select * from ICSBadCode where BCGroupID='{0}'", ID);
  739. dt = SqlHelper.GetDataTableBySql(sql);
  740. return dt;
  741. }
  742. public DataTable GetICSBadReason2(string BRGCode)
  743. {
  744. string sql = string.Empty;
  745. DataTable dt = null;
  746. sql = string.Format(@"select * from ICSBadReason where BRGroupID='{0}'", BRGCode);
  747. dt = SqlHelper.GetDataTableBySql(sql);
  748. return dt;
  749. }
  750. public void UpdateICSBadCodeGroup(ICSBadReason main, string BID, string BRGCode, string BRGDesc)
  751. {
  752. string sql = string.Empty;
  753. string sqls = string.Empty;
  754. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  755. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  756. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  757. List<ICSBadReason> list_Item1 = new List<ICSBadReason>();
  758. if (main.arrayShellFabricItem != null)
  759. {
  760. list_Item1 = JsonConvert.DeserializeObject<List<ICSBadReason>>(main.arrayShellFabricItem);
  761. }
  762. string connString = SqlHelper.DataCenterConnString;
  763. SqlConnection conn = new SqlConnection(connString);
  764. conn.Open();
  765. SqlTransaction sqlTran = conn.BeginTransaction();
  766. SqlCommand cmd = new SqlCommand();
  767. cmd.Transaction = sqlTran;
  768. cmd.Connection = conn;
  769. sql = @"UPDATE dbo.ICSBadCodeGroup set BCGCode='{0}',BCGDesc='{1}',MTIME=GETDATE(),MUSER='{2}',MUSERName='{3}',WorkPoint='{4}' WHERE ID='{5}'";
  770. sql = string.Format(sql, BRGCode, BRGDesc, MUSER, MUSERNAME, WorkPoint, BID);
  771. try
  772. {
  773. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  774. {
  775. foreach (ICSBadReason Item in list_Item1)
  776. {
  777. sqls = @" IF NOT EXISTS(SELECT * FROM ICSBadCode WHERE ID=@ID)
  778. BEGIN
  779. INSERT INTO ICSBadCode( ID,BCGroupID,BadCode,BadDesc,MTIME,MUSER,MUSERName,WorkPoint)
  780. VALUES (@ID,'{0}',@BadReasonCode,@BadReasonDesc,getdate(),'{1}','{2}','{3}')
  781. END
  782. ELSE
  783. BEGIN
  784. UPDATE dbo.ICSBadCode set BCGroupID='{0}',BadCode=@BadReasonCode,BadDesc=@BadReasonDesc,MTIME=GETDATE(),MUSER='{1}',MUSERName='{2}',WorkPoint='{3}' WHERE ID=@ID
  785. end
  786. ";
  787. sqls = string.Format(sqls, BID, MUSER, MUSERNAME, WorkPoint);
  788. SqlParameter[] sp_Item = {
  789. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  790. new SqlParameter("@BadReasonCode",DbType.String){ Value= Item.BadReasonCode},
  791. new SqlParameter("@BadReasonDesc",DbType.String){ Value= Item.BadReasonDesc},
  792. };
  793. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  794. }
  795. cmd.Transaction.Commit();
  796. }
  797. }
  798. catch (Exception ex)
  799. {
  800. cmd.Transaction.Rollback();
  801. throw new Exception(ex.Message);
  802. }
  803. finally
  804. {
  805. if (conn.State == ConnectionState.Open)
  806. {
  807. conn.Close();
  808. }
  809. conn.Dispose();
  810. }
  811. }
  812. public void UpdateICSBadReasonGroup(ICSBadReason main, string BID, string BRGCode, string BRGDesc)
  813. {
  814. string sql = string.Empty;
  815. string sqls = string.Empty;
  816. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  817. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  818. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  819. List<ICSBadReason> list_Item1 = new List<ICSBadReason>();
  820. if (main.arrayShellFabricItem != null)
  821. {
  822. list_Item1 = JsonConvert.DeserializeObject<List<ICSBadReason>>(main.arrayShellFabricItem);
  823. }
  824. string connString = SqlHelper.DataCenterConnString;
  825. SqlConnection conn = new SqlConnection(connString);
  826. conn.Open();
  827. SqlTransaction sqlTran = conn.BeginTransaction();
  828. SqlCommand cmd = new SqlCommand();
  829. cmd.Transaction = sqlTran;
  830. cmd.Connection = conn;
  831. sql = @"UPDATE dbo.ICSBadReasonGroup set BRGCode='{0}',BRGDesc='{1}',MTIME=GETDATE(),MUSER='{2}',MUSERName='{3}',WorkPoint='{4}' WHERE ID='{5}'";
  832. sql = string.Format(sql, BRGCode, BRGDesc, MUSER, MUSERNAME, WorkPoint, BID);
  833. try
  834. {
  835. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  836. {
  837. foreach (ICSBadReason Item in list_Item1)
  838. {
  839. sqls = @" IF NOT EXISTS(SELECT * FROM ICSBadReason WHERE ID=@ID)
  840. BEGIN
  841. INSERT INTO ICSBadReason( ID,BRGroupID,BadReasonCode,BadReasonDesc,MTIME,MUSER,MUSERName,WorkPoint)
  842. VALUES (@ID,'{0}',@BadReasonCode,@BadReasonDesc,getdate(),'{1}','{2}','{3}')
  843. END
  844. ELSE
  845. BEGIN
  846. UPDATE dbo.ICSBadReason set BRGroupID='{0}',BadReasonCode=@BadReasonCode,BadReasonDesc=@BadReasonDesc,MTIME=GETDATE(),MUSER='{1}',MUSERName='{2}',WorkPoint='{3}' WHERE ID=@ID
  847. end
  848. ";
  849. sqls = string.Format(sqls, BID, MUSER, MUSERNAME, WorkPoint);
  850. SqlParameter[] sp_Item = {
  851. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  852. new SqlParameter("@BadReasonCode",DbType.String){ Value= Item.BadReasonCode},
  853. new SqlParameter("@BadReasonDesc",DbType.String){ Value= Item.BadReasonDesc},
  854. };
  855. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  856. }
  857. cmd.Transaction.Commit();
  858. }
  859. }
  860. catch (Exception ex)
  861. {
  862. cmd.Transaction.Rollback();
  863. throw new Exception(ex.Message);
  864. }
  865. finally
  866. {
  867. if (conn.State == ConnectionState.Open)
  868. {
  869. conn.Close();
  870. }
  871. conn.Dispose();
  872. }
  873. }
  874. /// <summary>
  875. /// 删除不良代码组
  876. /// </summary>
  877. /// <param name="keyValue">传入ID</param>
  878. /// <returns></returns>
  879. public string DeleteICSBadCodeGroup(string keyValue)
  880. {
  881. //站点信息
  882. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  883. string msg = "";
  884. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  885. string sql = string.Empty;
  886. sql += string.Format(@"DELETE FROM dbo.ICSBadCodeGroup WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  887. sql += string.Format(@"DELETE FROM dbo.ICSBadCode WHERE BCGroupID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  888. try
  889. {
  890. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  891. {
  892. }
  893. }
  894. catch (Exception ex)
  895. {
  896. throw new Exception(ex.Message);
  897. }
  898. return msg;
  899. }
  900. /// <summary>
  901. /// 删除不良原因组
  902. /// </summary>
  903. /// <param name="keyValue">传入ID</param>
  904. /// <returns></returns>
  905. public string DeleteICSBadReasonGroup(string keyValue)
  906. {
  907. //站点信息
  908. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  909. string msg = "";
  910. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  911. string sql = string.Empty;
  912. sql += string.Format(@"DELETE FROM dbo.ICSBadReasonGroup WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  913. sql += string.Format(@"DELETE FROM dbo.ICSBadReason WHERE BRGroupID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  914. try
  915. {
  916. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  917. {
  918. }
  919. }
  920. catch (Exception ex)
  921. {
  922. throw new Exception(ex.Message);
  923. }
  924. return msg;
  925. }
  926. /// <summary>
  927. /// 初次加载查询检验项目组
  928. /// </summary>
  929. /// <param name="jqgridparam"></param>
  930. /// <returns></returns>
  931. public DataTable GetICSInspectionGroup(ref Pagination jqgridparam, string queryJson)
  932. {
  933. DataTable dt = new DataTable();
  934. var queryParam = queryJson.ToJObject();
  935. List<DbParameter> parameter = new List<DbParameter>();
  936. string sql = @"select ID,GroupCode,GroupName,Enable,MUSER,MUSERName,MTIME from ICSInspectionGroup ";
  937. sql += " WHERE 1=1";
  938. if (!string.IsNullOrWhiteSpace(queryJson))
  939. {
  940. if (!string.IsNullOrWhiteSpace(queryParam["ListCode"].ToString()))
  941. {
  942. sql += " and GroupCode like '%" + queryParam["ListCode"].ToString() + "%' ";
  943. }
  944. if (!string.IsNullOrWhiteSpace(queryParam["ListName"].ToString()))
  945. {
  946. sql += " and GroupName like '%" + queryParam["ListName"].ToString() + "%' ";
  947. }
  948. }
  949. sql = string.Format(sql);
  950. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  951. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  952. }
  953. /// <summary>
  954. /// 检验项目子表查询
  955. /// </summary>
  956. /// <param name="queryJson"></param>
  957. /// <param name="jqgridparam"></param>
  958. /// <returns></returns>
  959. public DataTable ICSInspectionList(string GroupCode, ref Pagination jqgridparam)
  960. {
  961. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  962. DataTable dt = new DataTable();
  963. //var queryParam = queryJson.ToJObject();
  964. List<DbParameter> parameter = new List<DbParameter>();
  965. string sql = @"select GroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable,MUSERName,MTIME from ICSInspectionList
  966. WHERE GroupID='" + GroupCode + "' ";
  967. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  968. }
  969. /// <summary>
  970. /// 根据id删除自动表
  971. /// </summary>
  972. /// <param name="ID"></param>
  973. public void DeleteList(string ID)
  974. {
  975. string sql = "DELETE FROM dbo.ICSInspectionList WHERE ID='" + ID + "'";
  976. SqlHelper.ExecuteNonQuery(sql);
  977. }
  978. /// <summary>
  979. /// 检查项目组修改
  980. /// </summary>
  981. /// <param name="main"></param>
  982. /// <param name="BID"></param>
  983. /// <param name="GroupCode"></param>
  984. /// <param name="GroupName"></param>
  985. /// <param name="Enable"></param>
  986. public void UpdateICSInspectionGroup(ICSInspectionList main, string BID, string GroupCode, string GroupName, string Enable)
  987. {
  988. string sql = string.Empty;
  989. string sqls = string.Empty;
  990. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  991. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  992. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  993. List<ICSInspectionList> list_Item1 = new List<ICSInspectionList>();
  994. if (main.arrayShellFabricItem != null)
  995. {
  996. list_Item1 = JsonConvert.DeserializeObject<List<ICSInspectionList>>(main.arrayShellFabricItem);
  997. }
  998. string connString = SqlHelper.DataCenterConnString;
  999. SqlConnection conn = new SqlConnection(connString);
  1000. conn.Open();
  1001. SqlTransaction sqlTran = conn.BeginTransaction();
  1002. SqlCommand cmd = new SqlCommand();
  1003. cmd.Transaction = sqlTran;
  1004. cmd.Connection = conn;
  1005. sql = @"UPDATE dbo.ICSInspectionGroup set GroupCode='{0}',GroupName='{1}',Enable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
  1006. sql = string.Format(sql, GroupCode, GroupName, Enable, MUSER, MUSERNAME, WorkPoint, BID);
  1007. try
  1008. {
  1009. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1010. {
  1011. foreach (ICSInspectionList Item in list_Item1)
  1012. {
  1013. sqls = @" IF NOT EXISTS(SELECT * FROM ICSInspectionList WHERE ID=@ID)
  1014. BEGIN
  1015. INSERT INTO ICSInspectionList( ID,GroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable,MTIME,MUSER,MUSERName,WorkPoint)
  1016. VALUES (@ID,'{0}',@ListCode,@ListName,@Unit,@SetValueMax,@SetValueMin,@Enable,getdate(),'{1}','{2}','{3}')
  1017. END
  1018. ELSE
  1019. BEGIN
  1020. 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
  1021. end
  1022. ";
  1023. sqls = string.Format(sqls, GroupCode, MUSER, MUSERNAME, WorkPoint);
  1024. SqlParameter[] sp_Item = {
  1025. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  1026. new SqlParameter("@ListCode",DbType.String){ Value= Item.ListCode},
  1027. new SqlParameter("@ListName",DbType.String){ Value= Item.ListName},
  1028. new SqlParameter("@Unit",DbType.String){ Value= Item.Unit},
  1029. new SqlParameter("@SetValueMax",DbType.String){ Value= Item.SetValueMax},
  1030. new SqlParameter("@SetValueMin",DbType.String){ Value= Item.SetValueMin},
  1031. new SqlParameter("@Enable",DbType.String){ Value= Item.Enable},
  1032. };
  1033. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  1034. }
  1035. cmd.Transaction.Commit();
  1036. }
  1037. }
  1038. catch (Exception ex)
  1039. {
  1040. cmd.Transaction.Rollback();
  1041. throw new Exception(ex.Message);
  1042. }
  1043. finally
  1044. {
  1045. if (conn.State == ConnectionState.Open)
  1046. {
  1047. conn.Close();
  1048. }
  1049. conn.Dispose();
  1050. }
  1051. }
  1052. /// <summary>
  1053. /// 检查项目组新增
  1054. /// </summary>
  1055. /// <param name="main"></param>
  1056. /// <param name="BRGCode"></param>
  1057. /// <param name="BRGDesc"></param>
  1058. public void ICSInspectionGroupAdd(ICSInspectionList main, string GroupCode, string GroupName, string Enable)
  1059. {
  1060. string sql = string.Empty;
  1061. string sqls = string.Empty;
  1062. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1063. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1064. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1065. List<ICSInspectionList> list_Item1 = new List<ICSInspectionList>();
  1066. if (main.arrayShellFabricItem != null)
  1067. {
  1068. list_Item1 = JsonConvert.DeserializeObject<List<ICSInspectionList>>(main.arrayShellFabricItem);
  1069. }
  1070. string connString = SqlHelper.DataCenterConnString;
  1071. SqlConnection conn = new SqlConnection(connString);
  1072. conn.Open();
  1073. SqlTransaction sqlTran = conn.BeginTransaction();
  1074. SqlCommand cmd = new SqlCommand();
  1075. cmd.Transaction = sqlTran;
  1076. cmd.Connection = conn;
  1077. sql = @"
  1078. IF EXISTS(select GroupCode from ICSInspectionGroup where GroupCode='{0}')
  1079. BEGIN
  1080. RAISERROR('',16,1);
  1081. RETURN
  1082. end
  1083. INSERT INTO dbo.ICSInspectionGroup
  1084. ( ID ,GroupCode ,GroupName,Enable, MTIME,MUSER ,MUSERName ,WorkPoint )
  1085. Values(NEWID(),'{0}','{1}','{2}',GETDATE(),'{3}','{4}','{5}')";
  1086. sql = string.Format(sql, GroupCode, GroupName, Enable, MUSER, MUSERNAME, WorkPoint);
  1087. try
  1088. {
  1089. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1090. {
  1091. foreach (ICSInspectionList Item in list_Item1)
  1092. {
  1093. sqls = @"
  1094. IF EXISTS(select ListCode from ICSInspectionList where ListCode=@ListCode)
  1095. BEGIN
  1096. RAISERROR('',16,1);
  1097. RETURN
  1098. end
  1099. INSERT INTO dbo.ICSInspectionList
  1100. ( ID ,GroupID,ListCode ,ListName, Unit,SetValueMax ,SetValueMin,Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
  1101. Values(@ID,'{0}',@ListCode,@ListName,@Unit,@SetValueMax,@SetValueMin,@Enable,getdate(),'{1}','{2}','{3}')";
  1102. sqls = string.Format(sqls, GroupCode, MUSER, MUSERNAME, WorkPoint);
  1103. SqlParameter[] sp_Item = {
  1104. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  1105. new SqlParameter("@ListCode",DbType.String){ Value= Item.ListCode},
  1106. new SqlParameter("@ListName",DbType.String){ Value= Item.ListName},
  1107. new SqlParameter("@Unit",DbType.String){ Value= Item.Unit},
  1108. new SqlParameter("@SetValueMax",DbType.String){ Value= Item.SetValueMax},
  1109. new SqlParameter("@SetValueMin",DbType.String){ Value= Item.SetValueMin},
  1110. new SqlParameter("@Enable",DbType.String){ Value= Item.Enable},
  1111. };
  1112. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  1113. }
  1114. cmd.Transaction.Commit();
  1115. }
  1116. }
  1117. catch (Exception ex)
  1118. {
  1119. cmd.Transaction.Rollback();
  1120. throw new Exception(ex.Message);
  1121. }
  1122. finally
  1123. {
  1124. if (conn.State == ConnectionState.Open)
  1125. {
  1126. conn.Close();
  1127. }
  1128. conn.Dispose();
  1129. }
  1130. }
  1131. /// <summary>
  1132. /// 动态子表修改加载页面
  1133. /// </summary>
  1134. /// <param name="GroupCode"></param>
  1135. /// <returns></returns>
  1136. public DataTable ICSInspectionList2(string GroupCode)
  1137. {
  1138. string sql = string.Empty;
  1139. DataTable dt = null;
  1140. sql = string.Format(@"SELECT ID,GroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,
  1141. case when Enable='1' then '是' else '否' end as Enable,
  1142. MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1 FROM
  1143. dbo.ICSInspectionList where GroupID='{0}'", GroupCode);
  1144. dt = SqlHelper.GetDataTableBySql(sql);
  1145. return dt;
  1146. }
  1147. /// <summary>
  1148. /// 删除不良原因组
  1149. /// </summary>
  1150. /// <param name="keyValue">传入ID</param>
  1151. /// <returns></returns>
  1152. public string DeleteICSInspectionGroup(string keyValue)
  1153. {
  1154. //站点信息
  1155. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1156. string msg = "";
  1157. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1158. string sql = string.Empty;
  1159. string sqls = string.Empty;
  1160. sql = string.Format(@"DELETE FROM dbo.ICSInspectionGroup WHERE GroupCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1161. try
  1162. {
  1163. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1164. {
  1165. sqls = string.Format(@"DELETE FROM dbo.ICSInspectionList WHERE GroupID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1166. SqlHelper.ExecuteNonQuery(sqls);
  1167. }
  1168. }
  1169. catch (Exception ex)
  1170. {
  1171. throw new Exception(ex.Message);
  1172. }
  1173. return msg;
  1174. }
  1175. /// <summary>
  1176. /// 新增料品属性
  1177. /// </summary>
  1178. /// <param name="queryJson"></param>
  1179. /// <returns></returns>
  1180. public string InsertICSInventory(string keyValue)
  1181. {
  1182. var queryParam = keyValue.ToJObject();
  1183. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1184. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1185. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1186. string msg = "";
  1187. string sql = string.Empty;
  1188. sql = @"INSERT INTO dbo.ICSInventory
  1189. ( ID ,InvCode ,InvName ,InvDesc,InvStd,InvUnit,AmountUnit ,ClassCode ,ClassName ,InvRate,InvVersion,InvBrand,InvIQC ,InvFQC ,EffectiveEnable,EffectiveDays,BatchEnable,LotEnable ,PrintEnable ,WHUser,MTIME,MUSER ,MUSERName ,WorkPoint )
  1190. 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}')
  1191. ";
  1192. sql = string.Format(sql,
  1193. queryParam["InvCode"].ToString(),
  1194. queryParam["InvName"].ToString(),
  1195. queryParam["InvDesc"].ToString(),
  1196. queryParam["InvStd"].ToString(),
  1197. queryParam["InvUnit"].ToString(),
  1198. queryParam["AmountUnit"].ToString(),
  1199. queryParam["ClassCode"].ToString(),
  1200. queryParam["ClassName"].ToString(),
  1201. queryParam["InvRate"].ToString(),
  1202. queryParam["InvVersion"].ToString(),
  1203. queryParam["InvBrand"].ToString(),
  1204. queryParam["InvIQC"].ToString(),
  1205. queryParam["InvFQC"].ToString(),
  1206. queryParam["EffectiveEnable"].ToString(),
  1207. queryParam["EffectiveDays"].ToString(),
  1208. queryParam["BatchEnable"].ToString(),
  1209. queryParam["LotEnable"].ToString(),
  1210. queryParam["PrintEnable"].ToString(),
  1211. queryParam["WHUser"].ToString(),
  1212. MUSER, MUSERNAME, WorkPoint);
  1213. try
  1214. {
  1215. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1216. {
  1217. }
  1218. else
  1219. {
  1220. msg = "新增失败";
  1221. }
  1222. }
  1223. catch (Exception ex)
  1224. {
  1225. throw new Exception(ex.Message);
  1226. }
  1227. return msg;
  1228. }
  1229. /// <summary>
  1230. /// 修改料品属性
  1231. /// </summary>
  1232. /// <param name="queryJson"></param>
  1233. /// <returns></returns>
  1234. public string UpdateICSInventory(string keyValue)
  1235. {
  1236. var queryParam = keyValue.ToJObject();
  1237. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1238. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1239. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1240. string msg = "";
  1241. string sql = string.Empty;
  1242. sql = @"UPDATE dbo.ICSInventory set
  1243. InvCode='{0}'
  1244. ,InvName='{1}'
  1245. ,InvDesc='{2}'
  1246. ,InvStd='{3}'
  1247. ,InvUnit='{4}'
  1248. ,AmountUnit='{5}'
  1249. ,ClassCode='{6}'
  1250. ,ClassName='{7}'
  1251. ,InvRate='{8}'
  1252. ,InvVersion='{9}'
  1253. ,InvBrand='{10}'
  1254. ,InvIQC='{11}'
  1255. ,InvFQC='{12}'
  1256. ,EffectiveEnable='{13}'
  1257. ,EffectiveDays='{14}'
  1258. ,BatchEnable='{15}'
  1259. ,LotEnable='{16}'
  1260. ,PrintEnable='{17}'
  1261. ,WHUser='{18}'
  1262. ,MTIME=GETDATE()
  1263. ,MUSER='{19}'
  1264. ,MUSERName='{20}'
  1265. ,WorkPoint='{21}'
  1266. WHERE ID='{22}'";
  1267. sql = string.Format(sql,
  1268. queryParam["InvCode"].ToString(),
  1269. queryParam["InvName"].ToString(),
  1270. queryParam["InvDesc"].ToString(),
  1271. queryParam["InvStd"].ToString(),
  1272. queryParam["InvUnit"].ToString(),
  1273. queryParam["AmountUnit"].ToString(),
  1274. queryParam["ClassCode"].ToString(),
  1275. queryParam["ClassName"].ToString(),
  1276. queryParam["InvRate"].ToString(),
  1277. queryParam["InvVersion"].ToString(),
  1278. queryParam["InvBrand"].ToString(),
  1279. queryParam["InvIQC"].ToString(),
  1280. queryParam["InvFQC"].ToString(),
  1281. queryParam["EffectiveEnable"].ToString(),
  1282. queryParam["EffectiveDays"].ToString(),
  1283. queryParam["BatchEnable"].ToString(),
  1284. queryParam["LotEnable"].ToString(),
  1285. queryParam["PrintEnable"].ToString(),
  1286. queryParam["WHUser"].ToString(),
  1287. MUSER, MUSERNAME, WorkPoint,
  1288. queryParam["ID"].ToString());
  1289. try
  1290. {
  1291. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1292. {
  1293. }
  1294. else
  1295. {
  1296. msg = "修改失败";
  1297. }
  1298. }
  1299. catch (Exception ex)
  1300. {
  1301. throw new Exception(ex.Message);
  1302. }
  1303. return msg;
  1304. }
  1305. /// <summary>
  1306. /// 获取下拉料品号获取其他信息
  1307. /// </summary>
  1308. public DataTable GetInputValue(string ID)
  1309. {
  1310. try
  1311. {
  1312. DataTable dt = new DataTable();
  1313. //var queryParam = queryJson.ToJObject();
  1314. List<DbParameter> parameter = new List<DbParameter>();
  1315. string sql = @"select InvCode,InvName,InvDesc,InvStd,InvUnit,AmountUnit, ClassCode,ClassName,InvRate,InvVersion,InvBrand,InvIQC,
  1316. InvFQC,EffectiveEnable,EffectiveDays,BatchEnable,LotEnable,PrintEnable,WHUser
  1317. from ICSInventory
  1318. WHERE 1=1 AND ID='{0}' ";
  1319. sql = string.Format(sql, ID);
  1320. return Repository().FindTableBySql(sql.ToString());
  1321. }
  1322. catch (Exception ex)
  1323. {
  1324. throw new Exception(ex.Message.ToString());
  1325. }
  1326. }
  1327. /// <summary>
  1328. /// 删除料品属性
  1329. /// </summary>
  1330. /// <param name="keyValue">传入ID</param>
  1331. /// <returns></returns>
  1332. public string DeleteICSInventory(string keyValue)
  1333. {
  1334. //站点信息
  1335. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1336. string msg = "";
  1337. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1338. string sql = string.Empty;
  1339. sql = string.Format(@"DELETE FROM dbo.ICSInventory WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1340. try
  1341. {
  1342. SqlHelper.ExecuteNonQuery(sql);
  1343. }
  1344. catch (Exception ex)
  1345. {
  1346. throw new Exception(ex.Message);
  1347. }
  1348. return msg;
  1349. }
  1350. /// <summary>
  1351. /// 获取料品信息
  1352. /// </summary>
  1353. /// <param name="jqgridparam"></param>
  1354. /// <returns></returns>
  1355. public DataTable GetICSInventoryInfo(string queryJson, ref Pagination jqgridparam)
  1356. {
  1357. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1358. DataTable dt = new DataTable();
  1359. var queryParam = queryJson.ToJObject();
  1360. List<DbParameter> parameter = new List<DbParameter>();
  1361. string sql = @"select ID, InvCode,InvName,InvDesc,InvStd,InvUnit,AmountUnit,ClassCode,ClassName,InvRate,InvVersion,InvBrand,
  1362. InvIQC,InvFQC,EffectiveEnable,EffectiveDays,BatchEnable,LotEnable,PrintEnable,WHUser
  1363. from ICSInventory where WorkPoint='{0}' ";
  1364. sql = string.Format(sql, WorkPoint);
  1365. if (!string.IsNullOrWhiteSpace(queryJson))
  1366. {
  1367. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1368. {
  1369. sql += " and InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1370. }
  1371. }
  1372. // DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1373. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1374. }
  1375. /// <summary>
  1376. /// 获取仓库信息
  1377. /// </summary>
  1378. /// <param name="jqgridparam"></param>
  1379. /// <returns></returns>
  1380. public DataTable GetICSWarehouseInfo(string queryJson, ref Pagination jqgridparam)
  1381. {
  1382. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1383. DataTable dt = new DataTable();
  1384. var queryParam = queryJson.ToJObject();
  1385. List<DbParameter> parameter = new List<DbParameter>();
  1386. string sql = @"select ID,WarehouseCode,WarehouseName ,Enable,BatchEnable,Asset,Proxy,InCost from ICSWarehouse where WorkPoint='{0}' ";
  1387. sql = string.Format(sql, WorkPoint);
  1388. if (!string.IsNullOrWhiteSpace(queryJson))
  1389. {
  1390. if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString()))
  1391. {
  1392. sql += " and WarehouseCode like '%" + queryParam["WHCode"].ToString() + "%' ";
  1393. }
  1394. }
  1395. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1396. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1397. }
  1398. /// <summary>
  1399. /// 新增料品仓库批次关系
  1400. /// </summary>
  1401. /// <param name="queryJson"></param>
  1402. /// <returns></returns>
  1403. public string InsertICSInventoryBatchEnable(string keyValue, string keyValue2)
  1404. {
  1405. List<string> InvCodeList = keyValue.Substring(1, keyValue.Length - 3).Split(',').ToList<string>();
  1406. List<string> WarehouseCodeList = keyValue2.Substring(1, keyValue2.Length - 3).Split(',').ToList<string>();
  1407. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1408. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1409. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1410. string msg = "";
  1411. string sql = string.Empty;
  1412. foreach (var item in InvCodeList)
  1413. {
  1414. foreach (var itemwh in WarehouseCodeList)
  1415. {
  1416. sql += @"IF EXISTS(select InvCode,WHCode from ICSInventoryBatchEnable where InvCode={0} and WHCode={1})
  1417. BEGIN
  1418. RAISERROR('',16,1);
  1419. RETURN
  1420. end
  1421. INSERT INTO dbo.ICSInventoryBatchEnable
  1422. ( ID ,InvCode ,WHCode ,BatchEnable,MTIME,MUSER ,MUSERName ,WorkPoint )
  1423. Values(NEWID(),{0},{1},'{2}',GETDATE(),'{3}','{4}','{5}')
  1424. ";
  1425. sql = string.Format(sql, item, itemwh, '1'.ToString(), MUSER, MUSERNAME, WorkPoint);
  1426. }
  1427. }
  1428. try
  1429. {
  1430. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1431. {
  1432. }
  1433. else
  1434. {
  1435. msg = "新增失败";
  1436. }
  1437. }
  1438. catch (Exception ex)
  1439. {
  1440. msg=ex.Message;
  1441. }
  1442. return msg;
  1443. }
  1444. /// <summary>
  1445. /// 修改料品仓库批次关系
  1446. /// </summary>
  1447. /// <param name="queryJson"></param>
  1448. /// <returns></returns>
  1449. public string UpdateICSInventoryBatchEnable(string keyValue)
  1450. {
  1451. var queryParam = keyValue.ToJObject();
  1452. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1453. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1454. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1455. string msg = "";
  1456. string sql = string.Empty;
  1457. sql = @"UPDATE dbo.ICSInventoryBatchEnable set InvCode='{0}',WHCode='{1}',BatchEnable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
  1458. sql = string.Format(sql, queryParam["InvCode"].ToString(), queryParam["WHCode"].ToString(), queryParam["BatchEnable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  1459. try
  1460. {
  1461. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1462. {
  1463. }
  1464. else
  1465. {
  1466. msg = "修改失败";
  1467. }
  1468. }
  1469. catch (Exception ex)
  1470. {
  1471. throw new Exception(ex.Message);
  1472. }
  1473. return msg;
  1474. }
  1475. /// <summary>
  1476. /// 删除料品仓库批次关系
  1477. /// </summary>
  1478. /// <param name="keyValue">传入ID</param>
  1479. /// <returns></returns>
  1480. public string DeleteICSInventoryBatchEnable(string keyValue)
  1481. {
  1482. //站点信息
  1483. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1484. string msg = "";
  1485. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1486. string sql = string.Empty;
  1487. sql = string.Format(@"DELETE FROM dbo.ICSInventoryBatchEnable WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1488. try
  1489. {
  1490. SqlHelper.ExecuteNonQuery(sql);
  1491. }
  1492. catch (Exception ex)
  1493. {
  1494. throw new Exception(ex.Message);
  1495. }
  1496. return msg;
  1497. }
  1498. /// <summary>
  1499. /// 获取库位信息
  1500. /// </summary>
  1501. /// <param name="jqgridparam"></param>
  1502. /// <returns></returns>
  1503. public DataTable GetICSLocation(string queryJson, ref Pagination jqgridparam)
  1504. {
  1505. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1506. DataTable dt = new DataTable();
  1507. var queryParam = queryJson.ToJObject();
  1508. List<DbParameter> parameter = new List<DbParameter>();
  1509. string sql = @"select ID,LocationCode,LocationName,WHID,MUSER,MUSERName,MTIME,WorkPoint from ICSLocation where WorkPoint='{0}' ";
  1510. sql = string.Format(sql, WorkPoint);
  1511. if (!string.IsNullOrWhiteSpace(queryJson))
  1512. {
  1513. if (!string.IsNullOrWhiteSpace(queryParam["LocationCode"].ToString()))
  1514. {
  1515. sql += " and LocationCode like '%" + queryParam["LocationCode"].ToString() + "%' ";
  1516. }
  1517. }
  1518. //DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1519. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1520. }
  1521. /// <summary>
  1522. /// 新增料品仓库批次关系
  1523. /// </summary>
  1524. /// <param name="queryJson"></param>
  1525. /// <returns></returns>
  1526. public string InsertICSInventoryLocation(string keyValue, string keyValue2)
  1527. {
  1528. List<string> InvCodeList = keyValue.Substring(1, keyValue.Length - 3).Split(',').ToList<string>();
  1529. List<string> LocationCodeList = keyValue2.Substring(1, keyValue2.Length - 3).Split(',').ToList<string>();
  1530. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1531. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1532. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1533. string msg = "";
  1534. string sql = string.Empty;
  1535. try
  1536. {
  1537. foreach (var item in InvCodeList)
  1538. {
  1539. foreach (var itemwh in LocationCodeList)
  1540. {
  1541. sql += @"IF EXISTS(select InvCode,LocationCode from ICSInventoryLocation where InvCode={0} and LocationCode={1})
  1542. BEGIN
  1543. RAISERROR('',16,1);
  1544. RETURN
  1545. end
  1546. INSERT INTO dbo.ICSInventoryLocation
  1547. ( ID ,InvCode ,LocationCode ,Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
  1548. Values(NEWID(),{0},{1},'{2}',GETDATE(),'{3}','{4}','{5}')
  1549. ";
  1550. sql = string.Format(sql, item, itemwh, '1'.ToString(), MUSER, MUSERNAME, WorkPoint);
  1551. }
  1552. }
  1553. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1554. {
  1555. }
  1556. else
  1557. {
  1558. msg = "新增失败";
  1559. }
  1560. }
  1561. catch (Exception ex)
  1562. {
  1563. msg=ex.Message;
  1564. }
  1565. return msg;
  1566. }
  1567. /// <summary>
  1568. /// 修改料品库位绑定关系
  1569. /// </summary>
  1570. /// <param name="queryJson"></param>
  1571. /// <returns></returns>
  1572. public string UpdateICSInventoryLocation(string keyValue)
  1573. {
  1574. var queryParam = keyValue.ToJObject();
  1575. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1576. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1577. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1578. string msg = "";
  1579. string sql = string.Empty;
  1580. sql = @"UPDATE dbo.ICSInventoryLocation set InvCode='{0}',LocationCode='{1}',Enable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
  1581. sql = string.Format(sql, queryParam["InvCode"].ToString(), queryParam["LocationCode"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  1582. try
  1583. {
  1584. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1585. {
  1586. }
  1587. else
  1588. {
  1589. msg = "修改失败";
  1590. }
  1591. }
  1592. catch (Exception ex)
  1593. {
  1594. throw new Exception(ex.Message);
  1595. }
  1596. return msg;
  1597. }
  1598. /// <summary>
  1599. /// 删除料品仓库批次关系
  1600. /// </summary>
  1601. /// <param name="keyValue">传入ID</param>
  1602. /// <returns></returns>
  1603. public string DeleteICSInventoryLocation(string keyValue)
  1604. {
  1605. //站点信息
  1606. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1607. string msg = "";
  1608. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1609. string sql = string.Empty;
  1610. sql = string.Format(@"DELETE FROM dbo.ICSInventoryLocation WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1611. try
  1612. {
  1613. SqlHelper.ExecuteNonQuery(sql);
  1614. }
  1615. catch (Exception ex)
  1616. {
  1617. throw new Exception(ex.Message);
  1618. }
  1619. return msg;
  1620. }
  1621. /// <summary>
  1622. /// 新增包装、容器
  1623. /// </summary>
  1624. /// <param name="queryJson"></param>
  1625. /// <returns></returns>
  1626. public string InsertICSContainer(string keyValue)
  1627. {
  1628. string msg = "";
  1629. try
  1630. {
  1631. var queryParam = keyValue.ToJObject();
  1632. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1633. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1634. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1635. string sql = string.Empty;
  1636. sql = @"IF EXISTS(select ContainerCODE from ICSContainer where ContainerCODE='{1}' )
  1637. RAISERROR('{1}',16,1)
  1638. else
  1639. INSERT INTO dbo.ICSContainer
  1640. ( ID ,ContainerID ,ContainerCODE ,ContainerName,Memo,MTIME,MUSER ,MUSERName ,WorkPoint )
  1641. Values(NEWID(),'{0}','{1}','{2}','{3}',GETDATE(),'{4}','{5}','{6}')
  1642. ";
  1643. sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["ContainerCODE"].ToString(), queryParam["ContainerName"].ToString(), queryParam["Memo"].ToString(), MUSER, MUSERNAME, WorkPoint);
  1644. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1645. {
  1646. }
  1647. else
  1648. {
  1649. msg = "新增失败";
  1650. }
  1651. }
  1652. catch (Exception ex)
  1653. {
  1654. throw new Exception(ex.Message);
  1655. }
  1656. return msg;
  1657. }
  1658. /// <summary>
  1659. /// 修改包装、容器
  1660. /// </summary>
  1661. /// <param name="queryJson"></param>
  1662. /// <returns></returns>
  1663. public string UpdateICSContainer(string keyValue)
  1664. {
  1665. var queryParam = keyValue.ToJObject();
  1666. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1667. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1668. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1669. string msg = "";
  1670. string sql = string.Empty;
  1671. sql = @"UPDATE dbo.ICSContainer set ContainerID='{0}',ContainerCODE='{1}',ContainerName='{2}',Memo='{3}',MTIME=GETDATE(),MUSER='{4}',MUSERName='{5}',WorkPoint='{6}' WHERE ID='{7}'";
  1672. sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["ContainerCODE"].ToString(), queryParam["ContainerName"].ToString(), queryParam["Memo"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  1673. try
  1674. {
  1675. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1676. {
  1677. }
  1678. else
  1679. {
  1680. msg = "修改失败";
  1681. }
  1682. }
  1683. catch (Exception ex)
  1684. {
  1685. throw new Exception(ex.Message);
  1686. }
  1687. return msg;
  1688. }
  1689. /// <summary>
  1690. /// 删除包装、容器
  1691. /// </summary>
  1692. /// <param name="keyValue">传入ID</param>
  1693. /// <returns></returns>
  1694. public string DeleteICSContainer(string keyValue)
  1695. {
  1696. //站点信息
  1697. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1698. string msg = "";
  1699. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1700. string sql = string.Empty;
  1701. sql = string.Format(@"DELETE FROM dbo.ICSContainer WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1702. try
  1703. {
  1704. SqlHelper.ExecuteNonQuery(sql);
  1705. }
  1706. catch (Exception ex)
  1707. {
  1708. throw new Exception(ex.Message);
  1709. }
  1710. return msg;
  1711. }
  1712. /// <summary>
  1713. /// 新增包装、容器关联条码
  1714. /// </summary>
  1715. /// <param name="queryJson"></param>
  1716. /// <returns></returns>
  1717. public string InsertICSContainerLot(string keyValue)
  1718. {
  1719. var queryParam = keyValue.ToJObject();
  1720. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1721. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1722. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1723. string msg = "";
  1724. string sql = string.Empty;
  1725. sql = @"INSERT INTO dbo.ICSContainerLot
  1726. ( ID ,ContainerID ,LotNo ,MTIME,MUSER ,MUSERName ,WorkPoint )
  1727. Values(NEWID(),'{0}','{1}',getdate(),'{2}','{3}','{4}')
  1728. ";
  1729. sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["LotNo"].ToString(), MUSER, MUSERNAME, WorkPoint);
  1730. try
  1731. {
  1732. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1733. {
  1734. }
  1735. else
  1736. {
  1737. msg = "新增失败";
  1738. }
  1739. }
  1740. catch (Exception ex)
  1741. {
  1742. throw new Exception(ex.Message);
  1743. }
  1744. return msg;
  1745. }
  1746. /// <summary>
  1747. /// 修改包装、容器
  1748. /// </summary>
  1749. /// <param name="queryJson"></param>
  1750. /// <returns></returns>
  1751. public string UpdateICSContainerLot(string keyValue)
  1752. {
  1753. var queryParam = keyValue.ToJObject();
  1754. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1755. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1756. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1757. string msg = "";
  1758. string sql = string.Empty;
  1759. sql = @"UPDATE dbo.ICSContainerLot set ContainerID='{0}',LotNo='{1}',MTIME=GETDATE(),MUSER='{2}',MUSERName='{3}',WorkPoint='{4}' WHERE ID='{5}'";
  1760. sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["LotNo"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  1761. try
  1762. {
  1763. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1764. {
  1765. }
  1766. else
  1767. {
  1768. msg = "修改失败";
  1769. }
  1770. }
  1771. catch (Exception ex)
  1772. {
  1773. throw new Exception(ex.Message);
  1774. }
  1775. return msg;
  1776. }
  1777. /// <summary>
  1778. /// 删除包装、容器
  1779. /// </summary>
  1780. /// <param name="keyValue">传入ID</param>
  1781. /// <returns></returns>
  1782. public string DeleteICSContainerLot(string keyValue)
  1783. {
  1784. //站点信息
  1785. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1786. string msg = "";
  1787. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1788. string sql = string.Empty;
  1789. sql = string.Format(@"DELETE FROM dbo.ICSContainerLot WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1790. try
  1791. {
  1792. SqlHelper.ExecuteNonQuery(sql);
  1793. }
  1794. catch (Exception ex)
  1795. {
  1796. throw new Exception(ex.Message);
  1797. }
  1798. return msg;
  1799. }
  1800. /// <summary>
  1801. /// 获取料品信息
  1802. /// </summary>
  1803. /// <returns></returns>
  1804. public DataTable GetInvCode()
  1805. {
  1806. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1807. string sql = @"
  1808. select '' as InvCode,'' as InvName
  1809. union all
  1810. SELECT InvCode,InvName FROM ICSInventory WITH (NOLOCK) WHERE 1=1 ";
  1811. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  1812. if (role != "admin")
  1813. {
  1814. sql += " and b.WorkPoint='" + WorkPoint + "'";
  1815. }
  1816. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  1817. return dt;
  1818. }
  1819. /// <summary>
  1820. /// 获取不良代码信息
  1821. /// </summary>
  1822. /// <returns></returns>
  1823. public DataTable GetBCGroup()
  1824. {
  1825. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1826. string sql = @"select '' as ID,'' as BCGDesc
  1827. union all
  1828. SELECT ID,BCGDesc FROM ICSBadCodeGroup WITH (NOLOCK) WHERE 1=1 ";
  1829. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  1830. if (role != "admin")
  1831. {
  1832. sql += " and b.WorkPoint='" + WorkPoint + "'";
  1833. }
  1834. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  1835. return dt;
  1836. }
  1837. /// <summary>
  1838. /// 获取不良原因信息
  1839. /// </summary>
  1840. /// <returns></returns>
  1841. public DataTable BRGroupID()
  1842. {
  1843. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1844. string sql = @"select '' as ID,'' as BRGDesc
  1845. union all
  1846. SELECT ID,BRGDesc FROM ICSBadReasonGroup WITH (NOLOCK) WHERE 1=1 ";
  1847. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  1848. if (role != "admin")
  1849. {
  1850. sql += " and b.WorkPoint='" + WorkPoint + "'";
  1851. }
  1852. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  1853. return dt;
  1854. }
  1855. /// <summary>
  1856. /// 新增料品不良信息
  1857. /// </summary>
  1858. /// <param name="queryJson"></param>
  1859. /// <returns></returns>
  1860. public string InsertInventoryBadGroup(string keyValue)
  1861. {
  1862. var queryParam = keyValue.ToJObject();
  1863. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1864. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1865. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1866. string msg = "";
  1867. string sql = string.Empty;
  1868. sql = @"INSERT INTO dbo.ICSInventoryBadGroup
  1869. ( ID,InvCode,BCGroupID,BRGroupID,Enable,MUSER,MUSERName,MTIME,WorkPoint)
  1870. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}',getdate(),'{6}')";
  1871. sql = string.Format(sql, queryParam["InvCode"].ToString(), queryParam["BCGroupID"].ToString(), queryParam["BRGroupID"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint);
  1872. try
  1873. {
  1874. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1875. {
  1876. }
  1877. else
  1878. {
  1879. msg = "新增失败";
  1880. }
  1881. }
  1882. catch (Exception ex)
  1883. {
  1884. throw new Exception(ex.Message);
  1885. }
  1886. return msg;
  1887. }
  1888. /// <summary>
  1889. /// 修改料品不良信息
  1890. /// </summary>
  1891. /// <param name="queryJson"></param>
  1892. /// <returns></returns>
  1893. public string UpdateInventoryBadGroup(string keyValue)
  1894. {
  1895. var queryParam = keyValue.ToJObject();
  1896. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1897. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1898. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1899. string msg = "";
  1900. string sql = string.Empty;
  1901. sql = @"UPDATE dbo.ICSInventoryBadGroup set BCGroupID='{0}',BRGroupID='{1}',Enable='{2}',MUSER='{3}',MUSERName='{4}',MTIME=GetDate(),WorkPoint='{5}' WHERE ID='{6}'";
  1902. sql = string.Format(sql, queryParam["BCGroupID"].ToString(), queryParam["BRGroupID"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  1903. try
  1904. {
  1905. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1906. {
  1907. }
  1908. else
  1909. {
  1910. msg = "修改失败";
  1911. }
  1912. }
  1913. catch (Exception ex)
  1914. {
  1915. throw new Exception(ex.Message);
  1916. }
  1917. return msg;
  1918. }
  1919. /// <summary>
  1920. /// 删除料品不良信息
  1921. /// </summary>
  1922. /// <param name="keyValue">传入ID</param>
  1923. /// <returns></returns>
  1924. public string DeleteInventoryBadGroup(string keyValue)
  1925. {
  1926. //站点信息
  1927. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1928. string msg = "";
  1929. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1930. string sql = string.Empty;
  1931. sql = string.Format(@"DELETE FROM dbo.ICSInventoryBadGroup WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1932. try
  1933. {
  1934. SqlHelper.ExecuteNonQuery(sql);
  1935. }
  1936. catch (Exception ex)
  1937. {
  1938. throw new Exception(ex.Message);
  1939. }
  1940. return msg;
  1941. }
  1942. //库位导入
  1943. public string SetData_PR(String savePath)
  1944. {
  1945. //数据获取
  1946. try
  1947. {
  1948. int index = 1;
  1949. string msg = "";
  1950. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1951. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1952. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1953. SqlConnection conn = SqlHelper.GetDataCenterConn();
  1954. string sql = "";
  1955. int count = 0;
  1956. DataTable data = FileToExcel.ExcelToTable(savePath);
  1957. foreach (DataRow dr in data.Rows)
  1958. {
  1959. index++;
  1960. var StackCode = "";
  1961. var StackName = "";
  1962. //string GUID = Guid.NewGuid().ToString();
  1963. string KuFang = dr["库房编码"].ToString().Trim().ToUpper();
  1964. string Qu = dr["区"].ToString().Trim().ToUpper();
  1965. string Pai = dr["排"].ToString().Trim().ToUpper();
  1966. string Jia = dr["货架"].ToString().Trim().ToUpper();
  1967. string Ceng = dr["层"].ToString().Trim().ToUpper();
  1968. string Ge = dr["格"].ToString().Trim().ToUpper();
  1969. if (KuFang==""|| KuFang==null)
  1970. {
  1971. throw new Exception("第 " + index + " 行库房编码不能为空!");
  1972. }
  1973. if (Qu == "" && Pai == "" && Jia == "" && Ceng == "" && Ge == "")
  1974. {
  1975. throw new Exception("第 " + index + " 区、排、货架、层、格至少填写一项!");
  1976. }
  1977. string sqlWH = @"select ID from ICSWarehouse where WarehouseCode='{0}' and WorkPoint='{1}'";
  1978. sqlWH = string.Format(sqlWH, KuFang, WorkPoint);
  1979. DataTable dd = SqlHelper.CmdExecuteDataTable(sqlWH);
  1980. if (dd==null && dd.Rows.Count<=0)
  1981. {
  1982. throw new Exception("库房编码: " + KuFang + " 不存在!");
  1983. }
  1984. string WHID = dd.Rows[0]["ID"].ToString();
  1985. StackCode = KuFang;
  1986. StackName = KuFang + "仓库";
  1987. if (Qu != "")
  1988. {
  1989. StackCode += "-" + Qu;
  1990. StackName += Qu + "区";
  1991. }
  1992. if (Pai != "")
  1993. {
  1994. StackCode += "-" + Pai;
  1995. StackName += Pai + "排";
  1996. }
  1997. if (Jia != "")
  1998. {
  1999. StackCode += "-" + Jia;
  2000. StackName += Jia + "货架";
  2001. }
  2002. if (Ceng != "")
  2003. {
  2004. StackCode += "-" + Ceng;
  2005. StackName += Ceng + "层";
  2006. }
  2007. if (Ge != "")
  2008. {
  2009. StackCode += "-" + Ge;
  2010. StackName += Ge + "格";
  2011. }
  2012. string sqls = @"select LocationCode from ICSLocation where LocationCode='{0}' and WorkPoint='{1}'";
  2013. sqls = string.Format(sqls, StackCode, WorkPoint);
  2014. DataTable dnum= SqlHelper.CmdExecuteDataTable(sqls);
  2015. if (dnum!=null && dnum.Rows.Count> 0)
  2016. {
  2017. throw new Exception("库位: " + StackCode + " 已存在!");
  2018. }
  2019. else
  2020. {
  2021. sql += @"Insert INto ICSLocation Values (newid(),'{0}','{1}','{2}','{3}','{4}',getdate(),'{5}','')";
  2022. }
  2023. sql = string.Format(sql, StackCode, StackName,WHID, MUSER, MUSERNAME, WorkPoint);
  2024. }
  2025. count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2026. if (count > 0)
  2027. {
  2028. msg = "导入成功";
  2029. }
  2030. else
  2031. {
  2032. return "无有效的导入数据。";
  2033. }
  2034. return msg;
  2035. }
  2036. catch (Exception ex)
  2037. {
  2038. return ex.Message;
  2039. }
  2040. }
  2041. /// <summary>
  2042. ///启用的料品库位绑定关系
  2043. /// </summary>
  2044. public string EnableInventoryLocation(string keyValue)
  2045. {
  2046. //站点信息
  2047. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2048. string msg = "";
  2049. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2050. string sql = string.Empty;
  2051. sql = string.Format(@"update ICSInventoryLocation set Enable='1' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2052. try
  2053. {
  2054. SqlHelper.ExecuteNonQuery(sql);
  2055. }
  2056. catch (Exception ex)
  2057. {
  2058. throw new Exception(ex.Message);
  2059. }
  2060. return msg;
  2061. }
  2062. /// <summary>
  2063. ///禁用的料品库位绑定关系
  2064. /// </summary>
  2065. public string ForbiddenInventoryLocation(string keyValue)
  2066. {
  2067. //站点信息
  2068. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2069. string msg = "";
  2070. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2071. string sql = string.Empty;
  2072. sql = string.Format(@"update ICSInventoryLocation set Enable='0' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2073. try
  2074. {
  2075. SqlHelper.ExecuteNonQuery(sql);
  2076. }
  2077. catch (Exception ex)
  2078. {
  2079. throw new Exception(ex.Message);
  2080. }
  2081. return msg;
  2082. }
  2083. /// <summary>
  2084. ///启用的料品仓库绑定关系
  2085. /// </summary>
  2086. public string EnableBatchEnable(string keyValue)
  2087. {
  2088. //站点信息
  2089. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2090. string msg = "";
  2091. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2092. string sql = string.Empty;
  2093. sql = string.Format(@"update ICSInventoryBatchEnable set BatchEnable='1' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2094. try
  2095. {
  2096. SqlHelper.ExecuteNonQuery(sql);
  2097. }
  2098. catch (Exception ex)
  2099. {
  2100. throw new Exception(ex.Message);
  2101. }
  2102. return msg;
  2103. }
  2104. /// <summary>
  2105. ///禁用的料品仓库绑定关系
  2106. /// </summary>
  2107. public string ForbiddenBatchEnable(string keyValue)
  2108. {
  2109. //站点信息
  2110. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2111. string msg = "";
  2112. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2113. string sql = string.Empty;
  2114. sql = string.Format(@"update ICSInventoryBatchEnable set BatchEnable='0' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2115. try
  2116. {
  2117. SqlHelper.ExecuteNonQuery(sql);
  2118. }
  2119. catch (Exception ex)
  2120. {
  2121. throw new Exception(ex.Message);
  2122. }
  2123. return msg;
  2124. }
  2125. public string CreateLableDataSource( string Sys_LableDataSource)
  2126. {
  2127. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2128. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2129. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2130. string msg = "";
  2131. string sql = string.Empty;
  2132. string SqlTxt = "";
  2133. JArray res = (JArray)JsonConvert.DeserializeObject(Sys_LableDataSource);
  2134. foreach (var item in res)
  2135. {
  2136. JObject jo = (JObject)item;
  2137. if (jo["DbParas"].ToString().Trim() != "")
  2138. {
  2139. string[] dbvs = jo["DbParas"].ToString().Trim().Split(',');
  2140. List<string> vs = new List<string>();
  2141. foreach (string s in dbvs)
  2142. {
  2143. if (!string.IsNullOrEmpty(s))
  2144. {
  2145. vs.Add(s);
  2146. }
  2147. }
  2148. SqlTxt = string.Format(jo["FormatSqlTxt"].ToString(), vs.ToArray());
  2149. }
  2150. else
  2151. {
  2152. SqlTxt = jo["FormatSqlTxt"].ToString();
  2153. }
  2154. sql += @"INSERT INTO dbo.Sys_LableDataSource
  2155. (ID,WorkPointCode,OtherDataBaseID,WorkPointDataFlag,SysDataFlag,SqlTxt,SourceName,FormatSqlTxt,Paras,DbParas,LinkCols,CreateUserID,CreateDate,ModifyUserID,ModifyDate,Link2Cols )
  2156. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',getdate(),'{11}',getdate(),'{12}')";
  2157. 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());
  2158. }
  2159. try
  2160. {
  2161. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2162. {
  2163. }
  2164. else
  2165. {
  2166. msg = "新增失败";
  2167. }
  2168. }
  2169. catch (Exception ex)
  2170. {
  2171. throw new Exception(ex.Message);
  2172. }
  2173. return msg;
  2174. }
  2175. public DataTable GetTXT(string ID)
  2176. {
  2177. DataTable dt = new DataTable();
  2178. //var queryParam = queryJson.ToJObject();
  2179. List<DbParameter> parameter = new List<DbParameter>();
  2180. string sql = @"SELECT
  2181. ID,
  2182. WorkPointCode,
  2183. OtherDataBaseID,
  2184. WorkPointDataFlag,
  2185. SysDataFlag,
  2186. SqlTxt,
  2187. SourceName,
  2188. FormatSqlTxt,
  2189. Paras,
  2190. DbParas,
  2191. LinkCols,
  2192. CreateUserID,
  2193. CreateDate,
  2194. ModifyUserID,
  2195. ModifyDate,
  2196. Link2Cols
  2197. FROM
  2198. dbo.Sys_LableDataSource where ID='" + ID + "'";
  2199. return Repository().FindTableBySql(sql.ToString());
  2200. }
  2201. public string updateLableDataSource(string Sys_LableDataSource)
  2202. {
  2203. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2204. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2205. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2206. string msg = "";
  2207. string sql = string.Empty;
  2208. string SqlTxt = "";
  2209. JArray res = (JArray)JsonConvert.DeserializeObject(Sys_LableDataSource);
  2210. foreach (var item in res)
  2211. {
  2212. JObject jo = (JObject)item;
  2213. if (jo["DbParas"].ToString().Trim() != "")
  2214. {
  2215. string[] dbvs = jo["DbParas"].ToString().Trim().Split(',');
  2216. List<string> vs = new List<string>();
  2217. foreach (string s in dbvs)
  2218. {
  2219. if (!string.IsNullOrEmpty(s))
  2220. {
  2221. vs.Add(s);
  2222. }
  2223. }
  2224. SqlTxt = string.Format(jo["FormatSqlTxt"].ToString(), vs.ToArray());
  2225. }
  2226. else
  2227. {
  2228. SqlTxt = jo["FormatSqlTxt"].ToString();
  2229. }
  2230. 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}'";
  2231. 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());
  2232. }
  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. public string DeleteLableDataSource(string keyValue)
  2250. {
  2251. //站点信息
  2252. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2253. string msg = "";
  2254. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2255. string sql = string.Empty;
  2256. sql = string.Format(@"DELETE FROM dbo.Sys_LableDataSource WHERE ID IN ({0}) ", keyValue.TrimEnd(','));
  2257. try
  2258. {
  2259. SqlHelper.ExecuteNonQuery(sql);
  2260. }
  2261. catch (Exception ex)
  2262. {
  2263. throw new Exception(ex.Message);
  2264. }
  2265. return msg;
  2266. }
  2267. public DataTable GetLableType()
  2268. {
  2269. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2270. string sql = @"
  2271. select '' as F_ItemCode,'' as F_ItemName
  2272. union all
  2273. 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'";
  2274. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  2275. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2276. return dt;
  2277. }
  2278. public DataTable GetSys_LablesID()
  2279. {
  2280. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2281. string sql = @"
  2282. select '' as ID,'' as LableName
  2283. union all
  2284. select distinct ID,LableName from Sys_Lables";
  2285. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  2286. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2287. return dt;
  2288. }
  2289. public string CreateLables(string txtLableName,string sel_LableType,string sel_LableSourceID)
  2290. {
  2291. string UserId = NFine.Code.OperatorProvider.Provider.GetCurrent().UserId;
  2292. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2293. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2294. string msg = "";
  2295. string sql = string.Empty;
  2296. string LableCode = "";
  2297. string SqlTxt = string.Format(@"SELECT MAX(A.LableCode) AS LableCode FROM Sys_Lables A "); ;
  2298. DataSet ds = SqlHelper.GetDataSetBySql(SqlTxt);
  2299. DataTable dts = ds.Tables[0];
  2300. if (dts != null && dts.Rows.Count > 0)
  2301. {
  2302. string lot = dts.Rows[0]["LableCode"].ToString();
  2303. LableCode = (Convert.ToInt64(lot) + 1).ToString().PadLeft(5, '0');
  2304. }
  2305. else
  2306. {
  2307. LableCode = "00001";
  2308. }
  2309. sql += @" INSERT INTO dbo.Sys_Lables
  2310. (ID,WorkPointCode,LableType,LableCode,LableName,LableXml,LableSourceID,CreateUserID,CreateDate,ModifyUserID,ModifyDate,FileAddress )
  2311. Values(NEWID(),'{0}','{1}','{2}','{3}','','{4}','{5}',getdate(),'{6}',getdate(),'')";
  2312. sql = string.Format(sql,WorkPoint, sel_LableType, LableCode, txtLableName, sel_LableSourceID, UserId, UserId);
  2313. try
  2314. {
  2315. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2316. {
  2317. }
  2318. else
  2319. {
  2320. msg = "新增失败";
  2321. }
  2322. }
  2323. catch (Exception ex)
  2324. {
  2325. throw new Exception(ex.Message);
  2326. }
  2327. return msg;
  2328. }
  2329. public DataTable GetLabelTXT(string ID)
  2330. {
  2331. DataTable dt = new DataTable();
  2332. //var queryParam = queryJson.ToJObject();
  2333. List<DbParameter> parameter = new List<DbParameter>();
  2334. string sql = @"select ID,WorkPointCode,LableType,LableCode,LableName,LableXml,LableSourceID,CreateUserID,CreateDate,ModifyUserID,ModifyDate,FileAddress from Sys_Lables where ID='" + ID + "'";
  2335. return Repository().FindTableBySql(sql.ToString());
  2336. }
  2337. public string updateLables(string ID,string txtLableName, string sel_LableType, string sel_LableSourceID)
  2338. {
  2339. string UserId = NFine.Code.OperatorProvider.Provider.GetCurrent().UserId;
  2340. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2341. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2342. string msg = "";
  2343. string sql = string.Empty;
  2344. sql += @"update Sys_Lables set LableType='{0}' ,LableName='{1}' ,LableSourceID='{2}',ModifyUserID='{3}',ModifyDate=getdate() where ID='{4}'";
  2345. sql = string.Format(sql, sel_LableType, txtLableName, sel_LableSourceID, UserId,ID);
  2346. try
  2347. {
  2348. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2349. {
  2350. }
  2351. else
  2352. {
  2353. msg = "修改失败";
  2354. }
  2355. }
  2356. catch (Exception ex)
  2357. {
  2358. throw new Exception(ex.Message);
  2359. }
  2360. return msg;
  2361. }
  2362. public string DeleteICSLabelTemplate(string keyValue)
  2363. {
  2364. //站点信息
  2365. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2366. string msg = "";
  2367. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2368. string sql = string.Empty;
  2369. sql = string.Format(@"DELETE FROM dbo.Sys_Lables WHERE ID IN ({0}) ", keyValue.TrimEnd(','));
  2370. try
  2371. {
  2372. SqlHelper.ExecuteNonQuery(sql);
  2373. }
  2374. catch (Exception ex)
  2375. {
  2376. throw new Exception(ex.Message);
  2377. }
  2378. return msg;
  2379. }
  2380. //获取父容器
  2381. public DataTable GetContainerID()
  2382. {
  2383. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2384. string sql = @"
  2385. select '' as ID,'' as ContainerName
  2386. union all
  2387. SELECT DISTINCT a.ID,a.ContainerName FROM dbo.ICSContainer a ";
  2388. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  2389. if (role != "admin")
  2390. {
  2391. sql += " and b.WorkPoint in(" + WorkPoint + ")";
  2392. }
  2393. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2394. return dt;
  2395. }
  2396. public int UpLoadLabelFile(string ID, string fileName)
  2397. {
  2398. DataTable dt = new DataTable();
  2399. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2400. string sql = "";
  2401. sql = string.Format(@"update Sys_Lables set FileAddress='{0}'
  2402. where ID='{1}'",
  2403. fileName, ID);
  2404. StringBuilder Str = new StringBuilder(sql);
  2405. return Repository().ExecuteBySql(Str);
  2406. }
  2407. //包装容器
  2408. public DataTable GetSendContainer(ref Pagination jqgridparam, string queryJson)
  2409. {
  2410. DataTable dt = new DataTable();
  2411. var queryParam = queryJson.ToJObject();
  2412. List<DbParameter> parameter = new List<DbParameter>();
  2413. string sql = @"select top 0 ID,ContainerID,ContainerCode,ContainerName,Memo,MUSER,MUSERName,MTIME,WorkPoint from ICSContainer";
  2414. sql += " WHERE 1=1";
  2415. sql = string.Format(sql);
  2416. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2417. }
  2418. public DataTable GetContainerInfo(string Code)
  2419. {
  2420. DataTable dt = new DataTable();
  2421. //var queryParam = queryJson.ToJObject();
  2422. List<DbParameter> parameter = new List<DbParameter>();
  2423. string sql = @" select ID,ContainerID,ContainerCode,ContainerName,Memo,MUSER,MUSERName,MTIME,WorkPoint from ICSContainer where ContainerCode='{0}'";
  2424. sql = string.Format(sql, Code);
  2425. return Repository().FindTableBySql(sql.ToString());
  2426. }
  2427. public DataTable GetBindContainerID(string SireCode)
  2428. {
  2429. DataTable dt = new DataTable();
  2430. //var queryParam = queryJson.ToJObject();
  2431. List<DbParameter> parameter = new List<DbParameter>();
  2432. string sql = @" select ID from ICSContainer where ContainerCode='{0}'";
  2433. sql = string.Format(sql, SireCode);
  2434. return Repository().FindTableBySql(sql.ToString());
  2435. }
  2436. public string BindingContainerID(string ICSMTDOC, string SireID)
  2437. {
  2438. string msg = "";
  2439. try
  2440. {
  2441. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2442. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2443. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2444. string sql = string.Empty;
  2445. JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
  2446. foreach (var item in res)
  2447. {
  2448. JObject jo = (JObject)item;
  2449. sql += @"
  2450. IF NOT EXISTS(SELECT ContainerCode FROM ICSContainer WHERE ContainerCode='{1}' )
  2451. BEGIN
  2452. RAISERROR('{1} ',16,1);
  2453. RETURN
  2454. END
  2455. IF EXISTS(select ContainerID from ICSContainer where ContainerCode='{1}' and isnull(ContainerID,'')<>'')
  2456. BEGIN
  2457. RAISERROR('{1}',16,1);
  2458. RETURN
  2459. END
  2460. update ICSContainer set ContainerID='{0}' WHERE ContainerCode = '{1}' and WorkPoint ='{2}'";
  2461. sql = string.Format(sql, SireID, jo["ContainerCode"].ToString(), WorkPoint);
  2462. }
  2463. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  2464. {
  2465. }
  2466. else
  2467. {
  2468. msg = "绑定失败";
  2469. }
  2470. }
  2471. catch (Exception ex)
  2472. {
  2473. msg = ex.Message;
  2474. }
  2475. return msg;
  2476. }
  2477. //包装容器关联条码
  2478. public DataTable GetSendContainerLot(ref Pagination jqgridparam, string queryJson)
  2479. {
  2480. DataTable dt = new DataTable();
  2481. var queryParam = queryJson.ToJObject();
  2482. List<DbParameter> parameter = new List<DbParameter>();
  2483. string sql = @"
  2484. select top 0 a.ID, a.LotNo,a.InvCode,b.InvName,b.InvStd,b.InvUnit, a.ProductDate,a.Quantity from ICSInventoryLot a
  2485. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint";
  2486. sql = string.Format(sql);
  2487. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2488. }
  2489. public DataTable GetContainerLotInfo(string LotNo)
  2490. {
  2491. DataTable dt = new DataTable();
  2492. //var queryParam = queryJson.ToJObject();
  2493. List<DbParameter> parameter = new List<DbParameter>();
  2494. string sql = @" select a.ID, a.LotNo,a.InvCode,b.InvName,b.InvStd,b.InvUnit, a.ProductDate,a.Quantity from ICSInventoryLot a
  2495. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint where a.LotNo='{0}'";
  2496. sql = string.Format(sql, LotNo);
  2497. return Repository().FindTableBySql(sql.ToString());
  2498. }
  2499. public string BindingContainerLotID(string ICSMTDOC, string SireID,string SireCode)
  2500. {
  2501. string msg = "";
  2502. try
  2503. {
  2504. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2505. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2506. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2507. string sql = string.Empty;
  2508. JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
  2509. foreach (var item in res)
  2510. {
  2511. JObject jo = (JObject)item;
  2512. sql += @"
  2513. IF NOT EXISTS(SELECT ContainerCode FROM ICSContainer WHERE ContainerCode='{5}')
  2514. BEGIN
  2515. RAISERROR('{5} ',16,1);
  2516. RETURN
  2517. END
  2518. IF NOT EXISTS(select LotNo from ICSInventoryLot where LotNo='{1}')
  2519. BEGIN
  2520. RAISERROR('{1}',16,1);
  2521. RETURN
  2522. END
  2523. IF EXISTS(select LotNo from ICSContainerLot where LotNo ='{1}')
  2524. BEGIN
  2525. RAISERROR('{1}',16,1);
  2526. RETURN
  2527. END
  2528. INSERT INTO ICSContainerLot
  2529. (ID,ContainerID,LotNo,MUSER,MUSERName,WorkPoint,MTIME )
  2530. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',getdate())";
  2531. sql = string.Format(sql, SireID, jo["LotNo"].ToString(), MUSER, MUSERNAME, WorkPoint, SireCode);
  2532. }
  2533. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  2534. {
  2535. }
  2536. else
  2537. {
  2538. msg = "绑定失败";
  2539. }
  2540. }
  2541. catch (Exception ex)
  2542. {
  2543. msg=ex.Message;
  2544. }
  2545. return msg;
  2546. }
  2547. }
  2548. }