コード例 #1
0
ファイル: article_list.cs プロジェクト: yi724926089/MyWx
        protected int totalcount; //OUT数据总数

        #endregion Fields

        #region Methods

        /// <summary>
        /// 重写虚方法,此方法将在Init事件前执行
        /// </summary>
        protected override void ShowPage()
        {
            page = MXRequest.GetQueryInt("page", 1);
            category_id = MXRequest.GetQueryInt("category_id");
            BLL.article_category bll = new BLL.article_category();
            model.title = "所有信息";
            if (category_id > 0) //如果ID获取到,将使用ID
            {
                if (bll.Exists(category_id))
                    model = bll.GetModel(category_id);
            }
        }
コード例 #2
0
ファイル: article_list.cs プロジェクト: wangjinfang/DTCMS
        protected int totalcount; //OUT数据总数

        #endregion Fields

        #region Methods

        /// <summary>
        /// 重写虚方法,此方法将在Init事件前执行
        /// </summary>
        protected override void ShowPage()
        {
            page = DTRequest.GetQueryInt("page", 1);
            category_id = DTRequest.GetQueryInt("category_id");
            strorder = DTRequest.GetQueryString("strorder");
            keyword = DTRequest.GetQueryString("keyword");
            flag = DTRequest.GetQueryString("flag");
            if (string.IsNullOrEmpty(flag))
            {
                flag = "default";
            }

            if (string.IsNullOrEmpty(strorder) || strorder == "default")
            {
                strorder = "default";
                str_order = "sort_id asc,add_time desc";
            }
            else
            {
                switch (strorder)
                {
                    case "moneya":
                        str_order = "sell_price asc";
                        break;
                    case "moneyd":
                        str_order = "sell_price desc";
                        break;
                }
            }

            BLL.article_category bll = new BLL.article_category();
            model.title = "所有信息";
            if (category_id > 0) //如果ID获取到,将使用ID
            {
                if (bll.Exists(category_id))
                    model = bll.GetModel(category_id);
                parent_category_id = model.parent_id;

                if (bll.Exists(parent_category_id))
                {
                    parent_category_title = bll.GetModel(parent_category_id).title;
                }
            }

            //if (hot_search.Contains(","))
            //{
            //    for (int i = 0; i < hot_search.Split(',').Length; i++)
            //    {

            //    }
            //}
        }
コード例 #3
0
ファイル: templatesDal.cs プロジェクト: yi724926089/MyWx
        /// <summary>
        /// 获得微帐号的底部菜单信息
        /// </summary>
        /// <param name="wid"></param>
        /// <param name="topNum">取前几条数据;若为-1,则不作筛选条件</param>
        /// <param name="parentId">若为-1,则不作筛选条件</param>
        /// <returns></returns>
        public IList<Model.article_category> GetBottomMenuByWid(int wid, int topNum, int parentId, int class_layer)
        {
            IList<Model.article_category> bottomList = new List<Model.article_category>();

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (topNum >= 0)
            {
                strSql.Append(" top " + topNum + " ");
            }
            strSql.Append(" id,title,call_index,parent_id,class_layer,link_url,img_url,[content],ico_url,seo_title,seo_keywords,seo_description from dt_article_category where channel_id=7 ");
            if (parentId != -1)
            {
                strSql.Append(" and parent_id=" + parentId);
            }
            if (class_layer != -1)
            {
                strSql.Append(" and class_layer=" + class_layer);
            }
            strSql.Append(" and wId=@wId order by sort_id asc");
            SqlParameter[] parameters = {
                    new SqlParameter("@wId", SqlDbType.Int,4)
            };
            parameters[0].Value = wid;
            SqlDataReader sr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters);

            Model.article_category category = new Model.article_category();
            while (sr.Read())
            {
                category = new Model.article_category();
                category.id = MyCommFun.Obj2Int(sr["id"]);
                category.title = MyCommFun.ObjToStr(sr["title"]);
                category.call_index = MyCommFun.ObjToStr(sr["call_index"]);
                category.parent_id = MyCommFun.Obj2Int(sr["parent_id"]);
                category.class_layer = MyCommFun.Obj2Int(sr["class_layer"]);
                category.link_url = MyCommFun.ObjToStr(sr["link_url"]);
                category.img_url = MyCommFun.ObjToStr(sr["img_url"]);
                category.content = MyCommFun.ObjToStr(sr["content"]);
                category.ico_url = MyCommFun.ObjToStr(sr["ico_url"]);
                category.seo_title = MyCommFun.ObjToStr(sr["seo_title"]);
                category.seo_keywords = MyCommFun.ObjToStr(sr["seo_keywords"]);
                category.seo_description = MyCommFun.ObjToStr(sr["seo_description"]);
                bottomList.Add(category);
            }
            sr.Close();

            return bottomList;
        }
