Ejemplo n.º 1
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        Table m = Table1;



        List <List <string> > questions = new List <List <string> >();
        List <string>         quest;
        int row_no   = Table1.Rows.Count;
        int quest_no = row_no / 5;


        for (int i = 0; i < row_no;)
        {
            quest = new List <string>();
            TextBox qu = (TextBox)Table1.Rows[i].Cells[1].Controls[0];
            quest.Add(qu.Text.ToString());
            i++;
            int cor_ans = 0;
            for (int j = 0; j < 4; j++)
            {
                RadioButton anc = (RadioButton)Table1.Rows[i].Cells[1].Controls[0];
                TextBox     an  = (TextBox)Table1.Rows[i].Cells[1].Controls[1];
                quest.Add(an.Text.ToString());
                if (anc.Checked)
                {
                    cor_ans = j + 1;
                }
                i++;
            }
            quest.Add(cor_ans.ToString());
            questions.Add(quest);
        }
        Employee_pros pros    = new Employee_pros();
        int           test_id = pros.Add_Test(TextBox1.Text.ToString(), Int32.Parse(DropDownList1.SelectedItem.ToString()), Session["user"].ToString().TrimEnd(), Int32.Parse(DropDownList2.SelectedValue.ToString()));

        if (test_id == 0)
        {
            Label4.Visible = true;
            return;
        }
        pros.add_test_questions(questions, test_id);
        Panel1.Visible = false;
        Label4.Text    = "Test Has Been Added Successfully";
        Label4.Visible = true;
    }