📄 form_kjdacxtj.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;
namespace bizdb
{
/// <summary>
/// Form_kjdacxtj 的摘要说明。
/// </summary>
public class Form_kjdacxtj : System.Windows.Forms.Form
{
private System.Windows.Forms.CheckBox chk_kskm;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.DataGrid grd;
private System.Windows.Forms.Button btn_clear;
private System.Windows.Forms.Button bnt_stat;
private System.Windows.Forms.Button btn_query;
private System.Windows.Forms.DateTimePicker dtp_date2;
private System.Windows.Forms.DateTimePicker dtp_date1;
private System.Windows.Forms.Label label19;
private System.Windows.Forms.ComboBox cbo_name;
private System.Windows.Forms.ComboBox cbo_kskm;
private System.Windows.Forms.CheckBox chk_name;
private dbAccess db = new dbAccess();
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form_kjdacxtj()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.chk_name = new System.Windows.Forms.CheckBox();
this.chk_kskm = new System.Windows.Forms.CheckBox();
this.label3 = new System.Windows.Forms.Label();
this.grd = new System.Windows.Forms.DataGrid();
this.btn_clear = new System.Windows.Forms.Button();
this.bnt_stat = new System.Windows.Forms.Button();
this.btn_query = new System.Windows.Forms.Button();
this.dtp_date2 = new System.Windows.Forms.DateTimePicker();
this.dtp_date1 = new System.Windows.Forms.DateTimePicker();
this.label19 = new System.Windows.Forms.Label();
this.cbo_name = new System.Windows.Forms.ComboBox();
this.cbo_kskm = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.grd)).BeginInit();
this.SuspendLayout();
//
// chk_name
//
this.chk_name.Location = new System.Drawing.Point(96, 110);
this.chk_name.Name = "chk_name";
this.chk_name.Size = new System.Drawing.Size(88, 24);
this.chk_name.TabIndex = 31;
this.chk_name.Text = "按学员姓名";
this.chk_name.CheckedChanged += new
System.EventHandler(this.chk_name_CheckedChanged);
//
// chk_kskm
//
this.chk_kskm.Location = new System.Drawing.Point(96, 78);
this.chk_kskm.Name = "chk_kskm";
this.chk_kskm.Size = new System.Drawing.Size(88, 24);
this.chk_kskm.TabIndex = 30;
this.chk_kskm.Text = "按考试科目";
this.chk_kskm.CheckedChanged += new
System.EventHandler(this.chk_kskm_CheckedChanged);
//
// label3
//
this.label3.Location = new System.Drawing.Point(32, 38);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 16);
this.label3.TabIndex = 29;
this.label3.Text = "请选择日期段";
//
// grd
//
this.grd.DataMember = "";
this.grd.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.grd.Location = new System.Drawing.Point(88, 160);
this.grd.Name = "grd";
this.grd.Size = new System.Drawing.Size(696, 296);
this.grd.TabIndex = 28;
//
// btn_clear
//
this.btn_clear.Location = new System.Drawing.Point(560, 104);
this.btn_clear.Name = "btn_clear";
this.btn_clear.Size = new System.Drawing.Size(104, 32);
this.btn_clear.TabIndex = 27;
this.btn_clear.Text = "清空";
this.btn_clear.Click += new
System.EventHandler(this.btn_clear_Click);
//
// bnt_stat
//
this.bnt_stat.Location = new System.Drawing.Point(560, 54);
this.bnt_stat.Name = "bnt_stat";
this.bnt_stat.Size = new System.Drawing.Size(104, 32);
this.bnt_stat.TabIndex = 26;
this.bnt_stat.Text = "生成报表";
//
// btn_query
//
this.btn_query.Location = new System.Drawing.Point(392, 102);
this.btn_query.Name = "btn_query";
this.btn_query.Size = new System.Drawing.Size(104, 32);
this.btn_query.TabIndex = 25;
this.btn_query.Text = "查询";
this.btn_query.Click += new
System.EventHandler(this.btn_query_Click);
//
// dtp_date2
//
this.dtp_date2.Location = new System.Drawing.Point(352, 32);
this.dtp_date2.Name = "dtp_date2";
this.dtp_date2.Size = new System.Drawing.Size(120, 21);
this.dtp_date2.TabIndex = 21;
//
// dtp_date1
//
this.dtp_date1.Location = new System.Drawing.Point(176, 32);
this.dtp_date1.Name = "dtp_date1";
this.dtp_date1.Size = new System.Drawing.Size(120, 21);
this.dtp_date1.TabIndex = 20;
//
// label19
//
this.label19.Location = new System.Drawing.Point(312, 40);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(24, 16);
this.label19.TabIndex = 22;
this.label19.Text = "至";
//
// cbo_name
//
this.cbo_name.Location = new System.Drawing.Point(184, 110);
this.cbo_name.Name = "cbo_name";
this.cbo_name.Size = new System.Drawing.Size(160, 20);
this.cbo_name.TabIndex = 24;
//
// cbo_kskm
//
this.cbo_kskm.Location = new System.Drawing.Point(184, 78);
this.cbo_kskm.Name = "cbo_kskm";
this.cbo_kskm.Size = new System.Drawing.Size(160, 20);
this.cbo_kskm.TabIndex = 23;
this.cbo_kskm.SelectedIndexChanged += new
System.EventHandler(this.cbo_kskm_SelectedIndexChanged);
//
// Form_kjdacxtj
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(792, 573);
this.Controls.Add(this.chk_name);
this.Controls.Add(this.chk_kskm);
this.Controls.Add(this.label3);
this.Controls.Add(this.grd);
this.Controls.Add(this.btn_clear);
this.Controls.Add(this.bnt_stat);
this.Controls.Add(this.btn_query);
this.Controls.Add(this.dtp_date2);
this.Controls.Add(this.dtp_date1);
this.Controls.Add(this.label19);
this.Controls.Add(this.cbo_name);
this.Controls.Add(this.cbo_kskm);
this.Name = "Form_kjdacxtj";
this.Text = "考籍档案查询统计";
this.Load += new System.EventHandler(this.Form_kjdacxtj_Load);
((System.ComponentModel.ISupportInitialize)(this.grd)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void Form_kjdacxtj_Load(object sender, System.EventArgs e)
{
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.ControlBox = false;
cbo_kskm.Enabled=false;
cbo_name.Enabled=false;
}
private void chk_kskm_CheckedChanged(object sender, System.EventArgs e)
{
if(cbo_kskm.Enabled==false)
{
cbo_kskm.Enabled=true;
DataSet ds_kskm=new DataSet();
ds_kskm.Reset();
cbo_kskm.Items.Clear();
//填充数据集
SqlConnection conn=new SqlConnection();
conn.ConnectionString=db.connStr;
SqlCommand cmd_kskm=new SqlCommand("select cou_name from examInfo,Course where examInfo.cou_no=Course.cou_no",conn);
SqlDataAdapter ada_kskm=new SqlDataAdapter(cmd_kskm);
ada_kskm.Fill(ds_kskm,"考试科目");
foreach(DataRow da_kskm in ds_kskm.Tables["考试科目"].Rows)
{
cbo_kskm.Items.Add(da_kskm["cou_name"].ToString());
}
}
else
cbo_kskm.Enabled=false;
}
private void chk_name_CheckedChanged(object sender, System.EventArgs e)
{
DataSet ds_name=new DataSet();
ds_name.Reset();
cbo_name.Items.Clear();
if(chk_name.Checked)
{
cbo_name.Enabled=true;
//填充数据集
SqlConnection conn=new SqlConnection();
conn.ConnectionString=db.connStr;
SqlCommand cmd_name=new SqlCommand("select stu_name from examInfo,Student where examInfo.stu_id=Student.stu_id group by stu_name",conn);
SqlDataAdapter ada_name=new SqlDataAdapter(cmd_name);
ada_name.Fill(ds_name,"学员姓名");
foreach(DataRow da_name in ds_name.Tables["学员姓名"].Rows)
{
cbo_name.Items.Add(da_name["stu_name"].ToString());
}
}
else
{
cbo_name.Enabled=false;
}
}
private void btn_query_Click(object sender, System.EventArgs e)
{
try
{
DataSet ds_cx=new DataSet();
SqlConnection conn=new SqlConnection();
conn.ConnectionString=db.connStr;
SqlCommand cmd_str=new SqlCommand("select exaI_examTime 考试时间,stu_name 学员姓名,exaI_score 考试成绩 from examInfo,Course, Student where examInfo.cou_no=Course.cou_no and examInfo.stu_id=Student.stu_id and exaI_examTime>='"+dtp_date1.Value.Date+"' and exaI_examTime<='"+dtp_date2.Value.Date+"'",conn);
if(chk_kskm.Checked)
{ if(cbo_kskm.Text=="")
{
MessageBox.Show("请选择考试科目");
}
else
{
cmd_str.CommandText="select exaI_examTime 考试时间,stu_name 学员名称,exaI_score 考试成绩 from examInfo,Course,Student where exaI_examTime>='"+dtp_date1.Value.Date+"' and exaI_examTime<='"+dtp_date2.Value.Date+"' and examInfo.cou_no=Course.cou_no and examInfo.stu_id=Student.stu_id and examInfo.stu_id=Student.stu_id and Course.cou_name='"+cbo_kskm.Text+"'";
}
}
if(chk_name.Checked)
{
if(cbo_name.Text=="")
{
MessageBox.Show("请选择学员");
}
else
{
cmd_str.CommandText="select exaI_examTime 考试时间,stu_name 学员名称,exaI_score 考试成绩 from examInfo,Course,Student where exaI_examTime>='"+dtp_date1.Value.Date+"' and exaI_examTime<='"+dtp_date2.Value.Date+"' and examInfo.cou_no=Course.cou_no and examInfo.stu_id=Student.stu_id and Student.stu_name='"+cbo_name.Text+"'";
}
}
SqlDataAdapter ada_cx=new SqlDataAdapter(cmd_str);
ada_cx.Fill(ds_cx,"kscx");
grd.DataSource=ds_cx.Tables["kscx"];
}
catch(System.Exception f)
{
MessageBox.Show(f.Message);
}
//把数据窗口是英文的改成中文的
// DataGridTextBoxColumn stu_name= new DataGridTextBoxColumn();
// stu_name.HeaderText = "学员名称";
// stu_name.MappingName = "stu_name";
//
// DataGridTextBoxColumn exaI_examTime = new DataGridTextBoxColumn();
// exaI_examTime.HeaderText = "考试时间";
// exaI_examTime.MappingName = "exaI_examTime";
}
private void btn_clear_Click(object sender, System.EventArgs e)
{
///清空DataGrid
grd.DataSource=null;
}
private void cbo_kskm_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -