DAL_AMYields.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. using MOKA_Factory_Tools.Models;
  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 MOKA_Factory_Tools.DAL
  9. {
  10. public class DAL_AMYields : BaseDAL
  11. {
  12. public DAL_AMYields(int NTFposion)
  13. {
  14. this.TableFieldNameString = "";
  15. if (NTFposion == 1)
  16. this.cps.SetConnectParameters(databaseServer: "10.138.96.109", databaseName: "IDOtherData", databaseAccount: "usr_rd", databasePassword: "Pa55W0rd4TMSA@202207#");
  17. else if (NTFposion == 2)
  18. this.cps.SetConnectParameters(databaseServer: "10.146.0.53", databaseName: "Amazon", databaseAccount: "GGuest", databasePassword: "Kintsugi$23");
  19. }
  20. #region 属性和字段
  21. string _tableName = "AMYields";
  22. /// <summary>
  23. /// 获取数据表名
  24. /// </summary>
  25. public override string TableName
  26. {
  27. get { return _tableName; }
  28. set { this._tableName = value; }
  29. }
  30. /// <summary>
  31. /// 获取当前新的数据表模型对象
  32. /// </summary>
  33. public override object ObjModel
  34. {
  35. get
  36. {
  37. return this.CurrentModel;
  38. }
  39. }
  40. /// <summary>
  41. /// 获取当前新的MOdel
  42. /// </summary>
  43. public AMYields CurrentModel
  44. {
  45. get { return new AMYields(); }
  46. }
  47. string _tableFieldNameString = "";
  48. /// <summary>
  49. /// 数据表字段名数组
  50. /// </summary>
  51. public override string TableFieldNameString
  52. {
  53. get { return this._tableFieldNameString; }
  54. set { this._tableFieldNameString = value; }
  55. }
  56. #endregion
  57. #region 检查记录
  58. //基类已经实现
  59. #endregion
  60. #region 增加数据
  61. /// <summary>
  62. /// 增加一条数据
  63. /// </summary>
  64. /// <param name="model">Model对象</param>
  65. /// <returns></returns>
  66. public bool Add(AMYields model)
  67. {
  68. return base.Add(model);
  69. }
  70. /// <summary>
  71. /// 增加一条数据
  72. /// </summary>
  73. /// <param name="model">Model对象</param>
  74. /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
  75. /// <returns></returns>
  76. public bool Add(AMYields model, string overlookFieldList = "ID")
  77. {
  78. return base.Add(model, overlookFieldList);
  79. }
  80. #endregion
  81. #region 删除数据
  82. /// <summary>
  83. /// 删除数据
  84. /// </summary>
  85. /// <param name="model"></param>
  86. /// <returns></returns>
  87. public bool Delete(AMYields model)
  88. {
  89. return base.Delete(model.ID);
  90. }
  91. #endregion
  92. #region 更新数据
  93. /// <summary>
  94. /// 更新一条数据
  95. /// </summary>
  96. public bool Update(AMYields model)
  97. {
  98. return base.Update(model);
  99. }
  100. /// <summary>
  101. /// 根据筛选字段和SQL筛选运算符号更新数据
  102. /// </summary>
  103. /// <param name="model">Model对象</param>
  104. /// <param name="filterFieldName">筛选字段名称</param>
  105. /// <param name="operators">SQL筛选运算符号</param>
  106. /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
  107. /// <returns></returns>
  108. public bool Update(AMYields model, string filterFieldName = "ID", string operators = "=", string overlookFieldList = "ID")
  109. {
  110. return base.Update(model, filterFieldName, operators, overlookFieldList);
  111. }
  112. #endregion
  113. #region 查询数据
  114. /// <summary>
  115. /// 得到一个对象实体
  116. /// </summary>
  117. public AMYields GetModel(string strWhere)
  118. {
  119. return DataRowToModel(GetDataRow(strWhere));
  120. }
  121. /// <summary>
  122. /// 得到一个对象实体
  123. /// </summary>
  124. public AMYields GetModel(string strLine, string strStation, string ODF, DateTime TestDate, int TestHour)
  125. {
  126. return DataRowToModel(GetDataRow(string.Format("Line = '{0}' and Station = '{1}' and ODF='{2}' and TestDate='{3}' and TestHour='{4}'", strLine, strStation, ODF, TestDate, TestHour)));
  127. }
  128. /// <summary>
  129. /// 得到一个对象实体
  130. /// </summary>
  131. /// <param name="row"></param>
  132. /// <returns></returns>
  133. public AMYields DataRowToModel(DataRow row)
  134. {
  135. return DataRowToModelObject(row) as AMYields;
  136. }
  137. /// <summary>
  138. /// 获得数据Model列表
  139. /// </summary>
  140. /// <param name="strWhere">条件 不包含 where 关键字</param>
  141. public List<AMYields> GetModelList(string strWhere)
  142. {
  143. DataSet ds = base.GetList(strWhere);
  144. return DataTableToList(ds.Tables[0]);
  145. }
  146. /// <summary>
  147. /// 获得数据列表
  148. /// </summary>
  149. /// <param name="dt">DataTable</param>
  150. public List<AMYields> DataTableToList(DataTable dt)
  151. {
  152. List<AMYields> modelList = new List<AMYields>();
  153. List<object> ObjList = base.GetDataTableToOblList(dt);
  154. foreach (object obj in ObjList)
  155. {
  156. modelList.Add((AMYields)obj);
  157. }
  158. return modelList;
  159. }
  160. #endregion
  161. }
  162. public class DAL_AMYields_TR : BaseDAL
  163. {
  164. public DAL_AMYields_TR(int NTFposion)
  165. {
  166. this.TableFieldNameString = "";
  167. if (NTFposion == 1)
  168. this.cps.SetConnectParameters(databaseServer: "10.138.96.109", databaseName: "IDOtherData", databaseAccount: "usr_rd", databasePassword: "Pa55W0rd4TMSA@202207#");
  169. else if (NTFposion == 2)
  170. this.cps.SetConnectParameters(databaseServer: "10.146.0.53", databaseName: "Amazon", databaseAccount: "GGuest", databasePassword: "Kintsugi$23");
  171. }
  172. #region 属性和字段
  173. string _tableName = "AMYields_TR";
  174. /// <summary>
  175. /// 获取数据表名
  176. /// </summary>
  177. public override string TableName
  178. {
  179. get { return _tableName; }
  180. set { this._tableName = value; }
  181. }
  182. /// <summary>
  183. /// 获取当前新的数据表模型对象
  184. /// </summary>
  185. public override object ObjModel
  186. {
  187. get
  188. {
  189. return this.CurrentModel;
  190. }
  191. }
  192. /// <summary>
  193. /// 获取当前新的MOdel
  194. /// </summary>
  195. public AMYields_TR CurrentModel
  196. {
  197. get { return new AMYields_TR(); }
  198. }
  199. string _tableFieldNameString = "";
  200. /// <summary>
  201. /// 数据表字段名数组
  202. /// </summary>
  203. public override string TableFieldNameString
  204. {
  205. get { return this._tableFieldNameString; }
  206. set { this._tableFieldNameString = value; }
  207. }
  208. #endregion
  209. #region 检查记录
  210. //基类已经实现
  211. #endregion
  212. #region 增加数据
  213. /// <summary>
  214. /// 增加一条数据
  215. /// </summary>
  216. /// <param name="model">Model对象</param>
  217. /// <returns></returns>
  218. public bool Add(AMYields_TR model)
  219. {
  220. return base.Add(model);
  221. }
  222. /// <summary>
  223. /// 增加一条数据
  224. /// </summary>
  225. /// <param name="model">Model对象</param>
  226. /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
  227. /// <returns></returns>
  228. public bool Add(AMYields_TR model, string overlookFieldList = "ID")
  229. {
  230. return base.Add(model, overlookFieldList);
  231. }
  232. #endregion
  233. #region 删除数据
  234. /// <summary>
  235. /// 删除数据
  236. /// </summary>
  237. /// <param name="model"></param>
  238. /// <returns></returns>
  239. public bool Delete(AMYields_TR model)
  240. {
  241. return base.Delete(model.ID);
  242. }
  243. #endregion
  244. #region 更新数据
  245. /// <summary>
  246. /// 更新一条数据
  247. /// </summary>
  248. public bool Update(AMYields_TR model)
  249. {
  250. return base.Update(model);
  251. }
  252. /// <summary>
  253. /// 根据筛选字段和SQL筛选运算符号更新数据
  254. /// </summary>
  255. /// <param name="model">Model对象</param>
  256. /// <param name="filterFieldName">筛选字段名称</param>
  257. /// <param name="operators">SQL筛选运算符号</param>
  258. /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
  259. /// <returns></returns>
  260. public bool Update(AMYields_TR model, string filterFieldName = "ID", string operators = "=", string overlookFieldList = "ID")
  261. {
  262. return base.Update(model, filterFieldName, operators, overlookFieldList);
  263. }
  264. #endregion
  265. #region 查询数据
  266. /// <summary>
  267. /// 得到一个对象实体
  268. /// </summary>
  269. public AMYields_TR GetModel(string strWhere)
  270. {
  271. return DataRowToModel(GetDataRow(strWhere));
  272. }
  273. /// <summary>
  274. /// 得到一个对象实体
  275. /// </summary>
  276. public AMYields_TR GetModel(string strLine, string strStation, string ODF, DateTime TestDate, int TestHour)
  277. {
  278. return DataRowToModel(GetDataRow(string.Format("Line = '{0}' and Station = '{1}' and ODF='{2}' and TestDate='{3}' and TestHour='{4}'", strLine, strStation, ODF, TestDate, TestHour)));
  279. }
  280. /// <summary>
  281. /// 得到一个对象实体
  282. /// </summary>
  283. /// <param name="row"></param>
  284. /// <returns></returns>
  285. public AMYields_TR DataRowToModel(DataRow row)
  286. {
  287. return DataRowToModelObject(row) as AMYields_TR;
  288. }
  289. /// <summary>
  290. /// 获得数据Model列表
  291. /// </summary>
  292. /// <param name="strWhere">条件 不包含 where 关键字</param>
  293. public List<AMYields_TR> GetModelList(string strWhere)
  294. {
  295. DataSet ds = base.GetList(strWhere);
  296. return DataTableToList(ds.Tables[0]);
  297. }
  298. /// <summary>
  299. /// 获得数据列表
  300. /// </summary>
  301. /// <param name="dt">DataTable</param>
  302. public List<AMYields_TR> DataTableToList(DataTable dt)
  303. {
  304. List<AMYields_TR> modelList = new List<AMYields_TR>();
  305. List<object> ObjList = base.GetDataTableToOblList(dt);
  306. foreach (object obj in ObjList)
  307. {
  308. modelList.Add((AMYields_TR)obj);
  309. }
  310. return modelList;
  311. }
  312. #endregion
  313. }
  314. }