// 新建问题 public bool create(Problem obj) { DataClassesDataContext da = new DataClassesDataContext(); da.Problem.InsertOnSubmit(obj); da.SubmitChanges(); return true; }
protected void AProSureButton_Click(object sender, EventArgs e) { Problem Apro = new Problem(); Apro.assignment = int.Parse(Request.QueryString["Assignmentid"].ToString()); Apro.title = AProtitleTextBox.Text; Apro.descrip = AProdescriTextBox.Text; Apro.score = float.Parse(scoreTextBox.Text); ProMan.create(Apro); Response.Redirect("OneAssignment.aspx?Assignmentid=" + Request.QueryString["Assignmentid"] + "&Assignmentnum=" + Request.QueryString["Assignmentnum"]); }
//添加该作业的一个问题 protected void AProSureButton_Click(object sender, EventArgs e) { AProPanel.Visible = false; Assignment assignment = (Assignment)Session["Aassignment"]; Problem Apro = new Problem(); problems = (List<Problem>)Session["problems"]; Apro.score = float.Parse(AProscoreTextBox.Text); Apro.title = AProtitleTextBox.Text; Apro.descrip = AProdescriTextBox.Text; Apro.assignment = assignment.id; problems.Add(Apro); Session["problems"] = problems; SelectProRadioButtonList.Items.Clear(); for (int i = 0; i != problems.Count; i++) { SelectProRadioButtonList.Items.Add(new ListItem(i+1 + "." + problems[i].title + "<br>" + problems[i].descrip, i.ToString())); } }
partial void DeleteProblem(Problem instance);
private void detach_Problem(Problem entity) { this.SendPropertyChanging(); entity.Assignment1 = null; }
partial void UpdateProblem(Problem instance);
private void attach_Problem(Problem entity) { this.SendPropertyChanging(); entity.Assignment1 = this; }
partial void InsertProblem(Problem instance);
//更新问题 public bool UpdateProblem(Problem pro) { DataClassesDataContext da = new DataClassesDataContext(); var p = from s in da.Problem where s.id == pro.id select s; foreach (Problem problem in p) { problem.id = pro.id; problem.assignment = pro.assignment; problem.title = pro.title; problem.descrip = pro.descrip; problem.score = pro.score; } da.SubmitChanges(); return true; }