Ejemplo n.º 1
0
 /// <summary>
 /// 插入文章信息
 /// </summary>
 /// <param name="art"></param>
 /// <returns></returns>
 public int InsertArticleInfo(ArticleInfo art)
 {
     int rowcount = 0;
     string sqltxt = @"INSERT  INTO qds157425440_db.dbo.ArticleInfo
     ( TitleName ,
       ViceTitleName ,
       AuthorID ,
       AuthorName ,
       PublishTime ,
       Astatus ,
       MainPicURL ,
       PicWidth ,
       PicHeight ,
       Addtime ,
       Updatetime ,
       CategoryID ,
       CategoryName ,
       Tags ,
       Summary ,
       DSummary ,
       ClickCount ,
       IsTop ,
       SourceUrl ,
       AFrom ,
       CommentCount
     )
     VALUES  ( @TitleName ,
       @ViceTitleName ,
       @AuthorID ,
       @AuthorName ,
       GETDATE() ,
       30 ,
       @MainPicURL ,
       @PicWidth ,
       @PicHeight ,
       GETDATE() ,
       GETDATE() ,
       @CategoryID ,
       @CategoryName ,
       @Tags ,
       @Summary ,
       @DSummary ,
       0 ,
       0 ,
       @SourceUrl ,
       @AFrom ,
       0
     );SELECT @@IDENTITY";
     SqlParameter[] paramter = {
                                   new SqlParameter("@TitleName",art.TitleName),
                                   new SqlParameter("@ViceTitleName",art.ViceTitleName),
                                   new SqlParameter("@AuthorID",art.AuthorID),
                                   new SqlParameter("@AuthorName",art.AuthorName),
                                   new SqlParameter("@MainPicURL",art.MainPicURL),
                                   new SqlParameter("@PicWidth",art.PicWidth),
                                   new SqlParameter("@PicHeight",art.PicHeight),
                                   new SqlParameter("@CategoryID",art.CategoryID),
                                   new SqlParameter("@CategoryName",art.CategoryName),
                                   new SqlParameter("@Tags",art.Tags),
                                   new SqlParameter("@Summary",art.Summary),
                                   new SqlParameter("@DSummary",art.DSummary),
                                   new SqlParameter("@SourceUrl",art.SourceUrl),
                                   new SqlParameter("@AFrom",art.AFrom)
                               };
     object k = helper.GetSingle(sqltxt, paramter);
     if (k!=null)
     {
         int aid = int.Parse(k.ToString());
         if (aid > 0)
         {
             art.Details.AID = aid;
             rowcount = InsertArticleDetail(art.Details);
         }
     }
     return rowcount;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 插入文章信息
 /// </summary>
 /// <param name="art"></param>
 /// <returns></returns>
 public int InsertArticleInfo(ArticleInfo art)
 {
     return adal.InsertArticleInfo(art);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 根据ID查找文章
 /// </summary>
 /// <param name="artid"></param>
 /// <returns></returns>
 public ArticleInfo GetArticleinfoByID(int artid)
 {
     ArticleInfo model = new ArticleInfo();
     string sqltxt = @"SELECT  AID ,
     TitleName ,
     ViceTitleName ,
     AuthorID ,
     AuthorName ,
     PublishTime ,
     Astatus ,
     MainPicURL ,
     PicWidth ,
     PicHeight ,
     Addtime ,
     Updatetime ,
     CategoryID ,
     CategoryName ,
     Tags ,
     Summary ,
     DSummary ,
     ClickCount ,
     IsTop ,
     SourceUrl ,
     AFrom
     FROM    qds157425440_db.dbo.ArticleInfo WITH(NOLOCK)
     WHERE AID=@id AND Astatus=30";
     SqlParameter[] paramter = { new SqlParameter("@id", artid) };
     DataSet ds = helper.Query(sqltxt, paramter);
     if (ds != null && ds.Tables.Count > 0)
     {
         if (ds.Tables[0].Rows.Count > 0)
         {
             model.AID = int.Parse(ds.Tables[0].Rows[0]["AID"].ToString());
             model.TitleName = ds.Tables[0].Rows[0]["TitleName"].ToString();
             model.ViceTitleName = ds.Tables[0].Rows[0]["ViceTitleName"].ToString();
             model.AuthorID = int.Parse(ds.Tables[0].Rows[0]["AuthorID"].ToString());
             model.AuthorName = ds.Tables[0].Rows[0]["AuthorName"].ToString();
             model.PublishTime = DateTime.Parse(ds.Tables[0].Rows[0]["PublishTime"].ToString());
             model.Astatus = int.Parse(ds.Tables[0].Rows[0]["Astatus"].ToString());
             model.MainPicURL = ds.Tables[0].Rows[0]["MainPicURL"].ToString();
             model.PicWidth = int.Parse(ds.Tables[0].Rows[0]["PicWidth"].ToString());
             model.PicHeight = int.Parse(ds.Tables[0].Rows[0]["PicHeight"].ToString());
             model.Addtime = DateTime.Parse(ds.Tables[0].Rows[0]["Addtime"].ToString());
             model.Updatetime = DateTime.Parse(ds.Tables[0].Rows[0]["Updatetime"].ToString());
             model.CategoryID = int.Parse(ds.Tables[0].Rows[0]["CategoryID"].ToString());
             model.CategoryName = ds.Tables[0].Rows[0]["CategoryName"].ToString();
             model.Tags = ds.Tables[0].Rows[0]["Tags"].ToString();
             model.Summary = ds.Tables[0].Rows[0]["Summary"].ToString();
             model.DSummary = ds.Tables[0].Rows[0]["DSummary"].ToString();
             model.ClickCount = int.Parse(ds.Tables[0].Rows[0]["ClickCount"].ToString());
             model.IsTop = int.Parse(ds.Tables[0].Rows[0]["IsTop"].ToString());
             model.SourceUrl = ds.Tables[0].Rows[0]["SourceUrl"].ToString();
             model.AFrom = ds.Tables[0].Rows[0]["AFrom"].ToString();
         }
         else
         { return null; }
     }
     sqltxt = @"SELECT  AID ,
     CategoryID ,
     CategoryName ,
     AContent ,
     Summary ,
     Authorname ,
     ADetailtext
     FROM    qds157425440_db.dbo.ArticleDetail WITH(NOLOCK)
     WHERE AID=@id";
     ds = helper.Query(sqltxt, paramter);
     if (ds != null && ds.Tables.Count > 0)
     {
         if (ds.Tables[0].Rows.Count > 0)
         {
             ArticleDetail details = new ArticleDetail();
             details.AID = int.Parse(ds.Tables[0].Rows[0]["AID"].ToString());
             details.AContent = ds.Tables[0].Rows[0]["AContent"].ToString();
             details.Authorname = ds.Tables[0].Rows[0]["Authorname"].ToString();
             details.CategoryID = int.Parse(ds.Tables[0].Rows[0]["CategoryID"].ToString());
             details.CategoryName = ds.Tables[0].Rows[0]["CategoryName"].ToString();
             details.Summary = ds.Tables[0].Rows[0]["Summary"].ToString();
             details.ADetailtext = ds.Tables[0].Rows[0]["ADetailtext"].ToString();
             model.Details = details;
         }
     }
     return model;
 }