Beispiel #1
0
 public ActionResult DeleteMaGiamGia(int id, PhieuGiamGia phieuGiamGia)
 {
     phieuGiamGia = db.PhieuGiamGias.Where(x => x.MaGiamGia == id).SingleOrDefault();
     db.PhieuGiamGias.Remove(phieuGiamGia);
     db.SaveChanges();
     return(RedirectToAction("GiamGia", "Admin"));
 }
Beispiel #2
0
 public ActionResult GiamGia(FormCollection frm,PhieuGiamGia phieuGiamGia)
 {
     Session["loi"] = null;
     string MaGiamGia1 = frm["txtmagiamgia"];
         var MaGiamGia = db.PhieuGiamGias.Where(x => x.GiamGia == MaGiamGia1).SingleOrDefault();
         if (db.PhieuGiamGias.Where(x => x.GiamGia == MaGiamGia1).SingleOrDefault()!=null/*MaGiamGia.SoLuong > 0/* && MaGiamGia.MucGiamGia !=null*/ /*&& MaGiamGia.ThoiGianKetThucGiamGia<DateTime.Now*/)
         {
             Session["giamgia"] = MaGiamGia.MucGiamGia;
             int a = Convert.ToInt32(MaGiamGia.MucGiamGia);
             int b = (int.Parse(Session["TongTien"].ToString()));
             int c = b - ((a * b) / 100);
             Session["TongTien1"] = c.ToString();
             Session["TongTien"] = c.ToString();
             MaGiamGia.SoLuong--;
             db.Entry(MaGiamGia).State = EntityState.Modified;
             db.SaveChanges();
             return RedirectToAction("GioHang");
         }
         else
         {
         Session["giamgia"] = null;
         Session["loi"] = "Code hết hạn sử dụng hoặc đã hết lượt!";
         return RedirectToAction("GioHang");
         }
 }
Beispiel #3
0
 public ActionResult ThemPhieuGiamGia(FormCollection frm, PhieuGiamGia phieuGiamGia)
 {
     try
     {
         phieuGiamGia.GiamGia = frm["GiamGia"];
         phieuGiamGia.ThoiGianBatDauGiamGia  = DateTime.Parse(DateTime.Now.ToString());
         phieuGiamGia.ThoiGianKetThucGiamGia = DateTime.Parse(DateTime.Now.ToString());
         phieuGiamGia.MucGiamGia             = int.Parse(frm["MucGiamGia"]);
         phieuGiamGia.SoLuong    = int.Parse(frm["SoLuong"]);
         phieuGiamGia.TenGiamGia = frm["TenGiamGia"];
         db.PhieuGiamGias.Add(phieuGiamGia);
         db.SaveChanges();
         return(RedirectToAction("GiamGia", "Admin"));
     }
     catch (Exception ex)
     {
     }
     return(View());
 }
Beispiel #4
0
        // Xóa Mã Giảm Giá
        public ActionResult DeleteMaGiamGia(int?id)
        {
            PhieuGiamGia bv = db.PhieuGiamGias.Find(id);

            return(View(bv));
        }