家教信息管理系统毕业论文设计(ASP.NET)(6)
资料介绍:
}
}
//删除帖子
protected void lbtDelPost_Click(object sender, EventArgs e)
{
//当前点击的按钮
LinkButton lb = (LinkButton)sender;
// 获取传过来的id
string postId = lb.CommandArgument;
//删除帖子
bool b = PostManager.DelPost(postId);
if (b)
{
//重新绑定帖子表
rePost.DataSource = PostManager.SelectAllPost();
rePost.DataBind(); [资料来源:Doc163.com]
}
else
{
//帖子删除失败
Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('帖子删除失败,请联系管理员!');</script>");
}
}
}
#region 取出所有帖子
/// <summary>
/// 取出所有帖子
/// </summary>
/// <returns></returns>
public DataTable SelectAllPost()
{ [来源:http://Doc163.com]
DataTable dt = new DataTable();
dt = sqlhelper.ExecuteQuery("post_SelectAll", CommandType.StoredProcedure);
return dt;
}
#endregion
#region 添加帖子
/// <summary>
/// 添加帖子
/// </summary>
/// <param name="p">帖子实体类</param>
/// <returns></returns>
public bool InsertPost(Post p)
{
[资料来源:http://www.doc163.com]
bool flag = false;
string cmdText = "post_Insert";
SqlParameter[] paras = new SqlParameter[] {
new SqlParameter("@postTitle",p.PostTitle)
};
int res = sqlhelper.ExecuteNonQuery(cmdText, paras, CommandType.StoredProcedure);
if (res > 0)
{
flag = true;
}
[资料来源:http://Doc163.com]
return flag;
}
#endregion
#region 删除帖子(连同其下的评论一起删除)
/// <summary>
/// 删除帖子(连同其下的评论一起删除)
/// </summary>
/// <param name="postId">帖子ID</param>
/// <returns></returns>
public bool DelPost(string postId)