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

529 lines
25 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. using ICSSoft.Entity;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using Newtonsoft.Json;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using ICSSoft.Common;
  11. namespace ICSSoft.DataProject
  12. {
  13. public class CreatePOArrive
  14. {
  15. private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  16. private static string connString = System.Configuration.ConfigurationManager.AppSettings["ERPConnStr"];
  17. private static string ConnStr = System.Configuration.ConfigurationManager.AppSettings["ConnStr"];
  18. private static string ERPDB = System.Configuration.ConfigurationManager.AppSettings["ERPDB"];
  19. private static string Type = System.Configuration.ConfigurationManager.AppSettings["Type"];
  20. //参数示例
  21. //[{
  22. // "ASNNO": "DN510852000001",
  23. // "WHCode": "11",
  24. // "User": "CC001",
  25. // "MTime": "2021-08-26 17:20:13",
  26. // "details": [
  27. // {
  28. // "LOTNO": "PO200219004100005",
  29. // "ReceiveQty": "2"
  30. // },{
  31. // "LOTNO": "PO200219004100001",
  32. // "ReceiveQty": "1"
  33. // }
  34. // ]
  35. //}]
  36. //返回参数
  37. //{
  38. //"Success": true,
  39. //"Message": "接口调用成功!",
  40. //"Data": null
  41. //}
  42. public string Get(List<ICSPOArrive> infos)
  43. {
  44. List<ICSPOArrive> szJson = new List<ICSPOArrive>();
  45. DataTable dt = null;
  46. DataTable dtNew = null;
  47. string json = "";
  48. string connS = "";
  49. if (infos.Count <= 0)
  50. {
  51. throw new Exception("传送数据为空!");
  52. }
  53. string res = string.Empty;
  54. SqlConnection conn = new SqlConnection();
  55. SqlCommand cmd = new SqlCommand();
  56. string sql = string.Empty;
  57. foreach (ICSPOArrive info in infos)
  58. {
  59. try
  60. {
  61. connS = string.Format(connString, info.WorkPoint);
  62. conn = new System.Data.SqlClient.SqlConnection(connS);
  63. conn.Open();
  64. SqlTransaction sqlTran = conn.BeginTransaction();
  65. cmd = new SqlCommand();
  66. cmd.Transaction = sqlTran;
  67. cmd.Connection = conn;
  68. if (info.MTime < new DateTime(2000, 01, 01))
  69. throw new Exception("请输入正确的操作时间:" + info.MTime);
  70. sql = @" SELECT A.ID,A.cCode,A.cVenCode,D.cVenName,C.CDEPNAME,A.cDepCode,C.cDepName,A.cpocode,A.cMaker,A.cMakeTime,A.cverifier,A.caudittime,
  71. B.Autoid,B.irowno ,B.cInvCode ,B.INUM,B.iQuantity,B.fValidInQuan,B.iPOsID
  72. FROM PU_ArrivalVouch A
  73. INNER JOIN PU_ArrivalVouchs B ON A.ID=B.ID
  74. INNER JOIN DEPARTMENT C ON A.CDEPCODE=C.CDEPCODE
  75. INNER JOIN VENDOR D ON A.CVENCODE=D.CVENCODE WHERE 1=1 and A.iBillType=0";
  76. if (!string.IsNullOrWhiteSpace(info.DNCode))
  77. {
  78. sql += " and a.cCode='{0}'";
  79. }
  80. if (!string.IsNullOrWhiteSpace(info.MTime.ToString()))
  81. {
  82. sql += " and ISNULL(a.cModifyTime,ISNULL(a.cAuditTime, ISNULL(a.cModifyTime, a.cmaketime)))>='{1}'";
  83. }
  84. if (!string.IsNullOrWhiteSpace(info.User))
  85. {
  86. sql += "and a.CMAKER='{2}'";
  87. }
  88. sql = string.Format(sql, info.DNCode, info.MTime, info.User);
  89. dt = DBHelper.SQlReturnData(sql, cmd);
  90. if (dtNew == null)
  91. dtNew = dt;
  92. else
  93. dtNew.Merge(dt);
  94. cmd.Transaction.Commit();
  95. }
  96. catch (Exception ex)
  97. {
  98. cmd.Transaction.Rollback();
  99. log.Error(ex.Message);
  100. throw new Exception(ex.Message);
  101. }
  102. finally
  103. {
  104. if (conn.State == ConnectionState.Open)
  105. {
  106. conn.Close();
  107. }
  108. conn.Dispose();
  109. }
  110. }
  111. json = JsonConvert.SerializeObject(dtNew);
  112. return json;
  113. }
  114. /// <summary>
  115. /// 生成到货单
  116. /// </summary>
  117. /// <param name="infos"></param>
  118. /// <returns></returns>
  119. public string Create(List<ICSPOArrive> infos)
  120. {
  121. if (infos.Count <= 0)
  122. {
  123. throw new Exception("传送数据为空!");
  124. }
  125. string res = string.Empty;
  126. SqlConnection conn = new System.Data.SqlClient.SqlConnection(ConnStr);
  127. conn.Open();
  128. SqlTransaction sqlTran = conn.BeginTransaction();
  129. SqlCommand cmd = new SqlCommand();
  130. cmd.Transaction = sqlTran;
  131. cmd.Connection = conn;
  132. try
  133. {
  134. string sql = string.Empty;
  135. foreach (ICSPOArrive info in infos)
  136. {
  137. if (info.MTime < new DateTime(2000, 01, 01))
  138. throw new Exception("请输入正确的操作时间:" + info.MTime);
  139. string Lotnos = "";
  140. foreach (var detail in info.details)
  141. {
  142. sql = @"IF EXISTS(SELECT LOTNO FROM ICSASNDETAIL WHERE LOTNO='{1}' AND STNO='{2}' AND ISNULL(RECEIVEQTY,0)>0) and WorkPoint='{3}'
  143. RAISERROR('{1}',16,1)
  144. UPDATE ICSASNDETAIL SET RECEIVEQTY=ISNULL(RECEIVEQTY,0)+{0} WHERE LOTNO='{1}' AND STNO='{2}' and WorkPoint='{3}'
  145. --IF EXISTS(SELECT LOTNO FROM ICSASNDETAIL WHERE LOTNO='{1}' AND STNO='{2}' AND RECEIVEQTY>PLANQTY)
  146. -- RAISERROR('{1}',16,1)";
  147. sql = string.Format(sql, detail.Quantity, detail.LOTNO, info.ASNNO, info.WorkPoint);
  148. DBHelper.CmdExecuteNonQuery(sql, cmd, "送货单号:" + info.ASNNO + ",条码:" + detail.LOTNO + "未查询到对应数据!");
  149. Lotnos += "'" + detail.LOTNO + "',";
  150. }
  151. if (string.IsNullOrWhiteSpace(Lotnos))
  152. throw new Exception("送货单号:" + info.ASNNO + ",无条码信息!");
  153. CreatePUArrive(infos);
  154. }
  155. cmd.Transaction.Commit();
  156. return res;
  157. }
  158. catch (Exception ex)
  159. {
  160. cmd.Transaction.Rollback();
  161. log.Error(ex.Message);
  162. throw new Exception(ex.Message);
  163. }
  164. finally
  165. {
  166. if (conn.State == ConnectionState.Open)
  167. {
  168. conn.Close();
  169. }
  170. conn.Dispose();
  171. }
  172. }
  173. /// <summary>
  174. /// 回写U8到货单,
  175. /// </summary>
  176. /// <param name="cmd"></param>
  177. /// <param name="Lotnos"></param>
  178. /// <param name="info"></param>
  179. public string CreatePUArrive(List<ICSPOArrive> Bills)
  180. {
  181. string res = string.Empty;
  182. string connS = "";
  183. string str = "";
  184. DataTable dtNew1 = null;
  185. DataTable dtNew2 = null;
  186. SqlConnection conn = new SqlConnection();
  187. SqlCommand cmd = new SqlCommand();
  188. int num = 0;
  189. //int iBaseCodeLen = Convert.ToInt32(dic["iBaseCodeLen"].ToString());
  190. //int cVouchCodeBase = Convert.ToInt32(dic["cVouchCodeBase"].ToString());
  191. List<ICSPOArrive> datas = new List<ICSPOArrive>();
  192. string sql = "";
  193. foreach (ICSPOArrive head in Bills)
  194. {
  195. try
  196. {
  197. string iFatherIdTwo = "";
  198. connS = string.Format(connString, head.WorkPoint);
  199. conn = new System.Data.SqlClient.SqlConnection(connS);
  200. conn.Open();
  201. SqlTransaction sqlTran = conn.BeginTransaction();
  202. cmd = new SqlCommand();
  203. cmd.Transaction = sqlTran;
  204. cmd.Connection = conn;
  205. if (DBHelper.IsInventoryConsolidation(cmd,head.WorkPoint))
  206. {
  207. }
  208. else
  209. {
  210. throw new Exception("U8正在整理现存量,请稍后再试");
  211. }
  212. num = head.details.Count();
  213. string[] ss = head.WorkPoint.Split('_');
  214. ERPDB = ss[1];
  215. DateTime time = DateTime.Now;
  216. Dictionary<string, int> dic = DBHelper.GetAllCode("" + ERPDB + "", "PuArrival", "" + num + "", head.WorkPoint);
  217. int iFatherId = Convert.ToInt32(dic["iFatherId"].ToString());
  218. int iChildId = Convert.ToInt32(dic["iChildId"].ToString());
  219. DateTime date = DateTime.Now;
  220. string iBaseCodeLen = DBHelper.GetAllRDCode("26", "" + time + "", "admin", head.WorkPoint);
  221. string DEF_ID = DBHelper.GetDefaultTemplate(Type, cmd);
  222. #region 主表
  223. sql = @"INSERT INTO dbo.PU_ArrivalVouch
  224. (iVTid, ID, cCode, cPTCode, dDate, cVenCode, cDepCode, cPersonCode, cPayCode, cexch_name, iExchRate, iTaxRate, cMemo, cBusType, cMaker, bNegative,
  225. iDiscountTaxType, iBillType, cMakeTime, cAuditDate, caudittime, cverifier, iverifystateex, IsWfControlled, iflowid, iPrintCount, cpocode)
  226. SELECT @iVTid, @ID, @cCode, cPTCode, CONVERT(NVARCHAR(10), GETDATE(), 23), cVenCode, cDepCode, cPersonCode, cPayCode, cexch_name, nflat, iTaxRate, cMemo, '', @User, 0,
  227. iDiscountTaxType, 0, GETDATE(), CONVERT(NVARCHAR(10), GETDATE(), 23), GETDATE(), @User, 2, 0, 0, iPrintCount, cPOID
  228. FROM PO_Pomain WHERE 1=1 AND cPOID = @POID ";
  229. cmd.Parameters.Clear();
  230. cmd.Parameters.Add(new SqlParameter("@iVTid", DEF_ID));
  231. cmd.Parameters.Add(new SqlParameter("@ID", iFatherId));
  232. cmd.Parameters.Add(new SqlParameter("@cCode", iBaseCodeLen));
  233. cmd.Parameters.Add(new SqlParameter("@User", head.User));
  234. cmd.Parameters.Add(new SqlParameter("@POID", head.POCode));
  235. //cmd.Parameters.Add(new SqlParameter("@dDate", data.dMate));
  236. cmd.CommandText = sql;
  237. try
  238. {
  239. int count = cmd.ExecuteNonQuery();
  240. if (count <= 0)
  241. {
  242. log.Error("生成采购到货单表头失败,受影响行数<=0;");
  243. throw new Exception("生成采购到货单表头失败,受影响行数<=0;");
  244. }
  245. }
  246. catch (Exception ex)
  247. {
  248. log.Error("生成采购到货单表头失败!采购订单号:" + head.POCode + ";异常:" + ex.Message + ";SQL:\r\n" + sql, ex);
  249. throw new Exception("生成采购到货单表头失败!采购订单号:" + head.POCode + ";异常:" + ex.Message + ";SQL:\r\n" + sql, ex);
  250. }
  251. #endregion
  252. #region 子表
  253. foreach (ICSPODetail body in head.details)
  254. {
  255. int iMassDate = 0;
  256. int cMassUnit = 0;
  257. sql = @"SELECT cInvCode, ISNULL(iMassDate, 0) iMassDate, ISNULL(cMassUnit, 0) cMassUnit FROM Inventory WHERE cInvCode = '{0}' ";
  258. sql = string.Format(sql, body.InvCode);
  259. DataTable dts = DBHelper.SQlReturnData(sql, cmd);
  260. if (dts.Rows.Count == 0)
  261. {
  262. log.Error("存货档案不存在");
  263. throw new Exception("存货档案不存在");
  264. }
  265. else
  266. {
  267. iMassDate = Convert.ToInt16(dts.Rows[0]["iMassDate"].ToString());
  268. cMassUnit = Convert.ToInt16(dts.Rows[0]["cMassUnit"].ToString());
  269. }
  270. sql = @"
  271. INSERT INTO dbo.PU_ArrivalVouchs
  272. (Autoid, ID, cInvCode, iQuantity, iOriCost, iOriTaxCost, iOriMoney, iOriTaxPrice, iOriSum, iCost, iMoney, iTaxPrice, iSum, iTaxRate,
  273. iPOsID, fValidInQuan, fRealQuantity, fValidQuantity, fRetQuantity, fInValidInQuan, bGsp, fValidNum, fValidInNum, fRealNum, bTaxCost,
  274. SoType, fInvalidInNum, iinvexchrate, cordercode, RejectSource, iExpiratDateCalcu, iordertype, ivouchrowno, bgift,
  275. dPDate, dVDate, imassdate, cmassunit, cExpirationdate, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8,
  276. cBatch, cDefine37, fKPQuantity, finValidQuantity, fRefuseQuantity, iProductType,bexigency,cFree9,cFree10)
  277. SELECT @Autoid, @ID1, @cInvCode, @iQuantity,pd.iUnitPrice,pd.iTaxPrice,round((pd.iTaxPrice*@iQuantity)/(1+pd.iPerTaxRate/100),2),
  278. round(pd.iTaxPrice*@iQuantity,2)-round((pd.iTaxPrice*@iQuantity)/(1+pd.iPerTaxRate/100),2),round(pd.iTaxPrice*@iQuantity,2),round((pd.iTaxPrice/(1+pd.iPerTaxRate/100)*b.nflat),2),
  279. round(round((pd.iTaxPrice*@iQuantity)/(1+pd.iPerTaxRate/100),2)*b.nflat,2),
  280. round((round(pd.iTaxPrice*@iQuantity,2)-round((pd.iTaxPrice*@iQuantity)/(1+pd.iPerTaxRate/100),2))*b.nflat,2),round(round(pd.iTaxPrice*@iQuantity,2)*b.nflat,2),pd.iPerTaxRate,
  281. pd.ID, 0, @iQuantity, @iQuantity, 0, 0, 0, null, null, null, 1,
  282. 0, null, 0, @cordercode, 0, 0, 0, @ivouchrowno, 0,
  283. @dPDate, @dVDate, @imassdate, @cmassunit, null, @cFree1, @cFree2, @cFree3, @cFree4, @cFree5, @cFree6, @cFree7, @cFree8,
  284. @Batch, @cDefine37, null, null, null, null, null,@cFree9,@cFree10 FROM PO_Podetails pd
  285. left join po_pomain b on pd.poid=b.poid
  286. WHERE pd.ID = @iPOsID
  287. EXEC PROC_Update_PO_PUArrivalVouchs @ID= @ID1
  288. ";
  289. cmd.Parameters.Clear();
  290. cmd.Parameters.Add(new SqlParameter("@iPOsID", body.PODetailID));
  291. cmd.Parameters.Add(new SqlParameter("@Autoid", iChildId));
  292. cmd.Parameters.Add(new SqlParameter("@ID1", iFatherId));
  293. cmd.Parameters.Add(new SqlParameter("@cInvCode", body.InvCode));
  294. cmd.Parameters.Add(new SqlParameter("@iQuantity", body.Quantity));
  295. cmd.Parameters.Add(new SqlParameter("@cordercode", head.POCode));
  296. cmd.Parameters.Add(new SqlParameter("@ivouchrowno", body.Sequence));
  297. cmd.Parameters.Add(new SqlParameter("@dPDate", head.MTime));
  298. if (cMassUnit == 1)
  299. {
  300. cmd.Parameters.Add(new SqlParameter("@dVDate", head.MTime.AddYears(iMassDate).Date));
  301. }
  302. if (cMassUnit == 2)
  303. {
  304. cmd.Parameters.Add(new SqlParameter("@dVDate", head.MTime.AddMonths(iMassDate).Date));
  305. }
  306. if (cMassUnit == 3)
  307. {
  308. cmd.Parameters.Add(new SqlParameter("@dVDate", head.MTime.AddDays(iMassDate).Date));
  309. }
  310. cmd.Parameters.Add(new SqlParameter("@dVDate", ""));
  311. cmd.Parameters.Add(new SqlParameter("@imassdate", iMassDate));
  312. cmd.Parameters.Add(new SqlParameter("@cmassunit", cMassUnit));
  313. cmd.Parameters.Add(new SqlParameter("@Batch", body.BatchCode));
  314. cmd.Parameters.Add(new SqlParameter("@cDefine37", head.MTime.AddDays(1 - DateTime.Now.Day).AddMonths(1).AddSeconds(-1)));
  315. cmd.Parameters.Add(new SqlParameter("@cFree1", body.cFree1));
  316. cmd.Parameters.Add(new SqlParameter("@cFree2", body.cFree2));
  317. cmd.Parameters.Add(new SqlParameter("@cFree3", body.cFree3));
  318. cmd.Parameters.Add(new SqlParameter("@cFree4", body.cFree4));
  319. cmd.Parameters.Add(new SqlParameter("@cFree5", body.cFree5));
  320. cmd.Parameters.Add(new SqlParameter("@cFree6", body.cFree6));
  321. cmd.Parameters.Add(new SqlParameter("@cFree7", body.cFree7));
  322. cmd.Parameters.Add(new SqlParameter("@cFree8", body.cFree8));
  323. cmd.Parameters.Add(new SqlParameter("@cFree9", body.cFree9));
  324. cmd.Parameters.Add(new SqlParameter("@cFree10", body.cFree10));
  325. cmd.CommandText = sql;
  326. try
  327. {
  328. int count = cmd.ExecuteNonQuery();
  329. if (count <= 0)
  330. {
  331. log.Error("生成采购到货单表体失败,受影响行数<=0;");
  332. throw new Exception("生成采购到货单表体失败,受影响行数<=0;");
  333. }
  334. }
  335. catch (Exception ex)
  336. {
  337. log.Error("生成采购到货单表体失败!采购订单号:" + head.POCode + ";异常:" + ex.Message + ";SQL:\r\n" + sql, ex);
  338. throw new Exception("生成采购到货单表体失败!采购订单号:" + head.POCode + ";异常:" + ex.Message + ";SQL:\r\n" + sql, ex);
  339. }
  340. sql = string.Format(@"UPDATE B SET B.iArrMoney = ISNULL(B.iArrMoney, 0) + A.iOriSum, B.iNatArrMoney = ISNULL(B.iNatArrMoney, 0) + A.iSum
  341. FROM dbo.PU_ArrivalVouchs A LEFT JOIN dbo.PO_Podetails B ON A.iPOsID = B.ID
  342. WHERE A.Autoid = '{0}'", iChildId);
  343. cmd.CommandText = sql;
  344. cmd.ExecuteNonQuery();
  345. iFatherIdTwo += "'" + iFatherId + "',";
  346. iChildId--;
  347. }
  348. #endregion
  349. sql = @"SELECT A.ID as ID,A.ID as IDs,A.cCode as DNCode ,A.cVenCode,D.cVenName,A.cDepCode,C.cDepName,
  350. A.cpocode as POCode,A.cMaker as CreateUser,A.cMakeTime as CreateDateTime,
  351. A.cverifier as Checker,A.caudittime as CheckDateTime
  352. FROM PU_ArrivalVouch A
  353. INNER JOIN DEPARTMENT C ON A.CDEPCODE=C.CDEPCODE
  354. INNER JOIN VENDOR D ON A.CVENCODE=D.CVENCODE WHERE 1=1 and A.iBillType=0 and A.ID in({0})
  355. SELECT A.ID as IDs,B.Autoid as DetailID,B.ivouchrowno as Sequence,B.cInvCode as InvCode,
  356. B.INUM as Amount,B.iQuantity as Quantity,B.fValidInQuan as RCVQuantity,B.iPOsID as PODetailID
  357. FROM PU_ArrivalVouch A
  358. INNER JOIN PU_ArrivalVouchs B ON A.ID=B.ID
  359. INNER JOIN DEPARTMENT C ON A.CDEPCODE=C.CDEPCODE
  360. INNER JOIN VENDOR D ON A.CVENCODE=D.CVENCODE WHERE 1=1 and A.iBillType=0 and A.ID in({0})";
  361. sql = string.Format(sql, iFatherIdTwo.TrimEnd(','));
  362. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  363. if (dtNew1 == null)
  364. dtNew1 = ds.Tables[0];
  365. else
  366. dtNew1.Merge(ds.Tables[0]);
  367. if (dtNew2 == null)
  368. dtNew2 = ds.Tables[1];
  369. else
  370. dtNew2.Merge(ds.Tables[1]);
  371. cmd.Transaction.Commit();
  372. }
  373. catch (Exception ex)
  374. {
  375. cmd.Transaction.Rollback();
  376. log.Error(ex.Message);
  377. throw new Exception(ex.Message);
  378. }
  379. finally
  380. {
  381. if (conn.State == ConnectionState.Open)
  382. {
  383. conn.Close();
  384. }
  385. conn.Dispose();
  386. }
  387. }
  388. string RelationName = "details";
  389. DataSet dz = new DataSet();
  390. dtNew1.TableName = "Table0";
  391. dtNew2.TableName = "Table1";
  392. dz.Tables.Add(dtNew1.Copy());
  393. dz.Tables.Add(dtNew2.Copy());
  394. DataRelation dh = new DataRelation(RelationName, dz.Tables[0].Columns["IDs"], dz.Tables[1].Columns["IDs"]);
  395. dz.Relations.Add(dh);
  396. str = DBHelper.DataSetToJson(dz, RelationName);
  397. return str;
  398. }
  399. public string Approve(List<ICSPOArrive> infos)
  400. {
  401. List<ICSPOArrive> szJson = new List<ICSPOArrive>();
  402. DataTable dt = null;
  403. string json = "";
  404. string connS = "";
  405. if (infos.Count <= 0)
  406. {
  407. throw new Exception("传送数据为空!");
  408. }
  409. string res = string.Empty;
  410. SqlConnection conn = new SqlConnection();
  411. SqlCommand cmd = new SqlCommand();
  412. string sql = string.Empty;
  413. foreach (ICSPOArrive info in infos)
  414. {
  415. try
  416. {
  417. connS = string.Format(connString, info.WorkPoint);
  418. conn = new System.Data.SqlClient.SqlConnection(connS);
  419. conn.Open();
  420. SqlTransaction sqlTran = conn.BeginTransaction();
  421. cmd = new SqlCommand();
  422. cmd.Transaction = sqlTran;
  423. cmd.Connection = conn;
  424. if (info.MTime < new DateTime(2000, 01, 01))
  425. throw new Exception("请输入正确的操作时间:" + info.MTime);
  426. sql = @"UPDATE dbo.PU_ArrivalVouch SET cVerifier ='" + info.User + @"' ,
  427. cAuditTime=CONVERT(VARCHAR(50),GETDATE(),112),cAuditDate=GETDATE() WHERE ID='{0}'";
  428. sql = string.Format(sql, info.ID);
  429. DBHelper.CmdExecuteNonQuery(sql, cmd, "未查询到对应数据!");
  430. cmd.Transaction.Commit();
  431. }
  432. catch (Exception ex)
  433. {
  434. cmd.Transaction.Rollback();
  435. log.Error(ex.Message);
  436. throw new Exception(ex.Message);
  437. }
  438. finally
  439. {
  440. if (conn.State == ConnectionState.Open)
  441. {
  442. conn.Close();
  443. }
  444. conn.Dispose();
  445. }
  446. }
  447. return json;
  448. }
  449. /// <summary>
  450. /// 删除请购单
  451. /// </summary>
  452. /// <param name="infos"></param>
  453. /// <returns></returns>
  454. public string Delete(List<ICSPOArrive> infos)
  455. {
  456. List<ICSPOArrive> szJson = new List<ICSPOArrive>();
  457. if (infos.Count <= 0)
  458. {
  459. throw new Exception("传送数据为空!");
  460. }
  461. string res = string.Empty;
  462. string connS = "";
  463. SqlConnection conn = new SqlConnection();
  464. SqlCommand cmd = new SqlCommand();
  465. string sql = string.Empty;
  466. foreach (ICSPOArrive info in infos)
  467. {
  468. try
  469. {
  470. connS = string.Format(connString, info.WorkPoint);
  471. conn = new System.Data.SqlClient.SqlConnection(connS);
  472. conn.Open();
  473. SqlTransaction sqlTran = conn.BeginTransaction();
  474. cmd = new SqlCommand();
  475. cmd.Transaction = sqlTran;
  476. cmd.Connection = conn;
  477. if (info.MTime < new DateTime(2000, 01, 01))
  478. throw new Exception("请输入正确的操作时间:" + info.MTime);
  479. sql = @" DELETE dbo.PU_ArrivalVouch WHERE ID='{0}'";
  480. sql = string.Format(sql, info.ID);
  481. DBHelper.CmdExecuteNonQuery(sql, cmd, "未查询到对应数据!");
  482. cmd.Transaction.Commit();
  483. }
  484. catch (Exception ex)
  485. {
  486. cmd.Transaction.Rollback();
  487. log.Error(ex.Message);
  488. throw new Exception(ex.Message);
  489. }
  490. finally
  491. {
  492. if (conn.State == ConnectionState.Open)
  493. {
  494. conn.Close();
  495. }
  496. conn.Dispose();
  497. }
  498. }
  499. return res;
  500. }
  501. }
  502. }