Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>返回影响行数</returns>
        public int Add(Arc_Article model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("INSERT INTO " + tablePrefix + "Arc_Article(");
            strSql.Append("ClassID,ViceClassID,Title,ShortTitle,TitleStyle,TitleFlag,Tags,ImgUrl,Author,Editor,PubLisher,Source,Templet,Keywords,Description,AContent,Click,Good,Bad,Readaccess,Money,Attribute,IsComment,IsVerify,IsRecycle,IsRedirect,IsHtml,IsPaging,FilePath,SimilarArticle,AddDate,PubDate,OrderID)");
            strSql.Append(" VALUES (");
            strSql.Append("@ClassID,@ViceClassID,@Title,@ShortTitle,@TitleStyle,@TitleFlag,@Tags,@ImgUrl,@Author,@Editor,@PubLisher,@Source,@Templet,@Keywords,@Description,@AContent,@Click,@Good,@Bad,@Readaccess,@Money,@Attribute,@IsComment,@IsVerify,@IsRecycle,@IsRedirect,@IsHtml,@IsPaging,@FilePath,@SimilarArticle,@AddDate,@PubDate,@OrderID)");
            SqlParameter[] cmdParms =
            {
                AddInParameter("@ClassID",        SqlDbType.Int,        4, model.ClassID),
                AddInParameter("@ViceClassID",    SqlDbType.Int,        4, model.ViceClassID),
                AddInParameter("@Title",          SqlDbType.NVarChar, 100, model.Title),
                AddInParameter("@ShortTitle",     SqlDbType.NVarChar, 100, model.ShortTitle),
                AddInParameter("@TitleStyle",     SqlDbType.VarChar,  100, model.TitleStyle),
                AddInParameter("@TitleFlag",      SqlDbType.TinyInt,    1, model.TitleFlag),
                AddInParameter("@Tags",           SqlDbType.NVarChar, 100, model.Tags),
                AddInParameter("@ImgUrl",         SqlDbType.VarChar,  255, model.ImgUrl),
                AddInParameter("@Author",         SqlDbType.NVarChar,  50, model.Author),
                AddInParameter("@Editor",         SqlDbType.NVarChar,  50, model.Editor),
                AddInParameter("@PubLisher",      SqlDbType.NVarChar,  50, model.PubLisher),
                AddInParameter("@Source",         SqlDbType.NVarChar, 100, model.Source),
                AddInParameter("@Templet",        SqlDbType.VarChar,  255, model.Templet),
                AddInParameter("@Keywords",       SqlDbType.NVarChar, 200, model.Keywords),
                AddInParameter("@Description",    SqlDbType.NVarChar, 500, model.Description),
                AddInParameter("@AContent",       SqlDbType.NVarChar,   8, model.AContent),
                AddInParameter("@Click",          SqlDbType.Int,        4, model.Click),
                AddInParameter("@Good",           SqlDbType.Int,        4, model.Good),
                AddInParameter("@Bad",            SqlDbType.Int,        4, model.Bad),
                AddInParameter("@Readaccess",     SqlDbType.SmallInt,   2, model.Readaccess),
                AddInParameter("@Money",          SqlDbType.SmallInt,   2, model.Money),
                AddInParameter("@Attribute",      SqlDbType.SmallInt,   2, model.Attribute),
                AddInParameter("@IsComment",      SqlDbType.TinyInt,    1, model.IsComment),
                AddInParameter("@IsVerify",       SqlDbType.TinyInt,    1, model.IsVerify),
                AddInParameter("@IsRecycle",      SqlDbType.TinyInt,    1, model.IsRecycle),
                AddInParameter("@IsRedirect",     SqlDbType.TinyInt,    1, model.IsRedirect),
                AddInParameter("@IsHtml",         SqlDbType.TinyInt,    1, model.IsHtml),
                AddInParameter("@IsPaging",       SqlDbType.TinyInt,    1, model.IsPaging),
                AddInParameter("@FilePath",       SqlDbType.VarChar,  255, model.FilePath),
                AddInParameter("@SimilarArticle", SqlDbType.VarChar,  200, model.SimilarArticle),
                AddInParameter("@AddDate",        SqlDbType.DateTime,   8, model.AddDate),
                AddInParameter("@PubDate",        SqlDbType.DateTime,   8, model.PubDate),
                AddInParameter("@OrderID",        SqlDbType.Int,        4, model.OrderID)
            };

            return(dbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms));
        }
Esempio n. 2
0
        /// <summary>
        /// 获取文章实体,添加,修改
        /// </summary>
        /// <returns>文章实体</returns>
        private Arc_Article GetArticleModel()
        {
            Arc_Article model = new Arc_Article();

            model.ID             = NewID;
            model.ClassID        = TypeConvert.ToInt32(slt_ClassName.Value.Trim());
            model.ViceClassID    = TypeConvert.ToInt32(txt_ViceClassID.Value.Trim(), -1);
            model.Title          = txt_Title.Value.Trim();
            model.ShortTitle     = txt_ShortTitle.Value.Trim();
            model.TitleStyle     = hide_TitleStyle.Value.Trim();
            model.TitleFlag      = TypeConvert.ToByte(slt_TitleFlag.Value);
            model.Tags           = txt_Tags.Value.Trim();
            model.ImgUrl         = txt_ImageUrl.Value.Trim();
            model.Author         = txt_Author.Value.Trim();
            model.Editor         = txt_Editor.Value.Trim();
            model.PubLisher      = ""; //当前用户
            model.Source         = txt_Source.Value.Trim();
            model.Templet        = txt_Templet.Value.Trim();
            model.Keywords       = txt_Keywords.Value.Trim();
            model.Description    = txt_Description.Value.Trim();
            model.AContent       = txt_Content.Value.Trim();
            model.Click          = 0;
            model.Good           = 0;
            model.Bad            = 0;
            model.Readaccess     = TypeConvert.ToInt16(slt_Readaccess.Value.Trim());
            model.Money          = TypeConvert.ToInt16(txt_Money.Value.Trim());
            model.Attribute      = TypeConvert.ToInt16(hide_Attribute.Value.Trim()); //文章属性
            model.IsComment      = (byte)(chk_IsComment.Checked ? 1 : 0);
            model.IsVerify       = (byte)(chk_IsVerify.Checked ? 1 : 0);
            model.IsRecycle      = (byte)0;
            model.IsRedirect     = (byte)(chk_JumpUrl.Checked ? 1 : 0);
            model.IsHtml         = (byte)(chk_IsHtml.Checked ? 1 : 0);
            model.IsPaging       = (byte)(rdo_Autopage.Checked ? 1 : 0);
            model.FilePath       = txt_FilePath.Value.Trim();
            model.SimilarArticle = txt_SimilarArticle.Value.Trim();
            model.AddDate        = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            model.PubDate        = Convert.ToDateTime(txt_PubDate.Value.Trim() == "" ? DateTime.Now.ToString("yyyy-MM-dd HH:ss:mm") : txt_PubDate.Value.Trim());
            model.OrderID        = int.Parse(txt_OrderID.Value.Trim() == "" ? "0" : txt_OrderID.Value.Trim());

            return(model);
        }
Esempio n. 3
0
        /// <summary>
        /// 由一行数据得到一个实体
        /// </summary>
        /// <param name="dr">SqlDataReader对象</param>
        /// <returns>实体对象</returns>
        private Arc_Article GetModel(SqlDataReader dr)
        {
            Arc_Article model = new Arc_Article();

            model.ID             = dbHelper.GetInt(dr["ID"]);
            model.ClassID        = dbHelper.GetInt(dr["ClassID"]);
            model.ViceClassID    = dbHelper.GetInt(dr["ViceClassID"]);
            model.Title          = dbHelper.GetString(dr["Title"]);
            model.ShortTitle     = dbHelper.GetString(dr["ShortTitle"]);
            model.TitleStyle     = dbHelper.GetString(dr["TitleStyle"]);
            model.TitleFlag      = dbHelper.GetByte(dr["TitleFlag"]);
            model.Tags           = dbHelper.GetString(dr["Tags"]);
            model.ImgUrl         = dbHelper.GetString(dr["ImgUrl"]);
            model.Author         = dbHelper.GetString(dr["Author"]);
            model.Editor         = dbHelper.GetString(dr["Editor"]);
            model.PubLisher      = dbHelper.GetString(dr["PubLisher"]);
            model.Source         = dbHelper.GetString(dr["Source"]);
            model.Templet        = dbHelper.GetString(dr["Templet"]);
            model.Keywords       = dbHelper.GetString(dr["Keywords"]);
            model.Description    = dbHelper.GetString(dr["Description"]);
            model.AContent       = dbHelper.GetString(dr["AContent"]);
            model.Click          = dbHelper.GetInt(dr["Click"]);
            model.Good           = dbHelper.GetInt(dr["Good"]);
            model.Bad            = dbHelper.GetInt(dr["Bad"]);
            model.Readaccess     = dbHelper.GetInt16(dr["Readaccess"]);
            model.Money          = dbHelper.GetInt16(dr["Money"]);
            model.Attribute      = dbHelper.GetInt16(dr["Attribute"]);
            model.IsComment      = dbHelper.GetByte(dr["IsComment"]);
            model.IsVerify       = dbHelper.GetByte(dr["IsVerify"]);
            model.IsRecycle      = dbHelper.GetByte(dr["IsRecycle"]);
            model.IsRedirect     = dbHelper.GetByte(dr["IsRedirect"]);
            model.IsHtml         = dbHelper.GetByte(dr["IsHtml"]);
            model.IsPaging       = dbHelper.GetByte(dr["IsPaging"]);
            model.FilePath       = dbHelper.GetString(dr["FilePath"]);
            model.SimilarArticle = dbHelper.GetString(dr["SimilarArticle"]);
            model.AddDate        = dbHelper.GetDateTime(dr["AddDate"]);
            model.PubDate        = dbHelper.GetDateTime(dr["PubDate"]);
            model.OrderID        = dbHelper.GetInt(dr["OrderID"]);
            return(model);
        }
Esempio n. 4
0
        /// <summary>
        ///  更新,初始化页面数据
        /// </summary>
        /// <param name="NewID">文章ID</param>
        private void SetPageData()
        {
            if (NewID <= 0)
            {
                return;
            }

            Arc_Article model = articleBll.GetModel(NewID);

            if (model != null)
            {
                slt_TitleFlag.Value         = model.TitleFlag.ToString();
                txt_Title.Value             = model.Title;
                hide_Attribute.Value        = model.Attribute.ToString();
                hide_TitleStyle.Value       = model.TitleStyle;
                txt_Tags.Value              = model.Tags;
                slt_ClassName.SelectedIndex = slt_ClassName.Items.IndexOf(slt_ClassName.Items.FindByValue(model.ClassID.ToString()));
                txt_Source.Value            = model.Source;
                txt_Author.Value            = model.Author;
                txt_Editor.Value            = model.Editor;
                txt_ImageUrl.Value          = model.ImgUrl;
                txt_Content.Value           = model.AContent;
                txt_ShortTitle.Value        = model.ShortTitle.Trim();
                txt_ViceClassID.Value       = model.ViceClassID.ToString();
                txt_OrderID.Value           = model.OrderID.ToString();
                txt_Templet.Value           = model.Templet;
                txt_FilePath.Value          = model.FilePath;
                txt_PubDate.Value           = model.PubDate.ToString();
                slt_Readaccess.Value        = model.Readaccess.ToString();
                txt_Money.Value             = model.Money.ToString();
                txt_SimilarArticle.Value    = model.SimilarArticle;
                txt_Keywords.Value          = model.Keywords.Trim();
                txt_Description.Value       = model.Description;
                //是否生成静态页
                chk_IsHtml.Checked = (model.IsHtml == 1);
                //是否允许评论
                chk_IsComment.Checked = (model.IsComment == 1);
                chk_IsVerify.Checked  = (model.IsVerify == 1); //是否审核
            }
        }
