PictureManage.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using CB.Entity;
  2. using CB.Interface.Infrastructure;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Data.Common;
  6. using System.Data.SqlClient;
  7. using CB.Common;
  8. using CB.Interface;
  9. namespace CB.Data.SqlServer
  10. {
  11. public class PictureManage : Repository<PictureInfo>, IPictureService
  12. {
  13. public PictureManage(string interfaceId):base(interfaceId){}
  14. public override bool Save(PictureInfo entity)
  15. {
  16. throw new System.NotImplementedException();
  17. }
  18. public override bool Update(PictureInfo entity)
  19. {
  20. throw new System.NotImplementedException();
  21. }
  22. public override bool Delete(int Id)
  23. {
  24. throw new System.NotImplementedException();
  25. }
  26. public override PictureInfo Get<TKey>(TKey key)
  27. {
  28. PictureInfo Entity = null;
  29. DbParameter[] para =
  30. {
  31. DbHelper.MakeInParam(InterfaceId,"@id",(DbType)SqlDbType.Int,4,key)
  32. };
  33. using (IDataReader reader = DbHelper.ExecuteReader(InterfaceId, CommandType.Text,
  34. @"SELECT TOP 1 [Id] , [Code] , [Name] , [AreaId] , [LotId] , [Sort] , [IsRAR] ,
  35. [About] , [hTitle] , [hKeywords] , [hDescription] , [Addtime] FROM [ZT_Picture] WHERE id= @id",
  36. para))
  37. {
  38. if (reader.Read())
  39. {
  40. Entity = LoadEntity(reader);
  41. }
  42. reader.Dispose();
  43. }
  44. return Entity;
  45. }
  46. public override IList<PictureInfo> ToList()
  47. {
  48. DbParameter[] parameters = new DbParameter[] { };
  49. using (DataTable dt = DbHelper.ExecuteDatatable(InterfaceId, CommandType.StoredProcedure, "uzt_Picture_GetList", parameters))
  50. {
  51. List<PictureInfo> lists = new List<PictureInfo>();
  52. for (int i = 0; i < dt.Rows.Count; i++)
  53. {
  54. lists.Add(LoadEntity(dt.Rows[i]));
  55. }
  56. return lists;
  57. }
  58. }
  59. public override IList<PictureInfo> ToList(PictureInfo entity)
  60. {
  61. throw new System.NotImplementedException();
  62. }
  63. public override IList<PictureInfo> ToPaging(PictureInfo entity, int pageSize, int pageIndex, out int recordCount)
  64. {
  65. throw new System.NotImplementedException();
  66. }
  67. /// <summary>
  68. /// IDataReader数据转换实体
  69. /// </summary>
  70. /// <param name="row">IDataReader</param>
  71. /// <returns></returns>
  72. protected override PictureInfo LoadEntity(IDataReader row)
  73. {
  74. return new PictureInfo
  75. {
  76. Id = TypeConverter.ObjectToInt(row["Id"]),
  77. Code = row["Code"].ToString().Trim(),
  78. Name = row["Name"].ToString().Trim(),
  79. AreaId = TypeConverter.ObjectToInt(row["AreaId"]),
  80. LotId = TypeConverter.ObjectToInt(row["LotId"]),
  81. Sort = TypeConverter.ObjectToInt(row["Sort"]),
  82. IsRAR = TypeConverter.ObjectToBool(row["IsRAR"], false),
  83. About = row["About"].ToString().Trim(),
  84. hTitle = row["hTitle"].ToString().Trim(),
  85. hKeywords = row["hKeywords"].ToString().Trim(),
  86. hDescription = row["hDescription"].ToString().Trim(),
  87. Addtime = TypeConverter.StrToDateTime(row["Addtime"].ToString())
  88. };
  89. }
  90. /// <summary>
  91. /// DataRow数据转换实体
  92. /// </summary>
  93. /// <param name="row">DataRow</param>
  94. /// <returns></returns>
  95. protected override PictureInfo LoadEntity(DataRow row)
  96. {
  97. return new PictureInfo
  98. {
  99. Id = TypeConverter.ObjectToInt(row["Id"]),
  100. Code = row["Code"].ToString().Trim(),
  101. Name = row["Name"].ToString().Trim(),
  102. AreaId = TypeConverter.ObjectToInt(row["AreaId"]),
  103. LotId = TypeConverter.ObjectToInt(row["LotId"]),
  104. Sort = TypeConverter.ObjectToInt(row["Sort"]),
  105. IsRAR = TypeConverter.ObjectToBool(row["IsRAR"], false),
  106. About = row["About"].ToString().Trim(),
  107. hTitle = row["hTitle"].ToString().Trim(),
  108. hKeywords = row["hKeywords"].ToString().Trim(),
  109. hDescription = row["hDescription"].ToString().Trim(),
  110. Addtime = TypeConverter.StrToDateTime(row["Addtime"].ToString())
  111. };
  112. }
  113. }
  114. }