Ejemplo n.º 1
0
        //public void LoadArticle(int articleId)
        //{
        //    string queryString = "SELECT [ArticleId],[CategoryId],[SecondLevCategoryId],[ThirdLevCategoryId],[Name] " +
        //                                ",[Title],[Description],[Author],[Keywords],[MainContent],[SideContent] " +
        //                                ",[ListItemContent],[ViewRequests],[URLLink] " +
        //                        "FROM [MLB].[dbo].[Article] " +
        //                        "WHERE ArticleId = " + articleId;
        //    using (SqlConnection connection = new SqlConnection(Base.conn))
        //    {
        //        // Create the Command and Parameter objects.
        //        SqlCommand command = new SqlCommand(queryString, connection);
        //        try
        //        {
        //            connection.Open();
        //            SqlDataReader reader = command.ExecuteReader();
        //            LoadArticle(reader);
        //            reader.Close();
        //        }
        //        catch (Exception ex)
        //        {
        //            DIYError sError = new DIYError(ex);
        //        }
        //    }
        //}
        //public void LoadArticle(int categoryId, int categoryLevel)
        //{
        //    string queryString = "SELECT [ArticleId],[CategoryId],[SecondLevCategoryId],[ThirdLevCategoryId],[Name] " +
        //                                ",[Title],[Description],[Author],[Keywords],[MainContent],[SideContent] " +
        //                                ",[ListItemContent],[ViewRequests],[URLLink] " +
        //                        "FROM [MLB].[dbo].[Article] ";
        //    switch (categoryLevel)
        //    {
        //        case 1:
        //            queryString += "WHERE CategoryId = " + categoryId;
        //            break;
        //        case 2:
        //            queryString += "WHERE SecondLevCategoryId = " + categoryId;
        //            break;
        //        case 3:
        //            queryString += "WHERE ThirdCategoryId = " + categoryId;
        //            break;
        //    }
        //    using (SqlConnection connection = new SqlConnection(Base.conn))
        //    {
        //        // Create the Command and Parameter objects.
        //        SqlCommand command = new SqlCommand(queryString, connection);
        //        try
        //        {
        //            connection.Open();
        //            SqlDataReader reader = command.ExecuteReader();
        //            LoadArticle(reader);
        //            reader.Close();
        //        }
        //        catch (Exception ex)
        //        {
        //            DIYError sError = new DIYError(ex);
        //        }
        //    }
        //}
        private void LoadArticle(SqlDataReader reader)
        {
            while (reader.Read())
            {
                this.ArticleId = reader.GetInt32(0);

                this.Name = reader.GetString(1);
                this.Title = reader.GetStringSafe(2);
                this.Description = reader.GetStringSafe(3);
                this.Author = reader.GetStringSafe(4);
                this.Keywords = reader.GetStringSafe(5);
                this.MainContent = reader.GetStringSafe(6);
                this.ViewRequests = reader.GetInt32(7);
                this.URLLink = reader.GetString(8);
                this.NameId = reader.GetString(9);
                this.CategoryRowId = reader.GetInt32(10);
                this.CategoryId = reader.GetInt32Safe(11);
                this.SecondLevCategoryId = reader.GetInt32Safe(12);
                this.ThirdLevCategoryId = reader.GetInt32Safe(13);
                this.CategoryName = reader.GetString(14);
                this.CategoryUrl = reader.GetString(15);
                this.SecondLevCategoryName = reader.GetStringSafe(16);
                this.SecondLevCategoryUrl = reader.GetStringSafe(17);
                this.ThirdLevCategoryName = reader.GetStringSafe(18);
                this.ThirdLevCategoryUrl = reader.GetStringSafe(19);
                this.CreatedDate = reader.GetDateTime(20);
            }
        }
Ejemplo n.º 2
0
 private void LoadArticle(SqlDataReader reader)
 {
     while (reader.Read())
     {
         this.ArticleId = reader.GetInt32(0);
         this.CategoryId = reader.GetInt32Safe(1);
         this.SecondLevCategoryId = reader.GetInt32Safe(2);
         this.ThirdLevCategoryId = reader.GetInt32Safe(3);
         this.Name = reader.GetString(4);
         this.Title = reader.GetStringSafe(5);
         this.Description = reader.GetStringSafe(6);
         this.Author = reader.GetStringSafe(7);
         this.Keywords = reader.GetStringSafe(8);
         this.MainContent = reader.GetStringSafe(9);
     }
 }