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

📄 subject.cpp

📁 课程设计的简单Access学生数据库系统
💻 CPP
字号:
// Subject.cpp: implementation of the Subject class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "SM.h"
#include "Subject.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

//##ModelId=40A481F20261
Subject::Subject()
{
	Set(0, "", 0);
}

//##ModelId=40A481F20262
Subject::~Subject()
{

}

//##ModelId=40A481F20243
void Subject::AddNew(CDaoRecordset *RS)
{
	RS->AddNew();
	RS->SetFieldValue("subject", LPCSTR(Title));
	RS->SetFieldValue("credit_hour", COleVariant(Credit));
	RS->Update();
	RS->MoveLast();
	ID = RS->GetFieldValue("ID").lVal;
}

//##ModelId=40A481F20235
void Subject::Update(CDaoRecordset *RS)
{
	RS->SetCurrentIndex("ID");
	if(RS->Seek("=", &COleVariant(ID)))
	{
		RS->Edit();
		RS->SetFieldValue("subject", LPCSTR(Title));
		RS->SetFieldValue("credit_hour", COleVariant(Credit));
		RS->Update();
	}
}

//##ModelId=40A481F20233
void Subject::Delete(CDaoRecordset *RS)
{
	RS->SetCurrentIndex("ID");
	if(RS->Seek("=", &COleVariant(ID)))
		RS->Delete();
}

//##ModelId=40A481F20226
void Subject::Load(CDaoRecordset *RS)
{
	RS->SetCurrentIndex("ID");
	if(RS->Seek("=", &COleVariant(ID)))
	{
		Title = V_BSTRT(&RS->GetFieldValue(_T("subject")));
		Credit = RS->GetFieldValue(_T("credit_hour")).lVal;
	}
}

//##ModelId=40A481F20222
inline void Subject::Set(long id, CString subject, long credit_hour)
{
	ID = id, Title = subject, Credit = credit_hour;
}

//##ModelId=40A481F20213
Subject::Subject(long id, CString subject, long credit_hour)
{
	Set(id, subject, credit_hour);
}

⌨️ 快捷键说明

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