1、计算机网络课程设计报告之简单新闻发布系统含核心代码 计算机网络课程设计报告课程设计名称: 简单新闻发布系统 班 级 : 姓 名 : 学 号 : 课程设计日期: 2010-6-122010-7-17 2010 年 7 月 17 日目 录一、课程设计目的和要求 3 1、课程设计目的 2、课程设计要求二、课程设计环境 3 1、课程Visual Studio 2005软件开发平台 2、SQL SERVER 2005数据库软件三、程序的逻辑框图 4四、程序源代码 5 1、系统登陆验证代码: 2、主体新闻页面代码 3、修改管理员密码代码: 4、添加用户信息代码 5、删除新闻信息代码: 6、添加新闻信息代码
2、:五、课程设计数据、结果分析 12 1、主要数据库表 2、数据库表结构(内容) (1)、用户信息表: (2)、新闻信息表: (3)、用户角色表: (4)、新闻类别表: 3、结果分析主要流程截图(管理员和新闻录入员) 六、总结 18七、教师意见 19一、课程设计目的和要求1、课程设计目的(1)、培养学生理论联系实际的设计思想,训练综合运用所学的基础理论知识,结合生产实际分析和解决网络应用中问题的能力,从而使基础理论知识得到巩固和加深。(2)、运用软件工程的原理、方法和工具完整地设计并开发一个软件项目。(3)、学习掌握网络应用系统的一般设计过程和方法。(4)、熟悉并掌握B/S模式构建网络应用。2、
3、课程设计要求(1)、合理设计系统框图和网站结构图。(2)、根据系统框图设计,编写网页及程序代码。(3)、程序设计时,要求使用JSP或者ASP.NET语言进行开发,完成课设题目的全部内容。(4)、完成课程设计报告。(5)、认真做好实验内容的准备,提前作出思考和分析。(6)、观察各种现象,作出必要的说明和分析。(7)、认真书写实验报告。包括实验目的和要求,实验情况及分析,程序设计说明,框图和清单二、课程设计环境1、课程设计Visual Studio 2005软件开发平台 Visual Studio 2005 是一套完整的开发工具,用于生成 ASP Web 应用程序、XML Web services
4、、桌面应用程序和移动应用程序。Visual Basic .NET、Visual C+ .NET、Visual C# .NET 和 Visual J# .NET 全都使用相同的集成开发环境 (IDE),该环境允许它们共享工具并有助于创建混合语言解决方案。另外,这些语言利用了 .NET Framework 的功能,此框架提供对简化 ASP Web 应用程序和 XML Web services 开发的关键技术的访问。2、SQL SERVER 2005数据库软件 SQL Server 2005 是一个全面的数据库平台,使用集成的商业智能 (BI) 工具提供了企业级的数据管理。SQL Server 20
5、05 数据库引擎为关系型数据和结构化数据提供了更安全可靠的存储功能,使您可以构建和管理用于业务的高可用和高性能的数据应用程序。SQL Server 2005 数据引擎是本企业数据管理解决方案的核心。此外 SQL Server 2005 结合了分析、报表、集成和通知功能。这使您的企业可以构建和部署经济有效的 BI 解决方案,帮助您的团队通过记分卡、Dashboard、Web services 和移动设备将数据应用推向业务的各个领域。三、程序的逻辑框图程序逻辑图描述:系统启动时默认进入默认界面(新闻浏览界面),一般浏览者可以在此界面浏览各种新闻,点击新闻标题可以查看各条新闻详细信息。如果是管理员或
6、者是普通用户(新闻录入员),可以在默认页面选择用户登录,然后进行相关操作。在登陆界面,用户有两种登陆选择,如果您是管理员,您可以通过用户名和密码登陆,登陆后可以实现管理员的相关操作功能。如果您是普通用户,您也可以通过相应名称和密码登陆,登陆后可以实现普通用户的相关操作功能。如图所示:四、程序源代码(部分)1、系统登陆验证代码:public partial class Login : System.Web.UI.Page alerts alert = new alerts(); protected void Page_Load(object sender, EventArgs e) txtNam
7、e.Focus(); FormsAuthentication.SignOut(); if (!this.IsPostBack) this.ViewStateGUID = System.Guid.NewGuid().ToString(); protected void btnOK_Click(object sender, EventArgs e) int login = 0; SoftLin.BLL.Users bll = new SoftLin.BLL.Users(); SoftLin.Model.Users model=new SoftLin.Model.Users(); model.Use
8、rName = txtName.Text; model.Password = SoftLin.Common.DEncrypt.EncryptPassword(txtPass.Text); if(DDLtType.SelectedValue=管理员) /判断用户身份 model.UserType = 1; else model.UserType = 0; login = bll.Logins(ConfigurationManager.ConnectionStringsDBW.ConnectionString, model); if (login != 0) /用户登录验证 SoftLin.Com
9、mon.AccountsPrincipal newuers = AccountsPrincipal.ValidateLogin(df, df); FormsAuthentication.SetAuthCookie(txtName.Text, false); Context.User = newuers; SessionLogin = Login; if (model.UserType = 1) /根据用户类型跳转到相应页面 Response.Redirect(Admin/Default.aspx); else Response.Redirect(edit/Default.aspx); else
10、 Response.Write(alert.alert(用户名或密码有误!); ; 2、主体新闻页面代码(一般浏览者可浏览页面): protected void Page_Load(object sender, EventArgs e) /设置新闻类别 SoftLin.BLL.News news = new SoftLin.BLL.News(); SoftLin.Model.News model = new SoftLin.Model.News(); model.Type = 校园大事; ds = news.NewsTypequery(con, model); for (int i = 0;
11、i ds.Tables0.Rows.Count; i+) matteri = ds.Tables0.Rowsi1.ToString(); HttpUtility.UrlEncode(mattersi = ds.Tables0.Rowsi1.ToString(), System.Text.Encoding.GetEncoding(GB2312); model.Type = 体育新闻; ds = news.NewsTypequery(con, model); for (int i = 0; i ds.Tables0.Rows.Count; i+) sporti = ds.Tables0.Rowsi
12、1.ToString(); HttpUtility.UrlEncode(sportsi = ds.Tables0.Rowsi1.ToString(), System.Text.Encoding.GetEncoding(GB2312); model.Type = 最新活动; ds = news.NewsTypequery(con, model); for (int i = 0; i ds.Tables0.Rows.Count; i+) activityi = ds.Tables0.Rowsi1.ToString(); HttpUtility.UrlEncode(activitiesi = ds.
13、Tables0.Rowsi1.ToString(), System.Text.Encoding.GetEncoding(GB2312); model.Type = 奇闻轶事; ds = news.NewsTypequery(con, model); for (int i = 0; i ds.Tables0.Rows.Count; i+) anecdotei = ds.Tables0.Rowsi1.ToString(); HttpUtility.UrlEncode(anecdotesi = ds.Tables0.Rowsi1.ToString(), System.Text.Encoding.Ge
14、tEncoding(GB2312); model.Type = 校园新闻; ds = news.NewsTypequery(con, model); for (int i = 0; i ds.Tables0.Rows.Count; i+) schoolnewi = ds.Tables0.Rowsi1.ToString(); HttpUtility.UrlEncode(schoolnewsi = ds.Tables0.Rowsi1.ToString(), System.Text.Encoding.GetEncoding(GB2312); model.Type = 校园论坛; ds = news.
15、NewsTypequery(con, model); for (int i = 0; i 0) Response.Write(alerts.alert(修改密码成功!); Response.Redirect(./Login.aspx); else Response.Write(alerts.alert(原密码输入有误!); 4、添加用户信息代码(管理员):protected void btnOK_Click(object sender, EventArgs e) int trues=0; string type; SoftLin.BLL.Users users = new SoftLin.BL
16、L.Users(); SoftLin.Model.Users Model = new SoftLin.Model.Users(); Model.UserName = txtName.Text; Model.Password =SoftLin.Common.DEncrypt.EncryptPassword( txtPass.Text); Model.TrueName = txtTName.Text; if (rbnSex.Checked) Model.Sex = 男; else Model.Sex = 女; Model.Phone = txtPhone.Text; Model.Birthday
17、=Convert.ToDateTime(txtBirthday.Text); Model.Email = txtEmail.Text; Model.LoginTime = DateTime.Now.ToString(); if (ddLiType.SelectedValue = 管理员) type = 1; else type = 0; Model.UserType = type; trues=users.CreateUsers(ConfigurationManager.ConnectionStringsDBU.ConnectionString, Model); if (trues 0) So
18、ftLin.Common.alerts alerts = new SoftLin.Common.alerts(); Response.Write(alerts.alert(添加成功!); 5、删除新闻信息代码:public partial class Admin_DeleteNews : System.Web.UI.Page string con = ConfigurationManager.ConnectionStringsDBU.ConnectionString; protected void Page_Load(object sender, EventArgs e) SoftLin.BL
19、L.News news = new SoftLin.BLL.News(); GridView1.DataSource = news.GetNews(con); GridView1.DataBind(); if (!Context.User.Identity.IsAuthenticated) Response.Redirect(./Login.aspx); protected void btnUp_Click(object sender, EventArgs e) SoftLin.BLL.News news = new SoftLin.BLL.News(); SoftLin.Model.News
20、 model = new SoftLin.Model.News(); model.NewID =Convert.ToInt32(txtup.Text); SoftLin.BLL.NewSsorts typen = new SoftLin.BLL.NewSsorts(); SoftLin.Model.NewSsorts mo = new SoftLin.Model.NewSsorts(); mo.NewID = model.NewID; typen.DeleteNewsSsorts(con, mo); news.DeleteNews(con, model); SoftLin.Common.ale
21、rts alert = new SoftLin.Common.alerts(); Response.Write(alert.alert(删除成功!); protected void dgUser_PageIndexChanged(object source, DataGridPageChangedEventArgs e) protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) GridView1.PageIndex = e.NewPageIndex; GridView1.DataBin
22、d(); 6、添加新闻信息代码:public partial class Admin_AddArticle : System.Web.UI.Page string con = ConfigurationManager.ConnectionStringsDBU.ConnectionString; protected void Page_Load(object sender, EventArgs e) if (!IsPostBack) DataSet ds = new DataSet(); SoftLin.BLL.Ssorts type = new SoftLin.BLL.Ssorts(); ds
23、 = type.GetSsorts(ConfigurationManager.ConnectionStringsDBU.ConnectionString); DDlType.DataSource = ds.Tablesds.DefaultView; DDlType.DataTextField = description; DDlType.DataBind(); if (!Context.User.Identity.IsAuthenticated) Response.Redirect(./Login.aspx); protected void GridView1_SelectedIndexCha
24、nged(object sender, EventArgs e) protected void btnAdd_Click(object sender, EventArgs e) string type = DDlType.SelectedItem.Text; int newID = 0; int SsodtID = 0; SoftLin.BLL.News news = new SoftLin.BLL.News(); SoftLin.BLL.NewSsorts ns = new SoftLin.BLL.NewSsorts(); SoftLin.Model.News model = new Sof
25、tLin.Model.News(); model.Title = txtArticle.Text; model.Bodys = txtBodys.Text; model.Author = Txtauthor.Text; model.Type = DDlType.SelectedValue; news.CreateNews(con, model); newID = news.GetNewsID(con, model); SoftLin.BLL.Ssorts ssorts = new SoftLin.BLL.Ssorts(); SsodtID = ssorts.GetSsortID(con,typ
26、e); SoftLin.Model.NewSsorts newsss = new SoftLin.Model.NewSsorts(); newsss.NewID = newID; newsss.SsortID = SsodtID; ns.CreateNewSsorts(con, newsss); SoftLin.Common.alerts alert = new SoftLin.Common.alerts(); Response.Write(alert.alert(添加成功!); protected void DDlType_SelectedIndexChanged(object sender, EventArgs e) protected void DDlType_TextChanged(object sender, EventArgs e) 五、课程设计数据、结果分析1、主要数据库表编号表名名称描述
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1