?? userrecordset.cpp
字號:
// UserRecordset.cpp : implementation file
//
#include "stdafx.h"
#include "CheckIn.h"
#include "UserRecordset.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CUserRecordset
IMPLEMENT_DYNAMIC(CUserRecordset, CRecordset)
CUserRecordset::CUserRecordset(CDatabase* pdb)
: CRecordset(pdb)
{
//{{AFX_FIELD_INIT(CUserRecordset)
m_UserName = _T("");
m_Password = _T("");
m_Authority = _T("");
m_nFields = 3;
//}}AFX_FIELD_INIT
m_nDefaultType = dynaset;
}
CString CUserRecordset::GetDefaultConnect()
{
return _T("ODBC;DSN=CheckIn");
}
CString CUserRecordset::GetDefaultSQL()
{
return _T("[tbUser]");
}
void CUserRecordset::DoFieldExchange(CFieldExchange* pFX)
{
//{{AFX_FIELD_MAP(CUserRecordset)
pFX->SetFieldType(CFieldExchange::outputColumn);
RFX_Text(pFX, _T("[UserName]"), m_UserName);
RFX_Text(pFX, _T("[Password]"), m_Password);
RFX_Text(pFX, _T("[Authority]"), m_Authority);
//}}AFX_FIELD_MAP
}
/////////////////////////////////////////////////////////////////////////////
// CUserRecordset diagnostics
#ifdef _DEBUG
void CUserRecordset::AssertValid() const
{
CRecordset::AssertValid();
}
void CUserRecordset::Dump(CDumpContext& dc) const
{
CRecordset::Dump(dc);
}
long CUserRecordset::MyGetRecordCount()
{
long iTmp;
if(!this->IsBOF())
this->MoveFirst();
while(!this->IsEOF ())
{
this->MoveNext ();
}
iTmp = this->GetRecordCount();
return iTmp;
}
#endif //_DEBUG
BOOL CUserRecordset::IsRepeatUser(CString userName)
{
try
{
if(!IsOpen())
Open(CRecordset::dynaset,_T("select * from tbUser where UserName ='"+userName+"'"));
if (!(this->IsBOF()))//表明表中已經存在userName的記錄
return true;
else
return false;
}
catch(CDBException *e)
{
AfxMessageBox(e->m_strError);
return true;
}
}
BOOL CUserRecordset::AddUser(CString userName, CString pass, CString strAuthority)
{
try
{
if(!IsOpen())
Open();
}
catch(CDBException *e)
{
AfxMessageBox(e->m_strError);
return false;
}
try
{
AddNew();
this->m_UserName = userName;
this->m_Password = pass;
this->m_Authority = strAuthority;
Update();
Close();
return true;
}
catch(CDBException *e)
{
AfxMessageBox(e->m_strError);
return false;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -