asp.net课程设计--新闻发布系统
最近更新 2024年06月18日
资源编号 220

asp.net课程设计--新闻发布系统

郑重承诺丨云炬网络提供安全交易、信息保真!
云炬公益:平台收入的50%以上将进行公益慈善捐赠(不定期公示):
详情介绍
asp.net课程设计--新闻发布系统

 

1.概述(绪论)…………………………………………………………1

1.1本网站系统实现的功能 ………………………………………1

1.2 开发环境简介…………………………………………………1

2.需求分析……………………………………………………………1

2.1 开发背景………………………………………………………1

2.2 开发目的………………………………………………………2

2.3 数据需求………………………………………………………2

2.4 功能需求………………………………………………………3

3.系统设计……………………………………………………………4

总体设计……………………………………………………………4

4.数据库设计……………………………………………………………4

4.1 概念设计(E-R图)……………………………………………4

4.2 逻辑设计………………………………………………………4

5.详细设计……………………………………………………………5

6.系统实现……………………………………………………………5

7.系统总结……………………………………………………………25

7.1在各开发环境下实现的功能………………………………25

7.2 系统不足,系统扩展构想…………………………………27

8.参考文献…………………………………………………………28

9. 附录………………………………………………………………28

1.概述(绪论)

1.1本网站系统实现的功能

利用ASP.NET和数据库技术开发的青岛理工大学新闻发布管理系统,实现了网站前台动态显示和后台的新闻动态管理,使得对信息的查看和管理更加及时、高效,大大提高了学生的查看效率和工作效率。创建成了“校内快讯 通知公告 教育管理 学院风采 科学研究 杏坛理工 学生之声 高校之声”等分类。

1.2 开发环境简介

Visual Studio 2005 是一套完整的开发工具,用于生成 ASP.NET Web 应用程序、XML Web Services、桌面应用程序和移动应用程序。Visual Basic、Visual C# 和 Visual C++ 都使用相同的集成开发环境 (IDE),这样就能够进行工具共享,并能够轻松地创建混合语言解决方案。另外,这些语言使用 .NET Framework 的功能,它提供了可简化 ASP Web 应用程序和 XML Web Services 开发的关键技术。

万维网最初实现从服务器向客户机的静态数据发送,这个数据用超文本标记语言(HTTP)发送,至今仍然如此。HTML页面从服务器向客个机移动时人改变形式,是响应超文本传输协议(HTTP)请求发送的。而这些开发语言的出现,实现了网站的动态性,更易于网站的交互性。

Visual Basic.NET是下一代的Visual Basic。而并不是简单的在Visual Basic 6.0上在添加一些新特性而已,微软重新设计了产品以便使开发者能够更加容易的开发分布式应用,例如基于WEB的程序以及多层系统。从而让我们在WEB开发方面展现出更大的优势。

2.需求分析

2.1 开发背景

随着Internet的普及,越来越多的企业建立了自己的WWW网站,企业通过网站可以展示产品,发布最新动态,与用户进行交流和沟通,与合作伙伴建立联系,以及开展电子商务等。其中新闻管理系统是构成企业网站的一个重要组成部分,它担负着双层作用,一方面可以用来动态发布有关新产品或新开发项目,另一方面又可以及时向顾客公告企业经营业绩、技术与研发进展、特别推荐或优惠的工程项目、产品和服务,从而吸引顾客,扩大顾客群。

作为学校这样的单位,同样具有与企业相当的新闻发布性,当然,学校在网站技术渐渐发展的时候需要建立这样的新闻发布网站!

作为互联网这一新兴的媒体新闻发布形式,其发展在近几年是有目共睹的,企业网站、个人博客、行业网站、门户站等一大批的网站相继建立,大到行业小到个人博客。学校网站则更需要在这发展中突显出其中的优势。

传统的网站新闻管理方式有两种,一是静态HTML页面,更新信息时需要重新制作页面然后上传页面并修改相应链接,这种方式因为效率太低已不多用。二是基于ASP和脚本语言,将动态网页和数据库结合,通过应用程序来处理新闻,这是目前较为流行的做法。但是由于ASP本身的局限性使得系统有一些不可克服的缺陷,而采取了ASP.NET技术的系统性能上有了很大的改善,其主要表现在以下几方面:
1.由于ASP页面每次打开都必须经过先编译后解释的过程,所以页面在反复打开时速度没有任何提升,而ASP.NET页面只需要一次编译后不需要重新编译,直到该页面被修改或Web应用程序重新启动。这使得在多次访问时速度有了极大的提升。
2.由于ASP没有提供任何输出数据为内容的元件,所以在使用ASP撰写数据库页面时只能借助ADO的RecordSet对象逐笔读取记录,而ASP.NET通过ADO.NET提供的DataGrid等数据库元件可以直接和数据库联系。
3.ASP.NET支持应用程序的实时更新。管理员不必关掉网络服务器或者甚至不用停止应用程序的运行就可以更新应用文件。应用程序文件永远不会被加锁,因此甚至在程序运行时文件就可以被覆盖。当文件更新后,系统会温和地转换到新的版本。
4.ASP.NET采取"code-behind"方式编写代码使得代码更易于编写,结构更清晰,降低了系统的开发与维护的复杂度和费用。

