예제 #1
0
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     int order_id = Convert.ToInt32(context.Request.QueryString["order_id"]);
     OrderDAO orderDAO = new OrderDAO();
     bool success = orderDAO.deleteById(order_id);
     context.Response.Write(success + "\n");
 }
예제 #2
0
 public void getAllOrders()
 {
     OrderDAO orderDAO = new OrderDAO();
     DishDAO dishDAO = new DishDAO();
     List<OrderEntity> list = orderDAO.getOrderByUserId(user_id);
     StringBuilder sb = new StringBuilder();
     for (int i = 0; i < list.Count; i++)
     {
         OrderEntity order = list[i];
         String dishString = "";
         for (int j = 0; j < order.dishList.Count - 1; j++)
         {
             DishEntity dish = dishDAO.getDishById(order.dishList[j].dish_id);
             dishString += dish.dish_name + ",";
             order.total_price += dish.price;
         }
         DishEntity dish2 = dishDAO.getDishById(order.dishList[order.dishList.Count - 1].dish_id);
         dishString += dish2.dish_name;
         order.total_price += dish2.price;
         DateTime todaydate = Convert.ToDateTime(order.start_time);
         String date = todaydate.ToString();
         switch (order.status)
         {
             //对订单状态进行分类,应该需要换,优化
             case 0:
                 sb.Append("<tr>");
                 sb.Append("<td width='55' class='bl_blue'><span class='label label-info'>新订单</span></td>");
                 sb.Append("<td>" + order.user_id + "</td>");
                 sb.Append("<td><input type='checkbox' class='checkall'/></td>");
                 //跳转位置
                 sb.Append("<td><a href='order_list.aspx?orderId=" + order.order_id + "' class='cblue'>" + dishString + "</a>");
                 sb.Append("<td><span class='mark'>" + date + "</span></td>");
                 sb.Append("<td>未支付</td>");
                 sb.Append("<td>¥"+ order.total_price +"</td>");
                 sb.Append("<td>已接单,等待制作</td>");
                 sb.Append("<td><a id='" + order.order_id + "' href='#' OnClick='cancleOrder(this)'>取消订单</a></td>>");
                 sb.Append("</tr>");
                 break;
             case 1:
                 sb.Append("<tr>");
                 sb.Append("<td class='bl_green'><span class='label label-success'>完成</span></td>");
                 sb.Append("<td>" + order.user_id + "</td>");
                 sb.Append("<td><input type='checkbox' class='checkall'/></td>");
                 //跳转位置
                 sb.Append("<td><a href='order_list.aspx?orderId=" + order.order_id + "' class='cblue'>" + dishString + "</a>");
                 sb.Append("<td><span class='mark'>" + date + "</span></td>");
                 sb.Append("<td>未支付</td>");
                 sb.Append("<td>¥" + order.total_price + "</td>");
                 sb.Append("<td>已接单,正在制作中</td>");
                 sb.Append("<td>取消</td>");
                 sb.Append("</tr>");
                 break;
             case 2:
                 sb.Append("<tr>");
                 sb.Append("<td>" + order.user_id + "</td>");
                 sb.Append("<td><input type='checkbox' class='checkall'/></td>");
                 //跳转位置
                 sb.Append("<td><a href='order_list.aspx?orderId=" + order.order_id + "' class='cblue'>" + dishString + "</a>");
                 sb.Append("<td><span class='mark'>" + date + "</span></td>");
                 sb.Append("<td>未支付</td>");
                 sb.Append("<td>¥" + order.total_price + "</td>");
                 sb.Append("<td>已接单,正在制作中</td>");
                 sb.Append("<td>取消</td>");
                 sb.Append("</tr>");
                 break;
         }
         total_price += order.total_price;
     }
     orderPart = sb.ToString();
 }
예제 #3
0
        protected void Unnamed_Click(object sender, EventArgs e)
        {
            OrderDAO orderDAO = new OrderDAO();
            OrderEntity order = new OrderEntity();
            DishDAO dishDAO = new DishDAO();

            if ((Request.Cookies["deskId"] != null)&&(Request.Cookies["restaurantId"] != null))
            {
                order.restaurant_id = Convert.ToInt32(Request.Cookies["restaurantId"].Value);
                order.user_id = Convert.ToInt32(Request.Cookies["deskId"].Value);
            }
            else
            {
                order.restaurant_id = 1;//这个要改
                order.user_id = 1;
            }
            order.remark = "空";
            List<HttpCookie> cookieList = new List<HttpCookie>();
            for (int i = 0; i < Request.Cookies.Count; i++)
            {
                string name = Request.Cookies[i].Name;
                if (name.Length >= 13 && Request.Cookies[i].Value != "null" && Request.Cookies[i].Value != "0")
                {
                    string id = name.Substring(13, name.Length - 13);
                    string logo = name.Substring(0, 13);
                    if (logo.Equals("yumiyumi_cart"))
                    {
                        DishEntity temp = dishDAO.getDishById(Convert.ToInt32(id));
                        OrderDetailEntity orderDetail = new OrderDetailEntity();
                        
                        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 = Convert.ToInt32(quantity[1].Split(':')[1]);
                        orderDetail.count = q;
                        orderDetail.dish_id = temp.id;
                        orderDetail.price = price;
                        order.dishList.Add(orderDetail);

                        Request.Cookies[i].Value = "0";
                        HttpCookie cookies = new HttpCookie(name);
                        cookies.Value = "0";
                        cookies.Expires = DateTime.Now.AddDays(-1);
                        Response.Cookies.Add(cookies);
                    }
                }
            }

                if (orderDAO.addOneOrder(order))
                {
                    Response.Redirect("successOrder.aspx");
                }
        }