Пример #1
0
 public OrderEntity getOneOrderByOrderId(int orderId)
 {
     string mysql = "SELECT `order_id`,`user_id`,`restaurant_id`,`remark`,`total_price` FROM `yumi_order` WHERE `order_id` =?orderId";
     MySqlParameter[] parameters = {
             new MySqlParameter("?orderId", MySqlDbType.UInt32)
             };
     parameters[0].Value = orderId;
     MySqlDataReader myreader = MySqlHelper.ExecuteReader(mysql, parameters);
     OrderEntity order = new OrderEntity();
     while (myreader.Read())
     {
         order.order_id = myreader.GetInt32(0);
         order.user_id = myreader.GetInt32(1);
         order.restaurant_id = myreader.GetInt32(2);
         order.remark = myreader.GetString(3);
         order.total_price = myreader.GetInt32(4);
         string mysql2 = "SELECT `id`,`order_id`,`dish_id`,`dish_count` FROM `yumi_order_detail` WHERE `order_id` =?orderId;";
         MySqlParameter[] parameters2 = {
             new MySqlParameter("?orderId", MySqlDbType.UInt32)
             };
         parameters2[0].Value = order.order_id;
         MySqlDataReader myreader2 = MySqlHelper.ExecuteReader(mysql2, parameters2);
         while (myreader2.Read())
         {
             OrderDetailEntity detail = new OrderDetailEntity();
             detail.order_id = myreader.GetInt32(1);
             detail.dish_id = myreader.GetInt32(2);
             detail.count = detail.dish_id = myreader.GetInt32(3);
             order.dishList.Add(detail);
         }
     }
     return order;
 }
Пример #2
0
 public List<OrderEntity> getAllOrderByRestaurantId(int restaurantId)
 {
     //string mysql = "SELECT * FROM yumiyumi.yumi_account where user_name ='"+email+"'";
     string mysql = "SELECT `order_id`,`user_id`,`restaurant_id`,`remark`,`total_price`,`status`,`start_time` FROM `yumi_order` WHERE `restaurant_id` =?restaurantId";
     MySqlParameter[] parameters = {
             new MySqlParameter("?restaurantId", MySqlDbType.UInt32)
             };
     parameters[0].Value = restaurantId;
     MySqlDataReader myreader = MySqlHelper.ExecuteReader(mysql, parameters);
     List<OrderEntity> list = new List<OrderEntity>();
     while (myreader.Read())
     {
         OrderEntity order = new OrderEntity();
         order.order_id = myreader.GetInt32(0);
         order.user_id = myreader.GetInt32(1);
         order.restaurant_id = myreader.GetInt32(2);
         order.remark = myreader.GetString(3);
         order.total_price = myreader.GetInt32(4);
         order.status = myreader.GetInt32(5);
         order.start_time = myreader.GetString(6);
         list.Add(order);
     }
     myreader.Close();
     for (int i = 0; i < list.Count; i++)
     {
         OrderEntity order = list[i];
         string mysql2 = "SELECT `id`,`order_id`,`dish_id`,`dish_count` FROM `yumi_order_detail` WHERE `order_id` =?orderId;";
         MySqlParameter[] parameters2 = {
             new MySqlParameter("?orderId", MySqlDbType.UInt32)
             };
         parameters2[0].Value = order.order_id;
         MySqlDataReader myreader2 = MySqlHelper.ExecuteReader(mysql2, parameters2);
         while (myreader2.Read())
         {
             OrderDetailEntity detail = new OrderDetailEntity();
             detail.order_id = myreader2.GetInt32(1);
             detail.dish_id = myreader2.GetInt32(2);
             detail.count = myreader2.GetInt32(3);
             order.dishList.Add(detail);
         }
         myreader2.Close();
     }
     return list;
 }
Пример #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");
                }
        }