Beispiel #1
0
        public IList <TopicPictureInfo> GetList()
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select TopicSubjectId,PictureId 
			            from TopicPicture
					    order by LastUpdatedDate desc "                    );

            IList <TopicPictureInfo> list = new List <TopicPictureInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString()))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        TopicPictureInfo model = new TopicPictureInfo();
                        model.TopicSubjectId = reader.GetGuid(0);
                        model.PictureId      = reader.GetGuid(1);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Beispiel #2
0
        public IList <TopicPictureInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select TopicSubjectId,PictureId
                        from TopicPicture ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }

            IList <TopicPictureInfo> list = new List <TopicPictureInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        TopicPictureInfo model = new TopicPictureInfo();
                        model.TopicSubjectId = reader.GetGuid(0);
                        model.PictureId      = reader.GetGuid(1);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Beispiel #3
0
        public IList <TopicPictureInfo> 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,
			           TopicSubjectId,PictureId
					   from TopicPicture "                    );
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex);

            IList <TopicPictureInfo> list = new List <TopicPictureInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        TopicPictureInfo model = new TopicPictureInfo();
                        model.TopicSubjectId = reader.GetGuid(1);
                        model.PictureId      = reader.GetGuid(2);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Beispiel #4
0
        public TopicPictureInfo GetModel(object TopicSubjectId)
        {
            TopicPictureInfo model = null;

            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"select top 1 TopicSubjectId,PictureId 
			                   from TopicPicture
							   where TopicSubjectId = @TopicSubjectId "                            );
            SqlParameter parm = new SqlParameter("@TopicSubjectId", SqlDbType.UniqueIdentifier);

            parm.Value = Guid.Parse(TopicSubjectId.ToString());

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parm))
            {
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        model = new TopicPictureInfo();
                        model.TopicSubjectId = reader.GetGuid(0);
                        model.PictureId      = reader.GetGuid(1);
                    }
                }
            }

            return(model);
        }
Beispiel #5
0
        public int Update(TopicPictureInfo model)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"update TopicPicture set PictureId = @PictureId 
			            where TopicSubjectId = @TopicSubjectId
					    "                    );

            SqlParameter[] parms =
            {
                new SqlParameter("@TopicSubjectId", SqlDbType.UniqueIdentifier),
                new SqlParameter("@PictureId",      SqlDbType.UniqueIdentifier)
            };
            parms[0].Value = model.TopicSubjectId;
            parms[1].Value = model.PictureId;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parms));
        }
Beispiel #6
0
 /// <summary>
 /// 修改数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(TopicPictureInfo model)
 {
     return(dal.Update(model));
 }
Beispiel #7
0
 /// <summary>
 /// 添加数据到数据库
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Insert(TopicPictureInfo model)
 {
     return(dal.Insert(model));
 }