예제 #1
0
 public ActionResult EditPhim(string id, phim phim)
 {
     if (!AuthCheck("admin"))
     {
         return(RedirectToAction("Index", "QLHome"));
     }
     db.Entry(phim).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("QLPhim"));
 }
예제 #2
0
 public ActionResult Register(khach_hang khachHang)
 {
     try
     {
         database.khach_hang.Add(khachHang);
         khachHang.ngay_dang_ky = DateTime.Today;
         database.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         return(Content(e.ToString()));
     }
 }
        public ActionResult Update_DDP(FormCollection form)
        {
            if (!AuthCheck("admin"))
            {
                return(RedirectToAction("Index", "QLHome"));
            }
            string         id  = form["idDDP_edit"].ToString();
            dinh_dang_phim ddp = db.dinh_dang_phim.Where(item => item.id == id).FirstOrDefault();

            ddp.phu_thu = int.Parse(form["phuthuDDP_edit"]);
            ddp.ten     = form["tenDDP_edit"];
            db.SaveChanges();
            return(Redirect(Url.Action("Index", "QLSetting") + "#DDP"));
        }
예제 #4
0
        public static void TicketCheck()
        {
            QLBanVePhimEntities db = new QLBanVePhimEntities();
            var  dsve = db.ve_ban.Where(s => s.trang_thai == "Book").ToList();
            bool flag = false;

            foreach (ve_ban ve in dsve)
            {
                DateTime ngChieu  = (DateTime)ve.suat_chieu.ngay_chieu;
                TimeSpan gioChieu = (TimeSpan)ve.suat_chieu.gio_bat_dau;
                if (ngChieu.Date < DateTime.Today)
                {
                    flag = true;
                }
                else if (ngChieu.Date == DateTime.Today)
                {
                    if (DateTime.Now.TimeOfDay >= gioChieu)
                    {
                        flag = true;
                    }
                }

                if (flag)
                {
                    ve.ghe_ngoi.da_chon = false;
                    ve.trang_thai       = "Cancelled";
                }
            }
            db.SaveChanges();
        }
예제 #5
0
        private static void InitDataGenerator(string type)
        {
            QLBanVePhimEntities db = new QLBanVePhimEntities();

            switch (type)
            {
            case "GiaVe":
                if (db.gia_ve.Where(x => x.id == "WEEKDAY").ToList().Count() == 0)
                {
                    gia_ve gv = new gia_ve();
                    gv.id      = "WEEKDAY";
                    gv.ten     = "Ngay Thuong";
                    gv.don_gia = 50000;
                    db.gia_ve.Add(gv);
                }

                if (db.gia_ve.Where(x => x.id == "WEEKEND").ToList().Count() == 0)
                {
                    gia_ve gv2 = new gia_ve();
                    gv2.id      = "WEEKEND";
                    gv2.ten     = "Cuoi Tuan";
                    gv2.don_gia = 70000;
                    db.gia_ve.Add(gv2);
                }

                db.SaveChanges();
                break;

            case "LoaiGhe":
                if (db.loai_ghe.Where(x => x.id == "NORMAL").ToList().Count() == 0)
                {
                    loai_ghe lg = new loai_ghe();
                    lg.id      = "NORMAL";
                    lg.ten_ghe = "Normal";
                    lg.phu_thu = 0;
                    db.loai_ghe.Add(lg);
                }
                if (db.loai_ghe.Where(x => x.id == "VIP").ToList().Count() == 0)
                {
                    loai_ghe lg2 = new loai_ghe();
                    lg2.id      = "VIP";
                    lg2.ten_ghe = "VIP";
                    lg2.phu_thu = 0;
                    db.loai_ghe.Add(lg2);
                }

                db.SaveChanges();
                break;

            case "FoodSize":
                if (db.kich_co_do_an.Where(x => x.id == "S").ToList().Count() == 0)
                {
                    kich_co_do_an fs = new kich_co_do_an
                    {
                        id  = "S",
                        ten = "Nhỏ"
                    };
                    db.kich_co_do_an.Add(fs);
                }
                if (db.kich_co_do_an.Where(x => x.id == "M").ToList().Count() == 0)
                {
                    kich_co_do_an fs2 = new kich_co_do_an
                    {
                        id  = "M",
                        ten = "Vừa"
                    };
                    db.kich_co_do_an.Add(fs2);
                }
                if (db.kich_co_do_an.Where(x => x.id == "L").ToList().Count() == 0)
                {
                    kich_co_do_an fs3 = new kich_co_do_an
                    {
                        id  = "L",
                        ten = "Lớn"
                    };
                    db.kich_co_do_an.Add(fs3);
                }

                db.SaveChanges();
                break;

            case "DDP":
                if (db.dinh_dang_phim.Where(x => x.id == "2d").ToList().Count() == 0)
                {
                    dinh_dang_phim ddp = new dinh_dang_phim
                    {
                        id      = "2d",
                        ten     = "2D",
                        phu_thu = 0
                    };
                    db.dinh_dang_phim.Add(ddp);
                }
                if (db.dinh_dang_phim.Where(x => x.id == "3d").ToList().Count() == 0)
                {
                    dinh_dang_phim ddp2 = new dinh_dang_phim
                    {
                        id      = "3d",
                        ten     = "3D",
                        phu_thu = 20000
                    };
                    db.dinh_dang_phim.Add(ddp2);
                }

                db.SaveChanges();
                break;

            default:
                break;
            }
        }
예제 #6
0
 public ActionResult AddNV(nguoi_dung _ngdung)
 {
     if (!AuthCheck("admin"))
     {
         return(RedirectToAction("Index"));
     }
     try
     {
         _ngdung.dang_lam     = true;
         _ngdung.ngay_vao_lam = DateTime.Now;
         db.nguoi_dung.Add(_ngdung);
         db.SaveChanges();
         return(RedirectToAction("QLNV"));
     }
     catch (Exception e)
     {
         ViewBag.Error = e.ToString();
         return(View("~/Views/QLHome/Error.cshtml"));
     }
 }
예제 #7
0
 public ActionResult AddDoAn(do_an_chi_tiet _dact)
 {
     if (!AuthCheck("admin"))
     {
         return(RedirectToAction("Index", "QLDoAn"));
     }
     try
     {
         do_an _da = new do_an
         {
             id            = _dact.do_an.id,
             ten           = _dact.do_an.ten,
             dang_ban      = true,
             hinh_anh      = _dact.do_an.hinh_anh,
             loai_do_an_id = _dact.do_an.loai_do_an_id
         };
         _dact.do_an_id       = _da.id;
         _dact.id             = _da.id + "_" + _dact.kich_co_do_an_id;
         _dact.dang_ban       = true;
         _dact.do_an.dang_ban = true;
         db.do_an_chi_tiet.Add(_dact);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         ViewBag.Error = e.ToString();
         return(View("~/Views/QLHome/Error.cshtml"));
     }
 }