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

151 lines
6.5 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
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 ICSControlModeService
  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. /// <summary>
  27. /// 获取当前启用的管控方式
  28. /// </summary>
  29. /// <param name="cmd"></param>
  30. /// <param name="language"></param>
  31. /// <returns></returns>
  32. /// <exception cref="Exception"></exception>
  33. public static ControlMode GetControlMode()
  34. {
  35. using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString))
  36. {
  37. conn.Open();
  38. SqlCommand cmd = new SqlCommand();
  39. SqlTransaction sqlTran = conn.BeginTransaction();
  40. cmd.Transaction = sqlTran;
  41. cmd.Connection = conn;
  42. try
  43. {
  44. string sql = @"SELECT TOP 1 F_ItemCode as itemCode,F_ItemName as itemName,F_EnabledMark as enableMark
  45. FROM [dbo].[Sys_SRM_ItemsDetail] WHERE F_ItemId='14361ce1-c5e3-4e85-a253-51aa3cdde3e6'AND F_EnabledMark='1' ORDER BY F_ItemCode";
  46. DataTable table = DBHelper.SQlReturnData(sql, cmd);
  47. string json = JsonConvert.SerializeObject(table);
  48. List<ControlMode> model = JsonConvert.DeserializeObject<List<ControlMode>>(json);
  49. cmd.Transaction.Commit();
  50. return model[0];
  51. }
  52. catch (Exception ex)
  53. {
  54. if (cmd.Transaction != null)
  55. cmd.Transaction.Rollback();
  56. log.Error(ex.Message);
  57. throw new Exception(ex.Message);
  58. }
  59. finally
  60. {
  61. if (conn.State == ConnectionState.Open)
  62. {
  63. conn.Close();
  64. }
  65. conn.Dispose();
  66. }
  67. }
  68. }
  69. /// <summary>
  70. /// 根据条码获取信息
  71. /// </summary>
  72. /// <param name="LotNo"></param>
  73. /// <param name="WorkPoint"></param>
  74. /// <returns></returns>
  75. /// <exception cref="Exception"></exception>
  76. public static string QueryLotNo(string LotNo,string WorkPoint)
  77. {
  78. using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString))
  79. {
  80. conn.Open();
  81. SqlCommand cmd = new SqlCommand();
  82. SqlTransaction sqlTran = conn.BeginTransaction();
  83. cmd.Transaction = sqlTran;
  84. cmd.Connection = conn;
  85. try
  86. {
  87. string sql = @"SELECT a.ID,
  88. con.ContainerCode,
  89. con.ContainerName,
  90. a.LotNo,
  91. a.InvCode,
  92. inv.InvName,
  93. inv.InvStd,
  94. inv.InvUnit,-- {0}
  95. inv.AmountUnit,
  96. ext.ID AS ExtensionID,
  97. ext.ProjectCode,
  98. ext.Version,
  99. ext.BatchCode,
  100. ext.Brand,
  101. ext.cFree1,
  102. ext.cFree2,
  103. ext.cFree3,
  104. ext.cFree4,
  105. ext.cFree5,
  106. ext.cFree6,
  107. ext.cFree7,
  108. ext.cFree8,
  109. ext.cFree9,
  110. ext.cFree10,
  111. a.MUSER AS [ USER ],
  112. a.MTIME AS [ MTime ]
  113. FROM
  114. ICSInventoryLot a
  115. LEFT JOIN ICSContainerLot conlot ON a.LotNo = conlot.LotNo AND a.WorkPoint = conlot.WorkPoint
  116. LEFT JOIN ICSContainer con ON conlot.ContainerID = con.ID AND conlot.WorkPoint = con.WorkPoint
  117. INNER JOIN ICSInventory inv ON a.InvCode = inv.InvCode AND a.WorkPoint = inv.WorkPoint
  118. INNER JOIN ICSExtension ext ON a.ExtensionID = ext.ID AND a.WorkPoint = ext.WorkPoint
  119. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'";
  120. sql = string.Format(sql, LotNo, WorkPoint);
  121. DataTable table = DBHelper.SQlReturnData(sql, cmd);
  122. string json = JsonConvert.SerializeObject(table);
  123. //List<LotNoMode> model = JsonConvert.DeserializeObject<List<LotNoMode>>(json);
  124. cmd.Transaction.Commit();
  125. return json;
  126. }
  127. catch (Exception ex)
  128. {
  129. if (cmd.Transaction != null)
  130. cmd.Transaction.Rollback();
  131. log.Error(ex.Message);
  132. throw new Exception(ex.Message);
  133. }
  134. finally
  135. {
  136. if (conn.State == ConnectionState.Open)
  137. {
  138. conn.Close();
  139. }
  140. conn.Dispose();
  141. }
  142. }
  143. }
  144. }
  145. }