ASP.NET小说网站.doc

上传人:laozhun 文档编号:2384293 上传时间:2023-02-17 格式:DOC 页数:32 大小:1.28MB
返回 下载 相关 举报
ASP.NET小说网站.doc_第1页
第1页 / 共32页
ASP.NET小说网站.doc_第2页
第2页 / 共32页
ASP.NET小说网站.doc_第3页
第3页 / 共32页
ASP.NET小说网站.doc_第4页
第4页 / 共32页
ASP.NET小说网站.doc_第5页
第5页 / 共32页
点击查看更多>>
资源描述

《ASP.NET小说网站.doc》由会员分享,可在线阅读,更多相关《ASP.NET小说网站.doc(32页珍藏版)》请在三一办公上搜索。

1、 目录 1封面1 2目录2 3摘要3 4引言4 5小说网项目设计5 5.1 项目架构.5 5.2 web.config6 5.3 数据库设计7 5.4 功能实现8 5.4.1 数据库连接.8 5.4.2 注册、登录.8 5.4.3 管理员操作11 5.4.4 小说操作16 6致谢20摘 要从建站的实际情况出发,经过对有关小说网站的一番考察和分析,确立了系统采用ASP.NET作为开发语言,SQL Server 2005作为数据库服务器,实现小说网站的更新访问等功能。 阐述系统的结构设计和功能设计,实现小说的分类显示,热门小说推荐、搜索、阅读等。经过授权的用户可以通过Web浏览器,以人机交互式的客

2、户端程序实现对小说的上传、下载,甚至对用户和小说进行管理,实时的进行行为统计和记录。本网站能满足大部分小说爱好者的需求,能够很好的配合其它子系统服务于网站的更新。该网站系统是一个基于小说上传、下载和内容管理的全站管理系统;基于B/S模式WEBMIS系统,可以将杂乱无章的信息(包括文字、图片)经过组织,合理而且有序地呈现在大家面前。AbstractFrom built them, the actual situation, after novel site on the Web site an examination and analysis, to establish the system a

3、s a development environment using ASP.NET, SQL Server 2005 as the database server, Realization of novel website update access and other functions. And described the structure of the system design and function design, implementation, classification of novels, Popular novel recommendation, search, rea

4、d, etc. Authorized users can Web browser, to human-computer interactive client program to realize the novels upload, download,Even for users and novel management, to conduct real-time statistics and records. The site can meet most fiction enthusiasts demand, Be good with other sub-systems serving th

5、e site updates. The system is a novel based on the upload, download and content management station management system; based on B / S mode WEBMIS system can be chaotic information (including text, pictures) through the organization, reasonable and orderly presentation in front of everyone. -部分内容摘自百度翻

6、译引 言 小说网站是现在网络体系不可缺少的一部分,对于小说的爱好者和作家,小说网站的内容至关重要。传统纸质书籍成本高,更新不及时,无法长久保存,携带不方便等等缺点。所以小说网站应该能够为读者提供充足的小说和快捷的查询手段,同时给作者带来便捷的更新管理体验。 随着科学技术的不断提高,计算机科学日渐成熟,其强大的功能已为人们深刻认识,它已进入人类社会的各个领域并发挥着越来越重要的作用。作为计算机应用的一部分,使用计算机对小说进行管理,具有着传统管理所无法比拟的优点.例如:更新及时、检索迅速、查找方便、可靠性高、存储量大、保密性好、存储寿命长、成本低等。这些优点能够极大地提高小说更新阅读效率,也是小

7、说的科学化、正规化管理,与世界接轨的先进传播途径。ASP.NET的前身ASP技术,是基于通用语言的编译运行的程序,所以它的强大性和适应性,可以使它运行在Web应用软件开发者的几乎全部的平台上。同时,它能使运行一些很平常的任务如表单的提交客户端的身份验证、分布系统和网站配置变得非常简单。ASP.net使用一种字符基础的,分级的配置系统,使你服务器环境和应用程序的设置更加简单,使A的基于应用的开发更加具体,和快捷。而且它还是一种可以用于多处理器的开发工具,它在多处理器的环境下用特殊的无缝连接技术,将很大的提高运行速度。ASP.NET 的语法在很大程度上与 ASP 兼容,同时它还提供一种新的编程模型

8、和结构,可生成伸缩性和稳定性更好的应用程序,并提供更好的安全保护。可以通过在现有 ASP 应用程序中逐渐添加 ASP.NET 功能,随时增强 ASP 应用程序的功能。ASP.NET 可以无缝地与 WYSIWYG HTML 编辑器和其他编程工具(包括 Microsoft Visual Studio .NET)一起工作。这不仅使得 Web 开发更加方便,而且还能提供这些工具必须提供的所有优点,包括开发人员可以用来将服务器控件拖放到 Web 页的 GUI 和完全集成的调试支持。ASP.net是目前最流行的Web应用程序开发工具之一。它是一种功能强大、灵活易学的服务器脚本编程环境,它的源代码均可以在服

9、务器端运行,运行的结果以HTML代码的形式输出到客户端。利用ASP不仅可以快速创建交互性的动态网页,而且程序代码完全保密,更重要的是它不用考虑客户端使用何种浏览器。网站项目设计1. 项目架构 1项目架构说明:列出整个小说网web项目的文件夹架构体系,如下图所示 2程序架构数据库 存储数据访问层 方法判定 Model层 储存实体类对应数据库表 Web项目 网页显示业务逻辑层 2所需Web.Config文件配置如下“Asp.Net 配置”选项。 设置和注释的完整列表在 ments 中,该文件通常位于 WindowsMicrosoft.NetFrameworkv2.xConfig 中- !- 通过

10、节可以配置 ASP.NET 使用的 安全身份验证模式, 以标识传入的用户。 - !- 如果在执行请求的过程中出现未处理的错误, 则通过 节可以配置相应的处理步骤。具体说来, 开发人员通过该节可以配置 要显示的 html 错误页 以代替错误堆栈跟踪。 - 3. 数据库设计数据库:小说表 数据库:小说分类表数据库:关键词搜索表用户表用户权限用户是否被封杀数据库关系图4. 功能实现设计数据库连接相关代码如下:private static string connString = server=.;database=Mynovels;uid=sa;pwd=1234;用户注册、登录及权限提取首页:注册:注

11、册成功提示注册界面public static User AddUser(User user) string sql =string.Format(INSERT Users (LoginId, LoginPwd, Name, UserRoleId, UserStateId) +VALUES (0,1,2,3),user.LoginId, user.LoginPwd, user.Name, user.UserRole.Id, user.UserState.Id); try int newId = DBHelper.GetScalar(sql,CommandType.Text);return Get

12、UserById(newId); catch (Exception e) Console.WriteLine(e.Message); throw e; public static void DeleteUser(User user)DeleteUserById( user.Id ); public static void DeleteUserById(int id) string sql =string.Format( DELETE Users WHERE Id =0,id); try DBHelper.ExecuteCommand(sql, CommandType.Text); catch

13、(Exception e) Console.WriteLine(e.Message);throw e; 登录及权限提取: 登录窗口: 登录后:普通用户登录后界面 管理员登陆后界面 #region 通过用户名取得用户 public static User GetUserByLoginId(string LoginId) string sql = select * from Users where LoginId= +LoginId + ; int userRoleId; int userStateId; try SqlDataReader reader = DBHelper.GetReader(

14、sql, CommandType.Text); if (reader.Read() User user = new User(); user.Id = (int)readerId; user.LoginId = (string)readerLoginId; user.LoginPwd = (string)readerLoginPwd; user.Name = (string)readerName; userRoleId = (int)readerUserRoleId; /FK userStateId = (int)readerUserStateId; /FK reader.Close(); u

15、ser.UserRole = UserRoleService.GetUserRoleById(userRoleId); user.UserState = UserStateService.GetUserStateById(userStateId); return user; else reader.Close(); return null; catch (Exception e) Console.WriteLine(e.Message); throw e; 权限提取: if (user.UserRole.Id = 1) SessionUser = user; Response.Redirect

16、(/Admin/AdminDefault.aspx); else SessionUser = user; Response.Redirect(Default.aspx); 管理员功能管理用户:public static partial class UserStateService public static UserState AddUserState(UserState userState) string sql =INSERT UserStates (Name) +VALUES (Name);sql += ; SELECT IDENTITY; try SqlParameter para =

17、 new SqlParameternew SqlParameter(Name, userState.Name); int newId = DBHelper.GetScalar(sql,CommandType.Text);return GetUserStateById(newId); catch (Exception e) Console.WriteLine(e.Message); throw e; public static void DeleteUserState(UserState userState)DeleteUserStateById( userState.Id ); public

18、static void DeleteUserStateById(int id) string sql = DELETE UserStates WHERE Id = Id; try SqlParameter para = new SqlParameternew SqlParameter(Id, id); DBHelper.ExecuteCommand(sql, CommandType.Text); catch (Exception e) Console.WriteLine(e.Message);throw e; public static void ModifyUserState(UserSta

19、te userState) string sql = UPDATE UserStates + SET + Name = Name + WHERE Id = Id; try SqlParameter para = new SqlParameternew SqlParameter(Id, userState.Id),new SqlParameter(Name, userState.Name);DBHelper.ExecuteCommand(sql, CommandType.Text); catch (Exception e) Console.WriteLine(e.Message);throw e

20、; public static IList GetAllUserStates() string sqlAll = SELECT * FROM UserStates;return GetUserStatesBySql( sqlAll ); public static UserState GetUserStateById(int id) string sql = string.Format(SELECT * FROM UserStates WHERE Id =0,id); try SqlDataReader reader = DBHelper.GetReader(sql,CommandType.T

21、ext); if (reader.Read() UserState userState = new UserState();userState.Id = (int)readerId;userState.Name = (string)readerName; reader.Close(); return userState; else reader.Close(); return null; catch (Exception e) Console.WriteLine(e.Message); throw e; private static IList GetUserStatesBySql( stri

22、ng safeSql ) List list = new List();tryDataTable table = DBHelper.GetDataSet( safeSql,CommandType.Text );foreach (DataRow row in table.Rows)UserState userState = new UserState();userState.Id = (int)rowId;userState.Name = (string)rowName;list.Add(userState);return list; catch (Exception e) Console.Wr

23、iteLine(e.Message); throw e; private static IList GetUserStatesBySql( string sql, params SqlParameter values ) List list = new List();tryDataTable table = DBHelper.GetDataSet( sql,CommandType.Text );foreach (DataRow row in table.Rows)UserState userState = new UserState();userState.Id = (int)rowId;us

24、erState.Name = (string)rowName;list.Add(userState);return list; catch (Exception e) Console.WriteLine(e.Message); throw e; 管理小说:public static void DeleteNovel(Novel novel)DeleteNovelById( novel.Id ); public static void DeleteNovelById(int id) string sql = string.Format(DELETE Novels WHERE Id =0,id);

25、 try DBHelper.ExecuteCommand(sql, CommandType.Text); catch (Exception e) Console.WriteLine(e.Message);throw e; 小说操作类列表查询:ublic static NovelType GetNovelTypeById(int id) string sql = SELECT * FROM NovelTypes WHERE Id =+id; try SqlDataReader reader = DBHelper.GetReader(sql, CommandType.Text); if (read

26、er.Read() NovelType novelType = new NovelType();novelType.Id = (int)readerId;novelType.Name = (string)readerName; reader.Close(); return novelType; else reader.Close(); return null; catch (Exception e) Console.WriteLine(e.Message); throw e; 关键字查询:搜索结果 输入关键字,点击搜索按钮。public static IList GetAllNovelsByK

27、eyword(string keyword) string sqlKey = SELECT * FROM Novels where Title like %+keyword+%; return GetNovelsBySql(sqlKey); 上传实现:上传成功提示 输入信息public static Novel AddNovel(Novel novel) string sql =string.Format(INSERT Novels (Title, Author, Date, ISBN, ContentDescription, NovelType) VALUES (0,1,2,3,4,5),n

28、ovel.Title, novel.Author, novel.Date, novel.ISBN, novel.ContentDescription, novel.NovelType.Id); try int newId = DBHelper.GetScalar(sql, CommandType.Text);return GetNovelById(newId); catch (Exception e) Console.WriteLine(e.Message); throw e; public static void ModifyNovel(Novel novel) string sql =string.Format(UPDATE Novels set NovelType = 0,Title = 1, Author =2,Date =3,ISBN = 4,ContentDescription =5 WHERE Id = 6, novel.NovelType.Id, novel.Title, novel.Author, novel.Date, novel.ISBN, novel.ContentDescription, novel.Id); try DBHelper.Ex

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 建筑/施工/环境 > 项目建议


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号