コード例 #4
0
ファイル: category_edit.aspx.cs プロジェクト: zhanglg40/SANKE
        private bool DoEdit(int _id)
        {
            try
            {
                BLL.article_category   bll   = new BLL.article_category();
                Model.article_category model = bll.GetModel(_id);

                int parentId = int.Parse(ddlParentId.SelectedValue);
                model.channel_id = this.channel_id;
                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.remark     = txtRemark.Text.Trim();
                model.class_type = txtType.Text.Trim();
                model.class_no   = txtclassno.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(AXEnums.ActionEnum.Edit.ToString(), "修改" + this.channel_name + "频道栏目分类:" + model.title); //记录日志
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
            return(false);
        }
コード例 #5
0
        /// <summary>
        /// 递归找到父节点
        /// </summary>
        private void LoopChannelMenu(StringBuilder strTxt, string urlKey, string mark, int category_id)
        {
            BLL.article_category   bll   = new BLL.article_category();
            Model.article_category model = bll.Get(category_id);
            int parentId = model.parent_id;

            if (parentId > 0)
            {
                i++;
                this.LoopChannelMenu(strTxt, urlKey, mark, parentId);
            }
            string url = null;

            if (model.call_index != "")
            {
                url = linkurl(urlKey, model.call_index);
            }
            else
            {
                url = linkurl(urlKey, category_id);
            }
            strTxt.Append("<a href=\"" + url + "\">" + bll.GetTitle(category_id) + "</a>" + mark);
        }
コード例 #6
0
ファイル: category_edit.aspx.cs プロジェクト: WayLeeLi/tea2
        private bool DoAdd()
        {
            try
            {
                Model.article_category model = new Model.article_category();
                BLL.article_category   bll   = new BLL.article_category();
                model.channel_id = this.channel_id;
                if (cbIsLock.Checked)
                {
                    model.call_index = "1";
                }
                else
                {
                    model.call_index = "0";
                }
                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(TWEnums.ActionEnum.Add.ToString(), "添加" + this.channel_name + "頻道欄位分類:" + model.title); //記錄日誌
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
            return(false);
        }
コード例 #7
0
        private void ShowInfo(int _id)
        {
            BLL.article_category   bll   = new BLL.article_category();
            Model.article_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;
            txtContent.Value          = model.content;
            rblPage.SelectedValue     = model.is_page.ToString();
            rblStatus.SelectedValue   = model.is_lock.ToString();
            //图片
            txtImgUrl.Text = model.img_url;
            if (!string.IsNullOrEmpty(model.img_url))
            {
                ImgDiv.Visible  = true;
                ImgUrl.ImageUrl = model.img_url;
            }
        }
コード例 #8
0
ファイル: article_category.cs プロジェクト: hui3694/forcomp
        /// <summary>
        /// 得到一个对象实体(重载,带事务)
        /// </summary>
        public Model.article_category GetModel(SqlConnection conn, SqlTransaction trans, int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 " + column + " from " + databaseprefix + "article_category ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #9
0
        private bool DoEdit(int _id)
        {
            try
            {
                BLL.article_category   bll   = new BLL.article_category();
                Model.article_category model = bll.GetModel(_id);

                int parentId = int.Parse(ddlParentId.SelectedValue);
                model.channel_id = 0;
                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;
                model.ico_url         = Request.Form["txtImgICO"].Trim();// txtImgICO.Text;
                if (bll.Update(model))
                {
                    AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "修改" + pageLevelName + "频道栏目分类:" + model.title); //记录日志
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
            return(false);
        }
コード例 #10
0
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  BasicMethod
        #region  ExtensionMethod

        /// <summary>
        /// 根据微用户所在行业给微账户添加默认模块
        /// </summary>
        public void addMouduleByRoleid(int roleid, int wid)
        {
            BLL.article_category acBll = new article_category();
            //得到模型的实体类集合
            List <Model.wx_industry_defaultModule> idList = getModelList(" role_id=" + roleid + " order by sort_id asc");

            //循环给为账户添加行业模块
            for (int i = 0; i < idList.Count; i++)
            {
                Model.article_category acModel = new Model.article_category
                {
                    title      = idList[i].mName,
                    call_index = "mubanpinyin",
                    wid        = wid,
                    link_url   = idList[i].url,
                    channel_id = 1,
                    sort_id    = MyCommFun.Obj2Int(idList[i].sort_id)
                };
                int resId = acBll.Add(acModel);
                Model.article_category upModel = acBll.GetModel(resId);
                upModel.class_list = "," + resId + ",";
                acBll.Update(upModel);
            }
        }
コード例 #11
0
ファイル: templatesDal.cs プロジェクト: yidane/51wine
        /// <summary>
        /// 获得该分类信息,使用wid仅仅作为限制条件
        /// </summary>
        /// <param name="wid"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public Model.article_category GetCategoryByWid(int wid, int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1");
            strSql.Append(" id,title,call_index,parent_id,class_layer,link_url,img_url,[content],ico_url,seo_title,seo_keywords,seo_description  ");
            strSql.Append(" from dt_article_category  where   id=@id  and wId=@wId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",  SqlDbType.Int, 4),
                new SqlParameter("@wId", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;
            parameters[1].Value = wid;
            SqlDataReader sr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters);

            Model.article_category category = new Model.article_category();
            while (sr.Read())
            {
                category                 = new Model.article_category();
                category.id              = MyCommFun.Obj2Int(sr["id"]);
                category.title           = MyCommFun.ObjToStr(sr["title"]);
                category.call_index      = MyCommFun.ObjToStr(sr["call_index"]);
                category.parent_id       = MyCommFun.Obj2Int(sr["parent_id"]);
                category.class_layer     = MyCommFun.Obj2Int(sr["class_layer"]);
                category.link_url        = MyCommFun.ObjToStr(sr["link_url"]);
                category.img_url         = MyCommFun.ObjToStr(sr["img_url"]);
                category.content         = MyCommFun.ObjToStr(sr["content"]);
                category.ico_url         = MyCommFun.ObjToStr(sr["ico_url"]);
                category.seo_title       = MyCommFun.ObjToStr(sr["seo_title"]);
                category.seo_keywords    = MyCommFun.ObjToStr(sr["seo_keywords"]);
                category.seo_description = MyCommFun.ObjToStr(sr["seo_description"]);
            }
            sr.Close();
            return(category);
        }
コード例 #12
0
ファイル: article_category.cs プロジェクト: rockhe168/CMS
        /// <summary>
        /// 得到一个对象实体(重载,带事务)
        /// </summary>
        public Model.article_category GetModel(SqlConnection conn, SqlTransaction trans, int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1 id,channel_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 " + databaseprefix + "article_category ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            Model.article_category model = new Model.article_category();
            DataSet ds = DbHelperSQL.Query(conn, trans, strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
コード例 #13
0
ファイル: article_category.cs プロジェクト: xuxiaolei/DTCMS
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.article_category model, int role_id)
 {
     return(dal.Add(model, role_id));
 }
コード例 #14
0
ファイル: article_category.cs プロジェクト: wslyzhh/kuaisitu
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.article_category model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        #region 主表信息===========================
                        //先判断选中的父节点是否被包含
                        if (IsContainNode(model.id, model.parent_id))
                        {
                            //查找旧数据
                            Model.article_category oldModel = GetModel(model.id);
                            //查找旧父节点数据
                            string class_list  = "," + model.parent_id + ",";
                            int    class_layer = 1;
                            if (oldModel.parent_id > 0)
                            {
                                Model.article_category oldParentModel = GetModel(conn, trans, oldModel.parent_id);//带事务
                                class_list  = oldParentModel.class_list + model.parent_id + ",";
                                class_layer = oldParentModel.class_layer + 1;
                            }
                            //先提升选中的父节点
                            DbHelperSQL.ExecuteSql(conn, trans, "update " + databaseprefix + "article_category set parent_id=" + oldModel.parent_id + ",class_list='" + class_list + "', class_layer=" + class_layer + " where id=" + model.parent_id); //带事务
                            UpdateChilds(conn, trans, model.parent_id);                                                                                                                                                                                 //带事务
                        }
                        //更新子节点
                        if (model.parent_id > 0)
                        {
                            Model.article_category model2 = GetModel(conn, trans, model.parent_id);//带事务
                            model.class_list  = model2.class_list + model.id + ",";
                            model.class_layer = model2.class_layer + 1;
                        }
                        else
                        {
                            model.class_list  = "," + model.id + ",";
                            model.class_layer = 1;
                        }

                        //更新本栏目类别信息
                        StringBuilder strSql = new StringBuilder();
                        StringBuilder str1   = new StringBuilder();
                        //利用反射获得属性的所有公共属性
                        PropertyInfo[]      pros  = model.GetType().GetProperties();
                        List <SqlParameter> paras = new List <SqlParameter>();
                        strSql.Append("update " + databaseprefix + "article_category set ");
                        foreach (PropertyInfo pi in pros)
                        {
                            //如果不是主键及List<T>则追加sql字符串
                            if (!pi.Name.Equals("id") && !typeof(System.Collections.IList).IsAssignableFrom(pi.PropertyType))
                            {
                                //判断属性值是否为空
                                if (pi.GetValue(model, null) != null && !pi.GetValue(model, null).ToString().Equals(""))
                                {
                                    str1.Append(pi.Name + "=@" + pi.Name + ",");                          //声明参数
                                    paras.Add(new SqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值
                                }
                            }
                        }
                        strSql.Append(str1.ToString().Trim(','));
                        strSql.Append(" where id=@id");
                        paras.Add(new SqlParameter("@id", model.id));
                        DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), paras.ToArray());
                        //更新子节点
                        UpdateChilds(conn, trans, model.id);
                        #endregion

                        #region 栏目规格===========================
                        //删除已删除的栏目规格
                        DbHelperSQL.ExecuteSql(conn, trans, "delete from " + databaseprefix + "article_category_spec where category_id=" + model.id);
                        //添加/修改栏目规格
                        if (model.category_specs != null)
                        {
                            StringBuilder strSql3;
                            foreach (Model.article_category_spec modelt in model.category_specs)
                            {
                                strSql3 = new StringBuilder();
                                if (modelt.id > 0)
                                {
                                    strSql3.Append("update " + databaseprefix + "article_category_spec ");
                                    strSql3.Append("category_id=@category_id,");
                                    strSql3.Append("spec_id=@spec_id");
                                    strSql3.Append(" where id=@id");
                                    SqlParameter[] parameters3 =
                                    {
                                        new SqlParameter("@category_id", SqlDbType.Int, 4),
                                        new SqlParameter("@spec_id",     SqlDbType.Int, 4),
                                        new SqlParameter("@id",          SqlDbType.Int, 4)
                                    };
                                    parameters3[0].Value = modelt.category_id;
                                    parameters3[1].Value = modelt.spec_id;
                                    parameters3[2].Value = modelt.id;
                                    DbHelperSQL.ExecuteSql(conn, trans, strSql3.ToString(), parameters3);
                                }
                                else
                                {
                                    strSql3.Append("insert into " + databaseprefix + "article_category_spec(");
                                    strSql3.Append("category_id,spec_id)");
                                    strSql3.Append(" values (");
                                    strSql3.Append("@category_id,@spec_id)");
                                    SqlParameter[] parameters3 =
                                    {
                                        new SqlParameter("@category_id", SqlDbType.Int, 4),
                                        new SqlParameter("@spec_id",     SqlDbType.Int, 4)
                                    };
                                    parameters3[0].Value = model.id;//栏目的ID
                                    parameters3[1].Value = modelt.spec_id;
                                    DbHelperSQL.ExecuteSql(conn, trans, strSql3.ToString(), parameters3);
                                }
                            }
                        }
                        #endregion

                        trans.Commit();//提交事务
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();//回滚事务
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #15
0
ファイル: article_category.cs プロジェクト: hui3694/forcomp
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.article_category model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        //先判断选中的父节点是否被包含
                        if (IsContainNode(model.id, model.parent_id))
                        {
                            //查找旧数据
                            Model.article_category oldModel = GetModel(model.id);
                            //查找旧父节点数据
                            string class_list  = "," + model.parent_id + ",";
                            int    class_layer = 1;
                            if (oldModel.parent_id > 0)
                            {
                                Model.article_category oldParentModel = GetModel(conn, trans, oldModel.parent_id); //带事务
                                class_list  = oldParentModel.class_list + model.parent_id + ",";
                                class_layer = oldParentModel.class_layer + 1;
                            }
                            //先提升选中的父节点
                            DbHelperSQL.ExecuteSql(conn, trans, "update " + databaseprefix + "article_category set parent_id=" + oldModel.parent_id + ",class_list='" + class_list + "', class_layer=" + class_layer + " where id=" + model.parent_id); //带事务
                            UpdateChilds(conn, trans, model.parent_id);                                                                                                                                                                                 //带事务
                        }
                        //更新子节点
                        if (model.parent_id > 0)
                        {
                            Model.article_category model2 = GetModel(conn, trans, model.parent_id); //带事务
                            model.class_list  = model2.class_list + model.id + ",";
                            model.class_layer = model2.class_layer + 1;
                        }
                        else
                        {
                            model.class_list  = "," + model.id + ",";
                            model.class_layer = 1;
                        }


                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("update " + databaseprefix + "article_category set ");
                        strSql.Append("channel_id=@channel_id,");
                        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("is_page=@is_page,");
                        strSql.Append("is_lock=@is_lock,");
                        strSql.Append("site_id=@site_id");
                        strSql.Append(" where id=@id");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@channel_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),
                            new SqlParameter("@is_page",         SqlDbType.Int,        4),
                            new SqlParameter("@is_lock",         SqlDbType.Int,        4),
                            new SqlParameter("@site_id",         SqlDbType.Int,        4),
                            new SqlParameter("@id",              SqlDbType.Int, 4)
                        };
                        parameters[0].Value  = model.channel_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;
                        parameters[13].Value = model.is_page;
                        parameters[14].Value = model.is_lock;
                        parameters[15].Value = model.site_id;
                        parameters[16].Value = model.id;
                        DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters);

                        //首先判断菜单是否存在
                        object name = DbHelperSQL.GetSingle(conn, trans, "select top 1 name from [" + databaseprefix + "channel]  where id=" + model.channel_id); //带事务
                        if (null != name)
                        {
                            //自动分级
                            string parent_name = "channel_" + name.ToString() + "_category";
                            if (model.parent_id > 0)
                            {
                                parent_name += "_" + model.parent_id;
                            }
                            if (Convert.ToInt32(DbHelperSQL.GetSingle(conn, trans, "select count(*) as H from [" + databaseprefix + "navigation]  where name='" + "channel_" + name.ToString() + "_category_" + model.id + "'")) == 0)
                            {
                                new DAL.navigation(databaseprefix).Add(conn, trans, parent_name, "channel_" + name.ToString() + "_category_" + model.id, model.title, "", model.sort_id, model.channel_id, "Show", 1);
                            }
                            else
                            {
                                int parent_id = Convert.ToInt32(DbHelperSQL.GetSingle(conn, trans, "select top 1 id from [" + databaseprefix + "navigation]  where name='" + parent_name + "'"));
                                if (parent_id > 0)
                                {
                                    new DAL.navigation(databaseprefix).Update(conn, trans, parent_name = "channel_" + name.ToString() + "_category_" + model.id, parent_id, parent_name, model.title, model.sort_id);
                                }
                            }
                        }

                        //更新子节点
                        UpdateChilds(conn, trans, model.id);

                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #16
