📄 stu_course.aspx.cs
字号:
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 studentdetail : System.Web.UI.Page
{
SqlConnection connections;
string strsql;
public void Bindgrid()
{
string strsql0 = "select * from tabstu_cour,tabcour where tabstu_cour.Crid=tabcour.Crid and Sid='" + Session["User_id"].ToString() + "'";
SqlDataAdapter sqlda = new SqlDataAdapter(strsql0, connections);
DataSet datas = new DataSet();
sqlda.Fill(datas);
DataGrid1.DataSource = datas;
DataGrid1.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
if (Session["user_id"] == null)
{
Response.Redirect("default.aspx");
}
this.Title = "浏览已选课程";
lbtnCourse_info.Enabled = false;
string connsql = System.Configuration.ConfigurationManager.AppSettings["connstring"];
connections = new SqlConnection(connsql);
if (!IsPostBack)
{
Bindgrid();
}
}
protected void lbtnQuit_Click(object sender, EventArgs e)
{
Session.Clear();
Response.Redirect("Default.aspx");
}
protected void Datagrid_course_SelectedIndexChanged(object sender, EventArgs e)
{
}
public void DataGrid_Page(object sender, DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
Bindgrid();
}
protected void btnSearch_Click(object sender, EventArgs e)
{
DataGrid1.CurrentPageIndex = 0;
if (dropType.Text == "课程名称")
{
strsql = "select * from tabcour,tabstu_cour where tabcour.Crname='" + txtKeyword.Text + "'" + "and tabstu_cour.Crid=tabcour.Crid";
//string strsql0 = "select * from tabstu_cour,tabcour where tabstu_cour.Crid=tabcour.Crid and Sid='" + Session["User_id"].ToString() + "'";
}
else
{
//strsql = "select * from tabcour where Crid='" + txtKeyword.Text + "'";
strsql = "select * from tabcour,tabstu_cour where tabcour.Crid='" + txtKeyword.Text + "'" + "and tabstu_cour.Crid=tabcour.Crid";
}
SqlDataAdapter sqlda = new SqlDataAdapter(strsql, connections);
DataSet datas = new DataSet();
sqlda.Fill(datas);
DataGrid1.DataSource = datas;
DataGrid1.DataBind();
if (DataGrid1.Items.Count == 0)
{
Response.Write("<script language=javascript>alert('未找到指定课程!');</script>");
return;
}
}
protected void btnDisplayAll_Click(object sender, EventArgs e)
{
Bindgrid();
}
protected void lbtnStuInfo_Click(object sender, EventArgs e)
{
Response.Redirect("stu_info.aspx");
}
protected void lbtnRepwd_Click(object sender, EventArgs e)
{
Response.Redirect("repassword.aspx");
}
protected void lbtnCourse_info_Click(object sender, EventArgs e)
{
Response.Redirect("stu_course.aspx");
}
protected void lbtnChoose_Click(object sender, EventArgs e)
{
Response.Redirect("choosecourse.aspx");
}
protected void lbtnGrade_Click(object sender, EventArgs e)
{
Response.Redirect("stu_grade.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -