📄 fingerdlg.cpp
字号:
return 0;
}
}
CCustomRs* CFingerDlg::GetCustom()
{
return &m_rsCustom;
}
void CFingerDlg::OnExit()
{
// TODO: Add your control notification handler code here
CDialog::OnOK();
}
void CFingerDlg::OnOnWork()
{
// TODO: Add your control notification handler code here
int t,v,k,m;
m_idengflag=1;
t=jiancha(1);
if(t==1)
{
v=Takeon(1);
if(v==1)
{
qumo(1);
if(m_pRs->RecordCount!=0)
{
k=pipei();
if(k==1)
{
m=recordcharge(1);
if(m==1)
MessageBox("登陆成功");
else
MessageBox("登陆失败");
}
else
MessageBox("指纹不匹配,可能由于输入图象质量问题,重新输入");
}
else
MessageBox("没有注册");
}
}
}
int CFingerDlg::getWhich()
{
CCustomRs* prs;
prs=GetCustom();
if(zhubiao==1)
{
zhubiao=0;
return 1;
}
if(m_idengflag==1)
{//1
if(prs->m_m_iTime1OnFlag==0)
{//2
dengji=1;
return 1;
}//2
else
{//3
if(prs->m_m_iTime2OnFlag==0)
{//4
if(prs->m_m_iTime1OutFlag==1)
{
dengji=2;
return 2;
}
else
{//5
MessageBox("上一次下班没有登记,请登记下班");
return 3;
}//5
}//4
else
{//6
MessageBox("你的本日上班登记已经完成");
return 3;
}//6
}//3
}//1
/////////////////////////////
if(m_idengflag==2)
{//1
if(prs->m_m_iTime1OutFlag==0)
{//2
if(prs->m_m_iTime1OnFlag==1)
{
dengji=1;
return 1;
}else
{//3
MessageBox("你还没有上班,请登记上班");
return 3;
}//3
}//2
else
{//4
if(prs->m_m_iTime2OutFlag==0)
{//5
if(prs->m_m_iTime2OnFlag==1)
{
dengji=2;
return 2;
}
else
{//6
MessageBox("你还没有上班,请登记上班");
return 3;
}//6
}//5
else
{//7
MessageBox("本日工作已经完成");
return 3;
}//7
}//4
}//1
return 3;
}
void CFingerDlg::OnOutWork()
{
// TODO: Add your control notification handler code here
int t,v,k,m;
m_idengflag=2;
t=jiancha(2);
if(t==1)
{
v=Takeon(2);
if(v==1)
{
qumo(1);
if(m_pRs->RecordCount!=0)
{
k=pipei();
if(k==1)
{
m=recordcharge(2);
if(m==1)
MessageBox("登陆成功");
else
MessageBox("登陆失败");
}
else
MessageBox("指纹不匹配,考虑重新输入");
}
else
MessageBox("没有注册");
}
}
}
int CFingerDlg::jiancha(int type)
{
int t;
CString sFile;
CString SQL;
CFileDialog FileDlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,_T("*.bmp|*.bmp|*.*|*.*|"));
UpdateData(TRUE);
if(m_EmployeeId!="")
{
SQL="Select * from Employee where m_sEmployeeId=";
SQL+="'";
SQL+=m_EmployeeId;
SQL+="'";
t=SetCustom(SQL,type);
if(t==1)
{
if(FileDlg.DoModal()==IDOK)
{
sFile=FileDlg.GetPathName();
IfRead=m_DIBStatic.LoadDib(sFile);
Being=TRUE;
}
else
{
if(IfRead)
m_DIBStatic.UpdateDib();
return 0;
}
m_DIBStatic.UpdateDib();
GiveData();
GiveDatabmp();
ShowBmp();
return 1;
}
else
MessageBox("输入号码出错或者登陆出错");
}
else
MessageBox("请输入您的号码");
return 0;
}
int CFingerDlg::qumo(int type)
{
CString SQL;
SQL="Select * from Fingerprint where m_sFingerId='";
SQL+=m_EmployeeId;
SQL+="'";
setFingerprint(SQL);
getmoend();
return 0;
}
int CFingerDlg::recordcharge(int type)
{
COleDateTime nowtime,motime;
int hours,mins,hour,min;
CCustomRs* prs;
prs=GetCustom();
if(m_idengflag==1)
{
if(dengji==1)
motime=prs->m_m_tTimeBeOn1;
else
motime=prs->m_m_tTimeBeOn2;
nowtime=COleDateTime::GetCurrentTime();
hour=nowtime.GetHour();
min=nowtime.GetMinute();
hours=motime.GetHour();
mins=motime.GetMinute();
if(((hours-hour)*60+(mins-min))<=30&&((hours-hour)*60+(mins-min))>=-15)
{
denglu(m_idengflag,dengji);///////////
return 1;
}
else
{
if(((hours-hour)*60+(mins-min))<-15)
{
denglu(m_idengflag,dengji);/////
sendmessage(1);//1表示迟到了;
return 1;
}
else
{
MessageBox("还不到上班时间");
return 0;
}
}
}
//////////////////////
if(m_idengflag==2)
{
if(dengji==1)
motime=prs->m_m_tTimeBeOut1;
else
motime=prs->m_m_tTimeBeOut2;
nowtime=COleDateTime::GetCurrentTime();
hour=nowtime.GetHour();
min=nowtime.GetMinute();
hours=motime.GetHour();
mins=motime.GetMinute();
if(((hours-hour)*60+(mins-min))<=5)
{
denglu(m_idengflag,dengji);///////////
return 1;
}
else
{
MessageBox("还不到下班时间");
return 0;
}
}
return 0;
}
int CFingerDlg::pipei()
{
int w,m;
CString s,s1;
float linsinnew,lincosnew,linchangnew;
float linsinmo,lincosmo,linchangmo;
int max,tmax;
enddian print[20];
int ceshi[20];
int i,j,v,k;
int ndx,ndy,nx,ny;
int mdx,mdy,mx,my;
float sinn,cosn,changn;
float sinm,cosm,changm;
int chax,chay;
max=0;
for(i=0;i<newendcount;i++)
{
ndx=newenddian[i].dirx;
ndy=newenddian[i].diry;
nx=newenddian[i].x;
ny=newenddian[i].y;
changn=(float)sqrt(ndx*ndx+ndy*ndy);
sinn=ndy/changn;
cosn=ndx/changn;
//////////////////////////
for(j=0;j<moendcount;j++)
{
mx=moenddian[j].x;
my=moenddian[j].y;
mdx=moenddian[j].dirx;
mdy=moenddian[j].diry;
changm=(float)sqrt(mdx*mdx+mdy*mdy);
sinm=mdy/changm;
cosm=mdx/changm;
chax=mx-nx;
chay=my-ny;
for(v=0;v<newendcount;v++)
{
print[v].x=(int)(((newenddian[v].x+chax-mx)*(cosm*cosn+sinn*sinm)-(newenddian[v].y+chay-my)*(cosm*sinn+sinm*cosn)))+(newenddian[v].x+chax);
print[v].y=(int)(((newenddian[v].x+chax-mx)*(cosm*sinn+sinm*cosn)+(newenddian[v].y+chay-my)*(cosm*cosn+sinn*sinm)))+(newenddian[v].x+chax);
print[v].dirx=(int)(newenddian[v].dirx*(cosm*cosn+sinn*sinm)-newenddian[v].diry*(cosm*sinn+sinm*cosn));
print[v].diry=(int)(newenddian[v].diry*(cosm*sinn+sinm*cosn)+newenddian[v].diry*(cosm*cosn+sinn*sinm));
}
for(v=0;v<newendcount;v++)
{
ceshi[v]=0;
if(print[v].x>10&&print[v].x<290&&print[v].y>10&&print[v].y<290)
{
linchangnew=(float)sqrt(print[v].dirx*print[v].dirx+print[v].diry*print[v].diry);
linsinnew=print[v].diry/linchangnew;
lincosnew=print[v].dirx/linchangnew;
for(k=0;k<moendcount;k++)
{
if(abs(moenddian[k].x-print[v].x)<10&&abs(moenddian[k].y-moenddian[v].y)<10)
{
linchangmo=(float)sqrt(moenddian[k].dirx*moenddian[k].dirx+moenddian[k].diry*moenddian[k].diry);
linsinmo=moenddian[k].diry/linchangmo;
lincosmo=moenddian[k].dirx/linchangmo;
if(fabs(linsinmo-linsinnew)<1&&fabs(lincosmo-linsinnew)<1)
ceshi[v]=1;
}
}
}
}
tmax=0;
for(v=0;v<newendcount;v++)
{
if(ceshi[v]==1)
tmax++;
}
if(tmax>max)
{
max=tmax;
zhuendcount=tmax;
m=0;
for(w=0;w<newendcount;w++)
{
if(ceshi[w]==1)
{
zhuenddian[m]=newenddian[w];
m++;
}
}
}
}
}
s.Format("%d",max);
s1=s;
s1+=" ";
s.Format("%d",newendcount);
s1+=s;
s1+=" ";
s.Format("%d",moendcount);
s1+=s;
//MessageBox(s1);
if(max>=(int)(moendcount/3))
return 1;
else
{
zhuendcount=0;
return 0;
}
}
int CFingerDlg::setFingerprint(CString SQL)
{
_variant_t vRecsAffected(0L);
m_strCmdText=_T(SQL);
m_pRs=NULL;
m_piAdoRecordBinding=NULL;
m_com->CommandText=_bstr_t(SQL);
m_pRs.CreateInstance(__uuidof(Recordset));
m_pRs->PutRefActiveConnection(m_con);
m_pRs->Open(_variant_t(SQL),vtMissing,adOpenKeyset,adLockBatchOptimistic, -1);
if(FAILED(m_pRs->QueryInterface(__uuidof(IADORecordBinding),(LPVOID*)&m_piAdoRecordBinding)))
_com_issue_error(E_NOINTERFACE);
m_piAdoRecordBinding->BindToRecordset(&m_rsFinEnd);
if(m_pRs->RecordCount>0)
return 1;
else
return 0;
}
CFingerEnd* CFingerDlg::GetFinger()
{
return &m_rsFinEnd;
}
int CFingerDlg::getmoend()
{
int i;
CFingerEnd* pRs;
pRs=GetFinger();
moendcount=m_pRs->GetRecordCount();
if(moendcount>1)
{
m_pRs->MoveFirst();
for(i=0;i<moendcount;i++)
{
moenddian[i].x=pRs->m_m_iFingerEndXP;
moenddian[i].y=pRs->m_m_iFingerEndYP;
moenddian[i].dirx=pRs->m_m_iFingerEndDirx;
moenddian[i].diry=pRs->m_m_iFingerEndDiry;
m_pRs->MoveNext();
}
}
return 0;
}
//////////////////
int CFingerDlg::deleteconnect()
{
m_pRs->Close();
m_piAdoRecordBinding->Release();
m_pRs=NULL;
CoUninitialize();
return 0;
}
int CFingerDlg::createDB()
{
::CoInitialize(NULL);
m_con.CreateInstance(__uuidof(Connection));
m_con->Open( L"Provider=MSDASQL.1;Data Source=test1", L"", L"", -1 );
m_com.CreateInstance(__uuidof(Command));
m_com->ActiveConnection=m_con;
return 0;
}
int CFingerDlg::newonmo()
{
return 0;
}
void CFingerDlg::OnZhuCe()
{
// TODO: Add your control notification handler code here
CString sFile;
CFileDialog FileDlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,_T("*.bmp|*.bmp|*.*|*.*|"));
CString str;
CString SQL;
int i,t,v,k;
zhubiao=1;
UpdateData(TRUE);
if(m_EmployeeId!="")
{
SQL="Select * from Employee where m_sEmployeeId='";
SQL+=m_EmployeeId;
SQL+="'";
t=SetCustom(SQL,1);
if(t==1)
{
SQL="Select m_sFingerId from Fingerprint where m_sFingerId='";
SQL+=m_EmployeeId;
SQL+="'";
setFingerprint(SQL);
if(m_pRs->RecordCount==0)
{
if(FileDlg.DoModal()==IDOK)
{
sFile=FileDlg.GetPathName();
IfRead=m_DIBStatic.LoadDib(sFile);
Being=TRUE;
m_DIBStatic.UpdateDib();
GiveData();
GiveDatabmp();
ShowBmp();
v=Takeon(1);
if(v==1)
{
moendcount=newendcount;
for(i=0;i<newendcount;i++)
{
moenddian[i]=newenddian[i];
}
if(FileDlg.DoModal()==IDOK)
{
sFile=FileDlg.GetPathName();
IfRead=m_DIBStatic.LoadDib(sFile);
Being=TRUE;
m_DIBStatic.UpdateDib();
GiveData();
GiveDatabmp();
ShowBmp();
v=Takeon(1);
if(v==1)
{
k=pipei();
if(k==1)
{
for(i=0;i<zhuendcount;i++)
{
SQL="Insert into FingerPrint(m_sFingerId,m_iFingerMun,m_iFingerEndXP,m_iFingerEndYP,m_iFingerEndDirx,m_iFingerEndDiry) values('";
SQL+=m_EmployeeId;
SQL+="'";
SQL+=",";
str.Format("%d",i);
SQL+=str;
SQL+=",";
str.Format("%d",zhuenddian[i].x);
SQL+=str;
SQL+=",";
str.Format("%d",zhuenddian[i].y);
SQL+=str;
SQL+=",";
str.Format("%d",zhuenddian[i].dirx);
SQL+=str;
SQL+=",";
str.Format("%d",zhuenddian[i].diry);
SQL+=str;
SQL+=")";
insertfinger(SQL);
}
MessageBox("注册成功");
}
else
MessageBox("注册失败,两幅图象不匹配");
}
else
MessageBox("注册失败");
}
else
MessageBox("注册失败");
}
else
MessageBox("注册失败");
}
else
MessageBox("注册失败");
}
else
MessageBox("已经注册过了");
}
else
MessageBox("没有这个号码");
}
else
MessageBox("没有输入号码");
}
int CFingerDlg::insertfinger(CString sql)
{
_variant_t vRecsAffected(0L);
m_strCmdText=_T(sql);
m_pRs=NULL;
m_piAdoRecordBinding=NULL;
m_com->CommandText=_bstr_t(sql);
m_pRs.CreateInstance(__uuidof(Recordset));
m_pRs->PutRefActiveConnection(m_con);
m_pRs->Open(_variant_t(sql),vtMissing,adOpenKeyset,adLockBatchOptimistic, -1);
return 1;
}
int CFingerDlg::denglu(int type, int position)
{
int t;
CString SQL,s1,st;
if(type==1)
{
if(position==1)
{
s1="m_iTime1OnFlag";
}
else
{
s1="m_iTime2OnFlag";
}
}
if(type==2)
{
if(position==1)
{
s1="m_iTime1OutFlag";
}
else
{
s1="m_iTime2OutFlag";
}
}
SQL="Update Employee set ";
SQL+=s1;
SQL+="=1 where m_sEmployeeId='";
SQL+=m_EmployeeId;
SQL+="'";
t=updatacustom(SQL);
return 0;
}
int CFingerDlg::sendmessage(int type)
{
COleDateTime nowtime;
CString SQL,s,s1;//m_tCountTime,
SQL="Insert into Count(m_tCountTime,m_sCountEmployeeId,m_sCountEmployeeName,m_sCountDepartName,m_sCountType) values(";
nowtime=COleDateTime::GetCurrentTime();
SQL+="'";
s.Format("%d-%d-%d %d:%d:%d",nowtime.GetYear(),nowtime.GetMonth(),nowtime.GetDay(),nowtime.GetHour(),nowtime.GetMinute(),nowtime.GetSecond());
SQL+=s;
SQL+="'";
SQL+=",";
SQL+="'";
SQL+=m_EmployeeId;
SQL+="'";
SQL+=",";
SQL+="'";
SQL+=m_EmployeeName;
SQL+="'";
SQL+=",";
SQL+="'";
SQL+=m_EmployeeDepartName;
SQL+="'";
SQL+=",";
SQL+="'";
if(type==1)
{
s1="迟到";
}
else
if(type==2)
{
s1="临时外出";
}
else
if(type==3)
{
s1="外出返回";
}
else
{
s1="不明";
}
SQL+=s1;
SQL+="'";
SQL+=")";
setcount(SQL);
return 0;
}
int CFingerDlg::setcount(CString SQL)
{
_variant_t vRecsAffected(0L);
m_strCmdText=_T(SQL);
m_pRs=NULL;
m_piAdoRecordBinding=NULL;
m_com->CommandText=_bstr_t(SQL);
m_pRs.CreateInstance(__uuidof(Recordset));
m_pRs->PutRefActiveConnection(m_con);
m_pRs->Open(_variant_t(SQL),vtMissing,adOpenKeyset,adLockBatchOptimistic, -1);
return 1;
}
CCount* CFingerDlg::getcount()
{
return &m_rsCount;
}
int CFingerDlg::updatacustom(CString SQL)
{
_variant_t vRecsAffected(0L);
m_strCmdText=_T(SQL);
m_pRs=NULL;
m_piAdoRecordBinding=NULL;
m_com->CommandText=_bstr_t(SQL);
m_pRs.CreateInstance(__uuidof(Recordset));
m_pRs->PutRefActiveConnection(m_con);
m_pRs->Open(_variant_t(SQL),vtMissing,adOpenKeyset,adLockBatchOptimistic, -1);
return 1;
}
void CFingerDlg::OnGoOut()
{
int t,v,k;
t=jiancha(3);
if(t==1)
{
v=Takeon(1);
if(v==1)
{
qumo(1);
if(m_pRs->RecordCount!=0)
{
k=pipei();
if(k==1)
{
sendmessage(2);
MessageBox("登陆成功");
}
else
MessageBox("登陆失败,可能图象质量问题,重新登陆");
}
else
MessageBox("没有注册");
}
}
}
void CFingerDlg::OnGoBack()
{
// TODO: Add your control notification handler code here
int t,v,k;
t=jiancha(3);
if(t==1)
{
v=Takeon(1);
if(v==1)
{
qumo(1);
if(m_pRs->RecordCount!=0)
{
k=pipei();
if(k==1)
{
sendmessage(3);
MessageBox("登陆成功");
}
else
MessageBox("登陆失败,可能图象质量问题,重新登陆");
}
else
MessageBox("没有注册");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -