?? student.cpp
字號:
// Student.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "console.h"
#include "student.h"
#include "studentui.h"
CStudentUI theUI;
CStudentFile theFile("student.dat");
// 定義命令函數
void DoAddRec(void);
void DoDelRec(void);
void DoListAllRec(void);
void DoFindRec(void);
void main()
{
const int nItemNum = 7;
char *strItem[nItemNum] = { "Add a student data record",
"Delete a student data record",
"-",
"List all data records",
"Find a student data record",
"-",
"Exit" };
theUI._SetOptionsTitle(" Main Menu ");
for (;;) {
int nIndex = theUI._GetOptions(strItem,0,0,nItemNum);
switch(nIndex) {
case 0: // Add a student data record
DoAddRec(); break;
case 1: // Delete a student data record
DoDelRec(); break;
case 2: // List all data records
DoListAllRec(); break;
case 3: // Find a student data record
DoFindRec(); break;
break;
case 4: // Exit
return;
}
}
}
void DoAddRec(void)
{
CStudentRec rec;
if ( theUI.InputStuRec( rec ) ) {
theFile.Add( rec );
DoListAllRec();
}
}
void DoDelRec(void)
{
CStudentRec rec;
char strID[80], str[80]=" No find the record of ";
strcpy(strID, theUI._InputBox( " Input Deleted Student ID ", 0, 0 ));
if (strID) {
int nIndex = theFile.Seek( strID, rec );
if (nIndex>=0) {
theFile.Delete( strID );
DoListAllRec();
} else {
strcat( str, strID );
strcat( str, " !" );
theUI._MessageBox(" Notice ", str, 1 );
}
}
}
void DoListAllRec(void)
{
int nCount = theFile.GetRecCount();
CStudentRec *stu;
stu = new CStudentRec[nCount];
theFile.GetStuRec( stu );
theUI.DispStuRecs( stu, nCount );
delete [nCount]stu;
}
void DoFindRec(void)
{
CStudentRec rec;
char strID[80], str[80]=" No find the record of ";
strcpy(strID, theUI._InputBox( " Input Finded Student ID ", 0, 0 ));
if (strID) {
int nIndex = theFile.Seek( strID, rec );
if (nIndex>=0)
theUI.DispStuRecs( &rec, 1 );
else {
strcat( str, strID );
strcat( str, " !" );
theUI._MessageBox(" Notice ", str, 1 );
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -