removeframe.cs
来自「独立完成考勤管理软件加打卡系统(C#) 是打卡加管理系统软件 」· CS 代码 · 共 492 行 · 第 1/2 页
CS
492 行
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(290, 183);
this.Controls.Add(this.label3);
this.Controls.Add(this.empIDCombo);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnHistory);
this.Controls.Add(this.btnDelete);
this.Controls.Add(this.textKaHao);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "RemoveFrame";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "RemoveFrame";
this.Load += new System.EventHandler(this.RemoveFrame_Load);
this.MouseHover += new System.EventHandler(this.RemoveFrame_MouseHover);
this.MouseEnter += new System.EventHandler(this.RemoveFrame_MouseEnter);
this.MouseLeave += new System.EventHandler(this.RemoveFrame_MouseLeave);
((System.ComponentModel.ISupportInitialize)(this.removeBrushID)).EndInit();
this.ResumeLayout(false);
}
#endregion
#region 变量定义...
string searchKaHaoSql="select distinct ID号 from Employee";
string strKaHaoSql=FaKaFrame.strKaHao;
string searchEmployeeID="select distinct 职工名称 from Employee";
#endregion
#region 数据库变量定义...
private ConnectionData conn=new ConnectionData();
private DataSet searchIDSet=new DataSet();
private DataTable searchIDTable =new DataTable();
#endregion
#region 初始化事件....
private void RemoveFrame_Load(object sender, System.EventArgs e)
{
#region 初始化变量
this.textKaHao.Text=FaKaFrame.strKaHao.ToString().Trim();
this.empIDCombo.Focus();
try
{
searchIDSet=conn.ExcuteDataSetResult(searchKaHaoSql,"Employee");
searchIDTable=searchIDSet.Tables[0];
#region 填充下拉表框
DataSet dsSet=new DataSet();
DataTable dsTable=new DataTable();
dsSet=conn.ExcuteDataSetResult(searchEmployeeID,"Employee");
dsTable=dsSet.Tables[0];
for(int k=0;k<dsTable.Rows.Count;k++)
{
empIDCombo.Items.Add(dsTable.Rows[k][0].ToString());
}
#endregion
}
catch(Exception ele)
{
MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
#endregion
}
#endregion
#region 删除卡号的函数
private void RemoveID(DataTable tableKaHao)
{
try
{
if(this.CheckNull())
{
return;
}
string sql="update Employee set ID号 = null where 职工名称='"+this.empIDCombo.Text.ToString().Trim()+"'";
int k=conn.ExcuteStrSql(sql);
if(k>0)
{
string str="删除卡号成功";
BrushIDFrameHistory(str);
MessageBox.Show(this,"移除卡号成功啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
ClearText();
}
else
{
string str="删除卡号失败";
BrushIDFrameHistory(str);
MessageBox.Show(this,"移除卡号失败啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
catch(Exception ese)
{
MessageBox.Show(this,ese.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
#endregion
#region 非空函数
private bool CheckNull()
{
if(this.empIDCombo.Text.Equals(""))
{
MessageBox.Show(this,"职工名称不能为空!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.empIDCombo.Focus();
return true;
}
else if(this.textKaHao.Text.Equals(""))
{
MessageBox.Show(this,"卡号不能为空!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.textKaHao.Focus();
return true;
}
return false;
}
#endregion
#region 清空函数
private void ClearText()
{
this.textKaHao.Text="";
this.empIDCombo.Text="";
}
#endregion
#region 鼠标移动变化...
private void RemoveFrame_MouseLeave(object sender, System.EventArgs e)
{
try
{
// Button buttonCancel=(Button)sender;
// buttonCancel.FlatStyle=FlatStyle.Flat;
// buttonCancel.Font=new Font("宋体",9);
}
catch(Exception ele)
{
MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
private void RemoveFrame_MouseHover(object sender, System.EventArgs e)
{
}
private void RemoveFrame_MouseEnter(object sender, System.EventArgs e)
{
try
{
// Button buttonCancel=(Button)sender;
// buttonCancel.FlatStyle=FlatStyle.Flat;
// buttonCancel.Font=new Font("宋体",9);
}
catch(Exception ele)
{
MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
#endregion
#region 删除卡号事件...
private void btnDelete_Click(object sender, System.EventArgs e)
{
RemoveID(searchIDTable);
}
#endregion
#region 历史记录事件
private void btnHistory_Click(object sender, System.EventArgs e)
{
}
#endregion
#region 职工号改变时事件...
private void empIDCombo_SelectedIndexChanged(object sender, System.EventArgs e)
{
try
{
string sql="select 职工名称, ID号 from Employee";
DataSet dsdata=new DataSet();
DataTable dsdataTable=new DataTable();
dsdata=conn.ExcuteDataSetResult(sql,"Employee");
dsdataTable=dsdata.Tables[0];
for(int j=0;j<dsdataTable.Rows.Count;j++)
{
if(dsdataTable.Rows[j][0].ToString().Trim().Equals(this.empIDCombo.Text.ToString().Trim()))
{
this.textKaHao.Text=dsdataTable.Rows[j][1].ToString().Trim();
}
}
}
catch(Exception eee)
{
MessageBox.Show(this,eee.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
#endregion
#region 数据库处理函数
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 BrushIDFrameHistory(string strStauts)
{
try
{
this.sqlConnection.Open();
this.sqlInsertCommand1.Parameters["@日期"].Value=DateTime.Now.ToString("yyyy-MM-dd").Trim();
this.sqlInsertCommand1.Parameters["@时间"].Value=WindowsApplication.dealTime.dealTime.dealTimeString(System.DateTime.Now.Hour,System.DateTime.Now.Minute,System.DateTime.Now.Second).Trim();
this.sqlInsertCommand1.Parameters["@卡号"].Value=this.textKaHao.Text.ToString().Trim();
this.sqlInsertCommand1.Parameters["@姓名"].Value=this.empIDCombo.Text.ToString().Trim();
this.sqlInsertCommand1.Parameters["@状态"].Value=strStauts;
int j=this.sqlInsertCommand1.ExecuteNonQuery();
if(j>0)
{}
else
{
MessageBox.Show(this,"记录失败!!!","提示作息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
catch(Exception ele)
{
MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
finally
{
if(this.sqlConnection.State.Equals(ConnectionState.Open))
{
this.sqlConnection.Close();
}
}
}
#endregion
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?