/// <summary> /// 添加题型 /// </summary> /// <param name="qtype">题型对象</param> /// <returns></returns> public int AddQuestionType(TbQuestionTypes qtype) { StringBuilder sbsql = new StringBuilder(); sbsql.Append("insert into tbQuestionTypes(TxName,TxCount,Txzf,SjID)"); sbsql.Append("values(@TxName,@TxCount,@Txzf,@SjID);select @@IDENTITY"); SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@TxName", qtype.TxName), new SqlParameter("@TxCount", qtype.TxCount), new SqlParameter("@Txzf", qtype.Txzf), new SqlParameter("@SjID", qtype.SjID) }; return(DBHelper.GetScalar(sbsql.ToString(), paras)); }
protected void Button1_Click(object sender, EventArgs e) { string Load = this.txtName.Text; #region 将上传的word文档转换为图片并保存 try { //上传的Word文件的保存路径 string postpath = FileUpload1.PostedFile.FileName; if (!postpath.Contains(':') || !postpath.Contains('\\')) { lblFileMessage.Text = "请设置您当前浏览器:工具-internet选项-安全-自定义级别-将文件上传到服务器是包含本地路径!"; return; } this.FileUpload1.PostedFile.SaveAs(postpath); //保存上传的Word文档 TbTestPaper paper = new TbTestPaper(); paper.SjName = txtName.Text; //试卷名称 paper.LsName = Request.Cookies["nowloginuser"].Value; //当前用户 paper.KmID = int.Parse(ddlSubject.SelectedValue); //科目编号 paper.KsTime = DateTime.Parse(startTime.Value); //开始时间 paper.JsTime = DateTime.Parse(endTime.Value); //结束时间 paper.Remark = txtRemark.Text; //备注 sjid = TbTestPaperManager.AddPaper(paper); //添加后的试卷ID Word_Convert2Image(postpath); //调用转换函数 } catch (Exception ex) { TbTestPaperManager.DeleteTestpaperBySjid(sjid); lblSubMessage.Text = ex.Message; return; } #endregion if (sjid > 0) { string dxcount = txtdxcount.Text; //单选题数 string duocount = txtduocount.Text; //多选题数 string pdcount = txtpdcount.Text; //判断题数 string jdcount = txtjdcount.Text; //简答题数 TbQuestionTypes qtype = new TbQuestionTypes(); qtype.SjID = sjid; if (dxcount != "" && dxcount != "0") //添加单选题 { qtype.TxName = "单选题"; qtype.TxCount = int.Parse(dxcount); qtype.Txzf = int.Parse(txtdxzf.Text); TbQuestionTypesManager.AddQuestionType(qtype); } if (duocount != "" && duocount != "0") //添加多选题 { qtype.TxName = "多选题"; qtype.TxCount = int.Parse(duocount); qtype.Txzf = int.Parse(txtduozf.Text); TbQuestionTypesManager.AddQuestionType(qtype); } if (pdcount != "" && pdcount != "0") //添加判断题 { qtype.TxName = "判断题"; qtype.TxCount = int.Parse(pdcount); qtype.Txzf = int.Parse(txtpdzf.Text); TbQuestionTypesManager.AddQuestionType(qtype); } if (jdcount != "" && jdcount != "0") //添加简答题 { qtype.TxName = "简答题"; qtype.TxCount = int.Parse(jdcount); qtype.Txzf = int.Parse(txtjdzf.Text); TbQuestionTypesManager.AddQuestionType(qtype); } lblSubMessage.Text = "试卷生成成功!"; } }
/// <summary> /// 添加题型 /// </summary> /// <param name="qtype">题型对象</param> /// <returns></returns> public static int AddQuestionType(TbQuestionTypes qtype) { return(qtypeServices.AddQuestionType(qtype)); }