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

3394 lines
140 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
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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 ,Region,Row,GoodsShelf ,Tier,Grid) Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',GETDATE(),'{5}','{6}','{7}','{8}','{9}','{10}')";
  108. sql = string.Format(sql, queryParam["StackCode"].ToString(), queryParam["StackName"].ToString(), dt.Rows[0]["ID"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["Qu"].ToString(), queryParam["Pai"].ToString(), queryParam["Jia"].ToString(), queryParam["Ceng"].ToString(), queryParam["Ge"].ToString());
  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}',Region='{7}',Row='{8}',GoodsShelf ='{9}',Tier='{10}',Grid='{11}' 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(), queryParam["Qu"].ToString(), queryParam["Pai"].ToString(), queryParam["Jia"].ToString(), queryParam["Ceng"].ToString(), queryParam["Ge"].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, BID, 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. string ID = Guid.NewGuid().ToString();
  1067. List<ICSInspectionList> list_Item1 = new List<ICSInspectionList>();
  1068. if (main.arrayShellFabricItem != null)
  1069. {
  1070. list_Item1 = JsonConvert.DeserializeObject<List<ICSInspectionList>>(main.arrayShellFabricItem);
  1071. }
  1072. string connString = SqlHelper.DataCenterConnString;
  1073. SqlConnection conn = new SqlConnection(connString);
  1074. conn.Open();
  1075. SqlTransaction sqlTran = conn.BeginTransaction();
  1076. SqlCommand cmd = new SqlCommand();
  1077. cmd.Transaction = sqlTran;
  1078. cmd.Connection = conn;
  1079. sql = @"
  1080. IF EXISTS(select GroupCode from ICSInspectionGroup where GroupCode='{0}')
  1081. BEGIN
  1082. RAISERROR('',16,1);
  1083. RETURN
  1084. end
  1085. INSERT INTO dbo.ICSInspectionGroup
  1086. ( ID ,GroupCode ,GroupName,Enable, MTIME,MUSER ,MUSERName ,WorkPoint )
  1087. Values('{6}','{0}','{1}','{2}',GETDATE(),'{3}','{4}','{5}')";
  1088. sql = string.Format(sql, GroupCode, GroupName, Enable, MUSER, MUSERNAME, WorkPoint,ID);
  1089. try
  1090. {
  1091. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1092. {
  1093. foreach (ICSInspectionList Item in list_Item1)
  1094. {
  1095. sqls = @"
  1096. IF EXISTS(select ListCode from ICSInspectionList where ListCode=@ListCode)
  1097. BEGIN
  1098. RAISERROR('',16,1);
  1099. RETURN
  1100. end
  1101. INSERT INTO dbo.ICSInspectionList
  1102. ( ID ,GroupID,ListCode ,ListName, Unit,SetValueMax ,SetValueMin,Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
  1103. Values(@ID,'{0}',@ListCode,@ListName,@Unit,@SetValueMax,@SetValueMin,@Enable,getdate(),'{1}','{2}','{3}')";
  1104. sqls = string.Format(sqls, ID, MUSER, MUSERNAME, WorkPoint);
  1105. SqlParameter[] sp_Item = {
  1106. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  1107. new SqlParameter("@ListCode",DbType.String){ Value= Item.ListCode},
  1108. new SqlParameter("@ListName",DbType.String){ Value= Item.ListName},
  1109. new SqlParameter("@Unit",DbType.String){ Value= Item.Unit},
  1110. new SqlParameter("@SetValueMax",DbType.String){ Value= Item.SetValueMax},
  1111. new SqlParameter("@SetValueMin",DbType.String){ Value= Item.SetValueMin},
  1112. new SqlParameter("@Enable",DbType.String){ Value= Item.Enable},
  1113. };
  1114. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  1115. }
  1116. cmd.Transaction.Commit();
  1117. }
  1118. }
  1119. catch (Exception ex)
  1120. {
  1121. cmd.Transaction.Rollback();
  1122. throw new Exception(ex.Message);
  1123. }
  1124. finally
  1125. {
  1126. if (conn.State == ConnectionState.Open)
  1127. {
  1128. conn.Close();
  1129. }
  1130. conn.Dispose();
  1131. }
  1132. }
  1133. /// <summary>
  1134. /// 动态子表修改加载页面
  1135. /// </summary>
  1136. /// <param name="GroupCode"></param>
  1137. /// <returns></returns>
  1138. public DataTable ICSInspectionList2(string GroupCode)
  1139. {
  1140. string sql = string.Empty;
  1141. DataTable dt = null;
  1142. sql = string.Format(@"SELECT ID,GroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,
  1143. case when Enable='1' then '是' else '否' end as Enable,
  1144. MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1 FROM
  1145. dbo.ICSInspectionList where GroupID='{0}'", GroupCode);
  1146. dt = SqlHelper.GetDataTableBySql(sql);
  1147. return dt;
  1148. }
  1149. /// <summary>
  1150. /// 删除不良原因组
  1151. /// </summary>
  1152. /// <param name="keyValue">传入ID</param>
  1153. /// <returns></returns>
  1154. public string DeleteICSInspectionGroup(string keyValue)
  1155. {
  1156. //站点信息
  1157. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1158. string msg = "";
  1159. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1160. string sql = string.Empty;
  1161. string sqls = string.Empty;
  1162. sql = string.Format(@"DELETE FROM dbo.ICSInspectionGroup WHERE GroupCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1163. try
  1164. {
  1165. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1166. {
  1167. sqls = string.Format(@"DELETE FROM dbo.ICSInspectionList WHERE GroupID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1168. SqlHelper.ExecuteNonQuery(sqls);
  1169. }
  1170. }
  1171. catch (Exception ex)
  1172. {
  1173. throw new Exception(ex.Message);
  1174. }
  1175. return msg;
  1176. }
  1177. /// <summary>
  1178. /// 新增料品属性
  1179. /// </summary>
  1180. /// <param name="queryJson"></param>
  1181. /// <returns></returns>
  1182. public string InsertICSInventory(string keyValue)
  1183. {
  1184. var queryParam = keyValue.ToJObject();
  1185. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1186. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1187. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1188. string msg = "";
  1189. string sql = string.Empty;
  1190. sql = @"INSERT INTO dbo.ICSInventory
  1191. ( ID ,InvCode ,InvName ,InvDesc,InvStd,InvUnit,AmountUnit ,ClassCode ,ClassName ,InvRate,InvVersion,InvBrand,InvIQC ,InvFQC ,EffectiveEnable,EffectiveDays,BatchEnable,LotEnable ,PrintEnable ,WHUser,MTIME,MUSER ,MUSERName ,WorkPoint )
  1192. 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}')
  1193. ";
  1194. sql = string.Format(sql,
  1195. queryParam["InvCode"].ToString(),
  1196. queryParam["InvName"].ToString(),
  1197. queryParam["InvDesc"].ToString(),
  1198. queryParam["InvStd"].ToString(),
  1199. queryParam["InvUnit"].ToString(),
  1200. queryParam["AmountUnit"].ToString(),
  1201. queryParam["ClassCode"].ToString(),
  1202. queryParam["ClassName"].ToString(),
  1203. queryParam["InvRate"].ToString(),
  1204. queryParam["InvVersion"].ToString(),
  1205. queryParam["InvBrand"].ToString(),
  1206. queryParam["InvIQC"].ToString(),
  1207. queryParam["InvFQC"].ToString(),
  1208. queryParam["EffectiveEnable"].ToString(),
  1209. queryParam["EffectiveDays"].ToString(),
  1210. queryParam["BatchEnable"].ToString(),
  1211. queryParam["LotEnable"].ToString(),
  1212. queryParam["PrintEnable"].ToString(),
  1213. queryParam["WHUser"].ToString(),
  1214. MUSER, MUSERNAME, WorkPoint);
  1215. try
  1216. {
  1217. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1218. {
  1219. }
  1220. else
  1221. {
  1222. msg = "新增失败";
  1223. }
  1224. }
  1225. catch (Exception ex)
  1226. {
  1227. throw new Exception(ex.Message);
  1228. }
  1229. return msg;
  1230. }
  1231. /// <summary>
  1232. /// 修改料品属性
  1233. /// </summary>
  1234. /// <param name="queryJson"></param>
  1235. /// <returns></returns>
  1236. public string UpdateICSInventory(string keyValue)
  1237. {
  1238. var queryParam = keyValue.ToJObject();
  1239. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1240. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1241. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1242. string msg = "";
  1243. string sql = string.Empty;
  1244. sql = @"UPDATE dbo.ICSInventory set
  1245. InvCode='{0}'
  1246. ,InvName='{1}'
  1247. ,InvDesc='{2}'
  1248. ,InvStd='{3}'
  1249. ,InvUnit='{4}'
  1250. ,AmountUnit='{5}'
  1251. ,ClassCode='{6}'
  1252. ,ClassName='{7}'
  1253. ,InvRate='{8}'
  1254. ,InvVersion='{9}'
  1255. ,InvBrand='{10}'
  1256. ,InvIQC='{11}'
  1257. ,InvFQC='{12}'
  1258. ,EffectiveEnable='{13}'
  1259. ,EffectiveDays='{14}'
  1260. ,BatchEnable='{15}'
  1261. ,LotEnable='{16}'
  1262. ,PrintEnable='{17}'
  1263. ,WHUser='{18}'
  1264. ,MTIME=GETDATE()
  1265. ,MUSER='{19}'
  1266. ,MUSERName='{20}'
  1267. ,WorkPoint='{21}'
  1268. WHERE ID='{22}'";
  1269. sql = string.Format(sql,
  1270. queryParam["InvCode"].ToString(),
  1271. queryParam["InvName"].ToString(),
  1272. queryParam["InvDesc"].ToString(),
  1273. queryParam["InvStd"].ToString(),
  1274. queryParam["InvUnit"].ToString(),
  1275. queryParam["AmountUnit"].ToString(),
  1276. queryParam["ClassCode"].ToString(),
  1277. queryParam["ClassName"].ToString(),
  1278. queryParam["InvRate"].ToString(),
  1279. queryParam["InvVersion"].ToString(),
  1280. queryParam["InvBrand"].ToString(),
  1281. queryParam["InvIQC"].ToString(),
  1282. queryParam["InvFQC"].ToString(),
  1283. queryParam["EffectiveEnable"].ToString(),
  1284. queryParam["EffectiveDays"].ToString(),
  1285. queryParam["BatchEnable"].ToString(),
  1286. queryParam["LotEnable"].ToString(),
  1287. queryParam["PrintEnable"].ToString(),
  1288. queryParam["WHUser"].ToString(),
  1289. MUSER, MUSERNAME, WorkPoint,
  1290. queryParam["ID"].ToString());
  1291. try
  1292. {
  1293. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1294. {
  1295. }
  1296. else
  1297. {
  1298. msg = "修改失败";
  1299. }
  1300. }
  1301. catch (Exception ex)
  1302. {
  1303. throw new Exception(ex.Message);
  1304. }
  1305. return msg;
  1306. }
  1307. /// <summary>
  1308. /// 获取下拉料品号获取其他信息
  1309. /// </summary>
  1310. public DataTable GetInputValue(string ID)
  1311. {
  1312. try
  1313. {
  1314. DataTable dt = new DataTable();
  1315. //var queryParam = queryJson.ToJObject();
  1316. List<DbParameter> parameter = new List<DbParameter>();
  1317. string sql = @"select InvCode,InvName,InvDesc,InvStd,InvUnit,AmountUnit, ClassCode,ClassName,InvRate,InvVersion,InvBrand,InvIQC,
  1318. InvFQC,EffectiveEnable,EffectiveDays,BatchEnable,LotEnable,PrintEnable,WHUser
  1319. from ICSInventory
  1320. WHERE 1=1 AND ID='{0}' ";
  1321. sql = string.Format(sql, ID);
  1322. return Repository().FindTableBySql(sql.ToString());
  1323. }
  1324. catch (Exception ex)
  1325. {
  1326. throw new Exception(ex.Message.ToString());
  1327. }
  1328. }
  1329. /// <summary>
  1330. /// 删除料品属性
  1331. /// </summary>
  1332. /// <param name="keyValue">传入ID</param>
  1333. /// <returns></returns>
  1334. public string DeleteICSInventory(string keyValue)
  1335. {
  1336. //站点信息
  1337. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1338. string msg = "";
  1339. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1340. string sql = string.Empty;
  1341. sql = string.Format(@"DELETE FROM dbo.ICSInventory WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1342. try
  1343. {
  1344. SqlHelper.ExecuteNonQuery(sql);
  1345. }
  1346. catch (Exception ex)
  1347. {
  1348. throw new Exception(ex.Message);
  1349. }
  1350. return msg;
  1351. }
  1352. /// <summary>
  1353. /// 获取料品信息
  1354. /// </summary>
  1355. /// <param name="jqgridparam"></param>
  1356. /// <returns></returns>
  1357. public DataTable GetICSInventoryInfo(string queryJson, ref Pagination jqgridparam)
  1358. {
  1359. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1360. DataTable dt = new DataTable();
  1361. var queryParam = queryJson.ToJObject();
  1362. List<DbParameter> parameter = new List<DbParameter>();
  1363. string sql = @"select ID, InvCode,InvName,InvDesc,InvStd,InvUnit,AmountUnit,ClassCode,ClassName,InvRate,InvVersion,InvBrand,
  1364. InvIQC,InvFQC,EffectiveEnable,EffectiveDays,BatchEnable,LotEnable,PrintEnable,WHUser
  1365. from ICSInventory where WorkPoint='{0}' ";
  1366. sql = string.Format(sql, WorkPoint);
  1367. if (!string.IsNullOrWhiteSpace(queryJson))
  1368. {
  1369. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1370. {
  1371. sql += " and InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1372. }
  1373. }
  1374. // DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1375. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1376. }
  1377. /// <summary>
  1378. /// 获取仓库信息
  1379. /// </summary>
  1380. /// <param name="jqgridparam"></param>
  1381. /// <returns></returns>
  1382. public DataTable GetICSWarehouseInfo(string queryJson, ref Pagination jqgridparam)
  1383. {
  1384. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1385. DataTable dt = new DataTable();
  1386. var queryParam = queryJson.ToJObject();
  1387. List<DbParameter> parameter = new List<DbParameter>();
  1388. string sql = @"select ID,WarehouseCode,WarehouseName ,Enable,BatchEnable,Asset,Proxy,InCost from ICSWarehouse where WorkPoint='{0}' ";
  1389. sql = string.Format(sql, WorkPoint);
  1390. if (!string.IsNullOrWhiteSpace(queryJson))
  1391. {
  1392. if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString()))
  1393. {
  1394. sql += " and WarehouseCode like '%" + queryParam["WHCode"].ToString() + "%' ";
  1395. }
  1396. }
  1397. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1398. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1399. }
  1400. /// <summary>
  1401. /// 新增料品仓库批次关系
  1402. /// </summary>
  1403. /// <param name="queryJson"></param>
  1404. /// <returns></returns>
  1405. public string InsertICSInventoryBatchEnable(string keyValue, string keyValue2)
  1406. {
  1407. List<string> InvCodeList = keyValue.Substring(1, keyValue.Length - 3).Split(',').ToList<string>();
  1408. List<string> WarehouseCodeList = keyValue2.Substring(1, keyValue2.Length - 3).Split(',').ToList<string>();
  1409. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1410. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1411. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1412. string msg = "";
  1413. string sql = string.Empty;
  1414. foreach (var item in InvCodeList)
  1415. {
  1416. foreach (var itemwh in WarehouseCodeList)
  1417. {
  1418. sql += @"IF EXISTS(select InvCode,WHCode from ICSInventoryBatchEnable where InvCode={0} and WHCode={1})
  1419. BEGIN
  1420. RAISERROR('',16,1);
  1421. RETURN
  1422. end
  1423. INSERT INTO dbo.ICSInventoryBatchEnable
  1424. ( ID ,InvCode ,WHCode ,BatchEnable,MTIME,MUSER ,MUSERName ,WorkPoint )
  1425. Values(NEWID(),{0},{1},'{2}',GETDATE(),'{3}','{4}','{5}')
  1426. ";
  1427. sql = string.Format(sql, item, itemwh, '1'.ToString(), MUSER, MUSERNAME, WorkPoint);
  1428. }
  1429. }
  1430. try
  1431. {
  1432. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1433. {
  1434. }
  1435. else
  1436. {
  1437. msg = "新增失败";
  1438. }
  1439. }
  1440. catch (Exception ex)
  1441. {
  1442. msg = ex.Message;
  1443. }
  1444. return msg;
  1445. }
  1446. /// <summary>
  1447. /// 修改料品仓库批次关系
  1448. /// </summary>
  1449. /// <param name="queryJson"></param>
  1450. /// <returns></returns>
  1451. public string UpdateICSInventoryBatchEnable(string keyValue)
  1452. {
  1453. var queryParam = keyValue.ToJObject();
  1454. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1455. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1456. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1457. string msg = "";
  1458. string sql = string.Empty;
  1459. sql = @"UPDATE dbo.ICSInventoryBatchEnable set InvCode='{0}',WHCode='{1}',BatchEnable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
  1460. sql = string.Format(sql, queryParam["InvCode"].ToString(), queryParam["WHCode"].ToString(), queryParam["BatchEnable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  1461. try
  1462. {
  1463. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1464. {
  1465. }
  1466. else
  1467. {
  1468. msg = "修改失败";
  1469. }
  1470. }
  1471. catch (Exception ex)
  1472. {
  1473. throw new Exception(ex.Message);
  1474. }
  1475. return msg;
  1476. }
  1477. /// <summary>
  1478. /// 删除料品仓库批次关系
  1479. /// </summary>
  1480. /// <param name="keyValue">传入ID</param>
  1481. /// <returns></returns>
  1482. public string DeleteICSInventoryBatchEnable(string keyValue)
  1483. {
  1484. //站点信息
  1485. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1486. string msg = "";
  1487. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1488. string sql = string.Empty;
  1489. sql = string.Format(@"DELETE FROM dbo.ICSInventoryBatchEnable WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1490. try
  1491. {
  1492. SqlHelper.ExecuteNonQuery(sql);
  1493. }
  1494. catch (Exception ex)
  1495. {
  1496. throw new Exception(ex.Message);
  1497. }
  1498. return msg;
  1499. }
  1500. /// <summary>
  1501. /// 获取库位信息
  1502. /// </summary>
  1503. /// <param name="jqgridparam"></param>
  1504. /// <returns></returns>
  1505. public DataTable GetICSLocation(string queryJson, ref Pagination jqgridparam)
  1506. {
  1507. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1508. DataTable dt = new DataTable();
  1509. var queryParam = queryJson.ToJObject();
  1510. List<DbParameter> parameter = new List<DbParameter>();
  1511. string sql = @"select ID,LocationCode,LocationName,WHID,MUSER,MUSERName,MTIME,WorkPoint from ICSLocation where WorkPoint='{0}' ";
  1512. sql = string.Format(sql, WorkPoint);
  1513. if (!string.IsNullOrWhiteSpace(queryJson))
  1514. {
  1515. if (!string.IsNullOrWhiteSpace(queryParam["LocationCode"].ToString()))
  1516. {
  1517. sql += " and LocationCode like '%" + queryParam["LocationCode"].ToString() + "%' ";
  1518. }
  1519. }
  1520. //DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1521. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1522. }
  1523. /// <summary>
  1524. /// 新增料品仓库批次关系
  1525. /// </summary>
  1526. /// <param name="queryJson"></param>
  1527. /// <returns></returns>
  1528. public string InsertICSInventoryLocation(string keyValue, string keyValue2)
  1529. {
  1530. List<string> InvCodeList = keyValue.Substring(1, keyValue.Length - 3).Split(',').ToList<string>();
  1531. List<string> LocationCodeList = keyValue2.Substring(1, keyValue2.Length - 3).Split(',').ToList<string>();
  1532. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1533. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1534. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1535. string msg = "";
  1536. string sql = string.Empty;
  1537. try
  1538. {
  1539. foreach (var item in InvCodeList)
  1540. {
  1541. foreach (var itemwh in LocationCodeList)
  1542. {
  1543. sql += @"IF EXISTS(select InvCode,LocationCode from ICSInventoryLocation where InvCode={0} and LocationCode={1})
  1544. BEGIN
  1545. RAISERROR('',16,1);
  1546. RETURN
  1547. end
  1548. INSERT INTO dbo.ICSInventoryLocation
  1549. ( ID ,InvCode ,LocationCode ,Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
  1550. Values(NEWID(),{0},{1},'{2}',GETDATE(),'{3}','{4}','{5}')
  1551. ";
  1552. sql = string.Format(sql, item, itemwh, '1'.ToString(), MUSER, MUSERNAME, WorkPoint);
  1553. }
  1554. }
  1555. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1556. {
  1557. }
  1558. else
  1559. {
  1560. msg = "新增失败";
  1561. }
  1562. }
  1563. catch (Exception ex)
  1564. {
  1565. msg = ex.Message;
  1566. }
  1567. return msg;
  1568. }
  1569. /// <summary>
  1570. /// 修改料品库位绑定关系
  1571. /// </summary>
  1572. /// <param name="queryJson"></param>
  1573. /// <returns></returns>
  1574. public string UpdateICSInventoryLocation(string keyValue)
  1575. {
  1576. var queryParam = keyValue.ToJObject();
  1577. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1578. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1579. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1580. string msg = "";
  1581. string sql = string.Empty;
  1582. sql = @"UPDATE dbo.ICSInventoryLocation set InvCode='{0}',LocationCode='{1}',Enable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
  1583. sql = string.Format(sql, queryParam["InvCode"].ToString(), queryParam["LocationCode"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  1584. try
  1585. {
  1586. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1587. {
  1588. }
  1589. else
  1590. {
  1591. msg = "修改失败";
  1592. }
  1593. }
  1594. catch (Exception ex)
  1595. {
  1596. throw new Exception(ex.Message);
  1597. }
  1598. return msg;
  1599. }
  1600. /// <summary>
  1601. /// 删除料品仓库批次关系
  1602. /// </summary>
  1603. /// <param name="keyValue">传入ID</param>
  1604. /// <returns></returns>
  1605. public string DeleteICSInventoryLocation(string keyValue)
  1606. {
  1607. //站点信息
  1608. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1609. string msg = "";
  1610. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1611. string sql = string.Empty;
  1612. sql = string.Format(@"DELETE FROM dbo.ICSInventoryLocation WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1613. try
  1614. {
  1615. SqlHelper.ExecuteNonQuery(sql);
  1616. }
  1617. catch (Exception ex)
  1618. {
  1619. throw new Exception(ex.Message);
  1620. }
  1621. return msg;
  1622. }
  1623. /// <summary>
  1624. /// 新增包装、容器
  1625. /// </summary>
  1626. /// <param name="queryJson"></param>
  1627. /// <returns></returns>
  1628. public string InsertICSContainer(string keyValue)
  1629. {
  1630. string msg = "";
  1631. try
  1632. {
  1633. var queryParam = keyValue.ToJObject();
  1634. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1635. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1636. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1637. string sql = string.Empty;
  1638. sql = @"IF EXISTS(select ContainerCODE from ICSContainer where ContainerCODE='{1}' )
  1639. RAISERROR('{1}',16,1)
  1640. else
  1641. INSERT INTO dbo.ICSContainer
  1642. ( ID ,ContainerID ,ContainerCODE ,ContainerName,Memo,MTIME,MUSER ,MUSERName ,WorkPoint )
  1643. Values(NEWID(),'{0}','{1}','{2}','{3}',GETDATE(),'{4}','{5}','{6}')
  1644. ";
  1645. sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["ContainerCODE"].ToString(), queryParam["ContainerName"].ToString(), queryParam["Memo"].ToString(), MUSER, MUSERNAME, WorkPoint);
  1646. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1647. {
  1648. }
  1649. else
  1650. {
  1651. msg = "新增失败";
  1652. }
  1653. }
  1654. catch (Exception ex)
  1655. {
  1656. throw new Exception(ex.Message);
  1657. }
  1658. return msg;
  1659. }
  1660. /// <summary>
  1661. /// 修改包装、容器
  1662. /// </summary>
  1663. /// <param name="queryJson"></param>
  1664. /// <returns></returns>
  1665. public string UpdateICSContainer(string keyValue)
  1666. {
  1667. var queryParam = keyValue.ToJObject();
  1668. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1669. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1670. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1671. string msg = "";
  1672. string sql = string.Empty;
  1673. sql = @" IF EXISTS(select ContainerCODE from ICSContainer where ContainerCODE='{1}' )
  1674. RAISERROR('{1}',16,1)
  1675. UPDATE dbo.ICSContainer set ContainerID='{0}',ContainerCODE='{1}',ContainerName='{2}',Memo='{3}',MTIME=GETDATE(),MUSER='{4}',MUSERName='{5}',WorkPoint='{6}' WHERE ID='{7}'";
  1676. sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["ContainerCODE"].ToString(), queryParam["ContainerName"].ToString(), queryParam["Memo"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  1677. try
  1678. {
  1679. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1680. {
  1681. }
  1682. else
  1683. {
  1684. msg = "修改失败";
  1685. }
  1686. }
  1687. catch (Exception ex)
  1688. {
  1689. msg = ex.Message;
  1690. }
  1691. return msg;
  1692. }
  1693. /// <summary>
  1694. /// 删除包装、容器
  1695. /// </summary>
  1696. /// <param name="keyValue">传入ID</param>
  1697. /// <returns></returns>
  1698. public string DeleteICSContainer(string keyValue)
  1699. {
  1700. //站点信息
  1701. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1702. string msg = "";
  1703. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1704. string sql = string.Empty;
  1705. sql = string.Format(@"DELETE FROM dbo.ICSContainer WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1706. try
  1707. {
  1708. SqlHelper.ExecuteNonQuery(sql);
  1709. }
  1710. catch (Exception ex)
  1711. {
  1712. throw new Exception(ex.Message);
  1713. }
  1714. return msg;
  1715. }
  1716. /// <summary>
  1717. /// 新增包装、容器关联条码
  1718. /// </summary>
  1719. /// <param name="queryJson"></param>
  1720. /// <returns></returns>
  1721. public string InsertICSContainerLot(string keyValue)
  1722. {
  1723. var queryParam = keyValue.ToJObject();
  1724. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1725. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1726. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1727. string msg = "";
  1728. string sql = string.Empty;
  1729. sql = @"INSERT INTO dbo.ICSContainerLot
  1730. ( ID ,ContainerID ,LotNo ,MTIME,MUSER ,MUSERName ,WorkPoint )
  1731. Values(NEWID(),'{0}','{1}',getdate(),'{2}','{3}','{4}')
  1732. ";
  1733. sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["LotNo"].ToString(), MUSER, MUSERNAME, WorkPoint);
  1734. try
  1735. {
  1736. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1737. {
  1738. }
  1739. else
  1740. {
  1741. msg = "新增失败";
  1742. }
  1743. }
  1744. catch (Exception ex)
  1745. {
  1746. throw new Exception(ex.Message);
  1747. }
  1748. return msg;
  1749. }
  1750. /// <summary>
  1751. /// 修改包装、容器
  1752. /// </summary>
  1753. /// <param name="queryJson"></param>
  1754. /// <returns></returns>
  1755. public string UpdateICSContainerLot(string keyValue)
  1756. {
  1757. var queryParam = keyValue.ToJObject();
  1758. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1759. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1760. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1761. string msg = "";
  1762. string sql = string.Empty;
  1763. sql = @"UPDATE dbo.ICSContainerLot set ContainerID='{0}',LotNo='{1}',MTIME=GETDATE(),MUSER='{2}',MUSERName='{3}',WorkPoint='{4}' WHERE ID='{5}'";
  1764. sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["LotNo"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  1765. try
  1766. {
  1767. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1768. {
  1769. }
  1770. else
  1771. {
  1772. msg = "修改失败";
  1773. }
  1774. }
  1775. catch (Exception ex)
  1776. {
  1777. throw new Exception(ex.Message);
  1778. }
  1779. return msg;
  1780. }
  1781. /// <summary>
  1782. /// 删除包装、容器
  1783. /// </summary>
  1784. /// <param name="keyValue">传入ID</param>
  1785. /// <returns></returns>
  1786. public string DeleteICSContainerLot(string keyValue)
  1787. {
  1788. //站点信息
  1789. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1790. string msg = "";
  1791. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1792. string sql = string.Empty;
  1793. sql = string.Format(@"DELETE FROM dbo.ICSContainerLot WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1794. try
  1795. {
  1796. SqlHelper.ExecuteNonQuery(sql);
  1797. }
  1798. catch (Exception ex)
  1799. {
  1800. throw new Exception(ex.Message);
  1801. }
  1802. return msg;
  1803. }
  1804. /// <summary>
  1805. /// 获取料品信息
  1806. /// </summary>
  1807. /// <returns></returns>
  1808. public DataTable GetInvCode()
  1809. {
  1810. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1811. string sql = @"
  1812. select '' as InvCode,'' as InvName
  1813. union all
  1814. SELECT InvCode,InvName FROM ICSInventory WITH (NOLOCK) WHERE 1=1 ";
  1815. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  1816. if (role != "admin")
  1817. {
  1818. sql += " and b.WorkPoint='" + WorkPoint + "'";
  1819. }
  1820. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  1821. return dt;
  1822. }
  1823. /// <summary>
  1824. /// 获取不良代码信息
  1825. /// </summary>
  1826. /// <returns></returns>
  1827. public DataTable GetBCGroup()
  1828. {
  1829. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1830. string sql = @"select '' as ID,'' as BCGDesc
  1831. union all
  1832. SELECT ID,BCGDesc FROM ICSBadCodeGroup WITH (NOLOCK) WHERE 1=1 ";
  1833. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  1834. if (role != "admin")
  1835. {
  1836. sql += " and b.WorkPoint='" + WorkPoint + "'";
  1837. }
  1838. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  1839. return dt;
  1840. }
  1841. /// <summary>
  1842. /// 获取不良原因信息
  1843. /// </summary>
  1844. /// <returns></returns>
  1845. public DataTable BRGroupID()
  1846. {
  1847. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1848. string sql = @"select '' as ID,'' as BRGDesc
  1849. union all
  1850. SELECT ID,BRGDesc FROM ICSBadReasonGroup WITH (NOLOCK) WHERE 1=1 ";
  1851. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  1852. if (role != "admin")
  1853. {
  1854. sql += " and b.WorkPoint='" + WorkPoint + "'";
  1855. }
  1856. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  1857. return dt;
  1858. }
  1859. /// <summary>
  1860. /// 新增料品不良信息
  1861. /// </summary>
  1862. /// <param name="queryJson"></param>
  1863. /// <returns></returns>
  1864. public string InsertInventoryBadGroup(string keyValue)
  1865. {
  1866. var queryParam = keyValue.ToJObject();
  1867. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1868. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1869. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1870. string msg = "";
  1871. string sql = string.Empty;
  1872. sql = @"INSERT INTO dbo.ICSInventoryBadGroup
  1873. ( ID,InvCode,BCGroupID,BRGroupID,Enable,MUSER,MUSERName,MTIME,WorkPoint)
  1874. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}',getdate(),'{6}')";
  1875. sql = string.Format(sql, queryParam["InvCode"].ToString(), queryParam["BCGroupID"].ToString(), queryParam["BRGroupID"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint);
  1876. try
  1877. {
  1878. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1879. {
  1880. }
  1881. else
  1882. {
  1883. msg = "新增失败";
  1884. }
  1885. }
  1886. catch (Exception ex)
  1887. {
  1888. throw new Exception(ex.Message);
  1889. }
  1890. return msg;
  1891. }
  1892. /// <summary>
  1893. /// 修改料品不良信息
  1894. /// </summary>
  1895. /// <param name="queryJson"></param>
  1896. /// <returns></returns>
  1897. public string UpdateInventoryBadGroup(string keyValue)
  1898. {
  1899. var queryParam = keyValue.ToJObject();
  1900. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1901. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1902. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1903. string msg = "";
  1904. string sql = string.Empty;
  1905. sql = @"UPDATE dbo.ICSInventoryBadGroup set BCGroupID='{0}',BRGroupID='{1}',Enable='{2}',MUSER='{3}',MUSERName='{4}',MTIME=GetDate(),WorkPoint='{5}' WHERE ID='{6}'";
  1906. sql = string.Format(sql, queryParam["BCGroupID"].ToString(), queryParam["BRGroupID"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
  1907. try
  1908. {
  1909. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  1910. {
  1911. }
  1912. else
  1913. {
  1914. msg = "修改失败";
  1915. }
  1916. }
  1917. catch (Exception ex)
  1918. {
  1919. throw new Exception(ex.Message);
  1920. }
  1921. return msg;
  1922. }
  1923. /// <summary>
  1924. /// 删除料品不良信息
  1925. /// </summary>
  1926. /// <param name="keyValue">传入ID</param>
  1927. /// <returns></returns>
  1928. public string DeleteInventoryBadGroup(string keyValue)
  1929. {
  1930. //站点信息
  1931. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1932. string msg = "";
  1933. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1934. string sql = string.Empty;
  1935. sql = string.Format(@"DELETE FROM dbo.ICSInventoryBadGroup WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1936. try
  1937. {
  1938. SqlHelper.ExecuteNonQuery(sql);
  1939. }
  1940. catch (Exception ex)
  1941. {
  1942. throw new Exception(ex.Message);
  1943. }
  1944. return msg;
  1945. }
  1946. //库位导入
  1947. public string SetData_PR(String savePath)
  1948. {
  1949. //数据获取
  1950. try
  1951. {
  1952. int index = 1;
  1953. string msg = "";
  1954. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1955. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1956. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1957. SqlConnection conn = SqlHelper.GetDataCenterConn();
  1958. string sql = "";
  1959. int count = 0;
  1960. DataTable data = FileToExcel.ExcelToTable(savePath);
  1961. foreach (DataRow dr in data.Rows)
  1962. {
  1963. index++;
  1964. var StackCode = "";
  1965. var StackName = "";
  1966. //string GUID = Guid.NewGuid().ToString();
  1967. string KuFang = dr["库房编码"].ToString().Trim().ToUpper();
  1968. string Qu = dr["区域"].ToString().Trim().ToUpper();
  1969. string Pai = dr["区"].ToString().Trim().ToUpper();
  1970. string Jia = dr["货架"].ToString().Trim().ToUpper();
  1971. string Ceng = dr["层"].ToString().Trim().ToUpper();
  1972. string Ge = dr["列"].ToString().Trim().ToUpper();
  1973. if (KuFang == "" || KuFang == null)
  1974. {
  1975. throw new Exception("第 " + index + " 行库房编码不能为空!");
  1976. }
  1977. if (Qu == "" && Pai == "" && Jia == "" && Ceng == "" && Ge == "")
  1978. {
  1979. throw new Exception("第 " + index + " 区域、区、货架、层、列至少填写一项!");
  1980. }
  1981. string sqlWH = @"select ID from ICSWarehouse where WarehouseCode='{0}' and WorkPoint='{1}'";
  1982. sqlWH = string.Format(sqlWH, KuFang, WorkPoint);
  1983. DataTable dd = SqlHelper.CmdExecuteDataTable(sqlWH);
  1984. if (dd == null || dd.Rows.Count <= 0)
  1985. {
  1986. throw new Exception("库房编码: " + KuFang + " 不存在!");
  1987. }
  1988. string WHID = dd.Rows[0]["ID"].ToString();
  1989. StackCode = KuFang;
  1990. StackName = KuFang + "仓库";
  1991. if (Qu != "")
  1992. {
  1993. StackCode += "-" + Qu;
  1994. StackName += Qu + "区域";
  1995. }
  1996. if (Pai != "")
  1997. {
  1998. StackCode += "-" + Pai;
  1999. StackName += Pai + "区";
  2000. }
  2001. if (Jia != "")
  2002. {
  2003. StackCode += "-" + Jia;
  2004. StackName += Jia + "货架";
  2005. }
  2006. if (Ceng != "")
  2007. {
  2008. StackCode += "-" + Ceng;
  2009. StackName += Ceng + "层";
  2010. }
  2011. if (Ge != "")
  2012. {
  2013. StackCode += "-" + Ge;
  2014. StackName += Ge + "列";
  2015. }
  2016. string sqls = @"select LocationCode from ICSLocation where LocationCode='{0}' and WorkPoint='{1}'";
  2017. sqls = string.Format(sqls, StackCode, WorkPoint);
  2018. DataTable dnum = SqlHelper.CmdExecuteDataTable(sqls);
  2019. if (dnum != null && dnum.Rows.Count > 0)
  2020. {
  2021. throw new Exception("库位: " + StackCode + " 已存在!");
  2022. }
  2023. else
  2024. {
  2025. sql += @"Insert INto ICSLocation Values (newid(),'{0}','{1}','{2}','{3}','{4}',getdate(),'{5}','','{6}','{7}','{8}','{9}','{10}')";
  2026. }
  2027. sql = string.Format(sql, StackCode, StackName, WHID, MUSER, MUSERNAME, WorkPoint,Qu,Pai,Jia,Ceng,Ge);
  2028. }
  2029. count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2030. if (count > 0)
  2031. {
  2032. msg = "导入成功";
  2033. }
  2034. else
  2035. {
  2036. return "无有效的导入数据。";
  2037. }
  2038. return msg;
  2039. }
  2040. catch (Exception ex)
  2041. {
  2042. return ex.Message;
  2043. }
  2044. }
  2045. /// <summary>
  2046. ///启用的料品库位绑定关系
  2047. /// </summary>
  2048. public string EnableInventoryLocation(string keyValue)
  2049. {
  2050. //站点信息
  2051. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2052. string msg = "";
  2053. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2054. string sql = string.Empty;
  2055. sql = string.Format(@"update ICSInventoryLocation set Enable='1' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2056. try
  2057. {
  2058. SqlHelper.ExecuteNonQuery(sql);
  2059. }
  2060. catch (Exception ex)
  2061. {
  2062. throw new Exception(ex.Message);
  2063. }
  2064. return msg;
  2065. }
  2066. /// <summary>
  2067. ///禁用的料品库位绑定关系
  2068. /// </summary>
  2069. public string ForbiddenInventoryLocation(string keyValue)
  2070. {
  2071. //站点信息
  2072. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2073. string msg = "";
  2074. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2075. string sql = string.Empty;
  2076. sql = string.Format(@"update ICSInventoryLocation set Enable='0' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2077. try
  2078. {
  2079. SqlHelper.ExecuteNonQuery(sql);
  2080. }
  2081. catch (Exception ex)
  2082. {
  2083. throw new Exception(ex.Message);
  2084. }
  2085. return msg;
  2086. }
  2087. /// <summary>
  2088. ///启用的料品仓库绑定关系
  2089. /// </summary>
  2090. public string EnableBatchEnable(string keyValue)
  2091. {
  2092. //站点信息
  2093. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2094. string msg = "";
  2095. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2096. string sql = string.Empty;
  2097. sql = string.Format(@"update ICSInventoryBatchEnable set BatchEnable='1' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2098. try
  2099. {
  2100. SqlHelper.ExecuteNonQuery(sql);
  2101. }
  2102. catch (Exception ex)
  2103. {
  2104. throw new Exception(ex.Message);
  2105. }
  2106. return msg;
  2107. }
  2108. /// <summary>
  2109. ///禁用的料品仓库绑定关系
  2110. /// </summary>
  2111. public string ForbiddenBatchEnable(string keyValue)
  2112. {
  2113. //站点信息
  2114. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2115. string msg = "";
  2116. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2117. string sql = string.Empty;
  2118. sql = string.Format(@"update ICSInventoryBatchEnable set BatchEnable='0' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2119. try
  2120. {
  2121. SqlHelper.ExecuteNonQuery(sql);
  2122. }
  2123. catch (Exception ex)
  2124. {
  2125. throw new Exception(ex.Message);
  2126. }
  2127. return msg;
  2128. }
  2129. public string CreateLableDataSource(string Sys_LableDataSource)
  2130. {
  2131. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2132. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2133. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2134. string msg = "";
  2135. string sql = string.Empty;
  2136. string SqlTxt = "";
  2137. JArray res = (JArray)JsonConvert.DeserializeObject(Sys_LableDataSource);
  2138. foreach (var item in res)
  2139. {
  2140. JObject jo = (JObject)item;
  2141. if (jo["DbParas"].ToString().Trim() != "")
  2142. {
  2143. string[] dbvs = jo["DbParas"].ToString().Trim().Split(',');
  2144. List<string> vs = new List<string>();
  2145. foreach (string s in dbvs)
  2146. {
  2147. if (!string.IsNullOrEmpty(s))
  2148. {
  2149. vs.Add(s);
  2150. }
  2151. }
  2152. SqlTxt = string.Format(jo["FormatSqlTxt"].ToString(), vs.ToArray());
  2153. }
  2154. else
  2155. {
  2156. SqlTxt = jo["FormatSqlTxt"].ToString();
  2157. }
  2158. sql += @"INSERT INTO dbo.Sys_LableDataSource
  2159. (ID,WorkPointCode,OtherDataBaseID,WorkPointDataFlag,SysDataFlag,SqlTxt,SourceName,FormatSqlTxt,Paras,DbParas,LinkCols,CreateUserID,CreateDate,ModifyUserID,ModifyDate,Link2Cols )
  2160. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',getdate(),'{11}',getdate(),'{12}')";
  2161. 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());
  2162. }
  2163. try
  2164. {
  2165. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2166. {
  2167. }
  2168. else
  2169. {
  2170. msg = "新增失败";
  2171. }
  2172. }
  2173. catch (Exception ex)
  2174. {
  2175. throw new Exception(ex.Message);
  2176. }
  2177. return msg;
  2178. }
  2179. public DataTable GetTXT(string ID)
  2180. {
  2181. DataTable dt = new DataTable();
  2182. //var queryParam = queryJson.ToJObject();
  2183. List<DbParameter> parameter = new List<DbParameter>();
  2184. string sql = @"SELECT
  2185. ID,
  2186. WorkPointCode,
  2187. OtherDataBaseID,
  2188. WorkPointDataFlag,
  2189. SysDataFlag,
  2190. SqlTxt,
  2191. SourceName,
  2192. FormatSqlTxt,
  2193. Paras,
  2194. DbParas,
  2195. LinkCols,
  2196. CreateUserID,
  2197. CreateDate,
  2198. ModifyUserID,
  2199. ModifyDate,
  2200. Link2Cols
  2201. FROM
  2202. dbo.Sys_LableDataSource where ID='" + ID + "'";
  2203. return Repository().FindTableBySql(sql.ToString());
  2204. }
  2205. public string updateLableDataSource(string Sys_LableDataSource)
  2206. {
  2207. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2208. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2209. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2210. string msg = "";
  2211. string sql = string.Empty;
  2212. string SqlTxt = "";
  2213. JArray res = (JArray)JsonConvert.DeserializeObject(Sys_LableDataSource);
  2214. foreach (var item in res)
  2215. {
  2216. JObject jo = (JObject)item;
  2217. if (jo["DbParas"].ToString().Trim() != "")
  2218. {
  2219. string[] dbvs = jo["DbParas"].ToString().Trim().Split(',');
  2220. List<string> vs = new List<string>();
  2221. foreach (string s in dbvs)
  2222. {
  2223. if (!string.IsNullOrEmpty(s))
  2224. {
  2225. vs.Add(s);
  2226. }
  2227. }
  2228. SqlTxt = string.Format(jo["FormatSqlTxt"].ToString(), vs.ToArray());
  2229. }
  2230. else
  2231. {
  2232. SqlTxt = jo["FormatSqlTxt"].ToString();
  2233. }
  2234. 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}'";
  2235. 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());
  2236. }
  2237. try
  2238. {
  2239. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2240. {
  2241. }
  2242. else
  2243. {
  2244. msg = "修改失败";
  2245. }
  2246. }
  2247. catch (Exception ex)
  2248. {
  2249. throw new Exception(ex.Message);
  2250. }
  2251. return msg;
  2252. }
  2253. public string DeleteLableDataSource(string keyValue)
  2254. {
  2255. //站点信息
  2256. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2257. string msg = "";
  2258. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2259. string sql = string.Empty;
  2260. sql = string.Format(@"DELETE FROM dbo.Sys_LableDataSource WHERE ID IN ({0}) ", keyValue.TrimEnd(','));
  2261. try
  2262. {
  2263. SqlHelper.ExecuteNonQuery(sql);
  2264. }
  2265. catch (Exception ex)
  2266. {
  2267. throw new Exception(ex.Message);
  2268. }
  2269. return msg;
  2270. }
  2271. public DataTable GetLableType()
  2272. {
  2273. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2274. string sql = @"
  2275. select '' as F_ItemCode,'' as F_ItemName
  2276. union all
  2277. 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'";
  2278. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  2279. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2280. return dt;
  2281. }
  2282. public DataTable GetSys_LablesID()
  2283. {
  2284. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2285. string sql = @"
  2286. select '' as ID,'' as LableName
  2287. union all
  2288. select distinct ID,LableName from Sys_Lables";
  2289. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  2290. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2291. return dt;
  2292. }
  2293. public string CreateLables(string txtLableName, string sel_LableType, string sel_LableSourceID)
  2294. {
  2295. string UserId = NFine.Code.OperatorProvider.Provider.GetCurrent().UserId;
  2296. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2297. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2298. string msg = "";
  2299. string sql = string.Empty;
  2300. string LableCode = "";
  2301. string SqlTxt = string.Format(@"SELECT MAX(A.LableCode) AS LableCode FROM Sys_Lables A "); ;
  2302. DataSet ds = SqlHelper.GetDataSetBySql(SqlTxt);
  2303. DataTable dts = ds.Tables[0];
  2304. if (dts != null && dts.Rows.Count > 0)
  2305. {
  2306. string lot = dts.Rows[0]["LableCode"].ToString();
  2307. LableCode = (Convert.ToInt64(lot) + 1).ToString().PadLeft(5, '0');
  2308. }
  2309. else
  2310. {
  2311. LableCode = "00001";
  2312. }
  2313. sql += @" INSERT INTO dbo.Sys_Lables
  2314. (ID,WorkPointCode,LableType,LableCode,LableName,LableXml,LableSourceID,CreateUserID,CreateDate,ModifyUserID,ModifyDate,FileAddress )
  2315. Values(NEWID(),'{0}','{1}','{2}','{3}','','{4}','{5}',getdate(),'{6}',getdate(),'')";
  2316. sql = string.Format(sql, WorkPoint, sel_LableType, LableCode, txtLableName, sel_LableSourceID, UserId, UserId);
  2317. try
  2318. {
  2319. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2320. {
  2321. }
  2322. else
  2323. {
  2324. msg = "新增失败";
  2325. }
  2326. }
  2327. catch (Exception ex)
  2328. {
  2329. throw new Exception(ex.Message);
  2330. }
  2331. return msg;
  2332. }
  2333. public DataTable GetLabelTXT(string ID)
  2334. {
  2335. DataTable dt = new DataTable();
  2336. //var queryParam = queryJson.ToJObject();
  2337. List<DbParameter> parameter = new List<DbParameter>();
  2338. string sql = @"select ID,WorkPointCode,LableType,LableCode,LableName,LableXml,LableSourceID,CreateUserID,CreateDate,ModifyUserID,ModifyDate,FileAddress from Sys_Lables where ID='" + ID + "'";
  2339. return Repository().FindTableBySql(sql.ToString());
  2340. }
  2341. public string updateLables(string ID, string txtLableName, string sel_LableType, string sel_LableSourceID)
  2342. {
  2343. string UserId = NFine.Code.OperatorProvider.Provider.GetCurrent().UserId;
  2344. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2345. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2346. string msg = "";
  2347. string sql = string.Empty;
  2348. sql += @"update Sys_Lables set LableType='{0}' ,LableName='{1}' ,LableSourceID='{2}',ModifyUserID='{3}',ModifyDate=getdate() where ID='{4}'";
  2349. sql = string.Format(sql, sel_LableType, txtLableName, sel_LableSourceID, UserId, ID);
  2350. try
  2351. {
  2352. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2353. {
  2354. }
  2355. else
  2356. {
  2357. msg = "修改失败";
  2358. }
  2359. }
  2360. catch (Exception ex)
  2361. {
  2362. throw new Exception(ex.Message);
  2363. }
  2364. return msg;
  2365. }
  2366. public string DeleteICSLabelTemplate(string keyValue)
  2367. {
  2368. //站点信息
  2369. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2370. string msg = "";
  2371. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2372. string sql = string.Empty;
  2373. sql = string.Format(@"DELETE FROM dbo.Sys_Lables WHERE ID IN ({0}) ", keyValue.TrimEnd(','));
  2374. try
  2375. {
  2376. SqlHelper.ExecuteNonQuery(sql);
  2377. }
  2378. catch (Exception ex)
  2379. {
  2380. throw new Exception(ex.Message);
  2381. }
  2382. return msg;
  2383. }
  2384. //获取父容器
  2385. public DataTable GetContainerID()
  2386. {
  2387. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2388. string sql = @"
  2389. select '' as ID,'' as ContainerName
  2390. union all
  2391. SELECT DISTINCT a.ID,a.ContainerName FROM dbo.ICSContainer a ";
  2392. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  2393. if (role != "admin")
  2394. {
  2395. sql += " and b.WorkPoint in(" + WorkPoint + ")";
  2396. }
  2397. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2398. return dt;
  2399. }
  2400. public int UpLoadLabelFile(string ID, string fileName)
  2401. {
  2402. DataTable dt = new DataTable();
  2403. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2404. string sql = "";
  2405. sql = string.Format(@"update Sys_Lables set FileAddress='{0}'
  2406. where ID='{1}'",
  2407. fileName, ID);
  2408. StringBuilder Str = new StringBuilder(sql);
  2409. return Repository().ExecuteBySql(Str);
  2410. }
  2411. public int UpLoadFiles(string LotNo, string fileName)
  2412. {
  2413. DataTable dt = new DataTable();
  2414. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2415. string sql = "";
  2416. sql = string.Format(@"update ICSInspection set FileName='{0}'
  2417. where LotNo='{1}' and Enable='1'",
  2418. fileName, LotNo);
  2419. StringBuilder Str = new StringBuilder(sql);
  2420. return Repository().ExecuteBySql(Str);
  2421. }
  2422. //包装容器
  2423. public DataTable GetSendContainer(ref Pagination jqgridparam, string queryJson)
  2424. {
  2425. DataTable dt = new DataTable();
  2426. var queryParam = queryJson.ToJObject();
  2427. List<DbParameter> parameter = new List<DbParameter>();
  2428. string sql = @"select top 0 ID,ContainerID,ContainerCode,ContainerName,Memo,MUSER,MUSERName,MTIME,WorkPoint from ICSContainer";
  2429. sql += " WHERE 1=1";
  2430. sql = string.Format(sql);
  2431. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2432. }
  2433. public DataTable GetContainerInfo(string Code)
  2434. {
  2435. DataTable dt = new DataTable();
  2436. //var queryParam = queryJson.ToJObject();
  2437. List<DbParameter> parameter = new List<DbParameter>();
  2438. string sql = @" select ID,ContainerID,ContainerCode,ContainerName,Memo,MUSER,MUSERName,MTIME,WorkPoint from ICSContainer where ContainerCode='{0}'";
  2439. sql = string.Format(sql, Code);
  2440. return Repository().FindTableBySql(sql.ToString());
  2441. }
  2442. public DataTable GetBindContainerID(string SireCode)
  2443. {
  2444. DataTable dt = new DataTable();
  2445. //var queryParam = queryJson.ToJObject();
  2446. List<DbParameter> parameter = new List<DbParameter>();
  2447. string sql = @" select ID from ICSContainer where ContainerCode='{0}'";
  2448. sql = string.Format(sql, SireCode);
  2449. return Repository().FindTableBySql(sql.ToString());
  2450. }
  2451. public string BindingContainerID(string ICSMTDOC, string SireID)
  2452. {
  2453. string msg = "";
  2454. try
  2455. {
  2456. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2457. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2458. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2459. string sql = string.Empty;
  2460. JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
  2461. foreach (var item in res)
  2462. {
  2463. JObject jo = (JObject)item;
  2464. sql += @"
  2465. IF NOT EXISTS(SELECT ContainerCode FROM ICSContainer WHERE ContainerCode='{1}' )
  2466. BEGIN
  2467. RAISERROR('{1} ',16,1);
  2468. RETURN
  2469. END
  2470. IF EXISTS(select ContainerID from ICSContainer where ContainerCode='{1}' and isnull(ContainerID,'')<>'')
  2471. BEGIN
  2472. RAISERROR('{1}',16,1);
  2473. RETURN
  2474. END
  2475. update ICSContainer set ContainerID='{0}' WHERE ContainerCode = '{1}' and WorkPoint ='{2}'";
  2476. sql = string.Format(sql, SireID, jo["ContainerCode"].ToString(), WorkPoint);
  2477. }
  2478. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  2479. {
  2480. }
  2481. else
  2482. {
  2483. msg = "绑定失败";
  2484. }
  2485. }
  2486. catch (Exception ex)
  2487. {
  2488. msg = ex.Message;
  2489. }
  2490. return msg;
  2491. }
  2492. //包装容器关联条码
  2493. public DataTable GetSendContainerLot(ref Pagination jqgridparam, string queryJson)
  2494. {
  2495. DataTable dt = new DataTable();
  2496. var queryParam = queryJson.ToJObject();
  2497. List<DbParameter> parameter = new List<DbParameter>();
  2498. string sql = @"
  2499. select top 0 a.ID, a.LotNo,a.InvCode,b.InvName,b.InvStd,b.InvUnit, a.ProductDate,a.Quantity from ICSInventoryLot a
  2500. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint";
  2501. sql = string.Format(sql);
  2502. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2503. }
  2504. public DataTable GetContainerLotInfo(string LotNo)
  2505. {
  2506. DataTable dt = new DataTable();
  2507. //var queryParam = queryJson.ToJObject();
  2508. List<DbParameter> parameter = new List<DbParameter>();
  2509. string sql = @" select a.ID, a.LotNo,a.InvCode,b.InvName,b.InvStd,b.InvUnit, a.ProductDate,a.Quantity from ICSInventoryLot a
  2510. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint where a.LotNo='{0}'";
  2511. sql = string.Format(sql, LotNo);
  2512. return Repository().FindTableBySql(sql.ToString());
  2513. }
  2514. public string BindingContainerLotID(string ICSMTDOC, string SireID, string SireCode)
  2515. {
  2516. string msg = "";
  2517. try
  2518. {
  2519. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2520. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2521. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2522. string sql = string.Empty;
  2523. JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
  2524. foreach (var item in res)
  2525. {
  2526. JObject jo = (JObject)item;
  2527. sql += @"
  2528. IF NOT EXISTS(SELECT ContainerCode FROM ICSContainer WHERE ContainerCode='{5}')
  2529. BEGIN
  2530. RAISERROR('{5} ',16,1);
  2531. RETURN
  2532. END
  2533. IF NOT EXISTS(select LotNo from ICSInventoryLot where LotNo='{1}')
  2534. BEGIN
  2535. RAISERROR('{1}',16,1);
  2536. RETURN
  2537. END
  2538. IF EXISTS(select LotNo from ICSContainerLot where LotNo ='{1}')
  2539. BEGIN
  2540. RAISERROR('{1}',16,1);
  2541. RETURN
  2542. END
  2543. INSERT INTO ICSContainerLot
  2544. (ID,ContainerID,LotNo,MUSER,MUSERName,WorkPoint,MTIME )
  2545. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',getdate())";
  2546. sql = string.Format(sql, SireID, jo["LotNo"].ToString(), MUSER, MUSERNAME, WorkPoint, SireCode);
  2547. }
  2548. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  2549. {
  2550. }
  2551. else
  2552. {
  2553. msg = "绑定失败";
  2554. }
  2555. }
  2556. catch (Exception ex)
  2557. {
  2558. msg = ex.Message;
  2559. }
  2560. return msg;
  2561. }
  2562. /// <summary>
  2563. /// 删除站点
  2564. /// </summary>
  2565. /// <param name="keyValue">传入ID</param>
  2566. /// <returns></returns>
  2567. public string DeleteWorkPoint(string keyValue)
  2568. {
  2569. //站点信息
  2570. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2571. string msg = "";
  2572. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2573. string sql = string.Empty;
  2574. sql = string.Format(@"DELETE FROM dbo.sys_WorkPoint WHERE ID IN ({0}) ", keyValue.TrimEnd(','), WorkPoint);
  2575. try
  2576. {
  2577. SqlHelper.ExecuteNonQuery(sql);
  2578. }
  2579. catch (Exception ex)
  2580. {
  2581. throw new Exception(ex.Message);
  2582. }
  2583. return msg;
  2584. }
  2585. /// <summary>
  2586. /// 新增站点
  2587. /// </summary>
  2588. /// <param name="queryJson"></param>
  2589. /// <returns></returns>
  2590. public string InsertWorkPoint(string keyValue)
  2591. {
  2592. var queryParam = keyValue.ToJObject();
  2593. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2594. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2595. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2596. string msg = "";
  2597. string sql = string.Empty;
  2598. string pwd = SqlHelper.ToMd5(queryParam["DataBasePwd"].ToString());
  2599. sql = @"INSERT INTO dbo.sys_WorkPoint
  2600. ( ID ,WorkPointCode ,WorkPointName ,ServerName,DataBaseName,DataBaseUser,DataBasePwd, StartFlag,CreateDate,CreateUserCode )
  2601. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}',GETDATE(),'{7}')
  2602. ";
  2603. sql = string.Format(sql, queryParam["WorkPointCode"].ToString(), queryParam["WorkPointName"].ToString(), queryParam["ServerName"].ToString(),
  2604. queryParam["DataBaseName"].ToString(), queryParam["DataBaseUser"].ToString(), pwd, queryParam["StartFlag"].ToString(), MUSER);
  2605. try
  2606. {
  2607. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2608. {
  2609. }
  2610. else
  2611. {
  2612. msg = "新增失败";
  2613. }
  2614. }
  2615. catch (Exception ex)
  2616. {
  2617. throw new Exception(ex.Message);
  2618. }
  2619. return msg;
  2620. }
  2621. /// <summary>
  2622. /// 修改站点
  2623. /// </summary>
  2624. /// <param name="queryJson"></param>
  2625. /// <returns></returns>
  2626. public string UpdateWorkPoint(string keyValue)
  2627. {
  2628. var queryParam = keyValue.ToJObject();
  2629. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2630. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2631. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2632. string msg = "";
  2633. string pwd = SqlHelper.ToMd5(queryParam["DataBasePwd"].ToString());
  2634. string sql = string.Empty;
  2635. sql = @"UPDATE dbo.sys_WorkPoint set WorkPointCode='{0}',WorkPointName='{1}',ServerName='{2}',DataBaseName='{3}',StartFlag='{4}'
  2636. ,DataBaseUser='{5}',DataBasePwd='{6}',ModifyDate=GETDATE(),ModifyUserCode='{7}' WHERE ID='{8}'";
  2637. sql = string.Format(sql, queryParam["WorkPointCode"].ToString(), queryParam["WorkPointName"].ToString(), queryParam["ServerName"].ToString(),
  2638. queryParam["DataBaseName"].ToString(), queryParam["StartFlag"].ToString(), queryParam["DataBaseUser"].ToString(), pwd
  2639. , MUSER, queryParam["ID"].ToString());
  2640. try
  2641. {
  2642. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2643. {
  2644. }
  2645. else
  2646. {
  2647. msg = "修改失败";
  2648. }
  2649. }
  2650. catch (Exception ex)
  2651. {
  2652. throw new Exception(ex.Message);
  2653. }
  2654. return msg;
  2655. }
  2656. public Sys_WorkPoint GetWorkPoint(string Id)
  2657. {
  2658. Sys_WorkPoint model = new Sys_WorkPoint();
  2659. string sql = string.Empty;
  2660. sql = string.Format(@"SELECT ID,
  2661. WorkPointCode,
  2662. WorkPointName,
  2663. ServerName,
  2664. DataBaseName,
  2665. DataBaseUser,
  2666. DataBasePwd,
  2667. StartFlag,
  2668. CreateUserCode,
  2669. CreateDate,
  2670. ModifyUserCode,
  2671. ModifyDate
  2672. FROM Sys_WorkPoint
  2673. WHERE ID='{0}'", Id);
  2674. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2675. if (dt != null && dt.Rows.Count > 0)
  2676. {
  2677. model.ID = dt.Rows[0]["ID"].ToString();
  2678. model.WorkPointCode = dt.Rows[0]["WorkPointCode"].ToString();
  2679. model.WorkPointName = dt.Rows[0]["WorkPointName"].ToString();
  2680. model.ServerName = dt.Rows[0]["ServerName"].ToString();
  2681. model.DataBaseName = dt.Rows[0]["DataBaseName"].ToString();
  2682. model.DataBaseUser = dt.Rows[0]["DataBaseUser"].ToString();
  2683. model.DataBasePwd = SqlHelper.FromMd5(dt.Rows[0]["DataBasePwd"].ToString());
  2684. model.StartFlag = dt.Rows[0]["StartFlag"].ToString();
  2685. }
  2686. return model;
  2687. }
  2688. public DataTable GetICSInventoryLotInfo(string ID)
  2689. {
  2690. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2691. DataTable dt = new DataTable();
  2692. //var queryParam = queryJson.ToJObject();
  2693. List<DbParameter> parameter = new List<DbParameter>();
  2694. string sql = @" SELECT a.ID,
  2695. a.LotNo,
  2696. a.InvCode,
  2697. a.ProductDate,
  2698. a.ExpirationDate,
  2699. a.Quantity,
  2700. a.Amount,
  2701. a.ExtensionID,
  2702. a.Type,
  2703. a.PrintTimes,
  2704. a.LastPrintUser,
  2705. a.LastPrintTime,
  2706. a.MUSER,
  2707. a.MUSERName,
  2708. a.MTIME,
  2709. a.WorkPoint,
  2710. a.EATTRIBUTE1,
  2711. b.InvName,
  2712. b.InvUnit,
  2713. c.Enable
  2714. FROM
  2715. dbo.ICSInventoryLot a left join ICSInventory b on a.InvCode=b.InvCode AND a.WorkPoint=b.WorkPoint
  2716. left join ICSInspection c on a.LotNo=c.LotNo AND a.WorkPoint=b.WorkPoint and c.Enable='1'
  2717. WHERE a.ID='" + ID + "'";
  2718. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2719. return Repository().FindTableBySql(sql.ToString());
  2720. }
  2721. public int UpdateExpirationDate(string ID, string ExpirationDate, string Inv,string LotNo, string InvCode, string Quantity)
  2722. {
  2723. decimal QualifiedQuantity = 0;
  2724. decimal UnqualifiedQuantity = 0;
  2725. if (Inv=="1"){QualifiedQuantity = Convert.ToDecimal(Quantity);}else {UnqualifiedQuantity = Convert.ToDecimal(Quantity); }
  2726. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2727. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2728. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2729. string sqls = string.Empty;
  2730. sqls = @"update ICSInspection set Enable='0' WHERE LotNO='{0}' and Enable='1' and WorkPoint='{1}'";
  2731. sqls = string.Format(sqls, LotNo, WorkPoint);
  2732. SqlHelper.CmdExecuteNonQueryLi(sqls);
  2733. string sql = string.Empty;
  2734. sql += @"UPDATE ICSInventoryLot SET ExpirationDate='{0}' where ID='{1}' AND WorkPoint='{2}'";
  2735. sql += @"INSERT INTO dbo.ICSInspection
  2736. ( ID ,LotNo ,InvCode ,Quantity,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,Type,Result,ExpirationDate,Enable,MUSER,MUSERName,MTIME,WorkPoint )
  2737. Values(NEWID(),'{3}','{4}','{5}','{6}','{7}',0,'4','{8}','{0}','1','{9}','{10}',GETDATE(),'{2}')";
  2738. sql = string.Format(sql, ExpirationDate,ID, WorkPoint, LotNo, InvCode, Quantity, QualifiedQuantity, UnqualifiedQuantity, Inv, MUSER, MUSERNAME);
  2739. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2740. return count;
  2741. }
  2742. //修改多语言
  2743. public string UpdateSys_Language(string keyValue)
  2744. {
  2745. var queryParam = keyValue.ToJObject();
  2746. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2747. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2748. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2749. string msg = "";
  2750. string sql = string.Empty;
  2751. sql = @"UPDATE Sys_Language set Code='{0}',CnValue='{1}',TwValue='{2}',EnValue='{3}' WHERE ID='{4}'";
  2752. sql = string.Format(sql, queryParam["Code"].ToString(), queryParam["CnValue"].ToString(), queryParam["TwValue"].ToString(), queryParam["EnValue"].ToString(), queryParam["ID"].ToString());
  2753. try
  2754. {
  2755. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2756. {
  2757. }
  2758. else
  2759. {
  2760. msg = "修改失败";
  2761. }
  2762. }
  2763. catch (Exception ex)
  2764. {
  2765. throw new Exception(ex.Message);
  2766. }
  2767. return msg;
  2768. }
  2769. //新增多语言
  2770. public string InsertSys_Language(string keyValue)
  2771. {
  2772. var queryParam = keyValue.ToJObject();
  2773. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2774. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2775. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2776. string msg = "";
  2777. string sql = string.Empty;
  2778. sql = @" IF EXISTS(SELECT * FROM Sys_Language WHERE Code='{0}' )
  2779. begin
  2780. RAISERROR('',16,1)
  2781. end
  2782. INSERT INTO Sys_Language
  2783. ( ID ,Code ,CnValue ,TwValue,EnValue )
  2784. Values(NEWID(),'{0}','{1}','{2}','{3}')
  2785. ";
  2786. sql = string.Format(sql, queryParam["Code"].ToString(), queryParam["CnValue"].ToString(), queryParam["TwValue"].ToString(), queryParam["EnValue"].ToString());
  2787. try
  2788. {
  2789. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2790. {
  2791. }
  2792. else
  2793. {
  2794. msg = "新增失败";
  2795. }
  2796. }
  2797. catch (Exception ex)
  2798. {
  2799. throw new Exception(ex.Message);
  2800. }
  2801. return msg;
  2802. }
  2803. public string GetSerialCode(string workPointCode, string tbName, string colName, string Pre, int numLen)
  2804. {
  2805. string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}";
  2806. sql = string.Format(sql, new object[] { workPointCode, tbName, colName, Pre, numLen });
  2807. return DbHelper.ExecuteScalar(CommandType.Text, sql).ToString();
  2808. }
  2809. public DataTable GetSys_Language(string ID)
  2810. {
  2811. DataTable dt = new DataTable();
  2812. //var queryParam = queryJson.ToJObject();
  2813. List<DbParameter> parameter = new List<DbParameter>();
  2814. string sql = @"select ID,Code,CnValue,TwValue,EnValue from Sys_Language
  2815. WHERE 1 =1 and ID='" + ID + "' ";
  2816. return Repository().FindTableBySql(sql.ToString());
  2817. }
  2818. /// <summary>
  2819. /// 删除多语言
  2820. /// </summary>
  2821. /// <param name="keyValue">传入ID</param>
  2822. /// <returns></returns>
  2823. public string DeleteSys_Language(string keyValue)
  2824. {
  2825. string msg = "";
  2826. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2827. string sql = string.Empty;
  2828. sql = string.Format(@"DELETE FROM Sys_Language WHERE ID IN ({0})", keyValue.TrimEnd(','));
  2829. try
  2830. {
  2831. SqlHelper.ExecuteNonQuery(sql);
  2832. }
  2833. catch (Exception ex)
  2834. {
  2835. throw new Exception(ex.Message);
  2836. }
  2837. return msg;
  2838. }
  2839. //料品检验项目
  2840. public DataTable GetICSInventoryInspectionGroup(ref Pagination jqgridparam, string queryJson)
  2841. {
  2842. DataTable dt = new DataTable();
  2843. var queryParam = queryJson.ToJObject();
  2844. List<DbParameter> parameter = new List<DbParameter>();
  2845. string sql = @"select ID,InvCode,GroupCode,GroupName,
  2846. case when Enable='1' then '是' else '否' end as Enable,
  2847. MUSER,MUSERName,MTIME,WorkPoint from ICSInventoryInspectionGroup ";
  2848. sql += " WHERE 1=1";
  2849. if (!string.IsNullOrWhiteSpace(queryJson))
  2850. {
  2851. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2852. {
  2853. sql += " and InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2854. }
  2855. if (!string.IsNullOrWhiteSpace(queryParam["GroupCode"].ToString()))
  2856. {
  2857. sql += " and GroupCode like '%" + queryParam["GroupCode"].ToString() + "%' ";
  2858. }
  2859. if (!string.IsNullOrWhiteSpace(queryParam["GroupName"].ToString()))
  2860. {
  2861. sql += " and GroupName like '%" + queryParam["GroupName"].ToString() + "%' ";
  2862. }
  2863. }
  2864. sql = string.Format(sql);
  2865. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2866. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2867. }
  2868. //料品检验项目子表
  2869. public DataTable ICSInventoryInspectionList(string ID, ref Pagination jqgridparam)
  2870. {
  2871. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2872. DataTable dt = new DataTable();
  2873. //var queryParam = queryJson.ToJObject();
  2874. List<DbParameter> parameter = new List<DbParameter>();
  2875. string sql = @" select ID,InvGroupID,ListCode,ListName,Unit,SetValueMax, SetValueMin,
  2876. CASE WHEN Enable=0 THEN '否' else '是' END Enable,
  2877. MUSERName,MTIME,WorkPoint from ICSInventoryInspectionList
  2878. WHERE InvGroupID='" + ID + "'";
  2879. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2880. }
  2881. // 删除料品检验项目子表
  2882. public string DeleteICSInventoryInspectionGroup(string keyValue)
  2883. {
  2884. //站点信息
  2885. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2886. string msg = "";
  2887. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  2888. string sql = string.Empty;
  2889. sql += string.Format(@"DELETE FROM dbo.ICSInventoryInspectionGroup WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2890. sql += string.Format(@"DELETE FROM dbo.ICSInventoryInspectionList WHERE InvGroupID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  2891. try
  2892. {
  2893. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  2894. {
  2895. }
  2896. }
  2897. catch (Exception ex)
  2898. {
  2899. throw new Exception(ex.Message);
  2900. }
  2901. return msg;
  2902. }
  2903. public DataTable Getinv(string invcode, ref Pagination jqgridparam)
  2904. {
  2905. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2906. List<DbParameter> parameter = new List<DbParameter>();
  2907. DataTable table = new DataTable();
  2908. string wherestr = "";
  2909. if (!string.IsNullOrEmpty(invcode))
  2910. {
  2911. wherestr += " and invcode like '%" + invcode + "%'";
  2912. }
  2913. string sql = "select ID,InvCode,InvName,InvDesc,InvUnit,WorkPoint from ICSInventory where workpoint='" + WorkPoint + "'" + wherestr;
  2914. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2915. }
  2916. public DataTable GetGroupCode()
  2917. {
  2918. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2919. string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
  2920. string sql = @"select '' as ID,'' as GroupName
  2921. union all
  2922. SELECT distinct ID,GroupName FROM ICSInspectionGroup where WorkPoint='{0}'";
  2923. sql = string.Format(sql, WorkPoint);
  2924. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2925. return dt;
  2926. }
  2927. public void DeleteINvItem(string ID)
  2928. {
  2929. string sql = "DELETE FROM dbo.ICSInventoryInspectionList WHERE ID='" + ID + "'";
  2930. SqlHelper.ExecuteNonQuery(sql);
  2931. }
  2932. public DataTable GetICSInventoryInspectionList(string ListCode, ref Pagination jqgridparam)
  2933. {
  2934. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2935. DataTable dt = new DataTable();
  2936. //var queryParam = queryJson.ToJObject();
  2937. List<DbParameter> parameter = new List<DbParameter>();
  2938. string sql = @"select ID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable,MUSERName,MTIME from ICSInventoryInspectionList
  2939. WHERE ListCode='" + ListCode + "' ";
  2940. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2941. }
  2942. public DataTable GetInspectionListInfo(string ID)
  2943. {
  2944. DataTable dt = new DataTable();
  2945. //var queryParam = queryJson.ToJObject();
  2946. List<DbParameter> parameter = new List<DbParameter>();
  2947. string sql = @"
  2948. select ID,ListCode,ListName,Unit,SetValueMax,SetValueMin, CASE WHEN Enable=0 THEN '否' else '是' END Enable
  2949. from ICSInspectionList where GroupID='{0}'";
  2950. sql = string.Format(sql, ID);
  2951. return Repository().FindTableBySql(sql.ToString());
  2952. }
  2953. //新增
  2954. public void SubICSInventoryInspectionGroupAdd(ICSInventoryInspectionGroup main, string ID, string InvCode)
  2955. {
  2956. string sql = string.Empty;
  2957. string sqls = string.Empty;
  2958. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2959. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2960. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2961. string NewID = Common.GuId();
  2962. List<ICSInventoryInspectionGroup> list_Item1 = new List<ICSInventoryInspectionGroup>();
  2963. if (main.arrayShellFabricItem != null)
  2964. {
  2965. list_Item1 = JsonConvert.DeserializeObject<List<ICSInventoryInspectionGroup>>(main.arrayShellFabricItem);
  2966. }
  2967. string connString = SqlHelper.DataCenterConnString;
  2968. SqlConnection conn = new SqlConnection(connString);
  2969. conn.Open();
  2970. SqlTransaction sqlTran = conn.BeginTransaction();
  2971. SqlCommand cmd = new SqlCommand();
  2972. cmd.Transaction = sqlTran;
  2973. cmd.Connection = conn;
  2974. sql = @"
  2975. INSERT INTO dbo.ICSInventoryInspectionGroup
  2976. ( ID ,InvCode ,GroupCode ,GroupName ,
  2977. Enable ,MUSER ,MUSERName ,MTIME ,WorkPoint )
  2978. SELECT '{0}','{1}',GroupCode,GroupName,Enable,'{2}','{3}',getdate(),'{4}'
  2979. FROM dbo.ICSInspectionGroup
  2980. WHERE ID='{5}'";
  2981. sql = string.Format(sql, NewID, InvCode, MUSER, MUSERNAME, WorkPoint, ID);
  2982. try
  2983. {
  2984. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  2985. {
  2986. foreach (ICSInventoryInspectionGroup Item in list_Item1)
  2987. {
  2988. sqls = @"
  2989. INSERT INTO dbo.ICSInventoryInspectionList
  2990. ( ID ,InvGroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable , MTIME,MUSER ,MUSERName ,WorkPoint )
  2991. Values(@ID,'{0}',@ListCode,@ListName,@Unit,@SetValueMax,@SetValueMin,@Enable,GETDATE(),'{1}','{2}','{3}')";
  2992. sqls = string.Format(sqls, NewID, MUSER, MUSERNAME, WorkPoint);
  2993. SqlParameter[] sp_Item = {
  2994. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  2995. new SqlParameter("@ListCode",DbType.String){ Value= Item.ListCode},
  2996. new SqlParameter("@ListName",DbType.String){ Value= Item.ListName},
  2997. new SqlParameter("@Unit",DbType.String){ Value= Item.Unit},
  2998. new SqlParameter("@SetValueMax",DbType.String){ Value= Item.SetValueMax},
  2999. new SqlParameter("@SetValueMin",DbType.String){ Value= Item.SetValueMin},
  3000. new SqlParameter("@Enable",DbType.String){ Value= Item.Enable},
  3001. };
  3002. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  3003. }
  3004. cmd.Transaction.Commit();
  3005. }
  3006. }
  3007. catch (Exception ex)
  3008. {
  3009. cmd.Transaction.Rollback();
  3010. throw new Exception(ex.Message);
  3011. }
  3012. finally
  3013. {
  3014. if (conn.State == ConnectionState.Open)
  3015. {
  3016. conn.Close();
  3017. }
  3018. conn.Dispose();
  3019. }
  3020. }
  3021. public DataTable GetICSInventoryInspectionList2(string BID)
  3022. {
  3023. string sql = string.Empty;
  3024. DataTable dt = null;
  3025. sql = string.Format(@" select ID,ListCode,ListName,Unit,SetValueMax,SetValueMin, CASE WHEN Enable='1' THEN '是' else '否' END Enable from ICSInventoryInspectionList where InvGroupID='{0}'", BID);
  3026. dt = SqlHelper.GetDataTableBySql(sql);
  3027. return dt;
  3028. }
  3029. //修改
  3030. public void UpdateICSInventoryInspectionGroup(ICSInventoryInspectionGroup main, string BID, string ID, string InvCode)
  3031. {
  3032. string sql = string.Empty;
  3033. string sqls = string.Empty;
  3034. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3035. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3036. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3037. List<ICSInventoryInspectionGroup> list_Item1 = new List<ICSInventoryInspectionGroup>();
  3038. if (main.arrayShellFabricItem != null)
  3039. {
  3040. list_Item1 = JsonConvert.DeserializeObject<List<ICSInventoryInspectionGroup>>(main.arrayShellFabricItem);
  3041. }
  3042. string connString = SqlHelper.DataCenterConnString;
  3043. SqlConnection conn = new SqlConnection(connString);
  3044. conn.Open();
  3045. SqlTransaction sqlTran = conn.BeginTransaction();
  3046. SqlCommand cmd = new SqlCommand();
  3047. cmd.Transaction = sqlTran;
  3048. cmd.Connection = conn;
  3049. sql = @"update b set b.InvCode='{0}',b.GroupCode=a.GroupCode,b.GroupName=a.GroupName,b.Enable=a.Enable,b.MTIME=GETDATE(),b.MUSER='{1}',b.MUSERName='{2}',b.WorkPoint='{3}' from ICSInspectionGroup a ,ICSInventoryInspectionGroup b where a.ID='{4}' and b.ID='{5}'";
  3050. sql = string.Format(sql, InvCode, MUSER, MUSERNAME, WorkPoint, ID,BID);
  3051. try
  3052. {
  3053. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  3054. {
  3055. foreach (ICSInventoryInspectionGroup Item in list_Item1)
  3056. {
  3057. sqls = @" IF NOT EXISTS(SELECT * FROM ICSInventoryInspectionList WHERE ID=@ID)
  3058. BEGIN
  3059. INSERT INTO dbo.ICSInventoryInspectionList
  3060. ( ID ,InvGroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable , MTIME,MUSER ,MUSERName ,WorkPoint )
  3061. Values(@ID,'{0}',@ListCode,@ListName,@Unit,@SetValueMax,@SetValueMin,@Enable,GETDATE(),'{1}','{2}','{3}')
  3062. END
  3063. ELSE
  3064. BEGIN
  3065. UPDATE dbo.ICSInventoryInspectionList set InvGroupID='{0}',ListCode=@ListCode,ListName=@ListName,Unit=@Unit,SetValueMax=@SetValueMax,SetValueMin=@SetValueMin,Enable=@Enable,MTIME=GETDATE(),MUSER='{1}',MUSERName='{2}',WorkPoint='{3}' WHERE ID=@ID
  3066. end
  3067. ";
  3068. sqls = string.Format(sqls, BID, MUSER, MUSERNAME, WorkPoint);
  3069. SqlParameter[] sp_Item = {
  3070. new SqlParameter("@ID",DbType.String){ Value= Item.ID},
  3071. new SqlParameter("@ListCode",DbType.String){ Value= Item.ListCode},
  3072. new SqlParameter("@ListName",DbType.String){ Value= Item.ListName},
  3073. new SqlParameter("@Unit",DbType.String){ Value= Item.Unit},
  3074. new SqlParameter("@SetValueMax",DbType.String){ Value= Item.SetValueMax},
  3075. new SqlParameter("@SetValueMin",DbType.String){ Value= Item.SetValueMin},
  3076. new SqlParameter("@Enable",DbType.String){ Value= Item.Enable},
  3077. };
  3078. SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
  3079. }
  3080. cmd.Transaction.Commit();
  3081. }
  3082. }
  3083. catch (Exception ex)
  3084. {
  3085. cmd.Transaction.Rollback();
  3086. throw new Exception(ex.Message);
  3087. }
  3088. finally
  3089. {
  3090. if (conn.State == ConnectionState.Open)
  3091. {
  3092. conn.Close();
  3093. }
  3094. conn.Dispose();
  3095. }
  3096. }
  3097. }
  3098. }