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

545 lines
26 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  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 OutsourcingIssueDoc
  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. public string Get(List<ICSOutsourcingIssueDoc> infos)
  23. {
  24. List<ICSOutsourcingIssueDoc> szJson = new List<ICSOutsourcingIssueDoc>();
  25. DataTable dt = null;
  26. string json = "";
  27. DataTable dtNew = null;
  28. string connS = "";
  29. if (infos.Count <= 0)
  30. {
  31. throw new Exception("传送数据为空!");
  32. }
  33. string res = string.Empty;
  34. SqlConnection conn = new SqlConnection();
  35. SqlCommand cmd = new SqlCommand();
  36. string sql = string.Empty;
  37. foreach (ICSOutsourcingIssueDoc info in infos)
  38. {
  39. try
  40. {
  41. connS = string.Format(connString, info.WorkPoint);
  42. conn = new System.Data.SqlClient.SqlConnection(connS);
  43. conn.Open();
  44. SqlTransaction sqlTran = conn.BeginTransaction();
  45. cmd = new SqlCommand();
  46. cmd.Transaction = sqlTran;
  47. cmd.Connection = conn;
  48. if (info.MTime < new DateTime(2000, 01, 01))
  49. throw new Exception("请输入正确的操作时间:" + info.MTime);
  50. sql = @"select a.ID as ID,a.ID as IDs,a.cCode as IssueCode,a.cDepCode,c.cDepName,a.cWhCode,
  51. d.cWhName,a.cSource,cMPoCode,a.cMaker,dnmaketime,cHandler,dnverifytime
  52. from rdrecord11 a
  53. left join Department c on a.cDepCode=c.cDepCode
  54. left join Warehouse d on a.cWhCode=d.cWhCode
  55. where a.cBusType=''
  56. select a.ID as IDs,iMPoIds as SourceDetailID ,b.irowno as Sequence,iordercode,b.cInvCode,b.iQuantity,b.iNum,b.AutoID as DetailID
  57. from rdrecord11 a
  58. left join rdrecords11 b on a.ID=b.ID
  59. left join Department c on a.cDepCode=c.cDepCode
  60. left join Warehouse d on a.cWhCode=d.cWhCode
  61. left join OM_MODetails e on b.iOMoDID=e.MoDetailsID
  62. where a.cBusType=''";
  63. if (!string.IsNullOrWhiteSpace(info.IssueCode))
  64. {
  65. sql += " and a.cCode='{0}'";
  66. }
  67. if (!string.IsNullOrWhiteSpace(info.MTime.ToString()))
  68. {
  69. sql += " and ISNULL(a.dnmodifytime,ISNULL(a.dnverifytime, ISNULL(a.dnmodifytime, a.dnmaketime)))>='{1}'";
  70. }
  71. if (!string.IsNullOrWhiteSpace(info.User))
  72. {
  73. sql += "and a.CMAKER='{2}'";
  74. }
  75. sql = string.Format(sql, info.IssueCode, info.MTime, info.User);
  76. dt = DBHelper.SQlReturnData(sql, cmd);
  77. if (dt.Rows.Count <= 0 || dt == null)
  78. throw new Exception("委外发料单:" + info.IssueCode + ",无信息!");
  79. dtNew.Merge(dt);
  80. cmd.Transaction.Commit();
  81. }
  82. catch (Exception ex)
  83. {
  84. cmd.Transaction.Rollback();
  85. log.Error(ex.Message);
  86. throw new Exception(ex.Message);
  87. }
  88. finally
  89. {
  90. if (conn.State == ConnectionState.Open)
  91. {
  92. conn.Close();
  93. }
  94. conn.Dispose();
  95. }
  96. }
  97. json = JsonConvert.SerializeObject(dtNew);
  98. return json;
  99. }
  100. public string CreateOutsourcingIssueDoc(List<ICSOutsourcingIssueDoc> Bills)
  101. {
  102. string msg = "";
  103. string sql = string.Empty;
  104. DataTable dtNew1 = null;
  105. DataTable dtNew2 = null;
  106. string connS = "";
  107. int num = 0;
  108. //取得out库单的默认显示模版
  109. //取得采购入库单单据 表头ID,表体DID
  110. VouchKey key = new VouchKey();
  111. SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
  112. SqlCommand cmd = new SqlCommand();
  113. if (Bills.Count <= 0)
  114. {
  115. throw new Exception("传送数据为空!");
  116. }
  117. LogInfo(Bills);
  118. foreach (ICSOutsourcingIssueDoc head in Bills)
  119. {
  120. try
  121. {
  122. string iFatherIdTwo = "";
  123. connS = string.Format(connString, head.WorkPoint);
  124. conn = new System.Data.SqlClient.SqlConnection(connS);
  125. conn.Open();
  126. SqlTransaction sqlTran = conn.BeginTransaction();
  127. cmd = new SqlCommand();
  128. cmd.Transaction = sqlTran;
  129. cmd.Connection = conn;
  130. string[] ss = head.WorkPoint.Split('_');
  131. ERPDB = ss[1];
  132. num = head.details.Count();
  133. Dictionary<string, int> dic = DBHelper.GetAllCode("" + ERPDB + "", "rd", "" + num + "");
  134. int iFatherId = Convert.ToInt32(dic["iFatherId"].ToString());
  135. int iChildId = Convert.ToInt32(dic["iChildId"].ToString());
  136. DateTime date = DateTime.Now;
  137. string iBaseCodeLen = DBHelper.GetAllRDCode("26", "" + date + "", "admin");
  138. if (head.details.Count <= 0)
  139. {
  140. throw new Exception("表体信息不存在!");
  141. }
  142. #region 判断委外订单是否已关闭
  143. sql = @"SELECT distinct isnull(b.cbCloser,'') as CloseUser
  144. from dbo.OM_MOMaterials a
  145. INNER JOIN OM_MODetails b ON a.MoDetailsID = b.MoDetailsID
  146. where a.MOMaterialsID='" + head.details[0].SourceDetailID + "'";
  147. DataTable dtClose = DBHelper.SQlReturnData(sql, cmd);
  148. if (dtClose != null && dtClose.Rows.Count > 0)
  149. {
  150. if (!string.IsNullOrEmpty(dtClose.Rows[0][0].ToString()))
  151. {
  152. throw new Exception("该委外订单行已关闭,无法领料!");
  153. }
  154. }
  155. #endregion
  156. #region 判断物料是否超额领取
  157. foreach (ICSOutsourcingIssueDocs body in head.details)
  158. {
  159. sql = @"SELECT isnull(b.fOutExcess,0) as fOutExcess,isnull(a.iSendQTY,0) as IssQty,a.iQuantity
  160. FROM dbo.OM_MOMaterials a
  161. LEFT JOIN dbo.Inventory b ON a.cInvCode=b.cInvCode
  162. WHERE a.MOMaterialsID='" + body.SourceDetailID + "'";
  163. DataTable dtQty = DBHelper.SQlReturnData(sql, cmd);
  164. // if (dtQty != null && dtQty.Rows.Count > 0)
  165. // {
  166. // //可超领比率
  167. // decimal fOutExcess = Convert.ToDecimal(dtQty.Rows[0]["fOutExcess"]);
  168. // //已领数量
  169. // decimal IssQty = Convert.ToDecimal(dtQty.Rows[0]["IssQty"]);
  170. // //应领数量
  171. // decimal Qty = Convert.ToDecimal(dtQty.Rows[0]["iQuantity"]);
  172. // //当前可总领数量
  173. // decimal TotalQty = Qty + fOutExcess * Qty;
  174. // if (head.IsReturn != "1")
  175. // {
  176. // if (IssQty + body.Quantity > TotalQty)
  177. // {
  178. // throw new Exception("物料领取超过当前可领用最大数,AllocateId:" + body.SourceDetailID);
  179. // }
  180. // }
  181. // else
  182. // {
  183. // if (IssQty < body.Quantity)
  184. // {
  185. // throw new Exception("物料退料超过当前已领用最大数,AllocateId:" + body.SourceDetailID);
  186. // }
  187. // }
  188. // }
  189. // else
  190. // {
  191. // throw new Exception("委外订单行子件不存在!AllocateId:" + body.SourceDetailID);
  192. // }
  193. //}
  194. }
  195. #endregion
  196. #region 委外材料出库单表头
  197. sql = @"
  198. INSERT INTO dbo.rdrecord11
  199. ( ID ,bRdFlag ,cVouchType ,cBusType ,cSource ,
  200. cWhCode ,dDate ,cCode ,cRdCode ,cDepCode,
  201. cPersonCode,cHandler ,bTransFlag ,cMaker ,dVeriDate ,
  202. bpufirst ,biafirst ,VT_ID ,bIsSTQc ,cPsPcode ,
  203. cMPoCode ,iproorderid ,bFromPreYear ,bIsLsQuery ,bIsComplement ,
  204. iDiscountTaxType ,ireturncount ,iverifystate ,iswfcontrolled ,dnmaketime ,
  205. dnverifytime ,bredvouch ,iPrintCount,cVenCode,iMQuantity)
  206. SELECT distinct @ID,0,'11','','',
  207. @cWhCode,CONVERT(NVARCHAR(15),GETDATE(),23),@cCode,'22',c.cDepCode,
  208. c.cPersonCode,@cHandler,0,@cMaker,CONVERT(NVARCHAR(15),GETDATE(),23),
  209. 0,0,@VT_ID,0,b.cInvCode,
  210. c.cCode,a.MoId,0,0,0,
  211. 0,0,0,0,GETDATE(),
  212. GETDATE(),0,0,c.cVenCode,b.iQuantity
  213. from dbo.OM_MOMaterials a
  214. INNER JOIN dbo.OM_MODetails b ON a.MoDetailsID = b.MoDetailsID
  215. LEFT JOIN dbo.OM_MOMain c ON b.MOID = c.MOID
  216. WHERE a.MOMaterialsID='" + head.details[0].SourceDetailID + "'";
  217. cmd.Parameters.Clear();
  218. cmd.Parameters.Add(new SqlParameter("@ID", iFatherId));
  219. cmd.Parameters.Add(new SqlParameter("@cWhCode", head.WHCode));
  220. cmd.Parameters.Add(new SqlParameter("@cCode", iBaseCodeLen));
  221. cmd.Parameters.Add(new SqlParameter("@cHandler", head.User));
  222. cmd.Parameters.Add(new SqlParameter("@cMaker", head.User));
  223. cmd.Parameters.Add(new SqlParameter("@VT_ID", iChildId));
  224. cmd.CommandText = sql;
  225. try
  226. {
  227. int count = cmd.ExecuteNonQuery();
  228. if (count <= 0)
  229. {
  230. log.Error("生成委外发料单表头失败,受影响行数<=0;");
  231. throw new Exception("生成委外发料单表头失败,受影响行数<=0;");
  232. }
  233. }
  234. catch (Exception ex)
  235. {
  236. log.Error("生成委外发料单表头失败!SQL:\r\n" + sql, ex);
  237. throw new Exception("生成委外发料单表头失败!SQL:\r\n" + sql, ex);
  238. }
  239. #endregion
  240. #region 委外材料出库单表体
  241. string iNQuantity = "";
  242. foreach (ICSOutsourcingIssueDocs body in head.details)
  243. {
  244. //if (head.IsReturn == "1")
  245. //{
  246. // body.iQuantity = -body.iQuantity;
  247. // iNQuantity = "-a.iQuantity";
  248. //}
  249. //else
  250. //{
  251. iNQuantity = "a.iQuantity";
  252. //}
  253. //if (head.IsReturn == "0")
  254. //{
  255. // //判断物料批号与现存量表批号是否一致、数量不能超过现存量物料数量
  256. // sql = @"SELECT cBatch,iQuantity from CurrentStock WHERE cInvCode='" + body.cInvCode + "'AND cBatch='" + body.cBatch + "'and cWhCode='" + head.cWhCode + "'";
  257. // DataTable dtItem = U8Helper.SQlReturnData(sql, cmd);
  258. // if (dtItem != null && dtItem.Rows.Count > 0)
  259. // {
  260. // if (!dtItem.Rows[0]["cBatch"].ToString().Equals(body.cBatch))
  261. // {
  262. // throw new Exception("物料条码的批号与U8现存量物料批号不一致,物料:" + body.cInvCode);
  263. // }
  264. // if (Convert.ToDecimal(dtItem.Rows[0]["iQuantity"].ToString()) < body.iQuantity)
  265. // {
  266. // throw new Exception("物料条码的数量大于U8现存量物料数量,物料:" + body.cInvCode);
  267. // }
  268. // }
  269. // else
  270. // {
  271. // throw new Exception("物料:" + body.cInvCode + "在现存量表中不存在!");
  272. // }
  273. //}
  274. sql = @"INSERT INTO dbo.rdrecords11
  275. ( AutoID,ID ,cInvCode,iQuantity ,cBatch ,
  276. iFlag ,cItemCode ,cName ,iNQuantity ,iMPoIds ,
  277. bLPUseFree ,iOriTrackID ,bCosting ,bVMIUsed ,cmocode ,
  278. invcode ,imoseq ,iopseq ,iExpiratDateCalcu ,iorderdid ,
  279. iordertype ,isotype ,ipesodid ,ipesotype ,cpesocode ,
  280. ipesoseq ,irowno ,bcanreplace ,iposflag,iOMoDID,
  281. iOMoMID,comcode)
  282. SELECT distinct
  283. @AutoID,@ID,@InvCode,@iQuantity,@cBatch,
  284. 0,null,null,@iQuantity,NULL,
  285. 0,0,1,0,NULL,
  286. b.cInvCode,NULL,NULL,0,0,
  287. 0,0,a.MOMaterialsID,'6',c.cCode,
  288. NULL, @irowno,0,NULL,b.MODetailsID,
  289. a.MOMaterialsID,c.cCode
  290. FROM dbo.OM_MOMaterials a
  291. INNER JOIN dbo.OM_MODetails b ON a.MoDetailsID=b.MODetailsID
  292. INNER JOIN dbo.OM_MOMain c ON b.MOID=c.MOID
  293. WHERE a.MOMaterialsID='" + body.SourceDetailID + "'";
  294. cmd.Parameters.Clear();
  295. cmd.Parameters.Add(new SqlParameter("@AutoID", iChildId));
  296. cmd.Parameters.Add(new SqlParameter("@ID", iFatherId));
  297. cmd.Parameters.Add(new SqlParameter("@iQuantity", body.Quantity));
  298. //cmd.Parameters.Add(new SqlParameter("@cCode", iBaseCodeLen));
  299. cmd.Parameters.Add(new SqlParameter("@InvCode", body.InvCode));
  300. cmd.Parameters.Add(new SqlParameter("@cBatch", body.BatchCode));
  301. cmd.Parameters.Add(new SqlParameter("@irowno", body.Sequence));
  302. cmd.Parameters.Add(new SqlParameter("@iNQuantity", iNQuantity));
  303. cmd.Parameters.Add(new SqlParameter("@cFree1", body.cFree1));
  304. cmd.Parameters.Add(new SqlParameter("@cFree2", body.cFree2));
  305. cmd.Parameters.Add(new SqlParameter("@cFree3", body.cFree3));
  306. cmd.Parameters.Add(new SqlParameter("@cFree4", body.cFree4));
  307. cmd.Parameters.Add(new SqlParameter("@cFree5", body.cFree5));
  308. cmd.Parameters.Add(new SqlParameter("@cFree6", body.cFree6));
  309. cmd.Parameters.Add(new SqlParameter("@cFree7", body.cFree7));
  310. cmd.Parameters.Add(new SqlParameter("@cFree8", body.cFree8));
  311. cmd.Parameters.Add(new SqlParameter("@cFree9", body.cFree9));
  312. cmd.Parameters.Add(new SqlParameter("@cFree10", body.cFree10));
  313. cmd.CommandText = sql;
  314. try
  315. {
  316. int count = cmd.ExecuteNonQuery();
  317. if (count <= 0)
  318. {
  319. log.Error("生成委外发料单表体失败,受影响行数<=0;");
  320. throw new Exception("生成委外发料单表体失败,受影响行数<=0;");
  321. }
  322. }
  323. catch (Exception ex)
  324. {
  325. log.Error("生成委外发料单表体失败" + sql, ex);
  326. throw new Exception("生成委外发料单表体失败 " + sql, ex);
  327. }
  328. if (head.UpdateStock)
  329. {
  330. //更新现存量
  331. key.cBustypeUN = "委外发料";
  332. key.cVouchTypeUN = "11";
  333. key.TableName = "IA_ST_UnAccountVouch11";
  334. //DBHelper.UpdateCurrentStock(cmd, body.InvCode, head.WHCode, "", -body.Quantity, key);
  335. DBHelper.UpdateCurrentStockNEW(cmd, body.InvCode, head.WHCode, body.BatchCode, -body.Quantity, body.cFree1, body.cFree2, body.cFree3, body.cFree4, body.cFree5, body.cFree6, body.cFree7, body.cFree8, body.cFree9, body.cFree10, key);
  336. }
  337. #region 回写工单子件已领数量
  338. sql = "update OM_MOMaterials set iSendQTY=isnull(iSendQTY,0)+" + body.Quantity + " where MOMaterialsID='" + body.SourceDetailID + "' ";
  339. DBHelper.CmdExecuteNonQuery(sql, cmd, "回写委外订单子件已领数量失败!");
  340. #endregion
  341. iFatherIdTwo += "'" + iFatherId + "',";
  342. iChildId--;
  343. }
  344. #endregion
  345. #region 查询
  346. sql = @"select a.ID as ID,a.ID as IDs,a.cCode as IssueCode,a.cDepCode,c.cDepName,a.cWhCode,
  347. d.cWhName,a.cSource,cMPoCode,a.cMaker,dnmaketime,cHandler,dnverifytime
  348. from rdrecord11 a
  349. left join Department c on a.cDepCode=c.cDepCode
  350. left join Warehouse d on a.cWhCode=d.cWhCode
  351. where a.cBusType=''and a.ID in ({0})
  352. select a.ID as IDs,iOMoMID as SourceDetailID ,b.irowno as Sequence,iordercode,b.cInvCode,b.iQuantity,b.iNum,b.AutoID as DetailID
  353. from rdrecord11 a
  354. left join rdrecords11 b on a.ID=b.ID
  355. left join Department c on a.cDepCode=c.cDepCode
  356. left join Warehouse d on a.cWhCode=d.cWhCode
  357. left join OM_MODetails e on b.iOMoDID=e.MoDetailsID
  358. where a.cBusType=''and a.ID in ({0})";
  359. sql = string.Format(sql, iFatherIdTwo.TrimEnd(','));
  360. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  361. dtNew1.Merge(ds.Tables[0]);
  362. dtNew2.Merge(ds.Tables[1]);
  363. #endregion
  364. cmd.Transaction.Commit();
  365. }
  366. catch (Exception ex)
  367. {
  368. cmd.Transaction.Rollback();
  369. log.Error(ex.Message);
  370. throw new Exception(ex.Message);
  371. }
  372. finally
  373. {
  374. if (conn.State == ConnectionState.Open)
  375. {
  376. conn.Close();
  377. }
  378. conn.Dispose();
  379. }
  380. }
  381. string RelationName = "details";
  382. DataRelation dh = new DataRelation(RelationName, dtNew1.Columns["IDs"], dtNew2.Columns["IDs"]);
  383. DataSet dz = new DataSet();
  384. dz.Relations.Add(dh);
  385. msg = DBHelper.DataSetToJson(dz, RelationName);
  386. return msg;
  387. }
  388. public string Approve(List<ICSOutsourcingIssueDoc> infos)
  389. {
  390. List<ICSOutsourcingIssueDoc> szJson = new List<ICSOutsourcingIssueDoc>();
  391. string connS = "";
  392. string json = "";
  393. if (infos.Count <= 0)
  394. {
  395. throw new Exception("传送数据为空!");
  396. }
  397. string res = string.Empty;
  398. SqlConnection conn = new SqlConnection();
  399. SqlCommand cmd = new SqlCommand();
  400. string sql = string.Empty;
  401. foreach (ICSOutsourcingIssueDoc info in infos)
  402. {
  403. try
  404. {
  405. connS = string.Format(connString, info.WorkPoint);
  406. conn = new System.Data.SqlClient.SqlConnection(connS);
  407. conn.Open();
  408. SqlTransaction sqlTran = conn.BeginTransaction();
  409. cmd = new SqlCommand();
  410. cmd.Transaction = sqlTran;
  411. cmd.Connection = conn;
  412. if (info.MTime < new DateTime(2000, 01, 01))
  413. throw new Exception("请输入正确的操作时间:" + info.MTime);
  414. sql = @"UPDATE dbo.rdrecord11 SET cHandler ='" + info.User + @"' ,
  415. dnmodifytime =CONVERT(VARCHAR(50),GETDATE(),112),dModifyDate =GETDATE() WHERE ID='{0}'";
  416. sql = string.Format(sql, info.ID);
  417. DBHelper.CmdExecuteNonQuery(sql, cmd, "未查询到对应数据!");
  418. cmd.Transaction.Commit();
  419. }
  420. catch (Exception ex)
  421. {
  422. cmd.Transaction.Rollback();
  423. log.Error(ex.Message);
  424. throw new Exception(ex.Message);
  425. }
  426. finally
  427. {
  428. if (conn.State == ConnectionState.Open)
  429. {
  430. conn.Close();
  431. }
  432. conn.Dispose();
  433. }
  434. }
  435. return json;
  436. }
  437. /// <summary>
  438. /// 删除请购单
  439. /// </summary>
  440. /// <param name="infos"></param>
  441. /// <returns></returns>
  442. public string Delete(List<ICSOutsourcingIssueDoc> infos)
  443. {
  444. List<ICSOutsourcingIssueDoc> szJson = new List<ICSOutsourcingIssueDoc>();
  445. if (infos.Count <= 0)
  446. {
  447. throw new Exception("传送数据为空!");
  448. }
  449. string res = string.Empty;
  450. string connS = "";
  451. SqlConnection conn = new SqlConnection();
  452. SqlCommand cmd = new SqlCommand();
  453. string sql = string.Empty;
  454. foreach (ICSOutsourcingIssueDoc info in infos)
  455. {
  456. try
  457. {
  458. connS = string.Format(connString, info.WorkPoint);
  459. conn = new System.Data.SqlClient.SqlConnection(connS);
  460. conn.Open();
  461. SqlTransaction sqlTran = conn.BeginTransaction();
  462. cmd = new SqlCommand();
  463. cmd.Transaction = sqlTran;
  464. cmd.Connection = conn;
  465. if (info.MTime < new DateTime(2000, 01, 01))
  466. throw new Exception("请输入正确的操作时间:" + info.MTime);
  467. sql = @" DELETE dbo.rdrecord11 WHERE ID='{0}'";
  468. sql = string.Format(sql, info.ID);
  469. DBHelper.CmdExecuteNonQuery(sql, cmd, "未查询到对应数据!");
  470. cmd.Transaction.Commit();
  471. }
  472. catch (Exception ex)
  473. {
  474. cmd.Transaction.Rollback();
  475. log.Error(ex.Message);
  476. throw new Exception(ex.Message);
  477. }
  478. finally
  479. {
  480. if (conn.State == ConnectionState.Open)
  481. {
  482. conn.Close();
  483. }
  484. conn.Dispose();
  485. }
  486. }
  487. return res;
  488. }
  489. /// <summary>
  490. ///
  491. /// 记录日志
  492. /// </summary>
  493. /// <param name="Bills"></param>
  494. private void LogInfo(List<ICSOutsourcingIssueDoc> Bills)
  495. {
  496. string HeadList = string.Empty;
  497. string BodyList = string.Empty;
  498. foreach (ICSOutsourcingIssueDoc head in Bills)
  499. {
  500. HeadList += "\r\n 表头主键ID:" + head.ID + ",仓库:" + head.WHCode + ",用户:" + head.User + ",站点:" + head.WorkPoint;
  501. foreach (ICSOutsourcingIssueDocs body in head.details)
  502. {
  503. BodyList += "\r\n 表体主键ID: " + body.SourceDetailID + ",数量:" + body.Quantity;
  504. }
  505. }
  506. log.Info(HeadList);
  507. log.Info(BodyList);
  508. }
  509. }
  510. }