private void btnAdd_Click(object sender, EventArgs e) { if (cboCourse.SelectedValue == null || txtFrontTitle.Text == "" || txtbackTitle.Text == "") { MessageBox.Show("请输入完整的题目信息!"); } else if (txtAnswer.Text == "") { MessageBox.Show("请输入正确答案!"); } else { try { fillBlankProblem fbp = new fillBlankProblem(cboCourse.SelectedValue.ToString(), txtFrontTitle.Text, txtbackTitle.Text, txtAnswer.Text); QuestionBll.AddfillBlankProblem(fbp); MessageBox.Show("添加成功!"); this.Close(); } catch (Exception ee) { MessageBox.Show("添加失败!" + ee); throw; } } }
/// <summary> /// 添加填空题信息 /// </summary> /// <param name="courseID">课程编号</param> /// <param name="FrontTitle">前描述</param> /// <param name="backTitle">后描述</param> /// <param name="answer">正确答案</param> public void AddfillBlankProblem(fillBlankProblem fbp) { string str = "select count(*)from fillBlankProblem"; SH.SqlCom(str, CommandType.Text); string ID = ((int)SH.SqlES() + 1).ToString(); str = "insert fillBlankProblem values(@ID,@courseID,@FrontTitle,@backTitle,@answer)"; SH.SqlCom(str, CommandType.Text); string[] str0={"@ID","@courseID","@FrontTitle","@backTitle","@answer"}; string[] str1 = { ID, fbp.CourseID, fbp.FrontTitle, fbp.BackTitle, fbp.Answer }; SH.SqlPar(str0,str1); SH.SqlENQ(); }