📄 leavefreamsearch.cs
字号:
this.sqlInsertCommand1.CommandText = "INSERT INTO Employee_LeaveTable(职工名称, 日期, 请假天数, 请假原因, 请假次数) VALUES (@职工名称, @日期, @" +
"请假天数, @请假原因, @请假次数); SELECT 编号, 职工名称, 日期, 请假天数, 请假原因, 请假次数 FROM Employee_LeaveTa" +
"ble WHERE (编号 = @@IDENTITY)";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
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("@请假天数", 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("@请假次数", System.Data.SqlDbType.VarChar, 50, "请假次数"));
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 编号, 职工名称, 日期, 请假天数, 请假原因, 请假次数 FROM Employee_LeaveTable";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE Employee_LeaveTable SET 职工名称 = @职工名称, 日期 = @日期, 请假天数 = @请假天数, 请假原因 = @请假原因, 请假次数 = @请假次数 WHERE (编号 = @Original_编号) AND (日期 = @Original_日期 OR @Original_日期 IS NULL AND 日期 IS NULL) AND (职工名称 = @Original_职工名称 OR @Original_职工名称 IS NULL AND 职工名称 IS NULL) AND (请假原因 = @Original_请假原因 OR @Original_请假原因 IS NULL AND 请假原因 IS NULL) AND (请假天数 = @Original_请假天数 OR @Original_请假天数 IS NULL AND 请假天数 IS NULL) AND (请假次数 = @Original_请假次数 OR @Original_请假次数 IS NULL AND 请假次数 IS NULL); SELECT 编号, 职工名称, 日期, 请假天数, 请假原因, 请假次数 FROM Employee_LeaveTable WHERE (编号 = @编号)";
this.sqlUpdateCommand1.Connection = this.sqlConnection1;
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("@请假原因", 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("@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("@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, "编号"));
//
// leaveTableSet
//
this.leaveTableSet.DataSetName = "LeaveTableSet";
this.leaveTableSet.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// searchLeaveDataAdapter
//
this.searchLeaveDataAdapter.SelectCommand = this.sqlSelectCommand2;
this.searchLeaveDataAdapter.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "Employee_LeaveTable", 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("请假次数", "请假次数")})});
//
// sqlSelectCommand2
//
this.sqlSelectCommand2.CommandText = "SELECT 编号, 职工名称, 日期, 请假天数, 请假原因, 请假次数 FROM Employee_LeaveTable WHERE (编号 LIKE @Pa" +
"ram4) AND (职工名称 LIKE @Param5) AND (日期 LIKE @Param6)";
this.sqlSelectCommand2.Connection = this.sqlConnection2;
this.sqlSelectCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param4", System.Data.SqlDbType.Int, 4, "编号"));
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, "日期"));
//
// sqlConnection2
//
this.sqlConnection2.ConnectionString = "workstation id=localhost;integrated security=SSPI;database=SystemODBC";
//
// LeaveFreamSearch
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(746, 423);
this.Name = "LeaveFreamSearch";
this.Load += new System.EventHandler(this.LeaveFreamSearch_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.leaveTableSet)).EndInit();
} #endregion
#region Init Event
private void LeaveFreamSearch_Load(object sender, System.EventArgs e)
{
try
{
searchLeaveDataAdapter.SelectCommand.Parameters[0].Value="%%";
searchLeaveDataAdapter.SelectCommand.Parameters[1].Value="%%";
searchLeaveDataAdapter.SelectCommand.Parameters[2].Value="%%";
this.sqlDataAdapter.Fill(leaveTableSet);
base.ds=leaveTableSet;
base.dataAdapter=this.sqlDataAdapter;
base.statusText.Text="今天请假:"+selectCount()+"人";
intLeave=Int32.Parse(selectCount().Trim());
DataTable tempTable=new DataTable();
tempTable=leaveTableSet.Tables[0];
base.dataGrid.DataSource=tempTable;
base.cmOrders=(System.Windows.Forms.CurrencyManager) BindingContext[tempTable];
}
catch(Exception exes)
{
exes.ToString();
}
} #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 selectCount()
private String selectCount()
{
string temp="";
string selectBrushID="select count(*) from Employee_LeaveTable where 日期='"+System.DateTime.Now.ToLongDateString()+"'";
DataTable tempBrushTable=new DataTable();
tempBrushTable=ExcuteSql(selectBrushID,"Emp_Time");
for(int k=0;k<tempBrushTable.Rows.Count;k++)
{
temp=tempBrushTable.Rows[k][0].ToString().Trim();
}
return temp;
}
#endregion
#region 查询事件....
private void btnSearch_Click(object sender, System.EventArgs e)
{
try
{
searchLeaveDataAdapter.SelectCommand.Parameters[0].Value="%%";
searchLeaveDataAdapter.SelectCommand.Parameters[1].Value="%%";
searchLeaveDataAdapter.SelectCommand.Parameters[2].Value="%%";
if(this.textSearchA.Text!="")
{
searchLeaveDataAdapter.SelectCommand.Parameters[0].Value="%"+this.textSearchA.Text+"%";
}
if(this.textSearchB.Text!="")
{
searchLeaveDataAdapter.SelectCommand.Parameters[1].Value="%"+this.textSearchB.Text+"%";
}
if(this.textSearchC.Text!="")
{
searchLeaveDataAdapter.SelectCommand.Parameters[2].Value="%"+this.textSearchC.Text+"%";
}
this.leaveTableSet.Clear();
this.searchLeaveDataAdapter.Fill(this.leaveTableSet);
// base.dataAdapter=this.searchLeaveDataAdapter;
// base.ds=this.leaveTableSet;
base.dataGrid.DataSource=this.leaveTableSet.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 + -