コード例 #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.about GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 id,channel_id,category_id,call_index,title,link_url,img_url,seo_title,seo_keywords,seo_description,zhaiyao,content,sort_id,click,status,is_msg,is_top,is_red,is_hot,is_slide,is_sys,user_name,add_time,update_time,company,site");
            strSql.Append(" from " + databaseprefix + "about");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
ファイル: list.aspx.cs プロジェクト: WayLeeLi/tea2
        //設定操作
        protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            //ChkAdminLevel("channel_" + this.channel_name + "_list", TWEnums.ActionEnum.Edit.ToString()); //檢查權限
            int id = Convert.ToInt32(((HiddenField)e.Item.FindControl("hidId")).Value);

            BLL.about   bll   = new BLL.about();
            Model.about model = bll.GetModel(id);
            switch (e.CommandName)
            {
            case "lbtnIsMsg":
                if (model.is_msg == 1)
                {
                    bll.UpdateField(id, "is_msg=0");
                }
                else
                {
                    bll.UpdateField(id, "is_msg=1");
                }
                break;

            case "lbtnIsSlide":
                if (model.is_slide == 1)
                {
                    bll.UpdateField(id, "is_slide=0");
                }
                else
                {
                    bll.UpdateField(id, "is_slide=1");
                }
                break;
            }
            this.RptBind(this.channel_id, this.category_id, "id>0" + CombSqlTxt(this.keywords, this.property, this.status), "sort_id desc,add_time desc,id desc");
        }
コード例 #3
0
        private bool DoAdd()
        {
            bool result = false;

            Model.about model = new Model.about();
            BLL.about   bll   = new BLL.about();

            model.channel_id      = this.channel_id;
            model.category_id     = Utils.StrToInt(ddlCategoryId.SelectedValue, 0);
            model.call_index      = txtCallIndex.Text.Trim();
            model.user_name       = ddlFabu.SelectedValue;
            model.title           = txtTitle.Text.Trim();
            model.link_url        = txtLinkUrl.Text.Trim();
            model.img_url         = txtImgUrl.Text;
            model.seo_title       = txtSeoTitle.Text.Trim();
            model.seo_keywords    = txtSeoKeywords.Text.Trim();
            model.seo_description = txtSeoDescription.Text.Trim();
            //内容摘要提取内容前255个字符
            if (string.IsNullOrEmpty(txtZhaiyao.Text.Trim()))
            {
                model.zhaiyao = Utils.DropHTML(txtContent.Value, 255);
            }
            else
            {
                model.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 255);
            }
            model.content = txtContent.Value;
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);
            model.click   = int.Parse(txtClick.Text.Trim());
            model.status  = Utils.StrToInt(rblStatus.SelectedValue, 0);
            model.is_msg  = 0;

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

            if (cblItem.Items[1].Selected == true)
            {
                model.is_slide = 1;
            }
            model.is_sys = 1; //管理员发布

            model.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim());
            DateTime _end_time;

            if (DateTime.TryParse(txtEndTime.Text.Trim(), out _end_time))
            {
                model.update_time = _end_time;
            }
            if (bll.Add(model) > 0)
            {
                AddAdminLog(TWEnums.ActionEnum.Add.ToString(), "添加" + this.channel_name + "频道内容:" + model.title); //记录日志
                result = true;
            }
            return(result);
        }
