在线考试系统代码.ppt
上传人:qw****27 上传时间:2024-09-12 格式:PPT 页数:10 大小:4.2MB 金币:15 举报 版权申诉
预览加载中,请您耐心等待几秒...

在线考试系统代码.ppt

在线考试系统代码.ppt

预览

在线预览结束,喜欢就下载吧,查找使用更方便

15 金币

下载此文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

一个在线考试系统的代码设计(1)登陆页面protectedvoidPage_Load(objectsender,EventArgse){if(Session["admin"]==null){Response.Redirect("../Login.aspx");}}protectedvoidbtnSubmit_Click(objectsender,EventArgse){if(txtName.Text==""||txtNum.Text==""||txtPwd.Text==""){MessageBox.Show("请将信息填写完整");return;}else{SqlConnectionconn=BaseClass.DBCon();conn.Open();SqlCommandcmd=newSqlCommand("selectcount(*)fromtb_StudentwhereStudentNum='"+txtNum.Text+"'",conn);inti=Convert.ToInt32(cmd.ExecuteScalar());if(i>0){MessageBox.Show("此学号已经存在");return;}else{cmd=newSqlCommand("insertintotb_Student(StudentNum,StudentName,StudentSex,StudentPwd)values('"+txtNum.Text.Trim()+"','"+txtName.Text.Trim()+"','"+rblSex.SelectedValue.ToString()+"','"+txtPwd.Text.Trim()+"')",conn);cmd.ExecuteNonQuery();conn.Close();MessageBox.Show("添加成功");btnConcel_Click(sender,e);}}}protectedvoidbtnConcel_Click(objectsender,EventArgse){txtName.Text="";txtNum.Text="";txtPwd.Text="";}publicpartialclassadmin_ChangeStudentInfo:System.Web.UI.Page{privatestaticintid;protectedvoidPage_Load(objectsender,EventArgse){if(Session["admin"]==null){Response.Redirect("../Login.aspx");}if(!IsPostBack){id=Convert.ToInt32(Request.QueryString["stuid"]);SqlConnectionconn=BaseClass.DBCon();conn.Open();SqlCommandcmd=newSqlCommand("select*fromtb_StudentwhereID="+id,conn);SqlDataReadersdr=cmd.ExecuteReader();sdr.Read();txtStuName.Text=sdr["StudentName"].ToString();txtStuNum.Text=sdr["StudentNum"].ToString();txtStuPwd.Text=sdr["StudentPwd"].ToString();rblSex.SelectedValue=sdr["StudentSex"].ToString();sdr.Close();conn.Close();}}protectedvoidbtnSava_Click(objectsender,EventArgse){if(txtStuName.Text.Trim()==""||txtStuPwd.Text.Trim()==""){MessageBox.Show("请将信息填写完整");return;}else{stringstr="updatetb_StudentsetStudentName='"+txtStuName.Text.Trim()+"',StudentPwd='"+txtStuPwd.Text.Trim()+"',StudentSex='"+rblSex.SelectedItem.Text+"'whereID="+id;BaseClass.OperateData(str);Response.Redirect("StudentInfo.aspx");}}protectedvoidbtnC