ASPNET课程设计_第1页
ASPNET课程设计_第2页
ASPNET课程设计_第3页
ASPNET课程设计_第4页
ASPNET课程设计_第5页
已阅读5页,还剩22页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、课程名称:ASP.NET课程设计姓名: 刘阳学号:201230330219所在专业:软件工程所在院系:信息工程学院辅导教师:宁星日期:2015年1月15日目录一、课程设计的目的·······························1二、课程设计要求···

2、;······························1三、课题及内容··················

3、83;················1四、流程图································

4、83;······2五、数据库·······································2六、页面代码··&#

5、183;··································31、登陆页面··············&

6、#183;·······················32、用户中心页面························

7、3;·········53、个人信息页面··································94、首页页面····

8、·································135、注册页面···············

9、3;·····················176、发布信息页面···························

10、······197、聊天室页面···································21 七、课程设计小结·····

11、3;··························23一、课程设计的目的 通过利用A进行web应用程序的设计与开发,加深对web程序开发的基本知识的理解,掌握动态页面设计的基本方法和步骤,掌握程序调试的一般方法和技巧。培养基本理论分析、解决实际问题的能力及锻炼写设计总结报告的能力。二、课程设计的基本要求 1. 本课程设计要求学生用A

12、技术开发一个动态网站,利用B/S结构,能将客户端的用户请求提交给服务器端的程序处理。服务器端程序能完成数据的插入、删除、更新以及将用户请求的查询数据返回客户端。 2. 课程设计结束后,每位同学独立提交一份web课程设计报告,内容包括总体设计和算法分析,主要流程,测试数据及测试过程,遇到的问题及解决方法等 3. 界面截图里要有代表性的数据。三、课程设计的内容题目:基于Web的房屋出租信息发布系统 功能要求: 1. 用户管理功能,包括:用户注册,登录认证,修改个人信息; 2. 房屋出租信息发布:注册用户登录后可发布,查询,修改,删除自己发布的房屋出租信息; 3. 房屋信息查询:游客可按房屋类型,所

13、处街道或出租价格查询相应的房屋出租信息。 4. 简易论坛或聊天室四、流程图登陆页面游客登陆用户登陆用户注册个人中心进入首页个人信息删除发布进入聊天室发布信息五、数据库SQL Server 中数据库里建立了三张表,分别是User表(用户信息表)、Fw表(房屋出租信息表)和chat表(聊天记录表)。1.User表中字段:id , pwd , name , sex2.Fw表中字段:id , 编号 , 类型 , 街道 ,价格3.chat表中字段:id , stext , stime六、页面代码1、登陆页面前端代码:<% Page Language="VB" AutoEvent

14、Wireup="false" CodeFile="ulogin.aspx.vb" Inherits="_Default" %><!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Transitional/EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml"><

15、;head runat="server"> <title></title></head><body> <center> <h1>房屋出租系统</h1> <form id="form1" runat="server"> <asp:Label ID="Label1" runat="server" Text="用户名:"></asp:Label> <a

16、sp:TextBox ID="idtext" runat="server"></asp:TextBox><br/><br/> <asp:Label ID="Label2" runat="server" Text="密码:"></asp:Label> <asp:TextBox ID="pwdtext" runat="server" textmode="password"

17、;></asp:TextBox><br/><br/> <asp:Button ID="youke" runat="server" Text="游客" /> <asp:Button ID="login" runat="server" Text="登录" /><br/><br/> <asp:Button ID="uzc" runat="server&quo

18、t; Text="注册" /> </form> </center></body></html>后台代码:Imports System.DataPartial Class _Default 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

19、 New SqlConnection("server=.;database=fwcz;uid=sa;pwd=91569;") 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.Execute

20、Scalar() <> Nothing Then Session.Add("login_name", id) conn.Close() Response.Redirect("user.aspx") Else Response.Write("<script>alert('账号密码错误!')</script>") End If If conn.State = ConnectionState.Open Then conn.Close() End If Catch ex As Excepti

