protected void SubmitBtn3_Click(object sender, EventArgs e) { TestingSystemEntities2 ts = new TestingSystemEntities2(); Sub s = new Sub(); Topic t = new Topic(); if (SubTxt2.Text != "") { if (ts.Subs.Any(a => a.name == SubTxt2.Text)) { ScriptManager.RegisterStartupScript(Page, typeof(Page), "key", "alert('Subject Name already exist')", true); } else { if (SubTxt2.Text != null && TopicTxt2.Text != null) { s.name = SubTxt2.Text; ts.Subs.Add(s); ts.SaveChanges(); t.Tname = TopicTxt2.Text; t.subId = s.id; ts.Topics.Add(t); ts.SaveChanges(); Response.Redirect("MCQPage.aspx"); } } } }
protected void BtnSubmit_Click(object sender, EventArgs e) { TestingSystemEntities2 db = new TestingSystemEntities2(); MainData maindata = Session["Maindata"] as MainData; Question q = new Question(); q.point = maindata.Points; q.Tid = maindata.Topicid; q.Qstate = txtBoxQuestion.Text; q.hardness = maindata.Hardness; db.Questions.Add(q); Program p = new Program(); p.Qid = q.id; p.code = txtBoxCode.Text; db.Programs.Add(p); db.SaveChanges(); txtBoxCode.Text = ""; txtBoxQuestion.Text = ""; Response.Redirect("Default.aspx"); }
protected void ddl1_SelectedIndexChanged(object sender, EventArgs e) { TestingSystemEntities2 db = new TestingSystemEntities2(); int SelectedSubject = Convert.ToInt32(ddl1.SelectedValue); var ListofTopics = db.Topics.Where(w => w.subId == SelectedSubject).ToList(); ddl2.DataSource = ListofTopics; ddl2.DataTextField = "Tname"; ddl2.DataValueField = "id"; ddl2.DataBind(); ddl2.Items.Insert(0, new ListItem("Select Topic", "")); }
protected void SubmitBtn2_Click(object sender, EventArgs e) { TestingSystemEntities2 ts = new TestingSystemEntities2(); Topic t = new Topic(); int id = Convert.ToInt32(ViewState["subjectid"]); if (TopicTxt1.Text != null) { t.Tname = TopicTxt1.Text; t.subId = id; ts.Topics.Add(t); ts.SaveChanges(); } TopicTxt1.Text = ""; Response.Redirect("MCQPage.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { MCQPlaceHolder.Visible = false; CodePlaceHolder.Visible = false; TestingSystemEntities2 db = new TestingSystemEntities2(); var ListofSubjects = db.Subs.ToList(); ddl1.DataSource = ListofSubjects; ddl1.DataTextField = "name"; ddl1.DataValueField = "id"; ddl1.DataBind(); ddl1.Items.Insert(0, new ListItem("Select Subject", "")); } }
protected void AddMoreTopicBtn_Click(object sender, EventArgs e) { int data = 1; TestingSystemEntities2 ts = new TestingSystemEntities2(); Topic t = new Topic(); Sub s = new Sub(); if (data == 1) { if (ts.Subs.Any(a => a.name == SubTxt1.Text)) { ScriptManager.RegisterStartupScript(Page, typeof(Page), "key", "alert('Subject Name already exist')", true); } else { s.name = SubTxt1.Text; ts.Subs.Add(s); ts.SaveChanges(); ViewState["subjectid"] = s.id; if (TopicTxt1.Text != null) { t.Tname = TopicTxt1.Text; t.subId = s.id; ts.Topics.Add(t); ts.SaveChanges(); } TopicTxt1.Text = ""; } data = 5; } else { int id = Convert.ToInt32(ViewState["subjectid"]); if (TopicTxt1.Text != null) { t.Tname = TopicTxt1.Text; t.subId = id; ts.Topics.Add(t); ts.SaveChanges(); } TopicTxt1.Text = ""; } }
protected void SubmitQues_Click(object sender, EventArgs e) { MainData maindata = Session["Maindata"] as MainData; List <TempData> data = ViewState["datalist"] as List <TempData>; TestingSystemEntities2 db = new TestingSystemEntities2(); Question q = new Question(); q.Qstate = txtofQstat.Text; q.point = maindata.Points; q.Tid = maindata.Topicid; q.hardness = maindata.Hardness; db.Questions.Add(q); int lindex = data.Count(); MCQOption mq; for (int i = 0; i < lindex; i++) { mq = new MCQOption(); mq.Qid = q.id; mq.MOption = data[i].Option; if (data[i].Status == true) { mq.correct = true; } else { mq.correct = false; } db.MCQOptions.Add(mq); } db.SaveChanges(); Response.Redirect("Default.aspx"); }