?? studentcreate.cpp
字號:
// StudentCreate.cpp: implementation of the StudentCreate class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Dormitory.h"
#include "StudentCreate.h"
#include "DStudent.h"
#include "student.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
extern CDormitoryApp theApp;
StudentCreate::StudentCreate()
{
}
StudentCreate::~StudentCreate()
{
}
int StudentCreate::input(CString sname,CString sno,CString ssex,CString sdept,CString sclass)//讀入學生基本信息
{
DStudent ds;
if(sname=="")
{
MessageBox(ds,"姓名不能為空!","警告!",MB_OK );
return 0;
}
if(sno=="")
{
MessageBox(ds,"學號不能為空!","警告!",MB_OK);
return 0;
}
if(ssex=="")
{
MessageBox(ds,"性別不能為空!","警告!",MB_OK);
return 0;
}
if(sdept=="")
{
MessageBox(ds,"學院不能為空!","警告!",MB_OK);
return 0;
}
if(sclass=="")
{
MessageBox(ds,"班級不能為空!","警告!",MB_OK);
return 0;
}
name=sname;
no=sno;
sex=ssex;
dept=sdept;
Class=sclass;
return 1;
}
Cstudent *StudentCreate:: create()//根據屬性值創建student對象
{
Cstudent* temp;
temp=(Cstudent*)(((Cstudent*)theApp.vec2)->SearchRecordByField("no",no));
if(temp)
{
AfxMessageBox("該學生的信息已經存在,請重新輸入");
return NULL;
}
Cstudent *student =new Cstudent();
student->name=name;
student->no=no;
student->sex=sex;
student->dept=dept;
student->grade=Class;
theApp.vec2->AddRecord(student);//學生信息保存在學生對象集合vec2中
return student;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -