База данных пилотов Формулы 1
Реферат - Компьютеры, программирование
Другие рефераты по предмету Компьютеры, программирование
,text,10);
SetWindowText(edit_pouls, text);
itoa(app.racers[0].blaps,text,10);
SetWindowText(edit_blaps, text);
itoa(app.racers[0].races,text,10);
SetWindowText(edit_races, text);
SetWindowText(edit_frace,app.racers[0].frace.c_str());
itoa(number,text,10);
SetWindowText(text_number,text);
}
else MessageBox(hwnd,"Error: Can not open file. File do not exist or damage!","Error!",NULL);
};
return 0;
case IDM_FILESAVEAS:
if(app.racers.size()==0)
{
MessageBox(hwnd,"Ups! You can not save empty data base! Ai-ai-ai!!!","Ups!",0);
return 0;
};
number--;
// Сохраняем элемент
GetWindowText(edit_blaps,text,20);
app.racers[number].blaps = atoi((const char *)text);
GetWindowText(edit_famely,text,20);
app.racers[number].famely = (string) text;
GetWindowText(edit_frace,text,20);
app.racers[number].frace = (string) text;
GetWindowText(edit_name,text,20);
app.racers[number].name = (string) text;
GetWindowText(edit_pouls,text,20);
app.racers[number].pouls = atoi((const char *)text);
GetWindowText(edit_races,text,20);
app.racers[number].races = atoi((const char *)text);
GetWindowText(edit_tituls,text,20);
app.racers[number].tituls = atoi((const char *)text);
GetWindowText(edit_wons,text,20);
app.racers[number].wons = atoi((const char *)text);
number++;
//Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = \0;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "Schnaider Yuri data base\0*.bd\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetSaveFileName(&ofn)==TRUE) // Reading
{
if(!app.db_save((const char *) ofn.lpstrFile))
MessageBox(hwnd,"Error! Can not save data base!","Save error!",NULL);
};
return 0;
// Удаляем элемент
case IDM_DELETE:
if(app.racers.size()<1)
{
MessageBox(hwnd,"Error! Can not delete empty data base!","Delete error!",NULL);
return 0;
};
app.db_delete_item(number-1); // Удаляем
SetWindowText(edit_famely, (char*)app.racers[0].famely.c_str());
SetWindowText(edit_name, (char*)app.racers[0].name.c_str());
itoa(app.racers[0].tituls,text,10);
SetWindowText(edit_tituls, text);
itoa(app.racers[0].wons,text,10);
SetWindowText(edit_wons, text);
itoa(app.racers[0].pouls,text,10);
SetWindowText(edit_pouls, text);
itoa(app.racers[0].blaps,text,10);
SetWindowText(edit_blaps, text);
itoa(app.racers[0].races,text,10);
SetWindowText(edit_races, text);
SetWindowText(edit_frace,app.racers[0].frace.c_str());
number=1;
itoa(number,text,10);
SetWindowText(text_number,text);
return 0;
// Добавляем элемент
case IDM_ADD:
if(app.racers.size()<1)
{
MessageBox(hwnd,"Auch! Can not add element in empty data base!","Khm. Little error...",NULL);
};
app.db_add_item();
return 0;
case IDM_SORT_NAME:
if(app.racers.size()<1)
{
MessageBox(hwnd,"Sorry, but data base is empty.","! Nothung for sort",NULL);
return 0;
};
app.bd_sortby(2);
draw_sort();
return 0;
case IDM_SORT_FAMELY:
if(app.racers.size()<1)
{
MessageBox(hwnd,"Sorry, but data base is empty.","! Nothung for sort",NULL);
return 0;
};
app.bd_sortby(1);
draw_sort();
return 0;
case IDM_SORT_TITULS:
if(app.racers.size()<1)
{
MessageBox(hwnd,"Sorry, but data base is empty.","! Nothung for sort",NULL);
return 0;
};
app.bd_sortby(7);
draw_sort();
return 0;
case IDM_SORT_WONS:
if(app.racers.size()<1)
{
MessageBox(hwnd,"Sorry, but data base is empty.","! Nothung for sort",NULL);
return 0;
};
app.bd_sortby(4);
draw_sort();
return 0;
case IDM_SORT_POULS:
if(app.racers.size()<1)
{
MessageBox(hwnd,"Sorry, but data base is empty.","! Nothung for sort",NULL);
return 0;
};
app.bd_sortby(5);
draw_sort();
return 0;
case IDM_SORT_BLAPS:
if(app.racers.size()<1)
{
MessageBox(hwnd,"Sorry, but data base is empty.","! Nothung for sort",NULL);
return 0;
};
app.bd_sortby(8);
draw_sort();
return 0;
case IDM_SORT_RACES:
if(app.racers.size()<1)
{
MessageBox(hwnd,"Sorry, but data base is empty.","! Nothung for sort",NULL);
return 0;
};
app.bd_sortby(3);
draw_sort();
return 0;
case IDM_SORT_FRACE:
if(app.racers.size()<1)
{
MessageBox(hwnd,"Sorry, but data base is empty.","! Nothung for sort",NULL);
return 0;
};
app.bd_sortby(6);
draw_sort();
return 0;
case IDM_FIND_FAMELY :
GetWindowText(edit_find,text,20);
SetWindowText(edit_find, "");
for(i=0;i<app.racers.size();i++)
if(app.racers[i].famely==(string)text) draw_find(i,app.racers[i].famely);
return 0;
case IDM_FIND_NAME :
GetWindowText(edit_find,text,20);
SetWindowText(edit_find, "");
for(i=0;i<app.racers.size();i++)
if(app.racers[i].name==(string)text) draw_find(i,app.racers[i].famely);
return 0;
case IDM_FIND_FRACE :
GetWindowText(edit_find,text,20);
SetWindowText(edit_find, "");
for(i=0;i<app.racers.size();i++)
if(app.racers[i].frace==(string)text) draw_find(i,app.racers[i].famely);
return 0;
case IDM_FIND_TITULS:
char text2[10];
GetWindowText(edit_find,text,20);
SetWindowText(edit_find, "");
for(i=0;i<app.racers.size();i++)
if( (string) itoa(app.racers[i].tituls,text2,10)==(string) text) draw_find(i,app.racers[i].famely);
return 0;
case IDM_FIND_WONS:
GetWindowText(edit_find,text,20);
SetWindowText(edit_find, "");
for(i=0;i<app.racers.size();i++)
if( (string) itoa(app.racers[i].wons,text2,10)==(string) text) draw_find(i,app.racers[i].famely);
return 0;
case IDM_FIND_POULS:
GetWindowText(edit_find,text,20);
SetWindowText(edit_find, "");
for(i=0;i<app.racers.size();i++)
if( (string) itoa(app.racers[i].pouls,text2,10)==(string) text) draw_find(i,app.racers[i].famely);
return 0;
case IDM_FIND_BLAPS:
GetWindowText(edit_find,text,20);
SetWindowText(edit_find, "");
for(i=0;i<app.racers.size();i++)
if( (string) itoa(app.racers[i].blaps,text2,10)==(string) text) draw_find(i,app.racers[i].famely);
return 0;
case IDM_FIND_RACES:
GetWindowText(edit_find,text,20);
SetWindowText(edit_find, "");
for(i=0;i<app.racers.size();i++)
if( (string) itoa(app.racers[i].races,text2,10)==(string) text) draw_find(i,app.racers[i].famely);
return 0;
case IDM_HELPABOUT:
MessageBox(hwnd,"Kursovaya. 3 semestr.","About",0);
default:
return 0;
};
default:
return DefWindowProc(hwnd, iMsg, wParam, lParam);
}
}
return 0;
}
"main.h"
#ifndef MAIN_H
#define MAIN_H
#define ID_MENU 501
#define IDM_FILENEW 200
#define IDM_FILEOPEN 201
#define IDM_FILESAVEAS 203
#define IDM_FILEEXIT 207
#define IDM_ADD 210
#define IDM_DELETE 211
#define IDM_SORT_NAME300
#define IDM_SORT_FAMELY301
#define IDM_SORT_TITULS302
#define IDM_SORT_WONS303
#defi