コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            if (context.Session["id"] != null)
            {
                List <GoodModel> goodsList = new List <GoodModel>();
                if (context.Request.Form["name"] != null)
                {
                    goodsList = GoodsBLL.GetGoodsListBySearch(context.Request.Form["name"].ToString());
                }
                else
                {
                    goodsList = GoodsBLL.GetGoodsList2();
                }

                //读取模板
                string temp = File.ReadAllText(context.Server.MapPath("admin_product.html"));
                //删除文本
                //string deleteText = "'确认要删除{1}的商品?'";
                StringBuilder sb = new StringBuilder();
                foreach (GoodModel item in goodsList)
                {
                    sb.AppendFormat(@"<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td><a href='DeleteGoods.ashx?goods_id={0}' class='btn btn-danger'>删除</a><a href='SaveGoods.ashx?goods_id={0}' class='btn btn-primary'>修改</a></td></tr>", item.GoodsId, item.GoodsName, item.GoodsPrice + "元", item.GoodsStock + "件");
                }
                temp = temp.Replace("@content", sb.ToString());
                temp = temp.Replace("@admin", context.Session["admin_name"].ToString());
                context.Response.Write(temp);
            }
            else
            {
                context.Response.Redirect("~/admin_login.html");
            }
        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            string effectId = context.Request.QueryString["effect"];

            List <GoodModel> goodsList = new List <GoodModel>();

            if (effectId != null)
            {
                goodsList = GoodsBLL.GetGoodsListByEffectId(effectId);
            }
            else if (context.Request.Form["goods_name"] != null)
            {
                goodsList = GoodsBLL.GetGoodsListBySearch(context.Request.Form["goods_name"].ToString());
            }


            string        temp = File.ReadAllText(context.Server.MapPath("drugstore_search.html"));
            StringBuilder sb   = new StringBuilder();

            if (goodsList == null)
            {
                temp = temp.Replace("@content", "该类型的商品还未上架,敬请期待.");
            }
            else
            {
                foreach (GoodModel item in goodsList)
                {
                    sb.AppendFormat(@"<div class='col-lg-3' ><div class='thumbnail'><img src='{4}' style='height: 300px' alt='...'><div class='caption'><h3>{0}</h3><p>{1}元</p><p>总销量:{2}</p><p><a href='ProcessDrugDetails.ashx?goods_id={3}' class='btn btn-primary' role='button'>查看详情</a> <a href='../ShopCartInfo/ProcessAddCart.ashx?goods_id={3}' class='btn btn-default' role='button'>加入购物车</a></p></div></div></div>", item.GoodsName, item.GoodsPrice, item.GoodsSalesVolume, item.GoodsId, "../Images/product_img/" + item.GoodsPicture);
                }
            }



            temp = temp.Replace("@content", sb.ToString());
            if (context.Session["users_id"] != null)
            {
                temp = temp.Replace("@user_name", context.Session["user_name"].ToString());
            }
            else
            {
                temp = temp.Replace("@user_name", "游客");
            }

            context.Response.Write(temp);
        }