public void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(this.txtES_TYPE.Text.Trim().Length==0) { strErr+="ES_TYPE不能为空!\\n"; } if(this.txtES_TITLE.Text.Trim().Length==0) { strErr+="ES_TITLE不能为空!\\n"; } if(this.txtES_CONTENT.Text.Trim().Length==0) { strErr+="ES_CONTENT不能为空!\\n"; } if(!PageValidate.IsNumber(txtES_HARD.Text)) { strErr+="ES_HARD格式错误!\\n"; } if(!PageValidate.IsNumber(txtES_DELFLAG.Text)) { strErr+="ES_DELFLAG格式错误!\\n"; } if(!PageValidate.IsDateTime(txtES_CTIME.Text)) { strErr+="ES_CTIME格式错误!\\n"; } if(this.txtES_TID.Text.Trim().Length==0) { strErr+="ES_TID不能为空!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } string ES_ID=this.lblES_ID.Text; string ES_TYPE=this.txtES_TYPE.Text; string ES_TITLE=this.txtES_TITLE.Text; string ES_CONTENT=this.txtES_CONTENT.Text; int ES_HARD=int.Parse(this.txtES_HARD.Text); int ES_DELFLAG=int.Parse(this.txtES_DELFLAG.Text); DateTime ES_CTIME=DateTime.Parse(this.txtES_CTIME.Text); string ES_TID=this.txtES_TID.Text; cfs.Model.OT_ESSAY model=new cfs.Model.OT_ESSAY(); model.ES_ID=ES_ID; model.ES_TYPE=ES_TYPE; model.ES_TITLE=ES_TITLE; model.ES_CONTENT=ES_CONTENT; model.ES_HARD=ES_HARD; model.ES_DELFLAG=ES_DELFLAG; model.ES_CTIME=ES_CTIME; model.ES_TID=ES_TID; cfs.BLL.OT_ESSAY bll=new cfs.BLL.OT_ESSAY(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","list.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public cfs.Model.OT_ESSAY GetModel(string ES_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ES_ID,ES_TYPE,ES_TITLE,ES_CONTENT,ES_ANSWER,ES_HARD,ES_DELFLAG,ES_CTIME,ES_TID from OT_ESSAY "); strSql.Append(" where ES_ID=@ES_ID "); SqlParameter[] parameters = { new SqlParameter("@ES_ID", SqlDbType.VarChar, 64) }; parameters[0].Value = ES_ID; cfs.Model.OT_ESSAY model = new cfs.Model.OT_ESSAY(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ES_ID"] != null && ds.Tables[0].Rows[0]["ES_ID"].ToString() != "") { model.ES_ID = ds.Tables[0].Rows[0]["ES_ID"].ToString(); } if (ds.Tables[0].Rows[0]["ES_TYPE"] != null && ds.Tables[0].Rows[0]["ES_TYPE"].ToString() != "") { model.ES_TYPE = ds.Tables[0].Rows[0]["ES_TYPE"].ToString(); } if (ds.Tables[0].Rows[0]["ES_TITLE"] != null && ds.Tables[0].Rows[0]["ES_TITLE"].ToString() != "") { model.ES_TITLE = ds.Tables[0].Rows[0]["ES_TITLE"].ToString(); } if (ds.Tables[0].Rows[0]["ES_CONTENT"] != null && ds.Tables[0].Rows[0]["ES_CONTENT"].ToString() != "") { model.ES_CONTENT = ds.Tables[0].Rows[0]["ES_CONTENT"].ToString(); } if (ds.Tables[0].Rows[0]["ES_ANSWER"] != null && ds.Tables[0].Rows[0]["ES_ANSWER"].ToString() != "") { model.ES_ANSWER = ds.Tables[0].Rows[0]["ES_ANSWER"].ToString(); } if (ds.Tables[0].Rows[0]["ES_HARD"] != null && ds.Tables[0].Rows[0]["ES_HARD"].ToString() != "") { model.ES_HARD = int.Parse(ds.Tables[0].Rows[0]["ES_HARD"].ToString()); } if (ds.Tables[0].Rows[0]["ES_DELFLAG"] != null && ds.Tables[0].Rows[0]["ES_DELFLAG"].ToString() != "") { model.ES_DELFLAG = int.Parse(ds.Tables[0].Rows[0]["ES_DELFLAG"].ToString()); } if (ds.Tables[0].Rows[0]["ES_CTIME"] != null && ds.Tables[0].Rows[0]["ES_CTIME"].ToString() != "") { model.ES_CTIME = DateTime.Parse(ds.Tables[0].Rows[0]["ES_CTIME"].ToString()); } if (ds.Tables[0].Rows[0]["ES_TID"] != null && ds.Tables[0].Rows[0]["ES_TID"].ToString() != "") { model.ES_TID = ds.Tables[0].Rows[0]["ES_TID"].ToString(); } return(model); } else { return(null); } }
private void ShowInfo(string ES_ID) { cfs.BLL.OT_ESSAY bll = new cfs.BLL.OT_ESSAY(); cfs.Model.OT_ESSAY model = bll.GetModel(ES_ID); this.lblES_ID.Text = model.ES_ID; this.lblES_TYPE.Text = model.ES_TYPE; this.lblES_TITLE.Text = model.ES_TITLE; this.lblES_CONTENT.Text = model.ES_CONTENT; this.lblES_HARD.Text = model.ES_HARD.ToString(); this.lblES_DELFLAG.Text = model.ES_DELFLAG.ToString(); this.lblES_CTIME.Text = model.ES_CTIME.ToString(); this.lblES_TID.Text = model.ES_TID; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(cfs.Model.OT_ESSAY model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update OT_ESSAY set "); strSql.Append("ES_TYPE=@ES_TYPE,"); strSql.Append("ES_TITLE=@ES_TITLE,"); strSql.Append("ES_CONTENT=@ES_CONTENT,"); strSql.Append("ES_ANSWER=@ES_ANSWER,"); strSql.Append("ES_HARD=@ES_HARD,"); strSql.Append("ES_DELFLAG=@ES_DELFLAG,"); strSql.Append("ES_CTIME=@ES_CTIME,"); strSql.Append("ES_TID=@ES_TID"); strSql.Append(" where ES_ID=@ES_ID "); SqlParameter[] parameters = { new SqlParameter("@ES_TYPE", SqlDbType.VarChar, 50), new SqlParameter("@ES_TITLE", SqlDbType.Text), new SqlParameter("@ES_CONTENT", SqlDbType.Text), new SqlParameter("@ES_ANSWER", SqlDbType.Text), new SqlParameter("@ES_HARD", SqlDbType.Int, 4), new SqlParameter("@ES_DELFLAG", SqlDbType.Int, 4), new SqlParameter("@ES_CTIME", SqlDbType.DateTime), new SqlParameter("@ES_TID", SqlDbType.VarChar, 50), new SqlParameter("@ES_ID", SqlDbType.VarChar, 64) }; parameters[0].Value = model.ES_TYPE; parameters[1].Value = model.ES_TITLE; parameters[2].Value = model.ES_CONTENT; parameters[3].Value = model.ES_ANSWER; parameters[4].Value = model.ES_HARD; parameters[5].Value = model.ES_DELFLAG; parameters[6].Value = model.ES_CTIME; parameters[7].Value = model.ES_TID; parameters[8].Value = model.ES_ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(cfs.Model.OT_ESSAY model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into OT_ESSAY("); strSql.Append("ES_ID,ES_TYPE,ES_TITLE,ES_CONTENT,ES_ANSWER,ES_HARD,ES_DELFLAG,ES_CTIME,ES_TID)"); strSql.Append(" values ("); strSql.Append("@ES_ID,@ES_TYPE,@ES_TITLE,@ES_CONTENT,@ES_ANSWER,@ES_HARD,@ES_DELFLAG,@ES_CTIME,@ES_TID)"); SqlParameter[] parameters = { new SqlParameter("@ES_ID", SqlDbType.VarChar, 64), new SqlParameter("@ES_TYPE", SqlDbType.VarChar, 50), new SqlParameter("@ES_TITLE", SqlDbType.Text), new SqlParameter("@ES_CONTENT", SqlDbType.Text), new SqlParameter("@ES_ANSWER", SqlDbType.Text), new SqlParameter("@ES_HARD", SqlDbType.Int, 4), new SqlParameter("@ES_DELFLAG", SqlDbType.Int, 4), new SqlParameter("@ES_CTIME", SqlDbType.DateTime), new SqlParameter("@ES_TID", SqlDbType.VarChar, 50) }; parameters[0].Value = model.ES_ID; parameters[1].Value = model.ES_TYPE; parameters[2].Value = model.ES_TITLE; parameters[3].Value = model.ES_CONTENT; parameters[4].Value = model.ES_ANSWER; parameters[5].Value = model.ES_HARD; parameters[6].Value = model.ES_DELFLAG; parameters[7].Value = model.ES_CTIME; parameters[8].Value = model.ES_TID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; /*----------------------题目操作接口—————————————————————————*/ string action = context.Request.Params["type"]; string qsid = context.Request.Params["qsid"]; cfs.Model.JSON jj; cfs.BLL.OT_QUESTION bll_q = new BLL.OT_QUESTION(); cfs.Model.OT_QUESTION model_q = new Model.OT_QUESTION(); cfs.BLL.OT_ESSAY bll_e = new BLL.OT_ESSAY(); cfs.Model.OT_ESSAY model_e = new cfs.Model.OT_ESSAY(); JavaScriptSerializer jss = new JavaScriptSerializer(); switch (action) { case "TranslationDetail": break; case "TranslationAdd": //调用存储过程生成ES_ID model_e.ES_CONTENT = context.Request.Form["question"]; model_e.ES_ANSWER = context.Request.Form["answer"]; model_e.ES_CTIME = System.DateTime.Now; if (bll_e.Add(model_e)) { jj = new Model.JSON() { statusCode = "200", message = "新增成功", navTabId = "Translation", rel = "", callbackType = "closeCurrent" }; } else { jj = new Model.JSON() { statusCode = "300", message = "新增失败", navTabId = "Translation", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; case "TranslationEdit": model_e = bll_e.GetModel(qsid); model_e.ES_CONTENT = context.Request.Form["question"]; model_e.ES_ANSWER = context.Request.Form["answer"]; model_e.ES_CTIME = System.DateTime.Now; if (bll_e.Update(model_e)) { jj = new Model.JSON() { statusCode = "200", message = "编辑成功", navTabId = "Translation", rel = "", callbackType = "closeCurrent" }; } else { jj = new Model.JSON() { statusCode = "300", message = "编辑失败", navTabId = "Translation", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; case "TranlationDelete": if (bll_e.Delete(qsid)) { jj = new Model.JSON() { statusCode = "200", message = "删除成功", navTabId = "Translation", rel = "", callbackType = "" }; } else { jj = new Model.JSON() { statusCode = "300", message = "删除失败", navTabId = "Translation", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; case "CompositionDetail": break; case "CompositionAdd": //调用存储过程生成ES_ID model_e.ES_TITLE = context.Request.Form["question_title"]; model_e.ES_CONTENT = context.Request.Form["question_content"]; model_e.ES_ANSWER = context.Request.Form["answer"]; model_e.ES_CTIME = System.DateTime.Now; if (bll_e.Add(model_e)) { jj = new Model.JSON() { statusCode = "200", message = "新增成功", navTabId = "Composition", rel = "", callbackType = "closeCurrent" }; } else { jj = new Model.JSON() { statusCode = "300", message = "新增失败", navTabId = "Composition", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; case "CompositionEdit": model_e = bll_e.GetModel(qsid); model_e.ES_TITLE = context.Request.Form["question_title"]; model_e.ES_CONTENT = context.Request.Form["question_content"]; model_e.ES_ANSWER = context.Request.Form["answer"]; model_e.ES_CTIME = System.DateTime.Now; if (bll_e.Update(model_e)) { jj = new Model.JSON() { statusCode = "200", message = "编辑成功", navTabId = "Composition", rel = "", callbackType = "closeCurrent" }; } else { jj = new Model.JSON() { statusCode = "300", message = "编辑失败", navTabId = "Composition", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; case "CompositionDelete": if (bll_e.Delete(qsid)) { jj = new Model.JSON() { statusCode = "200", message = "删除成功", navTabId = "Composition", rel = "", callbackType = "" }; } else { jj = new Model.JSON() { statusCode = "300", message = "删除失败", navTabId = "Composition", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; case "ChoiceDetail": break; case "ChoiceAdd": //调用存储过程生成QS_ID model_q.QS_CONTENT = context.Request.Form["question"]; model_q.QS_CHOICE_A = context.Request.Form["ca"]; model_q.QS_CHOICE_B = context.Request.Form["cb"]; model_q.QS_CHOICE_C = context.Request.Form["cc"]; model_q.QS_CHOICE_D = context.Request.Form["cd"]; model_q.QS_CHOICE_COR = Convert.ToInt32(context.Request.Form["answer"]); model_q.QS_COR_EXPLAINATION = context.Request.Form["explaination"]; model_q.QS_CTIME = System.DateTime.Now; if (bll_q.Add(model_q)) { jj = new Model.JSON() { statusCode = "200", message = "新增成功", navTabId = "Choice", rel = "", callbackType = "closeCurrent" }; } else { jj = new Model.JSON() { statusCode = "300", message = "新增失败", navTabId = "Choice", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; case "ChoiceEdit": model_q = bll_q.GetModel(qsid); model_q.QS_CONTENT = context.Request.Form["question"]; model_q.QS_CHOICE_A = context.Request.Form["ca"]; model_q.QS_CHOICE_B = context.Request.Form["cb"]; model_q.QS_CHOICE_C = context.Request.Form["cc"]; model_q.QS_CHOICE_D = context.Request.Form["cd"]; model_q.QS_CHOICE_COR = Convert.ToInt32(context.Request.Form["answer"]); model_q.QS_COR_EXPLAINATION = context.Request.Form["explaination"]; model_q.QS_CTIME = System.DateTime.Now; if (bll_q.Update(model_q)) { jj = new Model.JSON() { statusCode = "200", message = "编辑成功", navTabId = "Choice", rel = "", callbackType = "closeCurrent" }; } else { jj = new Model.JSON() { statusCode = "300", message = "编辑失败", navTabId = "Choice", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; case "ChoiceDelete": if (bll_q.Delete(qsid)) { jj = new Model.JSON() { statusCode = "200", message = "删除成功", navTabId = "Choice", rel = "", callbackType = "" }; } else { jj = new Model.JSON() { statusCode = "300", message = "删除失败", navTabId = "Choice", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; default: break; } }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtES_TYPE.Text.Trim().Length == 0) { strErr += "ES_TYPE不能为空!\\n"; } if (this.txtES_TITLE.Text.Trim().Length == 0) { strErr += "ES_TITLE不能为空!\\n"; } if (this.txtES_CONTENT.Text.Trim().Length == 0) { strErr += "ES_CONTENT不能为空!\\n"; } if (!PageValidate.IsNumber(txtES_HARD.Text)) { strErr += "ES_HARD格式错误!\\n"; } if (!PageValidate.IsNumber(txtES_DELFLAG.Text)) { strErr += "ES_DELFLAG格式错误!\\n"; } if (!PageValidate.IsDateTime(txtES_CTIME.Text)) { strErr += "ES_CTIME格式错误!\\n"; } if (this.txtES_TID.Text.Trim().Length == 0) { strErr += "ES_TID不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string ES_ID = this.lblES_ID.Text; string ES_TYPE = this.txtES_TYPE.Text; string ES_TITLE = this.txtES_TITLE.Text; string ES_CONTENT = this.txtES_CONTENT.Text; int ES_HARD = int.Parse(this.txtES_HARD.Text); int ES_DELFLAG = int.Parse(this.txtES_DELFLAG.Text); DateTime ES_CTIME = DateTime.Parse(this.txtES_CTIME.Text); string ES_TID = this.txtES_TID.Text; cfs.Model.OT_ESSAY model = new cfs.Model.OT_ESSAY(); model.ES_ID = ES_ID; model.ES_TYPE = ES_TYPE; model.ES_TITLE = ES_TITLE; model.ES_CONTENT = ES_CONTENT; model.ES_HARD = ES_HARD; model.ES_DELFLAG = ES_DELFLAG; model.ES_CTIME = ES_CTIME; model.ES_TID = ES_TID; cfs.BLL.OT_ESSAY bll = new cfs.BLL.OT_ESSAY(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public cfs.Model.OT_ESSAY GetModel(string ES_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ES_ID,ES_TYPE,ES_TITLE,ES_CONTENT,ES_ANSWER,ES_HARD,ES_DELFLAG,ES_CTIME,ES_TID from OT_ESSAY "); strSql.Append(" where ES_ID=@ES_ID "); SqlParameter[] parameters = { new SqlParameter("@ES_ID", SqlDbType.VarChar,64) }; parameters[0].Value = ES_ID; cfs.Model.OT_ESSAY model = new cfs.Model.OT_ESSAY(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ES_ID"] != null && ds.Tables[0].Rows[0]["ES_ID"].ToString() != "") { model.ES_ID = ds.Tables[0].Rows[0]["ES_ID"].ToString(); } if (ds.Tables[0].Rows[0]["ES_TYPE"] != null && ds.Tables[0].Rows[0]["ES_TYPE"].ToString() != "") { model.ES_TYPE = ds.Tables[0].Rows[0]["ES_TYPE"].ToString(); } if (ds.Tables[0].Rows[0]["ES_TITLE"] != null && ds.Tables[0].Rows[0]["ES_TITLE"].ToString() != "") { model.ES_TITLE = ds.Tables[0].Rows[0]["ES_TITLE"].ToString(); } if (ds.Tables[0].Rows[0]["ES_CONTENT"] != null && ds.Tables[0].Rows[0]["ES_CONTENT"].ToString() != "") { model.ES_CONTENT = ds.Tables[0].Rows[0]["ES_CONTENT"].ToString(); } if (ds.Tables[0].Rows[0]["ES_ANSWER"] != null && ds.Tables[0].Rows[0]["ES_ANSWER"].ToString() != "") { model.ES_ANSWER = ds.Tables[0].Rows[0]["ES_ANSWER"].ToString(); } if (ds.Tables[0].Rows[0]["ES_HARD"] != null && ds.Tables[0].Rows[0]["ES_HARD"].ToString() != "") { model.ES_HARD = int.Parse(ds.Tables[0].Rows[0]["ES_HARD"].ToString()); } if (ds.Tables[0].Rows[0]["ES_DELFLAG"] != null && ds.Tables[0].Rows[0]["ES_DELFLAG"].ToString() != "") { model.ES_DELFLAG = int.Parse(ds.Tables[0].Rows[0]["ES_DELFLAG"].ToString()); } if (ds.Tables[0].Rows[0]["ES_CTIME"] != null && ds.Tables[0].Rows[0]["ES_CTIME"].ToString() != "") { model.ES_CTIME = DateTime.Parse(ds.Tables[0].Rows[0]["ES_CTIME"].ToString()); } if (ds.Tables[0].Rows[0]["ES_TID"] != null && ds.Tables[0].Rows[0]["ES_TID"].ToString() != "") { model.ES_TID = ds.Tables[0].Rows[0]["ES_TID"].ToString(); } return model; } else { return null; } }