21、on 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 Session.Add("login_name", "guest") Response.Redirect(&quo

22、t;main.aspx") End SubEnd Class2、 用户中心页面前端代码:<% Page Language="VB" AutoEventWireup="false" CodeFile="user.aspx.vb" Inherits="user" %><!DOCTYPE html><html xmlns="/1999/xhtml"><head runat="server">&

23、lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title></head><body> <center> <form id="form1" runat="server"> <h2>用户中心</h2> <asp:Label ID="Label1" runat="serve

24、r" Text="请重新登陆!" ForeColor="#0033CC"></asp:Label> <br /> <br /> <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> <br /> <br /> 根据编号:<asp:TextBox ID="TextBox1" runat="s

25、erver"></asp:TextBox> <asp:Button ID="Button5" runat="server" Text="删除" style="height: 21px"></asp:Button> <br /> <br/> <asp:Button ID="Button2" runat="server" Text="首页"></asp:Button&

26、gt; <asp:Button ID="Button3" runat="server" Text="发布"></asp:Button><br/><br/> <asp:Button ID="Button1" runat="server" Text="个人信息"></asp:Button> <asp:Button ID="Button4" runat="server&quo

27、t; Text=" 聊天室 "></asp:Button> <br /> </form> </center></body></html>后台代码:Imports System.DataPartial Class user Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If (Session("login_name") <> Nothing) Then Dim id

28、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

29、 As SqlCommand = New SqlCommand(sqltext, conn) Dim objectreader As SqlDataReader Dim i As Integer Dim fw As String objectreader = sqlcmd.ExecuteReader() fw = "<table border=2>" fw += "<tr>" For i = 0 To objectreader.FieldCount - 1 fw += "<td>" + object

30、reader.GetName(i) + "</td>" Next fw += "</tr>" While objectreader.Read() fw += "<tr>" For i = 0 To objectreader.FieldCount - 1 fw += "<td>" + CStr(objectreader.GetValue(i) + "</td>" Next fw += "</tr>" End

31、 While fw += "</table>" Label2.Text = fw conn.Close() Else : Response.Write("<script>alert('用户过期,请重新登陆!');window.location.href ='ulogin.aspx'</script>") End If End Sub Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.

32、Click Response.Redirect("userinfo.aspx") End Sub Protected Sub Button2_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("

33、fatie.aspx") End Sub Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.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) The

34、n Dim id As String = Session("login_name") Dim n As String = TextBox1.Text.Trim() Dim conn As New SqlConnection("server=.;database=fwcz;uid=sa;pwd=91569;") Dim sqltext As String = "DELETE FROM Fw WHERE id = '" + id + "'and 编号 = '" + n + "'

35、" Try conn.Open() Dim sqlcom As SqlCommand = New SqlCommand(sqltext, conn) sqlcom.ExecuteNonQuery() conn.Close() Response.Write("<script>alert('删除成功!');window.location.href ='user.aspx'</script>") If conn.State = ConnectionState.Open Then conn.Close() End I

36、f Catch ex As Exception End Try End If End SubEnd Class3、 个人信息页面前端代码:<% Page Language="VB" AutoEventWireup="false" CodeFile="userinfo.aspx.vb" Inherits="userinfo" %><!DOCTYPE html><html xmlns="/1999/xhtml"><head r

37、unat="server"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title></head><body> <center> <form id="form1" runat="server"> <h2>您的个人信息</h2> <asp:Label ID="

38、Label10" runat="server" Text="用户名:" ForeColor="#0033CC"></asp:Label> <asp:Label ID="Label11" runat="server" Text=" " ForeColor="#0033CC"></asp:Label> <asp:Label ID="Label6" runat="server

39、" Text="姓名:" ForeColor="#0033CC"></asp:Label> <asp:Label ID="Label7" runat="server" Text=" " ForeColor="#0033CC"></asp:Label> <asp:Label ID="Label8" runat="server" Text="性别:" ForeCo

40、lor="#0033CC"></asp:Label> <asp:Label ID="Label9" runat="server" Text=" " ForeColor="#0033CC"></asp:Label> <h2>信息完善与修改</h2> <asp:Label ID="Label1" runat="server" Text="姓名:"></asp

41、:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br/><br/> <asp:Label ID="Label2" runat="server" Text="性别:"></asp:Label> <asp:DropDownList ID="DropDownList1" runat="server"

42、> <asp:ListItem Value="男"></asp:ListItem> <asp:ListItem Value="女"></asp:ListItem> </asp:DropDownList><br/><br/> <asp:Button ID="Button1" runat="server" Text="更新" style="height: 21px"></a

43、sp:Button> <h2>修改密码</h2> <asp:Label ID="Label3" runat="server" Text="原密码:"></asp:Label> <asp:TextBox ID="oldpwd" runat="server" textmode="password"></asp:TextBox><br/><br/> <asp:Label ID

44、="Label4" runat="server" Text="新密码:"></asp:Label> <asp:TextBox ID="newpwd1" runat="server" textmode="password"></asp:TextBox><br/><br/> <asp:Label ID="Label5" runat="server" Text="

45、;新密码:"></asp:Label> <asp:TextBox ID="newpwd2" runat="server" textmode="password"></asp:TextBox><br/><br/> <asp:Button ID="Button2" runat="server" Text="修改"></asp:Button> </form> </c

46、enter></body></html>后台代码:Imports System.DataPartial Class userinfo Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If (Session("login_name") <> Nothing) Then Dim id As String = Session("login_name") Dim n As String = TextBo

47、x1.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 = '" + id + "'"

48、; Try conn.Open() Dim sqlcom As SqlCommand = New SqlCommand(sqltext, conn) sqlcom.ExecuteNonQuery() conn.Close() Response.Write("<script>alert('更新成功!');window.location.href ='user.aspx'</script>") If conn.State = ConnectionState.Open Then conn.Close() End If Cat

49、ch ex As Exception End Try End If End Sub Protected Sub 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=fw

50、cz;uid=sa;pwd=91569;") Dim sqltext1 As String = "select name from User where id = '" + ID + "'" Dim sqltext2 As String = "select sex from User where id = '" + ID + "'" Try conn.Open() Dim sqlcom1 As SqlCommand = New SqlCommand(sqltext1, co

51、nn) Dim sqlcom2 As SqlCommand = New SqlCommand(sqltext2, conn) Label7.Text = sqlcom1.ExecuteScalar().ToString() Label9.Text = sqlcom2.ExecuteScalar().ToString() conn.Close() If conn.State = ConnectionState.Open Then conn.Close() End If Catch ex As Exception End Try Else : Response.Write("<sc

52、ript>alert('用户过期,请重新登陆!');window.location.href ='ulogin.aspx'</script>") End If End Sub Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim id As String = Session("login_name") Dim opwd As String = oldpwd.Text.Trim() Dim con

53、n 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.Execu

54、teScalar() <> Nothing 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,

55、conn) sqlcom1.ExecuteNonQuery() conn.Close() Response.Write("<script>alert('修改成功,请重新登录!');window.location.href ='ulogin.aspx'</script>") Else : Response.Write("<script>alert('两次新密码输入不同!')</script>") End If Else : Response.Write(&quo

56、t;<script>alert('原密码输入错误!')</script>") End If If conn.State = ConnectionState.Open Then conn.Close() End If End SubEnd Class4、 首页页面前端代码:<% Page Language="VB" AutoEventWireup="false" CodeFile="main.aspx.vb" Inherits="main" %><!

57、DOCTYPE html><html xmlns="/1999/xhtml"><head runat="server"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title></head><body> <center> <form id="form1&qu

58、ot; runat="server"> <h2>房屋出租首页</h2> 类型:<asp:DropDownList ID="DropDownList1" runat="server"> <asp:ListItem></asp:ListItem> <asp:ListItem>套房</asp:ListItem> <asp:ListItem>单间</asp:ListItem> </asp:DropDownList> 所

59、在街道:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 价格:<asp:TextBox ID="TextBox2" runat="server" Width="60px"></asp:TextBox> <asp:TextBox ID="TextBox3" runat="server" Width="60px">&

60、lt;/asp:TextBox> <br /> <br /> <asp:Button ID="Button2" runat="server" Text="查询"></asp:Button> <br /> <br /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <br /> <

61、;br/> <asp:Button ID="Button1" runat="server" Text="个人中心"></asp:Button> </form> </center></body></html>后台代码:Partial Class main Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If (Session("lo

62、gin_name") <> Nothing) Then If (Session("login_name") = "guest") Then Response.Write("<script>alert('游客请登陆!');window.location.href ='ulogin.aspx'</script>") Else : Response.Redirect("user.aspx") End If Else : Response.Red

63、irect("ulogin.aspx") End If End Sub Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If (Session("login_name") <> Nothing) Then Button1.Text = "个人中心" Else : Button1.Text = "登陆" End If Dim conn As New SqlConnection("server=.;

64、database=fwcz;uid=sa;pwd=91569;") Dim sqltext As String = "select * from Fw" conn.Open() Dim sqlcmd As SqlCommand = New SqlCommand(sqltext, conn) Dim objectreader As SqlDataReader Dim i As Integer Dim fw As String objectreader = sqlcmd.ExecuteReader() fw = "<table border=2>

65、" fw += "<tr>" For i = 0 To objectreader.FieldCount - 1 fw += "<td>" + objectreader.GetName(i) + "</td>" Next fw += "</tr>" While objectreader.Read() fw += "<tr>" For i = 0 To objectreader.FieldCount - 1 fw += "

66、;<td>" + CStr(objectreader.GetValue(i) + "</td>" Next fw += "</tr>" End While fw += "</table>" Label1.Text = fw End Sub Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim conn As New SqlConnection("s

67、erver=.;database=fwcz;uid=sa;pwd=91569;") Dim sql As String sql = "select * from Fw where" If (DropDownList1.Text.Trim() <> "") Then sql += " 类型 ='" + DropDownList1.Text.Trim() + "'" ElseIf (TextBox1.Text.Trim() <> "") Then s

68、ql += " 街道 like '%" + TextBox1.Text.Trim() + "%'" ElseIf (TextBox2.Text.Trim() <> "" And TextBox3.Text.Trim() Then sql += " 价格 BETWEEN '" + TextBox2.Text.Trim() + "' and '" + TextBox3.Text.Trim() + "'" Else Res

69、ponse.Write("<script>window.alert('请选择一项!');</script>") Exit Sub End If Try conn.Open() Dim sqlcmd As SqlCommand = New SqlCommand(sql, conn) Dim objectreader As SqlDataReader Dim i As Integer Dim fw As String objectreader = sqlcmd.ExecuteReader() fw = "<table bo

70、rder=2>" fw += "<tr>" For i = 0 To objectreader.FieldCount - 1 fw += "<td>" + objectreader.GetName(i) + "</td>" Next fw += "</tr>" While objectreader.Read() fw += "<tr>" For i = 0 To objectreader.FieldCount - 1 fw +=

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论