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

下载本文档

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

文档简介

1、系统源代码一、登录界面代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;protected void txtid_Click(object sender, EventArgs e)txtid.Text =""txtpassword.Text =""protected void Button1_Click(object sender, EventArgs e)string strconn = Config

2、urationManager.AppSettings"connStr"SqlConnection conn = new SqlConnection(strconn);conn.Open();DataSet ds=new DataSet ();SqlDataAdapter da = new SqlDataAdapter("select * from users where userid='" + txtid.Text + "' and userpwd='" + txtpassword.Text + "&

3、quot;', conn);da.Fill(ds);if (ds.Tables0.Rows.Count=0)Label3 .Text ="账号或密码错误,请重新输入!"elseSession "userid"=txtid .Text ;Session"userpwd" = txtpassword.Text;Session"username" = ds.Tables0.Rows0"username".ToString();Session"userpower" = ds.

4、Tables0.Rows0"userpower".ToString(); if (Session"userpower".ToString () = "0") Response.Redirect("admin/index.aspx");else if (Session"userpower".ToString() = "1")Response.Redirect("student/index.aspx"); else Label3.Text ="对不起

5、,权限验证失败 "conn.Close();ds.Clear ();二、添加课程页面代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;SqlCommand mycmd;SqlConnection conn;protected void Page_Load(object sender, EventArgs e)string strconn = ConRgurationManager.AppSettings"connStr&q

6、uot; conn = new SqlConnection(strconn);protected void Button1_Click(object sender, EventArgs e) Label7.Text ="课程号不能为空" else string sqlstr ="" sqlstr = "insert intocourse(courseid,coursename,coursetime,fen,type,teacher)values("' + courseid.Text + "','&qu

7、ot; + coursename.Text + "','" + coursetime.Text + "','" + fen.Text + "','" + type.Text + "','"+teacher.Text + "')"conn.Open();mycmd = new SqlCommand(sqlstr, conn);mycmd.Dispose();try mycmd.ExecuteNonQuery(); Respon

8、se.Write("<script>javascript:alert('添加成功!');</script>");catch (SqlException) Response.Write("<script>javascript:alert('添加失败!');</script>"); finally conn.Close();sqlstr =""protected void Button2_Click(object sender, EventArgs e)cou

9、rseid.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.Configuration;using

10、System.Collections;using System.Web;SqlCommand mycmd;SqlConnection conn;protected void Page_Load(object sender, EventArgs e)string strconn = ConfigurationManager.AppSettings"connStr"conn = new SqlConnection(strconn);protected void Button1_Click(object sender, EventArgs e)if (userid.Selecte

11、dValue .ToString ()="") Labelll.Text ="学号不能为空 "elsestring sqlstr =""sqlstr = "insert intoscore(userid,username,courseid,coursename,score,year)values("' + userid.SelectedValue + "','"+ username.Text + "','" + txtcourseid.

12、SelectedValue + "','" + coursename.Text + "','" + score.Text + "','" + txtyear.SelectedValue + "')"conn.Open();mycmd = new SqlCommand(sqlstr, conn);mycmd.Dispose();trymycmd.ExecuteNonQuery();Response.Write("<script>javasc

13、ript:alert('添加成功!');</script>");catch (SqlException)Response.Write("<script>javascript:alert('添力口失败!!');</script>");finallyconn.Close();sqlstr =""protected void Button2_Click(object sender, EventArgs e) username.Text =""coursename.

14、Text =""score.Text =""txtyear.Text =""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 s

15、tudents where userid='" + userid.SelectedValue + ; ;conn.Open();mycmd = new SqlCommand(sqlstr, conn);mycmd.Dispose();SqlDataReader da;da = mycmd.ExecuteReader();while (da.Read()username.Text = da"username".ToString();protected void txtcourseid_SelectedIndexChanged(object sender, E

16、ventArgs e)string sqlstr =""sqlstr = "select coursename from course where courseid='" +txtcourseid.SelectedValue + ""'conn.Open();mycmd = new SqlCommand(sqlstr, conn);mycmd.Dispose();SqlDataReader da;da = mycmd.ExecuteReader();while (da.Read()coursename.Text = d

17、a"coursename".ToString();四、添加学生程序代码using System;using System.。using System.Text;using System.Data;using System.Configuration;using System.Collections;using System.Web;SqlCommand mycmd;protected void Page_Load(object sender, EventArgs e)string strconn = ConfigurationManager.AppSettings"

18、;connStr"SqlConnection conn = new SqlConnection(strconn);protected void Button1_Click(object sender, EventArgs e)return;string strconn = ConfigurationManager.AppSettings"connStr"SqlConnection conn = new SqlConnection(strconn);string sqlstr =""string sql =""conn.Ope

19、n();mycmd = new SqlCommand(sqlstr, conn);mycmd.Dispose();获取上传文件的名称string type = name.Substring(name.LastIndexOf("") + 1);/获取上传文件的后缀string query1 = "insert into images(userid,path) values。' + userid.Text + "',path)"FileUploadl.SaveAs(ipath); / 服务器保存路径SqlCommand cm = n

20、ew SqlCommand(queryl);cm.Connection = conn;cm.Parameters"path".Value = wpath;cm.ExecuteNonQuery();/ this.lb_info.Text =" 上传成功!"trymycmd.ExecuteNonQuery();string sqlstrl =""sqlstrl = "insert into users(userid,username)values('" + userid.Text + "',&

21、#39;" + txtusername.Text + "')"SqlCommand mycmdl = new SqlCommand(sqlstr1, conn);mycmd1.Dispose();trymycmd1.ExecuteNonQuery();Response.Write("<script>javascript:alert('添加成功!');</script>");添加失败!');</script>");catch (SqlException)Response

22、.Write("<script>javascript:alert('finallysqlstrl =""catch (SqlException)Response.Write("<script>javascript:alert('添力口失败!!');</script>");finallyconn.Close();sqlstr =""protected void Button2_Click(object sender, EventArgs e)userid.Text =

23、""txtusername.Text =""txtminzu.Text =""txtbirthday.Text =""txtclass.Text =""txtcomefrom.Text =""txtbeizhu.Text =""protected void Button3_Click(object sender, EventArgs e)Response.Redirect("student.aspx");五、检查课程号唯一性程序代码us

24、ing System;using System.Data;using System.Configuration;using System.Collections;using System.Web;protected void Page_Load(object sender, EventArgs e) Response.Expires = 0;string strconn = ConfigurationManager.AppSettings"connStr"SqlConnection conn = new SqlConnection(strconn);string nam =

25、 Request.QueryString"name".ToString();string sql = "select courseid from course where courseid='" + nam + "'"SqlCommand DBHelper;DBHelper = new SqlCommand(sql, conn);conn.Open();</b>");SqlDataReader dr = DBHelper.ExecuteReader(); if (dr.Read() Respons

26、e.Write("<b class='Error'>该课程号已经存在,请换一个 else Response.Write("<b class='Right'>该课程号可以使用</b>"); dr.Close();六、检查学号唯一性程序代码using System; using System.Data;using System.Configuration;using System.Collections;using System.Web;protected void Page_Load(object

27、sender, EventArgs e)Response.Expires = 0;string strconn = ConfigurationManager.AppSettings"connStr"SqlConnection conn = new SqlConnection(strconn);string nam = Request.QueryString"name".ToString();string sql = "select userid from students where userid='" + nam + &qu

28、ot;"'SqlCommand DBHelper;DBHelper = new SqlCommand(sql, conn);conn.Open();SqlDataReader dr = DBHelper.ExecuteReader();if (dr.Read()</b>");Response.Write("<b class='Error'>该学号已经存在,请换一个 elseResponse.Write("<b class='Right'>该学号可以使用</b>&quo

29、t;);dr.Close();七、课程信息程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;SqlConnection conn;SqlDataReader getdata;protected void Page_Load(object sender, EventArgs e)string strconn = ConfigurationManager.AppSettings"connStr"conn = new Sql

30、Connection(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 = getdata;grdMain.DataBind();conn.Clo

31、se();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 + "'orcoursename like '" + coursename.Text +

32、 "'" cmd = new SqlCommand(strsql, conn);da = cmd.ExecuteReader();Datagridl.DataSource = da;Datagrid1.DataBind();conn.Close();cmd.Dispose();八、编辑、删除学生信息程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;SqlCommand cmd;SqlCommand cmd2;p

33、rotected void Page_Load(object sender, EventArgs e) if (!this.IsPostBack)string sql =""SqlDataReader reader;string uid =""uid = Page.Request"id"string strconn = ConfigurationManager.AppSettings"connStr"SqlConnection conn = new SqlConnection(strconn);sql = &quo

34、t;select * from students where userid='" + uid + "”'SqlCommand cmd;cmd = new SqlCommand(sql, conn);conn.Open();reader = cmd.ExecuteReader();while (reader.Read()userid.Text = reader"userId".ToString();txtusername.Text = reader"username".ToString();txtsex.Selected

35、Value = reader"sex".ToString();txtminzu.Text = reader"minzu".ToString();txtbirthday.Text = reader"birthday".ToString();txtclass.Text = reader"class".ToString();txtcomefrom.Text = reader"comefrom".ToString();txtxuey.Text = reader"xuey".ToStr

36、ing();txtzhuany.Text = reader"zhuany".ToString();txttel.Text = reader"tel".ToString();txtidc.Text = reader"idc".ToString();cmd.Dispose();sql =""conn.Close();protected void Button1_Click(object sender, EventArgs e)string uid=""uid=Page .Request "

37、id"string strconn = ConfigurationManager.AppSettings"connStr"SqlConnection conn = new SqlConnection(strconn);string sql=""cmd=new SqlCommand (sql,conn );conn.Open();trycmd.ExecuteNonQuery();Label11.Style"color" = "blue"!');</script>");Label

38、ll.Text ="编辑成功"Response.Write("<script>javascript:alert('编辑成功catch(SqlException )Labelll.Text ="编辑失败"Label11.Style"color" = "red"cmd.Dispose();conn.Close();protected void Button2_Click(object sender, EventArgs e)string sql =""string ui

39、d =""string sqlall =""uid = Page.Request"id"string strconn = ConfigurationManager.AppSettings"connStr"SqlConnection conn = new SqlConnection(strconn);sql = "delete from students where userid='" + uid + "”'sqlall = "delete from image

40、s where userid='" + uid + ""'cmd = new SqlCommand(sql, conn);cmd2 = new SqlCommand(sqlall,conn);conn.Open();trycmd.ExecuteNonQuery();string sql1 =""sql1 = "delete from users where userid='" + uid + ""'SqlCommand cmdl = new SqlCommand(sql1,

41、 conn);cmd1.Dispose();trycmd1.ExecuteNonQuery();Label11.Style"color" = "blue"!');</script>");!');</script>");Labelll.Text ="删除成功"Response.Write("<script>javascript:alert(' 删除成功catch (SqlException)Label11.Text ="删除失败"

42、;Response.Write("<script>javascript:alert(' 删除失败finallysql1 =""catch(SqlException )Labelll.Text ="删除失败"Label11.Style"color" = "red"cmd.Dispose();conn.Close();userid.Text =""txtusername.Text =""txtminzu.Text =""txtbi

43、rthday.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("studen

44、t.aspx");九、编辑、删除课程信息程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;SqlCommand cmd;protected void Page_Load(object sender, EventArgs e)if (!this.IsPostBack)string sql =""SqlDataReader reader;string uid =""uid = Page.Req

45、uest"id"string strconn = ConfigurationManager.AppSettings"connStr"SqlConnection conn = new SqlConnection(strconn);sql = "select * from course where courseid='" + uid + ""'SqlCommand cmd;cmd = new SqlCommand(sql, conn);conn.Open();reader = cmd.ExecuteRe

46、ader();while (reader.Read()courseid.Text = reader"courseid".ToString();coursename.Text = reader"coursename".ToString();coursetime.Text = reader"coursetime".ToString();fen.Text = reader"fen".ToString();type.Text = reader"type".ToString();type.Text = r

47、eader"teacher".ToString();cmd.Dispose();sql =""conn.Close();protected void Button1_Click(object sender, EventArgs e)string uid =""uid = Page.Request"id"string strconn = ConfigurationManager.AppSettings"connStr"SqlConnection conn = new SqlConnection(s

48、trconn);string sql =""sql = "update course set courseid='" + courseid.Text + "',coursename='" + coursename.Text + "',coursetime='" + coursetime.Text + "',fen='" + fen.Text + "',type='" + type.Text + "

49、;',teacher='" + teacher.Text + "' where courseid='" + uid + "'"cmd = new SqlCommand(sql, conn);conn.Open();trycmd.ExecuteNonQuery();Label7.Text ="编辑成功"Response.Write("<script>javascript:alert('编辑成功catch (SqlException)Label7.Text =

50、"编辑失败"cmd.Dispose();conn.Close();protected void Button2_Click(object sender, EventArgs e)string sql =""string uid =""uid = Page.Request"id"string strconn = ConfigurationManager.AppSettings"connStr"SqlConnection conn = new SqlConnection(strconn);sql =

51、 "delete from course where courseid='" + uid + "'"cmd = new SqlCommand(sql, conn);conn.Open();trycmd.ExecuteNonQuery();Label7.Text ="删除成功"Response.Write("<script>javascript:alert(' 删除成功catch (SqlException)!');</script>");!');<

52、;/script>");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");

53、十、编辑、删除成绩信息程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;SqlCommand cmd;SqlConnection conn;protected void Page_Load(object sender, EventArgs e)if (!this.IsPostBack)string sql =""SqlDataReader reader;string uid =""uid = Pag

54、e.Request"id"string strconn = ConRgurationManager.AppSettings"connStr"conn = new SqlConnection(strconn);sql = "select * from score where id='" + uid + "'"SqlCommand cmd;cmd = new SqlCommand(sql, conn);conn.Open();reader = cmd.ExecuteReader();while (rea

55、der.Read()id.Text = reader"id".ToString();userid.Text = reader"userid".ToString();username.Text = reader"username".ToString();txtcourseid.Text = reader"courseid".ToString();coursename.Text = reader"coursename".ToString();score.Text = reader"scor

56、e".ToString();cmd.Dispose();sql =""conn.Close();protected void Button1_Click(object sender, EventArgs e)string uid =""uid = Page.Request"id"string sql =""string strconn = ConfigurationManager.AppSettings"connStr"conn = new SqlConnection(strconn)

57、;sql = "update score set userid='" + userid.SelectedValue + "',username='" +username.Text + "',courseid='" + txtcourseid.SelectedValue + "',coursename='" + coursename.Text + "',score='" + score.Text + ”',year尸&

58、quot;+ txtyear.SelectedValue + "'whereid='" + uid + "”'cmd = new SqlCommand(sql,conn );conn.Open();trycmd.ExecuteNonQuery();!');</script>");Labelll.Text ="编辑成功"Response.Write("<script>javascript:alert('编辑成功catch (SqlException)Label11

59、.Text ="编辑失败"cmd.Dispose();conn.Close();protected void Button2_Click(object sender, EventArgs e)string sql =""string uid =""uid = Page.Request"id"string strconn = ConfigurationManager.AppSettings"connStr"conn = new SqlConnection(strconn);sql = "

60、delete from score where id='" + uid + "”'cmd = new SqlCommand(sql, conn);conn.Open();trycmd.ExecuteNonQuery();删除成功!!');</script>");Label11.Text ="删除成功"Response.Write("<script>javascript:alert('catch (SqlException)Labelll.Text ="删除失败"

61、;cmd.Dispose();conn.Close();id.Text =""username.Text =""coursename.Text =""score.Text =""protected void Button3_Click(object sender, EventArgs e)Response.Redirect("score.aspx");protected void userid_SelectedIndexChanged(object sender, EventArgs e)str

62、ing strconn = ConfigurationManager.AppSettings"connStr"conn = new SqlConnection(strconn);string sqlstr =""sqlstr = "select username from students where userid='" + userid.SelectedValue + ; ;conn.Open();cmd = new SqlCommand(sqlstr, conn);cmd.Dispose();SqlDataReader d

63、a;da = cmd.ExecuteReader();while (da.Read()username.Text = da"username".ToString();protected void txtcourseid_SelectedIndexChanged(object sender, EventArgs e) string strconn = ConfigurationManager.AppSettings"connStr"conn = new SqlConnection(strconn);string sqlstr =""sq

64、lstr = "select coursename from course where courseid='" +txtcourseid.SelectedValue + ""'conn.Open();cmd = new SqlCommand(sqlstr, conn);cmd.Dispose();SqlDataReader da;da = cmd.ExecuteReader();while (da.Read()coursename.Text = da"coursename".ToString();H一、修改密码程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;SqlConn

温馨提示

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

评论

0/150

提交评论