爱思开
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.

436 lines
26 KiB

2 years ago
  1. using ICSSoft.Common;
  2. using ICSSoft.Entity;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Data.SqlClient;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using Newtonsoft.Json;
  11. namespace ICSSoft.DataProject
  12. {
  13. public class OtherOutDoc
  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 ERPDB = System.Configuration.ConfigurationManager.AppSettings["ERPDB"];
  18. private static string Type = System.Configuration.ConfigurationManager.AppSettings["Type"];
  19. private static string CRNALL = System.Configuration.ConfigurationManager.AppSettings["OtherOutCRDNAME"];
  20. /// <summary>
  21. /// 生成其他出库单
  22. /// </summary>
  23. /// <param name="Bills"></param>
  24. /// <returns></returns>
  25. public string CreateRd09(List<ICSOtherOutCreateDoc> Bills)
  26. {
  27. string msg = string.Empty;
  28. string connS = "";
  29. string sql = string.Empty;
  30. SqlConnection conn = new SqlConnection();
  31. DataSet ds = null;
  32. int num = 0;
  33. SqlCommand cmd = new SqlCommand();
  34. string iFatherIdTwo = "";
  35. if (Bills.Count <= 0)
  36. {
  37. throw new Exception("传送数据为空!");
  38. }
  39. List<string> result = Bills.Select(t => t.WorkPoint).Distinct().ToList();
  40. foreach (string WorkPoint in result)
  41. {
  42. try
  43. {
  44. connS = string.Format(connString, WorkPoint);
  45. conn = new System.Data.SqlClient.SqlConnection(connS);
  46. conn.Open();
  47. SqlTransaction sqlTran = conn.BeginTransaction();
  48. cmd = new SqlCommand();
  49. cmd.Transaction = sqlTran;
  50. cmd.Connection = conn;
  51. foreach (ICSOtherOutCreateDoc head in Bills)
  52. {
  53. iFatherIdTwo = "";
  54. if (WorkPoint != head.WorkPoint)
  55. {
  56. continue;
  57. }
  58. if (!DBHelper.IsInventoryConsolidation(cmd, head.WorkPoint))
  59. throw new Exception("U8正在整理现存量,请稍后再试");
  60. string[] ss = head.WorkPoint.Split('_');
  61. ERPDB = ss[1];
  62. string[] dd = CRNALL.Split('~');
  63. string crdname = dd[0];
  64. string carname = dd[1];
  65. string surface = dd[2];
  66. num = head.details.Count();
  67. string cardnewcode = DBHelper.GetCardNumber(carname, cmd);
  68. Dictionary<string, int> dic = DBHelper.GetAllCode("" + ERPDB + "", surface, "" + num + "", head.WorkPoint, cmd);
  69. int iFatherId = Convert.ToInt32(dic["iFatherId"].ToString());
  70. int iChildId = Convert.ToInt32(dic["iChildId"].ToString());
  71. DateTime date = DateTime.Now;
  72. string cRDcode = DBHelper.GetRDCode(crdname, cmd);
  73. string iBaseCodeLen = DBHelper.GetAllRDCode(cardnewcode, "" + date + "", "admin", cRDcode, head.WorkPoint, cmd);
  74. ICSUserInfo userInfo = new ICSUserInfo();
  75. userInfo = DBHelper.GetPersonInfo(head.User, cmd);
  76. //取得out库单的默认显示模版
  77. string DEF_ID09 = DBHelper.GetDefaultTemplate(cardnewcode, cmd);
  78. //取得其他出库单单据 表头ID,表体DID
  79. VouchKey key09 = new VouchKey();
  80. #region 其他出库单表头
  81. key09.ID += 1;
  82. sql = @"INSERT INTO dbo.RdRecord09
  83. ( ID ,bRdFlag ,cVouchType ,cBusType ,cSource ,cWhCode ,dDate ,cCode ,
  84. cRdCode ,cDepCode ,cHandler ,bTransFlag ,cMaker ,dVeriDate ,bpufirst ,
  85. biafirst ,VT_ID ,bIsSTQc ,bFromPreYear ,bIsComplement ,iDiscountTaxType ,
  86. iBG_OverFlag ,cBG_Auditor ,cBG_AuditTime ,ControlResult ,ireturncount ,
  87. iverifystate ,iswfcontrolled ,cModifyPerson ,dnmaketime ,dnverifytime ,
  88. iPrintCount)
  89. VALUES(@ID,0,'09','','',@cWhCode,CONVERT(NVARCHAR(15),GETDATE(),23),@cCode,
  90. @cRdCode,@cDepCode,@cHandler,0,@cMaker,CONVERT(NVARCHAR(15),GETDATE(),23),0,
  91. 0,@VT_ID,0,0,0,0,
  92. 0,'','',-1,0,
  93. 0,0,'',GETDATE(),GETDATE(),0) ";
  94. cmd.Parameters.Clear();
  95. cmd.Parameters.Add(new SqlParameter("@ID", iFatherId));
  96. cmd.Parameters.Add(new SqlParameter("@cWhCode", head.WHCode));
  97. cmd.Parameters.Add(new SqlParameter("@cCode", iBaseCodeLen));
  98. cmd.Parameters.Add(new SqlParameter("@cRdCode", cRDcode));
  99. cmd.Parameters.Add(new SqlParameter("@cDepCode", head.DepCode));
  100. cmd.Parameters.Add(new SqlParameter("@cHandler", userInfo.UserName));
  101. cmd.Parameters.Add(new SqlParameter("@cMaker", userInfo.UserName));
  102. cmd.Parameters.Add(new SqlParameter("@VT_ID", DEF_ID09));
  103. cmd.CommandText = sql;
  104. try
  105. {
  106. cmd.ExecuteNonQuery();
  107. }
  108. catch (Exception)
  109. {
  110. log.Error("生成其他出库单失败!SQL:\r\n" + sql);
  111. throw new Exception("程序异常,请联系开发人员!");
  112. }
  113. #endregion
  114. foreach (ICSOtherOutCreateDocs body in head.details)
  115. {
  116. #region 3.5.1 表体
  117. sql = @"INSERT INTO dbo.rdrecords09
  118. ( AutoID ,ID ,cInvCode ,iQuantity ,iFlag ,bLPUseFree ,iRSRowNO ,iOriTrackID ,cBatch,iNNum,cItemCode,
  119. bCosting ,bVMIUsed ,iExpiratDateCalcu ,iordertype ,isotype ,irowno ,iposflag,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10)
  120. VALUES(@AutoID,@ID,@cInvCode,@iQuantity,0,0,0,0,@cBatch,@iNNum,@cItemCode,
  121. 1,0,0,0,0,@irowno,1,@cFree1,@cFree2,@cFree3,@cFree4,@cFree5,@cFree6,@cFree7,@cFree8,@cFree9,@cFree10)";
  122. cmd.Parameters.Clear();
  123. cmd.Parameters.Add(new SqlParameter("@AutoID", iChildId));
  124. cmd.Parameters.Add(new SqlParameter("@ID", iFatherId));
  125. cmd.Parameters.Add(new SqlParameter("@cInvCode", body.InvCode));
  126. cmd.Parameters.Add(new SqlParameter("@iQuantity", body.Quantity));
  127. cmd.Parameters.Add(new SqlParameter("@iNNum", body.Amount.ToString("0.00")));
  128. cmd.Parameters.Add(new SqlParameter("@irowno", body.Sequence));
  129. cmd.Parameters.Add(new SqlParameter("@cBatch", body.BatchCode));
  130. cmd.Parameters.Add(new SqlParameter("@cItemCode", body.ProjectCode));
  131. cmd.Parameters.Add(new SqlParameter("@cFree1", body.cFree1));
  132. cmd.Parameters.Add(new SqlParameter("@cFree2", body.cFree2));
  133. cmd.Parameters.Add(new SqlParameter("@cFree3", body.cFree3));
  134. cmd.Parameters.Add(new SqlParameter("@cFree4", body.cFree4));
  135. cmd.Parameters.Add(new SqlParameter("@cFree5", body.cFree5));
  136. cmd.Parameters.Add(new SqlParameter("@cFree6", body.cFree6));
  137. cmd.Parameters.Add(new SqlParameter("@cFree7", body.cFree7));
  138. cmd.Parameters.Add(new SqlParameter("@cFree8", body.cFree8));
  139. cmd.Parameters.Add(new SqlParameter("@cFree9", body.cFree9));
  140. cmd.Parameters.Add(new SqlParameter("@cFree10", body.cFree10));
  141. cmd.CommandText = sql;
  142. try
  143. {
  144. cmd.ExecuteNonQuery();
  145. }
  146. catch (Exception)
  147. {
  148. log.Error("生成其他出库单表体失败!SQL:\r\n" + sql);
  149. throw new Exception("程序异常,请联系开发人员!");
  150. }
  151. #endregion
  152. //更新现存量
  153. key09.cBustypeUN = "其他出库";
  154. key09.cVouchTypeUN = "09";
  155. key09.TableName = "IA_ST_UnAccountVouch09";
  156. //DBHelper.UpdateCurrentStock(cmd, body.InvCode, head.WHCode, "", -body.Quantity, key09);
  157. //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, key09);
  158. DBHelper.UpdateCurrentStockCCGC(cmd, body.InvCode, head.WHCode, body.BatchCode, -body.Quantity, -body.Amount, body.cFree1,
  159. body.cFree2, body.cFree3, body.cFree4, body.cFree5, body.cFree6, body.cFree7, body.cFree8, body.cFree9, body.cFree10,
  160. "", key09, "", "", "", "", 0, 0, 0, 0, 0, 0, 0, 0, iFatherId, iChildId);
  161. iFatherIdTwo = "'" + iFatherId + "',";
  162. iChildId--;
  163. }
  164. #region 查询
  165. sql = @"
  166. select DISTINCT a.ID as ID,a.ID as IDs,cBusCode as SourceCode ,
  167. cCode as OtherOutCode,a.cDepCode,c.cDepName,a.cWhCode,d.cWhName,
  168. cSource as SourceType,cMaker as CreateUser,dnmaketime as CreateDateTime,
  169. cHandler as Checker,dnverifytime as CheckDateTime
  170. from rdrecord09 a
  171. left join Department c on a.cDepCode=c.cDepCode
  172. left join Warehouse d on a.cWhCode=d.cWhCode
  173. WHERE a.ID in ({0})
  174. select DISTINCT a.ID as IDs,b.AutoID as DetailID,irowno as Sequence,b.cInvCode as InvCode
  175. ,iQuantity as Quantity,b.iDebitIDs as SourceDetailID,iNum as Amount
  176. ,isnull(b.cItemCode,'') ProjectCode,
  177. isnull(b.cbatch,'') cBatch,
  178. '' version ,'' brand,
  179. isnull(b.cFree1,'') as cFree1,
  180. isnull(b.cFree2,'') as cFree2,
  181. isnull(b.cFree3,'') as cFree3,
  182. isnull(b.cFree4,'') as cFree4,
  183. isnull(b.cFree5,'') as cFree5,
  184. isnull(b.cFree6,'') as cFree6,
  185. isnull(b.cFree7,'') as cFree7,
  186. isnull(b.cFree8,'') as cFree8,
  187. isnull(b.cFree9,'') as cFree9,
  188. isnull(b.cFree10,'') as cFree10
  189. from rdrecord09 a
  190. left join rdrecords09 b on a.ID=b.ID
  191. left join Department c on a.cDepCode=c.cDepCode
  192. left join Warehouse d on a.cWhCode=d.cWhCode
  193. WHERE a.ID in ({0})";
  194. sql = string.Format(sql, iFatherIdTwo.TrimEnd(','));
  195. if (ds != null)
  196. ds.Merge(DBHelper.SQlReturnDataSet(sql, cmd));
  197. else
  198. ds = DBHelper.SQlReturnDataSet(sql, cmd);
  199. #endregion
  200. cmd.CommandType = CommandType.Text;
  201. cmd.Parameters.Clear();
  202. }
  203. cmd.Transaction.Commit();
  204. }
  205. catch (Exception ex)
  206. {
  207. if (cmd.Transaction != null)
  208. cmd.Transaction.Rollback();
  209. log.Error(ex.Message);
  210. throw new Exception(ex.Message);
  211. }
  212. finally
  213. {
  214. if (conn.State == ConnectionState.Open)
  215. {
  216. conn.Close();
  217. }
  218. conn.Dispose();
  219. }
  220. }
  221. msg = JSON.DataSetToJson(ds, "details", "IDs");
  222. return msg;
  223. }
  224. /// <summary>
  225. /// 审核其他出库单
  226. /// </summary>
  227. /// <param name="Bills"></param>
  228. /// <returns></returns>
  229. public bool ConfirmRd09(List<ICSOtherOutDoc> Bills)
  230. {
  231. bool ResultFlag = false;
  232. string connS = "";
  233. SqlConnection conn = new SqlConnection();
  234. SqlCommand cmd = new SqlCommand();
  235. if (Bills.Count <= 0)
  236. {
  237. throw new Exception("传送数据为空!");
  238. }
  239. LogInfo(Bills);
  240. List<string> result = Bills.Select(t => t.WorkPoint).Distinct().ToList();
  241. foreach (string WorkPoint in result)
  242. {
  243. try
  244. {
  245. connS = string.Format(connString, WorkPoint);
  246. conn = new System.Data.SqlClient.SqlConnection(connS);
  247. conn.Open();
  248. SqlTransaction sqlTran = conn.BeginTransaction();
  249. cmd = new SqlCommand();
  250. cmd.Transaction = sqlTran;
  251. cmd.Connection = conn;
  252. foreach (ICSOtherOutDoc head in Bills)
  253. {
  254. if (WorkPoint != head.WorkPoint)
  255. continue;
  256. if (!DBHelper.IsInventoryConsolidation(cmd, head.WorkPoint))
  257. throw new Exception("U8正在整理现存量,请稍后再试");
  258. string sql = "";
  259. ICSUserInfo userInfo = new ICSUserInfo();
  260. userInfo = DBHelper.GetPersonInfo(head.User, cmd);
  261. #region 检验单号是否存在
  262. sql = "select * from RdRecord09 where ID='" + head.ID + "'";
  263. DataTable dt = DBHelper.SQlReturnData(sql, cmd);
  264. if (dt != null && dt.Rows.Count > 0)
  265. {
  266. string cHandler = dt.Rows[0]["cHandler"].ToString();
  267. if (!string.IsNullOrEmpty(cHandler))
  268. {
  269. throw new Exception("单据ID:" + head.ID + "不是开立状态!");
  270. }
  271. }
  272. else
  273. {
  274. throw new Exception("单据ID:" + head.ID + "在U8中不存在!");
  275. }
  276. #endregion
  277. #region 审核其他出库单
  278. sql = @"UPDATE dbo.RdRecord09 SET cHandler='" + userInfo.UserName + @"' ,
  279. dVeriDate=CONVERT(VARCHAR(50),GETDATE(),112),dnverifytime=GETDATE() WHERE ID='" + head.ID + "'";
  280. DBHelper.CmdExecuteNonQuery(sql, cmd, "审核其他出库单失败!");
  281. #endregion
  282. sql = "select * from dbo.RdRecords09 a inner join RdRecord09 b on a.ID=b.ID where b.ID='" + head.ID + "';";
  283. DataTable dtChecks = DBHelper.SQlReturnData(sql, cmd);
  284. #region 更新现存量
  285. for (int i = 0; i < dtChecks.Rows.Count; i++)
  286. {
  287. //判断物料批号与现存量表批号是否一致、数量不能超过现存量物料数量
  288. //sql = @"SELECT cBatch,iQuantity from CurrentStock WHERE cInvCode='" + dtChecks.Rows[i]["cInvCode"].ToString() + "'AND cBatch=''and cWhCode='" + dtChecks.Rows[i]["cWhCode"].ToString() + "'";
  289. sql = @"SELECT cBatch,iQuantity from CurrentStock WHERE cInvCode='" + dtChecks.Rows[i]["cInvCode"].ToString() + "'AND cBatch='" + dtChecks.Rows[i]["cBatch"].ToString() + @"'AND cFree1='" + dtChecks.Rows[i]["cFree1"].ToString() + @"' AND cFree2='" + dtChecks.Rows[i]["cFree2"].ToString() + @"' AND cFree3='" + dtChecks.Rows[i]["cFree3"].ToString() + @"' AND cFree4='" + dtChecks.Rows[i]["cFree4"].ToString() + @"' AND cFree5='" + dtChecks.Rows[i]["cFree5"].ToString() + @"' AND cFree6='" + dtChecks.Rows[i]["cFree6"].ToString() + @"' AND cFree7='" + dtChecks.Rows[i]["cFree7"].ToString() + @"' AND cFree8='" + dtChecks.Rows[i]["cFree8"].ToString() + @"' AND cFree9='" + dtChecks.Rows[i]["cFree9"].ToString() + @"' AND cFree10='" + dtChecks.Rows[i]["cFree10"].ToString() + @"' and cWhCode='" + dtChecks.Rows[i]["cWhCode"].ToString() + "'";
  290. DataTable dtItem = DBHelper.SQlReturnData(sql, cmd);
  291. if (dtItem != null && dtItem.Rows.Count > 0)
  292. {
  293. //if (!dtItem.Rows[0]["cBatch"].ToString().Equals(body.cBatch))
  294. //{
  295. // throw new Exception("物料条码的批号与U8现存量物料批号不一致,物料:" + body.cInvCode);
  296. //}
  297. if (Convert.ToDecimal(dtItem.Rows[0]["iQuantity"].ToString()) < Convert.ToDecimal(dtChecks.Rows[i]["iQuantity"].ToString()))
  298. {
  299. throw new Exception("物料条码的数量大于U8现存量物料数量,物料:" + dtChecks.Rows[i]["cInvCode"].ToString());
  300. }
  301. }
  302. else
  303. {
  304. throw new Exception("物料:" + dtChecks.Rows[i]["cInvCode"].ToString() + "在现存量表中不存在!");
  305. }
  306. sql = @" select * from CurrentStock where cWhCode='" + dtChecks.Rows[i]["cWhCode"].ToString() + @"' and cInvCode='" + dtChecks.Rows[i]["cInvCode"].ToString() + @"' and cBatch='" + dtChecks.Rows[i]["cBatch"].ToString() + @"'
  307. and cVMIVenCode='' and cFree1='" + dtChecks.Rows[i]["cFree1"].ToString() + @"' and cFree2='" + dtChecks.Rows[i]["cFree2"].ToString() + @"' and cFree3='" + dtChecks.Rows[i]["cFree3"].ToString() + @"' and cFree4='" + dtChecks.Rows[i]["cFree4"].ToString() + @"' and cFree5='" + dtChecks.Rows[i]["cFree5"].ToString() + @"'
  308. and cFree6='" + dtChecks.Rows[i]["cFree6"].ToString() + @"' and cFree7='" + dtChecks.Rows[i]["cFree7"].ToString() + @"' and cFree8='" + dtChecks.Rows[i]["cFree8"].ToString() + @"' and cFree9='" + dtChecks.Rows[i]["cFree9"].ToString() + @"' and cFree10='" + dtChecks.Rows[i]["cFree10"].ToString() + @"' ";
  309. DataTable curr = DBHelper.SQlReturnData(sql, cmd);
  310. string JsonData = JsonConvert.SerializeObject(curr);
  311. log.Info(JsonData);
  312. VouchKey key = new VouchKey();
  313. key.cBustypeUN = "其他出库";
  314. key.cVouchTypeUN = "09";
  315. key.TableName = "IA_ST_UnAccountVouch09";
  316. //DBHelper.UpdateCurrentStock(cmd, dtChecks.Rows[i]["cInvCode"].ToString(), dtChecks.Rows[i]["cWhCode"].ToString(),"", -Convert.ToDecimal(dtChecks.Rows[i]["iQuantity"].ToString()), key);
  317. //DBHelper.UpdateCurrentStockNEW(cmd, dtChecks.Rows[i]["cInvCode"].ToString(), dtChecks.Rows[i]["cWhCode"].ToString(), dtChecks.Rows[i]["cBatch"].ToString(), -Convert.ToDecimal(dtChecks.Rows[i]["iQuantity"].ToString()), dtChecks.Rows[i]["cFree1"].ToString(), dtChecks.Rows[i]["cFree2"].ToString(), dtChecks.Rows[i]["cFree3"].ToString(), dtChecks.Rows[i]["cFree4"].ToString(), dtChecks.Rows[i]["cFree5"].ToString(), dtChecks.Rows[i]["cFree6"].ToString(), dtChecks.Rows[i]["cFree7"].ToString(), dtChecks.Rows[i]["cFree8"].ToString(), dtChecks.Rows[i]["cFree9"].ToString(), dtChecks.Rows[i]["cFree10"].ToString(), key);
  318. string inum = dtChecks.Rows[i]["iNum"].ToString();
  319. if (inum == "")
  320. {
  321. inum = "0";
  322. }
  323. DBHelper.UpdateCurrentStockCCGC(cmd, dtChecks.Rows[i]["cInvCode"].ToString(), dtChecks.Rows[i]["cWhCode"].ToString(), dtChecks.Rows[i]["cBatch"].ToString(), -Convert.ToDecimal(dtChecks.Rows[i]["iQuantity"].ToString()), -Convert.ToDecimal(inum), dtChecks.Rows[i]["cFree1"].ToString(),
  324. dtChecks.Rows[i]["cFree2"].ToString(), dtChecks.Rows[i]["cFree3"].ToString(), dtChecks.Rows[i]["cFree4"].ToString(), dtChecks.Rows[i]["cFree5"].ToString(), dtChecks.Rows[i]["cFree6"].ToString(), dtChecks.Rows[i]["cFree7"].ToString(), dtChecks.Rows[i]["cFree8"].ToString(), dtChecks.Rows[i]["cFree9"].ToString(), dtChecks.Rows[i]["cFree10"].ToString(),
  325. "", key, "", "", "", "", head.UpdateTodoQuantity ? (-1 * Convert.ToDecimal(dtChecks.Rows[i]["iQuantity"].ToString())) : 0, head.UpdateTodoQuantity ? (-1 * Convert.ToDecimal(inum)) : 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(dtChecks.Rows[i]["ID"].ToString()), Convert.ToInt32(dtChecks.Rows[i]["AutoID"].ToString()));
  326. sql = @" select * from CurrentStock where cWhCode='" + dtChecks.Rows[i]["cWhCode"].ToString() + @"' and cInvCode='" + dtChecks.Rows[i]["cInvCode"].ToString() + @"' and cBatch='" + dtChecks.Rows[i]["cBatch"].ToString() + @"'
  327. and cVMIVenCode='' and cFree1='" + dtChecks.Rows[i]["cFree1"].ToString() + @"' and cFree2='" + dtChecks.Rows[i]["cFree2"].ToString() + @"' and cFree3='" + dtChecks.Rows[i]["cFree3"].ToString() + @"' and cFree4='" + dtChecks.Rows[i]["cFree4"].ToString() + @"' and cFree5='" + dtChecks.Rows[i]["cFree5"].ToString() + @"'
  328. and cFree6='" + dtChecks.Rows[i]["cFree6"].ToString() + @"' and cFree7='" + dtChecks.Rows[i]["cFree7"].ToString() + @"' and cFree8='" + dtChecks.Rows[i]["cFree8"].ToString() + @"' and cFree9='" + dtChecks.Rows[i]["cFree9"].ToString() + @"' and cFree10='" + dtChecks.Rows[i]["cFree10"].ToString() + @"' ";
  329. curr = DBHelper.SQlReturnData(sql, cmd);
  330. JsonData = JsonConvert.SerializeObject(curr);
  331. log.Info(JsonData);
  332. //回写fOutQuantityy
  333. // sql = @"Update CurrentStock set fOutQuantity=isnull(fOutQuantity,0)-" + Convert.ToDecimal(dtChecks.Rows[i]["iQuantity"].ToString()) + @"
  334. // where cInvCode='" + dtChecks.Rows[i]["cInvCode"].ToString() + "' and cWhCode='" + dtChecks.Rows[i]["cWhCode"].ToString() + "' ";
  335. //if (body.cBatch != null)
  336. //{
  337. // sql += "and cBatch='" + body.cBatch + "'";
  338. //}
  339. //else
  340. //{
  341. // sql += "and cBatch=''";
  342. //}
  343. //DBHelper.CmdExecuteNonQuery(sql, cmd, "回写fOutQuantity失败!");
  344. cmd.CommandText = sql;
  345. cmd.ExecuteNonQuery();
  346. }
  347. #endregion
  348. cmd.CommandType = CommandType.Text;
  349. cmd.Parameters.Clear();
  350. }
  351. cmd.Transaction.Commit();
  352. }
  353. catch (Exception ex)
  354. {
  355. if (cmd.Transaction != null)
  356. cmd.Transaction.Rollback();
  357. log.Error(ex.Message);
  358. throw new Exception(ex.Message);
  359. }
  360. finally
  361. {
  362. if (conn.State == ConnectionState.Open)
  363. {
  364. conn.Close();
  365. }
  366. conn.Dispose();
  367. }
  368. }
  369. ResultFlag = true;
  370. return ResultFlag;
  371. }
  372. /// <summary>
  373. /// 记录日志
  374. /// </summary>
  375. /// <param name="Bills"></param>
  376. private void LogInfo(List<ICSOtherOutDoc> Bills)
  377. {
  378. string HeadList = string.Empty;
  379. string BodyList = string.Empty;
  380. foreach (ICSOtherOutDoc head in Bills)
  381. {
  382. HeadList += "\r\n 表头主键ID:" + head.ID + ",用户:" + head.User + ",站点:" + head.WorkPoint+"";
  383. }
  384. log.Info(HeadList);
  385. log.Info(BodyList);
  386. }
  387. }
  388. }