📄 emp_latemanager.cs
字号:
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@职工名称", System.Data.SqlDbType.VarChar, 50, "职工名称"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@状态", System.Data.SqlDbType.VarChar, 50, "状态"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param1", System.Data.SqlDbType.VarChar, 50, "上/下"));
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 编号, 日期, 职工名称, 状态, [上/下] FROM Employee_Late";
this.sqlSelectCommand1.Connection = this.sqlConnection;
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE Employee_Late SET 日期 = @日期, 职工名称 = @职工名称, 状态 = @状态, [上/下] = @Param2 WHERE (编号 = @Original_编号) AND ([上/下] = @Original_上_下 OR @Original_上_下 IS NULL AND [上/下] IS NULL) AND (日期 = @Original_日期) AND (状态 = @Original_状态 OR @Original_状态 IS NULL AND 状态 IS NULL) AND (职工名称 = @Original_职工名称 OR @Original_职工名称 IS NULL AND 职工名称 IS NULL); SELECT 编号, 日期, 职工名称, 状态, [上/下] FROM Employee_Late WHERE (编号 = @编号)";
this.sqlUpdateCommand1.Connection = this.sqlConnection;
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@日期", System.Data.SqlDbType.VarChar, 50, "日期"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@职工名称", System.Data.SqlDbType.VarChar, 50, "职工名称"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@状态", System.Data.SqlDbType.VarChar, 50, "状态"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param2", System.Data.SqlDbType.VarChar, 50, "上/下"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_编号", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "编号", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_上_下", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "上/下", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_日期", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "日期", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_状态", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "状态", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_职工名称", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "职工名称", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@编号", System.Data.SqlDbType.Int, 4, "编号"));
//
// employee_LateSet
//
this.employee_LateSet.DataSetName = "Employee_LateSet";
this.employee_LateSet.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// dataLateSet
//
this.dataLateSet.DataSetName = "DataLateSet";
this.dataLateSet.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// searchLate
//
this.searchLate.SelectCommand = this.sqlSelectCommand2;
this.searchLate.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "Employee_Late", 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("状态", "状态")})});
//
// sqlSearchLateConnection
//
this.sqlSearchLateConnection.ConnectionString = "workstation id=localhost;integrated security=SSPI;database=SystemODBC";
//
// sqlSelectCommand2
//
this.sqlSelectCommand2.CommandText = "SELECT 编号, 日期, [上/下], 职工名称, 状态 FROM Employee_Late WHERE (日期 LIKE @Param4) AND ([上" +
"/下] LIKE @Param5) AND (职工名称 LIKE @Param6)";
this.sqlSelectCommand2.Connection = this.sqlSearchLateConnection;
this.sqlSelectCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param4", System.Data.SqlDbType.VarChar, 50, "日期"));
this.sqlSelectCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param5", System.Data.SqlDbType.VarChar, 50, "上/下"));
this.sqlSelectCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param6", System.Data.SqlDbType.VarChar, 50, "职工名称"));
//
// Emp_LateManager
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(746, 423);
this.Name = "Emp_LateManager";
this.Text = "Emp_LateManager";
this.Load += new System.EventHandler(this.Emp_LateManager_Load);
((System.ComponentModel.ISupportInitialize)(this.statusZhuangTai)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataGrid)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.ds)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusText)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.employee_LateSet)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataLateSet)).EndInit();
this.ResumeLayout(false);
} #endregion #region 初始化事件...
private void Emp_LateManager_Load(object sender, System.EventArgs e)
{
#region 初始化...
#region 初始化 searchLate....
this.searchLate.SelectCommand.Parameters[0].Value="%%";
this.searchLate.SelectCommand.Parameters[1].Value="%%";
this.searchLate.SelectCommand.Parameters[2].Value="%%";
#endregion
this.searchLate.Fill(dataLateSet);
this.sqlDataAdapter.Fill(dataLateSet);
tempTable=dataLateSet.Tables[0];
base.ds=dataLateSet;
base.dataAdapter=this.sqlDataAdapter;
base.dataTable=tempTable;
base.dataGrid.DataSource=tempTable;
base.cmOrders=(System.Windows.Forms.CurrencyManager) BindingContext[tempTable];
base.stringDateStr="日期:"+System.DateTime.Now.ToLongDateString().Trim();
base.stringStautsStr="状态:无";
base.stringTimeStr="时间:"+System.DateTime.Now.ToLongTimeString().Trim();
base.stringUserStr="操作员:"+landFrame.strName;
#endregion
#region 迟到人数
DataTable temTable=new DataTable();
temTable=selectlatecount();
for(int i=0;i<temTable.Rows.Count;i++)
{
base.statusText.Text="今天迟到人数:"+temTable.Rows[i][0].ToString();
//MessageBox.Show(base.statusMax.Text);
intLate=Int32.Parse(temTable.Rows[i][0].ToString());
}
#endregion
} #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 DataTable selectlatecount() { DataTable data=new DataTable(); try { string selectStautsSql="select count(状态)状态 from Employee_Late where 状态='迟到'and 日期 ='"+System.DateTime.Now.ToLongDateString().Trim()+"'"; data=ExcuteSql(selectStautsSql,"Employee_Late"); } catch(Exception ele) { MessageBox.Show(this,ele.ToString()," 提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information); } return data; } #endregion
#region 查询事件....
private void btnSearch_Click(object sender, System.EventArgs e)
{
try
{
this.searchLate.SelectCommand.Parameters[0].Value="%%";
this.searchLate.SelectCommand.Parameters[1].Value="%%";
this.searchLate.SelectCommand.Parameters[2].Value="%%";
if(this.textSearchA.Text!="")
{
this.searchLate.SelectCommand.Parameters[0].Value="%"+this.textSearchA.Text+"%";
}
if(this.textSearchB.Text!="")
{
this.searchLate.SelectCommand.Parameters[1].Value="%"+this.textSearchB.Text+"%";
}
if(this.textSearchC.Text!="")
{
this.searchLate.SelectCommand.Parameters[2].Value="%"+this.textSearchC.Text+"%";
}
this.dataLateSet.Employee_Late.Clear();
this.searchLate.Fill(dataLateSet);
// base.dataAdapter=this.searchLate;
base.dataGrid.DataSource=dataLateSet.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 + -