0
        /// <summary>
        /// 频道,即二级分类
        /// </summary>
        public void CategoryPage()
        {

            int parentId = MyCommFun.RequestInt("cid");
            this.Document.SetValue("parentid", parentId);//父级id
            BLL.article_category cateBll = new BLL.article_category();
            Model.article_category pCategory = cateBll.GetModel(parentId);
            if (pCategory == null)
            {
                return;
            }
            this.Document.SetValue("pcategory", pCategory);//父级分类基本信息
            //去二级分类
            IList<Model.article_category> categorylist = tDal.GetCategoryListByWid(wid, -1, parentId, 2);
            if (categorylist != null && categorylist.Count > 0)
            {
                Model.article_category cat = new Model.article_category();
                for (int i = 0; i < categorylist.Count; i++)
                {
                    cat = categorylist[i];
                    if (cat.hasSun)
                    {  //有子分类
                        cat.link_url = MyCommFun.urlAddOpenid("/category.aspx?wid=" + wid + "&cid=" + cat.id, openid);
                    }
                    else
                    {
                        if (cat.link_url == null || cat.link_url.Trim() == "")
                        {  //如果link_url为空,则直接调用本系统的信息
                            cat.link_url = MyCommFun.urlAddOpenid("/list.aspx?wid=" + wid + "&cid=" + cat.id, openid);

                        }
                        else
                        {
                            cat.link_url = MyCommFun.urlAddOpenid(cat.link_url, openid);
                        }
                    }

                }

                this.Document.SetValue("clist", categorylist);//二级分类列表
            }

        }
コード例 #17
0
ファイル: article_category.cs プロジェクト: hui3694/forcomp
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.article_category model, int role_id)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert into " + databaseprefix + "article_category(");
                        strSql.Append("channel_id,title,call_index,parent_id,class_list,class_layer,sort_id,link_url,img_url,content,seo_title,seo_keywords,seo_description,is_page,is_lock,site_id)");
                        strSql.Append(" values (");
                        strSql.Append("@channel_id,@title,@call_index,@parent_id,@class_list,@class_layer,@sort_id,@link_url,@img_url,@content,@seo_title,@seo_keywords,@seo_description,@is_page,@is_lock,@site_id)");
                        strSql.Append(";select @@IDENTITY");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@channel_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),
                            new SqlParameter("@is_page",         SqlDbType.Int,        4),
                            new SqlParameter("@is_lock",         SqlDbType.Int,        4),
                            new SqlParameter("@site_id",         SqlDbType.Int, 4)
                        };
                        parameters[0].Value  = model.channel_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;
                        parameters[13].Value = model.is_page;
                        parameters[14].Value = model.is_lock;
                        parameters[15].Value = model.site_id;

                        object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); //带事务
                        model.id = Convert.ToInt32(obj);

                        if (model.parent_id > 0)
                        {
                            Model.article_category model2 = GetModel(conn, trans, model.parent_id); //带事务
                            model.class_list  = model2.class_list + model.id + ",";
                            model.class_layer = model2.class_layer + 1;
                        }
                        else
                        {
                            model.class_list  = "," + model.id + ",";
                            model.class_layer = 1;
                        }

                        //添加权限菜单
                        object name = DbHelperSQL.GetSingle(conn, trans, "select top 1 name from [" + databaseprefix + "channel]  where id=" + model.channel_id); //带事务
                        if (null != name)
                        {
                            //自动分级
                            string parent_name = "channel_" + name.ToString() + "_category";
                            if (model.parent_id > 0)
                            {
                                parent_name += "_" + model.parent_id;
                            }
                            new DAL.navigation(databaseprefix).Add(conn, trans, parent_name, "channel_" + name.ToString() + "_category_" + model.id, model.title, "", model.sort_id, model.channel_id, "Show", 1);

                            if (role_id > 0)
                            {
                                Model.manager_role_value valModel = new Model.manager_role_value();
                                valModel.role_id     = role_id;
                                valModel.nav_name    = "channel_" + name.ToString() + "_category_" + model.id;
                                valModel.action_type = "Show";
                                new DAL.manager_role_value(databaseprefix).Add(valModel);
                            }
                        }

                        //修改节点列表和深度
                        DbHelperSQL.ExecuteSql(conn, trans, "update " + databaseprefix + "article_category set class_list='" + model.class_list + "', class_layer=" + model.class_layer + " where id=" + model.id); //带事务
                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(0);
                    }
                }
            }
            return(model.id);
        }
