《最新ASPNET课程设计.doc》由会员分享,可在线阅读,更多相关《最新ASPNET课程设计.doc(29页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精品资料ASPNET课程设计.课程名称:ASP.NET课程设计姓名: 刘阳学号:201230330219所在专业:软件工程所在院系:信息工程学院辅导教师:宁星日期:2015年1月15日目录一、课程设计的目的1二、课程设计要求1三、课题及内容1四、流程图2五、数据库2六、页面代码335913171921 七、课程设计小结23一、课程设计的目的 通过利用A进行web应用程序的设计与开发,加深对web程序开发的基本知识的理解,掌握动态页面设计的基本方法和步骤,掌握程序调试的一般方法和技巧。培养基本理论分析、解决实际问题的能力及锻炼写设计总结报告的能力。二、课程设计的基本要求 1. 本课程设计要求学生
2、用A技术开发一个动态网站,利用B/S结构,能将客户端的用户请求提交给服务器端的程序处理。服务器端程序能完成数据的插入、删除、更新以及将用户请求的查询数据返回客户端。 2. 课程设计结束后,每位同学独立提交一份web课程设计报告,内容包括总体设计和算法分析,主要流程,测试数据及测试过程,遇到的问题及解决方法等 3. 界面截图里要有代表性的数据。三、课程设计的内容题目:基于Web的房屋出租信息发布系统 功能要求: 1. 用户管理功能,包括:用户注册,登录认证,修改个人信息; 2. 房屋出租信息发布:注册用户登录后可发布,查询,修改,删除自己发布的房屋出租信息; 3. 房屋信息查询:游客可按房屋类型
3、,所处街道或出租价格查询相应的房屋出租信息。 4. 简易论坛或聊天室四、流程图登陆页面游客登陆用户登陆用户注册个人中心进入首页个人信息删除发布进入聊天室发布信息五、数据库SQL Server 中数据库里建立了三张表,分别是User表(用户信息表)、Fw表(房屋出租信息表)和chat表(聊天记录表)。1.User表中字段:id , pwd , name , sex2.Fw表中字段:id , 编号 , 类型 , 街道 ,价格3.chat表中字段:id , stext , stime六、页面代码1、登陆页面前端代码: 房屋出租系统 后台代码:Imports System.Data.SqlClient
4、Imports System.DataPartial Class _Default Inherits System.Web.UI.Page Protected Sub login_Click(sender As Object, e As EventArgs) Handles login.Click Dim id As String = idtext.Text.Trim() Dim pwd As String = pwdtext.Text.Trim() Dim conn As New SqlConnection(server=.;database=fwcz;uid=sa;pwd=91569;)
5、Dim sqltext As String = select * from User where id = + id + and pwd = + pwd + Try conn.Open() Dim sqlcom As SqlCommand = New SqlCommand(sqltext, conn) If sqlcom.ExecuteScalar() Nothing Then Session.Add(login_name, id) conn.Close() Response.Redirect(user.aspx) Else Response.Write(alert(账号密码错误!) End
6、If If conn.State = ConnectionState.Open Then conn.Close() End If Catch ex As Exception End Try End Sub Protected Sub uzc_Click(sender As Object, e As EventArgs) Handles uzc.Click Response.Redirect(uzc.aspx) End Sub Protected Sub youke_Click(sender As Object, e As EventArgs) Handles youke.Click Sessi
7、on.Add(login_name, guest) Response.Redirect(main.aspx) End SubEnd Class2、 用户中心页面前端代码: 用户中心 根据编号: 后台代码:Imports System.Data.SqlClientImports System.DataPartial Class user Inherits System.Web.UI.Page Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If (Session(login_name) Nothi
8、ng) Then Dim id As String = Session(login_name).ToString() Label1.Text = id + 欢迎您! 您的发布如下: Dim conn As New SqlConnection(server=.;database=fwcz;uid=sa;pwd=91569;) Dim sqltext As String = select * from Fw where id = + id + conn.Open() Dim sqlcmd As SqlCommand = New SqlCommand(sqltext, conn) Dim objec
9、treader As SqlDataReader Dim i As Integer Dim fw As String objectreader = sqlcmd.ExecuteReader() fw = fw += For i = 0 To objectreader.FieldCount - 1 fw += + objectreader.GetName(i) + Next fw += While objectreader.Read() fw += For i = 0 To objectreader.FieldCount - 1 fw += + CStr(objectreader.GetValu
10、e(i) + Next fw += End While fw += Label2.Text = fw conn.Close() Else : Response.Write(alert(用户过期,请重新登陆!);window.location.href =ulogin.aspx) End If End Sub Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Response.Redirect(userinfo.aspx) End Sub Protected Sub Button
11、2_Click(sender As Object, e As EventArgs) Handles Button2.Click Response.Redirect(main.aspx) End Sub Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click Response.Redirect(fatie.aspx) End Sub Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4
12、.Click Response.Redirect(chat.aspx) End Sub Protected Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click If (Session(login_name) Nothing) Then Dim id As String = Session(login_name) Dim n As String = TextBox1.Text.Trim() Dim conn As New SqlConnection(server=.;database=fwcz;uid
13、=sa;pwd=91569;) Dim sqltext As String = DELETE FROM Fw WHERE id = + id + and 编号 = + n + Try conn.Open() Dim sqlcom As SqlCommand = New SqlCommand(sqltext, conn) sqlcom.ExecuteNonQuery() conn.Close() Response.Write(alert(删除成功!);window.location.href =user.aspx) If conn.State = ConnectionState.Open The
14、n conn.Close() End If Catch ex As Exception End Try End If End SubEnd Class3、 个人信息页面前端代码: 您的个人信息 信息完善与修改 修改密码 后台代码:Imports System.Data.SqlClientImports System.DataPartial Class userinfo Inherits System.Web.UI.Page Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If
15、 (Session(login_name) Nothing) Then Dim id As String = Session(login_name) Dim n As String = TextBox1.Text.Trim() Dim s As String = DropDownList1.Text Dim conn As New SqlConnection(server=.;database=fwcz;uid=sa;pwd=91569;) Dim sqltext As String = update User set name = + n + ,sex = + s + where id =
16、+ id + Try conn.Open() Dim sqlcom As SqlCommand = New SqlCommand(sqltext, conn) sqlcom.ExecuteNonQuery() conn.Close() Response.Write(alert(更新成功!);window.location.href =user.aspx) If conn.State = ConnectionState.Open Then conn.Close() End If Catch ex As Exception End Try End If End Sub Protected Sub
17、Page_Load(sender As Object, e As EventArgs) Handles Me.Load If (Session(login_name) Nothing) Then Dim id As String = Session(login_name) Label11.Text = id Dim conn As New SqlConnection(server=.;database=fwcz;uid=sa;pwd=91569;) Dim sqltext1 As String = select name from User where id = + ID + Dim sqlt
18、ext2 As String = select sex from User where id = + ID + Try conn.Open() Dim sqlcom1 As SqlCommand = New SqlCommand(sqltext1, conn) Dim sqlcom2 As SqlCommand = New SqlCommand(sqltext2, conn) Label7.Text = sqlcom1.ExecuteScalar().ToString() Label9.Text = sqlcom2.ExecuteScalar().ToString() conn.Close()
19、 If conn.State = ConnectionState.Open Then conn.Close() End If Catch ex As Exception End Try Else : Response.Write(alert(用户过期,请重新登陆!);window.location.href =ulogin.aspx) End If End Sub Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim id As String = Session(login
20、_name) Dim opwd As String = oldpwd.Text.Trim() Dim conn As New SqlConnection(server=.;database=fwcz;uid=sa;pwd=91569;) Dim sqltext As String = select * from User where id = + id + and pwd = + opwd + conn.Open() Dim sqlcom As SqlCommand = New SqlCommand(sqltext, conn) If sqlcom.ExecuteScalar() Nothin
21、g Then Dim n1 As String = newpwd1.Text Dim n2 As String = newpwd2.Text If (n1 = n2) Then Dim sqltext1 As String = update User set pwd = + n1 + where id = + id + Dim sqlcom1 As SqlCommand = New SqlCommand(sqltext1, conn) sqlcom1.ExecuteNonQuery() conn.Close() Response.Write(alert(修改成功,请重新登录!);window.location.href =ulogin.aspx) Else : Response.Write(alert(两次新密码输入不同!) End If Else : Response.Write(alert(原密码输入错误!) End If If conn.State = ConnectionState.Open Then conn.Close() End If End SubEnd Class4、 首页页面前端代码: 房屋出租首页 类型: 套房 单间 所在街道: 价格:
限制150内