您的当前位置:首页正文

学生信息管理系统 系统源代码

2021-06-01 来源:要发发教育
实用标准文案

系统源代码

一、登录界面代码

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.SqlClient;

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.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 + \"'\

文档

实用标准文案

da.Fill(ds);

if (ds.Tables[0].Rows.Count==0) {

Label3 .Text =\"账号或密码错误,请重新输入!\"; } else {

Session [\"userid\"]=txtid .Text ; Session[\"userpwd\"] = txtpassword.Text; Session[\"username\"] =

ds.Tables[0].Rows[0][\"username\"].ToString(); Session[\"userpower\"] =

ds.Tables[0].Rows[0][\"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 = \"对不起,权限验证失败\"; } }

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.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\ string strconn = ConfigurationManager.AppSettings[\"connStr\"]; 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('\" +

courseid.Text + \"','\" + coursename.Text + \"','\" + coursetime.Text + \"','\" + fen.Text + \"','\" + type.Text + \"','\" + teacher.Text + \"')\"; conn.Open();

mycmd = new SqlCommand(sqlstr, conn); mycmd.Dispose(); try {

mycmd.ExecuteNonQuery();

Response.Write(\"\"); }

catch (SqlException) {

Response.Write(\"\"); } finally {

conn.Close(); sqlstr = \"\"; } } }

protected void Button2_Click(object sender, EventArgs e)

文档

实用标准文案

{

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 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 partial class addscore : System.Web.UI.Page {

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.SelectedValue .ToString ()== \"\") {

Label11.Text = \"学号不能为空\"; } else {

string 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.Dispose(); try {

mycmd.ExecuteNonQuery();

Response.Write(\"\"); }

catch (SqlException) {

文档

实用标准文案

Response.Write(\"\"); } finally {

conn.Close(); sqlstr = \"\"; } } }

protected void Button2_Click(object sender, EventArgs e) {

username.Text = \"\"; coursename.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 students 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, EventArgs 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 = da[\"coursename\"].ToString(); } } }

四、添加学生程序代码

using System; using System.IO; using System.Text; 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 partial class addstudent : System.Web.UI.Page {

SqlCommand mycmd;

protected void Page_Load(object sender, EventArgs e) {

userid.Attributes.Add(\"onblur\

string strconn = ConfigurationManager.AppSettings[\"connStr\"]; SqlConnection conn = new SqlConnection(strconn); }

protected void Button1_Click(object sender, EventArgs e) {

if (userid.Text.ToString() == \"\") return;

string strconn = ConfigurationManager.AppSettings[\"connStr\"]; 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,zhengzmm,zhiw,huoj,weij)values('\" + userid.Text + \"','\" + txtusername.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 + \"','\" + txthuoj.Text + \"','\" + txtweij.Text + \"')\"; conn.Open();

mycmd = new SqlCommand(sqlstr, conn); mycmd.Dispose();

string name = this.FileUpload1.FileName;//获取上传文件的名称 string type = name.Substring(name.LastIndexOf(\"\\\\\") + 1);//获取上传文件的后缀

string ipath = Server.MapPath(\"images/\") + DateTime.Now.ToString(\"yyyyMMddhhmmss\") + name;

string wpath = \"images\\\\\" + DateTime.Now.ToString(\"yyyyMMddhhmmss\") + name;

string query1 = \"insert into images(userid,path) values('\" + userid.Text + \"',@path)\";

FileUpload1.SaveAs(ipath); //服务器保存路径 SqlCommand cm = new SqlCommand(query1); cm.Connection = conn;

cm.Parameters.Add(\"@path\ cm.Parameters[\"@path\"].Value = wpath; cm.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();

Response.Write(\"\"); }

catch (SqlException) {

Response.Write(\"\"); } finally {

sqlstr1 = \"\"; } }

catch (SqlException) {

Response.Write(\"\"); } finally {

conn.Close(); sqlstr = \"\"; } }

protected void Button2_Click(object sender, EventArgs e)

文档

实用标准文案

{

userid.Text = \"\"; txtusername.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.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 checkcourseid : System.Web.UI.Page {

文档

实用标准文案

protected void Page_Load(object 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 courseid from course where courseid='\" + nam + \"'\";

SqlCommand DBHelper;

DBHelper = new SqlCommand(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.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;

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 + \"'\"; SqlCommand DBHelper;

DBHelper = new SqlCommand(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.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 course : System.Web.UI.Page {

SqlConnection conn; SqlDataReader getdata;

protected void Page_Load(object sender, EventArgs e) {

string strconn = ConfigurationManager.AppSettings[\"connStr\"]; 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 = getdata; 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 '\" + 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 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 images_editstudent : System.Web.UI.Page {

SqlCommand cmd; SqlCommand cmd2;

protected 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 = \"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.SelectedValue = 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\"].ToString(); 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 [\"id\"];

string strconn = ConfigurationManager.AppSettings[\"connStr\"]; SqlConnection conn = new SqlConnection(strconn); string sql=\"\";

sql = \"update students set userid='\" + userid.Text + \"',username='\" + txtusername.Text + \"',minzu='\" + 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.SelectedValue + \"'where userid='\" + uid + \"'\"; cmd=new SqlCommand (sql,conn ); conn.Open(); try {

cmd.ExecuteNonQuery();

Label11.Style[\"color\"] = \"blue\"; Label11.Text = \"编辑成功\";

Response.Write(\"\"); }

catch(SqlException ) {

Label11.Text = \"编辑失败\"; Label11.Style[\"color\"] = \"red\"; }

cmd.Dispose(); conn.Close(); }

protected void Button2_Click(object sender, EventArgs e) {

string sql = \"\"; string uid = \"\"; 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 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();

Label11.Style[\"color\"] = \"blue\"; Label11.Text = \"删除成功\";

Response.Write(\"\");

}

catch (SqlException) {

Label11.Text = \"删除失败\";

Response.Write(\"\"); } finally {

sql1 = \"\"; }

文档

实用标准文案

}

catch(SqlException ) {

Label11.Text = \"删除失败\"; Label11.Style[\"color\"] = \"red\"; }

cmd.Dispose(); conn.Close(); userid.Text = \"\"; 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\"); } }

九、编辑、删除课程信息程序代码

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.SqlClient;

public partial 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.Request[\"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.ExecuteReader(); 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 = reader[\"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(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 SqlCommand(sql, conn); conn.Open(); try {

cmd.ExecuteNonQuery(); Label7.Text = \"编辑成功\";

Response.Write(\"\"); }

catch (SqlException) {

Label7.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\"]; 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(\"\"); }

catch (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 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 partial class editscore : System.Web.UI.Page {

SqlCommand cmd;

文档

实用标准文案

SqlConnection conn;

protected 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\"]; conn = new SqlConnection(strconn);

sql = \"select * from score where id='\" + uid + \"'\"; SqlCommand cmd;

cmd = new SqlCommand(sql, conn); conn.Open();

reader = cmd.ExecuteReader(); while (reader.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[\"score\"].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);

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(); try {

cmd.ExecuteNonQuery(); Label11.Text = \"编辑成功\";

Response.Write(\"\"); }

catch (SqlException) {

Label11.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 = \"delete from score where id='\" + uid + \"'\"; cmd = new SqlCommand(sql, conn); conn.Open(); try {

cmd.ExecuteNonQuery(); Label11.Text = \"删除成功\";

Response.Write(\"\"); }

catch (SqlException) {

Label11.Text = \"删除失败\"; }

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)

文档

实用标准文案

{

string 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 da;

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 = \"\";

sqlstr = \"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(); } } }

十一、修改密码程序代码

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.SqlClient;

public partial class modify_pwd : System.Web.UI.Page {

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) {

string sql=\"\";

文档

实用标准文案

SqlCommand cmd; string uid; string pwd;

uid = Session[\"userid\"].ToString (); pwd = Session[\"userpwd\"].ToString(); if (txtpassword.Text == \"\") {

Label4.Text = \"原密码不能为空\"; }

else if (password.Text == \"\") {

Label4.Text = \"新密码不能为空\"; }

else if (password.Text != password1.Text) {

Label4.Text = \"新密码和确认密码不一致\"; }

else if (txtpassword.Text != pwd) {

Label4.Text = \"原密码不正确\"; } else {

sql = \"\";

sql = \"update users set userpwd='\" + password.Text + \"'where userid='\" + uid + \"'\";

cmd = new SqlCommand(sql, conn); conn.Open(); try {

文档

实用标准文案

cmd.ExecuteNonQuery(); Label4.Text = \"密码修改成功\"; }

catch (SqlException) {

Label4.Text = \"密码修改失败\"; } finally {

conn.Close(); } } }

protected void Button2_Click(object sender, EventArgs e) {

Response.Redirect(\"student.aspx\"); } }

十二、学生身份操作主界面程序代码

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.SqlClient;

public partial class student : System.Web.UI.Page {

protected void Page_Load(object sender, EventArgs e) {

string strconn = ConfigurationManager.AppSettings[\"connStr\"]; SqlConnection conn = new SqlConnection(strconn); string strsql = \"\";

string a = Session[\"userid\"].ToString(); conn.Open();

strsql = \"select * from students where userid='\"+a+\"'\"; DataSet ds=new DataSet () ;

SqlDataAdapter da= new SqlDataAdapter(strsql, conn); da.Fill(ds);

if (ds.Tables[0].Rows.Count == 0) {

Response .Write (\"没有记录\"); } else {

Label1.Text = ds.Tables[0].Rows[0][\"userid\"].ToString(); Label2.Text = ds.Tables[0].Rows[0][\"username\"].ToString(); Label3.Text = ds.Tables[0].Rows[0][\"sex\"].ToString(); Label4.Text = ds.Tables[0].Rows[0][\"minzu\"].ToString(); Label5.Text = DateTime .Parse

(ds.Tables[0].Rows[0][\"birthday\"].ToString ()).ToShortDateString (); Label7.Text = ds.Tables[0].Rows[0][\"class\"].ToString(); Label8.Text = ds.Tables[0].Rows[0][\"comefrom\"].ToString(); Label9.Text = ds.Tables[0].Rows[0][\"beizhu\"].ToString();

文档

实用标准文案

}

conn.Close(); } }

十三、学生身份成绩信息程序代码

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.SqlClient;

public partial class score : System.Web.UI.Page {

SqlConnection conn;

protected void Page_Load(object sender, EventArgs e) {

string strconn = ConfigurationManager.AppSettings[\"connStr\"]; conn = new SqlConnection(strconn); SqlDataReader getdata;

SqlDataAdapter da = new SqlDataAdapter(); SqlCommand mycmd;

DataSet ds = new DataSet(); string Sql;

文档

实用标准文案

Sql = \"select * from score where userid='\" + Session[\"userid\"] + \"'\"; mycmd = new SqlCommand(Sql, conn); da.SelectCommand = mycmd; da.Fill(ds, \"login\"); conn.Open();

// getdata = mycmd.ExecuteReader(); // grdMain.DataSource = getdata;

datagrid1.DataSource = ds.Tables[\"login\"]; ; datagrid1.DataBind(); conn.Close(); }

protected void Button1_Click(object sender, EventArgs e) {

datagrid1.CurrentPageIndex = 0; SqlDataReader getdata;

SqlDataAdapter da = new SqlDataAdapter(); SqlCommand mycmd;

DataSet ds = new DataSet(); string Sql;

Sql = \"select * from score where userid='\" + txtscore.Text + \"'or year='\" + txtyear.SelectedValue + \"'\"; mycmd = new SqlCommand(Sql, conn); da.SelectCommand = mycmd; da.Fill(ds, \"login\"); conn.Open();

//getdata = mycmd.ExecuteReader(); //grdMain.DataSource = getdata;

datagrid1.DataSource = ds.Tables[\"login\"]; ; datagrid1.DataBind(); conn.Close();

文档

实用标准文案

}

protected void datagrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e) {

datagrid1.CurrentPageIndex = e.NewPageIndex; datagrid1.DataBind(); } }

文档

因篇幅问题不能全部显示,请点此查看更多更全内容