Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("CauHoiId,ThiId,Ten")] CauHoiThi cauHoiThi)
        {
            if (id != cauHoiThi.CauHoiId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cauHoiThi);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CauHoiThiExists(cauHoiThi.CauHoiId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CauHoiId"] = new SelectList(_context.CauHoi, "Id", "Id", cauHoiThi.CauHoiId);
            ViewData["ThiId"]    = new SelectList(_context.This, "Id", "Ten", cauHoiThi.ThiId);
            return(View(cauHoiThi));
        }
Exemplo n.º 2
0
        private void load_cauhoi()
        {
            CauHoiThi ch = bll.getCauHoi(socauhoi);

            lb_cauhoi.Text = ch.noidung;
            rb_A.Text      = ch.dapanA;
            rb_B.Text      = ch.dapanB;
            rb_C.Text      = ch.dapanC;
            rb_D.Text      = ch.dapanD;

            if (ch.choice != null)
            {
                if (ch.choice.Trim() == "A")
                {
                    rb_A.Checked = true;
                }
                else if (ch.choice.Trim() == "B")
                {
                    rb_B.Checked = true;
                }
                else if (ch.choice.Trim() == "C")
                {
                    rb_C.Checked = true;
                }
                else if (ch.choice.Trim() == "D")
                {
                    rb_D.Checked = true;
                }
            }
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("CauHoiId,ThiId,Ten")] CauHoiThi cauHoiThi)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cauHoiThi);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CauHoiId"] = new SelectList(_context.CauHoi, "Id", "Ten");
            ViewData["ThiId"]    = new SelectList(_context.This, "Id", "Ten");
            return(View(cauHoiThi));
        }
Exemplo n.º 4
0
        public CauHoiThi getCH(int socauhoi)
        {
            CauHoiThi ch = new CauHoiThi();
            var       c  = db.CauHois.Where(p => p.MaCH == socauhoi).Select(p => p);

            foreach (var i in c)
            {
                ch.id_cauhoi = i.MaCH;
                ch.noidung   = i.NoiDung;
                ch.dapanA    = i.DapanA;
                ch.dapanB    = i.DapanB;
                ch.dapanC    = i.DapanC;
                ch.dapanD    = i.DapanD;
                ch.dapanDung = i.DapanDung;
                ch.choice    = i.Choice;
            }
            return(ch);
        }