Example #1
0
        private void ShowInfo(int _id)
        {
            BLL.wx_shop_category   bll   = new BLL.wx_shop_category();
            Model.wx_shop_category model = bll.GetModel(_id);

            ddlParentId.SelectedValue = model.parent_id.ToString();

            txtTitle.Text          = model.title;
            txtSortId.Text         = model.sort_id.ToString();
            txtSeoTitle.Text       = model.seo_title;
            txtSeoKeywords.Text    = model.seo_keywords;
            txtSeoDescription.Text = model.seo_description;
            txtLinkUrl.Text        = model.link_url;
            txtImgUrl.Text         = model.img_url;
            if (model.img_url != null && model.img_url.Trim() != "")
            {
                // imgUrl.ImageUrl = model.img_url;
            }
            txtContent.Text = model.class_content;
            txtImgICO.Text  = model.ico_url;
            if (model.ico_url != null && model.ico_url.Trim() != "")
            {
                if (model.ico_url.Contains("/"))
                {
                    imgIco.ImageUrl = model.ico_url;
                }
                else
                {
                    imgIco.Style.Add("display", "none");
                    litImgIco.Text = "<span class=\"" + model.ico_url + "\"></span>";
                }
            }
        }
Example #2
0
        private bool DoEdit(int _id)
        {
            try
            {
                BLL.wx_shop_category   bll   = new BLL.wx_shop_category();
                Model.wx_shop_category model = bll.GetModel(_id);

                int parentId = int.Parse(ddlParentId.SelectedValue);

                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.class_content   = txtContent.Text.Trim();
                model.ico_url         = Request.Form["txtImgICO"].Trim();// txtImgICO.Text;
                if (bll.Update(model))
                {
                    AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "修改商品目分类:" + model.title); //记录日志
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
            return(false);
        }
Example #3
0
        /// <summary>
        /// 获得该分类信息,使用wid仅仅作为限制条件
        /// </summary>
        /// <param name="wid"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public Model.wx_shop_category GetCategoryByWid(int wid, int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1");
            strSql.Append(" id,title,code,parent_id,class_list,class_layer,sort_id,link_url,img_url,class_content,remark,seo_title,seo_keywords,seo_description,wid,ico_url  ");
            strSql.Append(" from wx_shop_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.wx_shop_category category = new Model.wx_shop_category();
            while (sr.Read())
            {
                category                 = new Model.wx_shop_category();
                category.id              = MyCommFun.Obj2Int(sr["id"]);
                category.title           = MyCommFun.ObjToStr(sr["title"]);
                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.class_content   = MyCommFun.ObjToStr(sr["class_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);
        }
Example #4
0
        private bool DoAdd()
        {
            try
            {
                Model.wx_shop_category model = new Model.wx_shop_category();
                BLL.wx_shop_category   bll   = new BLL.wx_shop_category();


                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.class_content   = txtContent.Text.Trim();
                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(), "添加商品分类:" + model.title); //记录日志
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
            return(false);
        }
Example #5
0
        /// <summary>
        /// 商品列表
        /// </summary>
        public void ProductCategoryList()
        {
            int category_id = MyCommFun.RequestInt("cid");

            //--=====begin: 将这个列表(文章类别)的基本信息展示出来 ====--
            DAL.wx_shop_category   cateBll  = new DAL.wx_shop_category();
            Model.wx_shop_category category = cateBll.GetCategoryByWid(wid, category_id);
            this.Document.SetValue("category", category);
            this.Document.SetValue("wid", wid);
            //--=====end: 将这个列表(文章类别)的基本信息展示出来 ====--
        }
Example #6
0
        /// <summary>
        /// 获得wid的用户分类信息
        /// </summary>
        /// <returns></returns>
        public IList <Model.wx_shop_category> getCategory()
        {
            Tag tag = this.Document.CurrentRenderingTag;

            ///classlayer表示取类别深度,如果为-1,则取所有分类的深度,如果为1,则取第一层目录,如果为2,则去第2层目录
            var classlayer  = tag.Attributes["classlayer"];
            var parentidObj = tag.Attributes["parentid"];
            var attribute   = tag.Attributes["rows"];
            int rows        = -1;//若为-1,则不做限制条件
            IList <Model.wx_shop_category> categorylist = null;
            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());
            }
            DAL.wx_shop_category cateBll = new DAL.wx_shop_category();
            if (attribute != null && MyCommFun.isNumber(attribute.Value.GetValue()))
            {
                rows         = MyCommFun.Obj2Int(attribute.Value.GetValue());
                categorylist = cateBll.GetCategoryListByWid(wid, rows, parentid, class_layer);
            }
            else
            {
                categorylist = cateBll.GetCategoryListByWid(wid, -1, parentid, class_layer);
            }
            if (categorylist != null && categorylist.Count > 0)
            {
                Model.wx_shop_category cat = new Model.wx_shop_category();

                for (int i = 0; i < categorylist.Count; i++)
                {
                    cat = categorylist[i];
                    if (cat.link_url == null || cat.link_url.Trim() == "")
                    {  //如果link_url为空,则直接调用本系统的信息
                        cat.link_url = MyCommFun.urlAddOpenid("/shop/list.aspx?wid=" + wid + "&cid=" + cat.id + "", openid);
                    }
                    else
                    {
                        cat.link_url = MyCommFun.urlAddOpenid(cat.link_url, openid);
                    }
                }
            }

            return(categorylist);
        }
Example #7
0
        /// <summary>
        /// 获得微帐号的分类信息
        /// </summary>
        /// <param name="wid"></param>
        /// <param name="topNum">取前几条数据;若为-1,则不作筛选条件</param>
        /// <param name="parentId">若为-1,则不作筛选条件</param>
        /// <returns></returns>
        public IList <Model.wx_shop_category> GetCategoryListByWid(int wid, int topNum, int parentId, int class_layer)
        {
            IList <Model.wx_shop_category> categoryList = new List <Model.wx_shop_category>();

            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ");
            if (topNum >= 0)
            {
                strSql.Append(" top " + topNum + " ");
            }
            strSql.Append(" id,title,code,parent_id,class_list,class_layer,sort_id,link_url,img_url,class_content,remark,seo_title,seo_keywords,seo_description,wid,ico_url from wx_shop_category   where 1=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 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.wx_shop_category category = new Model.wx_shop_category();
            while (sr.Read())
            {
                category                 = new Model.wx_shop_category();
                category.id              = MyCommFun.Obj2Int(sr["id"]);
                category.title           = MyCommFun.ObjToStr(sr["title"]);
                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.class_content   = MyCommFun.ObjToStr(sr["class_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"]);
                categoryList.Add(category);
            }
            sr.Close();



            return(categoryList);
        }
Example #8
0
        /// <summary>
        /// 修改子节点的ID列表及深度(自身迭代)
        /// </summary>
        /// <param name="parent_id"></param>
        private void UpdateChilds(SqlConnection conn, SqlTransaction trans, int parent_id)
        {
            //查找父节点信息
            Model.wx_shop_category model = GetModel(conn, trans, parent_id);
            if (model != null)
            {
                //查找子节点
                string  strSql = "select id from wx_shop_category where parent_id=" + parent_id;
                DataSet ds     = DbHelperSQL.Query(conn, trans, strSql); //带事务
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    //修改子节点的ID列表及深度
                    int    id          = int.Parse(dr["id"].ToString());
                    string class_list  = model.class_list + id + ",";
                    int    class_layer = model.class_layer.Value + 1;
                    DbHelperSQL.ExecuteSql(conn, trans, "update wx_shop_category set class_list='" + class_list + "', class_layer=" + class_layer + " where id=" + id); //带事务

                    //调用自身迭代
                    this.UpdateChilds(conn, trans, id); //带事务
                }
            }
        }
Example #9
0
        /// <summary>
        /// 得到一个对象实体(重载,带事务)
        /// </summary>
        public Model.wx_shop_category GetModel(SqlConnection conn, SqlTransaction trans, int id)
        {
            StringBuilder strSql = new StringBuilder();

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

            Model.wx_shop_category model = new Model.wx_shop_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]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "")
                {
                    model.title = ds.Tables[0].Rows[0]["title"].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]["class_content"] != null && ds.Tables[0].Rows[0]["class_content"].ToString() != "")
                {
                    model.class_content = ds.Tables[0].Rows[0]["class_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);
            }
        }
Example #10
0
        public void ProductClassPage()
        {
            int category_id = MyCommFun.RequestInt("cid");

            //--=====begin: 将这个列表(文章类别)的基本信息展示出来 ====--
            DAL.wx_shop_category   cateBll  = new DAL.wx_shop_category();
            Model.wx_shop_category category = cateBll.GetCategoryByWid(wid, category_id);
            this.Document.SetValue("category", category);
            this.Document.SetValue("wid", wid);
            //--=====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 productlist = new DataSet();

            if (category_id != 0)
            {
                DAL.wx_shop_product artDal = new DAL.wx_shop_product();
                productlist = artDal.GetList(wid, category_id, pageSize, currPage, "upselling=1", orderby, out recordCount);
                if (productlist != null && productlist.Tables.Count > 0 && productlist.Tables[0].Rows.Count > 0)
                {
                    DataRow dr;
                    for (int i = 0; i < productlist.Tables[0].Rows.Count; i++)
                    {
                        dr = productlist.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 + "&pid=" + dr["id"].ToString(), openid);
                        }
                        productlist.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("productlist", productlist); //文章列表

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

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

            if (currPage >= totPage)
            {
                nextPageStr = "";
                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);         //下一页灰色的样式
        }
        /// <summary>
        /// 获得该分类信息,使用wid仅仅作为限制条件
        /// </summary>
        /// <param name="wid"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public Model.wx_shop_category GetCategoryByWid(int wid, int id)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1");
            strSql.Append(" id,title,code,parent_id,class_list,class_layer,sort_id,link_url,img_url,class_content,remark,seo_title,seo_keywords,seo_description,wid,ico_url  ");
            strSql.Append(" from wx_shop_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.wx_shop_category category = new Model.wx_shop_category();
            while (sr.Read())
            {
                category = new Model.wx_shop_category();
                category.id = MyCommFun.Obj2Int(sr["id"]);
                category.title = MyCommFun.ObjToStr(sr["title"]);
                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.class_content = MyCommFun.ObjToStr(sr["class_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;
        }
        /// <summary>
        /// 获得微帐号的分类信息
        /// </summary>
        /// <param name="wid"></param>
        /// <param name="topNum">取前几条数据;若为-1,则不作筛选条件</param>
        /// <param name="parentId">若为-1,则不作筛选条件</param>
        /// <returns></returns>
        public IList<Model.wx_shop_category> GetCategoryListByWid(int wid, int topNum, int parentId, int class_layer)
        {
            IList<Model.wx_shop_category> categoryList = new List<Model.wx_shop_category>();

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (topNum >= 0)
            {
                strSql.Append(" top " + topNum + " ");
            }
            strSql.Append(" id,title,code,parent_id,class_list,class_layer,sort_id,link_url,img_url,class_content,remark,seo_title,seo_keywords,seo_description,wid,ico_url from wx_shop_category   where 1=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 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.wx_shop_category category = new Model.wx_shop_category();
            while (sr.Read())
            {
                category = new Model.wx_shop_category();
                category.id = MyCommFun.Obj2Int(sr["id"]);
                category.title = MyCommFun.ObjToStr(sr["title"]);
                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.class_content = MyCommFun.ObjToStr(sr["class_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"]);
                categoryList.Add(category);
            }
            sr.Close();



            return categoryList;
        }
        /// <summary>
        /// 得到一个对象实体(重载,带事务)
        /// </summary>
        public Model.wx_shop_category GetModel(SqlConnection conn, SqlTransaction trans, int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1  id,title,code,parent_id,class_list,class_layer,sort_id,link_url,img_url,class_content,remark,seo_title,seo_keywords,seo_description,wid,ico_url from wx_shop_category  ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            Model.wx_shop_category model = new Model.wx_shop_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]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "")
                {
                    model.title = ds.Tables[0].Rows[0]["title"].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]["class_content"] != null && ds.Tables[0].Rows[0]["class_content"].ToString() != "")
                {
                    model.class_content = ds.Tables[0].Rows[0]["class_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;
            }
        }
Example #14
0
        /// <summary>
        /// 获得wid的用户分类信息 
        /// </summary>
        /// <returns></returns>
        public IList<Model.wx_shop_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());
            }
            DAL.wx_shop_category cateBll = new DAL.wx_shop_category();
            IList<Model.wx_shop_category> categorylist = cateBll.GetCategoryListByWid(wid, -1, parentid, class_layer);
            if (categorylist != null && categorylist.Count > 0)
            {
                Model.wx_shop_category cat = new Model.wx_shop_category();
                for (int i = 0; i < categorylist.Count; i++)
                {
                    cat = categorylist[i];
                    if (cat.link_url == null || cat.link_url.Trim() == "")
                    {  //如果link_url为空,则直接调用本系统的信息
                        cat.link_url = MyCommFun.urlAddOpenid("/shop/list.aspx?wid=" + wid + "&cid=" + cat.id, openid);

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

            return categorylist;
        }
Example #15
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.wx_shop_category model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        //先判断选中的父节点是否被包含
                        if (IsContainNode(model.id, model.parent_id.Value))
                        {
                            //查找旧数据
                            Model.wx_shop_category oldModel = GetModel(model.id);
                            //查找旧父节点数据
                            string class_list  = "," + model.parent_id + ",";
                            int    class_layer = 1;
                            if (oldModel.parent_id > 0)
                            {
                                Model.wx_shop_category oldParentModel = GetModel(conn, trans, oldModel.parent_id.Value); //带事务
                                class_list  = oldParentModel.class_list + model.parent_id + ",";
                                class_layer = oldParentModel.class_layer.Value + 1;
                            }
                            //先提升选中的父节点
                            DbHelperSQL.ExecuteSql(conn, trans, "update wx_shop_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.Value);                                                                                                                                                     //带事务
                        }
                        //更新子节点
                        if (model.parent_id > 0)
                        {
                            Model.wx_shop_category model2 = GetModel(conn, trans, model.parent_id.Value); //带事务
                            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 wx_shop_category set ");
                        strSql.Append("title=@title,");
                        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("class_content=@class_content,");
                        strSql.Append("seo_title=@seo_title,");
                        strSql.Append("seo_keywords=@seo_keywords,");
                        strSql.Append("seo_description=@seo_description,");
                        strSql.Append("wid=@wid,");
                        strSql.Append("ico_url=@ico_url");
                        strSql.Append(" where id=@id");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@title",           SqlDbType.NVarChar, 100),
                            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("@class_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("@wid",             SqlDbType.Int,        4),
                            new SqlParameter("@ico_url",         SqlDbType.NVarChar, 500),
                            new SqlParameter("@id",              SqlDbType.Int, 4)
                        };
                        parameters[0].Value  = model.title;
                        parameters[1].Value  = model.parent_id;
                        parameters[2].Value  = model.class_list;
                        parameters[3].Value  = model.class_layer;
                        parameters[4].Value  = model.sort_id;
                        parameters[5].Value  = model.link_url;
                        parameters[6].Value  = model.img_url;
                        parameters[7].Value  = model.class_content;
                        parameters[8].Value  = model.seo_title;
                        parameters[9].Value  = model.seo_keywords;
                        parameters[10].Value = model.seo_description;
                        parameters[11].Value = model.wid;
                        parameters[12].Value = model.ico_url;
                        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);
        }
Example #16
0
        private bool DoAdd()
        {
            try
            {
                Model.wx_shop_category model = new Model.wx_shop_category();
                BLL.wx_shop_category bll = new BLL.wx_shop_category();

                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.class_content = txtContent.Text.Trim();
                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(), "添加商品分类:" + model.title); //记录日志
                    return true;
                }
            }
            catch
            {
                return false;
            }
            return false;
        }
Example #17
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.wx_shop_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 wx_shop_category(");
                        strSql.Append("title,parent_id,class_list,class_layer,sort_id,link_url,img_url,class_content,seo_title,seo_keywords,seo_description,wid,ico_url)");
                        strSql.Append(" values (");
                        strSql.Append("@title,@parent_id,@class_list,@class_layer,@sort_id,@link_url,@img_url,@class_content,@seo_title,@seo_keywords,@seo_description,@wid,@ico_url)");
                        strSql.Append(";select @@IDENTITY");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@title",           SqlDbType.NVarChar, 100),
                            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("@class_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("@wid",             SqlDbType.Int,        4),
                            new SqlParameter("@ico_url",         SqlDbType.NVarChar, 500)
                        };
                        parameters[0].Value  = model.title;
                        parameters[1].Value  = model.parent_id;
                        parameters[2].Value  = model.class_list;
                        parameters[3].Value  = model.class_layer;
                        parameters[4].Value  = model.sort_id;
                        parameters[5].Value  = model.link_url;
                        parameters[6].Value  = model.img_url;
                        parameters[7].Value  = model.class_content;
                        parameters[8].Value  = model.seo_title;
                        parameters[9].Value  = model.seo_keywords;
                        parameters[10].Value = model.seo_description;
                        parameters[11].Value = model.wid;
                        parameters[12].Value = model.ico_url;
                        object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); //带事务
                        model.id = Convert.ToInt32(obj);

                        if (model.parent_id > 0)
                        {
                            Model.wx_shop_category model2 = GetModel(conn, trans, model.parent_id.Value); //带事务
                            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 wx_shop_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);
        }