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

104 lines
4.2 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
  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. public class SalesReturnBack
  14. {
  15. /// <summary>
  16. /// 获取销售发货
  17. /// </summary>
  18. /// <param name="infos"></param>
  19. /// <returns></returns>
  20. private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  21. private static string connString = System.Configuration.ConfigurationManager.AppSettings["ERPConnStr"];
  22. private static string ERPDB = System.Configuration.ConfigurationManager.AppSettings["ERPDB"];
  23. private static string Type = System.Configuration.ConfigurationManager.AppSettings["Type"];
  24. public string Get(List<ICSSalesReturnBack> infos)
  25. {
  26. List<ICSSalesReturnBack> szJson = new List<ICSSalesReturnBack>();
  27. DataTable dt = null;
  28. DataTable dtNew = null;
  29. string connS = "";
  30. string json = "";
  31. if (infos.Count <= 0)
  32. {
  33. throw new Exception("传送数据为空!");
  34. }
  35. string res = string.Empty;
  36. SqlConnection conn = new SqlConnection();
  37. SqlCommand cmd = new SqlCommand();
  38. string sql = string.Empty;
  39. foreach (ICSSalesReturnBack info in infos)
  40. {
  41. try
  42. {
  43. connS = string.Format(connString, info.WorkPoint);
  44. conn = new System.Data.SqlClient.SqlConnection(connS);
  45. conn.Open();
  46. SqlTransaction sqlTran = conn.BeginTransaction();
  47. cmd = new SqlCommand();
  48. cmd.Transaction = sqlTran;
  49. cmd.Connection = conn;
  50. if (info.MTime < new DateTime(2000, 01, 01))
  51. throw new Exception("请输入正确的操作时间:" + info.MTime);
  52. sql = @" select a.DLID ,a.cDLCode ,a.cCusCode,c.cCusName,a.cDepCode ,
  53. d.cDepName,b.cordercode ,a.cMaker ,a.dcreatesystime ,
  54. b.AutoID ,b.irowno,b.cInvCode ,b.iQuantity ,b.iNum ,b.iSOsID
  55. FROM dbo.DispatchList a
  56. INNER JOIN dbo.DispatchLists b ON a.DLID = b.DLID
  57. LEFT JOIN dbo.Customer c ON a.cCusCode = c.cCusCode
  58. left join Department d on a.cDepCode=d.cDepCode where b.iQuantity<0";
  59. if (!string.IsNullOrWhiteSpace(info.SDNRTCode))
  60. {
  61. sql += " and a.cDLCode='{0}'";
  62. }
  63. if (!string.IsNullOrWhiteSpace(info.MTime.ToString()))
  64. {
  65. sql += " and ISNULL(a.dnmodifytime ,ISNULL(a.dverifydate , ISNULL(a.dnmodifytime , a.dcreatesystime )))>='{1}'";
  66. }
  67. if (!string.IsNullOrWhiteSpace(info.User))
  68. {
  69. sql += "and a.CMAKER='{2}'";
  70. }
  71. sql = string.Format(sql, info.SDNRTCode, info.MTime, info.User);
  72. dt = DBHelper.SQlReturnData(sql, cmd);
  73. if (dt.Rows.Count <= 0 || dt == null)
  74. throw new Exception("销售发货单号:" + info.SDNRTCode + ",无信息!");
  75. dtNew.Merge(dt);
  76. cmd.Transaction.Commit();
  77. }
  78. catch (Exception ex)
  79. {
  80. cmd.Transaction.Rollback();
  81. log.Error(ex.Message);
  82. throw new Exception(ex.Message);
  83. }
  84. finally
  85. {
  86. if (conn.State == ConnectionState.Open)
  87. {
  88. conn.Close();
  89. }
  90. conn.Dispose();
  91. }
  92. }
  93. json = JsonConvert.SerializeObject(dtNew);
  94. return json;
  95. }
  96. }
  97. }