コード例 #4
0
ファイル: edit.aspx.cs プロジェクト: WayLeeLi/tea2
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.about   bll   = new BLL.about();
            Model.about model = bll.GetModel(_id);

            model.channel_id      = this.channel_id;
            model.category_id     = Utils.StrToInt(ddlCategoryId.SelectedValue, 0);
            model.call_index      = txtCallIndex.Text.Trim();
            model.title           = txtTitle.Text.Trim();
            model.link_url        = txtLinkUrl.Text.Trim();
            model.img_url         = txtImgUrl.Text;
            model.seo_title       = txtSeoTitle.Text.Trim();
            model.seo_keywords    = txtSeoKeywords.Text.Trim();
            model.seo_description = txtSeoDescription.Text.Trim();
            //內容摘要提取內容前255個字元
            if (string.IsNullOrEmpty(txtZhaiyao.Text.Trim()))
            {
                model.zhaiyao = Utils.DropHTML(txtContent.Value, 255);
            }
            else
            {
                model.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 255);
            }
            model.content = txtContent.Value;
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);
            model.click   = int.Parse(txtClick.Text.Trim());
            model.status  = Utils.StrToInt(rblStatus.SelectedValue, 0);
            model.is_msg  = 0;

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

            if (cblItem.Items[1].Selected == true)
            {
                model.is_slide = 1;
            }
            model.add_time    = Utils.StrToDateTime(txtAddTime.Text.Trim());
            model.update_time = DateTime.Now;
            if (bll.Update(model))
            {
                AddAdminLog(TWEnums.ActionEnum.Edit.ToString(), "修改" + this.channel_name + "頻道內容:" + model.title); //記錄日誌
                result = true;
            }
            return(result);
        }
コード例 #5
0
        private void ShowInfo(int _id)
        {
            BLL.about   bll   = new BLL.about();
            Model.about model = bll.GetModel(_id);

            ddlCategoryId.SelectedValue = model.category_id.ToString();
            txtCallIndex.Text           = model.call_index;
            txtTitle.Text   = model.title;
            txtLinkUrl.Text = model.link_url;
            //不是相册图片就绑定
            string filename = model.img_url.Substring(model.img_url.LastIndexOf("/") + 1);

            if (!filename.StartsWith("thumb_"))
            {
                txtImgUrl.Text = model.img_url;
            }
            txtSeoTitle.Text        = model.seo_title;
            txtSeoKeywords.Text     = model.seo_keywords;
            txtSeoDescription.Text  = model.seo_description;
            txtZhaiyao.Text         = model.zhaiyao;
            txtContent.Value        = model.content;
            txtSortId.Text          = model.sort_id.ToString();
            txtClick.Text           = model.click.ToString();
            rblStatus.SelectedValue = model.status.ToString();
            ddlFabu.SelectedValue   = model.user_name;
            if (action == TWEnums.ActionEnum.Edit.ToString())
            {
                txtAddTime.Text = model.add_time.ToString("yyyy-MM-dd");
            }
            if (model.is_msg == 1)
            {
                cblItem.Items[0].Selected = true;
            }

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

            if (model.update_time != null)
            {
                txtEndTime.Text = model.update_time.GetValueOrDefault().ToString("yyyy-M-d");
            }
        }
コード例 #6
0
ファイル: edit.aspx.cs プロジェクト: WayLeeLi/tea2
        private bool DoAdd()
        {
            bool result = false;

            Model.about model = new Model.about();
            BLL.about   bll   = new BLL.about();
            model.channel_id      = this.channel_id;
            model.category_id     = Utils.StrToInt(ddlCategoryId.SelectedValue, 0);
            model.call_index      = txtCallIndex.Text.Trim();
            model.title           = txtTitle.Text.Trim();
            model.link_url        = txtLinkUrl.Text.Trim();
            model.img_url         = txtImgUrl.Text;
            model.seo_title       = txtSeoTitle.Text.Trim();
            model.seo_keywords    = txtSeoKeywords.Text.Trim();
            model.seo_description = txtSeoDescription.Text.Trim();
            //內容摘要提取內容前255個字元
            if (string.IsNullOrEmpty(txtZhaiyao.Text.Trim()))
            {
                model.zhaiyao = Utils.DropHTML(txtContent.Value, 255);
            }
            else
            {
                model.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 255);
            }
            model.content = txtContent.Value;
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);
            model.click   = int.Parse(txtClick.Text.Trim());
            model.status  = Utils.StrToInt(rblStatus.SelectedValue, 0);
            model.is_msg  = 0;

            model.is_sys    = 1;                        //管理員發佈
            model.user_name = GetAdminInfo().user_name; //獲得當前登入用戶名
            model.add_time  = Utils.StrToDateTime(txtAddTime.Text.Trim());

            if (bll.Add(model) > 0)
            {
                AddAdminLog(TWEnums.ActionEnum.Add.ToString(), "添加" + this.channel_name + "頻道內容:" + model.title); //記錄日誌
                result = true;
            }
            return(result);
        }
コード例 #7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.about model)
 {
     return(dal.Update(model));
 }
コード例 #8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.about model)
 {
     return(dal.Add(model));
 }
コード例 #9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.about model)
 {
     using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
     {
         conn.Open();
         using (SqlTransaction trans = conn.BeginTransaction())
         {
             try
             {
                 #region 添加主表数据====================
                 StringBuilder strSql = new StringBuilder();
                 strSql.Append("insert into " + databaseprefix + "about(");
                 strSql.Append("channel_id,category_id,call_index,title,link_url,img_url,seo_title,seo_keywords,seo_description,zhaiyao,content,sort_id,click,status,is_msg,is_top,is_red,is_hot,is_slide,is_sys,user_name,add_time,update_time,company,site)");
                 strSql.Append(" values (");
                 strSql.Append("@channel_id,@category_id,@call_index,@title,@link_url,@img_url,@seo_title,@seo_keywords,@seo_description,@zhaiyao,@content,@sort_id,@click,@status,@is_msg,@is_top,@is_red,@is_hot,@is_slide,@is_sys,@user_name,@add_time,@update_time,@company,@site)");
                 strSql.Append(";select @@IDENTITY");
                 SqlParameter[] parameters =
                 {
                     new SqlParameter("@channel_id",      SqlDbType.Int,         4),
                     new SqlParameter("@category_id",     SqlDbType.Int,         4),
                     new SqlParameter("@call_index",      SqlDbType.NVarChar,   50),
                     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("@zhaiyao",         SqlDbType.NVarChar,  255),
                     new SqlParameter("@content",         SqlDbType.NText),
                     new SqlParameter("@sort_id",         SqlDbType.Int,         4),
                     new SqlParameter("@click",           SqlDbType.Int,         4),
                     new SqlParameter("@status",          SqlDbType.TinyInt,     1),
                     new SqlParameter("@is_msg",          SqlDbType.TinyInt,     1),
                     new SqlParameter("@is_top",          SqlDbType.TinyInt,     1),
                     new SqlParameter("@is_red",          SqlDbType.TinyInt,     1),
                     new SqlParameter("@is_hot",          SqlDbType.TinyInt,     1),
                     new SqlParameter("@is_slide",        SqlDbType.TinyInt,     1),
                     new SqlParameter("@is_sys",          SqlDbType.TinyInt,     1),
                     new SqlParameter("@user_name",       SqlDbType.NVarChar,  100),
                     new SqlParameter("@add_time",        SqlDbType.DateTime),
                     new SqlParameter("@update_time",     SqlDbType.DateTime),
                     new SqlParameter("@company",         SqlDbType.Int,         4),
                     new SqlParameter("@site",            SqlDbType.Int, 4)
                 };
                 parameters[0].Value  = model.channel_id;
                 parameters[1].Value  = model.category_id;
                 parameters[2].Value  = model.call_index;
                 parameters[3].Value  = model.title;
                 parameters[4].Value  = model.link_url;
                 parameters[5].Value  = model.img_url;
                 parameters[6].Value  = model.seo_title;
                 parameters[7].Value  = model.seo_keywords;
                 parameters[8].Value  = model.seo_description;
                 parameters[9].Value  = model.zhaiyao;
                 parameters[10].Value = model.content;
                 parameters[11].Value = model.sort_id;
                 parameters[12].Value = model.click;
                 parameters[13].Value = model.status;
                 parameters[14].Value = model.is_msg;
                 parameters[15].Value = model.is_top;
                 parameters[16].Value = model.is_red;
                 parameters[17].Value = model.is_hot;
                 parameters[18].Value = model.is_slide;
                 parameters[19].Value = model.is_sys;
                 parameters[20].Value = model.user_name;
                 parameters[21].Value = model.add_time;
                 parameters[22].Value = model.update_time;
                 parameters[23].Value = model.company;
                 parameters[24].Value = model.site;
                 //添加主表数据
                 object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); //带事务
                 model.id = Convert.ToInt32(obj);
                 #endregion
                 trans.Commit();
             }
             catch
             {
                 trans.Rollback();
                 return(0);
             }
         }
     }
     return(model.id);
 }
