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

📄 customer.cpp

📁 简单的考试管理系统程序的数据库是用的ODBC Acess驱动的数据源,使用前要在系统中添加4个系统数据源.下面以添加user数据源为例说明一下添加方法:控制面板-->管理工具-->数据源ODBC选择
💻 CPP
字号:
#include "stdafx.h"
#include "DBuser.h"
#include "Customer.h"


Customer::Customer()
{
	pDB = new CDatabase();
	try{
		if(!pDB->OpenEx("DSN=user"))
			AfxMessageBox("Error,Can't open database");
		pSet = new CDBuser(pDB);
		pSet->Open(CRecordset::dynaset);
	}catch(CException *e){
		e->ReportError();
	}
}
bool Customer::Login(CString user,CString pswd) //用户登录
{
	pSet->MoveFirst();
	do{
		if(pSet->m_ID!=user){
			pSet->MoveNext();
			continue;
		}else if(pSet->m_PSWD==pswd)
			return true;
	}while(!pSet->IsEOF());
	return false;
}

bool Customer::Rigister(			//用户注册
		CString id,
		CString name,
		CString sex,
		CString adress,
		CString email,
		CString pswd)
{
	int Temp;
	Temp=GetMaxNum();
	if(pSet->CanAppend()){
			pSet->AddNew();
			pSet->m_ID = id;
			pSet->m_NAME = name;
			pSet->m_SEX = sex;
			pSet->m_ADRESS = adress;
			pSet->m_EMAIL = email;
			pSet->m_PSWD = pswd;
			pSet->m_NO = Temp+1; 
			pSet->Update();
			return true;
		}else
			return false;
}
int Customer::GetMaxNum()	//获取最大用户数目
{
	int i(0);
	for(pSet->MoveFirst();!pSet->IsEOF();pSet->MoveNext())
		i++;
	return i;	
}	

void Customer::GetInfo()			//获取当前用户信息
{
	m_ID = pSet->m_ID;
	m_NAME = pSet->m_NAME;
	m_SEX = pSet->m_SEX;
	m_ADRESS = pSet->m_ADRESS;
	m_EMAIL = pSet->m_EMAIL;
	m_PSWD = pSet->m_PSWD;
}

bool Customer::UpdateProfile(			//更新用户信息
		CString id,
		CString name,
		CString sex,
		CString adress,
		CString email,
		CString pswd)
{	
	if(pSet->CanUpdate())
	{
		pSet->Edit();
		pSet->m_ID = id;
		pSet->m_ID = id;
		pSet->m_NAME = name;
		pSet->m_SEX = sex;
		pSet->m_ADRESS = adress;
		pSet->m_EMAIL = email;
		pSet->m_PSWD = pswd;
		pSet->Update();
		return true;
	}else
		return false;		
}
CString Customer::TakeExam()
{
	this->GetInfo();
	return this->m_ID;
}

Customer::~Customer()
{

	if(pDB->IsOpen())
		pDB->Close();	
	delete pDB;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -