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

87 lines
3.6 KiB

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