public ActionResult Create([Bind(Include = "Magiay,Manhacc,Manhasx,Maloaigiay,Tengiay,Soluongton,Giaban,Hinhanh,Mota")] Giay giay, HttpPostedFileBase UploadImage) { if (ModelState.IsValid) { if (UploadImage != null) { if (UploadImage.ContentType == "image/jpg" || UploadImage.ContentType == "image/png" || UploadImage.ContentType == "image/jpeg") { UploadImage.SaveAs(Server.MapPath("/") + "/Content/img_product/" + UploadImage.FileName); giay.Hinhanh = UploadImage.FileName; } else { return(View()); } } else { return(View()); } db.Giays.Add(giay); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Maloaigiay = new SelectList(db.LoaiGiays, "Maloaigiay", "Tenloaigiay", giay.Maloaigiay); ViewBag.Manhacc = new SelectList(db.NhaCungCaps, "Manhacc", "Tennhacc", giay.Manhacc); ViewBag.Manhasx = new SelectList(db.NhaSanXuats, "Manhasx", "Tennhasx", giay.Manhasx); return(View(giay)); }
public ActionResult Create([Bind(Include = "Maloaigiay,Tenloaigiay")] LoaiGiay loaiGiay) { if (ModelState.IsValid) { db.LoaiGiays.Add(loaiGiay); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(loaiGiay)); }
public ActionResult Create([Bind(Include = "Madh,Makh,Tendh,Ngaydat,Ngaygiao,Tinhtranggh,Dathanhtoan")] DonHang donHang) { if (ModelState.IsValid) { db.DonHangs.Add(donHang); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(donHang)); }
public ActionResult Create([Bind(Include = "Manhasx,Tennhasx,Diachi,Sdt,Website")] NhaSanXuat nhaSanXuat) { if (ModelState.IsValid) { db.NhaSanXuats.Add(nhaSanXuat); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nhaSanXuat)); }
public ActionResult Create([Bind(Include = "Mamau,Tenmau")] Mau mau) { if (ModelState.IsValid) { db.Maus.Add(mau); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(mau)); }
public ActionResult Create([Bind(Include = "Matk,Tentk,Matkhau")] TaiKhoan taiKhoan) { if (ModelState.IsValid) { db.TaiKhoans.Add(taiKhoan); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(taiKhoan)); }
public ActionResult Create([Bind(Include = "Masize,Sosize")] Size size) { if (ModelState.IsValid) { db.Sizes.Add(size); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(size)); }
//Thêm mới public int AddBill(Bill model) { Bill db = shopModel.Bills.Find(model.id); if (db != null) { return(-1); } shopModel.Bills.Add(model); shopModel.SaveChanges(); return(model.id); }
//Thêm mới public bool AddBill_Details(Bill_Details model) { Bill_Details db = shopModel.Bill_Details.Find(model.id); if (db != null) { return(false); } shopModel.Bill_Details.Add(model); shopModel.SaveChanges(); return(true); }
//Thêm mới public bool AddProduct(Product model) { Product db = shopModel.Products.Find(model.id); if (db != null) { return(false); } shopModel.Products.Add(model); shopModel.SaveChanges(); return(true); }
//Thêm mới public bool AddBrand(Brand model) { Brand db = shopModel.Brands.Find(model.id); if (db != null) { return(false); } shopModel.Brands.Add(model); shopModel.SaveChanges(); return(true); }
//Thêm mới public bool AddUser(UserLogin model) { UserLogin db = shopModel.UserLogins.Find(model.account); if (db != null) { return(false); } shopModel.UserLogins.Add(model); shopModel.SaveChanges(); return(true); }
//Thêm mới public bool AddSale(Sale model) { Sale db = shopModel.Sales.Find(model.id); if (db != null) { return(false); } shopModel.Sales.Add(model); shopModel.SaveChanges(); return(true); }
//Thêm mới public bool AddColor(Color model) { Color db = shopModel.Colors.Find(model.id); if (db != null) { return(false); } shopModel.Colors.Add(model); shopModel.SaveChanges(); return(true); }
//Thêm mới public bool Addstype(stype model) { stype db = shopModel.stypes.Find(model.id); if (db != null) { return(false); } shopModel.stypes.Add(model); shopModel.SaveChanges(); return(true); }
public ActionResult Create([Bind(Include = "Mamau,Magiay,Ghichu")] ChiTietMau chiTietMau) { if (ModelState.IsValid) { db.ChiTietMaus.Add(chiTietMau); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Magiay = new SelectList(db.Giays, "Magiay", "Tengiay", chiTietMau.Magiay); ViewBag.Mamau = new SelectList(db.Maus, "Mamau", "Tenmau", chiTietMau.Mamau); return(View(chiTietMau)); }
public ActionResult Create([Bind(Include = "Magiay,Manhacc,Manhasx,Maloaigiay,Tengiay,Soluongton,Giaban,Mau,Size,Hinhanh")] Giay giay) { if (ModelState.IsValid) { db.Giays.Add(giay); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Maloaigiay = new SelectList(db.LoaiGiays, "Maloaigiay", "Tenloaigiay", giay.Maloaigiay); ViewBag.Manhacc = new SelectList(db.NhaCungCaps, "Manhacc", "Tennhacc", giay.Manhacc); ViewBag.Manhasx = new SelectList(db.NhaSanXuats, "Manhasx", "Tennhasx", giay.Manhasx); return(View(giay)); }
public ActionResult AddOrEdit(Order ord) { using (ShopModel db = new ShopModel()) { if (ord.Id == 0) { db.Orders.Add(ord); db.SaveChanges(); return(Json(new { success = true, message = "Order Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(ord).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Order Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult AddOrEdit(Product pro) { using (ShopModel db = new ShopModel()) { if (pro.Id == 0) { db.Products.Add(pro); db.SaveChanges(); return(Json(new { success = true, message = "Product Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(pro).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Product Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult Delete(int id) { using (ShopModel db = new ShopModel()) { Order ord = db.Orders.Where(x => x.Id == id).FirstOrDefault <Order>(); db.Orders.Remove(ord); db.SaveChanges(); return(Json(new { success = true, message = "Order Deleted Successfully" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Delete(int id) { using (ShopModel db = new ShopModel()) { Product pro = db.Products.Where(x => x.Id == id).FirstOrDefault <Product>(); db.Products.Remove(pro); db.SaveChanges(); return(Json(new { success = true, message = "Product Deleted Successfully" }, JsonRequestBehavior.AllowGet)); } }
public void Save() { context.SaveChanges(); }