コード例 #18
0
        /// <summary>
        /// 得到一个对象实体(重载,带事务)
        /// </summary>
        public Model.article_category GetModel(SqlConnection conn, SqlTransaction trans, int id)
        {
            StringBuilder strSql = new StringBuilder();

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

            Model.article_category model = new Model.article_category();
            DataSet ds = DbHelperSQL.Query(conn, trans, 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]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "")
                {
                    model.title = ds.Tables[0].Rows[0]["title"].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]["parent_id"] != null && ds.Tables[0].Rows[0]["parent_id"].ToString() != "")
                {
                    model.parent_id = int.Parse(ds.Tables[0].Rows[0]["parent_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["class_list"] != null && ds.Tables[0].Rows[0]["class_list"].ToString() != "")
                {
                    model.class_list = ds.Tables[0].Rows[0]["class_list"].ToString();
                }
                if (ds.Tables[0].Rows[0]["class_layer"] != null && 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"] != 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]["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]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "")
                {
                    model.content = ds.Tables[0].Rows[0]["content"].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]["ico_url"] != null && ds.Tables[0].Rows[0]["ico_url"].ToString() != "")
                {
                    model.ico_url = ds.Tables[0].Rows[0]["ico_url"].ToString();
                }

                if (ds.Tables[0].Rows[0]["wid"] != null && ds.Tables[0].Rows[0]["wid"].ToString() != "")
                {
                    model.wid = int.Parse(ds.Tables[0].Rows[0]["wid"].ToString());
                }


                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #19
0
        /// <summary>
        /// 列表页面独有的数据
        /// </summary>
        public void ArticleClassPage()
        {
            int category_id = MyCommFun.RequestInt("cid");

            //--=====begin: 将这个列表(文章类别)的基本信息展示出来 ====--
            Model.article_category category = tDal.GetCategoryByWid(wid, category_id);
            this.Document.SetValue("category", category);

            this.Document.SetValue("fxTitle", category.title);
            this.Document.SetValue("fxDesc", category.content);
            this.Document.SetValue("fxPic", MyCommFun.ImgAddHttp(category.img_url));

            //--=====end: 将这个列表(文章类别)的基本信息展示出来 ====--

            Tag    orderByTag = this.Document.GetChildTagById("norderby");
            string orderby    = orderByTag.Attributes["value"].Value.ToString();

            Tag    pagesizeTag = this.Document.GetChildTagById("npagesize");
            string pagesizeStr = pagesizeTag.Attributes["value"].Value.ToString();

            int currPage    = 1;                              //当前页面
            int recordCount = 0;                              //总记录数
            int totPage     = 1;                              //总页数
            int pageSize    = MyCommFun.Str2Int(pagesizeStr); //每页的记录数

            if (pageSize <= 0)
            {
                pageSize = 10;
            }
            if (MyCommFun.RequestInt("page") > 0)
            {
                currPage = MyCommFun.RequestInt("page");
            }

            DataSet artlist = new DataSet();

            if (category_id != 0)
            {
                DAL.article artDal = new DAL.article();
                artlist = artDal.GetList("news", category_id, pageSize, currPage, "wid=" + wid, orderby, out recordCount);
                if (artlist != null && artlist.Tables.Count > 0 && artlist.Tables[0].Rows.Count > 0)
                {
                    DataRow dr;
                    for (int i = 0; i < artlist.Tables[0].Rows.Count; i++)
                    {
                        dr = artlist.Tables[0].Rows[i];
                        if (dr["link_url"] != null && dr["link_url"].ToString().Trim().Length > 0)
                        {
                            dr["link_url"] = MyCommFun.urlAddOpenid(dr["link_url"].ToString().Trim(), openid);
                        }
                        else
                        {
                            dr["link_url"] = MyCommFun.urlAddOpenid("detail.aspx?wid=" + wid + "&aid=" + dr["id"].ToString(), openid);
                        }
                        artlist.AcceptChanges();
                    }

                    totPage = recordCount / pageSize;
                    int yushu = recordCount % pageSize;
                    if (yushu > 0)
                    {
                        totPage += 1;
                    }
                    if (totPage < 1)
                    {
                        totPage = 1;
                    }
                }
                if (currPage > totPage)
                {
                    currPage = totPage;
                }
            }
            else
            {
                currPage    = 1;
                recordCount = 0;
                totPage     = 1;
            }
            this.Document.SetValue("totPage", totPage);   //总页数
            this.Document.SetValue("currPage", currPage); //当前页
            this.Document.SetValue("newslist", artlist);  //文章列表

            string beforePageStr = "";                    //上一页
            string nextPageStr   = "";                    //下一页
            string bgrey         = "c-p-grey";
            string ngrey         = "c-p-grey";

            if (currPage <= 1)
            {
                beforePageStr = "";
                bgrey         = "disabled";
            }
            else
            {
                beforePageStr = MyCommFun.ChangePageNum(MyCommFun.getTotalUrl(), (currPage - 1));
                beforePageStr = "href=\"" + beforePageStr + "\"";
                bgrey         = "";
            }

            if (currPage >= totPage)
            {
                nextPageStr = "";
                ngrey       = "disabled";
            }
            else
            {
                nextPageStr = MyCommFun.ChangePageNum(MyCommFun.getTotalUrl(), (currPage + 1));
                nextPageStr = "href=\"" + nextPageStr + "\"";
                ngrey       = "";
            }
            this.Document.SetValue("bpage", beforePageStr); //上一页
            this.Document.SetValue("npage", nextPageStr);   //下一页
            this.Document.SetValue("bgrey", bgrey);         //上一页灰色的样式
            this.Document.SetValue("ngrey", ngrey);         //下一页灰色的样式
        }
コード例 #20
0
 /// <summary>
 /// 获得所有分类+底部菜单(排除url为空的)
 /// </summary>
 /// <returns></returns>
 public IList<Model.article_category> getAllCateMenu()
 {
     IList<Model.article_category> category = getCategory();
     IList<Model.article_category> bmenulist = tDal.GetBottomMenuByWid(wid, -1, -1, -1);
     if (bmenulist != null && bmenulist.Count > 0)
     {
         Model.article_category cat = new Model.article_category();
         for (int i = 0; i < bmenulist.Count; i++)
         {
             cat = bmenulist[i];
             if (cat.link_url != null && cat.link_url.Trim() != "")
             {
                 cat.link_url = MyCommFun.urlAddOpenid(cat.link_url, openid);
                 category.Add(cat);
             }
         }
     }
     return category;
 }
コード例 #21
0
        /// <summary>
        /// 获得底部菜单
        /// </summary>
        /// <returns></returns>
        public IList<Model.article_category> getBottomMenu()
        {
            string openid = MyCommFun.RequestOpenid();

            Tag tag = this.Document.CurrentRenderingTag;
            var classlayer = tag.Attributes["classlayer"];
            var parentidObj = tag.Attributes["parentid"];
            int parentid = -1;
            if (parentidObj != null && MyCommFun.isNumber(parentidObj.Value.GetValue()))
            {
                parentid = MyCommFun.Obj2Int(parentidObj.Value.GetValue());
            }
            int class_layer = -1;
            if (classlayer != null && MyCommFun.isNumber(classlayer.Value.GetValue()))
            {
                class_layer = MyCommFun.Obj2Int(classlayer.Value.GetValue());
            }

            IList<Model.article_category> bmenulist = tDal.GetBottomMenuByWid(wid, -1, parentid, class_layer);

            if (bmenulist != null && bmenulist.Count > 0)
            {
                Model.article_category cat = new Model.article_category();
                for (int i = 0; i < bmenulist.Count; i++)
                {
                    cat = bmenulist[i];
                    if (cat.link_url == null || cat.link_url.Trim() == "" || isContainsNoOpenid_hz(cat.link_url))
                    {
                    }
                    else
                    {
                        cat.link_url = MyCommFun.urlAddOpenid(cat.link_url, openid);
                    }
                }
            }


            return bmenulist;
        }
コード例 #22
0
        /// <summary>
        /// 获得wid的用户分类信息 
        /// </summary>
        /// <returns></returns>
        public IList<Model.article_category> getCategory()
        {
            Tag tag = this.Document.CurrentRenderingTag;

            ///classlayer表示取类别深度,如果为-1,则取所有分类的深度,如果为1,则取第一层目录,如果为2,则去第2层目录
            var classlayer = tag.Attributes["classlayer"];
            var parentidObj = tag.Attributes["parentid"];
            int parentid = -1;
            if (parentidObj != null && MyCommFun.isNumber(parentidObj.Value.GetValue()))
            {
                parentid = MyCommFun.Obj2Int(parentidObj.Value.GetValue());
            }
            int class_layer = -1;
            if (classlayer != null && MyCommFun.isNumber(classlayer.Value.GetValue()))
            {
                class_layer = MyCommFun.Obj2Int(classlayer.Value.GetValue());
            }

            IList<Model.article_category> categorylist = tDal.GetCategoryListByWid(wid, -1, parentid, class_layer);
            if (categorylist != null && categorylist.Count > 0)
            {
                Model.article_category cat = new Model.article_category();
                for (int i = 0; i < categorylist.Count; i++)
                {
                    cat = categorylist[i];
                    if (cat.hasSun)
                    {  //有子分类
                        cat.link_url = MyCommFun.urlAddOpenid("/category.aspx?wid=" + wid + "&cid=" + cat.id, openid);
                    }
                    else
                    {
                        if (cat.link_url == null || cat.link_url.Trim() == "")
                        {  //如果link_url为空,则直接调用本系统的信息
                            cat.link_url = MyCommFun.urlAddOpenid("/list.aspx?wid=" + wid + "&cid=" + cat.id, openid);

                        }
                        else if (!isContainsNoOpenid_hz(cat.link_url))
                        {
                            cat.link_url = MyCommFun.urlAddOpenid(cat.link_url, openid);
                        }
                    }
                }
            }

            return categorylist;
        }
コード例 #23
0
        private bool DoAdd()
        {
            try
            {
                Model.article_category model = new Model.article_category();
                BLL.article_category bll = new BLL.article_category();
                model.channel_id = this.channel_id;
                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;
                model.ico_url = Request.Form["txtImgICO"].Trim();// txtImgICO.Text;
                Model.wx_userweixin weixin = GetWeiXinCode();
                model.wid = weixin.id;

                if (bll.Add(model) > 0)
                {
                    AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加" + this.channel_name + "微网站分类:" + model.title); //记录日志
                    return true;
                }
            }
            catch
            {
                return false;
            }
            return false;
        }
コード例 #24
0
        /// <summary>
        /// 列表页面独有的数据
        /// </summary>
        public void ArticleClassPage()
        {
            int category_id = 0;
            int channel_id  = 0;

            category_id = MyCommFun.RequestInt("cid");

            if (category_id == 0)
            {
                var categoryid = this.Document.GetChildTagById("categoryid");
                category_id = MyCommFun.Obj2Int(categoryid.Attributes["value"].Value.ToString());
            }
            var channelid = this.Document.GetChildTagById("channel_id");

            channel_id = MyCommFun.Obj2Int(channelid.Attributes["value"].Value.ToString());


            //--=====begin: 将这个列表(文章类别)的基本信息展示出来 ====--
            DAL.article_category   cateDal  = new DAL.article_category("dt_");
            Model.article_category category = cateDal.GetModel(category_id);
            this.Document.SetValue("category", category);
            //--=====end: 将这个列表(文章类别)的基本信息展示出来 ====--

            Tag    orderByTag = this.Document.GetChildTagById("norderby");
            string orderby    = orderByTag.Attributes["value"].Value.ToString();

            Tag    pagesizeTag = this.Document.GetChildTagById("npagesize");
            string pagesizeStr = pagesizeTag.Attributes["value"].Value.ToString();

            int currPage    = 1;                              //当前页面
            int recordCount = 0;                              //总记录数
            int totPage     = 1;                              //总页数
            int pageSize    = MyCommFun.Str2Int(pagesizeStr); //每页的记录数

            if (pageSize <= 0)
            {
                pageSize = 10;
            }
            if (MyCommFun.RequestInt("page") > 0)
            {
                currPage = MyCommFun.RequestInt("page");
            }

            DataSet artlist = new DataSet();

            if (category_id != 0)
            {
                DAL.article artDal = new DAL.article();
                artlist = artDal.GetList("hotnews", category_id, pageSize, currPage, "channel_id=" + channel_id, orderby, out recordCount);
                if (artlist != null && artlist.Tables.Count > 0 && artlist.Tables[0].Rows.Count > 0)
                {
                    DataRow dr;
                    for (int i = 0; i < artlist.Tables[0].Rows.Count; i++)
                    {
                        dr = artlist.Tables[0].Rows[i];
                        if (dr["link_url"] == null || dr["link_url"].ToString().Trim().Length <= 0)
                        {
                            dr["link_url"] = "/portalpage/weixin_news_detail.aspx?id=" + dr["id"].ToString();
                        }

                        artlist.AcceptChanges();
                    }

                    totPage = recordCount / pageSize;
                    int yushu = recordCount % pageSize;
                    if (yushu > 0)
                    {
                        totPage += 1;
                    }
                    if (totPage < 1)
                    {
                        totPage = 1;
                    }
                }
                if (currPage > totPage)
                {
                    currPage = totPage;
                }
            }
            else
            {
                currPage    = 1;
                recordCount = 0;
                totPage     = 1;
            }
            this.Document.SetValue("totPage", totPage);   //总页数
            this.Document.SetValue("currPage", currPage); //当前页
            this.Document.SetValue("newslist", artlist);  //文章列表

            string beforePageStr = "";                    //上一页
            string nextPageStr   = "";                    //下一页
            string bgrey         = "c-p-grey";
            string ngrey         = "c-p-grey";

            if (currPage <= 1)
            {
                beforePageStr = "javascript:;";
                bgrey         = "c-p-grey";
            }
            else
            {
                beforePageStr = MyCommFun.ChangePageNum(MyCommFun.getTotalUrl(), (currPage - 1));
                beforePageStr = "href=\"" + beforePageStr + "\"";
                bgrey         = "";
            }

            if (currPage >= totPage)
            {
                nextPageStr = "javascript:;";
                ngrey       = " c-p-grey";
            }
            else
            {
                nextPageStr = MyCommFun.ChangePageNum(MyCommFun.getTotalUrl(), (currPage + 1));
                nextPageStr = "href=\"" + nextPageStr + "\"";
                ngrey       = "";
            }
            this.Document.SetValue("bpage", beforePageStr); //上一页
            this.Document.SetValue("npage", nextPageStr);   //下一页
            this.Document.SetValue("bgrey", bgrey);         //上一页灰色的样式
            this.Document.SetValue("ngrey", ngrey);         //下一页灰色的样式
        }
コード例 #25
0
 private void GetAboutModel()
 {
     BLL.article_category bll = new BLL.article_category();
     modelabout = bll.GetModel(107);
 }
コード例 #26
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.article_category model)
 {
     return(dal.Update(model));
 }