2.2 开发目的

用Internet的普及,来改造校园信息发布的时代,让更多的学生可以在信息化的时代更真实地感受到网站给大家生活带来的便利,同时加强校外了解本校动态,进一步提高校园办公的效率。

2.3 数据需求

本网站是校园信息类网站,目的在于及时的让本校学生了解最新的校园及校外资讯,属于中小型新闻类网站,数据处理不是很复杂,主要处理新闻信息,图片显示,以及用户信息,搜索查询等,故采用ACCESS数据库开发。

以下为本站的数据字典:

表:admin(管理组权限设置)

序号 字段名 类型 长度 允许空 主键 说明
1 id 自动编号 50 管理组id
2 username 文本 50 登录名
3 password 密码 50 密码
4 Email 文本 50

表:classes(分类)

序号 字段名 类型 长度 小数位数 允许空 主键 说明
1 ClassesID 自动编号 长整型 分类自动编号
2 ClassesName 文本 50 分类名称

表:news:(新闻)

序号 字段名 类型 长度 小数位数 允许空 主键 说明
1 NewID 自动编号 长整型 新闻自动编号
2 ClassesID 数字 数字 新闻分类编号
3 Title 文本 50 新闻标题
4 Author 文本 50 新闻作者
5 Original 文本 50 新闻出处
6 UpdateTime 日期/时间 50 新闻更新时间
7 Content 备注 50 新闻内容

表:ReViewID:(评论)

序号 字段名 类型 长度 小数位数 允许空 主键 说明
1 ReViewID 自动编号 长整型 新闻评价编号
2 NewID 自动编号 长整型 新闻自动编号
3 ReViewTitle 文本 50 评价标题
4 Author 文本 100 评价作者
5 Email 文本 100 作者邮箱
6 Content 备注 50 评价内容

2.4 功能需求

该新闻管理系统可以在Windows 2000 Server操作系统平台上运行,Web服务器为IIS,数据库为ACCESS,开发工具采用的Microsoft Visual Studio .NET和DreamWeaver。其工作流程为:用户登录通过权限判断,普通用户只能浏览、阅读和查询新闻,可以留言,注册用户除了可以完成普通用户的操作外,还可以进入新闻管理模块进行新闻录入、修改和删除的操作。注册用户除系统管理员外只能对自己录入的新闻进行删改操作。

包括常见网站的新闻管理的各个方面:新闻录入、浏览、删除、修改、检索等各个方面,完整地实现了网站对即时新闻的管理要求。

3.系统设计

总体主要分前台和后台两大部分。操作简单、界面友好:完全控件式的页面布局,使得新闻的录入工作更简便;许多选项包括新闻类别、来源等只需要点击鼠标就可以完成;另外,跟踪出现的提示信息也让用户随时清楚自己的操作情况。

4.数据库设计

4.1 概念设计(E-R图)

网站总索引

4.2 逻辑设计
基于ASP.NET技术的系统结构模型
ASP.NET结构是一个三层系统:UI层、业务逻辑层和数据层,如图1所示。

asp.net课程设计--新闻发布系统

图1 ASP.NET的系统结构模型

UI层负责与用户交互,接收用户的输入并将服务器端传来的数据呈现给客户。
业务逻辑层负责接收浏览器传来的请求并将请求传给数据层,同时将请求处理结果发给浏览器。它由Web表单、XML Web服务和组件服务组成。其中Web表单是ASP.NET应用程序的核心所在,它是向客户呈现数据和信息的基础,也是响应和处理客户与显示的Web表单交互生成的信息和数据的基础。
数据层是通过ADO.NET操纵数据为事务逻辑层提供数据服务,如存储数据操作结果、返回数据检索结果等。

5.详细设计

系统的主要功能是通过几个功能模块来实现的。具体的设计过程如下:
⑴ 系统登录:该模块负责将用户分为普通用户和注册用户来实现用户权限的管理。
⑵ 新闻浏览:该模块负责分页列出网站所有新闻的信息,包括标题、分类、来源字段及发布日期,每条新闻的标题被做成一个超链接,点击它们就能跳转页面进行新闻阅读。
⑶ 新闻阅读:在其他页面中点击标题链接即进入新闻阅读页面,此时,每条新闻的详细信息将被取出,包括内容、标题、关键字等,并按照相对固定的格式放置在页面的不同区域,所有新闻使用大致相同的页面布局,只是各字段对应的内容不同而已,另外,页面其它位置,可以动态放置其他元件,如网站标志logo、页面广告banner等链接图片,这样可以很容易地实现图文并茂的阅读效果。
⑷ 新闻查询:该模块提供了新闻查询功能,输入待查找的内容及选定分类信息可以快速地找到符合条件的新闻,并输出查询结果。
⑸ 新闻管理:该模块负责分页罗列登录的注册用户曾发布过且未删除的新闻信息,用户可以对该条新闻进行删除、修改。非新闻发布者除系统管理员外不具有对该条新闻的处理权限,所以不同用户进入此页面将显示不同的内容。
⑹ 新闻录入和修改:录入一条新闻所需要的内容,包含标题、关键字、类型、来源部门、发布日期等,同时从登录模块得到用户名,这些信息将被写入数据库中保存。该模块还负责编辑状态下的更新,这时,它将根据取得的Title字段值对页面控件初始化。

