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

109 lines
3.6 KiB

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. /// pda版本
  15. /// </summary>
  16. public class ICSWMSVersions
  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. DataTable table = null;
  22. SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
  23. string sql = string.Empty;
  24. string sqlInfo = string.Empty;
  25. VerificationMethod verification = new VerificationMethod();
  26. public List<ICSVersions> Get(ICSVersions JsonData)
  27. {
  28. conn.Open();
  29. SqlTransaction sqlTran = conn.BeginTransaction();
  30. SqlCommand cmd = new SqlCommand();
  31. cmd.Transaction = sqlTran;
  32. cmd.Connection = conn;
  33. try
  34. {
  35. sql = @"select top(1)* from ICSVersions where 1=1";
  36. if (!string.IsNullOrWhiteSpace(JsonData.ProjectName))
  37. {
  38. sql += " and ProjectName='{0}'";
  39. }
  40. sql = string.Format(sql, JsonData.ProjectName);
  41. table = DBHelper.SQlReturnData(sql, cmd);
  42. string json = JsonConvert.SerializeObject(table);
  43. List<ICSVersions> model = JsonConvert.DeserializeObject<List<ICSVersions>>(json);
  44. cmd.Transaction.Commit();
  45. return model;
  46. }
  47. catch (Exception ex)
  48. {
  49. if (cmd.Transaction != null)
  50. cmd.Transaction.Rollback();
  51. log.Error(ex.Message);
  52. throw new Exception(ex.Message);
  53. }
  54. finally
  55. {
  56. if (conn.State == ConnectionState.Open)
  57. {
  58. conn.Close();
  59. }
  60. conn.Dispose();
  61. }
  62. }
  63. public List<ICSWorkPoint> GetWorkPoint(ICSWorkPoint JsonData)
  64. {
  65. conn.Open();
  66. SqlTransaction sqlTran = conn.BeginTransaction();
  67. SqlCommand cmd = new SqlCommand();
  68. cmd.Transaction = sqlTran;
  69. cmd.Connection = conn;
  70. try
  71. {
  72. sql = @"select * from Sys_WorkPoint where 1=1";
  73. if (!string.IsNullOrWhiteSpace(JsonData.WorkPointCode))
  74. {
  75. sql += " and WorkPointCode='{0}'";
  76. }
  77. sql = string.Format(sql, JsonData.WorkPointCode);
  78. table = DBHelper.SQlReturnData(sql, cmd);
  79. string json = JsonConvert.SerializeObject(table);
  80. List<ICSWorkPoint> model = JsonConvert.DeserializeObject<List<ICSWorkPoint>>(json);
  81. cmd.Transaction.Commit();
  82. return model;
  83. }
  84. catch (Exception ex)
  85. {
  86. if (cmd.Transaction != null)
  87. cmd.Transaction.Rollback();
  88. log.Error(ex.Message);
  89. throw new Exception(ex.Message);
  90. }
  91. finally
  92. {
  93. if (conn.State == ConnectionState.Open)
  94. {
  95. conn.Close();
  96. }
  97. conn.Dispose();
  98. }
  99. }
  100. }
  101. }