コード例 #1
0
ファイル: list.aspx.cs プロジェクト: yilulu/Way-diguang
        //設置操作
        protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            ChkAdminLevel(channel_id, DTEnums.ActionEnum.Edit.ToString()); //檢查許可權
            int id = Convert.ToInt32(((HiddenField)e.Item.FindControl("hidId")).Value);

            BLL.article           bll   = new BLL.article();
            Model.article_content model = bll.GetContentModel(id);
            switch (e.CommandName.ToLower())
            {
            case "ibtnmsg":
                if (model.is_msg == 1)
                {
                    bll.UpdateContentField(id, "is_msg=0");
                }
                else
                {
                    bll.UpdateContentField(id, "is_msg=1");
                }
                break;

            case "ibtnred":
                if (model.is_red == 1)
                {
                    bll.UpdateContentField(id, "is_red=0");
                }
                else
                {
                    bll.UpdateContentField(id, "is_red=1");
                }
                break;
            }
            this.RptBind("id>0" + CombSqlTxt(this.channel_id, this.category_id, this.keywords, this.property), "sort_id asc,add_time desc");
        }
コード例 #2
0
ファイル: edit.aspx.cs プロジェクト: yilulu/Way-diguang
        private void ShowInfo(int _id)
        {
            BLL.article           bll   = new BLL.article();
            Model.article_content model = bll.GetContentModel(_id);

            ddlCategoryId.SelectedValue = model.category_id.ToString();
            txtCallIndex.Text           = model.call_index;
            txtTitle.Text   = model.title;
            txtImgUrl.Text  = model.img_url;
            txtLinkUrl.Text = model.link_url;
            if (model.is_msg == 1)
            {
                cblItem.Items[0].Selected = true;
            }
            if (model.is_red == 1)
            {
                cblItem.Items[1].Selected = true;
            }
            if (model.is_lock == 1)
            {
                cblItem.Items[2].Selected = true;
            }
            txtSortId.Text         = model.sort_id.ToString();
            txtClick.Text          = model.click.ToString();
            txtDiggGood.Text       = model.digg_good.ToString();
            txtDiggBad.Text        = model.digg_bad.ToString();
            txtContent.Value       = model.content;
            txtSeoTitle.Text       = model.seo_title;
            txtSeoKeywords.Text    = model.seo_keywords;
            txtSeoDescription.Text = model.seo_description;
        }
コード例 #3
0
ファイル: edit.aspx.cs プロジェクト: yilulu/Way-diguang
        private bool DoEdit(int _id)
        {
            bool result = true;

            BLL.article           bll   = new BLL.article();
            Model.article_content model = bll.GetContentModel(_id);

            model.channel_id      = this.channel_id;
            model.title           = txtTitle.Text.Trim();
            model.call_index      = txtCallIndex.Text.Trim();
            model.category_id     = int.Parse(ddlCategoryId.SelectedValue);
            model.link_url        = txtLinkUrl.Text.Trim();
            model.img_url         = txtImgUrl.Text.Trim();
            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.click           = int.Parse(txtClick.Text.Trim());
            model.content         = txtContent.Value;
            model.digg_good       = int.Parse(txtDiggGood.Text.Trim());
            model.digg_bad        = int.Parse(txtDiggBad.Text.Trim());
            model.is_msg          = 0;
            model.is_red          = 0;
            model.is_lock         = 0;
            if (cblItem.Items[0].Selected == true)
            {
                model.is_msg = 1;
            }
            if (cblItem.Items[1].Selected == true)
            {
                model.is_red = 1;
            }
            if (cblItem.Items[2].Selected == true)
            {
                model.is_lock = 1;
            }

            if (!bll.Update(model))
            {
                result = false;
            }
            return(result);
        }
コード例 #4
0
 /// <summary>
 /// 重写虚方法,此方法将在Init事件前执行
 /// </summary>
 protected override void ShowPage()
 {
     id   = DTRequest.GetQueryInt("id");
     page = DTRequest.GetQueryString("page");
     BLL.article bll = new BLL.article();
     if (id > 0)
     {
         if (!bll.Exists(id))
         {
             HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出錯啦,您要瀏覽的頁面不存在或已刪除啦!"));
             return;
         }
         model = bll.GetContentModel(id);
     }
     else if (!string.IsNullOrEmpty(page))
     {
         if (!bll.ContentExists(page))
         {
             HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出錯啦,您要瀏覽的頁面不存在或已刪除啦!"));
             return;
         }
         model = bll.GetContentModel(page);
     }
     else
     {
         Server.Transfer("error.aspx");
         return;
     }
     //浏览数+1
     bll.UpdateField(model.id, "click=click+1");
     //跳转URL
     if (model.link_url != null)
     {
         model.link_url = model.link_url.Trim();
     }
     if (!string.IsNullOrEmpty(model.link_url))
     {
         HttpContext.Current.Response.Redirect(model.link_url);
     }
 }
コード例 #5
0
ファイル: content_show.cs プロジェクト: sichina/or-dtcms2.0
 /// <summary>
 /// 重写虚方法,此方法将在Init事件前执行
 /// </summary>
 protected override void ShowPage()
 {
     id = DTRequest.GetQueryInt("id");
     page = DTRequest.GetQueryString("page");
     BLL.article bll = new BLL.article();
     BLL.sys_channel bll_channel = new BLL.sys_channel();
     if (id > 0)
     {
         if (!bll.Exists(id))
         {
             HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"));
             return;
         }
         model = bll.GetContentModel(id);
     }
     else if (!string.IsNullOrEmpty(page))
     {
         if (!bll.ContentExists(page))
         {
             HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"));
             return;
         }
         model = bll.GetContentModel(page);
     }
     else
     {
         Server.Transfer("error.aspx");
         return;
     }
     //浏览数+1
     bll.UpdateField(model.id, "click=click+1");
     //跳转URL
     if (model.link_url != null)
         model.link_url = model.link_url.Trim();
     if (!string.IsNullOrEmpty(model.link_url))
     {
         HttpContext.Current.Response.Redirect(model.link_url);
     }
     channel = bll_channel.GetModel(model.channel_id);
 }
コード例 #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.article_content model)
 {
     return(dal.Update(model));
 }
コード例 #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.article_content model)
 {
     return(dal.Add(model));
 }
コード例 #8
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
        public Model.article_content GetContentModel(int id)
		{
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1 id,channel_id,category_id,title,link_url,img_url,seo_title,seo_keywords,seo_description,content,sort_id,click,is_lock,user_id,add_time,call_index,is_msg,is_red,digg_good,digg_bad from view_article_content ");
            strSql.Append(" where id=@id");
            OleDbParameter[] parameters = {
					new OleDbParameter("@id", OleDbType.Integer,4)};
            parameters[0].Value = id;

			Model.article_content model=new Model.article_content();
			DataSet ds=DbHelperOleDb.Query(strSql.ToString(),parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["channel_id"] != null && ds.Tables[0].Rows[0]["channel_id"].ToString() != "")
                {
                    model.channel_id = int.Parse(ds.Tables[0].Rows[0]["channel_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["category_id"] != null && ds.Tables[0].Rows[0]["category_id"].ToString() != "")
                {
                    model.category_id = int.Parse(ds.Tables[0].Rows[0]["category_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "")
                {
                    model.title = ds.Tables[0].Rows[0]["title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["link_url"] != null && ds.Tables[0].Rows[0]["link_url"].ToString() != "")
                {
                    model.link_url = ds.Tables[0].Rows[0]["link_url"].ToString();
                }
                if (ds.Tables[0].Rows[0]["img_url"] != null && ds.Tables[0].Rows[0]["img_url"].ToString() != "")
                {
                    model.img_url = ds.Tables[0].Rows[0]["img_url"].ToString();
                }
                if (ds.Tables[0].Rows[0]["seo_title"] != null && ds.Tables[0].Rows[0]["seo_title"].ToString() != "")
                {
                    model.seo_title = ds.Tables[0].Rows[0]["seo_title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["seo_keywords"] != null && ds.Tables[0].Rows[0]["seo_keywords"].ToString() != "")
                {
                    model.seo_keywords = ds.Tables[0].Rows[0]["seo_keywords"].ToString();
                }
                if (ds.Tables[0].Rows[0]["seo_description"] != null && ds.Tables[0].Rows[0]["seo_description"].ToString() != "")
                {
                    model.seo_description = ds.Tables[0].Rows[0]["seo_description"].ToString();
                }
                if (ds.Tables[0].Rows[0]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "")
                {
                    model.content = ds.Tables[0].Rows[0]["content"].ToString();
                }
                if (ds.Tables[0].Rows[0]["sort_id"] != null && ds.Tables[0].Rows[0]["sort_id"].ToString() != "")
                {
                    model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["click"] != null && ds.Tables[0].Rows[0]["click"].ToString() != "")
                {
                    model.click = int.Parse(ds.Tables[0].Rows[0]["click"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_lock"] != null && ds.Tables[0].Rows[0]["is_lock"].ToString() != "")
                {
                    model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_id"] != null && ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["call_index"] != null && ds.Tables[0].Rows[0]["call_index"].ToString() != "")
                {
                    model.call_index = ds.Tables[0].Rows[0]["call_index"].ToString();
                }
                if (ds.Tables[0].Rows[0]["is_msg"].ToString() != "")
                {
                    model.is_msg = int.Parse(ds.Tables[0].Rows[0]["is_msg"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_red"].ToString() != "")
                {
                    model.is_red = int.Parse(ds.Tables[0].Rows[0]["is_red"].ToString());
                }
                if (ds.Tables[0].Rows[0]["digg_good"].ToString() != "")
                {
                    model.digg_good = int.Parse(ds.Tables[0].Rows[0]["digg_good"].ToString());
                }
                if (ds.Tables[0].Rows[0]["digg_bad"].ToString() != "")
                {
                    model.digg_bad = int.Parse(ds.Tables[0].Rows[0]["digg_bad"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
		}
コード例 #9
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.article_content model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into dt_article(");
            strSql.Append("channel_id,category_id,title,link_url,img_url,seo_title,seo_keywords,seo_description,content,sort_id,click,is_lock,user_id,add_time)");
            strSql.Append(" values (");
            strSql.Append("@channel_id,@category_id,@title,@link_url,@img_url,@seo_title,@seo_keywords,@seo_description,@content,@sort_id,@click,@is_lock,@user_id,@add_time)");
            strSql.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@channel_id",      SqlDbType.Int,         4),
                new SqlParameter("@category_id",     SqlDbType.Int,         4),
                new SqlParameter("@title",           SqlDbType.NVarChar,  100),
                new SqlParameter("@link_url",        SqlDbType.NVarChar,  255),
                new SqlParameter("@img_url",         SqlDbType.NVarChar,  255),
                new SqlParameter("@seo_title",       SqlDbType.NVarChar,  255),
                new SqlParameter("@seo_keywords",    SqlDbType.NVarChar,  255),
                new SqlParameter("@seo_description", SqlDbType.NVarChar,  255),
                new SqlParameter("@content",         SqlDbType.NText),
                new SqlParameter("@sort_id",         SqlDbType.Int,         4),
                new SqlParameter("@click",           SqlDbType.Int,         4),
                new SqlParameter("@is_lock",         SqlDbType.TinyInt,     1),
                new SqlParameter("@user_id",         SqlDbType.Int,         4),
                new SqlParameter("@add_time",        SqlDbType.DateTime),
                new SqlParameter("@ReturnValue",     SqlDbType.Int)
            };
            parameters[0].Value      = model.channel_id;
            parameters[1].Value      = model.category_id;
            parameters[2].Value      = model.title;
            parameters[3].Value      = model.link_url;
            parameters[4].Value      = model.img_url;
            parameters[5].Value      = model.seo_title;
            parameters[6].Value      = model.seo_keywords;
            parameters[7].Value      = model.seo_description;
            parameters[8].Value      = model.content;
            parameters[9].Value      = model.sort_id;
            parameters[10].Value     = model.click;
            parameters[11].Value     = model.is_lock;
            parameters[12].Value     = model.user_id;
            parameters[13].Value     = model.add_time;
            parameters[14].Direction = ParameterDirection.Output;

            List <CommandInfo> sqllist = new List <CommandInfo>();
            CommandInfo        cmd     = new CommandInfo(strSql.ToString(), parameters);

            sqllist.Add(cmd);

            //副表信息
            StringBuilder strSql2 = new StringBuilder();

            strSql2.Append("insert into dt_article_content(");
            strSql2.Append("id,call_index,is_msg,is_red)");
            strSql2.Append(" values (");
            strSql2.Append("@id,@call_index,@is_msg,@is_red)");
            SqlParameter[] parameters2 =
            {
                new SqlParameter("@id",         SqlDbType.Int,       4),
                new SqlParameter("@call_index", SqlDbType.NVarChar, 50),
                new SqlParameter("@is_msg",     SqlDbType.TinyInt,   1),
                new SqlParameter("@is_red",     SqlDbType.TinyInt, 1)
            };
            parameters2[0].Direction = ParameterDirection.InputOutput;
            parameters2[1].Value     = model.call_index;
            parameters2[2].Value     = model.is_msg;
            parameters2[3].Value     = model.is_red;
            cmd = new CommandInfo(strSql2.ToString(), parameters2);
            sqllist.Add(cmd);

            //顶和踩
            StringBuilder strSql3 = new StringBuilder();

            strSql3.Append("insert into dt_article_diggs(");
            strSql3.Append("id,digg_good,digg_bad)");
            strSql3.Append(" values (");
            strSql3.Append("@id,@digg_good,@digg_bad)");
            SqlParameter[] parameters3 =
            {
                new SqlParameter("@id",        SqlDbType.Int, 4),
                new SqlParameter("@digg_good", SqlDbType.Int, 4),
                new SqlParameter("@digg_bad",  SqlDbType.Int, 4)
            };
            parameters3[0].Direction = ParameterDirection.InputOutput;
            parameters3[1].Value     = model.digg_good;
            parameters3[2].Value     = model.digg_bad;
            cmd = new CommandInfo(strSql3.ToString(), parameters3);
            sqllist.Add(cmd);

            DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist);
            return((int)parameters[14].Value);
        }
コード例 #10
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.article_content GetContentModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 id,channel_id,category_id,title,link_url,img_url,seo_title,seo_keywords,seo_description,content,sort_id,click,is_lock,user_id,add_time,call_index,is_msg,is_red,digg_good,digg_bad from view_article_content ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Model.article_content model = new Model.article_content();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["channel_id"] != null && ds.Tables[0].Rows[0]["channel_id"].ToString() != "")
                {
                    model.channel_id = int.Parse(ds.Tables[0].Rows[0]["channel_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["category_id"] != null && ds.Tables[0].Rows[0]["category_id"].ToString() != "")
                {
                    model.category_id = int.Parse(ds.Tables[0].Rows[0]["category_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "")
                {
                    model.title = ds.Tables[0].Rows[0]["title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["link_url"] != null && ds.Tables[0].Rows[0]["link_url"].ToString() != "")
                {
                    model.link_url = ds.Tables[0].Rows[0]["link_url"].ToString();
                }
                if (ds.Tables[0].Rows[0]["img_url"] != null && ds.Tables[0].Rows[0]["img_url"].ToString() != "")
                {
                    model.img_url = ds.Tables[0].Rows[0]["img_url"].ToString();
                }
                if (ds.Tables[0].Rows[0]["seo_title"] != null && ds.Tables[0].Rows[0]["seo_title"].ToString() != "")
                {
                    model.seo_title = ds.Tables[0].Rows[0]["seo_title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["seo_keywords"] != null && ds.Tables[0].Rows[0]["seo_keywords"].ToString() != "")
                {
                    model.seo_keywords = ds.Tables[0].Rows[0]["seo_keywords"].ToString();
                }
                if (ds.Tables[0].Rows[0]["seo_description"] != null && ds.Tables[0].Rows[0]["seo_description"].ToString() != "")
                {
                    model.seo_description = ds.Tables[0].Rows[0]["seo_description"].ToString();
                }
                if (ds.Tables[0].Rows[0]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "")
                {
                    model.content = ds.Tables[0].Rows[0]["content"].ToString();
                }
                if (ds.Tables[0].Rows[0]["sort_id"] != null && ds.Tables[0].Rows[0]["sort_id"].ToString() != "")
                {
                    model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["click"] != null && ds.Tables[0].Rows[0]["click"].ToString() != "")
                {
                    model.click = int.Parse(ds.Tables[0].Rows[0]["click"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_lock"] != null && ds.Tables[0].Rows[0]["is_lock"].ToString() != "")
                {
                    model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_id"] != null && ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["call_index"] != null && ds.Tables[0].Rows[0]["call_index"].ToString() != "")
                {
                    model.call_index = ds.Tables[0].Rows[0]["call_index"].ToString();
                }
                if (ds.Tables[0].Rows[0]["is_msg"].ToString() != "")
                {
                    model.is_msg = int.Parse(ds.Tables[0].Rows[0]["is_msg"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_red"].ToString() != "")
                {
                    model.is_red = int.Parse(ds.Tables[0].Rows[0]["is_red"].ToString());
                }
                if (ds.Tables[0].Rows[0]["digg_good"].ToString() != "")
                {
                    model.digg_good = int.Parse(ds.Tables[0].Rows[0]["digg_good"].ToString());
                }
                if (ds.Tables[0].Rows[0]["digg_bad"].ToString() != "")
                {
                    model.digg_bad = int.Parse(ds.Tables[0].Rows[0]["digg_bad"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #11
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.article_content model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update dt_article set ");
            strSql.Append("channel_id=@channel_id,");
            strSql.Append("category_id=@category_id,");
            strSql.Append("title=@title,");
            strSql.Append("link_url=@link_url,");
            strSql.Append("img_url=@img_url,");
            strSql.Append("seo_title=@seo_title,");
            strSql.Append("seo_keywords=@seo_keywords,");
            strSql.Append("seo_description=@seo_description,");
            strSql.Append("content=@content,");
            strSql.Append("sort_id=@sort_id,");
            strSql.Append("click=@click,");
            strSql.Append("is_lock=@is_lock,");
            strSql.Append("user_id=@user_id,");
            strSql.Append("add_time=@add_time");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@channel_id",      SqlDbType.Int,         4),
                new SqlParameter("@category_id",     SqlDbType.Int,         4),
                new SqlParameter("@title",           SqlDbType.NVarChar,  100),
                new SqlParameter("@link_url",        SqlDbType.NVarChar,  255),
                new SqlParameter("@img_url",         SqlDbType.NVarChar,  255),
                new SqlParameter("@seo_title",       SqlDbType.NVarChar,  255),
                new SqlParameter("@seo_keywords",    SqlDbType.NVarChar,  255),
                new SqlParameter("@seo_description", SqlDbType.NVarChar,  255),
                new SqlParameter("@content",         SqlDbType.NText),
                new SqlParameter("@sort_id",         SqlDbType.Int,         4),
                new SqlParameter("@click",           SqlDbType.Int,         4),
                new SqlParameter("@is_lock",         SqlDbType.TinyInt,     1),
                new SqlParameter("@user_id",         SqlDbType.Int,         4),
                new SqlParameter("@add_time",        SqlDbType.DateTime),
                new SqlParameter("@id",              SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.channel_id;
            parameters[1].Value  = model.category_id;
            parameters[2].Value  = model.title;
            parameters[3].Value  = model.link_url;
            parameters[4].Value  = model.img_url;
            parameters[5].Value  = model.seo_title;
            parameters[6].Value  = model.seo_keywords;
            parameters[7].Value  = model.seo_description;
            parameters[8].Value  = model.content;
            parameters[9].Value  = model.sort_id;
            parameters[10].Value = model.click;
            parameters[11].Value = model.is_lock;
            parameters[12].Value = model.user_id;
            parameters[13].Value = model.add_time;
            parameters[14].Value = model.id;

            List <CommandInfo> sqllist = new List <CommandInfo>();
            CommandInfo        cmd     = new CommandInfo(strSql.ToString(), parameters);

            sqllist.Add(cmd);

            //修改副表
            StringBuilder strSql2 = new StringBuilder();

            strSql2.Append("update dt_article_content set ");
            strSql2.Append("id=@id,");
            strSql2.Append("call_index=@call_index,");
            strSql2.Append("is_msg=@is_msg,");
            strSql2.Append("is_red=@is_red");
            strSql2.Append(" where id=@id ");
            SqlParameter[] parameters2 =
            {
                new SqlParameter("@id",         SqlDbType.Int,       4),
                new SqlParameter("@call_index", SqlDbType.NVarChar, 50),
                new SqlParameter("@is_msg",     SqlDbType.TinyInt,   1),
                new SqlParameter("@is_red",     SqlDbType.TinyInt, 1)
            };
            parameters2[0].Value = model.id;
            parameters2[1].Value = model.call_index;
            parameters2[2].Value = model.is_msg;
            parameters2[3].Value = model.is_red;
            cmd = new CommandInfo(strSql2.ToString(), parameters2);
            sqllist.Add(cmd);

            //修改顶和踩
            StringBuilder strSql3 = new StringBuilder();

            strSql3.Append("update dt_article_diggs set ");
            strSql3.Append("digg_good=@digg_good,");
            strSql3.Append("digg_bad=@digg_bad");
            strSql3.Append(" where id=@id ");
            SqlParameter[] parameters3 =
            {
                new SqlParameter("@digg_good", SqlDbType.Int, 4),
                new SqlParameter("@digg_bad",  SqlDbType.Int, 4),
                new SqlParameter("@id",        SqlDbType.Int, 4)
            };
            parameters3[0].Value = model.digg_good;
            parameters3[1].Value = model.digg_bad;
            parameters3[2].Value = model.id;
            cmd = new CommandInfo(strSql3.ToString(), parameters3);
            sqllist.Add(cmd);

            int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist);

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #12
0
        private bool DoAdd()
        {
            bool result = true;
            Model.article_content model = new Model.article_content();
            BLL.article bll = new BLL.article();

            model.channel_id = this.channel_id;
            model.title = txtTitle.Text.Trim();
            model.call_index = txtCallIndex.Text.Trim();
            model.category_id = 0;
            model.link_url = txtLinkUrl.Text.Trim();
            model.img_url = txtImgUrl.Text.Trim();
            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.click = int.Parse(txtClick.Text.Trim());
            model.content = txtContent.Text.Trim();
            model.digg_good = int.Parse(txtDiggGood.Text.Trim());
            model.digg_bad = int.Parse(txtDiggBad.Text.Trim());
            model.is_msg = 0;
            model.is_red = 0;
            model.is_lock = 0;
            if (bll.Add(model) < 1)
            {
                result = false;
            }
            return result;
        }