1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
CDatabase mydbe;
if( !mydbe.OpenEx( _T( "ODBC;DSN=pointage;UID=Scott;PWD=Tiger" ),
CDatabase::openReadOnly))
{
AfxMessageBox("Impossible d'ouvrir la base de donnée en lecture seule");
return;
}
else
{
CString sqll1;
CString pointagemat;
sqll1="select pointagemat from pointage where cin='";
sqll1+=m_CINL;
sqll1+="'";
re->Open(CRecordset::snapshot, sqll1);
if(re->IsEOF())
{
existe=FALSE;
}
else
{
while(!re->IsEOF())
{
re->GetFieldValue("pointagemat", pointagemat);
CString pmd=pointagemat.Mid(0,10);
if(pmd=td) //td est la date du systéme
existe=TRUE;
}
re->Close();
}
if(existe=TRUE)
AfxMessageBox("le pointage a déja eu lieu");
else
{
CString sqll;
sqll="insert into pointage values('";
sqll+=m_CINL;
sqll+="','";
sqll+=ctime(&t);
sqll+="','0')";
mydbe.ExecuteSQL(sqll);
}
} |
Partager