Cpjtpzservice.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. //using System;
  2. //using System.Collections.Generic;
  3. //using System.Linq;
  4. //using System.Text;
  5. //using QWPlatform.DataIntface;
  6. //using QWPlatform.IService;
  7. //using PMS.EntityModels.Product;
  8. //using System.Data;
  9. using PMS.EntityModels.Product;
  10. using QWPlatform.DataIntface;
  11. using QWPlatform.IService;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Data;
  15. namespace PMS.DBService.Product
  16. {
  17. /// <summary>
  18. /// 创 建 人:伍莲魁
  19. /// 创建日期:2018-12-10
  20. /// 功能描述:产品系统配置数据层
  21. /// </summary>
  22. public class Cpjtpzservice : DataServiceBase
  23. {
  24. /// <summary>
  25. /// 重写数据工厂
  26. /// </summary>
  27. /// <param name="conName"></param>
  28. protected override void DBFctory(string conName)
  29. {
  30. base.DBFctory(conName);
  31. }
  32. /// <summary>
  33. /// 增加数据记录
  34. /// </summary>
  35. /// <param name="model"></param>
  36. /// <returns></returns>
  37. public int Add(CPJTPZModel model)
  38. {
  39. model.ID = Guid.NewGuid().ToString();
  40. model.SetDataFactory(this.DataFactoryObject);
  41. return model.Insert();
  42. }
  43. /// <summary>
  44. /// 增加数据记录
  45. /// </summary>
  46. /// <param name="model"></param>
  47. /// <returns></returns>
  48. public int Add(CPJTPZModel model, ITransaction trans)
  49. {
  50. model.SetDataFactory(this.DataFactoryObject);
  51. if (trans == null)
  52. {
  53. return model.Insert();
  54. }
  55. else
  56. {
  57. return model.Insert(trans);
  58. }
  59. }
  60. /// <summary>
  61. /// 更新数据库记录
  62. /// </summary>
  63. /// <param name="model"></param>
  64. /// <returns></returns>
  65. public int Update(CPJTPZModel model)
  66. {
  67. model.SetDataFactory(this.DataFactoryObject);
  68. List<string> where = new List<string>();
  69. where.Add("ID");
  70. return model.Update(where,"编码", "名称", "状态", "负责人ID", "负责人", "说明", "产品流程状态");
  71. }
  72. /// <summary>
  73. /// 更新数据库记录
  74. /// </summary>
  75. /// <param name="model"></param>
  76. /// <returns></returns>
  77. public int Update(CPJTPZModel model, ITransaction trans)
  78. {
  79. model.SetDataFactory(this.DataFactoryObject);
  80. List<string> where = new List<string>();
  81. where.Add("ID");
  82. if (trans == null)
  83. {
  84. return model.Update(where, string.Empty);
  85. }
  86. else
  87. {
  88. return model.Update(trans, where, string.Empty);
  89. }
  90. }
  91. /// <summary>
  92. /// 删除数据记录
  93. /// </summary>
  94. /// <param name="model"></param>
  95. /// <returns></returns>
  96. public int Delete(CPJTPZModel model)
  97. {
  98. model.SetDataFactory(this.DataFactoryObject);
  99. return model.Delete("ID");
  100. }
  101. /// <summary>
  102. /// 删除数据记录
  103. /// </summary>
  104. /// <param name="model"></param>
  105. /// <returns></returns>
  106. public int Delete(CPJTPZModel model, ITransaction trans)
  107. {
  108. model.SetDataFactory(this.DataFactoryObject);
  109. if (trans == null)
  110. {
  111. return model.Delete("ID");
  112. }
  113. else
  114. {
  115. return model.Delete(trans, "ID");
  116. }
  117. }
  118. /// <summary>
  119. /// 查询数据对象并进行赋值
  120. /// </summary>
  121. /// <returns></returns>
  122. public CPJTPZModel Select(CPJTPZModel model)
  123. {
  124. model.SetDataFactory(this.DataFactoryObject);
  125. model.Select();
  126. return model;
  127. }
  128. /// <summary>
  129. /// 列表查询
  130. /// </summary>
  131. /// <returns></returns>
  132. public List<CPJTPZModel> SelectList(CPJTPZModel model)
  133. {
  134. model.SetDataFactory(this.DataFactoryObject);
  135. return model.SelectList<CPJTPZModel>();
  136. }
  137. /// <summary>
  138. /// 获取所有产品编码
  139. /// </summary>
  140. /// <returns></returns>
  141. public DataTable GetProductCode()
  142. {
  143. return this.SelectBuilder
  144. .From("产品系统配置")
  145. .Columns("编码,名称")
  146. .OrderBy("编码 ASC")
  147. .Select();
  148. }
  149. public DataTable GetProductCodeBycustom(string ProjectId)
  150. {
  151. return this.SelectBuilder
  152. .From("项目产品模块 a,产品系统配置 b")
  153. .Columns("b.编码,b.名称")
  154. .Where("a.项目ID", ProjectId)
  155. .Where("a.模块ID is null")
  156. .Where("a.产品ID=b.id")
  157. .OrderBy("b.编码 ASC")
  158. .Select();
  159. }
  160. /// <summary>
  161. /// 调用存储过程
  162. /// </summary>
  163. /// <returns></returns>
  164. public void CallProcedure(CPJTPZModel model)
  165. {
  166. this.ProcedureBuilder
  167. .Procedure("p_PT_产品系统配置_INSERT")
  168. .Paramter("ID_IN", model.ID)
  169. .Paramter("编码_IN", model.BM)
  170. .Paramter("名称_IN", model.MC)
  171. .Paramter("状态_IN", model.ZT)
  172. .Paramter("负责人ID_IN", model.FZRID)
  173. .Paramter("负责人_IN", model.FZR)
  174. .Paramter("说明_IN", model.SM)
  175. .Execute();
  176. }
  177. public DataTable GetProductInfoDataGrid(string search, string states)
  178. {
  179. var execute = this.ProcedureBuilder
  180. .Procedure("b_基础管理_产品管理.p_产品系统配置_Select")
  181. .Paramter("条件_In", search)
  182. .Paramter("状态_In", states)
  183. .ParamterOut("Resultlist", true);
  184. execute.Execute();
  185. var dt = execute.ParameterValue<DataTable>("Resultlist");
  186. return dt;
  187. }
  188. public DataTable ProductInfoCombobox()
  189. {
  190. return this.SelectBuilder.Columns("ID", "名称").From("产品系统配置").OrderBy("编码 asc").Select();
  191. }
  192. public DataTable GetProductFunctionTree(string ProductId,string search, string states)
  193. {
  194. var execute = this.ProcedureBuilder
  195. .Procedure("b_基础管理_产品管理.p_产品模块功能Tree_Select")
  196. .Paramter("开发状态_In", states)
  197. .Paramter("条件_In", search)
  198. .Paramter("产品id_In", ProductId)
  199. .ParamterOut("Resultlist", true);
  200. execute.Execute();
  201. var dt = execute.ParameterValue<DataTable>("Resultlist");
  202. return dt;
  203. }
  204. public DataTable GetProductInfo(string id)
  205. {
  206. return this.SelectBuilder.Columns("*")
  207. .From("产品系统配置")
  208. .Where("ID", id)
  209. .Select();
  210. }
  211. /// <summary>
  212. /// 根据项目ID获取产品模块
  213. /// </summary>
  214. /// <param name="id"></param>
  215. /// <returns></returns>
  216. public DataTable GetProductByProjectId(string id)
  217. {
  218. var execute = this.ProcedureBuilder
  219. .Procedure("b_基础管理_产品管理.p_项目产品模块_Select")
  220. .Paramter("项目ID_In", id)
  221. .ParamterOut("Resultlist", true);
  222. execute.Execute();
  223. var dt = execute.ParameterValue<DataTable>("Resultlist");
  224. return dt;
  225. }
  226. }
  227. }