杭电-aspnet期末样卷_第1页
杭电-aspnet期末样卷_第2页
杭电-aspnet期末样卷_第3页
杭电-aspnet期末样卷_第4页
杭电-aspnet期末样卷_第5页
已阅读5页,还剩20页未读 继续免费阅读

下载本文档

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

文档简介

1、杭电 -aspnet期末样卷期末样卷一、描述1、打开 VS2010,新建一个空网站项目,命名为“ 学号 姓名”,保存在磁盘考生目录;2、利用 VS2010 新建一个本地数据库,命名为“Books、mdf”,保存在项目 App_Data 目录;或使用已有数据库文件 “Books、mdf”;3、整体目录结构如下图:4、数据库中包含三张表:UserInfo用户表UserIDVarchar(10)PK用户IDUserNameVarchar(50)用户名PasswordVarchar(50)密码BookInfo书目表杭电 -aspnet期末样卷BookIDVarchar(10)PK书号 IDBookNa

2、meVarchar(50)书名PriceFloat价格OrderInfo订单表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 属性信息;实现 Find

3、Word ()方法 ,要求根据输入参数 word 在 Content 中查找出现得次数。2、控件应用题 (30 分)新建模板页 MasterPage、master,模板页含有站点地图信息;并新建一个内容页TestControl、aspx,如下图构建注册页面,使用相对应得验证控件进行输入数据得有效性验证。点击取消按钮清除文本框内已填写数据,点击确定按钮进行提交。杭电 -aspnet期末样卷3、数据库题 (50 分)主页面 MainPage、aspx 主要由一个 GridView 构成,页面打开时GridView 显示 Book 表中得信息,并允许选择删除一条Book 信息(注意如删除书本信息,必

4、须同时考虑删除订单信息)-using System;using System 、 Collections、Generic;杭电 -aspnet期末样卷using System 、 Linq;using System 、 Web;/ / Student得摘要说明/ public class Student:Human/ 、public Student()/ TODO: 在此处添加构造函数逻辑/public override void Work()/public void getInfo(params int numbers)foreach (int num in numbers)/if num

5、is Prime ouput num;private bool isPrime(int num)return true;public abstract class Humanpublic int Height get; set; public float Weight get; set; private string _name;public string Nameget return _name; set _name = value; public abstract void Work();-杭电 -aspnet期末样卷asp:SqlDataSource ID=SqlDataSource2

6、runat=serverConnectionString=SelectCommand=SELECTStudent 、StuId,Student 、 StuName, School 、 SchollFROM Student INNER JOIN School ON Student 、SchoolId = School、SchoolIdWHERE (Student、SchoolId = SchoolID)杭电 -aspnet期末样卷asp:SqlDataSource ID=SqlDataSource1 runat=server ConnectionString= SelectCommand=SEL

7、ECT * FROM School-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 partial class _Default : System、 Web、UI、Pageprotected void Page_Load(ob

8、ject sender, EventArgs e)protected void Button1_Click(object sender, EventArgs e)SqlConnection con = new SqlConnection(ConfigurationManager ConnectionStringsConnectionString 、ConnectionString);、con、Open();SqlCommand cmd = con、CreateCommand();cmd、CommandText= update student set schoolId=+DropDownList

9、2SelectedValue+ where schoolId=+DropDownList1、 SelectedValue;cmd、ExecuteNonQuery();cmd、CommandText = select Count(*) from student whereSchoolId=+DropDownList2 、SelectedValue;、Label1、Text = cmd、 ExecuteScalar()、ToString();con、Close();-Default 、aspx、csusing System;using System 、 Collections、Generic;us

10、ing System 、 Linq;using System 、 Web;杭电 -aspnet期末样卷using System 、 Web、 UI;using System 、 Web、 UI、WebControls;using System 、 Data、SqlClient;using System 、 Configuration;public partial class _Default : System、 Web、UI、Pageprotected void Page_Load(object sender, EventArgs e)protected void Button1_Click(

11、object sender, EventArgs e)SqlConnection con = new SqlConnection(ConfigurationManager ConnectionStringsConnectionString 、ConnectionString);、con、Open();SqlCommand cmd = con、CreateCommand();cmd、CommandText= update stuInfoset schoolID=+DropDownList2SelectedValue+where schoolID =+DropDownList1、 Selected

12、Value;cmd、ExecuteNonQuery();cmd、CommandText = select count(*) from stuInfo whereschoolID=+DropDownList2 、SelectedValue;、Label1、Text = cmd、 ExecuteScalar()、ToString();con、Close();-杭电 -aspnet期末样卷asp:SqlDataSource ID=SqlDataSource1 runat=serverConnectionString=DeleteCommand=DELETE FROM Student WHEREStu

13、ID = StuIDInsertCommand=INSERT INTO Student (StuID,StuName, SchoolID) VALUES (StuID, StuName, SchoolID)SelectCommand=SELECT * FROM StudentUpdateCommand=UPDATE Student SET StuName =StuName, SchoolID = SchoolID WHERE StuID = StuID杭电 -aspnet期末样卷原先得学院 ID 为:  学院学生数量: 选择要更新得学院: 计算机学院软件工程学院asp:ListIte

14、m Value= 电气学院 杭电 -aspnet期末样卷using System;杭电 -aspnet期末样卷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 、 SqlClient;using System、Data;public partial class _Default : System、 Web

15、、UI 、 Page/ 建立数据库连接string str = ConfigurationManager、ConnectionStringsConnectionString、 ConnectionString、ToString();SqlConnection conn;protected void Page_Load(object sender, EventArgs e)conn = new SqlConnection(str);/ 打开数据库conn 、Open();/ 获取原先学院信息string sql = string、 Format(select SchoolID from Stud

16、ent);杭电 -aspnet期末样卷/ 创建查询器SqlDataAdapter sad = new SqlDataAdapter(sql, conn);/ 创建结果集DataSet dataSet = new DataSet();/ 将结果集填入sad 、Fill(dataSet);Label1 、Text = dataSet、Tables0、Rows0SchoolID、ToString();Label2 、Text = dataSet、Tables0、Rows 、Count 、ToString();conn 、Close();protected void Button1_Click(obj

17、ect sender, EventArgs e)conn = new SqlConnection(str);/ 打开数据库conn 、Open();/ 更新数据库/ 建立数据库命令SqlCommand sqlcommd2 = new SqlCommand(updateStudent set SchoolID= + (DropDownList2、 SelectedIndex + 1) + where SchoolID= + Label1、 Text 、 ToString(), conn);/ 判断就是否命令执行成功杭电 -aspnet期末样卷if (sqlcommd2、ExecuteNonQue

18、ry() 0)Response 、 Write(更新成功! );GridView1、DataBind();conn 、Close();using System;using System、Collections、Generic;using System、Linq;using System、Web;杭电 -aspnet期末样卷using System、Web、UI;using System、Web、UI 、WebControls;using System、Configuration;using System、Data、SqlClient;using System、Data;public parti

19、al class _Default : System、Web、UI 、Page/获取连接字符串stringstr=ConfigurationManager、ConnectionStringsConnectionString、ConnectionString、ToString();SqlConnection conn;protected void Page_Load(object sender, EventArgs e)conn = new SqlConnection(str);/打开数据库conn、Open();/获取原先学院信息string sql = string、Format(selec

20、t * from Student);/创建查询器SqlDataAdapter sad = new SqlDataAdapter(sql, conn);/创建结果集DataSet dataSet = new DataSet();杭电 -aspnet期末样卷/将结果集填入sad、Fill(dataSet);Label1、Text = dataSet、Tables0、Rows0SchoolID 、ToString();Label2、 Text = dataSet、 Tables0、 Rows、 Count、ToString();/使用 sqlcommd1、ExecuteScalar()进行 coun

21、t SqlCommand sqlcommd1 = new SqlCommand(selectcount(*) from Student, conn);Label3、Text = sqlcommd1、ExecuteScalar()、ToString();/使用 sqlcommd1、ExecuteReader()SqlCommand sqlcommd2 = new SqlCommand(select StuName from Student where SchoolID = 2, conn);SqlDataReader reader = sqlcommd2、ExecuteReader();stri

22、ng str_name = ?;while(reader、 Read()str_name += reader0 + ,;Sessionname_1 = str_name;conn、Close();杭电 -aspnet期末样卷protected void Button1_Click(object sender, EventArgs e)conn = new SqlConnection(str);/打开数据库conn、Open();/更新数据库/建立数据库命令SqlCommand sqlcommd2 = new SqlCommand(updateStudent set SchoolID= + (D

23、ropDownList2 、SelectedIndex + 1) + where SchoolID= + Label1、Text、ToString(), conn);/SqlCommand sqlcommd2 = new SqlCommand(insertinto Student (StuID, StuName,SchoolID) values (14105177, 张 三 ,2) ,conn);/ SqlCommand sqlcommd2 = new SqlCommand(delete from Student where StuName = HHHH ,conn);/判断就是否命令执行成功

24、if (sqlcommd2、ExecuteNonQuery() 0)Response、Write( 更新成功! );GridView1 、DataBind();conn、Close();杭电 -aspnet期末样卷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();Sql

25、Command sqlcommd2 = 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)杭电 -aspnet期末样卷/打开数据库conn =

26、new SqlConnection(str);conn、Open();SqlCommand sqlcommd2 = new SqlCommand(deletefrom Student where StuName = 张三 , conn);/判断就是否命令执行成功if (sqlcommd2、ExecuteNonQuery() 0)Response、Write( 更新成功! );GridView1 、DataBind();conn、Close();protected void Button5_Click(object sender, EventArgs e)if ()(Server、MapPath

27、(/uploadFiles/) + );Image1、ImageUrl = /uploadFiles/ + ;Label4、Text = 上传成功! ;杭电 -aspnet期末样卷- 后台代码: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、SqlClient;using System、D

28、ata;public partial class _Default : System、Web、UI 、Page/获取连接字符串stringstr=ConfigurationManager、ConnectionStringsConnectionString、ConnectionString、ToString(); SqlConnection conn;protected void Page_Load(object sender, EventArgs e)conn = new SqlConnection(str);/打开数据库conn、Open();杭电 -aspnet期末样卷/获取原先学院信息s

29、tring sql = string、Format(select * from Student);/创建查询器SqlDataAdapter sad = new SqlDataAdapter(sql, conn);/创建结果集DataSet dataSet = new DataSet();/将结果集填入sad、Fill(dataSet);Label1、Text = dataSet、Tables0、Rows0SchoolID 、ToString();Label2、 Text = dataSet、 Tables0、 Rows、 Count、ToString();/使用 sqlcommd1、Execu

30、teScalar()进行 count SqlCommand sqlcommd1 = new SqlCommand(selectcount(*) from Student, conn);Label3、Text = sqlcommd1、ExecuteScalar()、ToString();/使用 sqlcommd1、ExecuteReader()SqlCommand sqlcommd2 = new SqlCommand(select StuName from Student where SchoolID = 2, conn);SqlDataReader reader = sqlcommd2、Exe

31、cuteReader();string str_name = ?;while(reader、 Read()杭电 -aspnet期末样卷str_name += reader0 + ,;Sessionname_1 = str_name;conn、Close();protected void Button1_Click(object sender, EventArgs e)conn = new SqlConnection(str);/打开数据库conn、Open();/更新数据库/建立数据库命令SqlCommand sqlcommd2 = new SqlCommand(updateStudent s

32、et SchoolID= + (DropDownList2 、SelectedIndex + 1) + where SchoolID= + Label1、Text、ToString(), conn);/SqlCommand sqlcommd2 = new SqlCommand(insertinto Student (StuID, StuName,SchoolID) values (14105177, 张 三 ,2) ,conn);/ SqlCommand sqlcommd2 = new SqlCommand(delete from Student where StuName = HHHH ,c

33、onn);/判断就是否命令执行成功杭电 -aspnet期末样卷if (sqlcommd2、ExecuteNonQuery() 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 sqlcommd2 = new SqlCommand(insert into Student (StuID, StuName,SchoolID) values (14105177,张三 ,2), conn);/判断就是否命令执行

温馨提示

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

评论

0/150

提交评论