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

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