public IList <AdvertPictureInfo> GetList() { StringBuilder sb = new StringBuilder(250); sb.Append(@"select AdvertId,PictureId from AdvertPicture order by LastUpdatedDate desc " ); IList <AdvertPictureInfo> list = new List <AdvertPictureInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString())) { if (reader != null && reader.HasRows) { while (reader.Read()) { AdvertPictureInfo model = new AdvertPictureInfo(); model.AdvertId = reader.GetGuid(0); model.PictureId = reader.GetGuid(1); list.Add(model); } } } return(list); }
public IList <AdvertPictureInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms) { StringBuilder sb = new StringBuilder(250); sb.Append(@"select AdvertId,PictureId from AdvertPicture "); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } IList <AdvertPictureInfo> list = new List <AdvertPictureInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { AdvertPictureInfo model = new AdvertPictureInfo(); model.AdvertId = reader.GetGuid(0); model.PictureId = reader.GetGuid(1); list.Add(model); } } } return(list); }
public IList <AdvertPictureInfo> GetList(int pageIndex, int pageSize, string sqlWhere, params SqlParameter[] cmdParms) { StringBuilder sb = new StringBuilder(250); int startIndex = (pageIndex - 1) * pageSize + 1; int endIndex = pageIndex * pageSize; sb.Append(@"select * from(select row_number() over(order by LastUpdatedDate desc) as RowNumber, AdvertId,PictureId from AdvertPicture " ); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex); IList <AdvertPictureInfo> list = new List <AdvertPictureInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { AdvertPictureInfo model = new AdvertPictureInfo(); model.AdvertId = reader.GetGuid(1); model.PictureId = reader.GetGuid(2); list.Add(model); } } } return(list); }
public AdvertPictureInfo GetModel(object AdvertId) { AdvertPictureInfo model = null; StringBuilder sb = new StringBuilder(300); sb.Append(@"select top 1 AdvertId,PictureId from AdvertPicture where AdvertId = @AdvertId " ); SqlParameter parm = new SqlParameter("@AdvertId", SqlDbType.UniqueIdentifier); parm.Value = Guid.Parse(AdvertId.ToString()); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parm)) { if (reader != null) { if (reader.Read()) { model = new AdvertPictureInfo(); model.AdvertId = reader.GetGuid(0); model.PictureId = reader.GetGuid(1); } } } return(model); }
public int Update(AdvertPictureInfo model) { StringBuilder sb = new StringBuilder(250); sb.Append(@"update AdvertPicture set PictureId = @PictureId where AdvertId = @AdvertId " ); SqlParameter[] parms = { new SqlParameter("@AdvertId", SqlDbType.UniqueIdentifier), new SqlParameter("@PictureId", SqlDbType.UniqueIdentifier) }; parms[0].Value = model.AdvertId; parms[1].Value = model.PictureId; return(SqlHelper.ExecuteNonQuery(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parms)); }
/// <summary> /// 修改数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Update(AdvertPictureInfo model) { return(dal.Update(model)); }
/// <summary> /// 添加数据到数据库 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Insert(AdvertPictureInfo model) { return(dal.Insert(model)); }