private bool DoAdd()
 {
     try
     {
         Model.meal_category model = new Model.meal_category();
         BLL.meal_category   bll   = new BLL.meal_category();
         model.call_index      = txtCallIndex.Text.Trim();
         model.title           = txtTitle.Text.Trim();
         model.parent_id       = int.Parse(ddlParentId.SelectedValue);
         model.sort_id         = int.Parse(txtSortId.Text.Trim());
         model.seo_title       = txtSeoTitle.Text;
         model.seo_keywords    = txtSeoKeywords.Text;
         model.seo_description = txtSeoDescription.Text;
         model.link_url        = txtLinkUrl.Text.Trim();
         model.img_url         = txtImgUrl.Text.Trim();
         model.content         = txtContent.Value;
         if (bll.Add(model) > 0)
         {
             AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加套餐频道栏目分类:" + model.title); //记录日志
             return(true);
         }
     }
     catch
     {
         return(false);
     }
     return(false);
 }
        private bool DoEdit(int _id)
        {
            try
            {
                BLL.meal_category   bll   = new BLL.meal_category();
                Model.meal_category model = bll.GetModel(_id);

                int parentId = int.Parse(ddlParentId.SelectedValue);
                model.call_index = txtCallIndex.Text.Trim();
                model.title      = txtTitle.Text.Trim();
                //如果选择的父ID不是自己,则更改
                if (parentId != model.id)
                {
                    model.parent_id = parentId;
                }
                model.sort_id         = int.Parse(txtSortId.Text.Trim());
                model.seo_title       = txtSeoTitle.Text;
                model.seo_keywords    = txtSeoKeywords.Text;
                model.seo_description = txtSeoDescription.Text;
                model.link_url        = txtLinkUrl.Text.Trim();
                model.img_url         = txtImgUrl.Text.Trim();
                model.content         = txtContent.Value;
                if (bll.Update(model))
                {
                    AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改套餐频道栏目分类:" + model.title); //记录日志
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
            return(false);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.meal_category GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, title, call_index, parent_id, class_list, class_layer, sort_id, link_url, img_url, content, seo_title, seo_keywords, seo_description  ");
            strSql.Append("  from td_meal_category ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.title      = ds.Tables[0].Rows[0]["title"].ToString();
                model.call_index = ds.Tables[0].Rows[0]["call_index"].ToString();
                if (ds.Tables[0].Rows[0]["parent_id"].ToString() != "")
                {
                    model.parent_id = int.Parse(ds.Tables[0].Rows[0]["parent_id"].ToString());
                }
                model.class_list = ds.Tables[0].Rows[0]["class_list"].ToString();
                if (ds.Tables[0].Rows[0]["class_layer"].ToString() != "")
                {
                    model.class_layer = int.Parse(ds.Tables[0].Rows[0]["class_layer"].ToString());
                }
                if (ds.Tables[0].Rows[0]["sort_id"].ToString() != "")
                {
                    model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString());
                }
                model.link_url        = ds.Tables[0].Rows[0]["link_url"].ToString();
                model.img_url         = ds.Tables[0].Rows[0]["img_url"].ToString();
                model.content         = ds.Tables[0].Rows[0]["content"].ToString();
                model.seo_title       = ds.Tables[0].Rows[0]["seo_title"].ToString();
                model.seo_keywords    = ds.Tables[0].Rows[0]["seo_keywords"].ToString();
                model.seo_description = ds.Tables[0].Rows[0]["seo_description"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.meal_category model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into td_meal_category(");
            strSql.Append("title,call_index,parent_id,class_list,class_layer,sort_id,link_url,img_url,content,seo_title,seo_keywords,seo_description");
            strSql.Append(") values (");
            strSql.Append("@title,@call_index,@parent_id,@class_list,@class_layer,@sort_id,@link_url,@img_url,@content,@seo_title,@seo_keywords,@seo_description");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@title",           SqlDbType.NVarChar, 100),
                new SqlParameter("@call_index",      SqlDbType.NVarChar,  50),
                new SqlParameter("@parent_id",       SqlDbType.Int,        4),
                new SqlParameter("@class_list",      SqlDbType.NVarChar, 500),
                new SqlParameter("@class_layer",     SqlDbType.Int,        4),
                new SqlParameter("@sort_id",         SqlDbType.Int,        4),
                new SqlParameter("@link_url",        SqlDbType.NVarChar, 255),
                new SqlParameter("@img_url",         SqlDbType.NVarChar, 255),
                new SqlParameter("@content",         SqlDbType.NText),
                new SqlParameter("@seo_title",       SqlDbType.NVarChar, 255),
                new SqlParameter("@seo_keywords",    SqlDbType.NVarChar, 255),
                new SqlParameter("@seo_description", SqlDbType.NVarChar, 255)
            };

            parameters[0].Value  = model.title;
            parameters[1].Value  = model.call_index;
            parameters[2].Value  = model.parent_id;
            parameters[3].Value  = model.class_list;
            parameters[4].Value  = model.class_layer;
            parameters[5].Value  = model.sort_id;
            parameters[6].Value  = model.link_url;
            parameters[7].Value  = model.img_url;
            parameters[8].Value  = model.content;
            parameters[9].Value  = model.seo_title;
            parameters[10].Value = model.seo_keywords;
            parameters[11].Value = model.seo_description;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        private void ShowInfo(int _id)
        {
            BLL.meal_category   bll   = new BLL.meal_category();
            Model.meal_category model = bll.GetModel(_id);

            ddlParentId.SelectedValue = model.parent_id.ToString();
            txtCallIndex.Text         = model.call_index;
            txtTitle.Text             = model.title;
            txtSortId.Text            = model.sort_id.ToString();
            txtSeoTitle.Text          = model.seo_title;
            txtSeoKeywords.Text       = model.seo_keywords;
            txtSeoDescription.Text    = model.seo_description;
            txtLinkUrl.Text           = model.link_url;
            txtImgUrl.Text            = model.img_url;
            txtContent.Value          = model.content;
        }
 private bool DoAdd()
 {
     try
     {
         Model.meal_category model = new Model.meal_category();
         BLL.meal_category bll = new BLL.meal_category();
         model.call_index = txtCallIndex.Text.Trim();
         model.title = txtTitle.Text.Trim();
         model.parent_id = int.Parse(ddlParentId.SelectedValue);
         model.sort_id = int.Parse(txtSortId.Text.Trim());
         model.seo_title = txtSeoTitle.Text;
         model.seo_keywords = txtSeoKeywords.Text;
         model.seo_description = txtSeoDescription.Text;
         model.link_url = txtLinkUrl.Text.Trim();
         model.img_url = txtImgUrl.Text.Trim();
         model.content = txtContent.Value;
         if (bll.Add(model) >0)
         {
             AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加套餐频道栏目分类:" + model.title); //记录日志
             return true;
         }
     }
     catch
     {
         return false;
     }
     return false;
 }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.meal_category model)
 {
     return(dal.Update(model));
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.meal_category model)
 {
     return(dal.Add(model));
 }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.meal_category GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select id, title, call_index, parent_id, class_list, class_layer, sort_id, link_url, img_url, content, seo_title, seo_keywords, seo_description  ");
            strSql.Append("  from td_meal_category ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.title = ds.Tables[0].Rows[0]["title"].ToString();
                model.call_index = ds.Tables[0].Rows[0]["call_index"].ToString();
                if (ds.Tables[0].Rows[0]["parent_id"].ToString() != "")
                {
                    model.parent_id = int.Parse(ds.Tables[0].Rows[0]["parent_id"].ToString());
                }
                model.class_list = ds.Tables[0].Rows[0]["class_list"].ToString();
                if (ds.Tables[0].Rows[0]["class_layer"].ToString() != "")
                {
                    model.class_layer = int.Parse(ds.Tables[0].Rows[0]["class_layer"].ToString());
                }
                if (ds.Tables[0].Rows[0]["sort_id"].ToString() != "")
                {
                    model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString());
                }
                model.link_url = ds.Tables[0].Rows[0]["link_url"].ToString();
                model.img_url = ds.Tables[0].Rows[0]["img_url"].ToString();
                model.content = ds.Tables[0].Rows[0]["content"].ToString();
                model.seo_title = ds.Tables[0].Rows[0]["seo_title"].ToString();
                model.seo_keywords = ds.Tables[0].Rows[0]["seo_keywords"].ToString();
                model.seo_description = ds.Tables[0].Rows[0]["seo_description"].ToString();

                return model;
            }
            else
            {
                return null;
            }
        }
Exemple #10
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.meal_category model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update td_meal_category set ");

            strSql.Append(" title = @title , ");
            strSql.Append(" call_index = @call_index , ");
            strSql.Append(" parent_id = @parent_id , ");
            strSql.Append(" class_list = @class_list , ");
            strSql.Append(" class_layer = @class_layer , ");
            strSql.Append(" sort_id = @sort_id , ");
            strSql.Append(" link_url = @link_url , ");
            strSql.Append(" img_url = @img_url , ");
            strSql.Append(" content = @content , ");
            strSql.Append(" seo_title = @seo_title , ");
            strSql.Append(" seo_keywords = @seo_keywords , ");
            strSql.Append(" seo_description = @seo_description  ");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@id",              SqlDbType.Int,        4),
                new SqlParameter("@title",           SqlDbType.NVarChar, 100),
                new SqlParameter("@call_index",      SqlDbType.NVarChar,  50),
                new SqlParameter("@parent_id",       SqlDbType.Int,        4),
                new SqlParameter("@class_list",      SqlDbType.NVarChar, 500),
                new SqlParameter("@class_layer",     SqlDbType.Int,        4),
                new SqlParameter("@sort_id",         SqlDbType.Int,        4),
                new SqlParameter("@link_url",        SqlDbType.NVarChar, 255),
                new SqlParameter("@img_url",         SqlDbType.NVarChar, 255),
                new SqlParameter("@content",         SqlDbType.NText),
                new SqlParameter("@seo_title",       SqlDbType.NVarChar, 255),
                new SqlParameter("@seo_keywords",    SqlDbType.NVarChar, 255),
                new SqlParameter("@seo_description", SqlDbType.NVarChar, 255)
            };

            parameters[0].Value  = model.id;
            parameters[1].Value  = model.title;
            parameters[2].Value  = model.call_index;
            parameters[3].Value  = model.parent_id;
            parameters[4].Value  = model.class_list;
            parameters[5].Value  = model.class_layer;
            parameters[6].Value  = model.sort_id;
            parameters[7].Value  = model.link_url;
            parameters[8].Value  = model.img_url;
            parameters[9].Value  = model.content;
            parameters[10].Value = model.seo_title;
            parameters[11].Value = model.seo_keywords;
            parameters[12].Value = model.seo_description;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }