科信学院课程设计说明书(2011/2012学年第一学期)课程名称:软件程序设计题目:网络U盘专业班级:电子信息工程09-1学生姓名:学号:指导教师:设计周数:2周设计成绩:2012年1月6日课程设计设计说明书电子信息工程09-1班王旭涛第1页共17页目录1.绪论·····························································································11.1课程设计的意义及目的·······························································21.2课程设计的主要任务··································································21.3课程设计的技术要求··································································22.设计正文·····················································································32.1网络U盘设计分析·····································································32.1.1需求分析···········································································32.1.2系统总体框图·····································································32.2数据库设计··············································································32.2.1数据库所列表·····································································32.3程序设计·················································································42.3.1程序分析···········································································42.3.2程序流程图········································································42.3.3主要代码···········································································52.4系统测试···············································································153.设计总结···················································································164.参考资料···················································································17课程设计设计说明书电子信息工程09-1班王旭涛第2页共17页1绪论1.1课程设计的意义及目的软件程序设计是一个重要的实践性教学环节,是通信专业的技术基础课。通过这一训练可以巩固学生所学C#和数据库的理论知识,有助于学生培养正确的设计思想,逐步树立正确的设计思想,培养分析和解决实际问题的能力。对后续专业课程的学习、毕业设计以及今后从事程序设计工作奠定扎实的基础具有重要的意义。其目的主要包括:(1)通过本次课程设计,熟悉网络U盘的设计过程;(2)掌握C#和数据库相结合设计软件的方法;(3)掌握登录、文件上传、下载、删除、重命名等常用功能的编写方法;(4)掌握数据绑定、排序、分页的实现方法;(5)掌握其主要思想,能够举一反三,设计其他软件程序。1.2课程设计的主要任务(1)根据技术要求和现有开发环境,分析题目;(2)设计软件方案。包括:模式的选择(B/S或C/S)、数据库的选择、软件功能结构、各功能模块的详细描述、关键程序流程图、数据库中表的结构设计等;(3)调试、修改并完善程序(4)生成安装程序,编写软件使用说明书(图文结合进行描述);(5)修改并完善设计;(6)撰写课程设计报告。1.3课程设计的技术要求(1)个人用户登录,新用户注册,密码修改;(2)个人上传文件,并可对文件进行管理;(3)个人可下载自己的文件;(4)文件按时间先后顺序排序显示,并支持分页显示功能。课程设计设计说明书电子信息工程09-1班王旭涛第3页共17页2设计正文2.1网络U盘设计分析2.1.1需求分析根据网络U盘的技术要求和现有开发环境,作如下具体需求分析:本设计可以在基于Web模式下实现用户对文件的基本管理,包括上传、下载、重命名和删除等基本操作;可注册一些新用户进行个人文件的管理;用户可自行修改自身密码;在文件列表中文件需按时间先后顺序排序显示,并支持分页显示功能。2.1.2系统总体框图图2-1网络U盘系统设计结构图2.2数据库设计2.2数据库所列表文件信息表(Directory):表2-1文件列表(Directory)列名数据类型长度是否为主键是否为空注释DirIDint是否文件序号Namevarchar20否否文件名称Containint否否文件大小CreateDatedatetime否否创建时间Urlvarchar255否否文件路径Typevarchar200否否文件类型网络U盘系统pan系统新用户注册系统普通用户系统新用户注册模块新用户登录模块用户操作模块文件管理模块帮助用户登录模块修改密码模块用户上传文件模块重命名文件模块删除文件模块下载文件模块帮助课程设计设计说明书电子信息工程09-1班王旭涛第4页共17页用户信息表(Users):表2-2用户信息表(Users)2.3程序设计2.3.1程序分析通过分析任务,程序中封装一个类供各部分相应窗体后台代码调用,类名为:王旭涛.cs。其中包括的方法为:获取单个文件的信息---GetSingleFile添加文件信息到数据库---AddFile修改数据库中的文件名---EditFile删除数据库中的文件信息---DeleteFile对应设计中的用户登录页面、新用户注册页面、查看文件页面、修改密码页面、上传文件页面和管理页面,设计的后台代码及名称包括登录代码Login.aspx.cs,注册代码UserAdd.aspx.cs,文件列表代码List.aspx.cs,修改密码的代码ModifyPwd.aspx.cs,上传代码UpLoad.aspx.cs,下载代码Down.aspx.cs,重命名代码EditFile.aspx.cs,删除文件代码GuanLi.aspx.cs。2.3.2程序流程图图2-2用户登录流程图列名数据类型长度是否为主键是否为空注释UserNamevarchar20是否用户登录帐号UserPasswordvarchar20否否用户登录密码开始初始化程序进入相应登录页面输入登录账号和密码判断数据库里帐号与密码是否相符?进入各自相应界面输出登录失败信息结束课程设计设计说明书电子信息工程09-1班王旭涛第5页共17页图2-3新注册用户登录流程图2.3.1主要代码(1)封装类王旭涛.cs:publicclass王旭涛{publicSqlDataReaderGetSingleFile(intnFileID){SqlConnectionmyConnection=newSqlConnection(ConfigurationManager.ConnectionStrings[SQLCONNECTIONSTRING].ConnectionString);stringcmdText=SELECT*+FROMDirectoryWHEREDirectory.DirID='+nFileID.ToString()+';SqlCommandmyCommand=newSqlCommand(cmdText,myConnection);SqlDataReaderdr=null;myConnection.Open();dr=myCommand.ExecuteReader(CommandBehavior.CloseConnection);//返回DataReaderreturndr;}publicintAddFile(stringsName,intnContain,stringsUrl,stringsType){//创建链接SqlConnectionmyConnection=newSqlConnection(开始初始化程序新用户注册页面进入各自相应界面输出注册失败信息结束进入登录页面注册成功?意接受课程设计设计说明书电子信息工程09-1班王旭涛第6页共17页ConfigurationManager.ConnectionStrings[SQLCONNECTIONSTRING].ConnectionString);//定义SQL语句,添加stringcmdText=INSERTINTODirectoryName,Contain,Url,Type,CreateDate)VALUES(+'+sName+',+'+nContain.ToString()+',+'+sUrl+',+'+sType+',+GetDate()+);//创建CommandSqlCommandmyCommand=newSqlCommand(cmdText,myConnection);//定义返回值intnResult=-1;try{myConnection.Open();//执行SQL语句nResult=myCommand.ExecuteNonQuery();}finally{//关闭链接myConnection.Close();}//返回nResultreturnnResult;}publicintEditFile(intnFileID,stringsName,stringsUrl){SqlConnectionmyConnection=newSqlConnection(ConfigurationManager.ConnectionStrings[SQLCONNECTIONSTRING].ConnectionString);stringcmdText=UPDATEDirectorySETName=+'+sName+'+,Url=+'+sUrl+'+WHEREDirID='+nFileID.ToString()+';//创建CommandSqlCommandmyCommand=newSqlCommand(cmdText,myConnection);//定义返回值intnResult=-1;try{//打开链接myConnection.Open();//执行SQL语句nResult=myCommand.ExecuteNonQuery();}finally{//关闭链接myConnection.Close();}returnnResult;课程设计设计说明书电子信息工程09-1班王旭涛第7页共17页}publicintDeleteFile(intnFileID){SqlConnectionmyConnection=newSqlConnection(Configur