学生信息管理系统-系统源代码_第1页
学生信息管理系统-系统源代码_第2页
学生信息管理系统-系统源代码_第3页
学生信息管理系统-系统源代码_第4页
学生信息管理系统-系统源代码_第5页
已阅读5页,还剩27页未读 继续免费阅读

下载本文档

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

文档简介

1、系统源代码 一、登录界面代码 using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlCl

2、ient; public partial class login : System.Web.UI.Page protected void txtid_Click(object sender, EventArgs e) txtid.Text = ; txtpassword.Text = ; protected void Button1_Click(object sender, EventArgs e) string strconn = ConfigurationManager.AppSettingsconnStr; SqlConnection conn = new SqlConnection(s

3、trconn); conn.Open(); DataSet ds=new DataSet () ; SqlDataAdapter da = new SqlDataAdapter(select * from users where userid= + txtid.Text + and userpwd= + txtpassword.Text + , conn); da.Fill(ds); if (ds.Tables0.Rows.Count=0) Label3 .Text = 账号或密码错误,请重新输入! else Session userid=txtid .Text ; Sessionuserpw

4、d = txtpassword.Text; Sessionusername = ds.Tables0.Rows0username.ToString(); Sessionuserpower = ds.Tables0.Rows0userpower.ToString(); if (Sessionuserpower.ToString () = 0) Response.Redirect(admin/index.aspx); else if (Sessionuserpower.ToString() = 1) Response.Redirect(student/index.aspx); else Label

5、3.Text = 对不起,权限验证失败 ; conn.Close(); ds.Clear (); 、添加课程页面代码 using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.

6、Web.UI.HtmlControls; using System.Data.SqlClient; public partial class addcourse : System.Web.UI.Page SqlCommand mycmd; SqlConnection conn; protected void Page_Load(object sender, EventArgs e) courseid.Attributes.Add(onblur, checkcourseid(); string strconn = ConfigurationManager.AppSettingsconnStr;

7、conn = new SqlConnection(strconn); protected void Button1_Click(object sender, EventArgs e) if (courseid.Text.ToString() = ) Label7.Text = 课程号不能为空 ; else string sqlstr = sqlstr = insert into course(courseid,coursename,coursetime,fen,type,teacher)values( coursename.Text + , + coursetime.Text + , + fe

8、n.Text + , + teacher.Text + ); conn.Open(); mycmd = new SqlCommand(sqlstr, conn); mycmd.Dispose(); try mycmd.ExecuteNonQuery(); Response.Write(javascript:alert( catch (SqlException) Response.Write(javascript:alert( finally conn.Close(); sqlstr = ; protected void Button2_Click(object sender, EventArg

9、s e) courseid.Text = ; + courseid.Text + , + type.Text + , + 添加成功 !);); 添加失败 !);); coursename.Text = coursetime.Text = fen.Text = type.Text = protected void Button3_Click(object sender, EventArgs e) Response.Redirect(course.aspx); 三、添加成绩程序代码 using System; using System.Data; using System.Configuratio

10、n; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class addscore : System.Web.UI.Page SqlCommand mycmd

11、; SqlConnection conn; protected void Page_Load(object sender, EventArgs e) string strconn = ConfigurationManager.AppSettingsconnStr; conn = new SqlConnection(strconn); protected void Button1_Click(object sender, EventArgs e) if (userid.SelectedValue .ToString ()= ) Label11.Text = 学号不能为空 ; else strin

12、g sqlstr = ; sqlstr = insert into score(userid,username,courseid,coursename,score,year)values( + userid.SelectedValue + , + username.Text + , + txtcourseid.SelectedValue + , + coursename.Text + , + score.Text + , + txtyear.SelectedValue + ); conn.Open(); mycmd = new SqlCommand(sqlstr, conn); mycmd.D

13、ispose(); try mycmd.ExecuteNonQuery(); Response.Write(javascript:alert( 添加成功 !);); catch (SqlException) Response.Write(javascript:alert( 添加失败 !);); finally conn.Close(); sqlstr = ; protected void Button2_Click(object sender, EventArgs e) username.Text = ; coursename.Text = ; score.Text = ; txtyear.T

14、ext = ; protected void Button3_Click(object sender, EventArgs e) Response.Redirect(score.aspx); protected void userid_SelectedIndexChanged(object sender, EventArgs e) string sqlstr = ; sqlstr = select username from students where userid= + userid.SelectedValue + conn.Open(); mycmd = new SqlCommand(s

15、qlstr, conn); mycmd.Dispose(); SqlDataReader da; da = mycmd.ExecuteReader(); while (da.Read() username.Text = dausername.ToString(); protected void txtcourseid_SelectedIndexChanged(object sender, EventArgs e) string sqlstr = ; sqlstr = select coursename from course where courseid= + txtcourseid.Sele

16、ctedValue + ; conn.Open(); mycmd = new SqlCommand(sqlstr, conn); mycmd.Dispose(); SqlDataReader da; da = mycmd.ExecuteReader(); while (da.Read() coursename.Text = dacoursename.ToString(); 四、添加学生程序代码 using System; using System.IO; using System.Text; using System.Data; using System.Configuration; usin

17、g System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class addstudent : System.Web.UI.Page SqlCommand mycmd; pro

18、tected void Page_Load(object sender, EventArgs e) userid.Attributes.Add(onblur, checkuserid(); string strconn = ConfigurationManager.AppSettingsconnStr; SqlConnection conn = new SqlConnection(strconn); protected void Button1_Click(object sender, EventArgs e) if (userid.Text.ToString() = ) return; st

19、ring strconn = ConfigurationManager.AppSettingsconnStr; SqlConnection conn = new SqlConnection(strconn); string sqlstr = ; string sql = ; sqlstr = insert into students(userid,username,sex,minzu,birthday,class,comefrom,beizhu,xuey,zhuany,tel,idc,zh engzmm,zhiw,huoj,weij)values( + userid.Text + , + tx

20、tusername.Text + , + txtsex.SelectedItem.Value + , + txtminzu.Text + , + txtbirthday.Text + , + txtclass.Text + , + txtcomefrom.Text + , + txtbeizhu.Text + , + txtxuey.SelectedValue + , + txtzhuany.SelectedValue + , + txttel.Text + , + txtidc.Text + , + txtzzmm.SelectedValue + , + txtzhiw.Text + , +

21、 txthuoj.Text + , + txtweij.Text + ); conn.Open(); mycmd = new SqlCommand(sqlstr, conn); mycmd.Dispose(); string name = this. 获取上传文件的名称 string type = name.Substring(name.LastIndexOf() + 1);/获取上传文件的后 缀 string ipath = Server.MapPath(images/) + DateTime.Now.ToString(yyyyMMddhhmmss) + name; string wpath

22、 = images + DateTime.Now.ToString(yyyyMMddhhmmss) + name; string query1 = insert into images(userid,path) values( + userid.Text + ,path); (ipath);/ 服务器保存路径 SqlCommand cm = new SqlCommand(query1); cm.Connection = conn; cm.Parameters.Add(path, SqlDbType.VarChar, 50); cm.Parameterspath.Value = wpath; c

23、m.ExecuteNonQuery(); / this.lb_info.Text = 上传成功! ; try mycmd.ExecuteNonQuery(); string sqlstr1 = ; sqlstr1 = insert into users(userid,username)values( + userid.Text + , + txtusername.Text + ) ; SqlCommand mycmd1 = new SqlCommand(sqlstr1, conn); mycmd1.Dispose(); try mycmd1.ExecuteNonQuery(); Respons

24、e.Write(javascript:alert( 添加成功 !);); catch (SqlException) Response.Write(javascript:alert( 添加失败 !);); finally sqlstr1 = ; catch (SqlException) Response.Write(javascript:alert( 添加失败 !);); finally conn.Close(); sqlstr = ; protected void Button2_Click(object sender, EventArgs e) userid.Text = ; txtuser

25、name.Text = ; txtminzu.Text = ; txtbirthday.Text = ; txtclass.Text = ; txtcomefrom.Text = ; txtbeizhu.Text = ; protected void Button3_Click(object sender, EventArgs e) Response.Redirect(student.aspx); 五、检查课程号唯一性程序代码 using System; using System.Data; using System.Configuration; using System.Collection

26、s; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class checkcourseid : System.Web.UI.Page protected void Page_Load(object sende

27、r, EventArgs e) Response.Expires = 0; string strconn = ConfigurationManager.AppSettingsconnStr; SqlConnectionconn = new SqlConnection(strconn); string nam = Request.QueryStringname.ToString(); string sql = select courseid from course where courseid= + nam + ; SqlCommand DBHelper; DBHelper = new SqlC

28、ommand(sql, conn); conn.Open(); SqlDataReader dr = DBHelper.ExecuteReader(); if (dr.Read() ); Response.Write( 该课程号已经存在,请换一个 else Response.Write( 该课程号可以使用 ); dr.Close(); 六、检查学号唯一性程序代码 using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System

29、.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class checkuser : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) Response.Expires = 0;

30、 string strconn = ConfigurationManager.AppSettingsconnStr; SqlConnection conn = new SqlConnection(strconn); string nam = Request.QueryStringname.ToString(); string sql = select userid from students where userid= + nam + SqlCommand DBHelper; DBHelper = new SqlCommand(sql, conn); conn.Open(); SqlDataR

31、eader dr = DBHelper.ExecuteReader(); if (dr.Read() Response.Write( 该学号已经存在,请换一个 ); else ); Response.Write(该学号可以使用 dr.Close(); 七、课程信息程序代码 using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using Syst

32、em.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class course : System.Web.UI.Page SqlConnection conn; SqlDataReader getdata; protected void Page_Load(object sender, EventArgs e) string strconn = Configurat

33、ionManager.AppSettingsconnStr; conn = new SqlConnection(strconn); SqlDataReader getdata; SqlCommand mycmd; DataSet ds = new DataSet(); string sql = ; sql = select * from course order by courseid; mycmd = new SqlCommand(sql, conn); conn.Open(); getdata = mycmd.ExecuteReader(); grdMain.DataSource = ge

34、tdata; grdMain.DataBind(); mycmd.Connection.Close(); conn.Close(); mycmd.Dispose(); protected void Button1_Click(object sender, EventArgs e) DataSet ds; SqlDataReader da; string strsql = ; SqlCommand cmd; conn.Open(); strsql = select * from course where courseid= + courseid.Text + or coursename like

35、 + coursename.Text + ; cmd = new SqlCommand(strsql, conn); da = cmd.ExecuteReader(); Datagrid1.DataSource = da; Datagrid1.DataBind(); conn.Close(); cmd.Dispose(); cmd.Connection.Close(); 八、编辑、删除学生信息程序代码 using System; using System.Data; using System.Configuration; using System.Collections; using Syst

36、em.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class images_editstudent : System.Web.UI.Page SqlCommand cmd; SqlCommand cmd2; protected vo

37、id Page_Load(object sender, EventArgs e) if (!this.IsPostBack) string sql = ; SqlDataReader reader; string uid = ; uid = Page.Requestid; string strconn = ConfigurationManager.AppSettingsconnStr; SqlConnection conn = new SqlConnection(strconn); sql = select * from students where userid= + uid + ; Sql

38、Command cmd; cmd = new SqlCommand(sql, conn); conn.Open(); reader = cmd.ExecuteReader(); while (reader.Read() userid.Text = readeruserId.ToString(); txtusername.Text = readerusername.ToString(); txtsex.SelectedValue = readersex.ToString(); txtminzu.Text = readerminzu.ToString(); txtbirthday.Text = r

39、eaderbirthday.ToString(); txtclass.Text = readerclass.ToString(); txtcomefrom.Text = readercomefrom.ToString(); txtxuey.Text = readerxuey.ToString(); txtzhuany.Text = readerzhuany.ToString(); txttel.Text = readertel.ToString(); txtidc.Text = readeridc.ToString(); cmd.Dispose(); sql = ; conn.Close();

40、 protected void Button1_Click(object sender, EventArgs e) string uid=; uid=Page .Request id; string strconn = ConfigurationManager.AppSettingsconnStr; SqlConnection conn = new SqlConnection(strconn); string sql=; sql = update students set userid= + userid.Text + ,username= + txtusername.Text + ,minz

41、u= + txtminzu.Text + ,sex= + txtsex.SelectedItem.Value + ,birthday= + txtbirthday.Text + ,class= + txtclass.Text + ,comefrom= + txtcomefrom.Text + ,beizhu= + txtbeizhu.Text + ,xuey= + txtxuey.Text + ,zhuany= + txtzhuany.Text + ,tel= + txttel.Text + ,idc= + txtidc.Text + ,zhengzmm= + txtzzmm.Selected

42、Value + where userid= + uid + ; cmd=new SqlCommand (sql,conn ); conn.Open(); try cmd.ExecuteNonQuery(); Label11.Stylecolor = blue; Label11.Text = 编辑成功 ; Response.Write(javascript:alert( 编辑成功 !);); catch(SqlException ) Label11.Text = 编辑失败 ; Label11.Stylecolor = red; cmd.Dispose(); conn.Close(); prote

43、cted void Button2_Click(object sender, EventArgs e) string sql = ; string uid = ; string sqlall = ; uid = Page.Requestid; string strconn = ConfigurationManager.AppSettingsconnStr; SqlConnection conn = new SqlConnection(strconn); sql = delete from students where userid= + uid + ; sqlall = delete from

44、 images where userid= + uid + ; cmd = new SqlCommand(sql, conn); cmd2 = new SqlCommand(sqlall,conn); conn.Open(); try cmd.ExecuteNonQuery(); string sql1 = ; sql1 = delete from users where userid= + uid + ; SqlCommand cmd1 = new SqlCommand(sql1, conn); cmd1.Dispose(); try cmd1.ExecuteNonQuery(); Labe

45、l11.Stylecolor = blue; Label11.Text = 删除成功 ; !);); !);); Response.Write(javascript:alert( 删除成功 catch (SqlException) Label11.Text = 删除失败 ; Response.Write(javascript:alert( 删除失败 finally sql1 = ; catch(SqlException ) Label11.Text = 删除失败 Label11.Stylecolor = red; cmd.Dispose(); conn.Close(); userid.Text

46、 = ; txtusername.Text = ; txtminzu.Text = ; txtbirthday.Text = ; txtclass.Text = ; txtcomefrom.Text = ; txtbeizhu.Text = ; txtxuey.Text = ; txtzhuany.Text = ; txttel.Text = ; txtidc.Text = ; protected void Button3_Click(object sender, EventArgs e) Response.Redirect(student.aspx); 九、编辑、删除课程信息程序代码 usi

47、ng System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public parti

48、al class editcourse : System.Web.UI.Page SqlCommand cmd; protected void Page_Load(object sender, EventArgs e) if (!this.IsPostBack) string sql = ; SqlDataReader reader; string uid = ; uid = Page.Requestid; string strconn = ConfigurationManager.AppSettingsconnStr; SqlConnection conn = new SqlConnecti

49、on(strconn); sql = select * from course where courseid= + uid + SqlCommand cmd; cmd = new SqlCommand(sql, conn); conn.Open(); reader = cmd.ExecuteReader(); while (reader.Read() courseid.Text = readercourseid.ToString(); coursename.Text = readercoursename.ToString(); coursetime.Text = readercoursetim

50、e.ToString(); fen.Text = readerfen.ToString(); type.Text = readertype.ToString(); type.Text = readerteacher.ToString(); cmd.Dispose(); sql = ; conn.Close(); protected void Button1_Click(object sender, EventArgs e) string uid = ; uid = Page.Requestid; string strconn = ConfigurationManager.AppSettings

51、connStr; SqlConnection conn = new SqlConnection(strconn); string sql = ; sql = update course set courseid= + courseid.Text + ,coursename= + coursename.Text + ,coursetime= + coursetime.Text + ,fen= + fen.Text + ,type= + type.Text + ,teacher= + teacher.Text + where courseid= + uid + ; cmd = new SqlCom

52、mand(sql, conn); conn.Open(); try cmd.ExecuteNonQuery(); Label7.Text = 编辑成功 ; Response.Write(javascript:alert( 编辑成功 !);); catch (SqlException) Label7.Text = 编辑失败 ; cmd.Dispose(); conn.Close(); protected void Button2_Click(object sender, EventArgs e) string sql = ; string uid = ; uid = Page.Requestid

53、; string strconn = ConfigurationManager.AppSettingsconnStr; SqlConnection conn = new SqlConnection(strconn); sql = delete from course where courseid= + uid + ; cmd = new SqlCommand(sql, conn); conn.Open(); try cmd.ExecuteNonQuery(); Label7.Text = 删除成功 ; !);); Response.Write(javascript:alert( 删除成功 ca

54、tch (SqlException) Label7.Text = 删除失败 ; cmd.Dispose(); conn.Close(); courseid.Text = ; coursename.Text = ; coursetime.Text = ; fen.Text = ; type.Text = ; protected void Button3_Click(object sender, EventArgs e) Response.Redirect(course.aspx); 十、编辑、删除成绩信息程序代码 using System; using System.Data; using Sy

55、stem.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class editscore : System.Web.UI.Pag

56、e SqlCommand cmd; SqlConnection conn; protected void Page_Load(object sender, EventArgs e) if (!this.IsPostBack) string sql = ; SqlDataReader reader; string uid = ; uid = Page.Requestid; string strconn = ConfigurationManager.AppSettingsconnStr; conn = new SqlConnection(strconn); sql = select * from

57、score where id= + uid + SqlCommand cmd; cmd = new SqlCommand(sql, conn); conn.Open(); reader = cmd.ExecuteReader(); while (reader.Read() id.Text = readerid.ToString(); userid.Text = readeruserid.ToString(); username.Text = readerusername.ToString(); txtcourseid.Text = readercourseid.ToString(); cour

58、sename.Text = readercoursename.ToString(); score.Text = readerscore.ToString(); cmd.Dispose(); sql = ; conn.Close(); protected void Button1_Click(object sender, EventArgs e) string uid = ; uid = Page.Requestid; string sql = string strconn = ConfigurationManager.AppSettingsconnStr; conn = new SqlConn

59、ection(strconn); sql = update score set userid= + userid.SelectedValue + ,username= + username.Text + ,courseid= + txtcourseid.SelectedValue + ,coursename= + coursename.Text + ,score= + score.Text + ,year= + txtyear.SelectedValue + where id= + uid + ; cmd = new SqlCommand(sql,conn ); conn.Open(); tr

60、y cmd.ExecuteNonQuery(); Label11.Text = 编辑成功 ; Response.Write(javascript:alert( 编辑成功 catch (SqlException) Label11.Text = 编辑失败 ; cmd.Dispose(); conn.Close(); protected void Button2_Click(object sender, EventArgs e) string sql = ; string uid = ; uid = Page.Requestid; string strconn = ConfigurationMana

温馨提示

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

评论

0/150

提交评论