📄 cour_choose.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;
using UseDataBase;
public partial class teacher_Cour_choose : System.Web.UI.Page
{
string connectionString = ConfigurationManager.ConnectionStrings["DataBaseConnectionString"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
/*
if (Session["UserID"] == null)
{
Response.Write("<script language=javascript>alert('请先登录');location='Default.aspx'</script>");
}
if (Session["power"] != "1")
{
Response.Write("<script language=javascript>alert('你的权限不够');location='Default.aspx'</script>");
}
*/
}
protected void btnGo_Click(object sender, EventArgs e)
{
cbl.DataSource = null;
cbl.DataSourceID = "srcGetSelectStudent";
if (rab.SelectedValue == "0")
{
srcGetSelectStudent.SelectCommand = "select tabstu_cour.scid,tabstu.sname from tabstu,tabstu_cour, tabCrous where tabCrous.Crname=@Crname and tabCrous.Crid=tabstu_cour.Crid and tabstu_cour.Sid=tabstu.Sid";
srcGetSelectStudent.SelectParameters.Clear();
srcGetSelectStudent.SelectParameters.Add(new ControlParameter("Crname", "txtSQL", "Text"));
}
else
{
Response.Write("<script>alert('对不起,这项查询功能还没有开放!')</script>");
}
srcGetSelectStudent.Select(DataSourceSelectArguments.Empty);
cbl.DataBind();
if (cbl.Items.Count == 0)
{
btnDelete.Visible = false;
Response.Write("<script>alert('对不起,没有符合要求的数据!')</script>");
}
else
btnDelete.Visible = true;
}
protected void btnDelete_Click(object sender, EventArgs e)
{
srcGetSelectStudent.DeleteCommand = "delete from tabstu_cour where Scid=@Scid";
for (int i = 0; i < cbl.Items.Count; i++)
{
if (cbl.Items[i].Selected)
{
srcGetSelectStudent.DeleteParameters.Clear();
Session.Add("Scid", cbl.Items[i].Value);
srcGetSelectStudent.DeleteParameters.Add(new SessionParameter("Scid", "Scid"));
srcGetSelectStudent.Delete();
}
else
continue;
}
cbl.DataSourceID = null;
DataBaseIO db = new DataBaseIO(connectionString);
string selectString = "select tabstu_cour.scid,tabstu.sname from tabstu,tabstu_cour, tabCrous where tabCrous.Crname=@Crname and tabCrous.Crid=tabstu_cour.Crid and tabstu_cour.Sid=tabstu.Sid";
SqlParameter parselectedName = new SqlParameter("@Crname", SqlDbType.VarChar);
parselectedName.Value = txtSQL.Text;
DataSet ds = new DataSet();
ds = db.GetDataSet(selectString, parselectedName);
cbl.DataSource = ds.Tables[0];
cbl.DataBind();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -