📄 fakaframe.cs
字号:
}
#endregion
#region 确定事件...
private void btnOk_Click(object sender, System.EventArgs e)
{
#region 发卡程序段...
try
{
bool f=false;
if(this.checkNull().Equals(true))
{
return;
}
// else if(this.CheckIsNotKaHaoAndEmpName().Equals(true))
// {
// //如果存在卡号和职工名称都存在情况如下...
// return;
// }
else if(this.CheckIsNoKaHao().Equals(true))
{
//如果只存在卡号的情况如下....
f=true;
return;
}
else if(this.checkIsNotEmp_ID_AND_EmpName().Equals(true))
{
//如果存在职工号和职工名称如下情况...
InsertCMOS_ChipSql="update Employee set ID号='"+this.textFaHao.Text+"'where 职工号='"+this.empIDFa.Text+"'";
int j=conn.ExcuteStrSql(InsertCMOS_ChipSql);
MessageBox.Show(this.textFaName.Text.ToString());
if(j>0)
{
MessageBox.Show(this,"发卡成功!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
string str="成功";
this.textFaHao.Text=AddOne();
BrushIDFrameHistory(str);
ClearText();
}
else
{
MessageBox.Show(this,"发卡失败!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
string str="失败";
BrushIDFrameHistory(str);
}
return;
}
else
{
//如果存在职工号的话该如何处理啊....
// if (this.CheckEmployeeID().Equals(true))
// {
// return;
// }
InsertCMOS_ChipSql="Insert Into Employee(职工号,ID号,职工名称) values ('"+this.empIDFa.Text.ToString()+"','"+this.textFaHao.Text.ToString()+"','"+this.textFaName.Text.ToString()+"')";
int k=conn.ExcuteStrSql(InsertCMOS_ChipSql);
if(k>0)
{
MessageBox.Show(this,"发卡成功!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
string str="成功";
BrushIDFrameHistory(str);
ClearText();
}
else
{
if(f.Equals(true))
{
MessageBox.Show(this,"发卡失败!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
string str="失败";
BrushIDFrameHistory(str);
return;
}
string strQ="失败";
BrushIDFrameHistory(strQ);
MessageBox.Show(this,"发卡失败!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
return;
}
}
catch(Exception ele)
{
MessageBox.Show(ele.ToString());
}
#endregion
}
#endregion
#region 清空函数
private void ClearText()
{
this.empIDFa.Text="";
this.textFaHao.Text="";
this.textFaName.Text="";
this.empIDBu.Text="";
this.textBuHao.Text="";
this.textBuName.Text="";
}
#endregion
#region 取消事件...
private void btnCancel_Click(object sender, System.EventArgs e)
{
DialogResult result=MessageBox.Show(this,"是否关闭此窗体啊!!!","提示信息",MessageBoxButtons.YesNo,MessageBoxIcon.Information);
if(result.Equals(DialogResult.Yes))
{
Close();
}
else
{
return;
}
}
#endregion
#region 函数事件...
private bool CheckEnable(bool f)
{
return false;
}
#endregion
#region 检查是否为空
private bool checkNull()
{
if(this.textFaHao.Text.Equals(""))
{
MessageBox.Show(this,"卡号不能为空!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.textFaHao.Focus();
return true;
}
else if(this.empIDFa.Text.Equals(""))
{
MessageBox.Show(this,"职工号不能为空!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.empIDFa.Focus();
return true;
}
else if(this.textFaName.Text.Equals(""))
{
MessageBox.Show(this,"姓名不能为空!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.textFaName.Focus();
return true;
}
else
{
try
{
string selectEmployeeSql="select 卡号 from Employee";
DataSet searchEmployeeSet=new DataSet();
DataTable searchEmployeeTable=new DataTable();
searchEmployeeSet=conn.ExcuteDataSetResult(selectEmployeeSql,"Employee");
searchEmployeeTable=searchEmployeeSet.Tables[0];
for(int i=0;i<searchEmployeeTable.Rows.Count;i++)
{
if(searchEmployeeTable.Rows[i][0].ToString().Equals(this.empIDFa.Text.ToString()))
{
MessageBox.Show(this,"已经存在了此号码!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.empIDFa.Focus();
return true;
}
}
}
catch(Exception elsere)
{
elsere.ToString();
}
}
return false;
}
#endregion
#region 如果存在卡号和姓名都存在应该怎么处理情况...
private bool CheckIsNotKaHaoAndEmpName()
{
try
{
string selectEmployeeSql="select ID号,职工名称 from Employee";
DataSet searchEmployeeSet=new DataSet();
DataTable searchEmployeeTable=new DataTable();
searchEmployeeSet=conn.ExcuteDataSetResult(selectEmployeeSql,"Employee");
searchEmployeeTable=searchEmployeeSet.Tables[0];
for(int i=0;i<searchEmployeeTable.Rows.Count;i++)
{
if(searchEmployeeTable.Rows[i][0].ToString().Equals(this.textFaHao.Text.ToString()) && searchEmployeeTable.Rows[i][1].ToString().Equals(this.textFaName.Text.ToString()))
{
MessageBox.Show(this,"此卡号已经存在啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
ClearText();
return true;
}
}
}
catch(Exception ese)
{
MessageBox.Show(this,ese.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
return false;
}
#endregion
#region 如果存在卡号该怎么办情况....
private bool CheckIsNoKaHao()
{
try
{
string selectEmployeeSql="select distinct ID号 from Employee";
DataSet searchEmployeeSet=new DataSet();
DataTable searchEmployeeTable=new DataTable();
searchEmployeeSet=conn.ExcuteDataSetResult(selectEmployeeSql,"Employee");
searchEmployeeTable=searchEmployeeSet.Tables[0];
for(int i=0;i<searchEmployeeTable.Rows.Count;i++)
{
if(searchEmployeeTable.Rows[i][0].ToString().Equals(this.textFaHao.Text.ToString()))
{
MessageBox.Show(this,"此卡号已经存在啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
ClearText();
return true;
}
}
}
catch(Exception exze)
{
MessageBox.Show(this,exze.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
return false;
}
#endregion
#region 如果存在职工号和职工名称的情况...
private bool checkIsNotEmp_ID_AND_EmpName()
{
try
{
string selectEmployeeSql="select 职工号,职工名称 from Employee";
DataSet searchEmployeeSet=new DataSet();
DataTable searchEmployeeTable=new DataTable();
searchEmployeeSet=conn.ExcuteDataSetResult(selectEmployeeSql,"Employee");
searchEmployeeTable=searchEmployeeSet.Tables[0];
for(int i=0;i<searchEmployeeTable.Rows.Count;i++)
{
if(searchEmployeeTable.Rows[i][0].ToString().Equals(this.empIDFa.Text.ToString()) && searchEmployeeTable.Rows[i][1].ToString().Equals(this.textFaName.Text.ToString()))
{
// this.textFaName.Text=searchEmployeeTable.Rows[i][1].ToString();
MessageBox.Show(this,"此职工号已经存在啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
//ClearText();
return true;
}
}
}
catch(Exception exze)
{
MessageBox.Show(this,exze.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
return false;
}
#endregion
#region 查询职工号是否存
private bool CheckEmployeeID()
{
try
{
string selectEmployeeID="select distinct 职工号 from Employee";
DataSet searchEmployeeIDSet=new DataSet();
DataTable searchEmployeeIDTable=new DataTable();
searchEmployeeIDSet=conn.ExcuteDataSetResult(selectEmployeeID,"Employee");
searchEmployeeIDTable=searchEmployeeIDSet.Tables[0];
for(int i=0;i<searchEmployeeIDTable.Rows.Count;i++)
{
if(searchEmployeeIDTable.Rows[i][0].ToString().Trim().Equals(this.empIDFa.Text.ToString().Trim()))
{
MessageBox.Show(this,"此职工号已经存在啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
return true;
}
MessageBox.Show(this,"数据库中没有此号码,可以进行添加数据号码啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
catch(Exception elses)
{
MessageBox.Show(this,elses.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
return false;
}
#endregion
#region 方法事件...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -