ImageVerifierCode 换一换
格式:DOCX , 页数:13 ,大小:172.82KB ,
资源ID:8254922      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/8254922.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(实验三 Aspnet控件应用.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

实验三 Aspnet控件应用.docx

1、实验三 Aspnet控件应用 信息工程学院实验报告成 绩:指导老师(签名):课程名称: 数据库原理 实验项目名称:A控件应用 实验时间:11.8 班级: 姓名: 学号: 一、实 验 目 的: 1、掌握WEB控件的应用; 2、掌握WEB表单验证控件的应用;二、实 验 设 备 与 器 件Win7,VS2010,Sql Server 2008三、实 验 内 容 与 步 骤 1、设计一个用户基本信息注册表单。(1) 通过利用工具箱所提供的各种组件完成注册界面的设计;图1-1 注册界面的设计(2) 获取各个控件的值;(3) 将控件的值写入student表中,具体程序代码见附录;2、设计一个用户登录表单。

2、(1) 登录界面设计;图1-2 登录界面的设计(2) 登录事件处理;根据不同的选择到不同的数据表中查询,如果选择是学生,就到Student表中查询,如果选择的是管理员,就到Manager表中查询; (3) 信息的传递:用Session对象将学号传到main页面,具体程序代码见附录。3、设计一个教师开课界面。(1) 开设新课界面设计;图1-3 教师开设新课界面设计(2) 确定事件处理,将内容写入Course表中,具体程序代码见附录。四、实 验 结 果 及 分 析:1、用户基本信息注册表单的设计结果。(1) 利用浏览器进行预览,注册界面如下:图2-1 用户注册界面(2) 学生在注册界面进行注册;图

3、2-2 用户进行注册图2-3 已注册学生信息打开管理员的学生信息管理界面,可以查看注册成功的学生信息,说明已将学生的信息写入student表中。2、用户登录表单的设计结果。(1) 利用浏览器进行预览,登录界面如下:图2-4 用户登录界面(2) 已注册的学生进行登录图2-5 已注册学生进行登录图2-6 学生成功登录系统界面(3) 管理员进行登录图2-7 管理员进行登录图2-8 管理员成功登录系统界面在登录界面,根据选择的不同用户,到不同的数据表中查询,如果选择是学生,就到Student表中查询,如果选择的是管理员,就到Manager表中查询,查询记录存在则登录相应的管理系统; 3、教师开课界面的

4、设计结果。(1) 登录管理员系统,点击进入开设新课界面进行预览,界面如下:图2-9 教师开课界面(2) 教师进行开课图2-11 开课成功提示 图2-10 教师进行开课图2-12 课程管理界面打开管理员的课程管理界面,可以查看到已开设的课程信息,说明已将教室开课的内容写入写入Course表中。五、实 验 总 结:通过这次实验的操作让我受益匪浅,在对实例的开发的期间,逐步掌握WEB控件的应用以及WEB表单验证控件的应用。包括熟悉了对数据库的建表,导入数据,查询,插入等一系列的操作。更重要的是通过独立操作并实现相应功能时所带给我的成就感。附录:/-学生注册页面程序-using System;usin

5、g System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data;using System.Data.SqlClient;public partial class 注册 : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) protected void Button1_Click(object send

6、er, EventArgs e) string no = txt_sno.Text; string paw = txt_paw.Text; string name = txt_name.Text; int age = Convert.ToInt16(txt_age.Text); string sex = ; if (rd_sex1.Checked) sex = 男; else sex = 女; string dp = dp_p.SelectedItem.Text; /数据库连接 / string strcon = Server=.;User id=linzhibin;pwd=123;datab

7、ase=MyDate; string Constr = Server=(local);Integrated Security=true;DataBase=MyDate; SqlConnection con = new SqlConnection(Constr); /编写Sql语句 string sqlstr=insert into Student values(+no+,+paw+,+name+,+age+,+sex+,+dp+); /编写SqlCommand对象 SqlCommand com=new SqlCommand(sqlstr,con); try con.Open(); com.Ex

8、ecuteNonQuery(); Response.Write(alert(注册成功!); Response.Redirect(Login.aspx); catch (Exception ex) Response.Write(alert(注册失败!); finally con.Close(); protected void Button2_Click(object sender, EventArgs e) txt_sno .Text = ; txt_name .Text = ; txt_paw.Text = ; txt_age.Text = ; /-用户-登录页面程序-using System

9、;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data;using System.Data.SqlClient;public partial class Login : System.Web.UI.Page protected void Page_L(object sender, EventArgs e) protected void Button0_Click(object

10、 sender, EventArgs e) string name = txt_name.Text; string pwd = txt_pwd.Text; /数据库连接 string Constr = Server=(local);Integrated Security=true;DataBase=MyDate; SqlConnection con = new SqlConnection(Constr); /编写Sql语句 /string sqlstr = select * from Student where Sno= + name + and pwd= + pwd + ; string s

11、qlstr = ; /编写SqlCommand对象 if (RadioButton1.Checked) sqlstr = select * from Student where Sno= + name + and pwd= + pwd + ; else sqlstr = select * from Manager where Mno= + name + and Mpwd= + pwd + ; SqlCommand com = new SqlCommand(sqlstr, con); try con.Open(); SqlDataReader dr = com.ExecuteReader();

12、if (dr.Read() /说明存在 if (RadioButton1.Checked) /学生登录成功 Sessionname = drSno.ToString(); Sessionno = drSno.ToString(); Response.Redirect(Studentmain.aspx); else /管理员登录成功 Sessionmanager = drMno.ToString(); Response.Redirect(Managermain.aspx); else Response.Write(alert(用户名或密码不对,请重新输入!); catch (Exception

13、ex) Response.Write(ex); finally con.Close(); /-教室开设课程页面程序-using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data;using System.Data.SqlClient;public partial class Manager_addCourse : System.Web.UI.Page pro

14、tected void Page_Load(object sender, EventArgs e) protected void Button3_Click(object sender, EventArgs e) string no =txt_no.Text; string name = txt_name.Text; string teacher = txt_teacher.Text; int credit = Convert.ToInt32(txt_credit.Text); string info =txt_info.Text; / string strcon = Server=.;Use

15、r id=linzhibin;pwd=123;database=MyDate; string Constr = Server=(local);Integrated Security=true;DataBase=MyDate; SqlConnection con = new SqlConnection(Constr); /编写Sql语句 string sqlstr=insert into Course values(+no+,+name+,+credit+,+teacher+,+info+); /编写SqlCommand对象 SqlCommand com=new SqlCommand(sqlstr,con); try con.Open(); com.ExecuteNonQuery(); Response.Write(alert(开课成功!); catch (Exception ex) Response.Write(ex); finally con.Close();

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1