/// <summary> /// 得到一个问题对象 /// </summary> /// <param name="data"></param> /// <returns></returns> /// <remarks>tianzhenyun 2011-10-14</remarks> public E_Question GetModel(E_Question data) { SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@QuestionID", SqlDbType.Int), new SqlParameter("@EnterpriseID", SqlDbType.Int) }; parms[0].Value = data.QuestionID; parms[1].Value = data.EnterpriseID; DataSet ds = DbHelperSQL.RunProcedureDataSet("ProcEP_B_QuestionS_Select", parms); DataTable questionTable = ds.Tables[0]; DataTable itemTable = ds.Tables [1]; if (questionTable != null && questionTable.Rows.Count == 1) { data.QuestionName = questionTable.Rows[0]["QuestionName"].ToString(); data.QuestionType = Convert.ToInt32(questionTable.Rows[0]["QuestionType"]); data.UpdateDate = Convert.ToDateTime(questionTable.Rows[0]["UpdateDate"]); //封装问题选项 List <E_QuestionItem> list = null; if (itemTable != null && itemTable.Rows.Count > 0) { list = new List <E_QuestionItem>(); } E_QuestionItem item = null; foreach (DataRow row in itemTable.Rows) { item = new E_QuestionItem(); item.QuestionItemID = Convert.ToInt32(row["QuestionItemID"]); item.QuestionItemName = row["QuestionItemName"].ToString(); list.Add(item); } data.QuestionItem = list; return(data); } return(null); }
/// <summary> /// 点击保存按钮处理事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { //判断标题是否输入 string questionName = txtQuestionName.Text; if (questionName == "") { MLMGC.COMP.Jscript.ShowMsg("请输入标题", this); return; } //获取界面里所有隐藏域集合 System.Collections.Specialized.NameValueCollection nv = Request.Form; string[] child_ItemIDs = nv.GetValues("hdQuestionItemIDs"); string[] child_ItemNameS = nv.GetValues("hdQuestionItemNameS"); if (child_ItemIDs == null || child_ItemNameS == null) { return; } if (child_ItemIDs.Length != child_ItemNameS.Length) { MLMGC.COMP.Jscript.ShowMsg("参数错误", this); return; } if (child_ItemIDs.Length == 0) { MLMGC.COMP.Jscript.ShowMsg("请输入选项", this); return; } //封装数据 E_Question data = new E_Question(); data.EnterpriseID = EnterpriceID; data.QuestionName = questionName; data.Flag = cbDeleteRelation.Checked ? 1 : 0; data.QuestionType = Convert.ToInt32(rblQuestionType.SelectedValue); data.QuestionItem = new List <E_QuestionItem>(); E_QuestionItem item = null; for (int i = 0; i < child_ItemIDs.Length; i++) { item = new E_QuestionItem(); item.QuestionItemID = Convert.ToInt64(child_ItemIDs[i]); item.QuestionItemName = child_ItemNameS[i]; data.QuestionItem.Add(item); } //判断是添加还是修改 if (type == "add") { bool flag = new T_Question().Add(data); new MLMGC.BLL.Enterprise.T_Log().Add(new MLMGC.DataEntity.Enterprise.E_Log() { EnterpriseID = EnterpriceID, UserID = UserID, LogTitle = "添加问题", IP = MLMGC.COMP.Requests.GetRealIP() }); if (flag) { MLMGC.COMP.Jscript.AlertAndRedirect(this, "添加成功", "QuestionList.aspx"); } else { MLMGC.COMP.Jscript.ShowMsg("添加失败", this); } } else { //获取项目资料编号 int questionID = MLMGC.COMP.Requests.GetQueryInt("questionid", 0); data.QuestionID = questionID; bool flag = new T_Question().Update(data); new MLMGC.BLL.Enterprise.T_Log().Add(new MLMGC.DataEntity.Enterprise.E_Log() { EnterpriseID = EnterpriceID, UserID = UserID, LogTitle = "修改问题", IP = MLMGC.COMP.Requests.GetRealIP() }); if (flag) { MLMGC.COMP.Jscript.AlertAndRedirect(this, "修改成功", "QuestionList.aspx"); } else { MLMGC.COMP.Jscript.ShowMsg("修改失败", this); } } }