网学网JSP,NET,JAVA类别编辑为广大网友搜集整理了:VB.NET博客系统的设计绩等信息,祝愿广大网友取得需要的信息,参考学习。
客服咨询,网学网竭诚为您服务,本站永久域名:myeducs.cn |
5.4 博客类别维护 本模块主要功能:对于博客类别的维护,包括添加或删除,如图所示: 图5.4 博客类别维护图 相关代码如下: Dim tmpData As New DataControl Private Sub initDg() ''显示类别 GridView1.DataSource = tmpData.Get_Table("select * from 类别") GridView1.DataBind() TextBox1.Text = "" Terr.InnerHtml = "" End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then ''调用函数 initDg() End If End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ''校验信息是否正确 If Me.TextBox1.Text = "" Then Terr.InnerHtml = "<font color=''red''>名称不能为空</font>" Exit Sub End If If tmpData.Get_Table("select * from 类别 where 名称=''" & TextBox1.Text.Trim() & "''").Rows.Count > 0 Then Terr.InnerHtml = "<font color=''red''>名称重复</font>" Exit Sub End If ''添加信息 tmpData.ExecSql("insert into 类别(名称) values(''" & TextBox1.Text.Trim() & "'')") initDg() End Sub Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand If e.CommandName = "Del" Then ''判断记录是否允许删除 Dim Key As String = GridView1.DataKeys(Convert.ToInt32(e.CommandArgument)).Value.ToString() If (tmpData.Get_Table("select * from 博客 where 类别编号=" + Key + "").Rows.Count > 0) Then Terr.InnerHtml = "<font color=''red''>当前类别正在使用!</font>" Exit Sub End If ''删除记录 刷新列表 tmpData.ExecSql("delete from 类别 where 编号=" + Key) initDg() End If End Sub 5.5 博客日志管理 本模块的主要功能:是管理会员发布的日志信息和会员评论的信息,如图所示: 图5.5 博客日志列表图 图5.6 博客评论图 相关代码如下: Dim key As String = GridView1.DataKeys(Convert.ToInt32(e.CommandArgument)).Value.ToString() If e.CommandName = "Del" Then Dim DPath As String If Server.MapPath("").Substring(Server.MapPath("").Length - 1, 1) = "\" Then DPath = Server.MapPath("") Else DPath = Server.MapPath("") + "\" End If DPath = DPath + "..\User\Pic\" Dim PicName As String = tmpData.Get_Table("select 图片 from 日志 where 编号=" + key + "").Rows(0)(0).ToString() ''/删除关联的图片文件 If File.Exists(DPath & PicName) Then File.Delete(DPath & PicName) ''删除博客日志 tmpData.ExecSql("delete from 评论 where 博客编号=" + key + " ") tmpData.ExecSql("delete from 日志 where 编号=" + key + "") GridView1.DataSource = tmpData.Get_Table("select * from 日志 ") GridView1.DataBind() ElseIf e.CommandName = "See" Then Response.Write("<script>window.open(''BkzrSee.aspx?tkid=" + key + "'');</script>") End If Dim tmpData As New DataControl Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then If Request.QueryString("Tkid") <> "" Then ''如果没有登陆的会员 屏蔽评论按钮 If Session("UserId") = Nothing Then Button1.Visible = False ''根据传递的编号 将当前的日志信息显示在控件中 Dim DPath As String DPath = "..\User\Pic\" Dim tmpda As New DataTable() tmpda = tmpData.Get_Table("SELECT 日志.编号, 日志.主题, 日志.内容, 日志.图片, 日志.时间, 日志.帐号, 博客.名称 FROM 会员 INNER JOIN 日志 ON 会员.帐号 = 日志.帐号 INNER JOIN 博客 ON 会员.帐号 = 博客.帐号 where 日志.编号=" + Request.QueryString("Tkid")) If tmpda.Rows.Count > 0 Then TSpmc.InnerHtml = tmpda.Rows(0)("主题").ToString() TSpjs.InnerHtml = (tmpda.Rows(0)("内容")).Replace("\r\n", "<br>") TImage.InnerHtml = "<img src=" + DPath + tmpda.Rows(0)("图片") + ">" TJg.InnerHtml = "¥ " + tmpda.Rows(0)("时间").ToString() TD1.InnerHtml = tmpda.Rows(0)("名称").ToString() TD2.InnerHtml = tmpda.Rows(0)("帐号").ToString() Me.GridView1.DataSource = tmpData.Get_Table("select * from 评论 where 博客编号=" & Request.QueryString("Tkid") & "") Me.GridView1.DataBind() End If End If End If End Sub |
本站发布的计算机毕业设计均是完整无错的全套作品,包含开题报告+程序+论文+源代码+翻译+答辩稿PPT |
本文选自计算机毕业设计http://myeducs.cn |