Example #1
0
        //在这个地方创建商品分类的字典,实现商品分类的ID与
        //商品分类的名称的一个映射关系
        public static string GetCnameByCid(int cid)
        {
            object obj = DataCache.GetCache("CategoryDic");

            if (obj == null)
            {
                //第一步:取得所有商品分类的信息
                List <Model.eb_category> listCategory = new BLL.eb_category().GetModelList("");
                //遍历集合,来创建一个字典表的映射
                Dictionary <int, string> dic = new Dictionary <int, string>();
                //向字典里面添加数据

                listCategory.ForEach(g =>
                {
                    dic.Add(g.cid, g.cname);
                });
                //把数据加载到缓存里面去
                DataCache.SetCache("CategoryDic", dic);
                return(dic[cid]);
            }
            else
            {
                Dictionary <int, string> dic = obj as Dictionary <int, string>;
                return(dic[cid]);
            }
        }
Example #2
0
        public void ProcessRequest(HttpContext context)
        {
            string cid  = context.Request["cid"] == null ? "" : context.Request["cid"].ToString();
            bool   flag = new BLL.eb_category().Delete(int.Parse(cid));

            if (flag)
            {
                //如果成功 我就输出1
                context.Response.Write("1");
            }
            else
            {
                //如果不成功,我就输出0
                context.Response.Write("0");
            }
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //获取商品所有的分类
                List <Model.eb_category> listCategory = new BLL.eb_category().GetModelList("");
                //skip是跳过多少条记录,take是取多少条记录
                this.rp_Category.DataSource = listCategory.Take(8);
                this.rp_Category.DataBind();

                //绑定商品的信息
                List <Model.eb_goods> listGoods = new BLL.eb_goods().GetModelList("");
                //判断一下是不是有些记录是没有传商品图片的,如果是的,就使用默认的图片替换掉
                //listGoods.ForEach(g =>
                //{
                //    if (string.IsNullOrEmpty(g.goodsimg))
                //    {
                //        g.goodsimg = ConfigHelper.GetConfigString("DefaultGoodsPic");
                //    }
                //});
                this.rp_goods.DataSource = listGoods;
                this.rp_goods.DataBind();
            }
        }