📄 kaoshianpai.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Configuration;
namespace OfficeSys.admin
{
/// <summary>
/// kaoshianpai 的摘要说明。
/// </summary>
public class kaoshianpai : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label11;
protected System.Web.UI.WebControls.DropDownList DropDownList6;
protected System.Web.UI.WebControls.DropDownList DropDownList5;
protected System.Web.UI.WebControls.Label about;
protected System.Web.UI.WebControls.Label Label10;
protected System.Web.UI.WebControls.TextBox kaoshi;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.DropDownList DropDownList2;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.DropDownList DropDownList3;
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.DropDownList DropDownList4;
protected System.Web.UI.WebControls.Label Label6;
protected System.Web.UI.WebControls.Label Label7;
protected System.Web.UI.WebControls.Label Label8;
protected System.Web.UI.WebControls.ListBox studentname;
protected System.Web.UI.WebControls.ListBox xianding;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Button Button3;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox jiaoshiyongna;
protected System.Web.UI.WebControls.Label Label9;
protected System.Web.UI.WebControls.TextBox TextBox4;
protected System.Web.UI.WebControls.Button Button8;
int renshu=0;
int j=0;
SqlCommand com;
int n=0;
int i;
string strConn=ConfigurationSettings.AppSettings ["Connection"];
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(Session["id"]==null)
{
Response.Redirect("../login.aspx");
}
if(!Page.IsPostBack)
{
//DropDownlist1选择班级名称
this.DropDownList1.Items.Add(new ListItem("请选择班级","请选择班级"));
Class.DataProcess sqlSelect=new OfficeSys.Class.DataProcess( );
string sqlStr="select * from 班级信息表";
SqlDataReader reader=sqlSelect.ExecuteReader(sqlStr);
while(reader.Read())
{
this.DropDownList1.Items.Add(new ListItem(reader["班级名"].ToString(),reader["班级号"].ToString()));
}
reader.Close();
this.about.Text="";
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.DropDownList5.SelectedIndexChanged += new System.EventHandler(this.DropDownList5_SelectedIndexChanged);
this.DropDownList1.SelectedIndexChanged += new System.EventHandler(this.DropDownList1_SelectedIndexChanged);
this.DropDownList2.SelectedIndexChanged += new System.EventHandler(this.DropDownList2_SelectedIndexChanged);
this.DropDownList3.SelectedIndexChanged += new System.EventHandler(this.DropDownList3_SelectedIndexChanged);
this.DropDownList4.SelectedIndexChanged += new System.EventHandler(this.DropDownList4_SelectedIndexChanged);
this.Button2.Click += new System.EventHandler(this.Button2_Click);
this.Button3.Click += new System.EventHandler(this.Button3_Click);
this.Button8.Click += new System.EventHandler(this.Button8_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.DropDownList3.Items.Clear();
//DropDownlist3 选择考试时间
Class.DataProcess sqlSel=new OfficeSys.Class.DataProcess();
string sqlstr="select * from 考试时间表 where 考试时间号 not in (select 考试时间号 from 考试表 where 班级号='"+this.DropDownList1.SelectedValue.Trim()+"')";
SqlDataReader readerTime=sqlSel.ExecuteReader(sqlstr);
this.DropDownList3.Items.Add(new ListItem("请选择考试时间","请选择考试时间"));
while(readerTime.Read( ))
{
this.DropDownList3.Items.Add(new ListItem(readerTime["考试时间"].ToString(),readerTime["考试时间号"].ToString()));
}
readerTime.Close();
//DropDownlist2 选择课程名称
this.DropDownList2.Items.Clear();
Class.DataProcess kecheng=new OfficeSys.Class.DataProcess( );
string banji=this.DropDownList1.SelectedValue.Trim().ToString();
string sqlStr="select distinct 科目信息表.科目名,课程表.科目号 from 课程表,科目信息表 where 课程表.科目号=科目信息表.科目号 and 科目信息表.科目号 not in(select distinct 科目号 from 考试表 where 班级号='"+banji+"')";
SqlDataReader reader=kecheng.ExecuteReader(sqlStr);
this.DropDownList2.Items.Add(new ListItem("请选择考试科目","请选择考试科目"));
while(reader.Read())
{
this.DropDownList2.Items.Add(new ListItem(reader["科目名"].ToString(),reader["科目号"].ToString()));
}
reader.Close();
Class.DataProcess renshu=new OfficeSys.Class.DataProcess( );
string select="select 班级人数 from 班级信息表 where 班级号='"+this.DropDownList1.SelectedValue.Trim()+"'";
SqlDataReader read=renshu.ExecuteReader(select);
while(read.Read())
{
this.TextBox1.Text=read["班级人数"].ToString();
}
read.Close();
}
private void DropDownList2_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.studentname.Items.Clear();
string con="select 学生信息表.学生名,学生信息表.学生号 from 学生信息表,课程表 where 课程表.班级号=学生信息表.班级号 and 学生信息表.班级号='"+this.DropDownList1.SelectedValue.Trim()+"'and 课程表.科目号='"+this.DropDownList2.SelectedValue.Trim()+"'";
Class.DataProcess abc=new OfficeSys.Class.DataProcess( );
SqlDataReader Reader=abc.ExecuteReader(con);
while (Reader.Read())
{
this.studentname.Items.Add(new ListItem(Reader["学生名"].ToString(),Reader["学生号"].ToString()));
renshu=renshu+1;
}
this.kaoshi.Text=renshu.ToString();
Reader.Close();
}
private void DropDownList3_SelectedIndexChanged(object sender, System.EventArgs e)
{
string kaoshishijian=this.DropDownList3.SelectedValue.Trim();
//DropDwonlist4 选择教室
this.DropDownList4.Items.Clear();
string sqlStr="select * from 教室信息表 where 教室号 not in (select 教室号 from 考试表 where 考试时间号='"+this.DropDownList3.SelectedValue.Trim()+"')";
Class.DataProcess sqlSelect=new OfficeSys.Class.DataProcess( );
SqlDataReader reader=sqlSelect.ExecuteReader(sqlStr);
this.DropDownList4.Items.Add(new ListItem("请选择空闲教室","请选择空闲教室"));
while(reader.Read())
{
this.DropDownList4.Items.Add(new ListItem(reader["教室名"].ToString(),reader["教室号"].ToString()));
}
//DropDowlist5 选择监考老师
this.DropDownList5.Items.Clear();
this.DropDownList5.Items.Add(new ListItem("请选择监考老师","请选择监考老师1"));
Class.DataProcess Select=new OfficeSys.Class.DataProcess( );
string sql="select * from 教师信息表 where 教师号 not in (select 主考教师 from 考试表 where 班级号!='"+this.DropDownList1.SelectedValue.Trim()+"'and 考试时间号='"+kaoshishijian+"') and 教师号 not in(select 辅考教师 from 考试表 where 班级号!='"+this.DropDownList1.SelectedValue.Trim()+"'and 考试时间号='"+kaoshishijian+"')";
SqlDataReader Reader=Select.ExecuteReader(sql);
while(Reader.Read())
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -