예제 #1
0
        public int Add(Article entity)
        {
            try
            {
                int result = 0;
                string strSQL = @"INSERT INTO tb_article (ChannelID,CategoryID,Title,Author,From,Summary,ImageUrl,LinkUrl,Content,SortID,ClickCount,IsRecommend,IsHot)
                            VALUES (@ChannelID,@CategoryID,@Title,@Author,@From,@Summary,@ImageUrl,@LinkUrl,@Content,@SortID,@ClickCount,@IsRecommend,@IsHot);";

                DbCommand dbCommand = DB.DB.Db().GetSqlStringCommand(strSQL);
                DB.DB.Db().AddInParameter(dbCommand, "@ChannelID", DbType.Int32, entity.ChannelID);
                DB.DB.Db().AddInParameter(dbCommand, "@CategoryID", DbType.Int32, entity.CategoryID);
                DB.DB.Db().AddInParameter(dbCommand, "@Title", DbType.String, entity.Title);
                DB.DB.Db().AddInParameter(dbCommand, "@Author", DbType.String, entity.Author);
                DB.DB.Db().AddInParameter(dbCommand, "@From", DbType.String, entity.From);
                DB.DB.Db().AddInParameter(dbCommand, "@Summary", DbType.String, entity.Summary);
                DB.DB.Db().AddInParameter(dbCommand, "@ImageUrl", DbType.String, entity.ImageURL);
                DB.DB.Db().AddInParameter(dbCommand, "@LinkUrl", DbType.String, entity.LinkURL);
                DB.DB.Db().AddInParameter(dbCommand, "@Content", DbType.String, entity.Content);
                DB.DB.Db().AddInParameter(dbCommand, "@SortID", DbType.Int32, entity.SortID);
                DB.DB.Db().AddInParameter(dbCommand, "@ClickCount", DbType.Int32, entity.ClickCount);
                DB.DB.Db().AddInParameter(dbCommand, "@IsRecommend", DbType.Int32, entity.IsRecommend);
                DB.DB.Db().AddInParameter(dbCommand, "@IsHot", DbType.Int32, entity.IsHot);

                result = DB.DB.Db().ExecuteNonQuery(dbCommand);

                return result;
            }
            catch (Exception ex)
            {
                Log.Log.logError(ex.Message);
                throw;
            }
        }
예제 #2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public int Add(Article entity)
 {
     return dal.Add(entity);
 }
예제 #3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public bool Update(Article entity)
 {
     return dal.Update(entity);
 }
        private bool DoAdd()
        {
            bool result = true;

            BLL.ArticleBll bll = new BLL.ArticleBll();
            Entity.Article model = new Article(); ;

            model.ChannelID = this.channel_id;
            model.Title = txtTitle.Text.Trim();
               // model.ChannelID = int.Parse(ddlCategoryId.SelectedValue);
            model.LinkURL = txtLinkUrl.Text.Trim();
            model.ImageURL = txtImgUrl.Text.Trim();
            model.Author = txtAuthor.Text.Trim();
            model.From = txtForm.Text.Trim();
            //自动提取摘要
            if (txtZhaiyao.Text.Trim() != string.Empty)
            {
                model.Summary = Utils.DropHTML(txtZhaiyao.Text, 250);
            }
            else
            {
                model.Summary = Utils.DropHTML(txtContent.Value, 250);
            }
            //model.seo_title = txtSeoTitle.Text.Trim();
            //model.seo_keywords = txtSeoKeywords.Text.Trim();
            //model.seo_description = txtSeoDescription.Text.Trim();
            //model.sort_id = int.Parse(txtSortId.Text.Trim());
            model.ClickCount = int.Parse(txtClick.Text.Trim());
            model.Content = txtContent.Value;

            model.IsRecommend = 0;
            model.IsHot = 0;

            if (cblItem.Items[0].Selected == true)
            {
                model.IsRecommend = 1;
            }
            if (cblItem.Items[1].Selected == true)
            {
                model.IsHot = 1;
            }

            if (bll.Add(model) < 1)
            {
                result = false;
            }
            return result;
        }
예제 #5
0
 private Article FillEntity(DataRow dr)
 {
     Article entity = new Article
     {
         ID = DataTypeHelper.Convert<Int32>(dr["ID"]),
         ChannelID = DataTypeHelper.Convert<Int32>(dr["ChannelID"]),
         CategoryID = DataTypeHelper.Convert<Int32>(dr["CategoryID"]),
         Title = DataTypeHelper.Convert<String>(dr["Title"]),
         Author = DataTypeHelper.Convert<String>(dr["Author"]),
         From = DataTypeHelper.Convert<String>(dr["From"]),
         Summary = DataTypeHelper.Convert<String>(dr["Summary"]),
         ImageURL = DataTypeHelper.Convert<String>(dr["ImageUrl"]),
         LinkURL = DataTypeHelper.Convert<String>(dr["LinkUrl"]),
         Content = DataTypeHelper.Convert<String>(dr["Content"]),
         SortID = DataTypeHelper.Convert<Int32>(dr["SortID"]),
         ClickCount = DataTypeHelper.Convert<Int32>(dr["ClickCount"]),
         IsRecommend = DataTypeHelper.Convert<Int32>(dr["IsRecommend"]),
         IsHot = DataTypeHelper.Convert<Int32>(dr["IsHot"]),
         AddTime = DataTypeHelper.Convert<DateTime>(dr["AddTime"])
     };
     return entity;
 }
예제 #6
0
        public bool Update(Article entity)
        {
            try
            {
                StringBuilder strSQL = new StringBuilder();
                strSQL.Append("UPDATE tb_article SET ");
                strSQL.Append("ChannelID=@ChannelID,");
                strSQL.Append("CategoryID=@CategoryID,");
                strSQL.Append("Title=@Title,");
                strSQL.Append("Author=@Author,");
                strSQL.Append("From=@From,");
                strSQL.Append("Summary=@Summary,");
                strSQL.Append("ImageUrl=@ImageUrl,");
                strSQL.Append("LinkUrl=@LinkUrl,");
                strSQL.Append("Content=@Content,");
                strSQL.Append("SortID=@SortID,");
                strSQL.Append("ClickCount=@ClickCount,");
                strSQL.Append("IsRecommend=@IsRecommend,");
                strSQL.Append("IsHot=@IsHot");
                strSQL.Append(" WHERE ID=@ID;");

                DbCommand dbCommand = DB.DB.Db().GetSqlStringCommand(strSQL.ToString());
                DB.DB.Db().AddInParameter(dbCommand, "@ChannelID", DbType.Int32, entity.ChannelID);
                DB.DB.Db().AddInParameter(dbCommand, "@CategoryID", DbType.Int32, entity.CategoryID);
                DB.DB.Db().AddInParameter(dbCommand, "@Title", DbType.String, entity.Title);
                DB.DB.Db().AddInParameter(dbCommand, "@Author", DbType.String, entity.Author);
                DB.DB.Db().AddInParameter(dbCommand, "@From", DbType.String, entity.From);
                DB.DB.Db().AddInParameter(dbCommand, "@Summary", DbType.String, entity.Summary);
                DB.DB.Db().AddInParameter(dbCommand, "@ImageUrl", DbType.String, entity.ImageURL);
                DB.DB.Db().AddInParameter(dbCommand, "@LinkUrl", DbType.String, entity.LinkURL);
                DB.DB.Db().AddInParameter(dbCommand, "@Content", DbType.String, entity.Content);
                DB.DB.Db().AddInParameter(dbCommand, "@SortID", DbType.Int32, entity.SortID);
                DB.DB.Db().AddInParameter(dbCommand, "@ClickCount", DbType.Int32, entity.ClickCount);
                DB.DB.Db().AddInParameter(dbCommand, "@IsRecommend", DbType.Int32, entity.IsRecommend);
                DB.DB.Db().AddInParameter(dbCommand, "@IsHot", DbType.Int32, entity.IsHot);

                DB.DB.Db().ExecuteNonQuery(dbCommand);

                return true;
            }
            catch (Exception ex)
            {
                Log.Log.logError(ex.Message);
                throw;
            }
        }