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.

581 lines
25 KiB

  1. using Newtonsoft.Json.Linq;
  2. using Newtonsoft.Json;
  3. using NFine.Code;
  4. using NFine.Data.Extensions;
  5. using NFine.Domain._03_Entity.SRM;
  6. using NFine.Repository;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Configuration;
  10. using System.Data;
  11. using System.Data.Common;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using System.Threading;
  16. using System.Reflection.Emit;
  17. namespace NFine.Application.DHAY
  18. {
  19. public class ICSAccessoriesMOIApplyApp : RepositoryFactory<ICSVendor>
  20. {
  21. public static DataTable Invmes = new DataTable();
  22. #region 删除辅料材料出库单
  23. public string DeleteICSMOApply(string keyValue)
  24. {
  25. //站点信息
  26. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  27. string msg = "";
  28. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  29. string sql = string.Empty;
  30. sql += string.Format(@"DELETE FROM dbo.ICSMOApply WHERE ApplyCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  31. try
  32. {
  33. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  34. {
  35. }
  36. }
  37. catch (Exception ex)
  38. {
  39. throw new Exception(ex.Message);
  40. }
  41. return msg;
  42. }
  43. #endregion
  44. #region 保存发料信息
  45. public string SaveICSMOApply(string ICSASN)
  46. {
  47. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  48. string UserName = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  49. string msg = "";
  50. List<JsonData> parsedData = JsonConvert.DeserializeObject<List<JsonData>>(ICSASN);
  51. string sql = "";
  52. string Colspan = "";
  53. string str1 = "";
  54. List<string> ExtensionIDList = new List<string>();
  55. // 获取解析后的数据
  56. JsonData data = parsedData[0];
  57. foreach (var detail in data.Detail)
  58. {
  59. Colspan ="~" + detail.Batch + "~~~~~~~~~~~~";
  60. string sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  61. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  62. bool flag = true;
  63. foreach (var item in ExtensionIDList)
  64. {
  65. if (item == Colspan + WorkPoint)
  66. {
  67. flag = false;
  68. }
  69. }
  70. if (ExtensionID == null && flag == true)
  71. {
  72. str1 = Guid.NewGuid().ToString();
  73. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  74. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  75. str1, Colspan, "", detail.Batch, "", "", "", "", "", "", "", "", "", "", "", "",
  76. data.User, UserName, WorkPoint);
  77. }
  78. else if (ExtensionID != null)
  79. {
  80. str1 = ExtensionID.ToString();
  81. }
  82. ExtensionIDList.Add(Colspan + WorkPoint);
  83. sql += "INSERT INTO ICSMOApply(ID,ApplyCode,WHCode,Sequence,InvCode,Quantity,CreatePerson,CreateDateTime,WorkPoint,Status,ApplyID,ApplyDetailID,ExtensionID,MUSER,MUSERName,MTIME,EATTRIBUTE,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE10,SourceCode,Type)" +
  84. " select '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',newID(),newID(),'{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','1'";
  85. sql = string.Format(sql, detail.ID, data.Code, detail.WHCode, detail.Sequence, detail.InvCode, detail.Quantity, data.User, data.MTIME, WorkPoint, '1', str1, data.User, UserName, data.MTIME, data.Dept, data.CodeType, data.ApplyNegCode, data.Custmer, data.Remarks, detail.DetailReamrk, data.SYproject, "杂发", detail.SourceCode);
  86. }
  87. try
  88. {
  89. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  90. {
  91. }
  92. }
  93. catch (Exception ex)
  94. {
  95. msg=ex.Message;
  96. }
  97. return msg;
  98. }
  99. #region 辅料材料出库单主表信息查询
  100. public DataTable GetICSMOApply(ref Pagination jqgridparam, string queryJson)
  101. {
  102. DataTable dt = new DataTable();
  103. List<DbParameter> parameter = new List<DbParameter>();
  104. var queryParam = queryJson.ToJObject();
  105. string sql = @" SELECT DISTINCT
  106. a.ApplyCode
  107. ,a.Status
  108. ,a.CreatePerson
  109. ,a.CreateDateTime
  110. ,a.MUSER
  111. ,a.MUSERName
  112. ,a.SourceCode
  113. ,a.EATTRIBUTE
  114. ,a.EATTRIBUTE2
  115. ,a.EATTRIBUTE3
  116. ,a.EATTRIBUTE4
  117. ,a.EATTRIBUTE5
  118. ,a.EATTRIBUTE7
  119. ,a.EATTRIBUTE8
  120. ,a.EATTRIBUTE9
  121. ,a.EATTRIBUTE10
  122. from dbo.ICSMOApply a
  123. left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint where 1=1";
  124. if (!string.IsNullOrWhiteSpace(queryJson))
  125. {
  126. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  127. {
  128. sql += " and a.ApplyCode like '%" + queryParam["POCode"].ToString() + "%' ";
  129. }
  130. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  131. {
  132. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  133. }
  134. if (!string.IsNullOrWhiteSpace(queryParam["CreatedBy"].ToString()))
  135. {
  136. sql += " and a.CreatePerson like '%" + queryParam["CreatedBy"].ToString() + "%' ";
  137. }
  138. if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
  139. {
  140. sql += " and convert(nvarchar(20),a.CreateDateTime,23) >= '" + queryParam["TimeFrom"].ToString() + "' ";
  141. }
  142. if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
  143. {
  144. sql += " and convert(nvarchar(20),a.CreateDateTime,23) <= '" + queryParam["TimeArrive"].ToString() + "' ";
  145. }
  146. }
  147. sql = string.Format(sql);
  148. DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  149. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  150. }
  151. #endregion
  152. #region 辅料材料出库单主表信息查询
  153. public DataTable GetICSMOApplyByApplyCode(string ApplyCode)
  154. {
  155. DataTable dt = new DataTable();
  156. List<DbParameter> parameter = new List<DbParameter>();
  157. string sql = @" SELECT DISTINCT
  158. a.ApplyCode
  159. ,a.Status
  160. ,a.CreatePerson
  161. ,a.CreateDateTime
  162. ,a.MUSER
  163. ,a.MUSERName
  164. ,a.SourceCode
  165. ,a.EATTRIBUTE
  166. ,a.EATTRIBUTE2
  167. ,a.EATTRIBUTE3
  168. ,a.EATTRIBUTE4
  169. ,a.EATTRIBUTE5
  170. ,a.EATTRIBUTE7
  171. ,a.EATTRIBUTE8
  172. ,a.EATTRIBUTE9
  173. ,a.EATTRIBUTE10
  174. from dbo.ICSMOApply a
  175. left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
  176. WHERE a.ApplyCode='{0}'";
  177. sql = string.Format(sql, ApplyCode);
  178. return Repository().FindTableBySql(sql.ToString());
  179. }
  180. #endregion
  181. #region 主页面子表信息查询
  182. public DataTable GetICSMOApplyDetail(string ApplyCode, string queryJson, ref Pagination jqgridparam)
  183. {
  184. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  185. DataTable dt = new DataTable();
  186. var queryParam = queryJson.ToJObject();
  187. //var queryParam = queryJson.ToJObject();
  188. List<DbParameter> parameter = new List<DbParameter>();
  189. string sql = @" select a.ID
  190. ,a.ApplyCode
  191. ,a.Sequence
  192. ,a.InvCode
  193. ,a.Quantity
  194. ,a.Amount
  195. ,a.ExtensionID
  196. ,a.MUSER
  197. ,a.MUSERName
  198. ,a.MTIME
  199. ,a.SourceCode
  200. ,IssueQuantity
  201. ,f.Colspan
  202. ,f.ProjectCode
  203. ,f.BatchCode
  204. ,f.Version
  205. ,f.Brand
  206. ,f.cFree1
  207. ,f.cFree2
  208. ,f.cFree3
  209. ,f.cFree4
  210. ,f.cFree5
  211. ,f.cFree6
  212. ,f.cFree7
  213. ,f.cFree8
  214. ,f.cFree9
  215. ,f.cFree10
  216. ,a.EATTRIBUTE
  217. ,a.EATTRIBUTE2
  218. ,a.EATTRIBUTE3
  219. ,a.EATTRIBUTE4
  220. ,a.EATTRIBUTE5
  221. ,a.EATTRIBUTE6
  222. ,a.EATTRIBUTE7
  223. ,a.EATTRIBUTE8
  224. ,a.EATTRIBUTE9
  225. ,a.EATTRIBUTE10
  226. from ICSMOApply a
  227. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  228. WHERE a.ApplyCode='" + ApplyCode + "' ";
  229. if (!string.IsNullOrWhiteSpace(queryJson))
  230. {
  231. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  232. {
  233. sql += " and a.ApplyCode like '%" + queryParam["POCode"].ToString() + "%' ";
  234. }
  235. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  236. {
  237. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  238. }
  239. if (!string.IsNullOrWhiteSpace(queryParam["CreatedBy"].ToString()))
  240. {
  241. sql += " and a.CreatePerson like '%" + queryParam["CreatedBy"].ToString() + "%' ";
  242. }
  243. if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
  244. {
  245. sql += " and convert(nvarchar(20),a.CreateDateTime,23) >= '" + queryParam["TimeFrom"].ToString() + "' ";
  246. }
  247. if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
  248. {
  249. sql += " and convert(nvarchar(20),a.CreateDateTime,23) <= '" + queryParam["TimeArrive"].ToString() + "' ";
  250. }
  251. }
  252. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  253. }
  254. #endregion
  255. public string DeleteICSMOApplyByCode(string keyValue)
  256. {
  257. //站点信息
  258. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  259. string msg = "";
  260. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  261. string sql = string.Empty;
  262. sql += string.Format(@"IF EXISTS( select ID from ICSMOApply where ApplyCode IN ({0}) and WorkPoint ='{1}' AND IssueQuantity>0)
  263. BEGIN
  264. RAISERROR('',16,1);
  265. RETURN
  266. END
  267. DELETE FROM dbo.ICSMOApply WHERE ApplyCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  268. try
  269. {
  270. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  271. {
  272. }
  273. }
  274. catch (Exception ex)
  275. {
  276. msg = ex.Message;
  277. }
  278. return msg;
  279. }
  280. /// <summary>
  281. /// 审核单据
  282. /// </summary>
  283. /// <param name="keyValue"></param>
  284. /// <returns></returns>
  285. public string ApproveICSMOApplyByCode(string keyValue)
  286. {
  287. //站点信息
  288. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  289. string msg = "";
  290. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  291. string sql = string.Empty;
  292. sql += string.Format(@"IF EXISTS( select ID from ICSMOApply where ApplyCode IN ({0}) and WorkPoint ='{1}' AND status!='1')
  293. BEGIN
  294. RAISERROR('',16,1);
  295. RETURN
  296. END
  297. UPDATE dbo.ICSMOApply SET Status='2' WHERE ApplyCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  298. try
  299. {
  300. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  301. {
  302. }
  303. }
  304. catch (Exception ex)
  305. {
  306. msg=ex.Message;
  307. }
  308. return msg;
  309. }
  310. /// <summary>
  311. /// 弃审单据
  312. /// </summary>
  313. /// <param name="keyValue"></param>
  314. /// <returns></returns>
  315. public string AbandonICSMOApplyByCode(string keyValue)
  316. {
  317. //站点信息
  318. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  319. string msg = "";
  320. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  321. string sql = string.Empty;
  322. sql += string.Format(@"IF EXISTS( select ID from ICSMOApply where ApplyCode IN ({0}) and WorkPoint ='{1}' AND status!='2')
  323. BEGIN
  324. RAISERROR('!',16,1);
  325. RETURN
  326. END
  327. IF EXISTS( select ID from ICSMOApply where ApplyCode IN ({0}) and WorkPoint ='{1}' AND IssueQuantity>0)
  328. BEGIN
  329. RAISERROR('',16,1);
  330. RETURN
  331. END
  332. UPDATE dbo.ICSMOApply SET Status='1' WHERE ApplyCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  333. try
  334. {
  335. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  336. {
  337. }
  338. }
  339. catch (Exception ex)
  340. {
  341. msg = ex.Message;
  342. }
  343. return msg;
  344. }
  345. /// <summary>
  346. /// 关闭单据
  347. /// </summary>
  348. /// <param name="keyValue"></param>
  349. /// <returns></returns>
  350. public string CloseICSMOApplyByCode(string keyValue)
  351. {
  352. //站点信息
  353. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  354. string msg = "";
  355. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  356. string sql = string.Empty;
  357. sql += string.Format(@"IF EXISTS( select ID from ICSMOApply where ApplyCode IN ({0}) and WorkPoint ='{1}' AND IssueQuantity>0)
  358. BEGIN
  359. RAISERROR('',16,1);
  360. RETURN
  361. END
  362. UPDATE dbo.ICSMOApply SET Status='3' WHERE ApplyCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  363. try
  364. {
  365. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  366. {
  367. }
  368. }
  369. catch (Exception ex)
  370. {
  371. msg=ex.Message;
  372. }
  373. return msg;
  374. }
  375. public string GetBidCode(string WorkPoint)
  376. {
  377. WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  378. string BidCide = string.Empty;
  379. if (!string.IsNullOrEmpty(WorkPoint))
  380. {
  381. string DateString = DateTime.Now.ToString("yyyyMMdd");
  382. string Pre = "CLCK" + DateString;
  383. BidCide = GetSerialCode(WorkPoint, "ICSMOApply", "ApplyCode", Pre, 4);
  384. }
  385. if (!string.IsNullOrWhiteSpace(BidCide))
  386. {
  387. string sqlISHave = @"SELECT ApplyCode FROM ICSMOApply a
  388. WHERE a.ApplyCode = '{0}'";
  389. sqlISHave = string.Format(sqlISHave, BidCide);
  390. DataTable dtIsHave = SqlHelper.GetDataTableBySql(sqlISHave);
  391. if (dtIsHave.Rows.Count > 0)
  392. {
  393. throw new Exception("单号已存在!");
  394. }
  395. }
  396. return BidCide;
  397. }
  398. public string GetSerialCode(string workPointCode, string tbName, string colName, string Pre, int numLen)
  399. {
  400. string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}";
  401. sql = string.Format(sql, new object[] { workPointCode, tbName, colName, Pre, numLen });
  402. return SqlHelper.ExecuteScalar(sql).ToString();
  403. }
  404. public string UpdateICSMOApply(string ICSASN)
  405. {
  406. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  407. string UserName = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  408. string msg = "";
  409. List<JsonData> parsedData = JsonConvert.DeserializeObject<List<JsonData>>(ICSASN);
  410. string sql = "";
  411. string Colspan = "";
  412. string str1 = "";
  413. List<string> ExtensionIDList = new List<string>();
  414. // 获取解析后的数据
  415. JsonData data = parsedData[0];
  416. foreach (var detail in data.Detail)
  417. {
  418. Colspan = "~" + detail.Batch + "~~~~~~~~~~~~";
  419. string sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
  420. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  421. bool flag = true;
  422. foreach (var item in ExtensionIDList)
  423. {
  424. if (item == Colspan + WorkPoint)
  425. {
  426. flag = false;
  427. }
  428. }
  429. if (ExtensionID == null && flag == true)
  430. {
  431. str1 = Guid.NewGuid().ToString();
  432. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  433. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  434. str1, Colspan, "", detail.Batch, "", "", "", "", "", "", "", "", "", "", "", "",
  435. data.User, UserName, WorkPoint);
  436. }
  437. else if (ExtensionID != null)
  438. {
  439. str1 = ExtensionID.ToString();
  440. }
  441. ExtensionIDList.Add(Colspan + WorkPoint);
  442. sql += @" IF NOT EXISTS(SELECT * FROM dbo.ICSMOApply WHERE ID='{0}')
  443. BEGIN
  444. INSERT INTO ICSMOApply(ID,ApplyCode,WHCode,Sequence,InvCode,Quantity,CreatePerson,CreateDateTime,WorkPoint,Status,ApplyID,ApplyDetailID,ExtensionID,MUSER,MUSERName,MTIME,EATTRIBUTE,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE10,SourceCode,Type)
  445. select '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',newID(),newID(),'{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','1'
  446. END
  447. ELSE
  448. BEGIN
  449. UPDATE dbo.ICSMOApply
  450. SET WHCode='{2}',InvCode='{4}',Quantity='{5}',CreatePerson='{6}',
  451. CreateDateTime='{7}' ,MTIME='{13}',EATTRIBUTE='{14}',EATTRIBUTE2='{15}',EATTRIBUTE3='{16}',EATTRIBUTE4='{17}',EATTRIBUTE5='{18}',EATTRIBUTE6='{19}',EATTRIBUTE7='{20}',SourceCode='{22}'
  452. WHERE ID='{0}'
  453. END";
  454. sql = string.Format(sql, detail.ID, data.Code, detail.WHCode, detail.Sequence, detail.InvCode, detail.Quantity, data.User, data.MTIME, WorkPoint, '1', str1, data.User, UserName, data.MTIME, data.Dept, data.CodeType, data.ApplyNegCode, data.Custmer, data.Remarks, detail.DetailReamrk, data.SYproject, "杂发", detail.SourceCode);
  455. }
  456. try
  457. {
  458. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  459. {
  460. }
  461. }
  462. catch (Exception ex)
  463. {
  464. msg = ex.Message;
  465. }
  466. return msg;
  467. }
  468. public DataTable GetICSReturnTemporary(string rfqno)
  469. {
  470. string sql = @"SELECT
  471. a.ID,
  472. a.ApplyCode,
  473. a.InvCode,
  474. b.InvName,
  475. b.InvStd,
  476. a.Quantity,
  477. a.SourceCode,
  478. a.WHCode,
  479. a.WHCode as WHCodeHHH,
  480. a.EATTRIBUTE6,
  481. a.SourceCode,
  482. a.Quantity
  483. ,f.BatchCode as Batch
  484. ,c.WarehouseName as WHCodeName
  485. FROM ICSMOApply a
  486. LEFT JOIN ICSInventory b ON a.InvCode = b.InvCode
  487. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  488. LEFT JOIN dbo.ICSWarehouse c ON a.WHCode=c.WarehouseCode AND a.WorkPoint=c.WorkPoint
  489. where a.ApplyCode='" + rfqno + "'";
  490. DataTable table = Repository().FindDataSetBySql(sql).Tables[0];
  491. DataTable dtCloned = table.Clone();
  492. foreach (DataColumn col in dtCloned.Columns)
  493. {
  494. col.DataType = typeof(string);
  495. }
  496. foreach (DataRow row in table.Rows)
  497. {
  498. DataRow newrow = dtCloned.NewRow();
  499. foreach (DataColumn column in dtCloned.Columns)
  500. {
  501. newrow[column.ColumnName] = row[column.ColumnName].ToString();
  502. }
  503. dtCloned.Rows.Add(newrow);
  504. }
  505. if (Invmes.Rows.Count > 0)
  506. {
  507. dtCloned.Merge(Invmes, false);
  508. }
  509. return dtCloned;
  510. }
  511. // 定义一个类来表示 JSON 数据的结构
  512. public class JsonData
  513. {
  514. public string Dept { get; set; }
  515. public string CodeType { get; set; }
  516. public string ApplyNegCode { get; set; }
  517. public string Custmer { get; set; }
  518. public string Remarks { get; set; }
  519. public string Code { get; set; }
  520. public string MTIME { get; set; }
  521. public string User { get; set; }
  522. public string SYproject { get; set; }
  523. public List<JsonDetail> Detail { get; set; }
  524. }
  525. public class JsonDetail
  526. {
  527. public string ID;
  528. public int Sequence { get; set; }
  529. public string InvCode { get; set; }
  530. public decimal Quantity { get; set; }
  531. public string WHCode { get; set; }
  532. /// <summary>
  533. /// 工单号
  534. /// </summary>
  535. public string SourceCode { get; set; }
  536. public string DetailReamrk { get; set; }
  537. public string Batch { get; set; }
  538. }
  539. #endregion
  540. }
  541. }