public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            if (context.Session["users_id"] != null)
            {
                string temp = File.ReadAllText(context.Server.MapPath("drugstore_shopping_cart.html"));

                DataTable     dt = ShopCartBLL.Cart12(context.Session["users_id"].ToString());
                StringBuilder sb = new StringBuilder();
                foreach (DataRow item in dt.Rows)
                {
                    //goods_id  item["cart_goods_id"]

                    DataTable dt2 = ShopCartBLL.Cart13(item["cart_goods_id"].ToString());
                    sb.AppendFormat("<tr><td><label><input type='checkbox' class='product' name='{0}'>{1}</label></td><td>{2}...</td><td class='price'>{3}元</td><td style='width:200px'><div class='input-group' ><span class='input-group-addon reduceNum' >-</span><input type='text' name='num{0}' value='{4}' class='form-control' ><span class='input-group-addon addNum'>+</span><span>件</span></div></td><td class='money'>¥</td><td><a class='btn btn-danger' href='ProcessShopCartDelete.ashx?cart_id={0}'>删除</a></td></tr>", item["cart_id"], dt2.Rows[0]["Goods_name"], dt2.Rows[0]["Goods_effect"], dt2.Rows[0]["Goods_price"], item["cart_count"]);
                }
                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);
            }
            else
            {
                context.Response.Write("登陆后再来使用购物车吧!<a href='../drugstore_login.html'>登录页面</a>");
            }
        }
예제 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";

            //建订单表 空(时间)
            bool flag    = true;
            int  orderId = 0;

            string orderNumber = ShopCartBLL.GetRandomOrderNumber();

            int i3 = ShopCartBLL.Cart4(orderNumber, context.Request.Form["address"].ToString(), context.Request.Form["phone"].ToString(), context.Session["users_id"].ToString());

            for (int i = 0; i < context.Request.Form.Count; i++)
            {
                if (context.Request.Form[i] == "on")
                {
                    int cartId = Int32.Parse(context.Request.Form.GetKey(i));
                    int count  = Int32.Parse(context.Request.Form["num" + context.Request.Form.GetKey(i)]);



                    DataTable dt2 = ShopCartBLL.Cart5(cartId);

                    int i2 = ShopCartBLL.Cart6(cartId);
                    if (i2 > 0)
                    {
                        flag = false;

                        //dt2.Rows[0]["Cart_goods_id"]    dt2.Rows[0]["Cart_users_id"]
                        //根据唯一的订单号获取添加的cart_id

                        DataTable dt4 = ShopCartBLL.Cart7(orderNumber);
                        //dt4.Rows[0]["cart_id"]
                        orderId = Int32.Parse(dt4.Rows[0]["order_id"].ToString());

                        int i5 = ShopCartBLL.Cart8(Int32.Parse(dt2.Rows[0]["Cart_goods_id"].ToString()), count, orderId);

                        //计算销量

                        int i7 = ShopCartBLL.Cart9(Int32.Parse(dt2.Rows[0]["Cart_goods_id"].ToString()), count);
                    }
                }
            }
            if (flag)
            {
                //falg为true时 说明没有订单商品属于该订单  需要删除时间为1900-01-01 00:00:00.000的订单

                int i6 = ShopCartBLL.Cart10(orderId);
                context.Response.Write("结算失败,请重试<a href='ProcessShoppingIndex.ashx'>购物车</a>");
            }
            else
            {
                context.Response.Write("收货地址:" + context.Request.Form["address"] + "    联系电话:" + context.Request.Form["phone"] + "   ");
                context.Response.Write("购买成功!<a href='../OrderInfo/ProcessOrderIndex.ashx'>前往查看订单</a>");
            }
        }
예제 #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            if (context.Session["users_id"] != null)
            {
                int id = context.Request.QueryString["goods_id"] == null ? 0 : Int32.Parse(context.Request.QueryString["goods_id"]);

                //在主页添加时默认等于1
                int addNum = 1;
                if (context.Request.Form["goods_num"] != null)
                {
                    addNum = Int32.Parse(context.Request.Form["goods_num"]);
                }
                if (id == 0)
                {
                    if (true)
                    {
                    }
                    context.Response.Redirect("../GoodsInfo/ProcessDruginfo.ashx");
                }


                DataTable dt = ShopCartBLL.Cart1(id, context.Session["users_id"].ToString());



                if (dt.Rows.Count > 0)
                {
                    int i = ShopCartBLL.Cart2((Convert.ToInt32(dt.Rows[0]["cart_count"]) + addNum).ToString(), id, context.Session["users_id"].ToString());
                    context.Response.Redirect("../GoodsInfo/ProcessDruginfo.ashx");
                }
                else
                {
                    int i = ShopCartBLL.Cart3(id, addNum, context.Session["users_id"].ToString());
                    if (i > 0)
                    {
                        context.Response.Redirect("../GoodsInfo/ProcessDruginfo.ashx");
                    }
                    else
                    {
                        context.Response.Redirect("../GoodsInfo/ProcessDruginfo.ashx");
                    }
                }
            }
            else
            {
                context.Response.Redirect("~/drugstore_login.html");
            }
        }
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/html";
     if (context.Session["users_id"] != null)
     {
         int cartId = context.Request.QueryString["cart_id"] == null ? 0 : Int32.Parse(context.Request.QueryString["cart_id"]);
         if (cartId != 0)
         {
             int i = ShopCartBLL.Cart11(cartId);
             context.Response.Write("删除成功<a href='ProcessShoppingIndex.ashx'>购物车页</a>");
         }
         else
         {
             context.Response.Write("删除购物车异常...<a href='ProcessShoppingIndex.ashx'>购物车页</a>");
         }
     }
     else
     {
         context.Response.Redirect("~/drugstore_login.html");
     }
 }