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

99 lines
4.1 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 OutsourcingOrderPick
  14. {
  15. private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  16. private static string connString = System.Configuration.ConfigurationManager.AppSettings["ConnStr"];
  17. private static string ERPDB = System.Configuration.ConfigurationManager.AppSettings["ERPDB"];
  18. public string Get(List<ICSOutsourcingOrderPick> infos)
  19. {
  20. List<ICSOutsourcingOrderPick> szJson = new List<ICSOutsourcingOrderPick>();
  21. DataTable dt = null;
  22. DataTable dtNew = null;
  23. string connS = "";
  24. string json = "";
  25. if (infos.Count <= 0)
  26. {
  27. throw new Exception("传送数据为空!");
  28. }
  29. string res = string.Empty;
  30. SqlConnection conn = new SqlConnection();
  31. SqlCommand cmd = new SqlCommand();
  32. string sql = string.Empty;
  33. foreach (ICSOutsourcingOrderPick info in infos)
  34. {
  35. try
  36. {
  37. connS = string.Format(connString, info.WorkPoint);
  38. conn = new System.Data.SqlClient.SqlConnection(connS);
  39. conn.Open();
  40. SqlTransaction sqlTran = conn.BeginTransaction();
  41. cmd = new SqlCommand();
  42. cmd.Transaction = sqlTran;
  43. cmd.Connection = conn;
  44. if (info.MTime < new DateTime(2000, 01, 01))
  45. throw new Exception("请输入正确的操作时间:" + info.MTime);
  46. sql = @" SELECT a.MOID,a.cCode,a.cDepCode,e.cDepName, a.csrccode ,a.cMaker ,a.dCreateTime,a.cVerifier ,a.dVerifyTime
  47. ,b.MODetailsID ODetailsID ,b.iVouchRowNo ,b.cInvCode ,b.iQuantity ,b.iArrQTY ,b.dArriveDate ,b.iTaxPrice ,d.AutoID
  48. FROM dbo.OM_MOMain a
  49. INNER JOIN dbo.OM_MODetails b ON a.MOID=b.MOID
  50. left join PU_AppVouch c on a.csrccode=c.cCode
  51. left join PU_AppVouchs d on c.ID =d.ID
  52. left join Department e on a.cDepCode =e.cDepCode ";
  53. if (!string.IsNullOrWhiteSpace(info.OOCode))
  54. {
  55. sql += " and a.cCode='{0}'";
  56. }
  57. if (!string.IsNullOrWhiteSpace(info.MTime.ToString()))
  58. {
  59. sql += " and ISNULL(a.cModifyTime,ISNULL(a.cAuditTime, ISNULL(a.cModifyTime, a.cmaketime)))>='{2}'";
  60. }
  61. if (!string.IsNullOrWhiteSpace(info.User))
  62. {
  63. sql += "and a.CMAKER='{3}'";
  64. }
  65. sql = string.Format(sql, info.OOCode, info.MTime, info.User);
  66. dt = DBHelper.SQlReturnData(sql, cmd);
  67. if (dt.Rows.Count <= 0 || dt == null)
  68. throw new Exception("委外订单号:" + info.OOCode + ",无信息!");
  69. if (dtNew == null)
  70. dtNew = dt;
  71. else
  72. dtNew.Merge(dt);
  73. cmd.Transaction.Commit();
  74. }
  75. catch (Exception ex)
  76. {
  77. cmd.Transaction.Rollback();
  78. log.Error(ex.Message);
  79. throw new Exception(ex.Message);
  80. }
  81. finally
  82. {
  83. if (conn.State == ConnectionState.Open)
  84. {
  85. conn.Close();
  86. }
  87. conn.Dispose();
  88. }
  89. }
  90. json = JsonConvert.SerializeObject(dtNew);
  91. return json;
  92. }
  93. }
  94. }