public void DeleteNoticeHtml(MNotice objNotice) { //生成静态页面后保存的路径 string strSavePath = HttpContext.Current.Server.MapPath("~/") + "Html/Notice/"; //定义新生成的html文件名 string strNewHtmlFileName = objNotice.NoticeHtmlName + ".html"; string Path = strSavePath + strNewHtmlFileName; if (File.Exists(@Path)) { File.Delete(@Path); } }
public DataTable SelectNoticeByID(MNotice objNotice) { StringBuilder sb = new StringBuilder(); sb.Append("select * from tb_notice where noticeID=@ID"); OleDbParameter[] param = { OleDbHelper.GetParameter("@ID", OleDbType.Integer, 4, "noticeID", objNotice.ID) }; DataTable dt = OleDbHelper.ExecuteDt(sb.ToString(), param); return(dt); }
/// <summary> /// 获取公告内容自动生成或更新XML文件 /// </summary> //public void SelectNoticeUpdXmlByID(MNotice objNotice) //{ // //注意:ADO.NET通过DataSet与XML进行交互。 // //定义一个数据集对象 // DataTable dt = new DataTable(); // dt.TableName = "Notice"; // //获取数据 // dt = notce.SelectNoticeByID(objNotice); // //实例化一个FileStream对象 // FileStream objFs = new FileStream(HttpContext.Current.Server.MapPath("~/Xml/NoticeXml/Notice.xml"), // FileMode.OpenOrCreate, FileAccess.Write); // DataSet ds = new DataSet(); // ds.Tables.Add(dt); // //将获取后的数据自动生成或更新xml文件 // ds.WriteXml(objFs); // //关闭新建对象 // objFs.Close(); //} /// <summary> /// 定义生成信息静态页面 /// </summary> public void CreateNoticeHtml(MNotice objNotice) { //生成静态页面后保存的路径 string strSavePath = HttpContext.Current.Server.MapPath("~/") + "Html/Notice/"; //静态页面样板所保存的路径 string strHtmlPath = HttpContext.Current.Server.MapPath("~/") + "Html/Notice/Model.html"; //定义样板读取变量并读样板 StreamReader objSr = new StreamReader(strHtmlPath, System.Text.Encoding.GetEncoding("gb2312"));//"utf-8" //文件数据流 string ObjContent = ""; //开始读取 try { ObjContent = objSr.ReadToEnd(); } catch (Exception ex) { HttpContext.Current.Response.Write(ex.Message); HttpContext.Current.Response.End(); objSr.Close(); } //定义新生成的html文件名 string strNewHtmlFileName = objNotice.NoticeHtmlName + ".html"; StreamWriter objSw = new StreamWriter(strSavePath + strNewHtmlFileName, false, System.Text.Encoding.GetEncoding("gb2312")); //写入生成的文件 ObjContent = ObjContent.Replace("T_Title", objNotice.NoticeTitle); ObjContent = ObjContent.Replace("N_Title", objNotice.NoticeTitle); ObjContent = ObjContent.Replace("N_Time", objNotice.NoticeTime.ToString()); ObjContent = ObjContent.Replace("N_Author", objNotice.NoticePerson); ObjContent = ObjContent.Replace("N_Content", objNotice.NoticeContent); try { objSw.Write(ObjContent); objSw.Flush(); } catch (Exception ex) { HttpContext.Current.Response.Write(ex.Message); HttpContext.Current.Response.End(); } finally { objSw.Close(); } }
public bool DeleteNoticeByID(MNotice objNotice) { StringBuilder sb = new StringBuilder(); sb.Append("delete from tb_notice where noticeID=@ID"); OleDbParameter[] param = { OleDbHelper.GetParameter("@ID", OleDbType.Integer, 4, "noticeID", objNotice.ID) }; bool is_succeed = OleDbHelper.ExecuteSql(sb.ToString(), param); if (is_succeed) { return(true); } else { return(false); } }
public bool UpdateNoticeByID(MNotice objNotice) { StringBuilder sb = new StringBuilder(); sb.Append("update tb_notice set noticeTitle=@Title,noticePerson=@NoticePerson,noticeContent=@NoticeContent where noticeID=@ID"); OleDbParameter[] param = { OleDbHelper.GetParameter("@Title", OleDbType.VarWChar, 40, "noticeTitle", objNotice.NoticeTitle), OleDbHelper.GetParameter("@NoticePerson", OleDbType.VarWChar, 20, "noticePerson", objNotice.NoticePerson), OleDbHelper.GetParameter("@NoticeContent", OleDbType.LongVarWChar, "noticeContent", objNotice.NoticeContent), OleDbHelper.GetParameter("@ID", OleDbType.Integer, 4, "noticeID", objNotice.ID) }; bool is_succeed = OleDbHelper.ExecuteSql(sb.ToString(), param); if (is_succeed) { return(true); } else { return(false); } }
public bool InsertIntoNotice(MNotice objNotice) { StringBuilder sb = new StringBuilder(); sb.Append("insert into tb_notice (noticeTitle,noticeTime,noticePerson,noticeContent,noticeHtmlName) values(@Title,@Datetime,@NoticePerson,@NoticeContent,@NoticeHtmlName)"); OleDbParameter[] param = { OleDbHelper.GetParameter("@Title", OleDbType.VarWChar, 40, "noticeTitle", objNotice.NoticeTitle), OleDbHelper.GetParameter("@Datetime", OleDbType.Date, "noticeTime", objNotice.NoticeTime), OleDbHelper.GetParameter("@NoticePerson", OleDbType.VarWChar, 20, "noticePerson", objNotice.NoticePerson), OleDbHelper.GetParameter("@NoticeContent", OleDbType.LongVarWChar, "noticeContent", objNotice.NoticeContent), OleDbHelper.GetParameter("@NoticeHtmlName", OleDbType.VarWChar, 50, "noticeHtmlName", objNotice.NoticeHtmlName) }; bool is_succeed = OleDbHelper.ExecuteSql(sb.ToString(), param); if (is_succeed) { return(true); } else { return(false); } }
public DataTable SelectNoticeByID(MNotice objNotice) { return(notce.SelectNoticeByID(objNotice)); }
public bool UpdateNoticeByID(MNotice objNotice) { return(notce.UpdateNoticeByID(objNotice)); }
public bool DeleteNoticeByID(MNotice objNotice) { return(notce.DeleteNoticeByID(objNotice)); }
public bool InsertIntoNotice(MNotice objNotice) { return(notce.InsertIntoNotice(objNotice)); }