Ejemplo n.º 1
0
        public ActionResult BookTable(string name, string date, string sodt, string timeBook, string email, int quantity, string noidung)
        {
            var order = new OrderTB.OrderTable();

            order.Full_Name    = name;
            order.DateBook     = date;
            order.Phone        = sodt;
            order.TimeBook     = timeBook;
            order.Email        = email;
            order.Count_people = quantity;
            if (noidung != null)
            {
                order.Description = noidung;
            }
            order.CreatedDate = DateTime.Now;
            try
            {
                var ins = new OrderSVClient();
                ins.Insert(order);
                SetAlert("Đặt bàn thành công", "success");
                return(Redirect("/"));
            }
            catch (Exception e)
            {
                SetAlert("Đặt bàn không thành công", "error");
                return(Redirect("dat-ban"));
            }
        }
        public ActionResult Edit(OrderTable orTB)
        {
            ViewBag.selectTime = new SelectList(GetAllTime(), "time", "time");
            var res = new OrderSVClient().EditOrder(orTB);

            if (res)
            {
                SetAlert("Cập nhật thông tin khách hàng thành công", "success");
                return(RedirectToAction("Index", "OrderTable"));
            }
            else
            {
                SetAlert("Cập nhật không thành công", "warning");
                return(View());
            }
        }
        public JsonResult Delete(long id)
        {
            var order = new OrderSVClient().DeleteOrder(id);

            if (order)
            {
                SetAlert("Xóa khách hàng thành công", "success");
                return(Json(new
                {
                    status = true
                }));
            }
            else
            {
                SetAlert("Xóa Không thành công", "warning");
                return(Json(new
                {
                    status = false
                }));
            }
        }
Ejemplo n.º 4
0
        //Lưu thực đơn và tên khách hàng đặt thực đơn
        public JsonResult SaveMenu(string Menu, string customer)
        {
            var menuJson = new JavaScriptSerializer().Deserialize <List <BookFood> >(Menu);
            var cusJson  = new JavaScriptSerializer().Deserialize <List <Feedback> >(customer);

            var feedback = new OrderTable();
            var listCus  = cusJson.ToList();

            foreach (var item in listCus)
            {
                if (item.Full_Name == null && item.Phone == null)
                {
                    SetAlert("Không thể bỏ trống HỌ VÀ TÊN và SỐ ĐIỆN THOẠI, vui lòng kiểm tra lại ", "warning");
                    break;
                    return(Json(new
                    {
                        status = true
                    }));
                }
                feedback.Full_Name = item.Full_Name;
                feedback.Phone     = item.Phone;
                feedback.Email     = item.Email;
                if (item.Description != " ")
                {
                    feedback.Description = item.Description;
                }
                feedback.DateBook     = item.DateBook;
                feedback.TimeBook     = item.TimeBook;
                feedback.Count_people = item.Count_people;
                feedback.CreatedDate  = DateTime.Now;

                var ins = new OrderSVClient();
                if (ins.Insert(feedback))
                {
                    SetAlert("Đặt bàn thành công", "success");
                }
                else
                {
                    SetAlert("Đặt bàn không thành công", "warning");
                }
            }


            var bookFood = new Book_Menu.Book_Food();
            var listFood = menuJson.ToList();
            var idOrder  = new OrderSVClient().FindIDNew();

            foreach (var item in listFood)
            {
                bookFood.Food_ID       = item.Food_ID;
                bookFood.Count         = item.Count;
                bookFood.Price         = Convert.ToDecimal(item.Price);
                bookFood.OrderTable_ID = idOrder;

                var ins = new BookMenuSVClient();
                if (ins.InsertMenu(bookFood))
                {
                    SetAlert("Bạn đã đặt trước thực đơn thành công", "success");
                }
                else
                {
                    SetAlert("Bạn đã đặt trước thực đơn không thành công", "warning");
                }
            }
            return(Json(new
            {
                status = true
            }));
        }