📄 displaytable.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace PK
{
/// <summary>
/// displayTable 的摘要说明。
/// </summary>
public class displayTable : System.Windows.Forms.UserControl
{
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label c00;
private System.Windows.Forms.Label c01;
private System.Windows.Forms.Label c02;
private System.Windows.Forms.Label c03;
private System.Windows.Forms.Label c04;
private System.Windows.Forms.Label c10;
private System.Windows.Forms.Label c11;
private System.Windows.Forms.Label c12;
private System.Windows.Forms.Label c13;
private System.Windows.Forms.Label c14;
private System.Windows.Forms.Label c20;
private System.Windows.Forms.Label c21;
private System.Windows.Forms.Label c22;
private System.Windows.Forms.Label c23;
private System.Windows.Forms.Label c24;
private string queryContent;
private string theObject;
//private string teacherNo;
public string QueryContent
{
get
{
return queryContent;
}
set
{
theObject = value;
}
}
public string TheObject
{
get
{
return theObject;
}
set
{
theObject = value;
}
}
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public displayTable()
{
// 该调用是 Windows.Forms 窗体设计器所必需的。
InitializeComponent();
// TODO: 在 InitializeComponent 调用后添加任何初始化
}
public displayTable(string queryContent1,string theObject1)
{
// 该调用是 Windows.Forms 窗体设计器所必需的。
InitializeComponent();
this.queryContent = queryContent1;
this.theObject = theObject1;
// TODO: 在 InitializeComponent 调用后添加任何初始化
switch (theObject1)
{
case "teacher":
Connection c = new Connection();
SqlConnection conn = new SqlConnection(c.getConnectionString);
conn.Open();
string str1 = "select * from teacher";
SqlCommand cmd = new SqlCommand(str1,conn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if (queryContent1 == Convert.ToString(dr["teacherNo"]))
{
this.label1.Text = Convert.ToString(dr["teacherName"]);
break;
}
}
this.createTable(this.queryContent,this.theObject);
dr.Close();
conn.Close();
break;
case "class":
this.label1.Text = this.queryContent;
this.createTable(this.queryContent,this.theObject);
break;
case "studyClass":
this.label1.Text = this.queryContent;
this.createTable(this.queryContent,this.theObject);
break;
}
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.c00 = new System.Windows.Forms.Label();
this.c01 = new System.Windows.Forms.Label();
this.c02 = new System.Windows.Forms.Label();
this.c03 = new System.Windows.Forms.Label();
this.c04 = new System.Windows.Forms.Label();
this.c10 = new System.Windows.Forms.Label();
this.c11 = new System.Windows.Forms.Label();
this.c12 = new System.Windows.Forms.Label();
this.c13 = new System.Windows.Forms.Label();
this.c14 = new System.Windows.Forms.Label();
this.c20 = new System.Windows.Forms.Label();
this.c21 = new System.Windows.Forms.Label();
this.c22 = new System.Windows.Forms.Label();
this.c23 = new System.Windows.Forms.Label();
this.c24 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.AllowDrop = true;
this.dataGrid1.AlternatingBackColor = System.Drawing.Color.GhostWhite;
this.dataGrid1.BackColor = System.Drawing.Color.GhostWhite;
this.dataGrid1.BackgroundColor = System.Drawing.Color.Lavender;
this.dataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.dataGrid1.CaptionBackColor = System.Drawing.Color.RoyalBlue;
this.dataGrid1.CaptionForeColor = System.Drawing.Color.White;
this.dataGrid1.DataMember = "";
this.dataGrid1.FlatMode = true;
this.dataGrid1.Font = new System.Drawing.Font("Tahoma", 8F);
this.dataGrid1.ForeColor = System.Drawing.Color.MidnightBlue;
this.dataGrid1.GridLineColor = System.Drawing.Color.RoyalBlue;
this.dataGrid1.HeaderBackColor = System.Drawing.Color.MidnightBlue;
this.dataGrid1.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
this.dataGrid1.HeaderForeColor = System.Drawing.Color.Lavender;
this.dataGrid1.LinkColor = System.Drawing.Color.Teal;
this.dataGrid1.Location = new System.Drawing.Point(56, 56);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ParentRowsBackColor = System.Drawing.Color.Lavender;
this.dataGrid1.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
this.dataGrid1.ReadOnly = true;
this.dataGrid1.SelectionBackColor = System.Drawing.Color.Teal;
this.dataGrid1.SelectionForeColor = System.Drawing.Color.PaleGreen;
this.dataGrid1.Size = new System.Drawing.Size(456, 176);
this.dataGrid1.TabIndex = 0;
//
// label1
//
this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.label1.Location = new System.Drawing.Point(144, 24);
this.label1.Name = "label1";
this.label1.TabIndex = 1;
//
// label2
//
this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label2.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.label2.Location = new System.Drawing.Point(272, 24);
this.label2.Name = "label2";
this.label2.TabIndex = 2;
this.label2.Text = "课程列表";
//
// label3
//
this.label3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label3.ForeColor = System.Drawing.Color.RosyBrown;
this.label3.Location = new System.Drawing.Point(56, 240);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(80, 23);
this.label3.TabIndex = 3;
this.label3.Text = "星期一";
//
// label4
//
this.label4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label4.ForeColor = System.Drawing.Color.RosyBrown;
this.label4.Location = new System.Drawing.Point(152, 240);
this.label4.Name = "label4";
this.label4.TabIndex = 4;
this.label4.Text = "星期二";
//
// label5
//
this.label5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label5.ForeColor = System.Drawing.Color.RosyBrown;
this.label5.Location = new System.Drawing.Point(256, 240);
this.label5.Name = "label5";
this.label5.TabIndex = 5;
this.label5.Text = "星期三";
//
// label6
//
this.label6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label6.ForeColor = System.Drawing.Color.RosyBrown;
this.label6.Location = new System.Drawing.Point(360, 240);
this.label6.Name = "label6";
this.label6.TabIndex = 6;
this.label6.Text = "星期四";
//
// label7
//
this.label7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label7.ForeColor = System.Drawing.Color.RosyBrown;
this.label7.Location = new System.Drawing.Point(464, 240);
this.label7.Name = "label7";
this.label7.TabIndex = 7;
this.label7.Text = "星期五";
//
// label8
//
this.label8.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label8.ForeColor = System.Drawing.Color.RosyBrown;
this.label8.Location = new System.Drawing.Point(8, 280);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(32, 23);
this.label8.TabIndex = 8;
this.label8.Text = "A";
//
// label9
//
this.label9.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label9.ForeColor = System.Drawing.Color.RosyBrown;
this.label9.Location = new System.Drawing.Point(8, 328);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(32, 23);
this.label9.TabIndex = 9;
this.label9.Text = "B";
//
// label10
//
this.label10.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label10.ForeColor = System.Drawing.Color.RosyBrown;
this.label10.Location = new System.Drawing.Point(8, 368);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(32, 23);
this.label10.TabIndex = 10;
this.label10.Text = "C";
//
// c00
//
this.c00.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.c00.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.c00.Location = new System.Drawing.Point(56, 280);
this.c00.Name = "c00";
this.c00.Size = new System.Drawing.Size(72, 23);
this.c00.TabIndex = 11;
//
// c01
//
this.c01.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.c01.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.c01.Location = new System.Drawing.Point(152, 280);
this.c01.Name = "c01";
this.c01.Size = new System.Drawing.Size(80, 23);
this.c01.TabIndex = 12;
//
// c02
//
this.c02.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.c02.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.c02.Location = new System.Drawing.Point(256, 280);
this.c02.Name = "c02";
this.c02.Size = new System.Drawing.Size(80, 23);
this.c02.TabIndex = 13;
//
// c03
//
this.c03.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.c03.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.c03.Location = new System.Drawing.Point(368, 280);
this.c03.Name = "c03";
this.c03.Size = new System.Drawing.Size(80, 23);
this.c03.TabIndex = 14;
//
// c04
//
this.c04.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.c04.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.c04.Location = new System.Drawing.Point(464, 280);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -