示例#1
0
        public int price;//用来存放价格,因为有单价与优惠价之分。
        protected void Page_Load(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            string id = Request.QueryString["restaurantId"];
            if (id == null)
            {
                id = "";
            }

            if ((Request.QueryString["deskId"] != null) && (Request.QueryString["restaurantId"] != null))
            {
                HttpCookie cook = new HttpCookie("deskId", Request.QueryString["deskId"].ToString());//新建一个cookie对象
                HttpCookie cookie = new HttpCookie("restaurantId", Request.QueryString["restaurantId"].ToString());//新建一个cookie对象
                Response.Cookies.Add(cook);
                Response.Cookies.Add(cookie);
            }
            else
            {
                HttpCookie cook = new HttpCookie("deskId", "1");//新建一个cookie对象
                HttpCookie cookie = new HttpCookie("restaurantId", "1");//新建一个cookie对象
            }
            RestaurantsDAO restaurantDAO = new RestaurantsDAO();
            DiscountDAO discountDAO = new DiscountDAO();
            List<DishEntity> disheslist = restaurantDAO.getDishListById(id);
            RestaurantEntity restaurant = restaurantDAO.getById(id);
           
            restaurantName = restaurant.name;
            int type_count = restaurantDAO.getTypeCount(id);
            int jj = 0;
            int kk = 0;
            while(jj<disheslist.Count)//总共有disheslist.Count个菜
            {
                sb.Append("<div class='order-top'>");
                sb.Append("<li style='width:35%' class='data'><h4>"+disheslist[jj].type_name+"</h4>");
                while (disheslist[kk].type_id == disheslist[jj].type_id && kk < disheslist.Count)//这是干嘛的,输出菜名,按列来搞
                {
                    sb.Append("<div style='width:100%'>");
                    sb.Append("<img style='width:50%;float:left;padding-right:20px' src='"+ disheslist[kk].photo +"' class='img-responsive'/>");
                    sb.Append("<p>"+disheslist[kk].dish_name+"</p>");
                    sb.Append("</div>");
                    sb.Append("<div style='padding-bottom:20px'></div>");
                    kk++;
                    if (kk == disheslist.Count) break;
                }
                kk = jj;
                sb.Append("</li>");
                sb.Append("<li style='width:60%' class='data'>");
                sb.Append("<div class='special-info grid_1 simpleCart_shelfItem'>");
                sb.Append("<h4>价格</h4>");
                while(disheslist[kk].type_id== disheslist[jj].type_id && kk<disheslist.Count)
                {
                    DiscountEntity discount = discountDAO.getDiscountById(disheslist[kk].id);
                    
                    sb.Append("<div class='pre-top'>");
                    sb.Append("<div class='pr-left'>");
                    if (discount.reason != null)
                    {
                        price = discount.currentprice;
                        sb.Append("<div class='item_add'><span  class='item_price'><h6 style='text-decoration:line-through;float:left;'> ¥" + disheslist[kk].price + ".00</h6>");
                        sb.Append("<h6 style='float:right;'>ONLY ¥"+ price+"</h6></span></div>");
                    }
                    else
                    {
                        sb.Append("<div class='item_add'><span  class='item_price'><h6>ONLY ¥" + disheslist[kk].price + ".00</h6></span></div>");
                        price = disheslist[kk].price;
                     }       
                    sb.Append("</div>");
                    sb.Append("<div class='pr-right'>");
                    sb.Append("<div class='item_add'><span id='a" + disheslist[kk].id + "' onclick='addtocart(this,0,"+  price + ")' class='item_price'><a href='#'>来一份</a></span></div>");//此处为了得到菜品单价,直接添加了单价作为参数。
                    sb.Append("</div>");
                   
                    sb.Append("<div class='clearfix'></div>");
                    sb.Append("</div>");
                    sb.Append("<div style='padding-bottom:20px'></div>");
                    kk++;
                    if (kk == disheslist.Count) break;
                }
                jj = kk;
                sb.Append("</div>");
                sb.Append("</li>");
				sb.Append("<div class='clearfix'></div>");
                sb.Append("</div>");
                sb.Append("");
            }
            dishList = sb.ToString();
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            DishDAO dishDAO = new DishDAO();
            DiscountDAO discountDAO = new DiscountDAO();
            shopping_count = 0;
            total_price = 0;
            every_price = 0;
            for (int i = 0; i < Request.Cookies.Count; i++)
            {
   
                string name = Request.Cookies[i].Name;
                if (name.Length >= 13 && Request.Cookies[i].Value!="null")
                {
                    string id = name.Substring(13, name.Length - 13);
                    string logo = name.Substring(0, 13);
                    if (logo.Equals("yumiyumi_cart"))
                    {
                        shopping_count++;
                        DishEntity temp = dishDAO.getDishById(Convert.ToInt32(id));
                        int branchid = temp.brand_id;
                        DiscountEntity discounttemp = discountDAO.getDiscountById(Convert.ToInt32(id));
                        string eachcookie = System.Web.HttpUtility.UrlDecode(Request.Cookies[i].Value.ToString());
                        string[] quantity = eachcookie.Split(';');
                        int q = Convert.ToInt32(quantity[0].Split(':')[1]);
                        int price = temp.price;
                        
                        /* Response.Write("Cookie[" + i + "]的Name为:" + id + "<br/>\n");
                       Response.Write("Cookie[" + i + "]的Value为:" + Request.Cookies[i].Value.ToString() + "<br/>\n");
                        sb.Append("<script>$(document).ready(function (c) {");
                        sb.Append("$('#close" + id +"').on('click', function (c) {");
                        sb.Append("$.cookie('"+name+"', '', { expires: -1 });");
                        sb.Append("$('#cart-header" + i + "').fadeOut('slow', function (c) {");
                        sb.Append("$('#cart-header" + i + "').remove();");
                        sb.Append("});");
                        sb.Append("});");
                        sb.Append("});");
                        sb.Append("</script>\n");*/
                        sb.Append("<div id='cart-header" + id + "'class='cart-header3'>\n");
                        sb.Append("<div id='close" + id + "' class='close3' onclick='deletepart(this)'> </div>\n");
                        sb.Append("<div class='cart-sec simpleCart_shelfItem'>\n");
                        sb.Append("<div class='cart-item cyc'>\n");
                        sb.Append("<img src='" + temp.photo +"' class='img-responsive' alt=''>\n");//菜的图片
                        sb.Append("</div>\n");
                        sb.Append("<div class='cart-item-info'>\n");
                        sb.Append("<h3><a href='#'>"+temp.dish_name+"</a> </h3>\n");
                        sb.Append("<ul class='qty'>\n");
                        sb.Append("<li><p>\0\0\0¥" + temp.price + "</p></li>\n"); //单价
                        sb.Append("</ul>\n");
                       
                        if (discounttemp.reason != null){
                            sb.Append("<ul class='qty' style='width:100%'>\n");
                            sb.Append("<li><p'>实价:¥" + discounttemp.currentprice + "</p></li>\n"); //单价
                            price = discounttemp.currentprice;
                            sb.Append("</ul>\n");
                            sb.Append("<div style='width:100%;float:left' ><p>折扣原因:"+ discounttemp.reason + "</p></div>\n");
                        }
                        total_price += q * price;
                        every_price = q * price;
                        
                        sb.Append("<div class='quantity'>");
                        sb.Append("<span class='number'>数量:</span>");
                        sb.Append(" <img id=p" + id + " src='images/remove.png'class='img-responsive img_minus' onclick='deletefromcart(this)'>");
                        sb.Append("<span style='float:left;padding-left:5px;' id=q" + id +" >" + q + "</span> ");
                        sb.Append(" <img id=p" + id + " src='images/plus.png'class='img-responsive img_plus' onclick='addtocart(this,1)'> </div> "); 
                        sb.Append("<div class='total_price'><span id=t" + id + ">总价:¥" + every_price + "</span></div>");
                        sb.Append("<div class='delivery'>\n");
                        sb.Append("<div class='clearfix'></div>\n");
                        sb.Append("</div>\n");
                        sb.Append("</div>\n");
                        sb.Append("<div class='clearfix'></div>\n");
                        sb.Append("</div>\n");
                        sb.Append("</div>\n");
                    }
                }
            }
            //检测是否是会员
            if(true){

            }
            if (shopping_count == 0)
            {
                sb.Append("<img class='emptycart img-responsive ' src='images/emptycart.png'alt=''>\n");//购物车是空的
                sb.Append("<a href = 'restaurants.aspx' class='btn'>");
                sb.Append("<input type='button' value=''/></a>\n");
            }
            else
            {
                commitOrder = "Temp1";
            }
            shopping_cart = sb.ToString();
        }