Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked == true)
            {
                selectedvalue = radioButton1.Text;
            }
            else if (radioButton2.Checked == true)
            {
                selectedvalue = radioButton2.Text;
            }
            else if (radioButton3.Checked == true)
            {
                selectedvalue = radioButton3.Text;
            }
            else if (radioButton4.Checked == true)
            {
                selectedvalue = radioButton4.Text;
            }

            else
            {
                MessageBox.Show("Select One Option");
            }


            if (selectedvalue.Equals(correctop))
            {
                score++;
                label3.Text = score.ToString();
            }


            s = rc.scalerReturn("select min(q_id) from questions where q_id>" + i + "and q_fk_ex=" + studentlogin.exam_id);
            if (s.Equals(""))
            {
                MessageBox.Show("Quiz Over!");
                button1.Enabled = false;
                MessageBox.Show("Your Score is " + score);
                studentmarks ss = new studentmarks();
                ss.marks = score.ToString();
                SqlConnection conn = new SqlConnection(connstring);
                conn.Open();
                SqlCommand cmd = new SqlCommand("insert into studentmarks values('" + (ss.ID + 1) + "', '" + ss.marks + "','" + "asghar" + "' )", conn);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Data Inserted Successfully.");
                conn.Close();
            }
            else
            {
                i                 = Convert.ToInt32(s);
                label1.Text       = rc.scalerReturn("select q_title from questions where q_id=" + i + "and q_fk_ex=" + studentlogin.exam_id);
                radioButton1.Text = rc.scalerReturn("select q_opa from questions where q_id=" + i + "and q_fk_ex=" + studentlogin.exam_id);
                radioButton2.Text = rc.scalerReturn("select q_opb from questions where q_id=" + i + "and q_fk_ex=" + studentlogin.exam_id);
                radioButton3.Text = rc.scalerReturn("select q_opc from questions where q_id=" + i + "and q_fk_ex=" + studentlogin.exam_id);
                radioButton4.Text = rc.scalerReturn("select q_opd from questions where q_id=" + i + "and q_fk_ex=" + studentlogin.exam_id);
                correctop         = rc.scalerReturn("select q_opcorrect from questions where q_id=" + i + "and q_fk_ex=" + studentlogin.exam_id);
            } radiobtn();
        }
Example #2
0
        private void studentlogin_Load(object sender, EventArgs e)
        {
            studentmarks obj = new studentmarks();

            user = obj.ID;


            SqlDataAdapter dadpter2 = new SqlDataAdapter("select * from exams", "Data Source=DESKTOP-B6M2MNK\\SQLEXPRESS;Initial Catalog=quizapp;Integrated Security=True");
            DataSet        dset2    = new DataSet();

            dadpter2.Fill(dset2);
            comboBox1.DataSource    = dset2.Tables[0];
            comboBox1.DisplayMember = "exam_name";
            comboBox1.ValueMember   = "ex_id";
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            studentmarks obj = new studentmarks();

            obj.Show();
        }