爱思开
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.

78 lines
2.9 KiB

2 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.IO;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace ICSSoft.DataProject
  13. {
  14. /// <summary>
  15. /// 管控方式
  16. /// </summary>
  17. public class ICSControlModeService
  18. {
  19. private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  20. private static string connString = System.Configuration.ConfigurationManager.AppSettings["ConnStr"];
  21. private static string ERPDB = System.Configuration.ConfigurationManager.AppSettings["ERPDB"];
  22. DataTable table = null;
  23. SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
  24. string sql = string.Empty;
  25. string sqlInfo = string.Empty;
  26. VerificationMethod verification = new VerificationMethod();
  27. /// <summary>
  28. /// 获取当前启用的管控方式
  29. /// </summary>
  30. /// <param name="cmd"></param>
  31. /// <param name="language"></param>
  32. /// <returns></returns>
  33. /// <exception cref="Exception"></exception>
  34. public static List<ControlMode> GetControlModes()
  35. {
  36. using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString))
  37. {
  38. conn.Open();
  39. SqlCommand cmd = new SqlCommand();
  40. SqlTransaction sqlTran = conn.BeginTransaction();
  41. cmd.Transaction = sqlTran;
  42. cmd.Connection = conn;
  43. try
  44. {
  45. string sql = @"SELECT F_ItemCode as itemCode,F_ItemName as itemName,F_EnabledMark as enableMark FROM [dbo].[Sys_SRM_ItemsDetail] WHERE F_ItemCode='ControlMode01' OR F_ItemCode='ControlMode02'";
  46. sql = string.Format(sql, cmd);
  47. DataTable table = DBHelper.SQlReturnData(sql, cmd);
  48. string json = JsonConvert.SerializeObject(table);
  49. //ControlMode model = JsonConvert.DeserializeObject<ControlMode>(json);
  50. List<ControlMode> model = JsonConvert.DeserializeObject<List<ControlMode>>(json);
  51. cmd.Transaction.Commit();
  52. return model;
  53. }
  54. catch (Exception ex)
  55. {
  56. if (cmd.Transaction != null)
  57. cmd.Transaction.Rollback();
  58. log.Error(ex.Message);
  59. throw new Exception(ex.Message);
  60. }
  61. finally
  62. {
  63. if (conn.State == ConnectionState.Open)
  64. {
  65. conn.Close();
  66. }
  67. conn.Dispose();
  68. }
  69. }
  70. }
  71. }
  72. }