コード例 #27
0
ファイル: article_category.cs プロジェクト: ForkByOther/DTCMS
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.article_category model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        //先判断选中的父节点是否被包含
                        if (IsContainNode(model.id, model.parent_id))
                        {
                            //查找旧数据
                            Model.article_category oldModel = GetModel(model.id);
                            //查找旧父节点数据
                            string class_list  = "," + model.parent_id + ",";
                            int    class_layer = 1;
                            if (oldModel.parent_id > 0)
                            {
                                Model.article_category oldParentModel = GetModel(conn, trans, oldModel.parent_id); //带事务
                                class_list  = oldParentModel.class_list + model.parent_id + ",";
                                class_layer = oldParentModel.class_layer + 1;
                            }
                            //先提升选中的父节点
                            DbHelperSQL.ExecuteSql(conn, trans, "update " + databaseprefix + "article_category set parent_id=" + oldModel.parent_id + ",class_list='" + class_list + "', class_layer=" + class_layer + " where id=" + model.parent_id); //带事务
                            UpdateChilds(conn, trans, model.parent_id);                                                                                                                                                                                 //带事务
                        }
                        //更新子节点
                        if (model.parent_id > 0)
                        {
                            Model.article_category model2 = GetModel(conn, trans, model.parent_id); //带事务
                            model.class_list  = model2.class_list + model.id + ",";
                            model.class_layer = model2.class_layer + 1;
                        }
                        else
                        {
                            model.class_list  = "," + model.id + ",";
                            model.class_layer = 1;
                        }


                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("update " + databaseprefix + "article_category set ");
                        strSql.Append("channel_id=@channel_id,");
                        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("@channel_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),
                            new SqlParameter("@id",              SqlDbType.Int, 4)
                        };
                        parameters[0].Value  = model.channel_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;
                        parameters[13].Value = model.id;
                        DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters);

                        //更新子节点
                        UpdateChilds(conn, trans, model.id);
                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #28
0
ファイル: templatesDal.cs プロジェクト: yidane/51wine
        /// <summary>
        /// 获得微帐号的分类信息
        /// </summary>
        /// <param name="wid"></param>
        /// <param name="topNum">取前几条数据;若为-1,则不作筛选条件</param>
        /// <param name="parentId">若为-1,则不作筛选条件</param>
        /// <returns></returns>
        public IList <Model.article_category> GetCategoryListByWid(int wid, int topNum, int parentId, int class_layer)
        {
            IList <Model.article_category> categoryList = new List <Model.article_category>();

            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ");
            if (topNum >= 0)
            {
                strSql.Append(" top " + topNum + " ");
            }
            strSql.Append(" (select count(1) from dt_article_category sc where c.id=sc.parent_id) hasSun,id,title,call_index,parent_id,class_layer,link_url,img_url,[content],ico_url,seo_title,seo_keywords,seo_description from dt_article_category c where channel_id=1 ");
            if (parentId != -1)
            {
                strSql.Append(" and parent_id=" + parentId);
            }
            if (class_layer != -1)
            {
                strSql.Append(" and class_layer=" + class_layer);
            }

            strSql.Append(" and wId=@wId and cStatus=1 order by sort_id asc,id desc");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wId", SqlDbType.Int, 4)
            };
            parameters[0].Value = wid;
            SqlDataReader sr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters);

            Model.article_category category = new Model.article_category();
            while (sr.Read())
            {
                category                 = new Model.article_category();
                category.id              = MyCommFun.Obj2Int(sr["id"]);
                category.title           = MyCommFun.ObjToStr(sr["title"]);
                category.call_index      = MyCommFun.ObjToStr(sr["call_index"]);
                category.parent_id       = MyCommFun.Obj2Int(sr["parent_id"]);
                category.class_layer     = MyCommFun.Obj2Int(sr["class_layer"]);
                category.link_url        = MyCommFun.ObjToStr(sr["link_url"]);
                category.img_url         = MyCommFun.ObjToStr(sr["img_url"]);
                category.content         = MyCommFun.ObjToStr(sr["content"]);
                category.ico_url         = MyCommFun.ObjToStr(sr["ico_url"]);
                category.seo_title       = MyCommFun.ObjToStr(sr["seo_title"]);
                category.seo_keywords    = MyCommFun.ObjToStr(sr["seo_keywords"]);
                category.seo_description = MyCommFun.ObjToStr(sr["seo_description"]);
                if (sr["hasSun"].ToString() == "0")
                {//无子分类
                    category.hasSun = false;
                }
                else
                {  //有子类
                    category.hasSun = true;
                }
                categoryList.Add(category);
            }
            sr.Close();



            return(categoryList);
        }
コード例 #29
0
ファイル: article_category.cs プロジェクト: ForkByOther/DTCMS
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.article_category model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert into " + databaseprefix + "article_category(");
                        strSql.Append("channel_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(" values (");
                        strSql.Append("@channel_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(";select @@IDENTITY");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@channel_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.channel_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;

                        object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); //带事务
                        model.id = Convert.ToInt32(obj);

                        if (model.parent_id > 0)
                        {
                            Model.article_category model2 = GetModel(conn, trans, model.parent_id); //带事务
                            model.class_list  = model2.class_list + model.id + ",";
                            model.class_layer = model2.class_layer + 1;
                        }
                        else
                        {
                            model.class_list  = "," + model.id + ",";
                            model.class_layer = 1;
                        }
                        //修改节点列表和深度
                        DbHelperSQL.ExecuteSql(conn, trans, "update " + databaseprefix + "article_category set class_list='" + model.class_list + "', class_layer=" + model.class_layer + " where id=" + model.id); //带事务
                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(0);
                    }
                }
            }
            return(model.id);
        }
コード例 #30
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.article_category model)
 {
     return(dal.Add(model));
 }
