學(xué)生信息管理系統(tǒng)-系統(tǒng)源代碼_第1頁
學(xué)生信息管理系統(tǒng)-系統(tǒng)源代碼_第2頁
學(xué)生信息管理系統(tǒng)-系統(tǒng)源代碼_第3頁
學(xué)生信息管理系統(tǒng)-系統(tǒng)源代碼_第4頁
學(xué)生信息管理系統(tǒng)-系統(tǒng)源代碼_第5頁
已閱讀5頁,還剩27頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、系統(tǒng)源代碼 一、登錄界面代碼 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 = 賬號(hào)或密碼錯(cuò)誤,請(qǐng)重新輸入! 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 = 對(duì)不起,權(quán)限驗(yàn)證失敗 ; 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 = 課程號(hào)不能為空 ; 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 = 學(xué)號(hào)不能為空 ; 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(); 四、添加學(xué)生程序代碼 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);/ 服務(wù)器保存路徑 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); 五、檢查課程號(hào)唯一性程序代碼 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( 該課程號(hào)已經(jīng)存在,請(qǐng)換一個(gè) else Response.Write( 該課程號(hào)可以使用 ); dr.Close(); 六、檢查學(xué)號(hào)唯一性程序代碼 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( 該學(xué)號(hào)已經(jīng)存在,請(qǐng)換一個(gè) ); else ); Response.Write(該學(xué)號(hào)可以使用 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(); 八、編輯、刪除學(xué)生信息程序代碼 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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論