コード例 #10
0
 /// <summary>
 /// 将对象转换为实体
 /// </summary>
 private Model.about DataRowToModel(DataRow row)
 {
     Model.about model = new Model.about();
     if (row != null)
     {
         #region 主表信息======================
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["channel_id"] != null && row["channel_id"].ToString() != "")
         {
             model.channel_id = int.Parse(row["channel_id"].ToString());
         }
         if (row["category_id"] != null && row["category_id"].ToString() != "")
         {
             model.category_id = int.Parse(row["category_id"].ToString());
         }
         if (row["call_index"] != null)
         {
             model.call_index = row["call_index"].ToString();
         }
         if (row["title"] != null)
         {
             model.title = row["title"].ToString();
         }
         if (row["link_url"] != null)
         {
             model.link_url = row["link_url"].ToString();
         }
         if (row["img_url"] != null)
         {
             model.img_url = row["img_url"].ToString();
         }
         if (row["seo_title"] != null)
         {
             model.seo_title = row["seo_title"].ToString();
         }
         if (row["seo_keywords"] != null)
         {
             model.seo_keywords = row["seo_keywords"].ToString();
         }
         if (row["seo_description"] != null)
         {
             model.seo_description = row["seo_description"].ToString();
         }
         if (row["zhaiyao"] != null)
         {
             model.zhaiyao = row["zhaiyao"].ToString();
         }
         if (row["content"] != null)
         {
             model.content = row["content"].ToString();
         }
         if (row["sort_id"] != null && row["sort_id"].ToString() != "")
         {
             model.sort_id = int.Parse(row["sort_id"].ToString());
         }
         if (row["click"] != null && row["click"].ToString() != "")
         {
             model.click = int.Parse(row["click"].ToString());
         }
         if (row["status"] != null && row["status"].ToString() != "")
         {
             model.status = int.Parse(row["status"].ToString());
         }
         if (row["is_msg"] != null && row["is_msg"].ToString() != "")
         {
             model.is_msg = int.Parse(row["is_msg"].ToString());
         }
         if (row["is_top"] != null && row["is_top"].ToString() != "")
         {
             model.is_top = int.Parse(row["is_top"].ToString());
         }
         if (row["is_red"] != null && row["is_red"].ToString() != "")
         {
             model.is_red = int.Parse(row["is_red"].ToString());
         }
         if (row["is_hot"] != null && row["is_hot"].ToString() != "")
         {
             model.is_hot = int.Parse(row["is_hot"].ToString());
         }
         if (row["is_slide"] != null && row["is_slide"].ToString() != "")
         {
             model.is_slide = int.Parse(row["is_slide"].ToString());
         }
         if (row["is_sys"] != null && row["is_sys"].ToString() != "")
         {
             model.is_sys = int.Parse(row["is_sys"].ToString());
         }
         if (row["user_name"] != null)
         {
             model.user_name = row["user_name"].ToString();
         }
         if (row["add_time"] != null && row["add_time"].ToString() != "")
         {
             model.add_time = DateTime.Parse(row["add_time"].ToString());
         }
         if (row["update_time"] != null && row["update_time"].ToString() != "")
         {
             model.update_time = DateTime.Parse(row["update_time"].ToString());
         }
         if (row["company"] != null && row["company"].ToString() != "")
         {
             model.company = int.Parse(row["company"].ToString());
         }
         if (row["site"] != null && row["site"].ToString() != "")
         {
             model.site = int.Parse(row["site"].ToString());
         }
         #endregion
     }
     return(model);
 }