6.系统实现

1)ACCESS数据库的结构及内容设计部分(Qtech/luyudata.mdb):

asp.net课程设计--新闻发布系统
asp.net课程设计--新闻发布系统
asp.net课程设计--新闻发布系统

2)网站美化部分,作为网站开发工作的重要一步,为追求美观和谐,需要做大量的事前工作,本站用photo和flash设计制作,制作的前期效果:

asp.net课程设计--新闻发布系统
asp.net课程设计--新闻发布系统

3)在VB.NET中创建WEB工程,并进行主要程序代码设计:

//css/style.css网站样式表文件

body

{font-family: 宋体,arial;

font-size: 12px;

padding:0;

margin:0 auto;

}

table {font-size: 12px;}

td {font-size: 12px;}

p {color: #000000;

font-size: 12px;

font-weight: normal;

line-height: 12px;}

li {color: #000000;

font-size: 12px;

text-decoration: none;}

br {font-size: 12px;

font-weight: normal;

line-height: 12px;}

b {font-weight: bold}

a {color: #083898;

font-size: 12px;

font-weight: normal;

text-decoration: none;}

a:visited {color: #083898;

text-decoration: none;}

a:active {color: #ff9933

text-decoration: none;}

a:hover {color: #ff9933;

text-decoration: none;}

.lr {color: #083898;

font-size: 12px;

font-weight: normal;

text-decoration: none;}

.nav {color: #083898;

font-size: 12px;

font-weight: normal;

text-decoration: underline;}

.banner {font-size: 12px;

font-weight: normal;

text-decoration: none;}

.sys {color: #666666;

font-size: 12px;

font-weight: normal;

text-decoration: underline;}

.affiche {color: #333333;

font-size: 12px;

font-weight: normal;}

.fonttitle {color: #993333;

font-size: 12px;

font-weight: bold;}

.title {color: #666699;

font-size: 12px;

font-weight: bold;}

//web.config网站配置文件

<?xml version="1.0"?>

<configuration>

<appSettings/>

<connectionStrings/>

<system.web>

<compilation debug="true"/>

<authentication mode="Windows"/>

<customErrorsmode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">

<error statusCode="403" redirect="NoAccess.htm" />

<error statusCode="404" redirect="FileNotFound.htm" />

</customErrors>

</system.web>

</configuration>

//Default.aspx首页文件

<!—头部信息,包含了各模块用的文件-->

<%@ Page Language="VB" Debug="true" %>

<%@ Import Namespace="System.Data" %>

<%@ Import Namespace="System.Data.OleDb" %>/数据库连接所用库包

<%@ Register TagPrefix="mynews" TagName="top" src="ascx/top.ascx"%>/网站头部

<%@ Register TagPrefix="mynews" TagName="footer" src="ascx/footer.ascx"%>/网站底部

<%@ Register TagPrefix="mynews" TagName="search" src="ascx/search.ascx"%>/用于显示搜索板块

<%@ Register Src="ascx/newslist.ascx" TagName="newslist" TagPrefix="mynews" %>/用于显示新闻资讯具体内容

<html>

<head>

<title>青岛理工大学新闻发布系统</title>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<link href="style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" type="text/css" rel="Stylesheet" />

</head>

<body>

<mynews:top runat="server" ID="top1" />

<table width="778px" border="0" align="center" cellpadding="0" cellspacing="6px">

<tr>

<td width="578px">

<mynews:newslist ID="newslist1" runat="server"/>

</td>

<td width="200px" valign="top">

<mynews:search ID="Search1" runat="server"/>

</td>

</tr>

</table>

<mynews:footer ID="End1" runat="server"/>

</body>

</html>

//newshow.aspx新闻显示代码

<%@ Page Language="VB" ContentType="text/html" debug="true"%>

<%@ Import Namespace="System.Data" %>

<%@ Import Namespace="System.Data.OleDb" %>

<%@ Register TagPrefix="mynews" TagName="top" src="ascx/top.ascx"%>

<%@ Register TagPrefix="mynews" TagName="review" src="ascx/review.ascx"%>

<%@ Register TagPrefix="mynews" TagName="newslist" src="ascx/newslist.ascx"%>

