当前位置:首页 > 个人博客设计报告
cmd.ExecuteNonQuery (); } finally{
m_Connection.Close (); } }
public DataSet GetNotes (DateTime fromDate, DateTime toDate) {
DataSet ds = new DataSet ();
// 查询特定时间段内张贴的文章,填入DataSet的MyNotes表中
OleDbDataAdapter da = new OleDbDataAdapter (\* FROM Notes WHERE DateTime BETWEEN ? AND ? ORDER BY DateTime DESC\
da.SelectCommand.Parameters.Add (\ da.SelectCommand.Parameters.Add (\(1);
m_Connection.Open (); da.Fill (ds, \ // 关闭数据库连接 m_Connection.Close (); return ds; // 返回数据集 }
public DataSet GetComments (int noteID, ref int count) { DataSet ds = new DataSet ();
String selectCmd = \ OleDbDataAdapter da = new OleDbDataAdapter (selectCmd, m_Connection);
da.SelectCommand.Parameters.Add (\ m_Connection.Open (); da.Fill (ds, \
count = ds.Tables[\ m_Connection.Close (); return ds; }
public void InsertNote (String title, String contents) {
OleDbCommand cmd = new OleDbCommand (\(?, ?)\
cmd.Parameters.Add (\
cmd.Parameters.Add (\(m_brChar, \
ExecuteCommand (cmd); }
public void InsertComment (int noteID, String author, String email, String comment){ OleDbCommand cmd =
new OleDbCommand (\VALUES(?, ?, ?, ?)\
cmd.Parameters.Add (\ cmd.Parameters.Add (\ cmd.Parameters.Add (\
cmd.Parameters.Add (\(m_brChar, \
ExecuteCommand (cmd);
// 如果邮件提醒功能打开,则发送一封邮件给博客主人
String sendNotifications = ConfigurationManager.AppSettings[\ if (sendNotifications != null && sendNotifications == \ {
String noteTitle = String.Empty, noteDate = String.Empty; // 读取父消息的细节(标题和发布时间)
cmd.CommandText = \ m_Connection.Open ();
OleDbDataReader reader = cmd.ExecuteReader (CommandBehavior.CloseConnection); if (reader.Read ()){
noteTitle = reader[\
noteDate = ((DateTime) reader[\ reader.Close (); }
// 创建Email提醒的内容
String mailMsg = String.Format (\刚刚在你的博客上张贴了评论)\ + \“{2}”,张贴时间为{3}。评论内容如下:{4}{4}{5}\
author, email, noteTitle, noteDate, Environment.NewLine, comment); // 发送邮件
SmtpClient smtpClient = new SmtpClient (); smtpClient.Send (\
ConfigurationManager.AppSettings[\ \新的评论\ } }
public void UpdateNote (int noteID, String title, String contents) {
OleDbCommand cmd = new OleDbCommand (\WHERE [NoteID] = ?\
cmd.Parameters.Add (\
cmd.Parameters.Add (\(m_brChar, \
cmd.Parameters.Add (\ ExecuteCommand (cmd); }
public void UpdateComment (int commentID, String author, String email, String comment) {
OleDbCommand cmd = new OleDbCommand (\
+ \
cmd.Parameters.Add (\ cmd.Parameters.Add (\
cmd.Parameters.Add (\(m_brChar, \
cmd.Parameters.Add (\ ExecuteCommand (cmd); }
public void DeleteNote (int noteID){
OleDbCommand cmd = new OleDbCommand (\ ExecuteCommand (cmd);
cmd.CommandText = \ ExecuteCommand (cmd); }
public void DeleteComment (int commentID){
OleDbCommand cmd = new OleDbCommand (\commentID);
ExecuteCommand (cmd); }
public void GetNoteData (int noteID, ref String title, ref String contents, ref String post_time){
OleDbCommand cmd = new OleDbCommand (\ + noteID, m_Connection); try{
m_Connection.Open ();
OleDbDataReader reader = cmd.ExecuteReader (CommandBehavior.CloseConnection); if (reader.Read ()){
title = reader[\
contents = reader[\ post_time = reader[\ reader.Close (); } } finally {
m_Connection.Close (); } }
public void GetCommentData (int commentID, ref String author, ref String email, ref String comment) {
OleDbCommand cmd = new OleDbCommand (\ + commentID, m_Connection); try{
m_Connection.Open ();
OleDbDataReader reader = cmd.ExecuteReader (CommandBehavior.CloseConnection);
if (reader.Read ()){
author = reader[\ email = reader[\
comment = reader[\ reader.Close (); } } finally{
m_Connection.Close (); } } }
5、系统数据结构设计
a) 文章的主要数据类型
数据库中文章所在表的名称为:Notes。 文章ID: NoteID 数字类型(自动编号) 文章标题: Title 文本类型 文章内容: Contents 备注类型 张贴时间: DataTime 日期/时间类型
b) 评价的主要数据类型
数据库中评价所在的表的名称为:Comments。 评价ID: CommentID 数字类型(自动编号) 对应文章ID: NoteID 数字类型 游客名称: Author 文本类型 Email地址: Email 文本类型 评价内容: Comment 备注类型 发布时间: DataTime 日期/时间类型
6、博客整体显示
共分享92篇相关文档