学生信息管理系统系统源代码.docx
- 文档编号:27621842
- 上传时间:2023-07-03
- 格式:DOCX
- 页数:39
- 大小:19.61KB
学生信息管理系统系统源代码.docx
《学生信息管理系统系统源代码.docx》由会员分享,可在线阅读,更多相关《学生信息管理系统系统源代码.docx(39页珍藏版)》请在冰豆网上搜索。
学生信息管理系统系统源代码
系统源代码
一、登录界面代码
usingSystem;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Collections;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
usingSystem.Data.SqlClient;
publicpartialclasslogin:
System.Web.UI.Page
{
protectedvoidtxtid_Click(objectsender,EventArgse)
{
txtid.Text="";
txtpassword.Text="";
}
protectedvoidButton1_Click(objectsender,EventArgse)
{
stringstrconn=ConfigurationManager.AppSettings["connStr"];
SqlConnectionconn=newSqlConnection(strconn);
conn.Open();
DataSetds=newDataSet();
SqlDataAdapterda=newSqlDataAdapter("select*fromuserswhereuserid='"+txtid.Text+"'anduserpwd='"+txtpassword.Text+"'",conn);
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");
}
elseif(Session["userpower"].ToString()=="1")
{
Response.Redirect("student/index.aspx");
}
else
{
Label3.Text="对不起,权限验证失败";
}
}
conn.Close();
ds.Clear();
}
}
二、添加课程页面代码
usingSystem;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Collections;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
usingSystem.Data.SqlClient;
publicpartialclassaddcourse:
System.Web.UI.Page
{
SqlCommandmycmd;
SqlConnectionconn;
protectedvoidPage_Load(objectsender,EventArgse)
{
courseid.Attributes.Add("onblur","checkcourseid()");
stringstrconn=ConfigurationManager.AppSettings["connStr"];
conn=newSqlConnection(strconn);
}
protectedvoidButton1_Click(objectsender,EventArgse)
{
if(courseid.Text.ToString()=="")
{
Label7.Text="课程号不能为空";
}
else
{
stringsqlstr="";
sqlstr="insertintocourse(courseid,coursename,coursetime,fen,type,teacher)values('"+courseid.Text+"','"+coursename.Text+"','"+coursetime.Text+"','"+fen.Text+"','"+type.Text+"','"+teacher.Text+"')";
conn.Open();
mycmd=newSqlCommand(sqlstr,conn);
mycmd.Dispose();
try
{
mycmd.ExecuteNonQuery();
Response.Write("");
}
catch(SqlException)
{
Response.Write("");
}
finally
{
conn.Close();
sqlstr="";
}
}
}
protectedvoidButton2_Click(objectsender,EventArgse)
{
courseid.Text="";
coursename.Text="";
coursetime.Text="";
fen.Text="";
type.Text="";
}
protectedvoidButton3_Click(objectsender,EventArgse)
{
Response.Redirect("course.aspx");
}
}
三、添加成绩程序代码
usingSystem;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Collections;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
usingSystem.Data.SqlClient;
publicpartialclassaddscore:
System.Web.UI.Page
{
SqlCommandmycmd;
SqlConnectionconn;
protectedvoidPage_Load(objectsender,EventArgse)
{
stringstrconn=ConfigurationManager.AppSettings["connStr"];
conn=newSqlConnection(strconn);
}
protectedvoidButton1_Click(objectsender,EventArgse)
{
if(userid.SelectedValue.ToString()=="")
{
Label11.Text="学号不能为空";
}
else
{
stringsqlstr="";
sqlstr="insertintoscore(userid,username,courseid,coursename,score,[year])values('"+userid.SelectedValue+"','"+username.Text+"','"+txtcourseid.SelectedValue+"','"+coursename.Text+"','"+score.Text+"','"+txtyear.SelectedValue+"')";
conn.Open();
mycmd=newSqlCommand(sqlstr,conn);
mycmd.Dispose();
try
{
mycmd.ExecuteNonQuery();
Response.Write("");
}
catch(SqlException)
{
Response.Write("");
}
finally
{
conn.Close();
sqlstr="";
}
}
}
protectedvoidButton2_Click(objectsender,EventArgse)
{
username.Text="";
coursename.Text="";
score.Text="";
txtyear.Text="";
}
protectedvoidButton3_Click(objectsender,EventArgse)
{
Response.Redirect("score.aspx");
}
protectedvoiduserid_SelectedIndexChanged(objectsender,EventArgse)
{
stringsqlstr="";
sqlstr="selectusernamefromstudentswhereuserid='"+userid.SelectedValue+"'";
conn.Open();
mycmd=newSqlCommand(sqlstr,conn);
mycmd.Dispose();
SqlDataReaderda;
da=mycmd.ExecuteReader();
while(da.Read())
{
username.Text=da["username"].ToString();
}
}
protectedvoidtxtcourseid_SelectedIndexChanged(objectsender,EventArgse)
{
stringsqlstr="";
sqlstr="selectcoursenamefromcoursewherecourseid='"+txtcourseid.SelectedValue+"'";
conn.Open();
mycmd=newSqlCommand(sqlstr,conn);
mycmd.Dispose();
SqlDataReaderda;
da=mycmd.ExecuteReader();
while(da.Read())
{
coursename.Text=da["coursename"].ToString();
}
}
}
四、添加学生程序代码
usingSystem;
usingSystem.IO;
usingSystem.Text;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Collections;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
usingSystem.Data.SqlClient;
publicpartialclassaddstudent:
System.Web.UI.Page
{
SqlCommandmycmd;
protectedvoidPage_Load(objectsender,EventArgse)
{
userid.Attributes.Add("onblur","checkuserid()");
stringstrconn=ConfigurationManager.AppSettings["connStr"];
SqlConnectionconn=newSqlConnection(strconn);
}
protectedvoidButton1_Click(objectsender,EventArgse)
{
if(userid.Text.ToString()=="")
return;
stringstrconn=ConfigurationManager.AppSettings["connStr"];
SqlConnectionconn=newSqlConnection(strconn);
stringsqlstr="";
stringsql="";
sqlstr="insertintostudents(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=newSqlCommand(sqlstr,conn);
mycmd.Dispose();
stringname=this.FileUpload1.FileName;//获取上传文件的名称
stringtype=name.Substring(name.LastIndexOf("\\")+1);//获取上传文件的后缀
stringipath=Server.MapPath("images/")+DateTime.Now.ToString("yyyyMMddhhmmss")+name;
stringwpath="images\\"+DateTime.Now.ToString("yyyyMMddhhmmss")+name;
stringquery1="insertintoimages(userid,path)values('"+userid.Text+"',@path)";
FileUpload1.SaveAs(ipath);//服务器保存路径
SqlCommandcm=newSqlCommand(query1);
cm.Connection=conn;
cm.Parameters.Add("@path",SqlDbType.VarChar,50);
cm.Parameters["@path"].Value=wpath;
cm.ExecuteNonQuery();
//this.lb_info.Text="上传成功!
";
try
{
mycmd.ExecuteNonQuery();
stringsqlstr1="";
sqlstr1="insertintousers(userid,username)values('"+userid.Text+"','"+txtusername.Text+"')";
SqlCommandmycmd1=newSqlCommand(sqlstr1,conn);
mycmd1.Dispose();
try
{
mycmd1.ExecuteNonQuery();
Response.Write("");
}
catch(SqlException)
{
Response.Write("");
}
finally
{
sqlstr1="";
}
}
catch(SqlException)
{
Response.Write("");
}
finally
{
conn.Close();
sqlstr="";
}
}
protectedvoidButton2_Click(objectsender,EventArgse)
{
userid.Text="";
txtusername.Text="";
txtminzu.Text="";
txtbirthday.Text="";
txtclass.Text="";
txtcomefrom.Text="";
txtbeizhu.Text="";
}
protectedvoidButton3_Click(objectsender,EventArgse)
{
Response.Redirect("student.aspx");
}
}
五、检查课程号唯一性程序代码
usingSystem;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Collections;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
usingSystem.Data.SqlClient;
publicpartialclasscheckcourseid:
System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
Response.Expires=0;
stringstrconn=ConfigurationManager.AppSettings["connStr"];
SqlConnectionconn=newSqlConnection(strconn);
stringnam=Request.QueryString["name"].ToString();
stringsql="selectcourseidfromcoursewherecourseid='"+nam+"'";
SqlCommandDBHelper;
DBHelper=newSqlCommand(sql,conn);
conn.Open();
SqlDataReaderdr=DBHelper.ExecuteReader();
if(dr.Read())
{
Response.Write("
}
else
{
Response.Write("
}
dr.Close();
}
}
六、检查学号唯一性程序代码
usingSystem;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Collections;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
usingSystem.Data.SqlCl
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 学生 信息管理 系统 源代码