コード例 #11
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.about model)
 {
     using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
     {
         conn.Open();
         using (SqlTransaction trans = conn.BeginTransaction())
         {
             try
             {
                 #region 修改主表数据==========================
                 StringBuilder strSql = new StringBuilder();
                 strSql.Append("update " + databaseprefix + "about set ");
                 strSql.Append("channel_id=@channel_id,");
                 strSql.Append("category_id=@category_id,");
                 strSql.Append("call_index=@call_index,");
                 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("zhaiyao=@zhaiyao,");
                 strSql.Append("content=@content,");
                 strSql.Append("sort_id=@sort_id,");
                 strSql.Append("click=@click,");
                 strSql.Append("status=@status,");
                 strSql.Append("is_msg=@is_msg,");
                 strSql.Append("is_top=@is_top,");
                 strSql.Append("is_red=@is_red,");
                 strSql.Append("is_hot=@is_hot,");
                 strSql.Append("is_slide=@is_slide,");
                 strSql.Append("is_sys=@is_sys,");
                 strSql.Append("user_name=@user_name,");
                 strSql.Append("add_time=@add_time,");
                 strSql.Append("update_time=@update_time");
                 strSql.Append(" where id=@id");
                 SqlParameter[] parameters =
                 {
                     new SqlParameter("@channel_id",      SqlDbType.Int,         4),
                     new SqlParameter("@category_id",     SqlDbType.Int,         4),
                     new SqlParameter("@call_index",      SqlDbType.NVarChar,   50),
                     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("@zhaiyao",         SqlDbType.NVarChar,  255),
                     new SqlParameter("@content",         SqlDbType.NText),
                     new SqlParameter("@sort_id",         SqlDbType.Int,         4),
                     new SqlParameter("@click",           SqlDbType.Int,         4),
                     new SqlParameter("@status",          SqlDbType.TinyInt,     1),
                     new SqlParameter("@is_msg",          SqlDbType.TinyInt,     1),
                     new SqlParameter("@is_top",          SqlDbType.TinyInt,     1),
                     new SqlParameter("@is_red",          SqlDbType.TinyInt,     1),
                     new SqlParameter("@is_hot",          SqlDbType.TinyInt,     1),
                     new SqlParameter("@is_slide",        SqlDbType.TinyInt,     1),
                     new SqlParameter("@is_sys",          SqlDbType.TinyInt,     1),
                     new SqlParameter("@user_name",       SqlDbType.NVarChar,  100),
                     new SqlParameter("@add_time",        SqlDbType.DateTime),
                     new SqlParameter("@update_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.call_index;
                 parameters[3].Value  = model.title;
                 parameters[4].Value  = model.link_url;
                 parameters[5].Value  = model.img_url;
                 parameters[6].Value  = model.seo_title;
                 parameters[7].Value  = model.seo_keywords;
                 parameters[8].Value  = model.seo_description;
                 parameters[9].Value  = model.zhaiyao;
                 parameters[10].Value = model.content;
                 parameters[11].Value = model.sort_id;
                 parameters[12].Value = model.click;
                 parameters[13].Value = model.status;
                 parameters[14].Value = model.is_msg;
                 parameters[15].Value = model.is_top;
                 parameters[16].Value = model.is_red;
                 parameters[17].Value = model.is_hot;
                 parameters[18].Value = model.is_slide;
                 parameters[19].Value = model.is_sys;
                 parameters[20].Value = model.user_name;
                 parameters[21].Value = model.add_time;
                 parameters[22].Value = model.update_time;
                 parameters[23].Value = model.id;
                 DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters);
                 #endregion
                 trans.Commit();
             }
             catch
             {
                 trans.Rollback();
                 return(false);
             }
         }
     }
     return(true);
 }