コード例 #31
0
        /// <summary>
        /// 验证频道列表数据
        /// </summary>
        /// <param name="channel_name"></param>
        public void validate_channel_data(string channel_name)
        {
            this.channel = channel_name;
            channelModel = new BLL.site_channel().GetModel(channel_name);
            if (null != channelModel && !channelModel.name.Equals(channel_name))
            {
                Response.Redirect(linkurl("error"));
                return;
            }

            BLL.article bll = new BLL.article();
            if (id > 0) //如果ID获取到,将使用ID
            {
                if (!bll.ArticleExists(channel, id))
                {
                    Response.Redirect(linkurl("error"));
                    return;
                }
                model = bll.ArticleModel(channel, id);
            }
            else if (!string.IsNullOrEmpty(call_index)) //否则检查设置的别名
            {
                if (!bll.ArticleExists(channel, call_index))
                {
                    Response.Redirect(linkurl("error"));
                    return;
                }
                model = bll.ArticleModel(channel, call_index);
                //赋值文章ID
                id = model.id;
            }
            else
            {
                Response.Redirect(linkurl("error"));
                return;
            }
            if (model.status == 1)
            {
                Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("浏览得该信息审核还未通过!")));
                return;
            }
            //判断是否是链接
            if (!string.IsNullOrEmpty(model.link_url))
            {
                Response.Redirect(model.link_url);
                return;
            }
            //判断SEO标题
            if (string.IsNullOrEmpty(model.seo_title))
            {
                model.seo_title = site.seo_title;
            }
            if (string.IsNullOrEmpty(model.seo_keywords))
            {
                model.seo_keywords = site.seo_keywords;
            }
            if (string.IsNullOrEmpty(model.seo_description))
            {
                model.seo_description = site.seo_description;
            }
            //获取频道内容
            channelModel = new BLL.site_channel().GetModel(model.channel_id);

            //获取类别内容
            categoryModel = new BLL.article_category().GetModel(model.category_id);

            ViewBag.model = model;
        }
コード例 #32
0
ファイル: article_category.cs プロジェクト: yi724926089/MyWx
        /// <summary>
        /// 得到一个对象实体(重载,带事务)
        /// </summary>
        public Model.article_category GetModel(SqlConnection conn, SqlTransaction trans, int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,channel_id,title,call_index,parent_id,class_list,class_layer,sort_id,link_url,img_url,content,seo_title,seo_keywords,seo_description,ico_url,wid from " + databaseprefix + "article_category ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            Model.article_category model = new Model.article_category();
            DataSet ds = DbHelperSQL.Query(conn, trans, 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]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "")
                {
                    model.title = ds.Tables[0].Rows[0]["title"].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]["parent_id"] != null && ds.Tables[0].Rows[0]["parent_id"].ToString() != "")
                {
                    model.parent_id = int.Parse(ds.Tables[0].Rows[0]["parent_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["class_list"] != null && ds.Tables[0].Rows[0]["class_list"].ToString() != "")
                {
                    model.class_list = ds.Tables[0].Rows[0]["class_list"].ToString();
                }
                if (ds.Tables[0].Rows[0]["class_layer"] != null && 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"] != 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]["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]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "")
                {
                    model.content = ds.Tables[0].Rows[0]["content"].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]["ico_url"] != null && ds.Tables[0].Rows[0]["ico_url"].ToString() != "")
                {
                    model.ico_url = ds.Tables[0].Rows[0]["ico_url"].ToString();
                }

                if (ds.Tables[0].Rows[0]["wid"] != null && ds.Tables[0].Rows[0]["wid"].ToString() != "")
                {
                    model.wid = int.Parse(ds.Tables[0].Rows[0]["wid"].ToString());
                }

                return model;
            }
            else
            {
                return null;
            }
        }
コード例 #33
0
        /// <summary>
        /// 获得该分类信息,使用wid仅仅作为限制条件
        /// </summary>
        /// <param name="wid"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public Model.article_category GetCategoryByWid(int wid, int id)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1");
            strSql.Append(" id,title,call_index,parent_id,class_layer,link_url,img_url,[content],ico_url,seo_title,seo_keywords,seo_description  ");
            strSql.Append(" from dt_article_category  where   id=@id  and wId=@wId");
            SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4),
                    new SqlParameter("@wId", SqlDbType.Int,4)
			};
            parameters[0].Value = id;
            parameters[1].Value = wid;
            SqlDataReader sr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters);
            Model.article_category category = new Model.article_category();
            while (sr.Read())
            {
                category = new Model.article_category();
                category.id = MyCommFun.Obj2Int(sr["id"]);
                category.title = MyCommFun.ObjToStr(sr["title"]);
                category.call_index = MyCommFun.ObjToStr(sr["call_index"]);
                category.parent_id = MyCommFun.Obj2Int(sr["parent_id"]);
                category.class_layer = MyCommFun.Obj2Int(sr["class_layer"]);
                category.link_url = MyCommFun.ObjToStr(sr["link_url"]);
                category.img_url = MyCommFun.ObjToStr(sr["img_url"]);
                category.content = MyCommFun.ObjToStr(sr["content"]);
                category.ico_url = MyCommFun.ObjToStr(sr["ico_url"]);
                category.seo_title = MyCommFun.ObjToStr(sr["seo_title"]);
                category.seo_keywords = MyCommFun.ObjToStr(sr["seo_keywords"]);
                category.seo_description = MyCommFun.ObjToStr(sr["seo_description"]);
            }
            sr.Close();
            return category;
        }
コード例 #34
0
ファイル: article_category.cs プロジェクト: ForkByOther/DTCMS
 /// <summary>
 /// 将对象转换为实体
 /// </summary>
 public Model.article_category DataRowToModel(DataRow row)
 {
     Model.article_category model = new Model.article_category();
     if (row != null)
     {
         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["title"] != null)
         {
             model.title = row["title"].ToString();
         }
         if (row["call_index"] != null)
         {
             model.call_index = row["call_index"].ToString();
         }
         if (row["parent_id"] != null && row["parent_id"].ToString() != "")
         {
             model.parent_id = int.Parse(row["parent_id"].ToString());
         }
         if (row["class_list"] != null)
         {
             model.class_list = row["class_list"].ToString();
         }
         if (row["class_layer"] != null && row["class_layer"].ToString() != "")
         {
             model.class_layer = int.Parse(row["class_layer"].ToString());
         }
         if (row["sort_id"] != null && row["sort_id"].ToString() != "")
         {
             model.sort_id = int.Parse(row["sort_id"].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["content"] != null)
         {
             model.content = row["content"].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();
         }
     }
     return(model);
 }
コード例 #35
0
 private bool DoAdd()
 {
     try
     {
         Model.article_category model = new Model.article_category();
         BLL.article_category bll = new BLL.article_category();
         model.channel_id = this.channel_id;
         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(), "添加" + this.channel_name + "频道栏目分类:" + model.title); //记录日志
             return true;
         }
     }
     catch
     {
         return false;
     }
     return false;
 }
コード例 #36
0
ファイル: partner.aspx.cs プロジェクト: harryluo163/netcms
 private void GetModel()
 {
     BLL.article_category bll = new BLL.article_category();
     model = bll.GetModel(category_id);
 }
