public ActionResult Edit([Bind(Include = "MaDH,MaKH,TongTien,NgayDat,NgayGiao,LuuY,TinhTrang,Sdt,DiaChi")] DonHang donHang) { if (ModelState.IsValid) { db.Entry(donHang).State = EntityState.Modified; TongTienDH(donHang.MaDH); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaKH = new SelectList(db.User, "MaKH", "Hoten", donHang.MaKH); return(View(donHang)); }
public ActionResult Edit([Bind(Include = "MaDH,MaSP,SoLuong,DonGia")] ChiTietDonHang chiTietDonHang) { if (ModelState.IsValid) { db.Entry(chiTietDonHang).State = EntityState.Modified; db.SaveChanges(); Url.Action("TongTienDH", "DonHang", new { maDH = chiTietDonHang.MaDH }); return(RedirectToAction("Details", "DonHang", new { id = chiTietDonHang.MaDH })); } ViewBag.MaDH = new SelectList(db.DonHang, "MaDH", "LuuY", chiTietDonHang.MaDH); ViewBag.MaSP = new SelectList(db.SanPham, "MaSP", "TenSP", chiTietDonHang.MaSP); return(View(chiTietDonHang)); }
public ActionResult Edit([Bind(Include = "MaLoai,TenLoai,Anh")] LoaiSp loaiSp) { if (ModelState.IsValid) { if ((db.LoaiSp.Any(k => k.TenLoai == loaiSp.TenLoai)) && (db.LoaiSp.Any(k => k.MaLoai != loaiSp.MaLoai))) { ViewBag.ThongBao = "Loại sản phẩm đã tồn tại"; } else { db.Entry(loaiSp).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(loaiSp)); }
public ActionResult Edit([Bind(Include = "MaNCC,TenNCC,DiaChi")] NhaCungCap nhaCungCap) { if (ModelState.IsValid) { if ((db.NhaCungCap.Any(k => k.TenNCC == nhaCungCap.TenNCC)) && (db.NhaCungCap.Any(k => k.MaNCC != nhaCungCap.MaNCC))) { ViewBag.ThongBao = "Nhà cung cấp đã tồn tại"; } else { db.Entry(nhaCungCap).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(nhaCungCap)); }
public ActionResult Edit([Bind(Include = "MaKH,Hoten,Username,MatKhau,Email,DienThoai,GioiTinh,NgaySinh,DiaChi")] User user) { if (ModelState.IsValid) { if ((db.User.Any(k => k.Username == user.Username)) && (db.User.Any(k => k.MaKH != user.MaKH))) { ViewBag.ThongBao = "Người dùng đã tồn tại"; } else { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(user)); }
public ActionResult Edit([Bind(Include = "MaSP,TenSP,GiaBan,MoTa,NgayCapNhat,SoLuongCon,MaLoai,NhaCungCap,HanSuDung")] SanPham sanPham) { if (ModelState.IsValid) { if ((db.SanPham.Any(k => k.TenSP == sanPham.TenSP)) && (db.SanPham.Any(k => k.MaSP != sanPham.MaSP))) { ViewBag.ThongBao = "Sản phẩm đã tồn tại"; } else { db.Entry(sanPham).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } ViewBag.MaLoai = new SelectList(db.LoaiSp, "MaLoai", "TenLoai", sanPham.MaLoai); ViewBag.NhaCungCap = new SelectList(db.NhaCungCap, "MaNCC", "TenNCC", sanPham.NhaCungCap); return(View(sanPham)); }
public ActionResult Edit([Bind(Include = "MaSP,TenSP,GiaBan,MoTa,NgayCapNhat,SoLuongCon,MaLoai,NhaCungCap,HanSuDung")] SanPham sanPham) { if (ModelState.IsValid) { db.Entry(sanPham).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } //var TenMaLoai = from sp in db.SanPham // join lsp in db.LoaiSp // on sp.MaLoai equals lsp.MaLoai // select lsp.TenLoai; //var TenNCC = from sp in db.SanPham // join ncc in db.NhaCungCap // on sp.NhaCungCap equals ncc.MaNCC // select ncc.TenNCC; //ViewBag.MaLoai = new SelectList(TenMaLoai); //ViewBag.NhaCungCap = new SelectList(TenNCC); ViewBag.MaLoai = new SelectList(db.LoaiSp, "MaLoai", "TenLoai", sanPham.MaLoai); ViewBag.NhaCungCap = new SelectList(db.NhaCungCap, "MaNCC", "TenNCC", sanPham.NhaCungCap); return(View(sanPham)); }