⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userrecordset.cpp

📁 一个简单的公司人员考勤系统的源代码,我已经编译运行过
💻 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 + -