コード例 #1
0
        private CauHoi questions()
        {
            CauHoi cauHoi = new CauHoi();

            try
            {
                connect.conn.Close();
                hienThiDuLieuLenDataGridView(count);
                demCauHoiTheoDoKho(count);
                Random rand = new Random();
                int    x    = rand.Next(0, countCauHoi);
                if (x < countCauHoi)
                {
                    cauHoi.cauHoi1 = dataGridView1.Rows[x].Cells[1].Value.ToString();
                    cauHoi.dapAn_A = dataGridView1.Rows[x].Cells[2].Value.ToString();
                    cauHoi.dapAn_B = dataGridView1.Rows[x].Cells[3].Value.ToString();
                    cauHoi.dapAn_C = dataGridView1.Rows[x].Cells[4].Value.ToString();
                    cauHoi.dapAn_D = dataGridView1.Rows[x].Cells[5].Value.ToString();
                    cauHoi.dapAn   = dataGridView1.Rows[x].Cells[6].Value.ToString();
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Thất Bại");
                ex.ToString();
            }
            return(cauHoi);
        }
コード例 #2
0
        private void hienThiCauHoi()
        {
            CauHoi ch = new CauHoi();

            ch              = questions();
            IDCauHoi.Text   = ch.idcauhoi;
            txtCauHoi.Text  = ch.cauHoi1;
            btnDapAn_A.Text = ch.dapAn_A;
            btnDapAn_B.Text = ch.dapAn_B;
            btnDapAn_C.Text = ch.dapAn_C;
            btnDapAn_D.Text = ch.dapAn_D;
            this.dapan      = ch.dapAn;
        }