<%@ Register TagPrefix="mynews" TagName="footer" src="ascx/footer.ascx"%>

<script language="VB" runat="server">

Dim sql, newstitle, part1, part2 As String

Dim newsno As Integer

Dim myconn As OleDbConnection

Dim myCmd, newscmd As OleDbCommand

'获取数据子程序

Function getdatareader(ByVal sql As String) As OleDbDataReader

myCmd = New OleDbCommand(sql, myconn)

myconn.Open()

getdatareader = myCmd.ExecuteReader()

End Function

'替换特殊字符子程序

Function changecode(ByVal str As String)

If Len(str) > 0 Then

str = Replace(str, Chr(32), " ")

str = Replace(str, Chr(9), "&nbsp;")

str = Replace(str, Chr(34), "&quot;")

str = Replace(str, Chr(39), "&#39;")

str = Replace(str, Chr(13), "")

str = Replace(str, Chr(10) & Chr(10), "</P><P>")

str = Replace(str, Chr(10), "<BR> ")

str = Replace(str, "[img]", "<img src='")

str = Replace(str, "[/img]", "'>")

str = Replace(str, "[b]", "<b>")

str = Replace(str, "[/b]", "</b>")

str = Replace(str, "[em]", "<em>")

str = Replace(str, "[/em]", "</em>")

str = Replace(str, "[u]", "<u>")

str = Replace(str, "[/u]", "</u>")

str = Replace(str, "[center]", "<center>")

str = Replace(str, "[/center]", "</center>")

str = Replace(str, "[mail]", "<a href='mailto:")

str = Replace(str, "[url]", "<a href='")

str = Replace(str, "[|mail]", "'>")

str = Replace(str, "[|url]", "'>")

str = Replace(str, "[/hyper]", "</a>")

str = Replace(str, "[upimg]", "<img src=upload/")

str = Replace(str, "[/upimg]", ">")

part1 = Left(str, InStr(str, ">"))

part2 = Right(str, (Len(str) - InStr(str, ">")))

str = part1 + part2

Return str

End If

End Function

'读取新闻详细信息

Sub Page_Load(sender As Object, e As EventArgs)

Dim strConn As String

strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&server.MapPath("./")&"Qtech/luyudata.mdb"

myConn = New OledbConnection(strConn)

if not page.ispostback then

newsno=Page.request("newsid")

sql="select Title,Author,UpdateTime,Original,Content from News where NewsID="&newsno

dim reader as OleDbDataReader=getdatareader(sql)

while reader.read()

session("newstitle")=reader.Item(0)

title.text=reader.Item(0)

author.text=reader.Item(1)

updatetime.text=reader.Item(2)

content.text=changecode(reader.Item(4))

original.text=reader.Item(3)

end while

myConn.close()

end if

End Sub

</script>

<html>

<head>

<title>新闻:<%=session("newstitle")%></title>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<link href="style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" type="text/css" rel="Stylesheet" />

</head>

<body>

<mynews:top runat="server" ID="top1" />

<form id="Form1" runat="server">

<table width="778px" border="0" align="center" cellpadding="0" cellspacing="6px">

<tr>

<td width="70%" valign="top">

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td align="center">

<font color="#009900"><b><asp:label ID="title" runat="server"/></b></font>

</td>

</tr>

<tr>

<td align="center" height="32px">

作者:<asp:label ID="author" runat="server"/>

更新时间:<asp:label ID="updatetime" runat="server"/>

</td>

</tr>

<tr>

<td>

<asp:label ID="content" runat="server"/>

</td>

</tr>

<tr>

<td align="right" height="36px">

源自:<asp:label ID="original" runat="server"/>

</td>

</tr>

<tr>

<td>

<mynews:review runat="server"/>

</td>

</tr>

</table>

</td>

<td align="center" valign="top" nowrap>

<mynews:newslist runat="server"/>

</td>

</tr>

</table>

</form>

<mynews:footer runat="server" ID="end1" />

</body>

</html>

footer.ascx底部文件

<br />

<table align="center" cellPadding=0 cellSpacing=0 style="WIDTH: 778px;">

<tr>

<td height=22 Align=center >

<table width="100%" height="100%" ><tr><td><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="download.macromedia.com" width="778" height="68">

<param name="movie" value="pic/bottom.swf" />

<param name="quality" value="high" />

<embed src="pic/bottom.swf" quality="high" pluginspage="macromedia.com/go/getfl" type="application/x-shockwave-flash" width="778" height="68"></embed>

</object></td></tr></table> </td>

</tr>

<tr>

<td height="22" align="center" background="pic/border1.gif" ><table width="100%" height="100%" style="BORDER-BOTTOM: #6595d6 1px solid; ">

<tr>

<td></td>

</tr>

</table></td>

</tr>

<tr>

<td height="24" align="center" >&nbsp;</td>

</tr>

<tr>

<td height="24" align="center" >

<a href="qtech.edu.cn" target="_blank">开发制作:陆瑜</a> <a href="./login.aspx" rel="external nofollow" >后台管理</a></td>

</tr>

<tr>

<td height="18" align="center" >

青岛理工大学新闻发布管理系统 </td>

</tr>

</table>

//newssearch.aspx新闻搜索

<%@ Page Language="VB" %>

<%@ Import Namespace="System.Data"%>

<%@ Import Namespace="System.Data.OleDb"%>

<%@ Register TagPrefix="mynews" TagName="top" src="ascx/top.ascx"%>

<%@ Register TagPrefix="mynews" TagName="special" src="ascx/newslist.ascx"%>

<%@ Register TagPrefix="mynews" TagName="footer" src="ascx/footer.ascx"%>

<script language="VB" runat="server">

Dim sql as string

Dim myConn as OleDbConnection

Dim myCmd as OleDbCommand

Function getdataview(ByVal sql As String, ByVal strtable As String) As DataView

Dim myDataAdapter As OleDbDataAdapter

Dim myDataSet As DataSet

myConn.Open()

myDataAdapter = New OleDbDataAdapter(sql, myConn)

myConn.Close()

myDataSet = New DataSet()

myDataAdapter.Fill(myDataSet, strtable)

getdataview = New DataView(myDataSet.Tables(strtable))

End Function

Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

Dim strConn As String

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("./") & "Qtech/luyudata.mdb"

myConn = New OleDbConnection(strConn)

Dim gjc As String

gjc = Page.Request("keyword")

sql = "select NewsID,Title,UpdateTime from News where Title like '%" & gjc & "%' or Content like '%" & gjc & "%' order by NewsID desc"

keyword.Text = gjc

Dim result As DataView = getdataview(sql, "newssearch")

searchresult.DataSource = result

searchresult.DataBind()

End Sub

</script>

<html>

<head>

<title>新闻搜索结果</title>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

</head>

<link href="style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" type="text/css" rel="Stylesheet" />

<body>

<mynews:top runat="server" ID="top1" />

<table width="778px" border="0" align="center" cellpadding="0" cellspacing="6px">

<tr>

<td width="478px" valign="top">

<table width="100%" cellpadding="2px" cellspacing="0" style="border:1px solid #6699FF;">

<tr>

<td bgcolor="#6699FF">

您的关键词是:<font color="#FF6600"><b><asp:label ID="keyword" runat="server"/></b></font>

</td>

</tr>

<asp:repeater ID="searchresult" runat="server">

<itemtemplate>

<tr>

<td>

<a href="newshow.aspx?newsid=<%# container.DataItem(" rel="external nofollow" NewsID")%>" target="_blank"><%# container.DataItem("Title")%></a>(<%# container.DataItem("UpdateTime")%>)

</td>

</tr>

</itemtemplate>

</asp:repeater>

</td>

</tr>

</table>

</td>

<td width="300px" valign="top">

<mynews:special ID="Special1" runat="server"/>

</td>

</tr>

</table>

<mynews:footer runat="server" ID="end1" />

</body>

</html>

//reviewshow.aspx评论查看

<%@ Page Language="VB" debug="true"%>

<%@ Import Namespace="System.Data"%>

<%@ Import Namespace="System.Data.OleDb"%>

<%@ Register TagPrefix="mynews" TagName="top" src="ascx/top.ascx"%>

<%@ Register TagPrefix="mynews" TagName="footer" src="ascx/footer.ascx"%>

<script language="VB" runat="server">

Dim sql, email, content As String

Dim newsid As Integer

Dim myConn As OleDbConnection

Dim myCmd As OleDbCommand

'获取数据子程序

Function getdatareader(ByVal sql As String) As OleDbDataReader

myCmd = New OleDbCommand(sql, myConn)

myConn.Open()

getdatareader = myCmd.ExecuteReader()

End Function

'特殊字符替换子程序

Function changecode(ByVal str As String)

If Len(str) > 0 Then

str = Replace(str, Chr(32), " ")

str = Replace(str, Chr(9), "&nbsp;")

str = Replace(str, Chr(34), "&quot;")

str = Replace(str, Chr(39), "&#39;")

str = Replace(str, Chr(13), "")

str = Replace(str, Chr(10) & Chr(10), "</P><P>")

str = Replace(str, Chr(10), "<BR> ")

Return str

End If

End Function

'初始化新闻评价信息子程序

Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

Dim strConn As String

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("./") & "Qtech/luyudata.mdb"

myConn = New OleDbConnection(strConn)

If Not Page.IsPostBack Then

newsid = Page.Request("reviewid")

sql = "select ReViewTitle,Content,Author,Email from ReView where ReviewID=" & newsid

Dim Reader As OleDbDataReader = getdatareader(sql)

While Reader.Read()

title.Text = Reader.Item(0)

content = changecode(Reader.Item(1))

author.Text = Reader.Item(2)

email = Reader.Item(3)

End While

myConn.Close()

