[HttpPost] //lkhi submit dữ liệu
 public ActionResult Input(OrderDetail model, string discountString, int oldProductID)
 {
     if (string.IsNullOrEmpty(model.ProductID.ToString()))
     {
         ModelState.AddModelError("Product", "product required");
     }
     if (string.IsNullOrEmpty(model.UnitPrice.ToString()))
     {
         ModelState.AddModelError("UnitPrice", "UnitPrice required");
     }
     if (string.IsNullOrEmpty(model.Quantity.ToString()))
     {
         ModelState.AddModelError("Quantity", "Quantity required");
     }
     if (string.IsNullOrEmpty(discountString.ToString()))
     {
         ModelState.AddModelError("Discount", "Discount required");
     }
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     model.Discount = Convert.ToDecimal(discountString);
     try
     {
         if (oldProductID == 0)
         {
             int Id = SaleManagementBLL.OrderDetail_Add(model);
             TempData["orderId"] = model.OrderID;
             return(RedirectToAction("Index"));
         }
         else
         {
             bool updateResult = SaleManagementBLL.OrderDetail_Update(model, oldProductID);
             TempData["orderId"] = model.OrderID;
             return(RedirectToAction("Index"));
         }
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", "Product already exist");
         OrderDetail newOrderTail = new OrderDetail();
         if (oldProductID == 0)
         {
             newOrderTail.OrderID = model.OrderID;
         }
         else
         {
             newOrderTail = SaleManagementBLL.OrderDetail_Get(model.OrderID, oldProductID);
         }
         return(View(newOrderTail));
         //TempData["orderId"] = model.OrderID;
         //return RedirectToAction("Index");
     }
 }
Exemple #2
0
        public ActionResult Detail(string id = "")
        {
            ViewBag.Title = "Detail Order";
            Order order = SaleManagementBLL.Order_Get(Convert.ToInt32(id));

            ViewData["orderdetail"] = SaleManagementBLL.OrderDetail_Get(Convert.ToInt32(id));
            ViewData["product"]     = CatalogBLL.Product_ListAll();
            ViewData["shipper"]     = CatalogBLL.Shipper_ListAll();
            ViewData["customer"]    = CatalogBLL.Customer_ListAll();
            ViewData["employee"]    = HumanResourceBLL.Employee_ListAll();
            return(View(order));
        }
 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));
     }
 }