protected void Button1_Click(object sender, EventArgs e)
    {
        string s = @"Data Source=localhost; Database=audit_form; User ID=root; Password='******'";



        if (faculty_name_text.Text == "" || sub_text.Text == "" /*|| impr_expt_text.Text == "" || add_cmnt_text.Text == ""*/)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "scripts", "<script>alert('Please fill all compulsory fields');</script>");
        }

        else
        {
            // try
            //{


            if (fac_count <= fac_name.Count)
            {
                Response.Write(fac_count);


                double sum = (Convert.ToDouble(RadioButtonList1.SelectedValue) + Convert.ToDouble(RadioButtonList2.SelectedValue) + Convert.ToDouble(RadioButtonList3.SelectedValue) + Convert.ToDouble(RadioButtonList4.SelectedValue) + Convert.ToDouble(RadioButtonList5.SelectedValue) + Convert.ToDouble(RadioButtonList6.SelectedValue) + Convert.ToDouble(RadioButtonList7.SelectedValue) + Convert.ToDouble(RadioButtonList8.SelectedValue) + Convert.ToDouble(RadioButtonList9.SelectedValue));
                double avg = sum / 9.0;

                String insert1 = "insert into fac_performance(fac_name,q1,q2,q3,q4,q5,q6,q7,q8,q9,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,Average) values('" + faculty_name_text.Text + "','" + RadioButtonList1.SelectedItem.Value + "','" + RadioButtonList2.SelectedItem.Value + "','" + RadioButtonList3.SelectedItem.Value + "','" + RadioButtonList4.SelectedItem.Value + "','" + RadioButtonList5.SelectedItem.Value + "','" + RadioButtonList6.SelectedItem.Value + "','" + RadioButtonList7.SelectedItem.Value + "','" + RadioButtonList8.SelectedItem.Value + "','" + RadioButtonList9.SelectedItem.Value + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text + "','" + TextBox10.Text + "','" + TextBox11.Text + "','" + TextBox12.Text + "','" + TextBox13.Text + "','" + impr_expt_text.Text + "','" + add_cmnt_text.Text + "','" + avg + "')";

                MySqlCommand cmd2 = new MySqlCommand(insert1, con);
                cmd2.ExecuteNonQuery();
                /* Sets every radiobuttonlist to null  */
                { RadioButtonList1.ClearSelection(); RadioButtonList2.ClearSelection(); RadioButtonList3.ClearSelection(); RadioButtonList4.ClearSelection(); RadioButtonList5.ClearSelection(); RadioButtonList6.ClearSelection(); RadioButtonList7.ClearSelection(); RadioButtonList8.ClearSelection(); RadioButtonList9.ClearSelection();

                  TextBox5.Text = String.Empty; TextBox6.Text = String.Empty; TextBox7.Text = String.Empty; TextBox8.Text = String.Empty; TextBox9.Text = String.Empty; TextBox10.Text = String.Empty; TextBox11.Text = String.Empty; TextBox12.Text = String.Empty; TextBox13.Text = String.Empty;  impr_expt_text.Text = String.Empty; add_cmnt_text.Text = String.Empty; }


                if (fac_count == fac_name.Count)
                {
                    Response.Redirect("Student_Login_Page.aspx");
                }
                else
                {
                    faculty_name_text.Text = fac_name[fac_count];
                    sub_text.Text          = sub[fac_count];

                    fac_count += 1;
                }
            }



            else
            {
                /*Button1.Text = "submit"; Session.Clear(); Session.Abandon(); */

                /*Response.ExpiresAbsolute = DateTime.Now;
                 * Response.Expires = 0;
                 * Response.CacheControl = "no-cache";
                 */

                Response.Redirect("Student_Login_Page.aspx");
            }

            //}


            /* catch (Exception ex)
             * {
             *   Console.WriteLine(ex);
             * }
             * finally
             * { con.Close(); }*/
        }
    }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)

        {
            DataSet ds1 = GetData2();
            for (int i = 0; i < 10; i++)
            {
                int     Qid  = int.Parse(ds1.Tables["Questions"].Rows[i][0].ToString());
                DataSet ds   = GetData1(Qid);
                int     type = int.Parse(ds1.Tables["Questions"].Rows[i][2].ToString());
                if (type == 0)
                {
                    controlArray[i] = new string[4]
                    {
                        ds.Tables["Choices"].Rows[0][0].ToString(),
                        ds.Tables["Choices"].Rows[1][0].ToString(),
                        ds.Tables["Choices"].Rows[2][0].ToString(),
                        ds.Tables["Choices"].Rows[3][0].ToString()
                    };
                }

                else
                {
                    controlArray[i] = new string[2]
                    {
                        ds.Tables["Choices"].Rows[0][0].ToString(),
                        ds.Tables["Choices"].Rows[1][0].ToString()
                    };
                }
            }

            RadioButtonList1.DataSource = controlArray[0];
            RadioButtonList1.DataBind();
            RadioButtonList2.DataSource = controlArray[1];
            RadioButtonList2.DataBind();
            RadioButtonList3.DataSource = controlArray[2];
            RadioButtonList3.DataBind();
            RadioButtonList4.DataSource = controlArray[3];
            RadioButtonList4.DataBind();
            RadioButtonList5.DataSource = controlArray[4];
            RadioButtonList5.DataBind();
            RadioButtonList6.DataSource = controlArray[5];
            RadioButtonList6.DataBind();
            RadioButtonList7.DataSource = controlArray[6];
            RadioButtonList7.DataBind();
            RadioButtonList8.DataSource = controlArray[7];
            RadioButtonList8.DataBind();
            RadioButtonList9.DataSource = controlArray[8];
            RadioButtonList9.DataBind();
            RadioButtonList10.DataSource = controlArray[9];
            RadioButtonList10.DataBind();
            Label1.Text  = ds1.Tables["Questions"].Rows[0][1].ToString();
            Label2.Text  = ds1.Tables["Questions"].Rows[1][1].ToString();
            Label3.Text  = ds1.Tables["Questions"].Rows[2][1].ToString();
            Label4.Text  = ds1.Tables["Questions"].Rows[3][1].ToString();
            Label5.Text  = ds1.Tables["Questions"].Rows[4][1].ToString();
            Label6.Text  = ds1.Tables["Questions"].Rows[5][1].ToString();
            Label7.Text  = ds1.Tables["Questions"].Rows[6][1].ToString();
            Label8.Text  = ds1.Tables["Questions"].Rows[7][1].ToString();
            Label9.Text  = ds1.Tables["Questions"].Rows[8][1].ToString();
            Label10.Text = ds1.Tables["Questions"].Rows[9][1].ToString();
        }
    }