//修改 protected void btnUpdate_Click(object sender, EventArgs e) { if (txtTitle.Text.Trim().Length == 0 || this.Textarea1.Value.Trim().Length == 0) { Javascript.GoHistory(-1, "标题和内容不能为空,请输入!", Page); } else { DalOperationAboutEnglishExam dalOperationAboutEnglishExam = new DalOperationAboutEnglishExam(); EnglishExamNotify notify = new EnglishExamNotify(); notify.englishExamNotifyId = englishExamNotifyInfoId; notify.englishExamNotifyTitle = txtTitle.Text.Trim(); notify.englishExamNotifyContent = this.Textarea1.Value.Trim(); notify.attachmentIds = hidAttachmentId.Value; notify.deadLineTime = Convert.ToDateTime(datepicker.Value); notify.updateTime = DateTime.Now; notify.locale = ddlLocale.SelectedValue; try { dalOperationAboutEnglishExam.UpdateEnglishExamNotifyById(notify);//修改 Javascript.RefreshParentWindow("修改成功!", "/Administrator/EnglishExamManage.aspx?page="+pageIndex, Page); } catch (Exception ex) { MongoDBLog.LogRecord(ex); Javascript.GoHistory(-1, "修改失败,请检查格式是否有误!", Page); } } }
/// <summary> /// 发布四六级通知 /// </summary> /// <returns></returns> public int AddEnglishExamNotify(EnglishExamNotify englishExamNotify) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into usta_EnglishExamNotify("); strSql.Append("englishExamNotifyTitle,englishExamNotifyContent,attachmentIds,deadLineTime,locale)"); strSql.Append(" values ("); strSql.Append("@englishExamNotifyTitle,@englishExamNotifyContent,@attachmentIds,@deadLineTime,@locale);"); SqlParameter[] parameters = { new SqlParameter("@englishExamNotifyTitle", SqlDbType.NChar,50), new SqlParameter("@englishExamNotifyContent", SqlDbType.NText), new SqlParameter("@attachmentIds", SqlDbType.NVarChar,200), new SqlParameter("@deadLineTime", SqlDbType.DateTime), new SqlParameter("@locale", SqlDbType.NVarChar,20)}; parameters[0].Value = englishExamNotify.englishExamNotifyTitle; parameters[1].Value = englishExamNotify.englishExamNotifyContent; parameters[2].Value = englishExamNotify.attachmentIds; parameters[3].Value = englishExamNotify.deadLineTime; parameters[4].Value = englishExamNotify.locale; return SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters); }
/// <summary> /// 根据Id修改四六级通知 /// </summary> /// <returns></returns> public int UpdateEnglishExamNotifyById(EnglishExamNotify englishExamNotify) { StringBuilder strSql = new StringBuilder(); strSql.Append("update usta_EnglishExamNotify set "); strSql.Append("englishExamNotifyTitle=@englishExamNotifyTitle,"); strSql.Append("englishExamNotifyContent=@englishExamNotifyContent,"); strSql.Append("attachmentIds=@attachmentIds,"); strSql.Append("deadLineTime=@deadLineTime,"); strSql.Append("locale=@locale"); strSql.Append(" where englishExamNotifyId=@englishExamNotifyId"); SqlParameter[] parameters = { new SqlParameter("@englishExamNotifyTitle", SqlDbType.NChar,50), new SqlParameter("@englishExamNotifyContent", SqlDbType.NText), new SqlParameter("@attachmentIds", SqlDbType.NVarChar,200), new SqlParameter("@updateTime", SqlDbType.DateTime), new SqlParameter("@deadLineTime", SqlDbType.DateTime), new SqlParameter("@englishExamNotifyId", SqlDbType.Int,4), new SqlParameter("@locale", SqlDbType.NVarChar,20)}; parameters[0].Value = englishExamNotify.englishExamNotifyTitle; parameters[1].Value = englishExamNotify.englishExamNotifyContent; parameters[2].Value = englishExamNotify.attachmentIds; parameters[3].Value = englishExamNotify.updateTime; parameters[4].Value = englishExamNotify.deadLineTime; parameters[5].Value = englishExamNotify.englishExamNotifyId; parameters[6].Value = englishExamNotify.locale; return SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters); }
/// <summary> /// 获取指定Id的四六级通知数据 /// </summary> /// <returns></returns> public EnglishExamNotify GetEnglishExamNotifyById(int englishExamNotifyId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 englishExamNotifyId,englishExamNotifyTitle,englishExamNotifyContent,deadLineTime,attachmentIds,updateTime,locale from usta_EnglishExamNotify "); strSql.Append(" where englishExamNotifyId=@englishExamNotifyId"); SqlParameter[] parameters = { new SqlParameter("@englishExamNotifyId", SqlDbType.Int,4) }; parameters[0].Value = englishExamNotifyId; EnglishExamNotify model = new EnglishExamNotify(); DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["englishExamNotifyId"] != null && ds.Tables[0].Rows[0]["englishExamNotifyId"].ToString().Trim() != "") { model.englishExamNotifyId = int.Parse(ds.Tables[0].Rows[0]["englishExamNotifyId"].ToString().Trim()); } if (ds.Tables[0].Rows[0]["englishExamNotifyTitle"] != null && ds.Tables[0].Rows[0]["englishExamNotifyTitle"].ToString().Trim() != "") { model.englishExamNotifyTitle = ds.Tables[0].Rows[0]["englishExamNotifyTitle"].ToString().Trim(); } if (ds.Tables[0].Rows[0]["englishExamNotifyContent"] != null && ds.Tables[0].Rows[0]["englishExamNotifyContent"].ToString().Trim() != "") { model.englishExamNotifyContent = ds.Tables[0].Rows[0]["englishExamNotifyContent"].ToString().Trim(); } model.attachmentIds = ds.Tables[0].Rows[0]["attachmentIds"].ToString(); if (ds.Tables[0].Rows[0]["updateTime"] != null && ds.Tables[0].Rows[0]["updateTime"].ToString().Trim() != "") { model.updateTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["updateTime"].ToString().Trim()); } if (ds.Tables[0].Rows[0]["deadLineTime"] != null && ds.Tables[0].Rows[0]["deadLineTime"].ToString().Trim() != "") { model.deadLineTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["deadLineTime"].ToString().Trim()); } model.locale = string.Empty; if (ds.Tables[0].Rows[0]["locale"] != null && ds.Tables[0].Rows[0]["locale"].ToString().Trim() != "") { model.locale = ds.Tables[0].Rows[0]["locale"].ToString().Trim(); } return model; } else { return null; } }
//第1个标签:结束 protected void btnAdd_Click(object sender, EventArgs e) { if (txtTitle.Text.Trim().Length == 0 || Textarea1.Value.Trim().Length == 0) { Javascript.GoHistory(-1, "标题和内容不能为空,请输入!", Page); Javascript.ExcuteJavascriptCode("delBeforeUnloadEvent();", Page); } else { DalOperationAboutEnglishExam dalOperationAboutEnglishExam = new DalOperationAboutEnglishExam(); EnglishExamNotify englishExamNotify = new EnglishExamNotify(); englishExamNotify.englishExamNotifyTitle = txtTitle.Text.Trim(); englishExamNotify.englishExamNotifyContent = Textarea1.Value.Trim(); englishExamNotify.deadLineTime = Convert.ToDateTime(datepicker.Value.Trim()); englishExamNotify.locale = ddlLocale.SelectedValue; //以下提交附件的判断与相关操作 if (hidAttachmentId.Value.CompareTo(string.Empty) != 0) { englishExamNotify.attachmentIds = hidAttachmentId.Value;//保存了附件并且返回了attachmentId(自增长类型主键) } try { dalOperationAboutEnglishExam.AddEnglishExamNotify(englishExamNotify);//保存通知 Javascript.ExcuteJavascriptCode("delBeforeUnloadEvent();", Page); Javascript.AlertAndRedirect("添加成功!", "/Administrator/EnglishExamManage.aspx?fragment=1", Page); } catch (Exception ex) { MongoDBLog.LogRecord(ex); Javascript.ExcuteJavascriptCode("delBeforeUnloadEvent();", Page); Javascript.GoHistory(-1, "添加失败,请检查格式是否有误!", Page); } } }