4,011
社区成员
发帖
与我相关
我的任务
分享
try
{
_bstr_t sql = "select * from LogInfo where userName='"+LogDlg.m_Name+"' ";
pRecordset->Open(sql,pConn.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
}
catch(_com_error e)
{
AfxMessageBox(e.Description());
}
if (pRecordset->GetadoEOF())
{
AfxMessageBox("没有可用账户");
return 0;
}
passwordInSql = pRecordset->GetCollect("password");
TypeInSql = pRecordset->GetCollect("levelType");
pRecordset->Close();
if ( (LogDlg.m_Password != (LPCTSTR)(_bstr_t)passwordInSql))
{
AfxMessageBox("用户名或密码错误!");
return FALSE;
}
//登陆
void CODBC_View::OnLogIN()
{
UpdateData(TRUE);
int n=0;
m_pSet->MoveFirst();
do
{
if((m_pSet->m_column5==m_num)&&(m_pSet->m_column6==m_pass)) //信息都正确
{
n=1;
break;
}
else if((m_pSet->m_column5==m_num)&&(m_pSet->m_column6!=m_pass)) //存在用户,密码错误
{
n=2;
break; /* */
}
else
{
m_pSet->MoveNext(); //没有此用户
n=3;
}
}while(!m_pSet->IsEOF());
// MessageBox(m_pSet->m_column5);
// MessageBox(m_pSet->m_column6);
if(n==1) //信息都正确
{
MessageBox("成功登陆!","提示:",MB_OK);
Stuinfodlg.avgscore=m_pSet->m_column9;
Stuinfodlg.ch_score=m_pSet->m_column4;
Stuinfodlg.eng_score=m_pSet->m_column2;
Stuinfodlg.math_score=m_pSet->m_column3;
Stuinfodlg.name=m_pSet->m_column7;
Stuinfodlg.num=m_pSet->m_column5;
Stuinfodlg.pass=m_pSet->m_column6;
Stuinfodlg.pro=m_pSet->m_column8;
UpdateData(FALSE);
if(Stuinfodlg.DoModal()==(-1))
{
MessageBox("出错了!","ERROR!",MB_ICONSTOP|MB_OK);
}
}
if(n==2) //密码错误
{
MessageBox("密码错误!\n请确认密码!","提示:",MB_ICONSTOP|MB_OK);
//m_num="";
m_pass="";
UpdateData(FALSE);
}
else if(n==3) //没有此用户
{
MessageBox("没有此用户!\n请重新输入账户!","提示:",MB_ICONSTOP|MB_OK);
m_num="";
m_pass="";
UpdateData(FALSE); /* */
}
else if(n==0)
{
MessageBox("登陆错误!","提示:",MB_ICONSTOP|MB_OK);
}
UpdateData(FALSE);
}