华恒Mes鼎捷代码
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.

201 lines
6.7 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using ICSSoft.Frame.Data.Entity;
  6. using ICSSoft.Base.Config.AppConfig;
  7. using System.Data;
  8. using System.Data.Sql;
  9. using System.Data.Linq;
  10. using ICSSoft.Base.Config.DBHelper;
  11. namespace ICSSoft.Frame.Data.DAL
  12. {
  13. public class ICSOQCCKGROUPDAL
  14. {
  15. public static void AddandEdit(ICSOQCCKGROUP MODEL, string Appconstr)
  16. {
  17. FramDataContext db = new FramDataContext(Appconstr);
  18. db.Connection.Open();
  19. db.Transaction = db.Connection.BeginTransaction();
  20. try
  21. {
  22. bool isNew = false;
  23. var line = db.ICSOQCCKGROUP.SingleOrDefault(a => a.ID == MODEL.ID);
  24. if (line == null)
  25. {
  26. isNew = true;
  27. line = new ICSOQCCKGROUP();
  28. line.ID = MODEL.ID;
  29. }
  30. line.CKGROUP = MODEL.CKGROUP;
  31. line.CKGROUPDNAME = MODEL.CKGROUPDNAME;
  32. line.CKGROUPDESC = MODEL.CKGROUPDESC;
  33. line.ISREF = MODEL.ISREF;
  34. line.MUSERName = MODEL.MUSERName;
  35. line.MUSER = MODEL.MUSER;
  36. line.MTIME = MODEL.MTIME;
  37. line.WorkPoint = AppConfig.WorkPointCode;
  38. if (isNew) db.ICSOQCCKGROUP.InsertOnSubmit(line);
  39. db.SubmitChanges();
  40. db.Transaction.Commit();
  41. }
  42. catch (Exception ex)
  43. {
  44. db.Transaction.Rollback();
  45. throw new Exception(ex.Message);
  46. }
  47. }
  48. public static string AddList(List<ICSOQCCKGROUP> InfoList, string Appconstr)
  49. {
  50. FramDataContext db = new FramDataContext(Appconstr);
  51. db.Connection.Open();
  52. db.Transaction = db.Connection.BeginTransaction();
  53. try
  54. {
  55. string str = "OK";
  56. foreach (ICSOQCCKGROUP info in InfoList)
  57. {
  58. bool isNew = false;
  59. var line = db.ICSOQCCKGROUP.SingleOrDefault(a => a.CKGROUP == info.CKGROUP);
  60. if (line == null)
  61. {
  62. isNew = true;
  63. line = new ICSOQCCKGROUP();
  64. line.ID = AppConfig.GetGuid();
  65. }
  66. line.CKGROUP = info.CKGROUP;
  67. line.CKGROUPDESC = info.CKGROUPDESC;
  68. line.CKGROUPDNAME = info.CKGROUPDNAME;
  69. line.ISREF = info.ISREF;
  70. line.MUSER = info.MUSER;
  71. line.MUSERName = info.MUSERName;
  72. line.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  73. line.WorkPoint = AppConfig.WorkPointCode;
  74. line.EATTRIBUTE1 = null;
  75. if (isNew) db.ICSOQCCKGROUP.InsertOnSubmit(line);
  76. db.SubmitChanges();
  77. }
  78. db.Transaction.Commit();
  79. return str;
  80. }
  81. catch (Exception ex)
  82. {
  83. db.Transaction.Rollback();
  84. throw new Exception(ex.Message);
  85. }
  86. }
  87. public static ICSOQCCKGROUP search(string CKGROUP, String Appconstr)
  88. {
  89. FramDataContext db = new FramDataContext(Appconstr);
  90. db.Connection.Open();
  91. db.Transaction = db.Connection.BeginTransaction();
  92. ICSOQCCKGROUP entity = new ICSOQCCKGROUP();
  93. try
  94. {
  95. var line = db.ICSOQCCKGROUP.SingleOrDefault(a => a.CKGROUP == CKGROUP);
  96. return (ICSOQCCKGROUP)line;
  97. }
  98. catch (Exception ex)
  99. {
  100. throw new Exception(ex.Message);
  101. }
  102. }
  103. public static void delete(List<String> guidList)
  104. {
  105. FramDataContext db = new FramDataContext(AppConfig.AppConnectString);
  106. db.Connection.Open();
  107. db.Transaction = db.Connection.BeginTransaction();
  108. try
  109. {
  110. var lines = db.ICSOQCCKGROUP.Where(a => guidList.Contains(a.ID));
  111. db.ICSOQCCKGROUP.DeleteAllOnSubmit(lines);
  112. db.SubmitChanges();
  113. db.Transaction.Commit();
  114. }
  115. catch (Exception ex)
  116. {
  117. db.Transaction.Rollback();
  118. throw ex;
  119. }
  120. }
  121. #region 获取检验方式
  122. public static DataTable SearchData(string dsconn)
  123. {
  124. try
  125. {
  126. string sql = @"SELECT EnumKey, EnumText FROM Sys_EnumValues WHERE 1=1 AND EnumKey = '00015' AND WorkPointCode = '{0}' ";
  127. sql = string.Format(sql, AppConfig.WorkPointCode);
  128. DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
  129. return dt;
  130. }
  131. catch (Exception ex)
  132. {
  133. throw ex;
  134. }
  135. }
  136. public static DataTable SearchData(string EnumText, string dsconn)
  137. {
  138. try
  139. {
  140. string sql = @"SELECT EnumKey, EnumText FROM Sys_EnumValues WHERE 1=1 AND EnumKey = '00015' AND EnumText = '{0}' AND WorkPointCode = '{1}' ";
  141. sql = string.Format(sql, EnumText, AppConfig.WorkPointCode);
  142. DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
  143. return dt;
  144. }
  145. catch (Exception ex)
  146. {
  147. throw ex;
  148. }
  149. }
  150. #endregion
  151. #region 获取检验属性
  152. public static DataTable SearchDataa(string dsconn)
  153. {
  154. try
  155. {
  156. string sql = @"SELECT EnumKey, EnumText FROM Sys_EnumValues WHERE 1=1 AND EnumKey = '00016' AND WorkPointCode = '{0}' ";
  157. sql = string.Format(sql, AppConfig.WorkPointCode);
  158. DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
  159. return dt;
  160. }
  161. catch (Exception ex)
  162. {
  163. throw ex;
  164. }
  165. }
  166. public static DataTable SearchDataa(string EnumText, string dsconn)
  167. {
  168. try
  169. {
  170. string sql = @"SELECT EnumKey, EnumText FROM Sys_EnumValues WHERE 1=1 AND EnumKey = '00016' AND EnumText = '{0}' AND WorkPointCode = '{1}' ";
  171. sql = string.Format(sql, EnumText, AppConfig.WorkPointCode);
  172. DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
  173. return dt;
  174. }
  175. catch (Exception ex)
  176. {
  177. throw ex;
  178. }
  179. }
  180. #endregion
  181. }
  182. }