示例#1
0
        public ActionResult Delete(int[] orderIds = null)
        {
            ViewBag.Delete = false;
            bool rs = false;

            if (orderIds != null)
            {
                rs = SaleManagementBLL.Order_Delete(orderIds);
                if (rs == true)
                {
                    TempData["orderError"] = "<script>alert('Xóa order thành công!');</script>";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["orderError"] = "<script>alert('Xóa không thành công !');</script>";
                    return(RedirectToAction("Index"));
                }
            }
            return(RedirectToAction("Index"));
        }
示例#2
0
 public ActionResult Input(int orderID = 0, int productID = 0)
 {
     if (orderID == 0)
     {
         return(RedirectToAction("Index", "Order"));
     }
     if (productID == 0)
     {
         ViewBag.Title = "add new Orderdetail";
         OrderDetail newOrderTail = new OrderDetail();
         newOrderTail.ProductID = 0;
         newOrderTail.OrderID   = orderID;
         return(View(newOrderTail));
     }
     else
     {
         ViewBag.Title = "edit Orderdetail";
         OrderDetail editOrderDetail = SaleManagementBLL.OrderDetail_Get(orderID, productID);
         return(View(editOrderDetail));
     }
 }
示例#3
0
        public ActionResult Create(Order model)
        {
            try
            {
                DateTime orderDate    = Convert.ToDateTime(model.OrderDate);
                DateTime requiredDate = Convert.ToDateTime(model.RequiredDate);
                //Validation dữ liệu
                if (string.IsNullOrEmpty(model.OrderDate))
                {
                    model.OrderDate = "";
                }
                if (string.IsNullOrEmpty(model.RequiredDate))
                {
                    model.RequiredDate = "";
                }
                if (string.IsNullOrEmpty(model.ShippedDate))
                {
                    model.ShippedDate = null;
                }
                if (orderDate >= requiredDate)
                {
                    ModelState.AddModelError("Wrong", "Ngày yêu cầu giao hàng phải muộn hơn ngày đặt hàng!");
                    ViewBag.ConfirmButton = "Create";
                    return(View(model));
                }
                //Kiểm tra có tồn tại bất kỳ lỗi nào hay không

                //Đưa dữ liệu vào CSDL
                int orderID = SaleManagementBLL.Order_Add(model);
                return(RedirectToAction("Input/" + orderID));
            }
            catch (Exception e)
            {
                Console.WriteLine("", e.Message + ":" + e.StackTrace);
                return(View(model));
            }
        }
示例#4
0
        public ActionResult Input(Order model)
        {
            if (string.IsNullOrEmpty(model.ShipAddress))
            {
                model.ShipAddress = "";
            }
            if (string.IsNullOrEmpty(model.ShipCity))
            {
                model.ShipCity = "";
            }
            if (string.IsNullOrEmpty(model.Freight.ToString()))
            {
                model.Freight = 0;
            }
            if (string.IsNullOrEmpty(model.EmployeeID.ToString()))
            {
                model.EmployeeID = 0;
            }
            if (string.IsNullOrEmpty(model.CustomerID))
            {
                model.CustomerID = "";
            }
            if (string.IsNullOrEmpty(model.ShipperID.ToString()))
            {
                model.ShipperID = 0;
            }
            var dateTime        = new DateTime(1900, 01, 01);
            var compareDatetime = DateTime.Compare(model.OrderDate, dateTime);

            if (compareDatetime < 0)
            {
                ModelState.AddModelError("OrderDate", "OrderDate is not format");
                return(View(model));
            }
            compareDatetime = DateTime.Compare(model.RequiredDate, dateTime);
            if (compareDatetime < 0)
            {
                ModelState.AddModelError("RequiredDate", "RequiredDate is not format");
                return(View(model));
            }
            compareDatetime = DateTime.Compare(model.ShippedDate, dateTime);
            if (compareDatetime < 0)
            {
                ModelState.AddModelError("ShippedDate", "ShippedDate is not format");
                return(View(model));
            }
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            try
            {
                if (model.OrderID == 0)
                {
                    //var path = Path.Combine(Server.MapPath("~/Images"), fileName);
                    //file.SaveAs(path);
                    int orderId = SaleManagementBLL.Order_Add(model);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    bool updateResult = SaleManagementBLL.Order_Update(model);
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message + ": " + ex.StackTrace);
                return(View());
            }
        }
示例#5
0
 public ActionResult Input(Order model)
 {
     try
     {
         DateTime orderDate    = Convert.ToDateTime(model.OrderDate);
         DateTime requiredDate = Convert.ToDateTime(model.RequiredDate);
         DateTime shippedDate  = Convert.ToDateTime(model.ShippedDate);
         //Validation dữ liệu
         if (string.IsNullOrEmpty(model.OrderDate))
         {
             model.OrderDate = "";
         }
         if (string.IsNullOrEmpty(model.RequiredDate))
         {
             model.RequiredDate = "";
         }
         if (orderDate >= requiredDate)
         {
             ModelState.AddModelError("Wrong", "Ngày yêu cầu giao hàng phải muộn hơn ngày đặt hàng ít nhất 1 ngày!");
             ViewBag.ConfirmButton = "Create";
             return(View(model));
         }
         if (shippedDate < requiredDate)
         {
             ModelState.AddModelError("WrongShipDate", "Ngày giao hàng phải muộn hơn ngày đặt hàng ít nhất 1 ngày!");
             ViewBag.ConfirmButton = "Save";
             return(View(model));
         }
         //Kiểm tra có tồn tại bất kỳ lỗi nào hay không
         if (!ModelState.IsValid)
         {
             if (model.OrderID == 0)
             {
                 ViewBag.Title         = "Add New Order";
                 ViewBag.ConfirmButton = "Add";
             }
             else
             {
                 ViewBag.Title         = "Edit New Order";
                 ViewBag.ConfirmButton = "Save";
             }
             return(View(model));
         }
         //Đưa dữ liệu vào CSDL
         if (model.OrderID == 0)
         {
             int orderID = SaleManagementBLL.Order_Add(model);
             return(RedirectToAction("Input/" + orderID));
         }
         else
         {
             bool rs = SaleManagementBLL.Order_Update(model);
             return(RedirectToAction("Index"));
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("", e.Message + ":" + e.StackTrace);
         return(View(model));
     }
 }