Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Ten,Loai,Da_chon,Da_xoa,PhongChieu_ID")] GheModel gheModel)
        {
            if (id != gheModel.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(gheModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GheModelExists(gheModel.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PhongChieu_ID"] = new SelectList(_context.Set <PhongChieuModel>(), "ID", "ID", gheModel.PhongChieu_ID);
            return(View(gheModel));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("IDGhe,IDLG,IDPhong,TenGhe,SoGhe,TrangThai")] GheModel gheModel)
        {
            if (id != gheModel.IDGhe)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(gheModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GheModelExists(gheModel.IDGhe))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IDLG"]    = new SelectList(_context.LoaiGhe, "IDLG", "IDLG", gheModel.IDLG);
            ViewData["IDPhong"] = new SelectList(_context.Phong, "IDPhong", "IDPhong", gheModel.IDPhong);
            return(View(gheModel));
        }
Ejemplo n.º 3
0
        public async Task <bool> Edit(int id, [Bind("ID,Ten,Loai,Da_chon,Da_xoa,PhongChieu_ID")] GheModel gheModel)
        {
            if (id != gheModel.ID)
            {
                return(false);
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(gheModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException err)
                {
                    if (!GheModelExists(gheModel.ID))
                    {
                        return(false);
                    }
                    else
                    {
                        Console.WriteLine(err);
                        return(false);
                    }
                }
                return(true);
            }
            ViewData["PhongChieu_ID"] = new SelectList(_context.Set <PhongChieuModel>(), "ID", "ID", gheModel.PhongChieu_ID);

            return(false);
        }
        // GET: Admin/Ghe
        public async Task <IActionResult> Index(int?id, int?TenHang)
        {
            ViewBag.ListHangGhe = (from a in _context.tb_CumRap
                                   join b in _context.tb_RapPhim on a.Id equals b.MaCumRap
                                   join c in _context.tb_Phong on b.Id equals c.MaRap
                                   join d in _context.tb_HangGhe on c.Id equals d.MaPhong
                                   where a.TrangThai == true
                                   where b.TrangThai == true
                                   where c.TrangThai == true
                                   where d.TrangThai == true
                                   select new
            {
                Id = d.Id,
                Value = "Hàng " + d.TenHang + " - " + c.TenPhong + " - " + b.TenRap + " - " + a.TenCum
            }).ToList();
            //ViewBag.ListHangGhe = _context.tb_HangGhe.Where(m =>  m.TrangThai == true).ToList();
            GheModel ghe = null;

            if (id != null)
            {
                ghe = await _context.tb_Ghe.FirstOrDefaultAsync(n => n.Id == id);
            }
            if (TenHang != 0)
            {
                ViewBag.ListGhe = (from m in _context.tb_Ghe where m.MaHangGhe == TenHang select m).ToList();
            }
            return(View(ghe));
        }
        public async Task <bool> Edit(int id, [Bind("Id,TenGhe,TrangThai,MaHangGhe")] GheModel gheModel)
        {
            if (id != gheModel.Id)
            {
                return(false);
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(gheModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GheModelExists(gheModel.Id))
                    {
                        return(false);
                    }
                    else
                    {
                        throw;
                    }
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 6
0
        public async Task <ActionResult <GheModel> > PostGheModel(GheModel gheModel)
        {
            _context.tb_Ghe.Add(gheModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetGheModel", new { id = gheModel.Id }, gheModel));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> PutGheModel(int id, GheModel gheModel)
        {
            if (id != gheModel.Id)
            {
                return(BadRequest());
            }

            _context.Entry(gheModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GheModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Edit(int id, [Bind("IdGhe,TenGhe,TrangThai,MaLoaiGhe,MaPhong")] GheModel gheModel)
        {
            ViewBag.Username = username;
            if (id != gheModel.IdGhe)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(gheModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GheModelExists(gheModel.IdGhe))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaLoaiGhe"] = new SelectList(_context.loaiGheModels, "IdLoaiGhe", "TenLoaiGhe", gheModel.MaLoaiGhe);
            ViewData["MaPhong"]   = new SelectList(_context.phongModels, "IdPhong", "TenPhong", gheModel.MaPhong);
            return(View(gheModel));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Create([Bind("ID,Ten,Loai,Da_chon,Da_xoa,PhongChieu_ID")] GheModel gheModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(gheModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PhongChieu_ID"] = new SelectList(_context.Set <PhongChieuModel>(), "ID", "ID", gheModel.PhongChieu_ID);
            return(View(gheModel));
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("IDGhe,IDLG,IDPhong,TenGhe,SoGhe,TrangThai")] GheModel gheModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(gheModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IDLG"]    = new SelectList(_context.LoaiGhe, "IDLG", "IDLG", gheModel.IDLG);
            ViewData["IDPhong"] = new SelectList(_context.Phong, "IDPhong", "IDPhong", gheModel.IDPhong);
            return(View(gheModel));
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Create([Bind("IdGhe,TenGhe,TrangThai,MaLoaiGhe,MaPhong")] GheModel gheModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(gheModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaLoaiGhe"] = new SelectList(_context.loaiGheModels, "IdLoaiGhe", "TenLoaiGhe", gheModel.MaLoaiGhe);
            ViewData["MaPhong"]   = new SelectList(_context.phongModels, "IdPhong", "TenPhong", gheModel.MaPhong);
            return(View(gheModel));
        }
        public async Task <IActionResult> Create(int soluong, int idphong)
        {
            ViewBag.ListHangGhe = _context.tb_Phong.Where(m => m.TrangThai == true).ToList();
            for (int i = 1; i <= soluong; i++)
            {
                GheModel ghe = new GheModel();
                ghe.TenGhe    = i;
                ghe.MaHangGhe = idphong;
                ghe.TrangThai = true;
                _context.Add(ghe);
            }
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "Ghe"));
        }
        public async Task <IActionResult> Create([Bind("ID,Ten_rap,Dia_chi,Da_xoa")] RapPhimModel rapPhimModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rapPhimModel);
                await _context.SaveChangesAsync();

                for (int i = 0; i < 3; ++i)
                {
                    PhongChieuModel phongChieu = new PhongChieuModel();
                    phongChieu.Da_xoa     = false;
                    phongChieu.Ten_Phong  = "P" + i.ToString();
                    phongChieu.RapPhim_ID = rapPhimModel.ID;
                    _context.PhongChieuModel.Add(phongChieu);
                    await _context.SaveChangesAsync();

                    for (int j = 0; j < 90; ++j)
                    {
                        GheModel ghe = new GheModel();
                        ghe.Da_xoa  = false;
                        ghe.Da_chon = false;
                        ghe.Ten     = (char)((j / 10) + 'A') + (j % 10).ToString();
                        if ((j / 10 >= 2) &&
                            (j / 10 <= 6) &&
                            (j % 10 >= 2) &&
                            (j % 10 <= 7))
                        {
                            ghe.Loai = 1;
                        }
                        else
                        {
                            ghe.Loai = 0;
                        }

                        ghe.PhongChieu_ID = phongChieu.ID;
                        _context.GheModel.Add(ghe);
                        await _context.SaveChangesAsync();
                    }
                }
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(rapPhimModel));
        }
Ejemplo n.º 14
0
        public async Task <IActionResult> Create([Bind("ID,Ten_Phong,Da_xoa,RapPhim_ID")] PhongChieuModel phongChieuModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(phongChieuModel);
                await _context.SaveChangesAsync();

                for (int j = 0; j < 90; ++j)
                {
                    GheModel ghe = new GheModel();
                    ghe.Da_xoa  = false;
                    ghe.Da_chon = false;
                    ghe.Ten     = (char)((j / 10) + 'A') + (j % 10).ToString();
                    if ((j / 10 >= 2) &&
                        (j / 10 <= 6) &&
                        (j % 10 >= 2) &&
                        (j % 10 <= 7))
                    {
                        ghe.Loai = 1;
                    }
                    else
                    {
                        ghe.Loai = 0;
                    }

                    ghe.PhongChieu_ID = phongChieuModel.ID;
                    _context.GheModel.Add(ghe);
                    await _context.SaveChangesAsync();
                }
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RapPhim_ID"] = new SelectList(_context.Set <RapPhimModel>(), "ID", "ID", phongChieuModel.RapPhim_ID);
            return(View(phongChieuModel));
        }