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

169 lines
7.9 KiB

  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. namespace ICSSoft.DataProject
  11. {
  12. public class BRRCode
  13. {
  14. private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  15. private static string connString = System.Configuration.ConfigurationManager.AppSettings["ERPConnStr"];
  16. private static string ERPDB = System.Configuration.ConfigurationManager.AppSettings["ERPDB"];
  17. private static string Type = System.Configuration.ConfigurationManager.AppSettings["Type"];
  18. /// <summary>
  19. /// 审核其他出库单
  20. /// </summary>
  21. /// <param name="Bills"></param>
  22. /// <returns></returns>
  23. // public bool ConfirmRd09(List<ICSBrrowDoc> Bills)
  24. // {
  25. // bool ResultFlag = false;
  26. // SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
  27. // conn.Open();
  28. // SqlTransaction sqlTran = conn.BeginTransaction();
  29. // SqlCommand cmd = new SqlCommand();
  30. // cmd.Transaction = sqlTran;
  31. // cmd.Connection = conn;
  32. // try
  33. // {
  34. // if (Bills.Count <= 0)
  35. // {
  36. // throw new Exception("传送数据为空!");
  37. // }
  38. // LogInfo(Bills);
  39. // foreach (ICSBrrowDoc head in Bills)
  40. // {
  41. // string sql = "";
  42. // ICSUserInfo userInfo = new ICSUserInfo();
  43. // userInfo = DBHelper.GetPersonInfo(head.User, cmd);
  44. // #region 检验单号是否存在
  45. // sql = "select * from HY_DZ_BorrowIn where cCODE ='" + head.BRRCode + "'";
  46. // DataTable dt = DBHelper.SQlReturnData(sql, cmd);
  47. // if (dt != null && dt.Rows.Count > 0)
  48. // {
  49. // string cHandler = dt.Rows[0]["cHandler"].ToString();
  50. // if (!string.IsNullOrEmpty(cHandler))
  51. // {
  52. // throw new Exception("借用单号:" + head.BRRCode + "不是开立状态!");
  53. // }
  54. // }
  55. // else
  56. // {
  57. // throw new Exception("借用单号:" + head.BRRCode + "在U8中不存在!");
  58. // }
  59. // #endregion
  60. // #region 审核其他出库单
  61. // sql = @"UPDATE dbo.HY_DZ_BorrowIn SET cHandler='" + userInfo.UserName + @"' ,
  62. // dVeriDate=CONVERT(VARCHAR(50),GETDATE(),112),dnverifytime=GETDATE() WHERE cCODE ='" + head.BRRCode + "'";
  63. // DBHelper.CmdExecuteNonQuery(sql, cmd, "审核其他出库单失败!");
  64. // #endregion
  65. // sql = "select * from dbo.HY_DZ_BorrowIns a inner join HY_DZ_BorrowIn b on a.ID=b.ID where b.cCODE='" + head.BRRCode + "';";
  66. // DataTable dtChecks = DBHelper.SQlReturnData(sql, cmd);
  67. // #region 更新现存量
  68. // for (int i = 0; i < dtChecks.Rows.Count; i++)
  69. // {
  70. // //判断物料批号与现存量表批号是否一致、数量不能超过现存量物料数量
  71. // sql = @"SELECT cBatch,iQuantity from CurrentStock WHERE cInvCode='" + dtChecks.Rows[i]["cInvCode"].ToString() + "'AND cBatch=''and cWhCode='" + dtChecks.Rows[i]["cWhCode"].ToString() + "'";
  72. // DataTable dtItem = DBHelper.SQlReturnData(sql, cmd);
  73. // if (dtItem != null && dtItem.Rows.Count > 0)
  74. // {
  75. // //if (!dtItem.Rows[0]["cBatch"].ToString().Equals(body.cBatch))
  76. // //{
  77. // // throw new Exception("物料条码的批号与U8现存量物料批号不一致,物料:" + body.cInvCode);
  78. // //}
  79. // if (Convert.ToDecimal(dtItem.Rows[0]["iQuantity"].ToString()) < Convert.ToDecimal(dtChecks.Rows[i]["iQuantity"].ToString()))
  80. // {
  81. // throw new Exception("物料条码的数量大于U8现存量物料数量,物料:" + dtChecks.Rows[i]["cInvCode"].ToString());
  82. // }
  83. // }
  84. // else
  85. // {
  86. // throw new Exception("物料:" + dtChecks.Rows[i]["cInvCode"].ToString() + "在现存量表中不存在!");
  87. // }
  88. // VouchKey key = new VouchKey();
  89. // key.cBustypeUN = "借出";
  90. // key.cVouchTypeUN = "09";
  91. // key.TableName = "IA_ST_UnAccountVouch09";
  92. // DBHelper.UpdateCurrentStock(cmd, dtChecks.Rows[i]["cInvCode"].ToString(), dtChecks.Rows[i]["cWhCode"].ToString(), "", -Convert.ToDecimal(dtChecks.Rows[i]["iQuantity"].ToString()), key);
  93. // //回写fOutQuantityy
  94. // // sql = @"Update CurrentStock set fOutQuantity=isnull(fOutQuantity,0)-" + Convert.ToDecimal(dtChecks.Rows[i]["iQuantity"].ToString()) + @"
  95. // // where cInvCode='" + dtChecks.Rows[i]["cInvCode"].ToString() + "' and cWhCode='" + dtChecks.Rows[i]["cWhCode"].ToString() + "' ";
  96. // //if (body.cBatch != null)
  97. // //{
  98. // // sql += "and cBatch='" + body.cBatch + "'";
  99. // //}
  100. // //else
  101. // //{
  102. // // sql += "and cBatch=''";
  103. // //}
  104. // //DBHelper.CmdExecuteNonQuery(sql, cmd, "回写fOutQuantity失败!");
  105. // //if (head.UpdateTodoQuantity == true)
  106. // //{
  107. // #region 判断现存量是否足够
  108. // sql = @"IF EXISTS(SELECT AutoID FROM dbo.CurrentStock WHERE iQuantity<0 OR iNum<0 OR fOutQuantity<0)
  109. // BEGIN
  110. // DECLARE @MSG NVARCHAR(100)
  111. // SELECT @MSG='ERP待出库数量不足!AutoID:'+CAST(AutoID AS NVARCHAR(100)) FROM dbo.CurrentStock WHERE iQuantity<0 OR iNum<0 OR fOutQuantity<0
  112. // RAISERROR(@MSG,16,1)
  113. // END";
  114. // cmd.CommandText = sql;
  115. // cmd.ExecuteNonQuery();
  116. // #endregion
  117. // }
  118. // #endregion
  119. // }
  120. // cmd.Transaction.Commit();
  121. // ResultFlag = true;
  122. // return ResultFlag;
  123. // }
  124. // catch (Exception ex)
  125. // {
  126. // cmd.Transaction.Rollback();
  127. // log.Error(ex.Message);
  128. // throw new Exception(ex.Message);
  129. // }
  130. // finally
  131. // {
  132. // if (conn.State == ConnectionState.Open)
  133. // {
  134. // conn.Close();
  135. // }
  136. // conn.Dispose();
  137. // }
  138. // }
  139. /// <summary>
  140. /// 记录日志
  141. /// </summary>
  142. /// <param name="Bills"></param>
  143. //private void LogInfo(List<ICSBrrowDoc> Bills)
  144. //{
  145. // string HeadList = string.Empty;
  146. // string BodyList = string.Empty;
  147. // foreach (ICSBrrowDoc head in Bills)
  148. // {
  149. // HeadList += "\r\n 借用单号:" + head.BRRCode + ",用户:" + head.User + "";
  150. // }
  151. // log.Info(HeadList);
  152. // log.Info(BodyList);
  153. //}
  154. }
  155. }