End If

End Sub

</script>

<html>

<head>

<title>新闻评论</title>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<link href="style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" type="text/css" rel="Stylesheet" />

</head>

<body>

<mynews:top runat="server" ID="top1" />

<br />

<table width="76%" align="center" cellpadding="0" cellspacing="6">

<tr>

<td align="center">

<asp:label ID="title" runat="server"/>

</td>

</tr>

<tr>

<td align="right" height="30">

作者:<a href="mailto:<%=email%>" rel="external nofollow" >

<asp:label ID="author" runat="server"/></a>

</td>

</tr>

<tr>

<td><%=content%></td>

</tr>

</table>

<br />

<mynews:footer runat="server" ID="end1" />

</body>

</html>

//upfile.aspx文件上传

<script Language="VB" runat="server">

Sub UpLoadFile(ByVal Sender As Object, ByVal e As EventArgs)

'如果上传的长度为0,表示没有上传成功

If FileUp.PostedFile.ContentLength = 0 Then

Response.Write("文件上传失败!")

Exit Sub

End If

'储存上传的文件

Dim FileSplit() As String = Split(FileUp.PostedFile.FileName, "\")

Dim FileName As String = FileSplit(FileSplit.Length - 1)

Dim filext As String = LCase(Right(FileName, 4))

If filext = ".asp" Or filext = ".aspx" Or filext = ".ascx" Or filext = ".exe" Then

Response.Write("文件格式不对!")

Else

Dim ranNum As Integer = Int(90000 * Rnd()) + 10000

FileName = Year(Now) & Month(Now) & Day(Now) & Hour(Now) & Minute(Now) & Second(Now) & CStr(ranNum) & filext

step2.Visible = "False"

Response.Write("<div style='text-align:center;'><br>文件上传成功!请把以下代码插入到新闻的适当位置:[upimg]" & FileName & "[/upimg]")

Response.Write("<br><br><a href='upfile.aspx'>继续</a></div>")

FileUp.PostedFile.SaveAs(Server.MapPath(".") & "\upload\" & FileName)

End If

End Sub

</script>

<html>

<head>

<title>上传文件</title>

<link href="style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" type="text/css" rel="Stylesheet" />

</head>

<body>

<asp:panel ID="step2" runat="server">

<Form Enctype="multipart/form-data" runat="server">

<table width="97%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td align="center">

请输入文件路径:

<input name="File" type="File" id="FileUp" runat="server">(注:文件格式为:*.jpg,*.gif,*.bmp。)

<asp:Button id="Upload" class="buttonface" OnClick="UpLoadFile" Text="上传" runat="server"/>

</td>

</tr>

</table>

</form>

</asp:panel>

</body>

</html>

//login.aspx管理登录页面

<%@ Page Language="VB" ContentType="text/html"%>

<%@ Import Namespace="System.Data"%>

<%@ Import Namespace="System.Data.OleDb"%>

<%@ Register TagPrefix="mynews" TagName="top" src="ascx/top.ascx"%>

<%@ Register TagPrefix="mynews" TagName="footer" src="ascx/footer.ascx"%>

<script language="VB" runat="server">

Dim sql As String

Dim myConn As OleDbConnection

Dim myCmd As OleDbCommand

'获取数据子程序

Function getdatareader(ByVal sql As String) As OleDbDataReader

myCmd = New OleDbCommand(sql, myConn)

myConn.Open()

getdatareader = myCmd.ExecuteReader()

End Function

'初始化退出登录

Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

Dim strConn As String

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("./") & "Qtech/luyudata.mdb"

myConn = New OleDbConnection(strConn)

If Page.Request("action") = "logout" Then

Session("user") = ""

Response.Redirect("index.aspx")

End If

End Sub

'登录验证子程序

Sub addclick(ByVal sender As Object, ByVal e As EventArgs)

If username.Text = "" Then

message.Text = "请输入用户名!"

Else

If passward.Text = "" Then

message.Text = "请输入口令!"

Else

sql = "select username,passward from Admin where username='" & Trim(username.Text) & "'"

Dim userid, pass As String

Dim user As OleDbDataReader = getdatareader(sql)

While user.Read()

userid = user.Item(0)

pass = user.Item(1)

End While

myConn.Close()

If userid = "" Then

message.Text = "用户名不存在,请重新输入!"

username.Text = ""

passward.Text = ""

Else

If pass = passward.Text Then

Session("user") = "administrator"

message.Text = ""

Response.Redirect("newsmanager.aspx")

Else

message.Text = "口令错误!"

passward.Text = ""

End If

End If

End If

End If

End Sub

'清除变量信息子程序

Sub cancelclick(ByVal sender As Object, ByVal e As EventArgs)

message.Text = ""

username.Text = ""

passward.Text = ""

End Sub

</script>

<html>

<head>

<title>管理员登陆</title>

<link rel="stylesheet" href="style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

</head>

<body>

<mynews:top runat="server"/>

<form runat="server">

<table width="70%" cellspacing="0" cellpadding="1" align="center">

<tr>

<td>

<table width="100%" border="0" cellspacing="1" cellpadding="1">

<tr>

<td width="40%" align="right" height="30">用户名:</td>

<td>

<asp:textbox ID="username" MaxLength="20" Columns="20" class="smallInput" runat="server"/>

</td>

</tr>

<tr>

<td align="right">密 码:</td>

<td>

<asp:textbox ID="passward" MaxLength="20" Columns="20" TextMode="Password" class="smallInput" runat="server"/>

</td>

</tr>

<tr>

<td colspan="2" height="25" align="center">

<asp:label ID="message" ForeColor="red" runat="server"/>

</td>

</tr>

</table>

</td>

</tr>

<tr align="center">

<td height="40">

<asp:button ID="add" Text="登录" OnClick="addclick" class="buttonface" runat="server"/>

<asp:button ID="cancel" Text="取消" OnClick="cancelclick" class="buttonface" runat="server"/>

</td>

</tr>

</table>

</form>

<mynews:footer runat="server"/>

</body>

</html>

//classmanager.aspx类别管理

<%@ Page Language="VB" ContentType="text/html" debug="true"%>

<%@ Import Namespace="System.Data"%>

<%@ Import Namespace="System.Data.OleDb"%>

<%@ Register TagPrefix="mynews" TagName="main" src="ascx/main.ascx"%>

<%@ Register TagPrefix="mynews" TagName="footer" src="ascx/footer.ascx"%>

<script language="VB" runat="server">

Dim sql,bianhao as string

Dim myConn as OleDbConnection

Dim myCmd as OleDbCommand

'查询数据子程序

Function getdatareader(ByVal sql As String) As OleDbDataReader

myCmd = New OleDbCommand(sql, myConn)

myConn.Open()

getdatareader = myCmd.ExecuteReader()

End Function

'查询数据子程序

Function getdataview(ByVal sql As String, ByVal strTable As String) As DataView

Dim myDataAdapter As OleDbDataAdapter

Dim myDataSet As DataSet

myConn.Open()

myDataAdapter = New OleDbDataAdapter(sql, myConn)

myConn.Close()

myDataSet = New DataSet()

myDataAdapter.Fill(myDataSet, strTable)

getdataview = New DataView(myDataSet.Tables(strTable))

End Function

'执行查询字符串子程序

Function executesql(ByVal sql As String)

myCmd = New OleDbCommand(sql, myConn)

myConn.Open()

myCmd.ExecuteNonQuery()

myConn.Close()

End Function

'数据绑定子程序

Function bindgrid()

information.Text = ""

sql = "select * from Classes order by ClassesID desc"

fenlei.DataSource = getdataview(sql, "fenlei")

fenlei.DataBind()

End Function

'初始化数据绑定子程序

Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

If Session("user") = "administrator" Then

Dim strConn As String

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("./") & "Qtech/luyudata.mdb"

myConn = New OleDbConnection(strConn)

If Not Page.IsPostBack Then

bindgrid()

End If

Else

Response.Redirect("login.aspx")

End If

End Sub

'翻页子程序

Sub changepage(ByVal Sender As Object, ByVal e As DataGridPageChangedEventArgs)

fenlei.CurrentPageIndex = e.NewPageIndex

bindgrid()

End Sub

'添加分类子程序

Sub butadd_Click(ByVal Sender As Object, ByVal e As EventArgs)

sql = "insert into Classes(ClassesName) values('" & fenleiname.Text & "')"

executesql(sql)

information.Text = "分类添加成功"

bindgrid()

End Sub

'删除分类子程序

Sub fenlei_delete(ByVal Sender As Object, ByVal e As DataGridCommandEventArgs)

bianhao = fenlei.DataKeys(e.Item.ItemIndex)

executesql("delete from Classes where ClassesID=" & CInt(bianhao))

bindgrid()

End Sub

'编辑分类子程序

Sub fenlei_edit(ByVal Sender As Object, ByVal e As DataGridCommandEventArgs)

fenlei.EditItemIndex = e.Item.ItemIndex

bindgrid()

End Sub

'更新分类子程序

Sub fenlei_update(ByVal Sender As Object, ByVal e As DataGridCommandEventArgs)

Dim fltext As TextBox = e.Item.Cells(1).Controls(0)

Dim flname As String = fltext.Text

bianhao = fenlei.DataKeys(e.Item.ItemIndex)

sql = "update Classes set ClassesName='" & flname & "' where ClassesID=" & CInt(bianhao)

executesql(sql)

fenlei.EditItemIndex = -1

bindgrid()

End Sub

'取消操作子程序

Sub fenlei_cancel(ByVal Sender As Object, ByVal e As DataGridCommandEventArgs)

fenlei.EditItemIndex = -1

bindgrid()

End Sub

</script>

//newsadd.aspx新闻添加核心代码

sql = "insert into News(Title,Author,Original,Content,UpdateTime,ClassesID) values('" & title & "','" & author & "','" & from & "','" & content & "','" & DateTime.Now() & "','" & classid & "')"

// newsedit.aspx新闻添加核心代码

sql = "update News set Title='" & title & "',Author='" & author & "',Original='" & from & "',Content='" & content & "',UpdateTime='" & DateTime.Now() & "',ClassesID=" & classid & " where NewsID=" & bianhao

4)调试中出现的问题:

//参数设置不正确导致的错误,出现在login.aspx后台登录文件中。

asp.net课程设计--新闻发布系统

//字符转换错误,不能正确转换出现的。

asp.net课程设计--新闻发布系统

7.系统总结

7.1在各开发环境下实现的功能

经过PHOTOSHOP和flash的处理,实现了页面美化显示效果。

经过ACCESS创建数据库,创建完成了luyudata.mdb表结构,并添另部分数据。

结合DREAMWEAVER搭建表格环境,以及可视化视图。

经过用Visual Stdio 2005进行工程创建,代码的组织编写,调试成功的主页如图所示:

asp.net课程设计--新闻发布系统

分类信息查看时的效果如下图所示:

asp.net课程设计--新闻发布系统

文章评论运行界面如下图所示:

asp.net课程设计--新闻发布系统

后台文章管理的运行界面如下图所示:

asp.net课程设计--新闻发布系统

分类信息管理的效果如下图所示:

asp.net课程设计--新闻发布系统

7.2 系统不足,系统扩展构想

1)系统不足

