protected void SqlDataSource2_Updated(object sender, SqlDataSourceStatusEventArgs e) { DataClasses2DataContext dc = new DataClasses2DataContext(); update_exam ue = new update_exam(); ue.date = System.DateTime.Now; ue.description = "updated"; ue.exam_name = DropDownList2.SelectedValue; ue.username = Session["username"].ToString(); dc.update_exams.InsertOnSubmit(ue); dc.SubmitChanges(); }
protected void Button1_Click(object sender, EventArgs e) { int exam_id = 0; try { DataClasses2DataContext dc = new DataClasses2DataContext(); var query = from t1 in dc.exam_masters where t1.exam_name == DropDownList2.SelectedItem.Text select t1; foreach (var i in query) { exam_id = i.exam_id; dc.exam_masters.DeleteOnSubmit(i); } update_exam ue = new update_exam(); ue.date = System.DateTime.Now; ue.description = "deleted"; ue.exam_name = DropDownList2.SelectedValue; ue.username = Session["username"].ToString(); dc.update_exams.InsertOnSubmit(ue); dc.SubmitChanges(); dc.SubmitChanges(); ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Questionpaper deleted successfully');window.location ='admin.aspx';", true); // var query1 = from t1 in dc.exam_masters group t1 by t1.exam_type into gr select gr.Key; // DropDownList1.DataSource = query1; // DropDownList1.DataBind(); // var query2 = from t2 in dc.exam_masters where t2.exam_type == DropDownList1.SelectedValue select t2.exam_name; // DropDownList2.DataSource = query2; // DropDownList2.DataBind(); } catch (Exception ee) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Something went wrong!try again!!');window.location ='admin.aspx';", true); } }
protected void Button3_Click(object sender, EventArgs e) { int flag = 0; for (int i = 1; i <= 6; i++) { if (((TextBox)form1.FindControl("TextBox" + (((((int)Session["totalque"]) - 1) * 6 + i)))).Text == "") { flag = 1; } } if (flag == 1) { Label2.Text = "*all fileds required!!"; } else { Label2.Text = ""; //Label1.Text = (MultiView1.ActiveViewIndex + 2).ToString() + "/" + Session["totalque"]; //MultiView1.ActiveViewIndex = MultiView1.ActiveViewIndex + 1; int exam_id = 0, temp; String strtemp; DataClasses2DataContext dc = new DataClasses2DataContext(); var query = from t1 in dc.exam_masters where t1.exam_name == Session["qname"].ToString() select t1.exam_id; foreach (var i in query) { exam_id = i; } for (int i = 1; i <= (int)Session["totalque"]; i++) { question_master qm = new question_master(); qm.que_id = i; qm.exam_id = exam_id; temp = (i - 1) * 6 + 1; strtemp = "Textbox" + temp; qm.que = ((TextBox)form1.FindControl(strtemp)).Text; temp = (i - 1) * 6 + 2; strtemp = "Textbox" + temp; qm.op1 = ((TextBox)form1.FindControl(strtemp)).Text; temp = (i - 1) * 6 + 3; strtemp = "Textbox" + temp; qm.op2 = ((TextBox)form1.FindControl(strtemp)).Text; temp = (i - 1) * 6 + 4; strtemp = "Textbox" + temp; qm.op3 = ((TextBox)form1.FindControl(strtemp)).Text; temp = (i - 1) * 6 + 5; strtemp = "Textbox" + temp; qm.op4 = ((TextBox)form1.FindControl(strtemp)).Text; temp = (i - 1) * 6 + 6; strtemp = "Textbox" + temp; qm.right_answer = ((TextBox)form1.FindControl(strtemp)).Text; dc.question_masters.InsertOnSubmit(qm); } try { dc.SubmitChanges(); update_exam ue = new update_exam(); ue.date = System.DateTime.Now; ue.description = "added"; ue.exam_name = Session["qname"].ToString(); ue.username = Session["username"].ToString(); dc.update_exams.InsertOnSubmit(ue); dc.SubmitChanges(); ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Questionpaper with questions added Successfully!!!');window.location ='admin.aspx';", true); } catch (Exception ee) { var query1 = from t1 in dc.exam_masters where t1.exam_name == Session["qname"].ToString() select t1; foreach (var i in query1) { dc.exam_masters.DeleteOnSubmit(i); } dc.SubmitChanges(); ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Something went wrong!please try again!!!');window.location ='admin.aspx';", true); } } }