最新学生信息管理系统 系统源代码Word下载.docx
《最新学生信息管理系统 系统源代码Word下载.docx》由会员分享,可在线阅读,更多相关《最新学生信息管理系统 系统源代码Word下载.docx(33页珍藏版)》请在冰豆网上搜索。
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;
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();
}
二、添加课程页面代码
publicpartialclassaddcourse:
SqlCommandmycmd;
SqlConnectionconn;
protectedvoidPage_Load(objectsender,EventArgse)
courseid.Attributes.Add("
onblur"
"
checkcourseid()"
conn=newSqlConnection(strconn);
if(courseid.Text.ToString()=="
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"
三、添加成绩程序代码
publicpartialclassaddscore:
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='
SqlD