本站只是实现了简单的网站浏览功能,与学生的互动性不是很强,具体会员互动还没有开发制作,另外数据库不是很强大,没有进行数据库用户密码的加密,以明文显示的。

2)系统扩展构想

增加会员互动功能,扩展更大的图片显示板块,网站表达方面更生动,更具和谐性,同时在数据库方面扩展为SQL SEVER等大型数据库,增强网站的健壮性。

8.参考文献

[1]Chris Payne.ASP.NET从入门到精通。北京:人民邮电出版社,2002.1

[2]葛小东,邓秋媛。VB_NET编程技巧与实例集粹.北京:中国科学技术出版社,2003.8

[3] ASP数据库系统开发完全手册 人民邮电出版社 明日科技 [4]王珊,萨师煊等。数据库系统概论(第四版)高等教育出版社2007、11

[5] 徐学东,孙延明等。 JDBC事务处理在WEB信息系统中的应用. 计算机工程与应用,2005,01:171-173

9. 附录

App_Data/data.mdb

Ascx/ main.ascx、top.ascx、newslist.ascx、search.ascx、footer.ascx、review.ascx

pic/banner.swf、bottom.swf、其它gif图片文件

psd/bottom.psd、top.psd

style.css

classmanager.aspx

classnews.aspx

default.aspx

login.aspx

newsadd.aspx

newsedit.aspx

newshow.aspx

newsmanager.aspx

newssearch.aspx

reviewshow.aspx

style.css

upfile.aspx

资源下载此资源下载价格为9.9云朵立即购买,云炬VIP季会员免费
客服微信:2743319061
收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章资源,如无特殊说明或标注,均为本站网友和创作者贡献分享。如若本站内容侵犯了原著者的合法权益,可联系网站客服QQ2743319061删除。

云炬星球 课设源码 asp.net课程设计--新闻发布系统 https://src.yunjunet.cn/220.html

常见问题
  • 放心亲,我们不会为了几十块钱的东西坏了名声!
查看详情
  • 方法一:点击“立即下载.”按钮,付款后在下载弹窗的虚线框的隐藏信息里获取 方法二:在正文底部使用VIP查看隐藏的解压密码 方法三:联系【云炬网络】公众号客服获取
查看详情
  • 付款后会出现“立即下载”按钮(点击即可下载),如果下载失败也可以联系客服发订单截图补发。
查看详情
  • 登录购买会多端同步购买记录,永久可以查看反复下载;非登录购买仅将购买记录保存到本地浏览器中,浏览器cookie清除后无法再次下载。先右上角点登录,然后点击微信图标可以快速授权注册登录^_^
查看详情
  • 可以试看。点击”查看演示“或“试看预览”按钮可以试读从资料目录中节选的部分内容,也可以自己指定想试看的内容。
查看详情
  • 原因一:本站所有资源已开启有效性检测(服务器24h全自动监测),当监测到下载链接无法访问时会提示“该资源已失效,请勿购买”,遇到这种情况可以联系客服修复失效的下载链接,或直接联系客服在淘宝下单购买即可。(检测原理:购买前服务器程序会预访问下载链接,响应值为200说明资源有效允许购买,响应值为404或502等报错说明资源失效禁止购买)。原因二:上传者未启用“下载”选项。
查看详情
官方客服团队

为您解决烦忧 - 24小时在线 专业服务