| |
//======================================================================
// By Xuan Sun
// Dec. 22, 99
// File: item_record.cpp
//=======================================================================
#include "item_record.h"
itemRecord::itemRecord()
{
strcpy(id, "");
strcpy(name, "");
strcpy(dir, "");
strcpy(comm, "");
beini=FALSE;
}
itemRecord::~itemRecord()
{
}
bool itemRecord::iniRecord(char* itemId)
{
if(beini!=TRUE) {
strcpy(id, itemId);
strcpy(name, "----------");
strcpy(dir, "----------");
strcpy(comm, "----------");
beini=TRUE;
}
return TRUE;
}
bool itemRecord::setRecord(char* itemId, char* itemName, char* itemDir, char* itemComm)
{
strcpy(id, itemId);
strcpy(name, itemName);
strcpy(dir, itemDir);
strcpy(comm, itemComm);
beini=FALSE;
return TRUE;
}
bool itemRecord::getRecord(char* itemId, char* itemName, char* itemDir, char* itemComm)
{
strcpy(itemId, id);
strcpy(itemName, name);
strcpy(itemDir, dir);
strcpy(itemComm, comm);
return TRUE;
}
void itemRecord::displayRecord(void)
{
printf("ID#: %s\nNAME: %s\nDIRE: %s\nMEMO: %s\n", id, name, dir, comm);
}
void itemRecord::editRecord() {
char command[10];
int i;
printf("COMMANDS FOR EDITING:\n");
do{
printf("\n1 - name\t2 - directory\t3 - comments\t4 - quit\n");
printf("Please enter(1-4): ");
gets(command);
i=atoi(command);
switch (i) {
case 1:
printf("\nOld Name: %s", name);
printf("\nNew Name: ");
gets(name);
printf("\n");
break;
case 2:
printf("\nOld Directory: %s", dir);
printf("\nNew Directory: ");
gets(dir);
printf("\n");
break;
case 3:
printf("\nOld Comments: %s", comm);
printf("\nNew Comments: ");
gets(comm);
printf("\n");
break;
case 4:
printf("\n");
break;
default:
printf("Wrong commands used. Please enter again.\n");
break;
}
} while(i!=4);
beini=FALSE;
}
|
|