📄 brushkaidframe.cs
字号:
{
MessageBox.Show(this,elses.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
#endregion
#region 添加刷卡表
private void insertBrushFrame(string userName)
{
// try
// {
// string emp_timeStr=System.DateTime.Now.ToLongTimeString().Trim();
// if(emp_timeStr.Length==7)
// {
// emp_timeStr="0"+System.DateTime.Now.ToLongTimeString().Trim();
// }
// BrushFrameID(userName,emp_timeStr);
// }
// catch(Exception ele)
// {
// MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
// }
}
#endregion
#region dealStr(textname)
private String dealStr(string textname)
{
string strname="";
if(!(textname.Equals("")))
{
strname=textname+"\r\n";
}
return strname;
}
#endregion
#region 连接Access数据库...
private void IntoMonth10()
{
try
{
DataTable accesstable=new DataTable();
accesstable=selectEmp_Time();
int r=selectEmpCount();
string str="";
string username="1001";
for(int i=r-BrushCounts;i<accesstable.Rows.Count;i++)
{
if(Int32.Parse(accesstable.Rows[i][1].ToString().Trim().Substring(0,2))<12)
{
str="am";
try
{
string insertString="insert into month10 (amorpm,username,name,comedate) values('"+str+"','"+username+"','"+accesstable.Rows[i][0].ToString().Trim()+"','"+accesstable.Rows[i][1].ToString().Trim()+"')";
int h=ConnectionAccessDB.ExcuteSql(insertString);
if(h>0)
{
}
else
{
MessageBox.Show("添加失败啦!!!");
}
}
catch(Exception ele)
{
MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
finally
{
// if(this.oleDbConnection.State.Equals(ConnectionState.Open))
// {
// this.oleDbConnection.Close();
// }
}
}
else if(Int32.Parse(accesstable.Rows[i][1].ToString().Trim().Substring(0,2)).Equals(12))
{
str="pm";
try
{
string insertString="insert into month10 (amorpm,username,name,comedate) values('"+str+"','"+username+"','"+accesstable.Rows[i][0].ToString().Trim()+"','"+accesstable.Rows[i][1].ToString().Trim()+"')";
int h=ConnectionAccessDB.ExcuteSql(insertString);
if(h>0)
{
}
else
{
MessageBox.Show("添加失败啦!!!");
}
}
catch(Exception ele)
{
MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
finally
{
// if(this.oleDbConnection.State.Equals(ConnectionState.Open))
// {
// this.oleDbConnection.Close();
// }
}
}
else if(Int32.Parse(accesstable.Rows[i][1].ToString().Trim().Substring(0,2))>12)
{
str="pm";
try
{
string insertString="insert into month10 (amorpm,username,name,comedate) values('"+str+"','"+username+"','"+accesstable.Rows[i][0].ToString().Trim()+"','"+accesstable.Rows[i][1].ToString().Trim()+"')";
int h=ConnectionAccessDB.ExcuteSql(insertString);
if(h>0)
{
}
else
{
MessageBox.Show("添加失败啦!!!");
}
}
catch(Exception ele)
{
MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
finally
{
// if(this.oleDbConnection.State.Equals(ConnectionState.Open))
// {
// this.oleDbConnection.Close();
// }
}
}
}
}
catch(Exception ele)
{
ele.ToString();
}
}
#endregion
#region 退出程序...
private void BrushKaIDFrame_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if(this.axMSComm2.PortOpen.Equals(true))
{
this.axMSComm2.PortOpen=false;
//this.btnOpenPort.Text="关闭端口(&C)";
this.axMSComm2.InBufferCount=0;
this.axMSComm2.OutBufferCount=0;
// this.axMSComm1.Input="";
return;
}
else if(this.axMSComm2.PortOpen.Equals(false))
{
this.axMSComm2.PortOpen=true;
//this.btnOpenPort.Text="打开端口(&O)";
this.axMSComm2.InBufferCount=0;
this.axMSComm2.OutBufferCount=0;
// this.axMSComm1.Output="";
return;
}
//IntoMonth10();
}
#endregion
#region string getUserName()
private String getUserName()
{
string tempStr="";
string sql="select 职工名称,ID号 from Employee";
try
{
DataSet dsSet=new DataSet();
DataTable dsTable=new DataTable();
ConnectionData conn=new ConnectionData();
dsSet=conn.ExcuteDataSetResult(sql,"Employee");
dsTable=dsSet.Tables[0];
for(int i=0;i<dsTable.Rows.Count;i++)
{
if(dsTable.Rows[i][1].ToString().Trim().Equals(this.textTextText.Text.Substring(0,12)))
{
tempStr=dsTable.Rows[i][0].ToString();
this.textBox.ForeColor=Color.Blue;
this.NameText.Text="姓名:"+dsTable.Rows[i][0].ToString().Trim();
string textname=dsTable.Rows[i][0].ToString().Trim();
this.textName.Text=dealStr(textname);
}
else if(!(dsTable.Rows[i][1].ToString().Trim().Equals(this.textTextText.Text.Substring(0,12))))
{
this.textBox.ForeColor=Color.Red;
}
}
}
catch(Exception ele)
{
MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
return tempStr;
}
#endregion
#region DataFunction
private DataTable ExcuteSql(string strSql,string tableName)
{
ConnectionData conn=new ConnectionData();
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 查询Emp_Time
private DataTable selectEmp_Time()
{
DataTable tempEmpTime=new DataTable();
try
{
tempEmpTime=ExcuteSql("select 职工名称,时间,日期 from Emp_Time","Emp_Time");
}
catch(Exception ele)
{
MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
return tempEmpTime;
}
#endregion
#region 查询Emp_Time记录数
private int selectEmpCount()
{
int k=0;
try
{
ConnectionData conn=new ConnectionData();
DataTable temptable=new DataTable();
temptable=ExcuteSql("select count(*) from Emp_Time","Emp_Time");
for(int j=0;j<temptable.Rows.Count;j++)
{
k=Int32.Parse(temptable.Rows[j][0].ToString().Trim());
}
}
catch(Exception ele)
{
ele.ToString();
}
return k;
}
#endregion
#region returnDateTime()
private String returnDateTime()
{
string tempTimeStr="";
try
{
System.DateTime datetime=DateTime.Now;
string format="yyyy-MM-dd";
tempTimeStr=datetime.ToString(format);
}
catch(Exception ele)
{
MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
return tempTimeStr;
}
#endregion
#region BrushIDHistory().....历史记录....
private void BrushIDHistory()
{
try
{
for(int k=BrushCounts-1;k<this.listBox.Items.Count;k++)
{
if(empStr.Equals(""))
{
this.sqlConnection.Open();
this.sqlInsertCommand1.Parameters["@卡号"].Value=this.listBox.Items[k].ToString().Trim();
this.sqlInsertCommand1.Parameters["@职工名称"].Value="null";
this.sqlInsertCommand1.Parameters["@日期"].Value=System.DateTime.Now.ToLongDateString().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="有";
int h=this.sqlInsertCommand1.ExecuteNonQuery();
if(h>0)
{}
else
{
MessageBox.Show(this,"记录失败啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
if(this.sqlConnection.State.Equals(ConnectionState.Open))
{
this.sqlConnection.Close();
}
}
else
{
this.sqlConnection.Open();
this.sqlInsertCommand1.Parameters["@卡号"].Value=this.listBox.Items[k].ToString().Trim();
this.sqlInsertCommand1.Parameters["@职工名称"].Value=empStr.ToString().Trim();
this.sqlInsertCommand1.Parameters["@日期"].Value=System.DateTime.Now.ToLongDateString().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="有";
int h=this.sqlInsertCommand1.ExecuteNonQuery();
if(h>0)
{}
else
{
MessageBox.Show(this,"记录失败啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
if(this.sqlConnection.State.Equals(ConnectionState.Open))
{
this.sqlConnection.Close();
}
}
}
}
catch(Exception ele)
{
MessageBox.Show(this,ele.ToString(),"提示信息",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -