📄 monthframe.cs
字号:
this.btnStatictis.Location = new System.Drawing.Point(560, 56);
this.btnStatictis.Name = "btnStatictis";
this.btnStatictis.Size = new System.Drawing.Size(80, 24);
this.btnStatictis.TabIndex = 3;
this.btnStatictis.Text = "查询(&S)";
this.btnStatictis.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.btnStatictis.Click += new System.EventHandler(this.btnStatictis_Click);
this.btnStatictis.MouseEnter += new System.EventHandler(this.btnEmp_Name_MouseEnter);
this.btnStatictis.MouseLeave += new System.EventHandler(this.btnEmp_Name_MouseLeave);
//
// imageList
//
this.imageList.ImageSize = new System.Drawing.Size(16, 16);
this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream")));
this.imageList.TransparentColor = System.Drawing.Color.Transparent;
//
// btnPrint
//
this.btnPrint.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnPrint.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnPrint.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.btnPrint.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
this.btnPrint.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnPrint.ImageIndex = 1;
this.btnPrint.ImageList = this.imageList;
this.btnPrint.Location = new System.Drawing.Point(560, 96);
this.btnPrint.Name = "btnPrint";
this.btnPrint.Size = new System.Drawing.Size(80, 24);
this.btnPrint.TabIndex = 4;
this.btnPrint.Text = "打印(&P)";
this.btnPrint.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);
this.btnPrint.MouseEnter += new System.EventHandler(this.btnEmp_Name_MouseEnter);
this.btnPrint.MouseLeave += new System.EventHandler(this.btnEmp_Name_MouseLeave);
//
// btnExit
//
this.btnExit.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnExit.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnExit.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.btnExit.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
this.btnExit.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnExit.ImageIndex = 2;
this.btnExit.ImageList = this.imageList;
this.btnExit.Location = new System.Drawing.Point(560, 136);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(80, 24);
this.btnExit.TabIndex = 5;
this.btnExit.Text = "退出(&X)";
this.btnExit.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
this.btnExit.MouseEnter += new System.EventHandler(this.btnEmp_Name_MouseEnter);
this.btnExit.MouseLeave += new System.EventHandler(this.btnEmp_Name_MouseLeave);
//
// dataGrid
//
this.dataGrid.AlternatingBackColor = System.Drawing.Color.GhostWhite;
this.dataGrid.BackColor = System.Drawing.Color.GhostWhite;
this.dataGrid.BackgroundColor = System.Drawing.Color.Lavender;
this.dataGrid.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.dataGrid.CaptionBackColor = System.Drawing.Color.RoyalBlue;
this.dataGrid.CaptionForeColor = System.Drawing.Color.White;
this.dataGrid.CaptionVisible = false;
this.dataGrid.DataMember = "";
this.dataGrid.FlatMode = true;
this.dataGrid.Font = new System.Drawing.Font("Tahoma", 8F);
this.dataGrid.ForeColor = System.Drawing.Color.MidnightBlue;
this.dataGrid.GridLineColor = System.Drawing.Color.RoyalBlue;
this.dataGrid.HeaderBackColor = System.Drawing.Color.MidnightBlue;
this.dataGrid.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
this.dataGrid.HeaderForeColor = System.Drawing.Color.Lavender;
this.dataGrid.LinkColor = System.Drawing.Color.Teal;
this.dataGrid.Location = new System.Drawing.Point(0, 176);
this.dataGrid.Name = "dataGrid";
this.dataGrid.ParentRowsBackColor = System.Drawing.Color.Lavender;
this.dataGrid.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
this.dataGrid.ReadOnly = true;
this.dataGrid.SelectionBackColor = System.Drawing.Color.Teal;
this.dataGrid.SelectionForeColor = System.Drawing.Color.PaleGreen;
this.dataGrid.Size = new System.Drawing.Size(664, 216);
this.dataGrid.TabIndex = 6;
//
// statusBar
//
this.statusBar.Cursor = System.Windows.Forms.Cursors.Hand;
this.statusBar.Location = new System.Drawing.Point(0, 391);
this.statusBar.Name = "statusBar";
this.statusBar.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
this.stStatus,
this.stTime,
this.stDate,
this.stuser});
this.statusBar.ShowPanels = true;
this.statusBar.Size = new System.Drawing.Size(658, 32);
this.statusBar.TabIndex = 7;
this.statusBar.Text = "statusBar1";
//
// stStatus
//
this.stStatus.Icon = ((System.Drawing.Icon)(resources.GetObject("stStatus.Icon")));
this.stStatus.Text = "状态:";
this.stStatus.Width = 150;
//
// stTime
//
this.stTime.Icon = ((System.Drawing.Icon)(resources.GetObject("stTime.Icon")));
this.stTime.Text = "时间:";
this.stTime.Width = 150;
//
// stDate
//
this.stDate.Icon = ((System.Drawing.Icon)(resources.GetObject("stDate.Icon")));
this.stDate.Text = "日期:";
this.stDate.Width = 150;
//
// stuser
//
this.stuser.Icon = ((System.Drawing.Icon)(resources.GetObject("stuser.Icon")));
this.stuser.Text = "用户:";
this.stuser.Width = 150;
//
// currentTime
//
this.currentTime.Enabled = true;
this.currentTime.Interval = 1000;
this.currentTime.Tick += new System.EventHandler(this.currentTime_Tick);
//
// sqlDataAdapter
//
this.sqlDataAdapter.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "Month_statictis_Table", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("编号", "编号"),
new System.Data.Common.DataColumnMapping("职工名称", "职工名称"),
new System.Data.Common.DataColumnMapping("统计日期", "统计日期"),
new System.Data.Common.DataColumnMapping("月份", "月份"),
new System.Data.Common.DataColumnMapping("迟到次数", "迟到次数"),
new System.Data.Common.DataColumnMapping("未到次数", "未到次数"),
new System.Data.Common.DataColumnMapping("请假次数", "请假次数"),
new System.Data.Common.DataColumnMapping("备注", "备注")})});
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 编号, 职工名称, 统计日期, 月份, 迟到次数, 未到次数, 请假次数, 备注 FROM Month_statictis_Table WHERE " +
"(月份 LIKE @Param22) AND (职工名称 LIKE @Param21)";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param21", System.Data.SqlDbType.VarChar, 50, "职工名称"));
this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param22", System.Data.SqlDbType.VarChar, 50, "月份"));
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=localhost;integrated security=SSPI;database=SystemODBC";
//
// monthdataTable
//
this.monthdataTable.DataSetName = "MonthdataTable";
this.monthdataTable.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// MonthFrame
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(658, 423);
this.Controls.Add(this.statusBar);
this.Controls.Add(this.dataGrid);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnPrint);
this.Controls.Add(this.btnStatictis);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.titleLabel);
this.Controls.Add(this.groupBox2);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MonthFrame";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "月考勤统计";
this.Load += new System.EventHandler(this.MonthFrame_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.stStatus)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.stTime)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.stDate)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.stuser)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.monthdataTable)).EndInit();
this.ResumeLayout(false);
}
#endregion
#region 初始化事件...
private void MonthFrame_Load(object sender, System.EventArgs e)
{
try
{
sqlDataAdapter.SelectCommand.Parameters[0].Value="%%";
sqlDataAdapter.SelectCommand.Parameters[1].Value="%%";
sqlDataAdapter.Fill(this.monthdataTable);
#region 初始化状态栏
this.stStatus.Text="状态:无";
this.stuser.Text="用户:"+landFrame.strName;
this.stDate.Text="日期:"+System.DateTime.Now.ToLongDateString().Trim();
this.stTime.Text="时间:"+System.DateTime.Now.ToLongTimeString().Trim();
#endregion
#region 填充部门列表框
DataTable tempTable=new DataTable();
tempTable=ExcuteSql("select distinct 部门名称 from Department","Department");
for(int i=0;i<tempTable.Rows.Count;i++)
{
this.department.Items.Add(tempTable.Rows[i][0].ToString().Trim());
}
#endregion
#region 填充员工列表框
DataTable temTable=new DataTable();
temTable=ExcuteSql("select distinct 职工名称 from Employee","Employee");
for(int j=0;j<temTable.Rows.Count;j++)
{
this.emp_Text.Items.Add(temTable.Rows[j][0].ToString().Trim());
}
this.emp_Text.SelectedIndex=0;
#endregion
#region 填充DataGrid表格中
DataTable tempMonthDay=new DataTable();
tempMonthDay=ExcuteSql("select * from Month_statictis_Table","Month_statictis_Table");
this.dataGrid.DataSource=tempMonthDay;
#endregion
#region 初始化当前月份...
int month=System.DateTime.Now.Month;
for(int i=0;i<this.MonthText.Items.Count;i++)
{
if(this.MonthText.Items[i].ToString().Substring(0,2).Trim().Equals(month.ToString()))
{
this.MonthText.SelectedIndex=i;
}
}
#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 btnStatictis_Click(object sender, System.EventArgs e)
{
try
{
sqlDataAdapter.SelectCommand.Parameters[0].Value="%%";
sqlDataAdapter.SelectCommand.Parameters[1].Value="%%";
if(emp_Text.Text!="")
{
sqlDataAdapter.SelectCommand.Parameters[0].Value="%"+emp_Text.Text+"%";
}
if(this.MonthText.Text!="")
{
sqlDataAdapter.SelectCommand.Parameters[1].Value="%"+MonthText.Text+"%";
}
this.monthdataTable.Month_statictis_Table.Clear();
this.sqlDataAdapter.Fill(this.monthdataTable);
this.dataGrid.DataSource=this.monthdataTable.Tables[0];
}
catch(Exception ele)
{
MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
#endregion
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -