123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- using CB.Entity;
- using CB.Interface.Infrastructure;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.Common;
- using System.Data.SqlClient;
- using CB.Common;
- using CB.Interface;
- namespace CB.Data.SqlServer
- {
- public class PictureManage : Repository<PictureInfo>, IPictureService
- {
- public PictureManage(string interfaceId):base(interfaceId){}
- public override bool Save(PictureInfo entity)
- {
- throw new System.NotImplementedException();
- }
- public override bool Update(PictureInfo entity)
- {
- throw new System.NotImplementedException();
- }
- public override bool Delete(int Id)
- {
- throw new System.NotImplementedException();
- }
- public override PictureInfo Get<TKey>(TKey key)
- {
- PictureInfo Entity = null;
- DbParameter[] para =
- {
- DbHelper.MakeInParam(InterfaceId,"@id",(DbType)SqlDbType.Int,4,key)
- };
- using (IDataReader reader = DbHelper.ExecuteReader(InterfaceId, CommandType.Text,
- @"SELECT TOP 1 [Id] , [Code] , [Name] , [AreaId] , [LotId] , [Sort] , [IsRAR] ,
- [About] , [hTitle] , [hKeywords] , [hDescription] , [Addtime] FROM [ZT_Picture] WHERE id= @id",
- para))
- {
- if (reader.Read())
- {
- Entity = LoadEntity(reader);
- }
- reader.Dispose();
- }
- return Entity;
- }
- public override IList<PictureInfo> ToList()
- {
- DbParameter[] parameters = new DbParameter[] { };
- using (DataTable dt = DbHelper.ExecuteDatatable(InterfaceId, CommandType.StoredProcedure, "uzt_Picture_GetList", parameters))
- {
- List<PictureInfo> lists = new List<PictureInfo>();
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- lists.Add(LoadEntity(dt.Rows[i]));
- }
- return lists;
- }
- }
- public override IList<PictureInfo> ToList(PictureInfo entity)
- {
- throw new System.NotImplementedException();
- }
- public override IList<PictureInfo> ToPaging(PictureInfo entity, int pageSize, int pageIndex, out int recordCount)
- {
- throw new System.NotImplementedException();
- }
- /// <summary>
- /// IDataReader数据转换实体
- /// </summary>
- /// <param name="row">IDataReader</param>
- /// <returns></returns>
- protected override PictureInfo LoadEntity(IDataReader row)
- {
- return new PictureInfo
- {
- Id = TypeConverter.ObjectToInt(row["Id"]),
- Code = row["Code"].ToString().Trim(),
- Name = row["Name"].ToString().Trim(),
- AreaId = TypeConverter.ObjectToInt(row["AreaId"]),
- LotId = TypeConverter.ObjectToInt(row["LotId"]),
- Sort = TypeConverter.ObjectToInt(row["Sort"]),
- IsRAR = TypeConverter.ObjectToBool(row["IsRAR"], false),
- About = row["About"].ToString().Trim(),
- hTitle = row["hTitle"].ToString().Trim(),
- hKeywords = row["hKeywords"].ToString().Trim(),
- hDescription = row["hDescription"].ToString().Trim(),
- Addtime = TypeConverter.StrToDateTime(row["Addtime"].ToString())
- };
- }
- /// <summary>
- /// DataRow数据转换实体
- /// </summary>
- /// <param name="row">DataRow</param>
- /// <returns></returns>
- protected override PictureInfo LoadEntity(DataRow row)
- {
- return new PictureInfo
- {
- Id = TypeConverter.ObjectToInt(row["Id"]),
- Code = row["Code"].ToString().Trim(),
- Name = row["Name"].ToString().Trim(),
- AreaId = TypeConverter.ObjectToInt(row["AreaId"]),
- LotId = TypeConverter.ObjectToInt(row["LotId"]),
- Sort = TypeConverter.ObjectToInt(row["Sort"]),
- IsRAR = TypeConverter.ObjectToBool(row["IsRAR"], false),
- About = row["About"].ToString().Trim(),
- hTitle = row["hTitle"].ToString().Trim(),
- hKeywords = row["hKeywords"].ToString().Trim(),
- hDescription = row["hDescription"].ToString().Trim(),
- Addtime = TypeConverter.StrToDateTime(row["Addtime"].ToString())
- };
- }
- }
- }
|