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

📄 room.cpp

📁 学生住宿管理系统 本程序用于交流方面,仅共学习交流,用于其他方面 功能欠缺
💻 CPP
字号:
// room.cpp: implementation of the Croom class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Dormitory.h"
#include "room.h"

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

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

Croom::Croom()
{

}

IMPLEMENT_SERIAL(Croom,CObject,1)

void Croom::Serialize(CArchive &ar){
	
	CObject::Serialize( ar );
	if(ar.IsStoring())
		ar<<no<<building<<floor<<bed<<chair<<desk<<remain<<size<<balcony<<toilet<<dept;
	else
		ar>>no>>building>>floor>>bed>>chair>>desk>>remain>>size>>balcony>>toilet>>dept;
		

}//序列化的实

CString Croom:: getField( CString Field )
{   int i;
	if(Field=="no") i=0; 
	if(Field=="floor")     i=1;
	if(Field=="building")      i=2;
    if(Field=="balcony") i=3;
	if(Field=="chair")  i=4;
	if(Field=="desk")  i=5;
	if(Field=="remain")  i=6;
	if(Field=="size")  i=7;
	if(Field=="toilet")  i=8;
	if(Field=="bed")  i=9;
	if(Field=="dept")  i=10;
	
    return getField(i);

 
}
CString Croom:: getField( int i )
{ 
  switch(i){
  case 0: return no; break;
  case 1: return floor; break;
  case 2: return building; break;
  case 3: return  balcony; break;
  case 4: return  chair; break;
  case 5: return  desk; break;
  case 6: return  remain; break;
  case 7: return  size; break;
  case 8: return  toilet; break;
  case 9: return  bed; break;
  case 10: return dept; break;
 
  default: return "NULL";
           
}
}

Cobjectset * Croom::SearchByField( CString Field, CString Value )
{//按一个关键字查询,结果为一个记录集
	Cobjectset *q = NULL;
	Croom *p = (Croom*)getFirstRecord();
	while ( p != NULL ) {
		while ( p != NULL && p->getField( Field ) != Value ) {
			p = (Croom*)getNext();
		}
		if ( !p&&!q ) {
			return NULL;
		}
		else {
			if ( !q ) {
				q = new Cobjectset();
			}
			if(p)
			{q->AddRecord( p );
			p =(Croom*)getNext();}
		}
	}
	return q;
}

void Croom::setField(CString Field,CString Value)
{
	int i;
	if(Field=="no") i=0; 
	if(Field=="floor")     i=1;
	if(Field=="building")      i=2;
	if(Field=="bed")    i=3;
    if(Field=="chair")  i=4;
	if(Field=="desk")  i=5;
	if(Field=="remain")      i=6;
   	if(Field=="size")   i=7;
	if(Field=="balcony")   i=8;
	if(Field=="toilet")   i=9;
	if(Field=="dept")   i=10;
	
    setField( i, Value);
}
void Croom:: setField( int i, CString Value )
{ 
  switch(i){
  case 0: no=Value; break;
  case 1: floor=Value; break;
  case 2: building=Value;; break;
  case 3: bed=Value; break;
  case 4: chair=Value; break;
  case 5: desk=Value; break;
  case 6: remain=Value; break;
  case 7: size=Value; break;
  case 8: balcony=Value; break;
  case 9: toilet=Value; break;
  case 10: dept=Value; break;
  
 
	}
}

⌨️ 快捷键说明

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