学生信息管理系统系统源代码Word文档下载推荐.docx
《学生信息管理系统系统源代码Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《学生信息管理系统系统源代码Word文档下载推荐.docx(29页珍藏版)》请在冰豆网上搜索。
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;
username"
]=ds.Tables[0].Rows[0]["
].ToString();
userpower"
if(Session["
].ToString()=="
0"
)
Response.Redirect("
admin/index.aspx"
);
elseif(Session["
].ToString()=="
1"
student/index.aspx"
Label3.Text="
对不起,权限验证失败"
conn.Close();
ds.Clear();
}
二、添加课程页面代码
SqlCommandmycmd;
SqlConnectionconn;
protectedvoidPage_Load(objectsender,EventArgse)
conn=newSqlConnection(strconn);
Label7.Text="
课程号不能为空"
stringsqlstr="
sqlstr="
insertintocourse(courseid,coursename,coursetime,fen,type,teacher)values('
+courseid.Text+"
'
+coursename.Text+"
+coursetime.Text+"
+fen.Text+"
+type.Text+"
+teacher.Text+"
)"
mycmd=newSqlCommand(sqlstr,conn);
mycmd.Dispose();
try
mycmd.ExecuteNonQuery();
Response.Write("
<
script>
javascript:
alert('
添加成功!
!
/script>
catch(SqlException)
添加失败!
finally
protectedvoidButton2_Click(objectsender,EventArgse)
courseid.Text="
coursename.Text="
coursetime.Text="
fen.Text="
type.Text="
protectedvoidButton3_Click(objectsender,EventArgse)
course.aspx"
三、添加成绩程序代码
if(userid.SelectedValue.ToString()=="
Label11.Text="
学号不能为空"
insertintoscore(userid,username,courseid,coursename,score,[year])values('
+userid.SelectedValue+"
+username.Text+"
+txtcourseid.SelectedValue+"
+score.Text+"
+txtyear.SelectedValue+"
username.Text="
score.Text="
txtyear.Text="
score.aspx"
protectedvoiduserid_SelectedIndexChanged(objectsender,EventArgse)
selectusernamefromstudentswhereuserid='
SqlDataReaderda;
da=mycmd.ExecuteReader();
while(da.Read())
username.Text=da["
protectedvoidtxtcourseid_SelectedIndexChanged(objectsender,EventArgse)
selectcoursenamefromcoursewherecourseid='
coursename.Text=da["
coursename"
四、添加学生程序代码
usingSystem.IO;
usingSystem.Text;
return;
stringsql="
获取上传文件的名称
stringtype=name.Substring(name.LastIndexOf("
\\"
)+1);
//获取上传文件的后缀
stringquery1="
insertintoimages(userid,path)values('
+userid.Text+"
@path)"
FileUpload1.SaveAs(ipath);
//服务器保存路径
SqlCommandcm=newSqlCommand(query1);
cm.Connection=conn;
cm.Parameters["
@path"
].Value=wpath;
cm.ExecuteNonQuery();
//this.lb_info.Text="
上传成功!
stringsqlstr1="
sqlstr1="
insertintousers(userid,username)values('
+txtusername.Text+"
)"
SqlCommandmycmd1=newSqlCommand(sqlstr1,conn);
mycmd1.Dispose();
mycmd1.ExecuteNonQuery();
userid.Text="
txtusername.Text="
txtminzu.Text="
txtbirthday.Text="
txtclass.Text="
txtcomefrom.Text="
txtbeizhu.Text="
student.aspx"
五、检查课程号唯一性程序代码
Response.Expires=0;
stringnam=Request.QueryString["
name"
selectcourseidfromcoursewherecourseid='
+nam+"
SqlCommandDBHelper;
DBHelper=newSqlCommand(sql,conn);
SqlDataReaderdr=DBHelper.ExecuteReader();
if(dr.Read())
bclass='
Error'
>
该课程号已经存在,请换一个<
/b>
Right'
该课程号可以使用<
dr.Close();
}
六、检查学号唯一性程序代码
selectuseridfromstudentswhereuserid='
该学号已经存在,请换一个<
该学号可以使用<
七、课程信息程序代码
SqlDataReadergetdata;
DataSetds=newDataSet();
sql="
select*fromcourseorderbycourseid"
mycmd=newSqlCommand(sql,conn);
getdata=mycmd.ExecuteReader();
grdMain.DataSource=getdata;
grdMain.DataBind();
DataSetds;
stringstrsql="
SqlCommandcmd;
strsql="
select*fromcoursewherecourseid='
orcoursenamelike'
cmd=newSqlCommand(strsql,conn);
da=cmd.ExecuteReader();
Datagrid1.DataSource=da;
Datagrid1.DataBind();
cmd.Dispose();
八、编辑、删除学生信息程序代码
SqlCommandcmd2;
if(!
this.IsPostBack)
SqlDataReaderreader;
stringuid="
uid=Page.Request["
id"
select*fromstudentswhereuserid='
+uid+"
cmd=newSqlCommand(sql,conn);
reader=cmd.ExecuteReader();
while(reader.Read())
userid.Text=reader["
userId"
txtusername.Text=reader["
us