course.cpp

来自「陕西理工学院计算机系教师信息管理系统的设计与实现」· C++ 代码 · 共 80 行

CPP
80
字号
// Course.cpp: implementation of the CCourse class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "TeacherMIS.h"
#include "Course.h"

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

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

CCourse::CCourse()
{
	m_CourseID="";
	m_Name="";
	m_Period="";
	m_Mark="";
	m_Classroom="";
}

CCourse::~CCourse()
{

}
//添加课程
void CCourse::AddRecord()
{
	CADORecordset* pRs=new CADORecordset(((CTeacherMISApp*)AfxGetApp())->pDB);
	CString strSQL;
	strSQL.Format("select * from tbCourse");
	pRs->Open(strSQL,CADORecordset::openQuery);
	pRs->AddNew();
	pRs->SetFieldValue("CourseID",m_CourseID);
	pRs->SetFieldValue("Name",m_Name);
	pRs->SetFieldValue("Period",m_Period);
	pRs->SetFieldValue("Mark",m_Mark);
	pRs->SetFieldValue("Classroom",m_Classroom);

	pRs->Update();
}

int CCourse::HaveName(CString cCourseName)
{
	CADORecordset* pRs=new CADORecordset(((CTeacherMISApp*)AfxGetApp())->pDB);
	CString strSQL;
	int m;
	strSQL.Format("select * from tbCourse where Name='%s'",cCourseName);
	pRs->Open(strSQL,CADORecordset::openQuery);
	if(pRs->GetRecordCount()==1)
		m=1;
	else m=-1;

	pRs->Close();
	delete pRs;
	return m;
}

int CCourse::HaveID(CString cID)
{
	CADORecordset* pRs=new CADORecordset(((CTeacherMISApp*)AfxGetApp())->pDB);
	CString strSQL;
	int m;
	strSQL.Format("select * from tbCourse where CourseID='%s'",cID);
	pRs->Open(strSQL,CADORecordset::openQuery);
	if(pRs->GetRecordCount()==1)
		m=1;
	else m=-1;

	pRs->Close();
	delete pRs;
	return m;
}

⌨️ 快捷键说明

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