版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、期末样卷一、描述1、 打开VS2010,新建一个空网站项目,命名为“学号姓名”,保存在磁盘考生目录;2、 利用VS2010新建一个本地数据库,命名为“Books.mdf”,保存在项目App_Data目录;或使用已有数据库文件“Books.mdf”;3、 整体目录结构如下图:4、 数据库中包含三张表:UserInfo 用户表UserIDVarchar(10) PK用户IDUserNameVarchar(50)用户名PasswordVarchar(50)密码BookInfo 书目表BookIDVarchar(10) PK书号IDBookNameVarchar(50)书名PriceFloat价格Or
2、derInfo 订单表UserIDVarchar(10) PK用户IDBookIDVarchar(10) PK书号IDCountInt数量5、把压缩包内三篇短文放置在目录Books下。二、试题1、面向对象题(20分)。周三下午1:30 6/312 创建一个抽象类:书类(Book),包含书号BookID、书名BookName,价格Price,包含一个抽象方法int FindWord(string word);创建一个教材类(TeachingMaterial)继承于书类,包含内容Content属性信息;实现FindWord ()方法,要求根据输入参数word在Content中查找出现的次数。2、控
3、件应用题(30分)新建模板页MasterPage.master,模板页含有站点地图信息;并新建一个内容页TestControl.aspx,如下图构建注册页面,使用相对应的验证控件进行输入数据的有效性验证。点击取消按钮清除文本框内已填写数据,点击确定按钮进行提交。3、数据库题(50分)主页面MainPage.aspx主要由一个GridView构成,页面打开时GridView显示Book表中的信息,并允许选择删除一条Book信息(注意如删除书本信息,必须同时考虑删除订单信息)-using System;using System.Collections.Generic;using System.Li
4、nq;using System.Web;/ <summary>/ Student 的摘要说明/ </summary>public class Student:Human /.public Student()/ TODO: 在此处添加构造函数逻辑/ public override void Work() / public void getInfo(params int numbers) foreach (int num in numbers) /if num is Prime ouput num; private bool isPrime(int num) return
5、true; public abstract class Human public int Height get; set; public float Weight get; set; private string _name; public string Name get return _name; set _name = value; public abstract void Work();-<% Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs&qu
6、ot; Inherits="_Default" %><!DOCTYPE html><html xmlns="/1999/xhtml"><head runat="server"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title></head><body&g
7、t; <form id="form1" runat="server"> <div> </div> <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="Scholl" DataValueField="SchoolId"
8、> </asp:DropDownList> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="StuId" DataSourceID="SqlDataS
9、ource2"> <Columns> <asp:BoundField DataField="StuId" HeaderText="学号" ReadOnly="True" SortExpression="StuId" /> <asp:BoundField DataField="StuName" HeaderText="姓名" SortExpression="StuName" /> <asp:Bound
10、Field DataField="Scholl" HeaderText="学院" SortExpression="Scholl" /> </Columns> </asp:GridView> <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource1" DataTextField="Scholl" DataValueFie
11、ld="SchoolId"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT Student.StuId, Student.StuName, School.Scholl FROM Student INNER
12、JOIN School ON Student.SchoolId = School.SchoolId WHERE (Student.SchoolId = SchoolID)"> <SelectParameters> <asp:ControlParameter ControlID="DropDownList1" Name="SchoolID" PropertyName="SelectedValue" /> </SelectParameters> </asp:SqlDataSourc
13、e> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand
14、="SELECT * FROM School"></asp:SqlDataSource> </form></body></html>-using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data.SqlClient;using System.Configuration;public p
15、artial class _Default : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) protected void Button1_Click(object sender, EventArgs e) SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings"ConnectionString".ConnectionString); con.Open(); SqlCommand
16、cmd = con.CreateCommand(); cmd.CommandText = "update student set schoolId="+DropDownList2.SelectedValue+" where schoolId="+DropDownList1.SelectedValue; cmd.ExecuteNonQuery(); cmd.CommandText = "select Count(*) from student where SchoolId="+DropDownList2.SelectedValue; L
17、abel1.Text = cmd.ExecuteScalar().ToString(); con.Close(); -Default.aspx.csusing System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data.SqlClient;using System.Configuration;public partial class _Default : System
18、.Web.UI.Page protected void Page_Load(object sender, EventArgs e) protected void Button1_Click(object sender, EventArgs e) SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings"ConnectionString".ConnectionString); con.Open(); SqlCommand cmd = con.CreateCommand(); cmd
19、.CommandText = "update stuInfo set schoolID="+DropDownList2.SelectedValue+"where schoolID ="+DropDownList1.SelectedValue; cmd.ExecuteNonQuery(); cmd.CommandText = "select count(*) from stuInfo where schoolID="+DropDownList2.SelectedValue; Label1.Text = cmd.ExecuteScalar
20、().ToString(); con.Close(); -<% Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Transitional/EN" "/TR/xhtml1/DTD/xhtml1-transitional.d
21、td"><html xmlns="/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <div> <asp:SqlDataSource ID="SqlDataSource1" runat="serv
22、er" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM Student WHERE StuID = StuID" InsertCommand="INSERT INTO Student (StuID, StuName, SchoolID) VALUES (StuID, StuName, SchoolID)" SelectCommand="SELECT * FROM Student
23、" UpdateCommand="UPDATE Student SET StuName = StuName, SchoolID = SchoolID WHERE StuID = StuID"> <DeleteParameters> <asp:Parameter Name="StuID" Type="String" /> </DeleteParameters> <InsertParameters> <asp:Parameter Name="StuID&quo
24、t; Type="String" /> <asp:Parameter Name="StuName" Type="String" /> <asp:Parameter Name="SchoolID" Type="String" /> </InsertParameters> <UpdateParameters> <asp:Parameter Name="StuName" Type="String" /&
25、gt; <asp:Parameter Name="SchoolID" Type="String" /> <asp:Parameter Name="StuID" Type="String" /> </UpdateParameters> </asp:SqlDataSource> <br /> 原先的学院ID为:<asp:Label ID="Label1" runat="server" Text="Labe
26、l"></asp:Label> 学院学生数量:<asp:Label ID="Label2" runat="server" Text="Labe2"></asp:Label> <br /> 选择要更新的学院:<asp:DropDownList ID="DropDownList2" runat="server"> <asp:ListItem Selected="True">
27、;计算机学院</asp:ListItem> <asp:ListItem>软件工程学院</asp:ListItem> <asp:ListItem Value="电气学院"></asp:ListItem> </asp:DropDownList> <br /> <asp:Button ID="Button1" runat="server" Text="确定更新" onclick="Button1_Click" /
28、> <br /> <br /> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="StuID" DataSourceID="SqlDataSource1"> <Columns> <asp:BoundField DataField="StuID" HeaderText="StuID&quo
29、t; ReadOnly="True" SortExpression="StuID" /> <asp:BoundField DataField="StuName" HeaderText="StuName" SortExpression="StuName" /> <asp:BoundField DataField="SchoolID" HeaderText="SchoolID" SortExpression="SchoolID
30、" /> </Columns> </asp:GridView> <br /> </div> </form></body></html>using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Configuration;using System.Data.SqlCl
31、ient;using System.Data;public partial class _Default : System.Web.UI.Page /建立数据库连接 string str = ConfigurationManager.ConnectionStrings"ConnectionString".ConnectionString.ToString(); SqlConnection conn; protected void Page_Load(object sender, EventArgs e) conn = new SqlConnection(str); /打开数
32、据库 conn.Open(); /获取原先学院信息 string sql = string.Format("select SchoolID from Student"); /创建查询器 SqlDataAdapter sad = new SqlDataAdapter(sql, conn); /创建结果集 DataSet dataSet = new DataSet(); /将结果集填入 sad.Fill(dataSet); Label1.Text = dataSet.Tables0.Rows0"SchoolID".ToString(); Label2.Tex
33、t = dataSet.Tables0.Rows.Count.ToString(); conn.Close(); protected void Button1_Click(object sender, EventArgs e) conn = new SqlConnection(str); /打开数据库 conn.Open(); /更新数据库 /建立数据库命令 SqlCommand sqlcommd2 = new SqlCommand("update Student set SchoolID=" + (DropDownList2.SelectedIndex + 1) + &q
34、uot; where SchoolID=" + Label1.Text.ToString(), conn); /判断是否命令执行成功 if (sqlcommd2.ExecuteNonQuery() > 0) Response.Write("更新成功!"); GridView1.DataBind(); conn.Close(); using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web
35、.UI.WebControls;using System.Configuration;using System.Data.SqlClient;using System.Data;public partial class _Default : System.Web.UI.Page /获取连接字符串 string str = ConfigurationManager.ConnectionStrings"ConnectionString".ConnectionString.ToString(); SqlConnection conn; protected void Page_Lo
36、ad(object sender, EventArgs e) conn = new SqlConnection(str); /打开数据库 conn.Open(); /获取原先学院信息 string sql = string.Format("select * from Student"); /创建查询器 SqlDataAdapter sad = new SqlDataAdapter(sql, conn); /创建结果集 DataSet dataSet = new DataSet(); /将结果集填入 sad.Fill(dataSet); Label1.Text = dataS
37、et.Tables0.Rows0"SchoolID".ToString(); Label2.Text = dataSet.Tables0.Rows.Count.ToString(); /使用sqlcommd1.ExecuteScalar()进行count SqlCommand sqlcommd1 = new SqlCommand("select count(*) from Student", conn); Label3.Text = sqlcommd1.ExecuteScalar().ToString(); /使用sqlcommd1.ExecuteRea
38、der() SqlCommand sqlcommd2 = new SqlCommand("select StuName from Student where SchoolID = 2", conn); SqlDataReader reader = sqlcommd2.ExecuteReader(); string str_name = "?" while(reader.Read() str_name += reader0 + "," Session"name_1" = str_name; conn.Close();
39、 protected void Button1_Click(object sender, EventArgs e) conn = new SqlConnection(str); /打开数据库 conn.Open(); /更新数据库 /建立数据库命令 SqlCommand sqlcommd2 = new SqlCommand("update Student set SchoolID=" + (DropDownList2.SelectedIndex + 1) + " where SchoolID=" + Label1.Text.ToString(), con
40、n);/ SqlCommand sqlcommd2 = new SqlCommand("insert into Student (StuID, StuName,SchoolID) values (14105177,'张三',2)" ,conn);/ SqlCommand sqlcommd2 = new SqlCommand("delete from Student where StuName = 'HHHH'" ,conn); /判断是否命令执行成功 if (sqlcommd2.ExecuteNonQuery() >
41、 0) Response.Write("更新成功!"); GridView1.DataBind(); conn.Close(); protected void Button2_Click(object sender, EventArgs e) Response.Redirect("check.aspx"); protected void Button3_Click(object sender, EventArgs e) /打开数据库 conn = new SqlConnection(str); conn.Open(); SqlCommand sqlcom
42、md2 = new SqlCommand("insert into Student (StuID, StuName,SchoolID) values (14105177,'张三',2)", conn); /判断是否命令执行成功 if (sqlcommd2.ExecuteNonQuery() > 0) Response.Write("更新成功!"); GridView1.DataBind(); conn.Close(); protected void Button4_Click(object sender, EventArgs e)
43、/打开数据库 conn = new SqlConnection(str); conn.Open(); SqlCommand sqlcommd2 = new SqlCommand("delete from Student where StuName = '张三'", conn); /判断是否命令执行成功 if (sqlcommd2.ExecuteNonQuery() > 0) Response.Write("更新成功!"); GridView1.DataBind(); conn.Close(); protected void Butt
44、on5_Click(object sender, EventArgs e) if (FileUpload1.HasFile) FileUpload1.SaveAs(Server.MapPath("/uploadFiles/") + FileUpload1.FileName); Image1.ImageUrl = "/uploadFiles/" + FileUpload1.FileName; Label4.Text = "上传成功!" -后台代码:using System;using System.Collections.Generic
45、;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Configuration;using System.Data.SqlClient;using System.Data;public partial class _Default : System.Web.UI.Page /获取连接字符串 string str = ConfigurationManager.ConnectionStrings"ConnectionString"
46、.ConnectionString.ToString(); SqlConnection conn; protected void Page_Load(object sender, EventArgs e) conn = new SqlConnection(str); /打开数据库 conn.Open(); /获取原先学院信息 string sql = string.Format("select * from Student"); /创建查询器 SqlDataAdapter sad = new SqlDataAdapter(sql, conn); /创建结果集 DataSet
47、 dataSet = new DataSet(); /将结果集填入 sad.Fill(dataSet); Label1.Text = dataSet.Tables0.Rows0"SchoolID".ToString(); Label2.Text = dataSet.Tables0.Rows.Count.ToString(); /使用sqlcommd1.ExecuteScalar()进行count SqlCommand sqlcommd1 = new SqlCommand("select count(*) from Student", conn); Lab
48、el3.Text = sqlcommd1.ExecuteScalar().ToString(); /使用sqlcommd1.ExecuteReader() SqlCommand sqlcommd2 = new SqlCommand("select StuName from Student where SchoolID = 2", conn); SqlDataReader reader = sqlcommd2.ExecuteReader(); string str_name = "?" while(reader.Read() str_name += rea
49、der0 + "," Session"name_1" = str_name; conn.Close(); protected void Button1_Click(object sender, EventArgs e) conn = new SqlConnection(str); /打开数据库 conn.Open(); /更新数据库 /建立数据库命令 SqlCommand sqlcommd2 = new SqlCommand("update Student set SchoolID=" + (DropDownList2.Selecte
50、dIndex + 1) + " where SchoolID=" + Label1.Text.ToString(), conn);/ SqlCommand sqlcommd2 = new SqlCommand("insert into Student (StuID, StuName,SchoolID) values (14105177,'张三',2)" ,conn);/ SqlCommand sqlcommd2 = new SqlCommand("delete from Student where StuName = 'HHHH'" ,conn); /判断是否命令执行成功 if (sqlcommd2.ExecuteNonQuery() > 0) Response.Write("更新成功!"); GridView1.DataBind(); conn.Close();
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 护理核心制度要点精讲
- 2026年大学大一(经济学基础实训)弹性理论应用阶段测试试题及答案
- 2026年大学大一(机械电子工程)机电系统故障诊断阶段测试题及答案
- 摄像岗位方向分析
- 急诊科护理急救技能培训与演练
- 房颤患者护理沟通技巧
- 护理团队沟通:建立有效桥梁
- 护理礼仪与医院文化
- 护理管理学自考应试技巧
- 护理学导论护理沟通技巧
- 高速铁路接触网设备运行与维护课件:接触网支撑定位装置
- 反歧视艾滋病培训
- 膈下脓肿护理查房
- 《形象塑造》课件
- 渠道开发与维护课件
- 养老行业从业人员健康管理制度
- Unit 3 On the Move单词讲解 课件高中英语外研版(2019)必修第二册
- 养鹅专业技术工作总结报告
- 20S121生活热水加热机组(热水机组选用与安装)
- 小班数学活动《宝宝送物品》课件
- (高清版)DZT 0388-2021 矿区地下水监测规范
评论
0/150
提交评论