📄 brushdatetimeframe.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace WindowsApplication.searchBrushFrameHistory
{
/// <summary>
/// brushDateTimeFrame 的摘要说明。
/// </summary>
public class brushDateTimeFrame : WindowsApplication.ParentFrame
{
#region 控件集合...
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ComboBox textTime;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
#endregion
#region 数据库变量...
private ConnectionData conn=new ConnectionData();
private DataTable tempTable=new DataTable();
private DataTable tempEmpName=new DataTable();
private DataTable tempTime=new DataTable();
#endregion
#region 变量定义...
private string searchSql="select * from Emp_Time";
private string searchDateSql="select distinct 日期 from Emp_Time";
private System.Windows.Forms.ComboBox textDate;
private string searchTimeSql="select distinct 时间 from Emp_Time";
#endregion
#region 构造函数...
public brushDateTimeFrame()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#endregion
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.textDate = new System.Windows.Forms.ComboBox();
this.textTime = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(264, 32);
this.label1.Text = "日期时间查询";
//
// button1
//
this.button1.Location = new System.Drawing.Point(48, 144);
this.button1.Name = "button1";
this.button1.Text = "查询(&S)";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(152, 144);
this.button2.Name = "button2";
//
// label2
//
this.label2.Location = new System.Drawing.Point(24, 56);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(40, 24);
this.label2.Text = "日期:";
//
// textDate
//
this.textDate.Location = new System.Drawing.Point(88, 56);
this.textDate.Name = "textDate";
this.textDate.Size = new System.Drawing.Size(136, 20);
this.textDate.TabIndex = 4;
this.textDate.SelectedIndexChanged += new System.EventHandler(this.textCom_SelectedIndexChanged);
//
// textTime
//
this.textTime.Location = new System.Drawing.Point(88, 96);
this.textTime.Name = "textTime";
this.textTime.Size = new System.Drawing.Size(136, 20);
this.textTime.TabIndex = 5;
this.textTime.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// label3
//
this.label3.Location = new System.Drawing.Point(24, 96);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(40, 23);
this.label3.TabIndex = 6;
this.label3.Text = "时间:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// brushDateTimeFrame
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(258, 183);
this.Controls.Add(this.label3);
this.Controls.Add(this.textTime);
this.Controls.Add(this.textDate);
this.Name = "brushDateTimeFrame";
this.Text = "brushDateTimeFrame";
this.Load += new System.EventHandler(this.brushDateTimeFrame_Load);
this.Controls.SetChildIndex(this.textDate, 0);
this.Controls.SetChildIndex(this.label1, 0);
this.Controls.SetChildIndex(this.button1, 0);
this.Controls.SetChildIndex(this.button2, 0);
this.Controls.SetChildIndex(this.label2, 0);
this.Controls.SetChildIndex(this.textTime, 0);
this.Controls.SetChildIndex(this.label3, 0);
this.ResumeLayout(false);
}
#endregion
#region 日期查询
private void textCom_SelectedIndexChanged(object sender, System.EventArgs e)
{
try
{
}
catch(Exception esl)
{
MessageBox.Show(this,esl.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
#endregion
#region 时间查询
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
try
{
}
catch(Exception esl)
{
MessageBox.Show(this,esl.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
#endregion
#region 初始化事件...
private void brushDateTimeFrame_Load(object sender, System.EventArgs e)
{
try
{
#region 初始化变量...
tempTable=ExcuteSql(searchSql,"Emp_Time");
tempTime=ExcuteSql(searchTimeSql,"Emp_Time");
tempEmpName=ExcuteSql(searchDateSql,"Emp_Time");
#endregion
#region 填充Date下拉表框...
FillDate(tempEmpName);
#endregion
#region 填充Emp_Name下拉表框..
FillTime(tempTime);
#endregion
}
catch(Exception esl)
{
MessageBox.Show(this,esl.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
#endregion
#region 填充Date下拉表框的函数...
private void FillDate(DataTable tempdata)
{
for(int i=0;i<tempdata.Rows.Count;i++)
{
this.textDate.Items.Add(tempdata.Rows[i][0].ToString().Trim());
}
}
#endregion
#region 填充Emp_Name下拉表框..
private void FillTime(DataTable temp)
{
for(int j=0;j<temp.Rows.Count;j++)
{
this.textTime.Items.Add(temp.Rows[j][0].ToString());
}
}
#endregion
#region 查询按钮事件...
private void button1_Click(object sender, System.EventArgs e)
{
try
{
}
catch(Exception esl)
{
MessageBox.Show(this,esl.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
#endregion
#region DataFunction
private DataTable ExcuteSql(string strSql,string tableName)
{
DataSet dsSet=new DataSet();
DataTable dsTable=new DataTable();
try
{
dsSet=conn.ExcuteDataSetResult(strSql,tableName);
dsTable=dsSet.Tables[0];
}
catch(Exception eles)
{
MessageBox.Show(this,eles.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
return dsTable;
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -