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

69 lines
2.7 KiB

2 years ago
2 years ago
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.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace ICSSoft.DataProject
  12. {
  13. /// <summary>
  14. /// 自定义语言服务
  15. /// </summary>
  16. public class ICSDefiniteLanguageService
  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 static string GetLanguage()
  27. {
  28. using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString))
  29. {
  30. conn.Open();
  31. SqlCommand cmd = new SqlCommand();
  32. SqlTransaction sqlTran = conn.BeginTransaction();
  33. cmd.Transaction = sqlTran;
  34. cmd.Connection = conn;
  35. try
  36. {
  37. string sql = @"select top 1 b.F_Define1 as DefineCode,b.F_itemCode as ItemCode,b.F_ItemName as ItemName
  38. from Sys_SRM_Items a left join Sys_SRM_ItemsDetail b on a.F_Id=b.F_ItemId
  39. where a.F_EnCode='LGG0001' and b.F_EnabledMark='1' order by b.F_ItemCode";
  40. DataTable table = DBHelper.SQlReturnData(sql, cmd);
  41. string json = JsonConvert.SerializeObject(table);
  42. List<LanguageModel> modelList = JsonConvert.DeserializeObject<List<LanguageModel>>(json);
  43. // LanguageModel model = JsonConvert.DeserializeObject<LanguageModel>(json);
  44. cmd.Transaction.Commit();
  45. return modelList[0].DefineCode;
  46. // return model.DefineCode;
  47. }
  48. catch(Exception ex)
  49. {
  50. if (cmd.Transaction != null)
  51. cmd.Transaction.Rollback();
  52. log.Error(ex.Message);
  53. throw new Exception(ex.Message);
  54. }
  55. finally
  56. {
  57. if (conn.State == ConnectionState.Open)
  58. {
  59. conn.Close();
  60. }
  61. conn.Dispose();
  62. }
  63. }
  64. }
  65. }
  66. }