Example #1
0
        /// <summary>
        /// 根据id得到一个专题实体对象
        /// </summary>
        /// <param name="special_id"></param>
        /// <returns></returns>
        public YouthSpecial GetListById(int special_id)
        {
            YouthSpecial  model = new YouthSpecial();
            StringBuilder str   = new StringBuilder();

            str.Append(" select * from special ");
            str.Append(" where special_id=@special_id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@special_id", SqlDbType.Int, 8)
            };
            parameters[0].Value = special_id;
            DataSet ds = DbHelperSQL.Query(str.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["special_id"] != null)
                {
                    model.Special_id = Convert.ToInt32(ds.Tables[0].Rows[0]["special_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["special_title"] != null)
                {
                    model.Special_title = ds.Tables[0].Rows[0]["special_title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["special_img_url"] != null)
                {
                    model.Special_img_url = ds.Tables[0].Rows[0]["special_img_url"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        /// <summary>
        /// 更新首页banner
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int updIsBanner(YouthSpecial model)
        {
            StringBuilder str = new StringBuilder();

            str.Append(" update special set ");
            str.Append(" is_banner=@is_banner ");
            str.Append(" where special_id=@special_id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@is_banner",  SqlDbType.NVarChar, 10),
                new SqlParameter("@special_id", SqlDbType.Int, 8)
            };
            parameters[0].Value = model.Is_banner;
            parameters[1].Value = model.Special_id;
            int rows = DbHelperSQL.ExecuteSql(str.ToString(), parameters);

            StringBuilder str1 = new StringBuilder();

            str1.Append(" update special set ");
            str1.Append(" is_banner='N' ");
            str1.Append(" where special_id<>@special_id ");
            SqlParameter[] parameters1 =
            {
                new SqlParameter("@special_id", SqlDbType.Int, 8)
            };
            parameters1[0].Value = model.Special_id;
            DbHelperSQL.ExecuteSql(str1.ToString(), parameters1);
            return(rows);
        }
        protected void bindSpecial()
        {
            int special_id = Convert.ToInt32(ViewState["special_id"].ToString());

            model         = special_bll.GetListById(special_id);
            txtTitle.Text = model.Special_title;
            ViewState["Special_img_url"] = model.Special_img_url;
        }
        /// <summary>
        /// 添加专题
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddSpecial(YouthSpecial model)
        {
            int rows = special_dal.AddSpecial(model);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 更新首页banner
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool updIsBanner(YouthSpecial model)
        {
            int rows = special_dal.updIsBanner(model);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #6
0
        /// <summary>
        /// 添加专题
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddSpecial(YouthSpecial model)
        {
            StringBuilder str = new StringBuilder();

            str.Append(" insert into special ");
            str.Append("(special_title,special_img_url)");
            str.Append("values");
            str.Append("(@special_title,@special_img_url)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@special_title",   SqlDbType.NVarChar, 50),
                new SqlParameter("@special_img_url", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.Special_title;
            parameters[1].Value = model.Special_img_url;
            int rows = DbHelperSQL.ExecuteSql(str.ToString(), parameters);

            return(rows);
        }
Example #7
0
        /// <summary>
        /// 编辑更新专题
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdSpecial(YouthSpecial model)
        {
            StringBuilder str = new StringBuilder();

            str.Append(" update special set ");
            str.Append(" special_title=@special_title,");
            str.Append(" special_img_url=@special_img_url ");
            str.Append(" where special_id=@special_id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@special_title",   SqlDbType.NVarChar, 50),
                new SqlParameter("@special_img_url", SqlDbType.NVarChar, 50),
                new SqlParameter("@special_id",      SqlDbType.Int, 8)
            };
            parameters[0].Value = model.Special_title;
            parameters[1].Value = model.Special_img_url;
            parameters[2].Value = model.Special_id;
            int rows = DbHelperSQL.ExecuteSql(str.ToString(), parameters);

            return(rows);
        }