web开发技术实训报告

<web开发技术>

实训报告

姓名:曾晖

班级:09网络01班

网站类型:个人网站

指导老师:曾小亮

实训时间:20##-12-20----20##-12-30

一、实习目的

·让学生了解网站的制作流程和基本技法。

. Dreamweaver的使用

·掌握利用IIS完成站点创建,学会站点的规划与创建,能自己创建个人网站和简单的企业网站。

·掌握利用SQL Server的企业管理器建立数据库和数据库表,巩固数据库基本命令的使用(当然,不反对利用ACCESS建立数据库和数据库表)。

·掌握利用ASP访问与操作数据库的各种常用的功能及实现方法。

·了解动态网页的制作技术,掌握与数据库的链接及简单的数据处理。

·培训学生的动手能力、综合应用能力和团队合作能力。

二、实习要求

·按时、按地参加实习,遵守实习纪律,遵守实习场地的制度;

·爱护实习场地的所有实习设备,讲究公共卫生;

·做好实习笔记和实习记载, 实掌握实习的每项内容;

·认真填写好实习报告、实习总结,实习完成统一交实习老师。

三、实习形式

·前一周完成ASP、SQL Server(或Access)以及DeramweacerMX2004的学习,要及时完成学习任务。

·后一两周进行网站综合开发实训,可分组进行。(题目可自选,要求:有一定实际意义的网络数据库应用程序,具有较好的界面和使用的方便性、准确性和安全性,且能在机上运行通过软件。)

四、实习内容及进程

五、实验内容

椭圆: Flash动画1.网站结构示意图

 

                

 

2.实验作品大概示意图和浏览流程

(1)Index.asp

打开我的首页,然后点击zhufu按钮进入按钮界面,

(20如下(2)所示

(2)newyears/index.asp

进入页面后有一首欢快的背景音乐,在祝福页面里,你可以向你的好友发表你的祝福,你可以对祝福查看和修改,并且还可以看到历史记录,页面右上角可以返回首页。

(3)liuyan1/index.asp

回到主页再点击留言按钮,进入下一页面,你可以发表留言,不需要审核也能发表。

由于时间仓促,网站暂时到此,网站还在积极开设建设中,敬请期待你的到来

五、实训结果(实训分析)

 实验基本成功

实训是培养学生综合运用所学知识,发现,提出,分析和解决实际问题,通过上机练习来培养我们自身实践能力,这次网页布局训练就是其中之一。

这次的网页设计与制作让我收获颇丰。的确,从听老师解说到开始自己制作,从理论到实践,在这几节课的实操时间里,过程中不仅巩固了以前所学过的知识,而且学到了很多在书本上所没有学到过的知识。使我懂得了理论与实际相结合是很重要的,只有从理论中得出结论,才能真正为掌握技术,从而提高自己的实际动手能力和独立思考的能力。只有把布局的基础打好,才能设计出成功的网页

六,实训心得

首先我要做的就是要选择好题目和网站的风格,之后我就分步骤准备在制作网站前所要做好的准备工作。我浏览了日照职业技术学院以及相关网站的一些特点,借鉴这些网站的优秀之处,不好的地方在自己的网站上加以改良,从而使自己的网站更加美观。

回顾这次课程设计,至今我仍感慨颇多。的却。从选题到开始制作,从理论到实践,在实训机房日子里,可以说得是苦多于甜,但是可以学到很多很多的的东西,同时不仅可以巩固了以前所学过的知识,而且学到了很多在书本上所没有学到过的知识。

在选择好题目和网站的风格之后,我就开始了实训项目的进程,按照实训方案的规定,先是将网站的总体策划以书面的形式展现出来,通过老师审核之后,在相应的时间段找相关的素材,搜集与主题相关的文字、图像等。再是设计网站的内容结构、目录结构和链接结构,设计首页及其页面的版式结构。然后创建本地网站,建立网站的目录结构。制作首页、二级子页、内容页,创建超级链接。最后就是测试与浏览网页,如果还有什么不理想的地方再改进再预览,如此反复,最后达到最好效果!

在此次网站的设计与制作过程中,难免会遇到过各种各样的问题,这毕竟是第一次独自设计网站、制作网站。但值得高兴的是:在设计的过程中发现了自己的不足之处,对以前所学过的知识理解得不够深刻,掌握得不够牢固,没有能完全达到自己预期的效果,还好通过老师的细心指导才能达到最终效果……

 WEB网站开发技术

实训总结

 本学期的第十七、十八周,我们电商两个班一起进行了网页设计与制作的实训课程,从中学到了很多,也懂得了更多有关这门课程的专业知识及运用。培养我们学生综合运用本学期所学知识来发现、提出、分析和解决实际问题,锻炼实践能力,是对我们学生实际工作能力的具体训练和考察过程.

课程设计是培养学生综合运用所学知识,发现,提出,分析和解决实际问题,锻炼实践能力的重要环节,是对学生实际工作能力的具体训练和考察过程.随着科学技术发展的日新日异,网页设计制作已经成为当今计算机应用中空前活跃的领域,在生活中可以说得是无处不在。因此作为二十一世纪的大学来说掌握网页设计制作的技术能力是十分重要的。

这次实训老师要求我们每人提交两份作业,一份是实训报告,另一份是运用所学知识建立一个电子商务研究所的网站。

在选择好题目和网站的风格之后,我就开始了实训项目的进程,按照实训方案的规定,先是将网站的总体策划以书面的形式展现出来,通过老师审核之后,在相应的时间段找相关的素材,搜集与主题相关的文字、图像、动画、音乐等。再是设计网站的内容结构、目录结构和链接结构,设计首页及其页面的版式结构。然后创建本地网站,建立网站的目录结构。制作首页、二级子页、内容页,创建超级链接。最后就是测试与浏览网页,如果还有什么不理想的地方再改进再预览,如此反复,最后达到最好效果!

这次实训是我自己第一次建立网站,难免紧张中带着一丝小兴奋,我很期待自己建成的网站是什么样子。这两周的实训,从选材到开始制作,从理论到实践,一路上留下了我们学习的点点滴滴。在这两周实训的日子里,我不仅巩固了课本上的知识,而且切身体会到了理论与实际相结合的重要性。从理论中得出结论,才能真正为掌握技术,从而提高自己的实际动手能力和独立思考的能力。

通过这次的实训,我从中发现了自己的不足之处,并且积极努力改正。一份耕耘,一份收获,你课堂上学到了多少,你就会在建网站的时候多运用几分。

生命不是一场赛跑,而是一次旅行。比赛在乎终点,而旅行在乎沿途风景。我会记住学习《网页设计与制作》实训过程中的点点滴滴,珍惜学习的机会。瞩目远方,你才会加快步伐;观赏风景,你才会步履轻盈;结伴同行,你才能欢歌笑语;风雨兼程,你才能成功登顶

 

第二篇:基于Web的数据库开发实训报告模板

2011-20xx年度 第一学期 实验专用周

班级:Z090551/52

实验环节名称:基于Web的数据库开发 实验专用周题目:学生成绩管理系统 学生学号:

学生姓名:

学生班级:

实验专用周指导教师:

实验专用周完成日期:2011.12.16

学生成绩:

一、目标:

通过基于Web的数据库开发,使学生更进一步的掌握ASP.NET课堂讲授的内容,把理论知识灵活地运用到ASP.NET程序的开发与设计中去。

二、要求:

按时参加基于Web的数据库开发训练,不得迟到和早退;独立完成程序设计;按要求撰写实践报告。

三、详细内容:

使用《ASP.NET》课程讲授内容,设计学生成绩管理系统,要求实现如下功能: 1. 用户登陆

学生信息管理网站采用用户名及密码验证模式,进入学生信息管理网站前,用户必须在登陆页面输入用户名及密码,只有验证通过的用户方可进入学生信息管理网站操作主页面。 2. 用户管理

包括2个功能模块:用户信息查询以及用户的删除、修改、插入操作。 3. 学生信息管理

包括3个功能模块:学生个人信息的添加、学生个人信息的查询以及学生个人信息的修改与删除。 4. 学生成绩管理

包括3个功能模块:学生成绩的添加与删除、学生成绩查询以及学生成绩的修改。

四、数据库表设计

根据系统功能的需要,可以通过SQL Server数据库来存储各种数据。用户和角色数据存储在SQL Server 2005 Express数据库中,并由ASP.NET 成员资格服务自动维护;专业、课程、年级、班级、学生和成绩数据则存储在另一个名为srms的SQL Server 2005数据库中,各个数据表的结构分别在表1~表6中列出。

表1 Majors表

基于Web的数据库开发实训报告模板

表2 Grades表

基于Web的数据库开发实训报告模板

表3 Classes表

基于Web的数据库开发实训报告模板

表4 Courses表

基于Web的数据库开发实训报告模板

表5 Results表

基于Web的数据库开发实训报告模板

表6 Students表

基于Web的数据库开发实训报告模板

五、系统结构图

如图图1所示

基于Web的数据库开发实训报告模板

图1 系统结构图

六、源代码

1、站点地图Web.sitemap代码

<?xml version="1.0" encoding="utf-8" ?>

<siteMap xmlns="/AspNet/SiteMap-File-1.0" > <siteMapNode url="default.aspx" title="系统首页" description=""> <siteMapNode title="管理员专区" roles="*">

<siteMapNode url="~/admin/addUser.aspx" title="添加用户" description =""/> <siteMapNode url="~/admin/findUser.aspx" title="查询用户信息" description="" /> <siteMapNode url="~/admin/manageUser.aspx" title="管理用户信息" description="删除、修改用户" />

</siteMapNode>

<siteMapNode title="操作员专区" roles="*">

<siteMapNode url="~/op/fdstuinf.aspx" title="查询学生信息" description="" /> <siteMapNode url="~/op/fdstucj.aspx" title="查询学生成绩" description="" /> </siteMapNode>

<siteMapNode title="教师专区" roles="*">

<siteMapNode url="~/teacher/bjstuinf.aspx" title="班级学生信息" description="以班级为单位查询学生信息" />

<siteMapNode url="~/teacher/bjstucj.aspx" title="班级学生成绩" description="以班级为单位查询学期成绩" />

</siteMapNode>

<siteMapNode title="学生专区" roles="*">

<siteMapNode url="~/student/fdselfinf.aspx" title="查询个人信息" description="" /> <siteMapNode url="~/student/fdselfcj.aspx" title="查询个人成绩" description="查询学生个人的所有成绩" />

</siteMapNode>

</siteMapNode>

</siteMap> 2、管理用户信息的manageUser.aspx.vb代码

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="manageUser.aspx.vb" Inherits="admin_manageUser" title="无标题页" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

<style type="text/css">

.style3

{

width: 138px;

}

</style>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> &nbsp;

<table>

<tr>

<td>

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"

CellPadding="4" ForeColor="#333333" GridLines="None" Height="238px"

Width="444px" DataKeyNames="UserName">

<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />

<RowStyle BackColor="#E3EAEB" />

<Columns>

<asp:BoundField DataField="UserName" HeaderText="用户名" />

<asp:TemplateField HeaderText="活动">

<EditItemTemplate>

<asp:CheckBox ID="chkIsApproved" runat="server"

Checked='<%# Bind("IsApproved") %>' />

</EditItemTemplate>

<ItemTemplate>

<asp:CheckBox ID="CheckBox1" runat="server"

Checked='<%# Bind("IsApproved") %>' />

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="电子邮箱">

<EditItemTemplate>

<asp:TextBox ID="txtEmail" runat="server" Text='<%#

Bind("Email") %>'></asp:TextBox>

</EditItemTemplate>

<ItemTemplate>

<asp:Label ID="Label1" runat="server" Text='<%#

Bind("Email") %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="备注">

<EditItemTemplate>

<asp:TextBox ID="txtComment" runat="server" Text='<%#

Bind("Comment") %>'></asp:TextBox>

</EditItemTemplate>

<ItemTemplate>

<asp:Label ID="Label2" runat="server" Text='<%#

Bind("Comment") %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:CommandField CancelText="取消" EditText="编辑用户" ShowEditButton="True" UpdateText="更新" />

<asp:CommandField DeleteText="删除用户" ShowDeleteButton="True" />

<asp:CommandField SelectText="编辑角色" ShowSelectButton="True" />

</Columns>

<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" /> <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />

<EditRowStyle BackColor="#7C6F57" />

<AlternatingRowStyle BackColor="White" />

</asp:GridView>

</td>

<td class="style3">

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<asp:Table ID="tbRoles" runat="server" Width="19px" Height="16px">

</asp:Table>

<asp:Label ID="lblUserName" runat="server"></asp:Label>

<asp:DataList ID="lstRoles" runat="server" CellPadding="4" ForeColor="#333333" Width="58px">

<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <AlternatingItemStyle BackColor="White" />

<ItemStyle BackColor="#E3EAEB" />

<SelectedItemStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" /> <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <ItemTemplate>

<asp:CheckBox ID="chkUserInRole" runat="server"

oncheckedchanged="chkUserInRole_CheckedChanged" />

</ItemTemplate>

</asp:DataList>

</td>

</tr>

</table>

</asp:Content>

管理用户信息的

Sub gvDataBind()

Me.GridView1.DataSource = Membership.GetAllUsers() '获取数据库中用户集合

Me.GridView1.DataBind() '执行数据绑定

End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Me.IsPostBack Then

gvDataBind()

End If

End Sub

'单击用户列表中的“编辑用户”按钮时执行以下事件处理程序

Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As

System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing

Me.GridView1.EditIndex = e.NewEditIndex '使该列转换为编辑模式

gvDataBind() '执行数据绑定

End Sub

Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As

System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating

Dim IsApproved As Boolean =

CType(Me.GridView1.Rows(e.RowIndex).Cells(1).FindControl("chkIsApproved"), CheckBox).Checked Dim Email As String =

CType(Me.GridView1.Rows(e.RowIndex).Cells(2).FindControl("txtEmail"), TextBox).Text Dim Comment As String =

CType(Me.GridView1.Rows(e.RowIndex).Cells(3).FindControl("txtComment"), TextBox).Text Dim OldUserName As String = Me.GridView1.DataKeys(e.RowIndex).Value

Dim CurrentUser As MembershipUser = Membership.GetUser(OldUserName) manageUser.aspx.vb代码

CurrentUser.IsApproved = IsApproved

CurrentUser.Email = Email

CurrentUser.Comment = Comment

Membership.UpdateUser(CurrentUser)

Me.GridView1.EditIndex = -1

Me.gvDataBind()

End Sub

'在编辑模式下单击“取消”链接时执行以下事件处理程序

Protected Sub GridView1_RowCancelingEdit(ByVal sender As Object, ByVal e As

System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GridView1.RowCancelingEdit Me.GridView1.EditIndex = -1

gvDataBind()

End Sub

'单击用户列表中的“删除用户”链接时执行以下事件处理程序

Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As

System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting

Dim UserName As String = Me.GridView1.DataKeys(e.RowIndex).Value

Me.GridView1.EditIndex = -1

Me.gvDataBind()

End Sub

'在GridView控件中创建行时执行以下事件处理程序

Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As

System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated

If e.Row.RowState = DataControlRowState.Normal Or e.Row.RowState =

DataControlRowState.Alternate Then

If e.Row.Cells(5).Controls.Count <> 0 Then

Dim btnDelete As LinkButton = e.Row.Cells(5).Controls(0)

If btnDelete IsNot Nothing Then

btnDelete.Attributes("onclick") = "return confirm('你确定要删除这个用户吗?')"

End If

End If

End If

End Sub

'通用过程,用于实现DataList控件的数据绑定

Sub DataListBinding(ByVal UserName As String)

Me.lstRoles.DataSource = Roles.GetAllRoles()

Me.lstRoles.DataBind()

For i As Integer = 0 To Roles.GetAllRoles.Length - 1

Dim chkUserInRole As CheckBox =

CType(Me.lstRoles.Items(i).FindControl("chkUserInRole"), CheckBox)

chkUserInRole.Text = Roles.GetAllRoles(i)

chkUserInRole.Checked = Roles.IsUserInRole(UserName, Roles.GetAllRoles(i)) chkUserInRole.Attributes("RoleName") = Roles.GetAllRoles(i)

Next

End Sub

'在用户列表中单击“编辑角色”链接时执行以下事件处理程序

Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged

Dim UserName As String = Me.GridView1.SelectedValue

Me.lblUserName.Text = "将用户<b>" & UserName & "</b>添加到:"

DataListBinding(UserName)

Me.tbRoles.Visible = True

Me.ViewState("UserName") = UserName

End Sub

'单击某角色前面的复选框时执行以下事件处理程序

Protected Sub chkUserInRole_CheckedChanged(ByVal sender As Object, ByVal e As

System.EventArgs)

Dim UserName As String = Me.ViewState("UserName")

Dim chkUserInRole As CheckBox = CType(sender, CheckBox)

Dim RoleName As String = chkUserInRole.Attributes("RoleName")

If Roles.IsUserInRole(UserName, RoleName) Then

Roles.RemoveUserFromRole(UserName, RoleName)

Else

Roles.AddUserToRole(UserName, RoleName)

End If

DataListBinding(UserName)

End Sub

End Class

3、操作员查询并管理学生成绩的fdstucj.aspx代码

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="fdstucj.aspx.vb" Inherits="op_fdstucj" title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

<style type="text/css">

.style3

{

width: 249px;

}

</style>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <table class="style1">

<tr>

<td class="style3">

年级:<asp:DropDownList ID="lstGrade" runat="server"

DataSourceID="SqlDataSource1"

DataTextField="GradeName" DataValueField="GradeID" AutoPostBack="True"> </asp:DropDownList>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"

ConnectionString="<%$ ConnectionStrings:srmsConnectionString %>" SelectCommand="SELECT * FROM [Grades]"></asp:SqlDataSource></td> <td>

专业:<asp:DropDownList ID="lstMajor" runat="server"

DataSourceID="SqlDataSource2"

DataTextField="MajorName" DataValueField="MajorID">

</asp:DropDownList>

<asp:SqlDataSource ID="SqlDataSource2" runat="server"

ConnectionString="<%$ ConnectionStrings:srmsConnectionString %>" SelectCommand="SELECT DISTINCT Majors.MajorID, Majors.MajorName,

Students.GradeID FROM Majors INNER JOIN Students ON Majors.MajorID = Students.MajorID WHERE (Students.GradeID = @GradeID)">

<SelectParameters>

<asp:ControlParameter ControlID="lstGrade" Name="GradeID"

PropertyName="SelectedValue" />

</SelectParameters>

</asp:SqlDataSource>

</td></tr>

<tr>

<td class="style3">

班级:<asp:DropDownList ID="lstClass" runat="server"

DataSourceID="SqlDataSource3"

DataTextField="ClassName" DataValueField="ClassID">

</asp:DropDownList>

<asp:SqlDataSource ID="SqlDataSource3" runat="server"

ConnectionString="<%$ ConnectionStrings:srmsConnectionString %>"

SelectCommand="SELECT DISTINCT Classes.ClassID, Classes.ClassName FROM Students INNER JOIN Classes ON Students.ClassID = Classes.ClassID WHERE (Students.GradeID = Students.GradeID)"></asp:SqlDataSource></td>

<td>

课程:<asp:DropDownList ID="lstCourse" runat="server"

DataSourceID="SqlDataSource4" DataTextField="CourseName"

DataValueField="CourseID">

</asp:DropDownList>

<asp:SqlDataSource ID="SqlDataSource4" runat="server"

ConnectionString="<%$ ConnectionStrings:srmsConnectionString %>"

SelectCommand="SELECT [CourseID], [GradeID], [MajorID], [CourseName] FROM

[Courses] WHERE (([GradeID] = @GradeID) AND ([MajorID] = @MajorID))">

<SelectParameters>

<asp:ControlParameter ControlID="lstGrade" Name="GradeID"

PropertyName="SelectedValue" Type="Int32" />

<asp:ControlParameter ControlID="lstMajor" Name="MajorID"

PropertyName="SelectedValue" Type="Int32" />

</SelectParameters>

</asp:SqlDataSource>&nbsp;

<asp:Button ID="btnLoad" runat="server" Text="加载数据" />

</td>

</tr>

<tr>

<td colspan="2">

<asp:GridView ID="gvResult" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#336666" BorderStyle="Double"

orderWidth="3px"

CellPadding="4" GridLines="Horizontal"

Height="97px" Width="545px" AllowPaging="True" AllowSorting="True" DataKeyNames="StudentID,CourseID" PageSize="5"

DataSourceID="SqlDataSource5">

<FooterStyle BackColor="White" ForeColor="#333333" />

<RowStyle BackColor="White" ForeColor="#333333" />

<Columns>

<asp:BoundField DataField="StudentID" HeaderText="学号"

ReadOnly="True"

SortExpression="StudentID" />

<asp:BoundField DataField="StudentName" HeaderText="姓名"

ReadOnly="True"

SortExpression="StudentName" />

<asp:BoundField DataField="Result" HeaderText="成绩"

SortExpression="Result" />

<asp:CommandField ShowEditButton="True" />

<asp:CommandField ShowDeleteButton="True" />

</Columns>

<PagerStyle BackColor="#336666" ForeColor="White"

HorizontalAlign="Center" />

<SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />

<HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" /> </asp:GridView>

<asp:SqlDataSource ID="SqlDataSource5" runat="server"

ConnectionString="<%$ ConnectionStrings:srmsConnectionString %>" SelectCommand="SELECT r.StudentID, s.StudentName, r.CourseID,

co.CourseName, r.Result, s.ClassID, cl.ClassName FROM Courses AS co INNER JOIN Results AS r ON co.CourseID = r.CourseID INNER JOIN Students AS s ON r.StudentID = s.StudentID INNER JOIN Classes AS cl ON s.ClassID = cl.ClassID WHERE (s.ClassID = @ClassID) AND (r.CourseID = @CourseID)" DeleteCommand="DELETE FROM Results WHERE (StudentID = @StudentID) AND (CourseID = @CourseID)"

UpdateCommand="UPDATE Results SET Result = @Result WHERE (StudentID = @StudentID) AND (CourseID = @CourseID)">

<SelectParameters>

<asp:ControlParameter ControlID="lstClass" Name="ClassID" PropertyName="SelectedValue" />

<asp:ControlParameter ControlID="lstCourse" Name="CourseID" PropertyName="SelectedValue" />

</SelectParameters>

<DeleteParameters>

<asp:Parameter Name="StudentID" />

<asp:Parameter Name="CourseID" />

</DeleteParameters>

<UpdateParameters>

<asp:Parameter Name="Result" />

<asp:Parameter Name="StudentID" />

<asp:Parameter Name="CourseID" />

</UpdateParameters>

</asp:SqlDataSource>

</td>

</tr>

</table>

</asp:Content>

操作员查询并管理学生成绩的fdstucj.aspx.vb代码

Partial Class op_fdstucj

Inherits System.Web.UI.Page

Protected Sub gvResult_RowCancelingEdit(ByVal sender As Object, ByVal e As

System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles gvResult.RowCancelingEdit gvResult.EditIndex = -1

gvResult.DataBind()

End Sub

Protected Sub gvResult_RowDeleting(ByVal sender As Object, ByVal e As

System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles gvResult.RowDeleting '设置数据库连接

Dim sqlconnstr As String = Me.SqlDataSource5.ConnectionString

Dim sqlconn As SqlConnection = New SqlConnection(sqlconnstr)

sqlconn.Open()

'删除行处理

Dim sql As String = "delete from Students where StudentID='" &

gvResult.DataKeys(e.RowIndex).Value.ToString() & "'"

Dim Comm As SqlCommand = New SqlCommand(sql, sqlconn)

Comm.ExecuteNonQuery()

sqlconn.Close()

sqlconn = Nothing

Comm = Nothing

gvResult.EditIndex = -1

gvResult.DataBind()

End Sub

Protected Sub gvResult_RowEditing(ByVal sender As Object, ByVal e As

System.Web.UI.WebControls.GridViewEditEventArgs) Handles gvResult.RowEditing

gvResult.EditIndex = e.NewEditIndex

gvResult.DataBind()

End Sub

Protected Sub gvResult_RowUpdating(ByVal sender As Object, ByVal e As

System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles gvResult.RowUpdating

Dim connection As New SqlConnection(Me.SqlDataSource5.ConnectionString)

If connection.State = Data.ConnectionState.Closed Then connection.Open()

Dim sqlUpdate As String = "update Results set Result=@Result where StudentID=@StudentID AND CourseID=@CourseID"

Dim command As New SqlCommand

command.Connection = connection

command.CommandText = sqlUpdate

command.Parameters.AddWithValue("@StudentID",

gvResult.DataKeys(e.RowIndex).Value.ToString())

command.Parameters.AddWithValue("@CourseID",

gvResult.DataKeys(e.RowIndex).Value.ToString())

Dim txtResult As TextBox = gvResult.Rows(e.RowIndex).Cells(2).Controls(0)

command.Parameters.AddWithValue("@Result", txtResult.Text)

command.ExecuteNonQuery()

Me.gvResult.DataBind()

End Sub

Protected Sub btnLoad_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLoad.Click

Dim connectionString As String = Me.SqlDataSource5.ConnectionString

Dim connection As New SqlConnection(connectionString)

Dim sqlSelect As String = "select results.StudentID,results.CourseID from results inner join students on results.StudentID=students.StudentID where(results.CourseID=@CourseID) and (students.ClassID=@ClassID)"

Dim sqlInsert As String = "insert into results(StudentID,CourseID) select

StudentID,@CourseID from Students where ClassID=@ClassID"

Dim command As New SqlCommand(sqlSelect, connection)

connection.Open()

command.Parameters.Add("@ClassID", Data.SqlDbType.Int).Value =

Me.lstClass.SelectedValue

command.Parameters.Add("@CourseID", Data.SqlDbType.Int).Value =

Me.lstCourse.SelectedValue

'检查该班课程成绩记录是否存在

Dim reader As SqlDataReader = command.ExecuteReader()

If reader.HasRows Then Exit Sub

reader.Close()

'将所选班级学生的学号和所选课程编号一次填入成绩表

command.Parameters("@ClassID").Value = Me.lstClass.SelectedValue

command.Parameters("@CourseID").Value = Me.lstCourse.SelectedValue

command.CommandText = sqlInsert

If command.ExecuteNonQuery() > 0 Then

Me.gvResult.DataBind()

End If

Me.SetGvCaption()

End Sub

'通用过程,用于设置GridView的标题文字

Sub SetGvCaption()

If Me.gvResult.Rows.Count = 0 Then

Me.gvResult.Caption = ""

Else

If Me.lstClass.SelectedIndex <> -1 And Me.lstCourse.SelectedIndex <> -1 Then Dim className As String = Me.lstClass.SelectedItem.Text

Dim courseName As String = Me.lstCourse.SelectedItem.Text

Me.gvResult.Caption = "<b>" & className & "班的《" & courseName & "》课程成绩</b>"

End If

End If

End Sub

'完成对网页和控件的所有视图状态和控件状态信息的保存后执行以下事件处理程序

Protected Sub Page_SaveStateComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SaveStateComplete

'根据4个列表框包含的项数是否为0决定是否启用“加载数据”按钮

Me.btnLoad.Enabled = (Me.lstGrade.Items.Count <> 0 And Me.lstMajor.Items.Count <> 0 And Me.lstClass.Items.Count <> 0 And Me.lstCourse.Items.Count <> 0)

End Sub

End Class

4、操作员管理学生信息的fdstuinf.aspx.vb主要事件代码

Partial Class op_fdstuinf

Inherits System.Web.UI.Page

'通用过程,根据年级列表框的内容更改班级列表框的内容,实现二者的联动

Sub dropdownlistBind(ByVal sender As Object)

Dim gradeid As Integer = CType(sender, DropDownList).SelectedValue

Dim lstClass As DropDownList = CType(Me.fvStudent.Row.Cells(0).FindControl("lstClass"), DropDownList)

Dim connstring As String = Me.dsDetail.ConnectionString

Dim conn As New SqlConnection(connstring)

conn.Open()

Dim sql As String = "select * from Classes where GradeID=" & gradeid

Dim command As New SqlCommand(sql, conn)

Dim reader As SqlDataReader = command.ExecuteReader()

Dim i As Integer = 0

lstClass.Items.Clear()

Do While reader.Read()

lstClass.Items.Add(i)

lstClass.Items(i).Value = reader.Item("ClassID")

lstClass.Items(i).Text = reader.Item("ClassName")

i += 1

Loop

End Sub

'页面加载事件处理程序

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim connectionString As String = Me.dsDetail.ConnectionString

Dim connection As New SqlConnection(connectionString)

Dim sql As String = "select * from Majors;" & "select * from Grades;select * from Classes" Dim command As New SqlCommand(sql, connection)

connection.Open()

Dim reader As SqlDataReader = command.ExecuteReader()

Dim lbl As Label = CType(Me.Master.FindControl("lblMessage"), Label)

If Not reader.HasRows Then

lbl.Text = "暂无专业信息!"

Me.fvStudent.Enabled = False

End If

reader.NextResult()

If Not reader.HasRows Then

lbl.Text &= "暂无年级信息!"

Me.fvStudent.Enabled = False

End If

reader.NextResult()

If Not reader.HasRows Then

lbl.Text &= "暂无班级信息!"

Me.fvStudent.Enabled = False

End If

End Sub

'在从表中插入记录前执行以下事件处理程序,对输入的学号进行检查

Protected Sub fvStudent_ItemInserting(ByVal sender As Object, ByVal e As

System.Web.UI.WebControls.FormViewInsertEventArgs) Handles fvStudent.ItemInserting

Dim sno As String = e.Values(0)

Dim gradeid As Integer = e.Values(4)

Dim classid As Integer = e.Values(5)

If sno.Length <> 6 Or Not IsNumeric(sno) Then

e.Cancel = True

CType(Me.Master.FindControl("lblMessage"), Label).Text = "学号必须是6为数字!" End If

Dim connectionString As String = Me.dsDetail.ConnectionString

Dim connection As New SqlConnection(connectionString)

Dim sql As String = "select * from Students where StudentID='" & sno & "'"

Dim command As New SqlCommand(sql, connection)

connection.Open()

Dim reader As SqlDataReader = command.ExecuteReader()

If reader.HasRows Then

e.Cancel = True

CType(Me.Master.FindControl("lblMessage"), Label).Text = "学号" & sno & "已存在!" End If

End Sub

'从表中插入记录后执行以下事件处理程序

Protected Sub fvStudent_ItemInserted(ByVal sender As Object, ByVal e As

System.Web.UI.WebControls.FormViewInsertedEventArgs) Handles fvStudent.ItemInserted

Me.gvStudent.DataBind()

e.KeepInInsertMode = True

End Sub

'在从表中更新记录后执行以下事件处理程序

Protected Sub fvStudent_ItemUpdated(ByVal sender As Object, ByVal e As

System.Web.UI.WebControls.FormViewUpdatedEventArgs) Handles fvStudent.ItemUpdated

Me.gvStudent.DataBind()

End Sub

'当从“年级”列表中选择一个不同项时执行以下事件处理程序

Protected Sub lstGrade_SelectedIndexChanged(ByVal sender As Object, ByVal e As

System.EventArgs)

Me.dropdownlistBind(sender)

End Sub

'呈现“年级”列表框前执行以下事件处理程序

Protected Sub lstGrade_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Me.dropdownlistBind(sender)

End Sub

'当从表的工作模式发生变化时执行以下事件处理程序

Protected Sub fvStudent_ModeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles fvStudent.ModeChanged

Select Case Me.fvStudent.CurrentMode

Case FormViewMode.Edit

Me.fvStudent.Caption = "修改学生记录"

Case FormViewMode.Insert

Me.fvStudent.Caption = "添加学生记录"

Case FormViewMode.ReadOnly

Me.fvStudent.Caption = "学生详细信息"

End Select

End Sub

'在主表单击导航链接时执行以下事件处理程序

Protected Sub gvStudent_PageIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvStudent.PageIndexChanged

Me.gvStudent.SelectedIndex = -1

End Sub

'单击“添加学生记录”按钮时执行以下事件处理程序

Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Me.fvStudent.Caption = "添加学生记录"

End Sub

'在主表中选择不同记录时执行以下事件处理程序

Protected Sub gvStudent_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvStudent.SelectedIndexChanged

Me.fvStudent.Caption = "学生详细信息"

End Sub

End Class

七、总结

这次web综合课程设计是我们这学期对此课程的一次综合性检测。通过这次做综合设计,我明白了让理论联系上实际并不是一件简单的事。我们平时很少动手操作,这也使我们知道了很多以前没有涉及到的方面,让我们知道了更多的知识,增强了我们动手操作能力,实践能力,去发现问题,解决问题的能力,为以后的学习、生活、工作积累了经验,打了一定基础。在这段时间的上机学习,我了解了关于web编程的简单基础知识和web程序开发环境,还有一些web数据库应用程序的一些知识,在学习过程中,我遇到了不少问题,在建立数据库的过程中时有小问题发生,我们同学之间都会互相帮助,体现了大家的团结精神。当然,在学习过程中遇到的不少困难,大多是老师为我们耐心的讲解,我们还需要多到图书馆去借阅相关书籍,读一些课外资料,使我们在有充分理论知识的前提下去增强动手能力,我想效果会更好。我们所具备的知识是远远不够的,需要在课下多和老师交流交流。总之,我们在这方面还有待提高,需要自身去努力。这次的学生成绩管理系统还存在着一定问题,希望在以后的时间里能提高自己,做得越来越好。

相关推荐