return 1;
else
return 0;
}
int CContr::IsBgn()
{
if (current_record->IsBgn)
return 1;
else
return 0;
}
void CContr::print ()
{
current_record->print();
}
CRecord& CRecord::NewData (char *surname, char *name, char *patronymic,
char *post, int lengthofservice, int rateofpay)
{
record.NewData (surname,name,patronymic,post,lengthofservice,rateofpay);
return *this;
}
Display::Display()
{
OutData();
}
void Display::mask()
{
cout << ">\n\n\nSurname Name Patronimyc Post LengthOfService RateOfPay" << endl;
gotoxy (1,24);
cout << "1-print 2-AddNRecord 3-DeleteNRecord 4-Sort 5-Save 6-Restor 7-DelAll" << endl;
cout << "8-Insert 9-Edit q-exit";
gotoxy (1,6);
}
void Display::OutData ()
{
clrscr();
mask ();
MoveBgn ();
while ( (!IsEnd()) && (!Record().IsBgn))
{
print();
MoveNext();
}
MoveNext();
gotoxy (2,1);
}
void CContr::DelNRecord (int n_field)
{
MoveBgn();
n_field--;
while (!IsEnd() && n_field)
{
MoveNext();
n_field--;
}
if (!IsEnd())
DelCur();
if (!IsBgn())
MoveBgn();
}
int CContr::IsEmpty()
{
if (head_record->next->IsEnd)
return 1;
return 0;
}
CRecord CContr::Record ()
{
return (*current_record);
}
void Display::AddNRecord()
{
CRecord new_record;
MoveEnd();
AddTempl(new_record);
AddRecord (new_record);
MoveBgn();
}
void CContr::DelAll ()
{
MoveBgn();
while ( (!IsEnd()) && (!Record().IsBgn))
{
DelCur();
}
MoveBgn ();
}
void CContr::Insert (int index)/
{
if (Move (index))
{
CRecord *new_record = new CRecord;
CRecord current (*current_record);
AddTempl (*new_record);
// AddRecord (new_record);
current_record->next = new_record;
new_record->pred = current_record;
new_record->next = current.next;
current.next->pred = new_record;
}
else
{
gotoxy (1,2);
cout << "ERROR! Press Any Key";
getch ();
}
}
int CContr::Move (int index)//переміщення по базіданних
{
if (index < 0)
return 0;
if (head_record->next == last_record)
return 0;
if (!index)
return 1;
MoveBgn();
index--;
while ( (!IsEnd()) && (!IsBgn()) && index)
{
MoveNext ();
index--;
}
if (index)
{
MoveBgn();
return 0;
}
return 1;
}
void CContr::AddTempl(CRecord &new_record)//додання поля
{
int y (wherey () + 1);
cout << '\n';
cin >> new_record.record.CS_Surname;
gotoxy (11,y);
cin >> new_record.record.CS_Name;
gotoxy (19,y);
cin >> new_record.record.CS_Patronymic;
gotoxy (31,y);
cin >> new_record.record.CS_Post;
gotoxy (41,y);
cin >> new_record.record.i_LengthOfService;
gotoxy (58,y);
cin >> new_record.record.i_RateOfPay;
gotoxy (67,y);
}
void CContr::Edit (int index)//редагування поля структури
{
if (Move(index))
{
CRecord new_value;
AddTempl (new_value);
current_record->record = new_value.record;
}
else
{
gotoxy (1,2);
cout << "ERROR! Press Any Key";
getch ();
}
}
void WDisk::Save ()//зберігання файла на диск
{
FILE *file = fopen(File_Name,"w");
if (file)
{
MoveBgn();
while (!IsEnd())
{
fprintf (file,"%s\n",current_record->record.CS_Surname.c_str());
fprintf (file,"%s\n",current_record->record.CS_Name.c_str());
fprintf (file,"%s\n",current_record->record.CS_Patronymic.c_str());
fprintf (file,"%s\n",current_record->record.CS_Post.c_str());
fprintf (file,"%d\n",current_record->record.i_LengthOfService);
fprintf (file,"%d\n",current_record->record.i_RateOfPay);
MoveNext();
}
}else
{
cout << "Can't create new file";
}
MoveBgn();
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.