示例#1
0
 public ActionResult Edit([Bind(Include = "OrderID,ProductID,ProductName,PricePresent,Quantity,TotalMoney")] Order_Details order_Details)
 {
     if (ModelState.IsValid)
     {
         if (!Regex.IsMatch(order_Details.PricePresent.ToString(), @"^\d+$") || !Regex.IsMatch(order_Details.TotalMoney.ToString(), @"^\d+$"))
         {
             return(View(order_Details));
         }
         db.Entry(order_Details).State = EntityState.Modified;
         var    order    = db.Orders.SingleOrDefault(x => x.OrderID == order_Details.OrderID);
         var    lst      = db.Order_Details.Where(x => x.OrderID == order.OrderID).ToList();
         double tongtien = 0;
         foreach (Order_Details item in lst)
         {
             tongtien += (double)item.TotalMoney;
         }
         order.TotalMoney      = tongtien;
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", "/Order_Details", new { idOrder = order_Details.OrderID }));
     }
     ViewBag.OrderID   = new SelectList(db.Orders, "OrderID", "CustomerID", order_Details.OrderID);
     ViewBag.ProductID = new SelectList(db.Products, "ProductID", "ProductName", order_Details.ProductID);
     return(View(order_Details));
 }
 public ActionResult Edit([Bind(Include = "CategoryFatherID,CategoryName,icon")] Category_Fathers category_Fathers)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category_Fathers).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category_Fathers));
 }
示例#3
0
 public ActionResult Edit([Bind(Include = "TenVT,MoTa")] VaiTros vaiTros)
 {
     if (ModelState.IsValid)
     {
         db.Entry(vaiTros).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(vaiTros));
 }
 public ActionResult Edit([Bind(Include = "id,name,email,adress,contents,phone,date,status")] Lienlac lienlac)
 {
     if (ModelState.IsValid)
     {
         db.Entry(lienlac).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(lienlac));
 }
示例#5
0
 public ActionResult Edit([Bind(Include = "CategoryChildID,CategoryName,CategoryFatherID")] Category_Childs category_Childs)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category_Childs).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", "Category_Childs", new { idcha = category_Childs.CategoryFatherID }));
     }
     ViewBag.CategoryFatherID = new SelectList(db.Category_Fathers, "CategoryFatherID", "CategoryName", category_Childs.CategoryFatherID);
     return(View(category_Childs));
 }
        public ActionResult Edit(Employees employees)
        {
            if (ModelState.IsValid)
            {
                db.Entry(employees).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.a = db.VaiTros.ToList();

            return(View(employees));
        }
        public ActionResult Edit([Bind(Include = "CustomerID,Address,CustomerName,TenDN,Email,MatKhau,phonenumber,Picture")] Customers customers)
        {
            // khoi doi tuong
            //giong ham main
            if (ModelState.IsValid)
            {
                db.Entry(customers).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(customers));
        }