コード例 #37
0
ファイル: article_category.cs プロジェクト: zhanglg40/SANKE
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.article_category model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        //先判断选中的父节点是否被包含
                        if (IsContainNode(model.id, model.parent_id))
                        {
                            //查找旧数据
                            Model.article_category oldModel = GetModel(model.id);
                            //查找旧父节点数据
                            string class_list  = "," + model.parent_id + ",";
                            int    class_layer = 1;
                            if (oldModel.parent_id > 0)
                            {
                                Model.article_category oldParentModel = GetModel(conn, trans, oldModel.parent_id); //带事务
                                class_list  = oldParentModel.class_list + model.parent_id + ",";
                                class_layer = oldParentModel.class_layer + 1;
                            }
                            //先提升选中的父节点
                            DbHelperSQL.ExecuteSql(conn, trans, "update " + databaseprefix + "article_category set parent_id=" + oldModel.parent_id + ",class_list='" + class_list + "', class_layer=" + class_layer + " where id=" + model.parent_id); //带事务
                            UpdateChilds(conn, trans, model.parent_id);                                                                                                                                                                                 //带事务
                        }
                        //更新子节点
                        if (model.parent_id > 0)
                        {
                            Model.article_category model2 = GetModel(conn, trans, model.parent_id); //带事务
                            model.class_list  = model2.class_list + model.id + ",";
                            model.class_layer = model2.class_layer + 1;
                        }
                        else
                        {
                            model.class_list  = "," + model.id + ",";
                            model.class_layer = 1;
                        }


                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("update " + databaseprefix + "article_category set ");
                        strSql.Append("class_no=@class_no,");
                        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("class_type=@class_type,");
                        strSql.Append("remark=@remark,");
                        strSql.Append("seo_description=@seo_description");
                        strSql.Append(" where id=@id");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@class_no",        SqlDbType.NVarChar, 100),
                            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("@class_type",      SqlDbType.NVarChar,   5),
                            new SqlParameter("@remark",          SqlDbType.NVarChar, 500),

                            new SqlParameter("@seo_description", SqlDbType.NVarChar, 255),
                            new SqlParameter("@id",              SqlDbType.Int, 4)
                        };
                        parameters[0].Value  = model.class_no;
                        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.class_type;
                        parameters[13].Value = model.remark;
                        parameters[14].Value = model.seo_description;
                        parameters[15].Value = model.id;
                        DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters);


                        //添加自定义图片尺寸
                        if (model.imagesize_values != null)
                        {
                            //删除已删除的图片
                            new article_images_size(databaseprefix).DeleteList(conn, trans, model.imagesize_values, model.id);
                            StringBuilder strSqlimage;
                            foreach (Model.article_images_size modelimagesize in model.imagesize_values)
                            {
                                strSqlimage = new StringBuilder();
                                if (modelimagesize.id > 0)
                                {
                                    strSqlimage.Append("update ax_article_images_size set ");
                                    strSqlimage.Append("category_id=@category_id,");
                                    strSqlimage.Append("height=@height,");
                                    strSqlimage.Append("width=@width");
                                    strSqlimage.Append(" where id=@id");
                                    SqlParameter[] parametersimages =
                                    {
                                        new SqlParameter("@category_id", SqlDbType.Int,       4),
                                        new SqlParameter("@height",      SqlDbType.NVarChar, 50),
                                        new SqlParameter("@width",       SqlDbType.NVarChar, 50),
                                        new SqlParameter("@id",          SqlDbType.Int, 4)
                                    };
                                    parametersimages[0].Value = model.id;
                                    parametersimages[1].Value = modelimagesize.height;
                                    parametersimages[2].Value = modelimagesize.width;
                                    parametersimages[3].Value = model.id;
                                    DbHelperSQL.ExecuteSql(conn, trans, strSqlimage.ToString(), parametersimages);
                                }
                                else
                                {
                                    strSqlimage.Append("insert into " + databaseprefix + "article_images_size(");
                                    strSqlimage.Append("category_id,height,width)");
                                    strSqlimage.Append(" values (");
                                    strSqlimage.Append("@category_id,@height,@width)");
                                    SqlParameter[] parametersimages =
                                    {
                                        new SqlParameter("@category_id", SqlDbType.Int,       4),
                                        new SqlParameter("@height",      SqlDbType.NVarChar, 50),
                                        new SqlParameter("@width",       SqlDbType.NVarChar, 50)
                                    };
                                    parametersimages[0].Value = model.id;
                                    parametersimages[1].Value = modelimagesize.height;
                                    parametersimages[2].Value = modelimagesize.width;
                                    DbHelperSQL.ExecuteSql(conn, trans, strSqlimage.ToString(), parametersimages);
                                }
                            }
                        }


                        //更新子节点
                        UpdateChilds(conn, trans, model.id);
                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #38
0
ファイル: article_category.cs プロジェクト: wslyzhh/kuaisitu
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.article_category model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        #region 主表信息===========================
                        StringBuilder strSql = new StringBuilder();
                        StringBuilder str1   = new StringBuilder(); //数据字段
                        StringBuilder str2   = new StringBuilder(); //数据参数
                        //利用反射获得属性的所有公共属性
                        PropertyInfo[]      pros  = model.GetType().GetProperties();
                        List <SqlParameter> paras = new List <SqlParameter>();
                        strSql.Append("insert into  " + databaseprefix + "article_category(");
                        foreach (PropertyInfo pi in pros)
                        {
                            //如果不是主键及List<T>则追加sql字符串
                            if (!pi.Name.Equals("id") && !typeof(System.Collections.IList).IsAssignableFrom(pi.PropertyType))
                            {
                                //判断属性值是否为空
                                if (pi.GetValue(model, null) != null && !pi.GetValue(model, null).ToString().Equals(""))
                                {
                                    str1.Append(pi.Name + ",");                                           //拼接字段
                                    str2.Append("@" + pi.Name + ",");                                     //声明参数
                                    paras.Add(new SqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值
                                }
                            }
                        }
                        strSql.Append(str1.ToString().Trim(','));
                        strSql.Append(") values (");
                        strSql.Append(str2.ToString().Trim(','));
                        strSql.Append(") ");
                        strSql.Append(";select @@IDENTITY;");
                        object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), paras.ToArray());
                        model.id = Convert.ToInt32(obj);
                        //查询父节点的深度赋值
                        if (model.parent_id > 0)
                        {
                            Model.article_category model2 = GetModel(conn, trans, model.parent_id);
                            model.class_list  = model2.class_list + model.id + ",";
                            model.class_layer = model2.class_layer + 1;
                        }
                        else
                        {
                            model.class_list  = "," + model.id + ",";
                            model.class_layer = 1;
                        }
                        //修改节点列表和深度
                        DbHelperSQL.ExecuteSql(conn, trans, "update " + databaseprefix + "article_category set class_list='" + model.class_list + "', class_layer=" + model.class_layer + " where id=" + model.id);
                        #endregion

                        #region 栏目规格===========================
                        if (model.category_specs != null)
                        {
                            StringBuilder strSql3;
                            foreach (Model.article_category_spec modelt in model.category_specs)
                            {
                                strSql3 = new StringBuilder();
                                strSql3.Append("insert into " + databaseprefix + "article_category_spec(");
                                strSql3.Append("category_id,spec_id)");
                                strSql3.Append(" values (");
                                strSql3.Append("@category_id,@spec_id)");
                                SqlParameter[] parameters3 =
                                {
                                    new SqlParameter("@category_id", SqlDbType.Int, 4),
                                    new SqlParameter("@spec_id",     SqlDbType.Int, 4)
                                };
                                parameters3[0].Value = model.id;//刚插入的ID
                                parameters3[1].Value = modelt.spec_id;
                                DbHelperSQL.ExecuteSql(conn, trans, strSql3.ToString(), parameters3);
                            }
                        }
                        #endregion

                        trans.Commit();//提交事务
                    }
                    catch
                    {
                        trans.Rollback();//回滚事务
                        return(0);
                    }
                }
            }
            return(model.id);
        }
コード例 #39
0
ファイル: article_category.cs プロジェクト: rockhe168/CMS
 /// <summary>
 /// 将对象转换为实体
 /// </summary>
 public Model.article_category DataRowToModel(DataRow row)
 {
     Model.article_category model = new Model.article_category();
     if (row != null)
     {
         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["title"] != null)
         {
             model.title = row["title"].ToString();
         }
         if (row["call_index"] != null)
         {
             model.call_index = row["call_index"].ToString();
         }
         if (row["parent_id"] != null && row["parent_id"].ToString() != "")
         {
             model.parent_id = int.Parse(row["parent_id"].ToString());
         }
         if (row["class_list"] != null)
         {
             model.class_list = row["class_list"].ToString();
         }
         if (row["class_layer"] != null && row["class_layer"].ToString() != "")
         {
             model.class_layer = int.Parse(row["class_layer"].ToString());
         }
         if (row["sort_id"] != null && row["sort_id"].ToString() != "")
         {
             model.sort_id = int.Parse(row["sort_id"].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["content"] != null)
         {
             model.content = row["content"].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();
         }
     }
     return model;
 }