public List <KHUYEN_MAI> getAllKhuyenMai1(int id) { connectdb = new ConnectDb(); List <KHUYEN_MAI> list = new List <KHUYEN_MAI>(); SqlCommand cmd = new SqlCommand("getAllKhuyenMai", connectdb.conn); cmd.CommandType = CommandType.StoredProcedure; sdr = cmd.ExecuteReader(); while (sdr.Read()) { KHUYEN_MAI item_khuyenmai = new KHUYEN_MAI(); if (id == (int)sdr["MAKHUYENMAI"]) { item_khuyenmai.MAKHUYENMAI = (int)sdr["MAKHUYENMAI"]; item_khuyenmai.TIEUDEKHUYENMAI = (string)sdr["TIEUDEKHUYENMAI"]; item_khuyenmai.NOIDUNGKHUYENMAI = (string)sdr["NOIDUNGKHUYENMAI"]; item_khuyenmai.URLANH = (string)sdr["URLANH"]; item_khuyenmai.THOIGIANTAO = (DateTime)sdr["THOIGIANTAO"]; item_khuyenmai.NGUOITAO = (string)sdr["NGUOITAO"]; list.Add(item_khuyenmai); } } return(list); }
public ActionResult DeleteConfirmed(Guid id) { KHUYEN_MAI kHUYEN_MAI = db.KHUYEN_MAI.Find(id); db.KHUYEN_MAI.Remove(kHUYEN_MAI); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "MA_KM,TEN_KM,SO_MON_DK,TIEN_GIAM")] KHUYEN_MAI kHUYEN_MAI) { if (ModelState.IsValid) { db.Entry(kHUYEN_MAI).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(kHUYEN_MAI)); }
public ActionResult Create(FormCollection f) { KHUYEN_MAI km = new KHUYEN_MAI(); km.MA_KM = Guid.NewGuid(); km.TEN_KM = f["name"]; km.SO_MON_DK = int.Parse(f["somon"]); km.TIEN_GIAM = int.Parse(f["phantramgiam"]); db.KHUYEN_MAI.Add(km); db.SaveChanges(); return(View()); }
// GET: Admin/KHUYEN_MAI/Delete/5 public ActionResult Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } KHUYEN_MAI kHUYEN_MAI = db.KHUYEN_MAI.Find(id); if (kHUYEN_MAI == null) { return(HttpNotFound()); } return(View(kHUYEN_MAI)); }