Esempio n. 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">实体对象</param>
 /// <returns>返回影响行数</returns>
 public int Update(Arc_Article model)
 {
     return(dal.Update(model));
 }
Esempio n. 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">实体对象</param>
 /// <returns>返回影响行数</returns>
 public int Add(Arc_Article model)
 {
     return(dal.Add(model));
 }
Esempio n. 7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>返回影响行数</returns>
        public int Update(Arc_Article model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("UPDATE " + tablePrefix + "Arc_Article SET ");
            strSql.Append("ClassID=@ClassID,");
            strSql.Append("ViceClassID=@ViceClassID,");
            strSql.Append("Title=@Title,");
            strSql.Append("ShortTitle=@ShortTitle,");
            strSql.Append("TitleStyle=@TitleStyle,");
            strSql.Append("TitleFlag=@TitleFlag,");
            strSql.Append("Tags=@Tags,");
            strSql.Append("ImgUrl=@ImgUrl,");
            strSql.Append("Author=@Author,");
            strSql.Append("Editor=@Editor,");
            strSql.Append("PubLisher=@PubLisher,");
            strSql.Append("Source=@Source,");
            strSql.Append("Templet=@Templet,");
            strSql.Append("Keywords=@Keywords,");
            strSql.Append("Description=@Description,");
            strSql.Append("AContent=@AContent,");
            strSql.Append("Click=@Click,");
            strSql.Append("Good=@Good,");
            strSql.Append("Bad=@Bad,");
            strSql.Append("Readaccess=@Readaccess,");
            strSql.Append("Money=@Money,");
            strSql.Append("Attribute=@Attribute,");
            strSql.Append("IsComment=@IsComment,");
            strSql.Append("IsVerify=@IsVerify,");
            strSql.Append("IsRecycle=@IsRecycle,");
            strSql.Append("IsRedirect=@IsRedirect,");
            strSql.Append("IsHtml=@IsHtml,");
            strSql.Append("IsPaging=@IsPaging,");
            strSql.Append("FilePath=@FilePath,");
            strSql.Append("SimilarArticle=@SimilarArticle,");
            strSql.Append("AddDate=@AddDate,");
            strSql.Append("PubDate=@PubDate,");
            strSql.Append("OrderID=@OrderID");
            strSql.Append(" WHERE ID=@ID");
            SqlParameter[] cmdParms =
            {
                AddInParameter("@ClassID",        SqlDbType.Int,        4, model.ClassID),
                AddInParameter("@ViceClassID",    SqlDbType.Int,        4, model.ViceClassID),
                AddInParameter("@Title",          SqlDbType.NVarChar, 100, model.Title),
                AddInParameter("@ShortTitle",     SqlDbType.NVarChar, 100, model.ShortTitle),
                AddInParameter("@TitleStyle",     SqlDbType.VarChar,  100, model.TitleStyle),
                AddInParameter("@TitleFlag",      SqlDbType.TinyInt,    1, model.TitleFlag),
                AddInParameter("@Tags",           SqlDbType.NVarChar, 100, model.Tags),
                AddInParameter("@ImgUrl",         SqlDbType.VarChar,  255, model.ImgUrl),
                AddInParameter("@Author",         SqlDbType.NVarChar,  50, model.Author),
                AddInParameter("@Editor",         SqlDbType.NVarChar,  50, model.Editor),
                AddInParameter("@PubLisher",      SqlDbType.NVarChar,  50, model.PubLisher),
                AddInParameter("@Source",         SqlDbType.NVarChar, 100, model.Source),
                AddInParameter("@Templet",        SqlDbType.VarChar,  255, model.Templet),
                AddInParameter("@Keywords",       SqlDbType.NVarChar, 200, model.Keywords),
                AddInParameter("@Description",    SqlDbType.NVarChar, 500, model.Description),
                AddInParameter("@AContent",       SqlDbType.NVarChar,   8, model.AContent),
                AddInParameter("@Click",          SqlDbType.Int,        4, model.Click),
                AddInParameter("@Good",           SqlDbType.Int,        4, model.Good),
                AddInParameter("@Bad",            SqlDbType.Int,        4, model.Bad),
                AddInParameter("@Readaccess",     SqlDbType.SmallInt,   2, model.Readaccess),
                AddInParameter("@Money",          SqlDbType.SmallInt,   2, model.Money),
                AddInParameter("@Attribute",      SqlDbType.SmallInt,   2, model.Attribute),
                AddInParameter("@IsComment",      SqlDbType.TinyInt,    1, model.IsComment),
                AddInParameter("@IsVerify",       SqlDbType.TinyInt,    1, model.IsVerify),
                AddInParameter("@IsRecycle",      SqlDbType.TinyInt,    1, model.IsRecycle),
                AddInParameter("@IsRedirect",     SqlDbType.TinyInt,    1, model.IsRedirect),
                AddInParameter("@IsHtml",         SqlDbType.TinyInt,    1, model.IsHtml),
                AddInParameter("@IsPaging",       SqlDbType.TinyInt,    1, model.IsPaging),
                AddInParameter("@FilePath",       SqlDbType.VarChar,  255, model.FilePath),
                AddInParameter("@SimilarArticle", SqlDbType.VarChar,  200, model.SimilarArticle),
                AddInParameter("@AddDate",        SqlDbType.DateTime,   8, model.AddDate),
                AddInParameter("@PubDate",        SqlDbType.DateTime,   8, model.PubDate),
                AddInParameter("@OrderID",        SqlDbType.Int,        4, model.OrderID),
                AddInParameter("@ID",             SqlDbType.Int,        4, model.ID)
            };

            return(dbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms));
        }
