StationInformationDAL.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. using Maticsoft.DBUtility;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace PMSUI.Model
  9. {
  10. public class StationInformationBLL
  11. {
  12. public static DataSet GetList(string strWhere)
  13. {
  14. StringBuilder sql = new StringBuilder();
  15. sql.Append($"Select * from StationInformation");
  16. if (strWhere.Trim() != "")
  17. {
  18. sql.Append($" where {strWhere}");
  19. }
  20. return DbHelperSQL.Query(sql.ToString());
  21. }
  22. /// <summary>
  23. /// 获取对应得库位状态
  24. /// </summary>
  25. /// <param name="type"></param>
  26. /// <param name="locationCode"></param>
  27. /// <returns></returns>
  28. public static int GetStatus(int id)
  29. {
  30. StringBuilder sql = new StringBuilder();
  31. sql.Append($"Select * from StationInformation where ID=" + id + "");
  32. DataTable dt1 = DbHelperSQL.Query(sql.ToString()).Tables[0];
  33. return int.Parse(dt1.Rows[0]["Status"].ToString());
  34. }
  35. /// <summary>
  36. /// 获取对应得物料信息
  37. /// </summary>
  38. /// <param name="type"></param>
  39. /// <param name="locationCode"></param>
  40. /// <returns></returns>
  41. public static string GetMaterials(int id)
  42. {
  43. StringBuilder sql = new StringBuilder();
  44. sql.Append($"Select * from StationInformation where ID=" + id + "");
  45. DataTable dt1 = DbHelperSQL.Query(sql.ToString()).Tables[0];
  46. return dt1.Rows[0]["Materials"].ToString();
  47. }
  48. //public static Tuple<int, bool> Add(Model.TaskListTable model)
  49. //{
  50. // StringBuilder strSql = new StringBuilder();
  51. // strSql.Append("insert into TaskListTable ");
  52. // strSql.Append(" ([TaskStatus],[AGVID],[TaskType],[UpPos] ,[DownPos],[GoDownPos],[BackToUpPos],[TaskPriority],[CalledTime],[StartTime],[EndTime]) ");
  53. // strSql.Append($" values ('{model.TaskStatus}','{model.AGVID}','{model.TaskType}','{model.UpPos}','{model.DownPos}','{model.GoDownPos}','{model.BackToUpPos}','{model.TaskPriority}','{model.CalledTime}','{model.StartTime}','{model.EndTime}')");
  54. // int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
  55. // if (rows > 0)
  56. // {
  57. // string str = "SELECT IDENT_CURRENT('TaskListTable')";
  58. // DataTable d = DbHelperSQL.Query(str?.ToString()).Tables[0];
  59. // int i = int.Parse(d?.Rows[0][0].ToString());
  60. // return Tuple.Create(i, true);
  61. // }
  62. // else
  63. // {
  64. // return Tuple.Create(-1, false);
  65. // }
  66. //}
  67. public static Tuple<int, bool> GetID(string name)
  68. {
  69. StringBuilder sql = new StringBuilder();
  70. sql.Append($"Select * from StationInformation where Name='{name}'");
  71. DataTable dt1 = DbHelperSQL.Query(sql.ToString()).Tables[0];
  72. if (dt1.Rows.Count > 0)
  73. {
  74. string str = "SELECT IDENT_CURRENT('StationInformation')";
  75. DataTable d = DbHelperSQL.Query(str?.ToString()).Tables[0];
  76. int i = int.Parse(d?.Rows[0][0].ToString());
  77. return Tuple.Create(i, true);
  78. }
  79. else
  80. {
  81. return Tuple.Create(-1, false);
  82. }
  83. }
  84. public static bool Update(int id, int stattus)
  85. {
  86. StringBuilder sql = new StringBuilder();
  87. sql.Append($"update StationInformation set Status='{stattus}' where ID={stattus}");
  88. int row = DbHelperSQL.ExecuteSql(sql.ToString());
  89. if (row > 0)
  90. {
  91. return true;
  92. }
  93. else
  94. {
  95. return false;
  96. }
  97. }
  98. public static bool Update(int id, int stattus, string materitals)
  99. {
  100. StringBuilder sql = new StringBuilder();
  101. sql.Append($"update StationInformation set Status={stattus} ");
  102. if (materitals != "")
  103. {
  104. sql.Append($" , Materials='{materitals}' ");
  105. }
  106. sql.Append($" where ID={id}");
  107. int row = DbHelperSQL.ExecuteSql(sql.ToString());
  108. if (row > 0)
  109. {
  110. return true;
  111. }
  112. else
  113. {
  114. return false;
  115. }
  116. }
  117. public static bool Update(int id, int x, int y)
  118. {
  119. StringBuilder sql = new StringBuilder();
  120. sql.Append($"update StationInformation set LocationX={x} , LocationY ={y} where ID={id}");
  121. int row = DbHelperSQL.ExecuteSql(sql.ToString());
  122. if (row > 0)
  123. {
  124. return true;
  125. }
  126. else
  127. {
  128. return false;
  129. }
  130. }
  131. public static bool Update(StationInformation model)
  132. {
  133. StringBuilder sql = new StringBuilder();
  134. sql.Append($"update StationInformation set Name='{model.Name}',Materials='{model.Materials}',Status={model.Status},Station={model.Station}, JobIndex={model.JobIndex} , Width ={model.Width}, Height ={model.Height}, LocationX ={model.LocationX}, LocationY ={model.LocationY} where ID={model.ID}");
  135. return DbHelperSQL.ExecuteSql(sql.ToString()) > 0 ? true : false;
  136. }
  137. public static bool Delete(int id)
  138. {
  139. StringBuilder sql = new StringBuilder();
  140. sql.Append($"delete StationInformation where ID={id}");
  141. int row = DbHelperSQL.ExecuteSql(sql.ToString());
  142. if (row > 0)
  143. {
  144. return true;
  145. }
  146. else
  147. {
  148. return false;
  149. }
  150. }
  151. public static bool Add(StationInformation model)
  152. {
  153. StringBuilder sql = new StringBuilder();
  154. sql.Append($"INSERT INTO StationInformation([Name],[Materials],[Status],[Station],[JobIndex],[Width],[Height],[LocationX],[LocationY]) ");
  155. sql.Append($" VALUES('{model.Name}','{model.Materials}',{model.Status},{model.Station},{model.JobIndex},{model.Width},{model.Height},{model.LocationX},{model.LocationY})");
  156. return DbHelperSQL.ExecuteSql(sql.ToString()) > 0 ? true : false;
  157. }
  158. }
  159. }