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

2967 lines
120 KiB

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