This repository has been archived by the owner on Feb 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
S_Class.aspx.cs
58 lines (57 loc) · 2.56 KB
/
S_Class.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class S_Class : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Pubno"] == null)//判断登录用户名是否为空,如果为空,则跳转到登录界面
{
Server.Transfer("Entry.aspx");
}
//连接数据库读取课程信息表,并将其显示到gridview控件中
string con = "server=10.153.170.140;uid=sa;pwd=lrj@130279;database=HW;Trusted_Connection=no";
SqlConnection mycon = new SqlConnection(con);
string sql =
" SELECT Course.Cno AS 课程编码,Course.Cname AS 课程名称,Course.Credit AS 学分,Course.Cattribute AS 课程属性," +
" Course.Ctime AS 课程时间,Course.Cloc AS 课程地点, Course.Call AS 课程人数,Course.Cnow AS 已选人数,"+
" SC.Semester AS 学期,Teacher.Tname as 任课教师 FROM SC,Teacher,Course,TC"+
" WHERE SC.Sno = '"+Session["Pubno"].ToString()+"' AND"+
" TC.Semester = SC.Semester AND SC.Semester = Course.Semester AND"+
" TC.Cno = SC.Cno AND Teacher.Tno = TC.Tno AND SC.Cno = Course.Cno"+
" ORDER BY SC.Semester";
mycon.Open();
SqlDataAdapter myda = new SqlDataAdapter(sql, mycon);
DataSet myds = new DataSet();
myda.Fill(myds,"Course");
GridView1.Visible = true;
GridView1.DataSource = myds.Tables["Course"];
GridView1.DataBind();
sql =
" SELECT Course.Cno AS 课程编码,Course.Cname AS 课程名称,SC.Semester AS 学期,"+
" Book.Bno AS ISBN编码,Book.Bname AS 书名,Book.Bauthor AS 作者,Book.Bpublish AS 出版社, Book.Bvalue AS 价格" +
" FROM SC,TC,Book,Course"+
" WHERE SC.Sno = '" + Session["Pubno"].ToString() + "' AND" +
" TC.Semester = SC.Semester AND SC.Semester = Course.Semester AND" +
" TC.Cno = SC.Cno AND SC.Cno = Course.Cno AND TC.Bno = Book.Bno"+
" ORDER BY SC.Semester";
myda = new SqlDataAdapter(sql, mycon);
myda.Fill(myds, "Book");
GridView2.Visible = true;
GridView2.DataSource = myds.Tables["Book"];
GridView2.DataBind();
myds.Dispose();
myda.Dispose();
mycon.Close();
mycon.Dispose();
}
protected void Button1_Click(object sender, EventArgs e)
{
Server.Transfer("mainpage.aspx");
}
}