Пример #1
0
        public static List <HoTroLayBDThi> LayBDThi(int maBD)
        {
            List <HoTroLayBDThi> lstHTT = new List <HoTroLayBDThi>();

            if (Program.KetNoi() == 0)
            {
                return(null);
            }
            SqlDataReader myReader;

            myReader = Program.ExecSqlDataReader(string.Format(KeyConst.Lenh.LayCauHoiThi, maBD));
            if (myReader == null)
            {
                return(null);
            }
            HoTroLayBDThi ht = new HoTroLayBDThi();

            while (myReader.Read())
            {
                ht = new HoTroLayBDThi
                {
                    MaCauHoi = myReader.GetInt32(0),
                    SoTT     = myReader.GetInt32(1)
                };
                lstHTT.Add(ht);
            }
            myReader.Close();
            return(lstHTT);
        }
Пример #2
0
        private void FormThi_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dtsTTN.CT_BAITHI' table. You can move, or remove it, as needed.
            this.cT_BAITHITableAdapter.Fill(this.dtsTTN.CT_BAITHI);
            bANGDIEMTableAdapter.Fill(this.dtsTTN.BANGDIEM);
            MyTimer.Interval = (1000); // 1 mins
            MyTimer.Tick    += new EventHandler(t_Tick);
            MyTimer.Start();

            if (MaBD != -1)
            {
                BDThiTam = BoDe.LayBDThi(MaBD);
                if (BDThi == null)
                {
                    return;
                }
                CAUHOITHI = new List <HoTroLayCauHoiThi>();
                HoTroLayCauHoiThi htCHThi  = null;
                Panel             pnCauHoi = null;
                int i = BDThiTam.Count;
                while (BDThiTam.Count != 0)
                {
                    htCHThi = new HoTroLayCauHoiThi();
                    int           r  = rnd.Next(BDThiTam.Count);
                    HoTroLayBDThi ht = BDThiTam[r];
                    BDThi.Add(ht);
                    CAUHOI         cauHoi  = CauHoi.GetCauHoiByMaCH(ht.MaCauHoi);
                    List <LUACHON> luachon = CauHoi.GetLuaChonByMaCH(ht.MaCauHoi);

                    pnCauHoi          = new Panel();
                    pnCauHoi.AutoSize = true;
                    pnCauHoi.Dock     = DockStyle.Top;

                    Label lb = new Label();
                    lb.AutoSize = true;
                    FontStyle newFontStyle = (FontStyle)(FontStyle.Bold);
                    lb.Font = new Font("Times New Rowman", 25, newFontStyle);
                    lb.Text = "Câu " + i + " : " + cauHoi.NOIDUNG;

                    RadioButton rGLuaChon = null;

                    foreach (LUACHON lc in luachon)
                    {
                        rGLuaChon          = new RadioButton();
                        rGLuaChon.AutoSize = true;
                        rGLuaChon.Name     = lc.MALC.Trim() + "-" + cauHoi.MACH.ToString().Trim();
                        rGLuaChon.Font     = new Font("Times New Rowman", 25, newFontStyle);
                        // update dap an neu thay doi lua chon
                        rGLuaChon.CheckedChanged += new EventHandler(LuaChon_Click);
                        //rGLuaChon.Add(new RadioGroupItem(lc.MALC.ToString(), "Câu " + lc.MALC.ToString() + " : " + lc.NOIDUNG));
                        rGLuaChon.Text = "Câu " + lc.MALC.ToString() + " : " + lc.NOIDUNG;
                        rGLuaChon.Dock = DockStyle.Bottom;
                        rGLuaChon.Focus();
                        pnCauHoi.Controls.Add(rGLuaChon);
                    }

                    lb.Dock = DockStyle.Top;
                    pnCauHoi.Controls.Add(lb);
                    pnThi.Controls.Add(pnCauHoi);

                    htCHThi.MaCH      = cauHoi.MACH;
                    htCHThi.STT       = ht.SoTT;
                    htCHThi.DapAn     = cauHoi.DAPAN;
                    htCHThi.STTKhiThi = i - 1;

                    CAUHOITHI.Add(htCHThi);
                    BDThiTam.RemoveAt(r);
                    i--;
                }
            }
            pnThi.AllowDrop  = true;
            pnThi.AutoScroll = true;
        }