📄 leavesearchframe.cs
字号:
#region 命名空间...
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using WindowsApplication.LeaveFrameStatistic;
using WindowsApplication.EmployeeLeaveManager;
#endregion
namespace WindowsApplication
{
public class LeaveSearchFrame : System.Windows.Forms.Form
{
#region 控件...
protected System.Windows.Forms.Label label1;
protected System.Windows.Forms.GroupBox groupBox2;
protected System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.ComboBox resultText;
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.CheckBox cheMorming;
private System.Windows.Forms.CheckBox cheMiddle;
private System.Windows.Forms.CheckBox cheNight;
private System.Windows.Forms.ComboBox searchText;
private System.Windows.Forms.Button btnHistory;
private System.Windows.Forms.DateTimePicker startDateTime;
private System.Windows.Forms.DateTimePicker EndDateTime;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
#endregion
#region 构造函数...
public LeaveSearchFrame()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#endregion
#region 数据变量...
private ConnectionData conn=new ConnectionData();
public static DataTable leaveTable=new DataTable();
private DataTable searchTable=new DataTable();
#endregion
#region 变量...
private string sqlSearch="select * from Employee_UnCome";
public static string strSex="";
public static string strDate="";
#endregion
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(LeaveSearchFrame));
this.label1 = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.EndDateTime = new System.Windows.Forms.DateTimePicker();
this.startDateTime = new System.Windows.Forms.DateTimePicker();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.cheNight = new System.Windows.Forms.CheckBox();
this.cheMiddle = new System.Windows.Forms.CheckBox();
this.cheMorming = new System.Windows.Forms.CheckBox();
this.label2 = new System.Windows.Forms.Label();
this.resultText = new System.Windows.Forms.ComboBox();
this.label5 = new System.Windows.Forms.Label();
this.btnOk = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.searchText = new System.Windows.Forms.ComboBox();
this.btnHistory = new System.Windows.Forms.Button();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(432, 32);
this.label1.TabIndex = 0;
this.label1.Text = "请假查询";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.EndDateTime);
this.groupBox2.Controls.Add(this.startDateTime);
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Location = new System.Drawing.Point(0, 32);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(248, 112);
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "统计时间";
//
// EndDateTime
//
this.EndDateTime.Location = new System.Drawing.Point(112, 72);
this.EndDateTime.Name = "EndDateTime";
this.EndDateTime.Size = new System.Drawing.Size(117, 21);
this.EndDateTime.TabIndex = 7;
//
// startDateTime
//
this.startDateTime.Location = new System.Drawing.Point(112, 32);
this.startDateTime.Name = "startDateTime";
this.startDateTime.Size = new System.Drawing.Size(117, 21);
this.startDateTime.TabIndex = 6;
//
// label4
//
this.label4.Location = new System.Drawing.Point(24, 72);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(80, 23);
this.label4.TabIndex = 5;
this.label4.Text = "结束日期:";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.Location = new System.Drawing.Point(24, 32);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(80, 23);
this.label3.TabIndex = 4;
this.label3.Text = "起始日期:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.cheNight);
this.groupBox3.Controls.Add(this.cheMiddle);
this.groupBox3.Controls.Add(this.cheMorming);
this.groupBox3.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.groupBox3.Location = new System.Drawing.Point(256, 32);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(160, 192);
this.groupBox3.TabIndex = 2;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "统计数据(&S)";
//
// cheNight
//
this.cheNight.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.cheNight.Location = new System.Drawing.Point(32, 136);
this.cheNight.Name = "cheNight";
this.cheNight.TabIndex = 2;
this.cheNight.Text = "晚上";
this.cheNight.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// cheMiddle
//
this.cheMiddle.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.cheMiddle.Location = new System.Drawing.Point(32, 88);
this.cheMiddle.Name = "cheMiddle";
this.cheMiddle.TabIndex = 1;
this.cheMiddle.Text = "中午";
this.cheMiddle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// cheMorming
//
this.cheMorming.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.cheMorming.Location = new System.Drawing.Point(32, 40);
this.cheMorming.Name = "cheMorming";
this.cheMorming.TabIndex = 0;
this.cheMorming.Text = "早上";
this.cheMorming.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 160);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(80, 23);
this.label2.TabIndex = 8;
this.label2.Text = "查询:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// resultText
//
this.resultText.DropDownStyle = System.Windows.Forms.ComboBoxStyle.Simple;
this.resultText.Items.AddRange(new object[] {
"日期",
"时间",
"姓名"});
this.resultText.Location = new System.Drawing.Point(96, 200);
this.resultText.Name = "resultText";
this.resultText.Size = new System.Drawing.Size(120, 20);
this.resultText.TabIndex = 11;
this.resultText.SelectedIndexChanged += new System.EventHandler(this.resultText_SelectedIndexChanged);
this.resultText.MouseEnter += new System.EventHandler(this.resultText_MouseEnter);
this.resultText.MouseLeave += new System.EventHandler(this.resultText_MouseLeave);
//
// label5
//
this.label5.Location = new System.Drawing.Point(8, 200);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(80, 23);
this.label5.TabIndex = 10;
this.label5.Text = "结果:";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// btnOk
//
this.btnOk.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnOk.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnOk.Location = new System.Drawing.Point(128, 240);
this.btnOk.Name = "btnOk";
this.btnOk.TabIndex = 12;
this.btnOk.Text = "确定";
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCancel.Location = new System.Drawing.Point(336, 240);
this.btnCancel.Name = "btnCancel";
this.btnCancel.TabIndex = 13;
this.btnCancel.Text = "取消";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// searchText
//
this.searchText.DropDownStyle = System.Windows.Forms.ComboBoxStyle.Simple;
this.searchText.Items.AddRange(new object[] {
"当天",
"本周",
"上周"});
this.searchText.Location = new System.Drawing.Point(96, 160);
this.searchText.Name = "searchText";
this.searchText.Size = new System.Drawing.Size(120, 20);
this.searchText.TabIndex = 14;
this.searchText.SelectedIndexChanged += new System.EventHandler(this.searchText_SelectedIndexChanged);
this.searchText.MouseEnter += new System.EventHandler(this.resultText_MouseEnter);
this.searchText.MouseLeave += new System.EventHandler(this.resultText_MouseLeave);
//
// btnHistory
//
this.btnHistory.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnHistory.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnHistory.Location = new System.Drawing.Point(232, 240);
this.btnHistory.Name = "btnHistory";
this.btnHistory.TabIndex = 15;
this.btnHistory.Text = "记录";
this.btnHistory.Click += new System.EventHandler(this.btnHistory_Click);
//
// LeaveSearchFrame
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.White;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(426, 279);
this.Controls.Add(this.btnHistory);
this.Controls.Add(this.searchText);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOk);
this.Controls.Add(this.resultText);
this.Controls.Add(this.label5);
this.Controls.Add(this.label1);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.label2);
this.Cursor = System.Windows.Forms.Cursors.Hand;
this.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "LeaveSearchFrame";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "LeaveSearchFrame";
this.Load += new System.EventHandler(this.LeaveSearchFrame_Load);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
#region 初始化程序...
private void LeaveSearchFrame_Load(object sender, System.EventArgs e)
{
try
{
#region 初始化控件变量...
int hour=System.DateTime.Now.Hour;
if(hour>=8 && hour<=11)
{
this.cheMorming.Checked=true;
}
else if(hour>=12 && hour<=15)
{
this.cheMiddle.Checked=true;
}
else if(hour>18 && hour<=23)
{
this.cheNight.Checked=true;
}
#endregion
#region 初始化 searchText控件为本周
this.searchText.SelectedIndex=1;
#endregion
#region 初始化 resultText 为 日期
this.resultText.SelectedIndex=0;
#endregion
#region 初始化数据表...
searchTable=ExcuteSql(sqlSearch,"Employee_UnCome");
leaveTable=searchTable;
#endregion
}
catch(Exception ele)
{
MessageBox.Show(this,ele.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
#region 确定事件...
private void btnOk_Click(object sender, System.EventArgs e)
{
#region 统计窗体...
WindowsApplication.LeaveFrameStatistic.LeaveFrameStatistic log=new WindowsApplication.LeaveFrameStatistic.LeaveFrameStatistic();
MessageBox.Show(this,"请假统计","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
Dispose();
log.ShowDialog();
#endregion
#region
#endregion
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -