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

500 lines
26 KiB

  1. using ICSSoft.Common;
  2. using ICSSoft.Entity;
  3. using Newtonsoft.Json;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Data.SqlClient;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace ICSSoft.DataProject
  12. {
  13. /// <summary>
  14. /// 销售出库红字
  15. /// </summary>
  16. public class SalesShipmentDocNegative
  17. {
  18. private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  19. private static string connString = System.Configuration.ConfigurationManager.AppSettings["ERPConnStr"];
  20. private static string ERPDB = System.Configuration.ConfigurationManager.AppSettings["ERPDB"];
  21. private static string Type = System.Configuration.ConfigurationManager.AppSettings["Type"];
  22. string bustype = string.Empty;
  23. /// <summary>
  24. ///获取销售出库单红字
  25. /// </summary>
  26. /// <param name="infos"></param>
  27. /// <returns></returns>
  28. public string Get(List<ICSSalesShipmentDocNegative> infos)
  29. {
  30. List<ICSSalesShipmentDocNegative> szJson = new List<ICSSalesShipmentDocNegative>();
  31. DataTable dt = null;
  32. string json = "";
  33. if (infos.Count <= 0)
  34. {
  35. throw new Exception("传送数据为空!");
  36. }
  37. string res = string.Empty;
  38. SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
  39. conn.Open();
  40. SqlTransaction sqlTran = conn.BeginTransaction();
  41. SqlCommand cmd = new SqlCommand();
  42. cmd.Transaction = sqlTran;
  43. cmd.Connection = conn;
  44. try
  45. {
  46. string sql = string.Empty;
  47. foreach (ICSSalesShipmentDocNegative info in infos)
  48. {
  49. if (info.MTime < new DateTime(2000, 01, 01))
  50. throw new Exception("请输入正确的操作时间:" + info.MTime);
  51. sql = @"select a.ID,a.cCode,a.cCusCode,c.cCusName,a.cWhCode,d.cWhName,e.cordercode ,a.cMaker ,a.dnmaketime ,a.cHandler ,a.dnverifytime ,
  52. b.AutoID,b.iRSRowNO ,b.cInvCode ,b.iQuantity ,b.iNum,e.AutoID
  53. from rdrecord32 a
  54. inner join rdrecords32 b on a.ID=b.ID
  55. left join DispatchLists e on a.cDLCode=e.DLID
  56. left join Customer c on a.cCusCode=c.cCusCode
  57. left join Warehouse d on a.cWhCode=d.cWhCode WHERE 1=1 and b.iquantity<0 ";
  58. if (!string.IsNullOrWhiteSpace(info.SDNNEGCode))
  59. {
  60. sql += " and a.cCode='{0}'";
  61. }
  62. if (!string.IsNullOrWhiteSpace(info.MTime.ToString()))
  63. {
  64. sql += " and ISNULL(a.dnmodifytime ,ISNULL(a.dnverifytime , ISNULL(a.dnmodifytime , a.dnmaketime )))>='{1}'";
  65. }
  66. if (!string.IsNullOrWhiteSpace(info.User))
  67. {
  68. sql += "and a.CMAKER='{2}'";
  69. }
  70. sql = string.Format(sql, info.SDNNEGCode, info.MTime, info.User);
  71. dt = DBHelper.SQlReturnData(sql, cmd);
  72. if (dt.Rows.Count <= 0 || dt == null)
  73. throw new Exception("红字销售出库单号:" + info.SDNNEGCode + ",无信息!");
  74. json = JsonConvert.SerializeObject(dt);
  75. }
  76. cmd.Transaction.Commit();
  77. return json;
  78. }
  79. catch (Exception ex)
  80. {
  81. cmd.Transaction.Rollback();
  82. log.Error(ex.Message);
  83. throw new Exception(ex.Message);
  84. }
  85. finally
  86. {
  87. if (conn.State == ConnectionState.Open)
  88. {
  89. conn.Close();
  90. }
  91. conn.Dispose();
  92. }
  93. }
  94. /// <summary>
  95. /// 创建销售出库单红字
  96. /// </summary>
  97. /// <param name="Bills"></param>
  98. /// <returns></returns>
  99. public string CreateSalesShipmentDocNegative(List<ICSSalesShipmentDocNegative> Bills)
  100. {
  101. string sql = "";
  102. string msg = "";
  103. DataTable dt = null;
  104. int iFatherId = 0;
  105. int iChildId = 0;
  106. string iFatherIdTwo = "";
  107. int num = 0;
  108. //bool ResultFlag = false;
  109. SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
  110. conn.Open();
  111. SqlTransaction sqlTran = conn.BeginTransaction();
  112. SqlCommand cmd = new SqlCommand();
  113. cmd.Transaction = sqlTran;
  114. cmd.Connection = conn;
  115. VouchKey key = new VouchKey();
  116. try
  117. {
  118. if (Bills.Count <= 0)
  119. {
  120. throw new Exception("传送数据为空!");
  121. }
  122. LogInfo(Bills);
  123. foreach (ICSSalesShipmentDocNegative head in Bills)
  124. {
  125. #region 检查 发货单状态
  126. sql = @"SELECT a.DLID,a.cBusType,c.cRdCode,a.cSTCode,b.AutoID,b.irowno,a.cPersonCode,a.cCusCode,b.iDLsID,
  127. a.cMemo,a.cShipAddress,a.cDepCode,cCusInvName,b.cBatch,a.caddcode,a.cCloser,a.cVerifier FROM dbo.DispatchList a INNER JOIN
  128. dbo.DispatchLists b ON a.DLID=b.DLID
  129. LEFT JOIN dbo.SaleType c ON c.cSTCode=a.cSTCode
  130. WHERE a.cDLCode ='" + head.SDNRTCode + "'";
  131. cmd.CommandText = sql;
  132. DataTable dtDisCheck = DBHelper.SQlReturnData(sql, cmd);
  133. if (dtDisCheck != null && dtDisCheck.Rows.Count > 0)
  134. {
  135. foreach (DataRow item in dtDisCheck.Rows)
  136. {
  137. if (!string.IsNullOrEmpty(item["cCloser"].ToString()))
  138. {
  139. log.Info("DLID:" + head.ID);
  140. throw new Exception("ERP发货单已关闭,无法发货!发货单号:" + head.SDNNEGCode);
  141. }
  142. }
  143. bustype = dtDisCheck.Rows[0]["cBusType"].ToString();
  144. }
  145. else
  146. {
  147. throw new Exception("销售发货单单号:" + head.ID + "在ERP内不存在!");
  148. }
  149. #endregion
  150. #region 检验发货单数量
  151. foreach (ICSSalesShipmentDocNegatives body in head.details)
  152. {
  153. sql = "SELECT isnull(fOutQuantity,0) as fOutQuantity,ABS(iQuantity) as iQuantity FROM dbo.DispatchLists WHERE AutoID='" + body.SDNRTDetailID + "'";
  154. DataTable dtfOutQty = DBHelper.SQlReturnData(sql, cmd);
  155. if (dtfOutQty != null && dtfOutQty.Rows.Count > 0)
  156. {
  157. decimal fOutQty = Convert.ToDecimal(dtfOutQty.Rows[0]["fOutQuantity"]);
  158. decimal iQuantity = Convert.ToDecimal(dtfOutQty.Rows[0]["iQuantity"]);
  159. if (fOutQty + body.Quantity > iQuantity)
  160. {
  161. throw new Exception("可出库数量超过发货单表体出库数量!");
  162. }
  163. }
  164. else
  165. {
  166. throw new Exception("发货单表体不存在!");
  167. }
  168. }
  169. #endregion
  170. #region 红字销售出库单表头
  171. num = head.details.Count();
  172. DateTime time = DateTime.Now;
  173. Dictionary<string, int> dic = DBHelper.GetAllCode("" + ERPDB + "", "ShipmentDoc", "" + num + "");
  174. iFatherId = Convert.ToInt32(dic["iFatherId"].ToString());
  175. iChildId = Convert.ToInt32(dic["iChildId"].ToString());
  176. DateTime date = DateTime.Now;
  177. string iBaseCodeLen = DBHelper.GetAllRDCode("0303", "" + time + "", "admin");
  178. sql = @"INSERT INTO dbo.rdrecord32
  179. ( ID ,bRdFlag ,cVouchType ,cBusType ,cSource ,cBusCode ,cWhCode ,
  180. dDate ,cCode ,cRdCode ,cDepCode ,cPersonCode ,cSTCode ,cCusCode ,
  181. cDLCode ,cHandler ,cMemo ,bTransFlag ,cMaker ,cDefine1 ,cDefine2 ,
  182. cDefine3 ,cDefine4 ,cDefine5 ,cDefine6 ,cDefine7 ,cDefine8 ,cDefine9 ,
  183. cDefine10 ,dVeriDate ,bpufirst ,biafirst ,VT_ID ,bIsSTQc ,cDefine11 ,
  184. cDefine12 ,cDefine13 ,cDefine14 ,cDefine15 ,cDefine16 ,cShipAddress ,
  185. caddcode ,bOMFirst ,bFromPreYear ,bIsComplement ,iDiscountTaxType ,
  186. ireturncount ,iverifystate ,iswfcontrolled ,dnmaketime ,dnverifytime ,
  187. iPrintCount ,cinvoicecompany)
  188. SELECT @ID,0,32,a.cBusType,'',a.cDLCode,@cWhCode,
  189. CONVERT(NVARCHAR(15),GETDATE(),23),@cCode,'21',a.cDepCode,a.cPersonCode,a.cSTCode,a.cCusCode,
  190. a.DLID,@cHandler,a.cMemo,0,@cMaker,a.cDefine1,a.cDefine2,
  191. a.cDefine3,a.cDefine4,a.cDefine5,a.cDefine6,a.cDefine7,a.cDefine8,a.cDefine9,
  192. a.cDefine10,CONVERT(NVARCHAR(15),GETDATE(),23),0,0,@VT_ID,0,a.cDefine11,
  193. a.cDefine12,a.cDefine13,a.cDefine14,a.cDefine15,a.cDefine16,a.cShipAddress,
  194. a.caddcode,null,0,0,0,
  195. 0,0,0,GETDATE(),GETDATE(),
  196. 0,a.cinvoicecompany
  197. FROM dbo.DispatchList a WHERE a.cDLCode ='" + head.SDNRTCode + "'";
  198. cmd.Parameters.Clear();
  199. cmd.Parameters.Add(new SqlParameter("@ID", iFatherId));
  200. cmd.Parameters.Add(new SqlParameter("@cWhCode", head.WHCode));
  201. cmd.Parameters.Add(new SqlParameter("@cCode", iBaseCodeLen));
  202. cmd.Parameters.Add(new SqlParameter("@cDepCode", ""));
  203. cmd.Parameters.Add(new SqlParameter("@cHandler", head.User));
  204. cmd.Parameters.Add(new SqlParameter("@cMaker", head.User));
  205. cmd.Parameters.Add(new SqlParameter("@VT_ID", iChildId));
  206. //cmd.Parameters.Add(new SqlParameter("@dDate", data.dMate));
  207. cmd.CommandText = sql;
  208. try
  209. {
  210. int count = cmd.ExecuteNonQuery();
  211. if (count <= 0)
  212. {
  213. log.Error("生成红字销售出库单表头失败,受影响行数<=0;");
  214. throw new Exception("生成红字销售出库单表头失败,受影响行数<=0;");
  215. }
  216. }
  217. catch (Exception ex)
  218. {
  219. log.Error("生成红字销售出库单表头失败!销售出库单号:" + head.SDNNEGCode + ";异常:" + ex.Message + ";SQL:\r\n" + sql, ex);
  220. throw new Exception("生成红字销售出库单表头失败!销售出库单号:" + head.SDNNEGCode + ";异常:" + ex.Message + ";SQL:\r\n" + sql, ex);
  221. }
  222. #endregion
  223. #region 红字销售出库单表体
  224. foreach (ICSSalesShipmentDocNegatives body in head.details)
  225. {
  226. //iChildId -= 1;
  227. ////if (head.IsReturn == "1")
  228. ////{
  229. //body.Quantity = -body.Quantity;
  230. //}
  231. //else
  232. //{
  233. //判断物料批号与现存量表批号是否一致、数量不能超过现存量物料数量
  234. //sql = @"SELECT cBatch,iQuantity from CurrentStock WHERE cInvCode='" + body.InvCode + "'AND cBatch='" + "" + "'and cWhCode='" + head.WHCode + "'";
  235. //DataTable dtItem = DBHelper.SQlReturnData(sql, cmd);
  236. //if (dtItem != null && dtItem.Rows.Count > 0)
  237. //{
  238. // //if (!dtItem.Rows[0]["cBatch"].ToString().Equals(body.cBatch))
  239. // //{
  240. // // throw new Exception("物料条码的批号与U8现存量物料批号不一致,物料:" + body.cInvCode);
  241. // //}
  242. // if (Convert.ToDecimal(dtItem.Rows[0]["iQuantity"].ToString()) < body.Quantity)
  243. // {
  244. // throw new Exception("物料条码的数量大于U8现存量物料数量,物料:" + body.InvCode);
  245. // }
  246. //}
  247. //else
  248. //{
  249. // throw new Exception("物料:" + body.InvCode + "在现存量表中不存在!");
  250. //}
  251. //}
  252. sql = @"INSERT INTO dbo.rdrecords32
  253. ( AutoID ,ID ,cInvCode ,iQuantity ,cBatch ,iFlag ,
  254. cDefine22 ,cDefine23 ,cDefine24 ,cDefine25 ,cDefine26 ,
  255. cDefine27 ,cItem_class ,cItemCode ,iDLsID ,iNQuantity ,
  256. cDefine28 ,cDefine29 ,cDefine30 ,cDefine31 ,cDefine32 ,
  257. cDefine33 ,cDefine34 ,cDefine35 ,cDefine36 ,cDefine37 ,
  258. bLPUseFree ,iRSRowNO ,iOriTrackID ,ccusinvcode,ccusinvname,bCosting ,bVMIUsed ,
  259. cbdlcode ,iExpiratDateCalcu ,iorderdid ,iordertype ,
  260. iordercode ,iorderseq ,ipesodid ,ipesotype ,cpesocode ,
  261. ipesoseq ,isodid ,isotype ,csocode ,isoseq ,irowno ,
  262. bIAcreatebill ,bsaleoutcreatebill ,isaleoutid ,bneedbill,iposflag )
  263. SELECT @AutoID,@ID,@cInvCode,@iQuantity,@cBatch,0,
  264. a.cDefine22,a.cDefine23,a.cDefine24,a.cDefine25,a.cDefine26,
  265. a.cDefine27,a.cItem_class,a.cItemCode,a.AutoID,a.iQuantity,
  266. a.cDefine28,a.cDefine29,a.cDefine30,a.cDefine31,a.cDefine32,
  267. a.cDefine33,a.cDefine34,a.cDefine35,a.cDefine36,a.cDefine37,
  268. 0,0,0,a.cCusInvCode,a.cCusInvName,1,0,
  269. b.cDLCode,0,a.iSOsID,1,
  270. d.cSOCode,c.iRowNo,a.iSOsID,1,d.cSOCode,
  271. 1,a.iSOsID,1,d.cSOCode,c.iRowNo,@irowno,
  272. 1,1,@AutoID,1,null
  273. FROM dbo.DispatchLists a
  274. INNER JOIN dbo.DispatchList b ON a.DLID=b.DLID
  275. LEFT JOIN dbo.SO_SODetails c ON a.iSOsID=c.iSOsID
  276. LEFT JOIN dbo.SO_SOMain d ON c.ID=d.ID WHERE a.AutoID='" + body.SDNRTDetailID + "'";
  277. cmd.Parameters.Clear();
  278. cmd.Parameters.Add(new SqlParameter("@AutoID", iChildId));
  279. cmd.Parameters.Add(new SqlParameter("@ID", iFatherId));
  280. cmd.Parameters.Add(new SqlParameter("@cInvCode", body.InvCode));
  281. cmd.Parameters.Add(new SqlParameter("@iQuantity", -body.Quantity));
  282. cmd.Parameters.Add(new SqlParameter("@cBatch", ""));
  283. cmd.Parameters.Add(new SqlParameter("@irowno", body.Sequence));
  284. cmd.CommandText = sql;
  285. try
  286. {
  287. int count = cmd.ExecuteNonQuery();
  288. if (count <= 0)
  289. {
  290. log.Error("生成红字销售出库单表体失败,受影响行数<=0;");
  291. throw new Exception("生成红字销售出库单表体失败,受影响行数<=0;");
  292. }
  293. }
  294. catch (Exception ex)
  295. {
  296. log.Error("生成红字销售出库单表体失败!销售出库单号:" + head.SDNNEGCode + ";异常:" + ex.Message + ";SQL:\r\n" + sql, ex);
  297. throw new Exception("生成红字销售出库单表体失败!销售出库单号:" + head.SDNNEGCode + ";异常:" + ex.Message + ";SQL:\r\n" + sql, ex);
  298. }
  299. #region 更新现存量 现存量表待出库数量增加
  300. key.cBustypeUN = bustype;
  301. key.cVouchTypeUN = "32";
  302. key.TableName = "IA_ST_UnAccountVouch32";
  303. DBHelper.UpdateCurrentStock(cmd, body.InvCode, head.WHCode, "", body.Quantity, key);
  304. #endregion
  305. log.Debug(sql);
  306. #region 回写销售订单累计发货数量,回写销售发货单累计出库数量
  307. sql = @"UPDATE a SET a.foutquantity=ISNULL(a.foutquantity,0)+" + -body.Quantity + @"
  308. FROM dbo.SO_SODetails a LEFT JOIN dbo.DispatchLists b ON a.iSOsID=b.iSOsID
  309. WHERE b.AutoID='" + body.SDNRTDetailID + "'";
  310. DBHelper.CmdExecuteNonQuery(sql, cmd, "回写销售订单累计发货数量失败!");
  311. sql = "Update DispatchLists set fOutQuantity=isnull(fOutQuantity,0)+" + -body.Quantity + " where AutoID='" + body.SDNRTDetailID + "' ";
  312. DBHelper.CmdExecuteNonQuery(sql, cmd, "回写销售发货单累计出库数量失败!");
  313. iChildId--;
  314. #endregion
  315. }
  316. #endregion
  317. iFatherIdTwo += "'" + iFatherId + "',";
  318. }
  319. #region 查询
  320. sql = @"
  321. select distinct a.ID as ID, a.ID as IDs,a.cCode as SDNNEGCode,a.cCusCode as CusCode,
  322. c.cCusName as CusName,a.cWhCode as WHCode,d.cWhName as WHName,e.cordercode ,
  323. a.cMaker as CreateUser ,a.dnmaketime as CreateDateTime ,a.cHandler as Checker ,
  324. a.dnverifytime as CheckDateTime
  325. from rdrecord32 a
  326. left join DispatchLists e on a.cDLCode=e.DLID
  327. left join Customer c on a.cCusCode=c.cCusCode
  328. left join Warehouse d on a.cWhCode=d.cWhCode WHERE 1=1 and a.ID in({0})
  329. select distinct a.ID as IDs,b.AutoID as DetailID,b.irowno as Sequence,b.cInvCode as InvCode ,b.iQuantity as Quantity ,
  330. b.iNum as Amount,b.iDLsID as SDNRTDetailID
  331. from rdrecord32 a
  332. inner join rdrecords32 b on a.ID=b.ID
  333. left join Customer c on a.cCusCode=c.cCusCode
  334. left join Warehouse d on a.cWhCode=d.cWhCode WHERE 1=1 and a.ID in({0})";
  335. sql = string.Format(sql, iFatherIdTwo.TrimEnd(','));
  336. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  337. string RelationName = "details";
  338. DataRelation dr = new DataRelation(RelationName, ds.Tables[0].Columns["IDs"], ds.Tables[1].Columns["IDs"]);
  339. ds.Relations.Add(dr);
  340. #endregion
  341. msg = DBHelper.DataSetToJson(ds, RelationName);
  342. cmd.Transaction.Commit();
  343. //ResultFlag = true;
  344. return msg;
  345. }
  346. catch (Exception ex)
  347. {
  348. cmd.Transaction.Rollback();
  349. log.Error(ex.Message);
  350. throw new Exception(ex.Message);
  351. }
  352. finally
  353. {
  354. if (conn.State == ConnectionState.Open)
  355. {
  356. conn.Close();
  357. }
  358. conn.Dispose();
  359. }
  360. }
  361. /// <summary>
  362. /// 删除销售出库单红字
  363. /// </summary>
  364. /// <param name="infos"></param>
  365. /// <returns></returns>
  366. public string Delete(List<ICSSalesShipmentDocNegative> infos)
  367. {
  368. List<ICSSalesShipmentDocNegative> szJson = new List<ICSSalesShipmentDocNegative>();
  369. if (infos.Count <= 0)
  370. {
  371. throw new Exception("传送数据为空!");
  372. }
  373. string res = string.Empty;
  374. SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
  375. conn.Open();
  376. SqlTransaction sqlTran = conn.BeginTransaction();
  377. SqlCommand cmd = new SqlCommand();
  378. cmd.Transaction = sqlTran;
  379. cmd.Connection = conn;
  380. try
  381. {
  382. string sql = string.Empty;
  383. foreach (ICSSalesShipmentDocNegative info in infos)
  384. {
  385. if (info.MTime < new DateTime(2000, 01, 01))
  386. throw new Exception("请输入正确的操作时间:" + info.MTime);
  387. sql = @"delete rdrecord11 where rdrecord32.ID='" + info.ID + "'";
  388. sql += @"delete rdrecords11 where rdrecords32.ID='" + info.ID + "'";
  389. //UPDATE dbo.rdrecord11 a SET cHandler='" + info.User + @"' ,
  390. // dVeriDate=CONVERT(VARCHAR(50),GETDATE(),112),dnverifytime=GETDATE()
  391. // WHERE a.ID='" + info.ID + "'";
  392. DBHelper.CmdExecuteNonQuery(sql, cmd, "删除红字销售出单失败!");
  393. }
  394. cmd.Transaction.Commit();
  395. return res;
  396. }
  397. catch (Exception ex)
  398. {
  399. cmd.Transaction.Rollback();
  400. log.Error(ex.Message);
  401. throw new Exception(ex.Message);
  402. }
  403. finally
  404. {
  405. if (conn.State == ConnectionState.Open)
  406. {
  407. conn.Close();
  408. }
  409. conn.Dispose();
  410. }
  411. }
  412. /// <summary>
  413. /// 审核销售出库单
  414. /// </summary>
  415. /// <param name="infos"></param>
  416. /// <returns></returns>
  417. public string Approve(List<ICSSalesShipmentDocNegative> infos)
  418. {
  419. List<ICSSalesShipmentDocNegative> szJson = new List<ICSSalesShipmentDocNegative>();
  420. DataTable dt = null;
  421. string json = "";
  422. if (infos.Count <= 0)
  423. {
  424. throw new Exception("传送数据为空!");
  425. }
  426. string res = string.Empty;
  427. SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
  428. conn.Open();
  429. SqlTransaction sqlTran = conn.BeginTransaction();
  430. SqlCommand cmd = new SqlCommand();
  431. cmd.Transaction = sqlTran;
  432. cmd.Connection = conn;
  433. try
  434. {
  435. string sql = string.Empty;
  436. foreach (ICSSalesShipmentDocNegative info in infos)
  437. {
  438. if (info.MTime < new DateTime(2000, 01, 01))
  439. throw new Exception("请输入正确的操作时间:" + info.MTime);
  440. sql = @"UPDATE rdrecord32 SET cHandler ='" + info.User + @"' ,
  441. dnverifytime=CONVERT(VARCHAR(50),GETDATE(),112),dVeriDate=GETDATE() WHERE ID='{0}'";
  442. sql = string.Format(sql, info.ID);
  443. DBHelper.CmdExecuteNonQuery(sql, cmd, "审核红字销售出单失败!");
  444. }
  445. cmd.Transaction.Commit();
  446. return json;
  447. }
  448. catch (Exception ex)
  449. {
  450. cmd.Transaction.Rollback();
  451. log.Error(ex.Message);
  452. throw new Exception(ex.Message);
  453. }
  454. finally
  455. {
  456. if (conn.State == ConnectionState.Open)
  457. {
  458. conn.Close();
  459. }
  460. conn.Dispose();
  461. }
  462. }
  463. /// <summary>
  464. ///
  465. /// 记录日志
  466. /// </summary>
  467. /// <param name="Bills"></param>
  468. private void LogInfo(List<ICSSalesShipmentDocNegative> Bills)
  469. {
  470. string HeadList = string.Empty;
  471. string BodyList = string.Empty;
  472. foreach (ICSSalesShipmentDocNegative head in Bills)
  473. {
  474. HeadList += "\r\n 表头主键ID:" + head.ID + ",仓库:" + head.WHCode + ",用户:" + head.User;
  475. foreach (ICSSalesShipmentDocNegatives body in head.details)
  476. {
  477. BodyList += "\r\n 表体主键ID: " + body.SDNRTDetailID + ",数量:" + body.Quantity;
  478. }
  479. }
  480. log.Info(HeadList);
  481. log.Info(BodyList);
  482. }
  483. }
  484. }