Productfunservice.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. 
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using QWPlatform.DataIntface;
  7. using QWPlatform.IService;
  8. using PMS.EntityModels.Product;
  9. using System.Data;
  10. using QWPlatform.SystemLibrary.LogManager;
  11. using PMS.BusinessModels.Product;
  12. namespace PMS.DBService.Product
  13. {
  14. /// <summary>
  15. /// 创 建 人:伍莲魁
  16. /// 创建日期:2018-12-10
  17. /// 功能描述:产品功能配置数据层
  18. /// </summary>
  19. public class Productfunservice : DataServiceBase
  20. {
  21. /// <summary>
  22. /// 重写数据工厂
  23. /// </summary>
  24. /// <param name="conName"></param>
  25. protected override void DBFctory(string conName)
  26. {
  27. base.DBFctory(conName);
  28. }
  29. /// <summary>
  30. /// 增加数据记录
  31. /// </summary>
  32. /// <param name="model"></param>
  33. /// <returns></returns>
  34. public int Add(ProductFunModel model)
  35. {
  36. model.ID = Guid.NewGuid().ToString();
  37. model.SetDataFactory(this.DataFactoryObject);
  38. return model.Insert();
  39. }
  40. public int AddInport(ProductFunModel model)
  41. {
  42. try
  43. {
  44. model.SetDataFactory(this.DataFactoryObject);
  45. return model.Insert();
  46. }
  47. catch (Exception ex)
  48. {
  49. }
  50. return -1;
  51. }
  52. /// <summary>
  53. /// 增加数据记录
  54. /// </summary>
  55. /// <param name="model"></param>
  56. /// <returns></returns>
  57. public int Add(ProductFunModel model, ITransaction trans)
  58. {
  59. model.SetDataFactory(this.DataFactoryObject);
  60. if (trans == null)
  61. {
  62. return model.Insert();
  63. }
  64. else
  65. {
  66. return model.Insert(trans);
  67. }
  68. }
  69. /// <summary>
  70. /// 更新数据库记录
  71. /// </summary>
  72. /// <param name="model"></param>
  73. /// <returns></returns>
  74. public int Update(ProductFunModel model)
  75. {
  76. try
  77. {
  78. model.SetDataFactory(this.DataFactoryObject);
  79. List<string> where = new List<string>();
  80. return model.Where("ID").Update("类型", "上级ID", "编码", "名称", "状态", "开发方式", "说明", "测试人NEW", "测试人IDNEW", "研发人", "研发人ID");
  81. }catch(Exception ex)
  82. {
  83. Logger.Instance.Error(ex.Message);
  84. return 0;
  85. }
  86. }
  87. /// <summary>
  88. /// 更新数据库记录
  89. /// </summary>
  90. /// <param name="model"></param>
  91. /// <returns></returns>
  92. public int Update(ProductFunModel model, ITransaction trans)
  93. {
  94. model.SetDataFactory(this.DataFactoryObject);
  95. List<string> where = new List<string>();
  96. where.Add("ID");
  97. if (trans == null)
  98. {
  99. return model.Update(where, string.Empty);
  100. }
  101. else
  102. {
  103. return model.Update(trans, where, string.Empty);
  104. }
  105. }
  106. /// <summary>
  107. /// 删除数据记录
  108. /// </summary>
  109. /// <param name="model"></param>
  110. /// <returns></returns>
  111. public int Delete(ProductFunModel model)
  112. {
  113. model.SetDataFactory(this.DataFactoryObject);
  114. return model.Delete("ID");
  115. }
  116. /// <summary>
  117. /// 删除数据记录
  118. /// </summary>
  119. /// <param name="model"></param>
  120. /// <returns></returns>
  121. public int Delete(ProductFunModel model, ITransaction trans)
  122. {
  123. model.SetDataFactory(this.DataFactoryObject);
  124. if (trans == null)
  125. {
  126. return model.Delete("ID");
  127. }
  128. else
  129. {
  130. return model.Delete(trans, "ID");
  131. }
  132. }
  133. /// <summary>
  134. /// 查询数据对象并进行赋值
  135. /// </summary>
  136. /// <returns></returns>
  137. public ProductFunModel Select(ProductFunModel model)
  138. {
  139. model.SetDataFactory(this.DataFactoryObject);
  140. model.Select();
  141. return model;
  142. }
  143. /// <summary>
  144. /// 列表查询
  145. /// </summary>
  146. /// <returns></returns>
  147. public List<ProductFunModel> SelectList(ProductFunModel model)
  148. {
  149. model.SetDataFactory(this.DataFactoryObject);
  150. return model.SelectList<ProductFunModel>();
  151. }
  152. /// <summary>
  153. /// 调用存储过程
  154. /// </summary>
  155. /// <returns></returns>
  156. public void CallProcedure(ProductFunModel model)
  157. {
  158. this.ProcedureBuilder
  159. .Procedure("p_PT_产品模块功能_INSERT")
  160. .Paramter("ID_IN", model.ID)
  161. .Paramter("产品ID_IN", model.CPID)
  162. .Paramter("上级ID_IN", model.SJID)
  163. .Paramter("类型_IN", model.LX)
  164. .Paramter("编码_IN", model.BM)
  165. .Paramter("名称_IN", model.MC)
  166. .Paramter("状态_IN", model.ZT)
  167. .Paramter("开发方式_IN", model.KFFS)
  168. .Paramter("研发人ID_IN", model.YFRID)
  169. .Paramter("研发人_IN", model.YFR)
  170. .Paramter("测试人ID_IN", model.CSRID)
  171. .Paramter("测试人_IN", model.CSR)
  172. .Paramter("说明_IN", model.SM)
  173. .Execute();
  174. }
  175. public DataTable GetProductFunInfo(string id)
  176. {
  177. return this.SelectBuilder.Columns("*")
  178. .From("产品模块功能")
  179. .Where("ID", id)
  180. .Select();
  181. }
  182. //获取所有产品版本信息
  183. public DataTable GetAllProducts()
  184. {
  185. return this.SelectBuilder
  186. .Columns("ID")
  187. .Columns("名称")
  188. .From("产品系统配置")
  189. .Where("状态", 1)
  190. .OrderBy("编码 ASC")
  191. .Select();
  192. }
  193. public bool AddVersionFile(ProductVersionFileModel model)
  194. {
  195. return this.InsertBuilder.Insert("产品版本附件")
  196. .Column("ID", Guid.NewGuid().ToString())
  197. .Column("产品版本ID", model.VersionID)
  198. .Column("添加时间", this.DataBaseBuilder.GetDateTime)
  199. .Column("类型", model.Type)
  200. .Column("添加人", model.Name)
  201. .Column("附件ID", model.FileId)
  202. .Execute() > 0;
  203. }
  204. public bool DeleteProductVersionFile(string id)
  205. {
  206. return this.UpdateBuilder.Update("产品版本附件")
  207. .Where("ID", id)
  208. .Column("是否删除", 1)
  209. .Execute() > 0;
  210. }
  211. }
  212. }