コード例 #1
0
ファイル: watchoutDAL.cs プロジェクト: karthikxx/USAdvisory
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static List<watchoutlisting> GetAllWatchOutNews()
        {
            //DB Connection goes here

               List<watchoutlisting> _article = new List<watchoutlisting>();

               // Create the Database object, using the default database service. The
               // default database service is determined through configuration.
               Database db = DatabaseFactory.CreateDatabase();

               string sqlCommand = "GetAllWatchOutNews";
               DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

               // Retrieve products from the specified category.
               //db.AddInParameter(dbCommand, "CategoryID", DbType.Int32, Category);

               // DataSet that will hold the returned results
               DataSet commentaryDataSet = null;

               commentaryDataSet = db.ExecuteDataSet(dbCommand);

               // Note: connection was closed by ExecuteDataSet method call

               foreach (DataRow dr in commentaryDataSet.Tables[0].Rows)
               {
                   watchoutlisting _commListing = new watchoutlisting();
                   _commListing.ArticleId = Int32.Parse(dr["WatchOutId"].ToString());
                   _commListing.ArticleTitle = dr["WatchOuttitle"].ToString();
                   _commListing.ArticleDesc = dr["WatchOutText"].ToString();
                   _commListing.ArticleDate = DateTime.Parse(dr["WatchOutDateTime"].ToString());
                   _commListing.Ticker = dr["Ticker"].ToString();
                   _article.Add(_commListing);

               }
               return _article;
        }
コード例 #2
0
ファイル: watchoutDAL.cs プロジェクト: karthikxx/USAdvisory
        /// <summary>
        /// 
        /// </summary>
        public static watchoutlisting GetWatchOutByArticle(int _articleId)
        {
            //DB Connection goes here

               watchoutlisting _commListing = new watchoutlisting();

               // Create the Database object, using the default database service. The
               // default database service is determined through configuration.
               Database db = DatabaseFactory.CreateDatabase();

               string sqlCommand = "GetWatchOutNewsByArticle";
               DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

               // Retrieve products from the specified category.
               db.AddInParameter(dbCommand, "WatchOutId", DbType.Int32, _articleId);

               // DataSet that will hold the returned results
               DataSet commentaryDataSet = null;

               commentaryDataSet = db.ExecuteDataSet(dbCommand);

               // Note: connection was closed by ExecuteDataSet method call

               foreach (DataRow dr in commentaryDataSet.Tables[0].Rows)
               {

                   _commListing.ArticleTitle = dr["Watchouttitle"].ToString();
                   _commListing.ArticleDesc = dr["WatchOutText"].ToString();
                   _commListing.IsActive = Boolean.Parse(dr["IsPaid"].ToString());
                   _commListing.Ticker = dr["Ticker"].ToString();
               }

               return _commListing;
        }