Ejemplo n.º 1
0
        public void Insert(Core.Business.InstrumentRecommend instrumentRecommend)
        {
            SqlServerUtility sql = new SqlServerUtility();

            sql.AddParameter("@Autor", SqlDbType.UniqueIdentifier, instrumentRecommend.Autor);
            sql.AddParameter("@RecommendDate", SqlDbType.DateTime, instrumentRecommend.RecommendDate);
            sql.AddParameter("@Commend", SqlDbType.NVarChar, instrumentRecommend.Commend);
            SqlDataReader reader = sql.ExecuteSqlReader(SqlInsertInstrumentRecommend);

            if (reader != null && !reader.IsClosed && reader.Read())
            {
                if (!reader.IsDBNull(0))
                {
                    instrumentRecommend.Id = reader.GetGuid(0);
                }

                reader.Close();
            }
            else
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }
            }
        }
        public IList <Core.Business.ExhibitionInstrument> GetExhibitionInstrumentTopBySequenceNumber(int num)
        {
            IList <Core.Business.ExhibitionInstrument> exhibitionInstrumentlist = new List <Core.Business.ExhibitionInstrument>();
            SqlServerUtility sql       = new SqlServerUtility();
            string           sqlSelAll = "SELECT top " + num + " ExhibitionInstrument.[Id],[InstrumentID],[ExhibitionDate],[SequenceNumber],[IsShowinHomePage]FROM [dbo].[ExhibitionInstrument]";

            sqlSelAll += "order by SequenceNumber ASC";
            SqlDataReader reader = sql.ExecuteSqlReader(sqlSelAll);

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.ExhibitionInstrument exhibitionInstrument = new Core.Business.ExhibitionInstrument();

                    if (!reader.IsDBNull(0))
                    {
                        exhibitionInstrument.Id = reader.GetGuid(0);
                    }
                    if (!reader.IsDBNull(1))
                    {
                        exhibitionInstrument.InstrumentID = reader.GetGuid(1);
                    }
                    if (!reader.IsDBNull(2))
                    {
                        exhibitionInstrument.ExhibitionDate = reader.GetDateTime(2);
                    }
                    if (!reader.IsDBNull(3))
                    {
                        exhibitionInstrument.SequenceNumber = reader.GetInt32(3);
                    }
                    if (!reader.IsDBNull(4))
                    {
                        exhibitionInstrument.IsShowinHomePage = reader.GetInt32(4);
                    }

                    exhibitionInstrument.MarkOld();
                    exhibitionInstrumentlist.Add(exhibitionInstrument);
                }
                reader.Close();
            }
            return(exhibitionInstrumentlist);
        }
Ejemplo n.º 3
0
        public Core.Business.InstrumentRecommend Select(Guid id)
        {
            SqlServerUtility sql = new SqlServerUtility();

            sql.AddParameter("@Id", SqlDbType.UniqueIdentifier, id);
            SqlDataReader reader = sql.ExecuteSqlReader(SqlSelectInstrumentRecommend);

            if (reader != null && !reader.IsClosed && reader.Read())
            {
                Core.Business.InstrumentRecommend instrumentRecommend = new Core.Business.InstrumentRecommend();

                if (!reader.IsDBNull(0))
                {
                    instrumentRecommend.Id = reader.GetGuid(0);
                }
                if (!reader.IsDBNull(1))
                {
                    instrumentRecommend.Autor = reader.GetGuid(1);
                }
                if (!reader.IsDBNull(2))
                {
                    instrumentRecommend.RecommendDate = reader.GetDateTime(2);
                }
                if (!reader.IsDBNull(3))
                {
                    instrumentRecommend.Commend = reader.GetString(3);
                }

                reader.Close();
                return(instrumentRecommend);
            }
            else
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }

                return(null);
            }
        }
Ejemplo n.º 4
0
        public IList <Core.Business.InstrumentRecommend> GetAllInstrumentRecommend()
        {
            IList <Core.Business.InstrumentRecommend> instrumentRecommendlist = new List <Core.Business.InstrumentRecommend>();
            SqlServerUtility sql = new SqlServerUtility();

            SqlDataReader reader = sql.ExecuteSqlReader(SqlGetAllInstrumentRecommend);

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.InstrumentRecommend instrumentRecommend = new Core.Business.InstrumentRecommend();

                    if (!reader.IsDBNull(0))
                    {
                        instrumentRecommend.Id = reader.GetGuid(0);
                    }
                    if (!reader.IsDBNull(1))
                    {
                        instrumentRecommend.Autor = reader.GetGuid(1);
                    }
                    if (!reader.IsDBNull(2))
                    {
                        instrumentRecommend.RecommendDate = reader.GetDateTime(2);
                    }
                    if (!reader.IsDBNull(3))
                    {
                        instrumentRecommend.Commend = reader.GetString(3);
                    }

                    instrumentRecommend.MarkOld();
                    instrumentRecommendlist.Add(instrumentRecommend);
                }
                reader.Close();
            }
            return(instrumentRecommendlist);
        }