Esempio n. 8
0
        protected void Btn_Submit_Click(object sender, EventArgs e)
        {
            int         updateStart  = 0; //更新是否成功
            Arc_Article modelArticle = GetArticleModel();

            #region 数据验证

            if (modelArticle.ClassID <= 0 || !bllClass.Exists(modelArticle.ClassID, "", ""))
            {//栏目不存在
                Message.Dialog("操作失败!文章所选栏目不存在。", "-1", MessageIcon.Error, 0);
                return;
            }
            if (modelArticle.Title.Trim() == "")
            {//文章标题为空
                Message.Dialog("操作失败!文章标题不能为空。", "-1", MessageIcon.Error, 0);
                return;
            }

            if (articleBll.ExistsArticleName(NewID, modelArticle.Title))
            {//文章已经存在
                Message.Dialog("操作失败!该文章已经存在。", "-1", MessageIcon.Error, 0);
                return;
            }
            #endregion 数据验证

            if (NewID > 0)
            {
                try
                {
                    updateStart = articleBll.Update(modelArticle);
                }
                catch
                {
                    Message.Dialog("更新文章失败!更新文章出现未知错误。", "-1", MessageIcon.Success, 0);
                    return;
                }

                if (updateStart > 0)
                {
                    Message.Dialog("更新文章成功!", "News_list.aspx", MessageIcon.Success, 0);
                    return;
                }
                else
                {
                    Message.Dialog("更新文章失败!请检查数据是否完整。", "-1", MessageIcon.Success, 0);
                    return;
                }
            }
            else
            {
                if (modelArticle.IsRedirect == 1)
                {
                    //是否是跳转地址
                    if (txt_Redirect.Value.Trim().Length == 0)
                    {
                        Message.Dialog("操作失败!跳转地址不能为空。", "-1", MessageIcon.Error, 0);
                        return;
                    }

                    modelArticle.FilePath = txt_Redirect.Value.Trim();
                    modelArticle.AContent = "";
                }

                try
                {
                    updateStart = articleBll.Add(modelArticle);
                }
                catch
                {
                    Message.Dialog("添加文章失败!添加文章出现未知错误。", "-1", MessageIcon.Success, 0);
                    return;
                }

                if (updateStart > 0)
                {
                    Message.Dialog("添加文章成功!", "News_list.aspx", MessageIcon.Success, 0);
                    return;
                }
                else
                {
                    Message.Dialog("添加文章失败!请检查数据是否完整。", "-1", MessageIcon.Success, 0);
                    return;
                }
            }
        }