êóðñîâûå,êîíòðîëüíûå,äèïëîìû,ðåôåðàòû
Ðîññèéñêèé Íîâûé Óíèâåðñèòåò
Ïîÿñíèòåëüíàÿ çàïèñêà
ê êóðñîâîé ðàáîòå
ïî ïðåäìåòó «Ïðîãðàììèðîâàíèå»
íà òåìó:
«Áàçà äàííûõ ïèëîòîâ Ôîðìóëû 1».
Âûïîëíèë ñòóäåíò ãð. 424
Ôàêóëüòåòà ÈÑ è ÊÒ
Øíàéäåð Þðèé Þðüåâè÷
Ðóêîâîäèòåëü: Ìàñëÿíêèí Â.È.
Êóðñîâàÿ ðàáîòà äîïóùåíà ê çàùèòå:
______________________
Ìîñêâà
2006 ã.
Ñîäåðæàíèå:
1. Ââåäåíèå. Öåëè è çàäà÷è êóðñîâîé ðàáîòû.
2. Îïèñàíèå ïðåäìåòíîé îáëàñòè.
2.1. Ïîñòàíîâêà çàäà÷è
2.2. Îáúåêòû ïðåäìåòíîé îáëàñòè.
2.3. Íåîáõîäèìûå ðåñóðñû.
3. Ðàçðàáîòêà ïðîåêòà.
3.1. Êëàññû: ñâîéñòâà è ìåòîäû.
3.2. Îðãàíèçàöèÿ êëàññîâ.
3.3. Èíòåðôåéñ ïîëüçîâàòåëÿ.
4. Ðåàëèçàöèÿ ïðîåêòà.
5. Ïåðñïåêòèâû äîðàáîòêè ïðîãðàììû.
1. Ââåäåíèå. Öåëè è çàäà÷è êóðñîâîé ðàáîòû.
Ýòà ïðîãðàììà íàïèñàíà äëÿ ëþáèòåëåé ãîíîê "ôîðìóëà 1". Èñïîëüçóÿ å¸, ïîëüçîâàòåëè ìîãóò íàéòè ðàçëè÷íóþ èíôîðìàöèþ î ïèëîòå, òàêóþ êàê êîëè÷åñòâî òèòóëîâ, ïîáåä, è ò.ï. Áàçà äàííûõ ïîçâîëÿåò óäàëÿòü ïèëîòîâ è äîáàâëÿòü íîâûõ, à òàêæå íàéòè ïèëîòà ïî îïðåäåë¸ííîìó ïàðàìåòðó.
2. Îïèñàíèå ïðåäìåòíîé îáëàñòè.
2.1. Ïîñòàíîâêà çàäà÷è.
Îñíîâíûå ôóíêöèè ïðîãðàììû:
1. çàïîìèíàòü ââîäèìûå çíà÷åíèÿ, ïîêàçûâàòü áàçó äàííûõ;
2. äîáàâëÿòü, ðåäàêòèðîâàòü äàííûå;
3. îñóùåñòâëÿòü ïîèñê â áàçå;
4. ñîðòèðîâàòü äàííûå áàçû ïî çàïðàøèâàåìîìó ïàðàìåòðó;
5. óäàëÿòü è ñîõðàíÿòü èçìåíåíèÿ â áàçå;
6. ñîõðàíÿòü âñþ èíôîðìàöèþ, à òàêæå èìåòü äîñòóï ê îòêðûòèþ èíôîðìàöèè.
2.2. Îáúåêòû ïðåäìåòíîé îáëàñòè.
Îáúåêòû ïðèíàäëåæàùèå, õðàíåíèþ è îáðàáîòêå:
struct Racer
{
string famely;
string name;
string frace;
int races;
int wons;
int pouls;
int tituls;
int blaps;
};
«famely»: ôàìèëèÿ ãîíùèêà. Òåêñòîâîå çíà÷åíèå.
«name»: Èìÿ ãîíùèêà. Òåêñòîâîå çíà÷åíèå.
«frace»: Äåáþòíàÿ ãîíêà â ôîðìóëå 1. Òåêñòîâîå çíà÷åíèå.
«races»: Êîëè÷åñòâî ïðîâåä¸ííûõ ãîíîê. Öèôðîâîå çíà÷åíèå.
«wons»: Êîëè÷åñòâî ïîáåä. Öèôðîâîå çíà÷åíèå.
«pouls»: Êîëè÷åñòâî ïîóë-ïîçèöèé (ïåðâîå ìåñòî íà ñòàðòå). Öèôðîâîå çíà÷åíèå.
«tituls»: Êîëè÷åñòâî òèòóëîâ ÷åìïèîíà ìèðà. Öèôðîâîå çíà÷åíèå.
«blaps»: Êîëè÷åñòâî Ëó÷øèõ êðóãîâ â ãîíêå. Öèôðîâîå çíà÷åíèå.
2.3. Íåîáõîäèìûå ðåñóðñû.
Äëÿ ðåàëèçàöèè ïðîåêòà íåîáõîäèìî ïîäêëþ÷åíèå ñëåäóþùèõ çàãîëîâî÷íûõ ôàéëîâ:
Òàê-æå, íåîáõîäèìû ñëåäóþùèå windows - áèáëèîòåêè: “comctl32.lib” è “comdlg.lib”
3. Ðàçðàáîòêà ïðîåêòà.
3.1. Êëàññû: ïîëÿ è ìåòîäû.
Êëàññ ÿâëÿåòñÿ àáñòðàêòíûì òèïîì äàííûõ, îïðåäåëÿåìûì ïîëüçîâàòåëåì, è ïðåäñòàâëÿåò ñîáîé ìîäåëü ðåàëüíîãî îáúåêòà â âèäå äàííûõ è ôóíêöèé äëÿ ðàáîòû ñ íèìè.
Ïðîãðàììà ðàçáèòà íà 2-à êëàññà. 1-ûé îòâå÷àåò çà áàçó äàííûõ, 2-îé çà âçàèìîäåéñòâèÿ ñ íèì.
Ðàññìîòðèì 1-ûé êëàññ:
class Reader
{
public:
Reader(); // Êîíñòðóêòîð / äåñòðóêîòîð
~Reader();
bool open_db(const char * file); // Îòêðûòü áä
bool
save_db(const char * file,vector
void close_db(); // Çàêðûòü áä
bool read(); // ×èòàòü ÁÄ
void new_paragraph(); // Íîâûé ïàðàãðàô
string paragraph; // Èìÿ ïàðàãðàôà
int loadAsInt(string name); // Çàãðóæàåì ïàðàìåòð êàê öåëîå ÷èñëî
string loadAsString(string name); // Çàãðóæàåì ïàðàìåòð êàê ñòðîêó
private:
fstream db; // Ôàèë áä
};
Ðàññìîòðèì 2-îé êëàññ:
class Application
{
public:
Application();
~Application();
bool db_load(const char *file); // Çàãðóæàåì áàçó äàííûõ
void db_close(); // Çàêðûâàåì áàçó äàííûõ
bool db_save(const char *file); // Ñîõðàíÿåì áàçó äàííûõ
void db_add_item(); // Äîáàâëÿåì íîâûé ýëåìåíò
void db_delete_item(int number); // Óäàëÿåì îïðåäåë¸ííûé ýëåìåíò
void bd_sortby(int value); // Ñîðòèðîâêà
vector
private:
Reader reader; // Ôàéëîâûé ìåíåäæåð
};
3.2. Îðãàíèçàöèÿ êëàññîâ
Âûáðàííûé êîíòåéíåð äëÿ õðàíåíèÿ îáúåêòîâ ñòàíäàðòíûé “vector” èç “vector.h”.
3.3. Èíòåðôåéñ ïîëüçîâàòåëÿ.
Èíòåðôåéñ ïîëüçîâàòåëÿ ñîñòîèò èç 2 îñíîâíûõ ýëåìåíòîâ:
· - êîíòåêñòíîãî ìåíþ, ïîñðåäñòâîì êîòîðîãî ïîëüçîâàòåëü ìîæåò îòêðûâàòü, çàêðûâàòü, ñîçäàâàòü íîâûå áàçû äàííûõ, äîáàâëÿòü è óäàëÿòü ýëåìåíòû ÁÄ, ñîðòèðîâàòü ïî âñåì ïàðàìåòðàì çàïèñè è ïðîèçâîäèòü ïîèñê çàïèñåé ïî îïðåäåë¸ííûì ïàðàìåòðàì.
· - îñíîâíîå îêíî, ñîäåðæàùåå èíñòðóìåíòû äëÿ ðåäàêòèðîâàíèÿ ýëåìåíòîâ áàçû äàííûõ, ïðîñìîòðà ýëåìåíòîâ, ïðîñìîòðà ðåçóëüòàòîâ ïîèñêà è ñîðòèðîâêè ÁÄ, à òàêæå çàäàâàòü ïàðàìåòðû ïîèñêà.
3.4. Õðàíåíèå äàííûõ.
Áàçà äàííûõ ñîäåðæèò â íà÷àëå êàæäîé çàïèñè çàãîëîâîê (ïàðàãðàô) "racer". Ïîñëå íåãî ÷åðåç ïðîáåë ñîäåðæàòñÿ ýëåìåíòû çàïèñè. Êàæäàÿ çàïèñü íà÷èíàåòñÿ ñ íîâîé ñòðîêè.
4. Ðåàëèçàöèÿ ïðîåêòà.
 êà÷åñòâå ÿçûêà ïðîãðàììèðîâàíèÿ èñïîëüçóåì Ñ++. Êîìïèëÿòîð Visual C++ âåðñèè 6.
Ïðîãðàììà ðàçáèòà íà íåñêîëüêî ôàéëîâ:
· main.cpp - ðåàëèçàöèÿ îñíîâíûõ ìåòîäîâ è êëàññîâ ïðèëîæåíèÿ.
· main.h - îïèñàíèå èäåíòèôèêàòîðîâ ìåíþ.
· Rsrc.rc - ôàèë ðåñóðñîâ.
"main.cpp"
#include "main.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#pragma comment(lib,"comctl32.lib")
using namespace std;
/* Îïèñàíèå ãîíùèêà */
struct Racer
{
string famely;
string name;
string frace;
int races;
int wons;
int pouls;
int tituls;
int blaps;
};
//------------------------------------
// Ôàéëîâàÿ ñèñòåìà
class Reader
{
public:
Reader(); // Êîíñòðóêòîð / äåñòðóêîòîð
~Reader();
bool open_db(const char * file); // Îòêðûòü áä
bool
save_db(const char * file,vector
void close_db(); // Çàêðûòü áä
bool read(); // ×èòàòü ÁÄ
void new_paragraph(); // Íîâûé ïàðàãðàô
string paragraph; // Èìÿ ïàðàãðàôà
int loadAsInt(string name); // Çàãðóæàåì ïàðàìåòðû
string loadAsString(string name);
private:
fstream db; // Ôàèë áä
};
Reader::Reader() {}; // Êîíñòðóêòîð / äåñòðóêòîð
Reader::~Reader() { db.close(); };
/* Îòêðûâàåì áä */
bool Reader::open_db(const char *file)
{
db.open(file);
if(!db) return false;
return true;
};
/* Ñîõðàíÿåì áàçó äàííûõ */
bool Reader::save_db(const char *
file,vector
{
ofstream save;
save.open(file,ios::trunc); // Îòêðûâàåì ôàèë
if(!save) return false;
for(int
i=0;i { save
<< "racer "; save
<< "SurName=" << racer[i].famely; save
<< " Name=" << racer[i].name; save
<< " Races=" << racer[i].races; save
<< " Wons=" << racer[i].wons; save
<< " Pouls=" << racer[i].pouls; save
<< " FirstRace=" << racer[i].frace; save
<< " Tituls=" << racer[i].tituls; save
<< " BestLaps=" << racer[i].blaps; if(i }; save.close();
// Çàêðûâàåì ôàèë save.clear(); return
true; }; /* Çàêðûâàåì áä */ void Reader::close_db() { db.close(); db.clear(); }; /* ×èòàåì ïàðàãðàô */ bool Reader::read() { if(db.eof()
|| !db) return false; // Êîíåö ôàéëà else db
>> paragraph; return
true; }; /* ×èòàåì ÷èñëî */ int Reader::loadAsInt(string name) // Loading As Int { string s; db
>> s; name+="="; return
atoi(s.substr(name.size(),s.size()).c_str()); }; /* ×èòàåì ñòðîêó */ string Reader::loadAsString(string name) // Loading As
String { string s; db
>> s; name+="="; return
s.substr(name.size(),s.size()); }; /*
Ïåðåõîä íà íîâûé ïàðàãðàô */ void
Reader::new_paragraph() { db.ignore(1,'n'); }; //
---------------------------------------------------------------------------------------- //
Ðàáîòà ïðèëîæåíèÿ class Application { public: Application(); ~Application(); bool
db_load(const char *file); // Çàãðóçêà áä void db_close(); //
Çàêðûòü òåêóùóþ áä bool db_save(const
char *file); // Ñîõðàíèòü áä void db_add_item(); //
Äîáàâèòü ýëåìåíò void
db_delete_item(int number); // Óäàëèòü ýëåìåíò void bd_sortby(int
value); // Ñîðòèðîâàòü ïî ýëåìåíòó int bd_findby(int
value,string look); // Èñêàòü â ýëåìåíòå vector private: inline int
find_name(string value); // ----------------------------------------------- Reader
reader; // Ôàéëîâàÿ ñèñòåìà }; Application::Application() {}; // Êîíñòðóêòîð / äåñòðóêòîð Application::~Application() {}; bool Application::db_load(const char * file) { if(reader.open_db(file)) { racers.clear();
// Î÷èùàåì âåêòîð while(reader.read()) { Racer
m_racer; m_racer.famely
= reader.loadAsString("SurName"); m_racer.name
= reader.loadAsString("Name"); m_racer.races
= reader.loadAsInt("Races"); m_racer.wons
= reader.loadAsInt("Wons"); m_racer.pouls
= reader.loadAsInt("Pouls"); m_racer.frace
= reader.loadAsString("FirstRace"); m_racer.tituls
= reader.loadAsInt("Tituls"); m_racer.blaps
= reader.loadAsInt("BestLaps"); reader.paragraph; racers.push_back(m_racer);
// Äîáàâëÿåì ãîíùèêà â àêêóìóëÿòîð }; reader.close_db();
// Çàêðûâàåì ôàèë return
true; }; return
false; }; /* Çàêðûâàåì áä */ void Application::db_close() { racers.clear(); // Î÷èùàåì ñïèñîê
ãîíùèêîâ }; /* Ñîõðàíåíèå áä */ bool Application::db_save(const char * name) { if(!reader.save_db(name,racers))
return false; return
true; }; /* Äîáàâèòü ýëåìåíò */ void Application::db_add_item() { Racer
temp; temp.blaps
= 0; temp.famely
= "Mr.Unknown"; temp.frace
= "When?"; temp.name
= "Unknown"; temp.pouls
= 0; temp.races
= 0; temp.tituls
= 0; temp.wons
= 0; racers.push_back(temp); }; /* Óäàëèòü ýëåìåíò */ void Application::db_delete_item(int number) { if(number
>= racers.size() || number<0) return; vector for(int
i=0;i racers.erase(it); }; // ----------------------------------------------- /* Ñîðòèðîâêà */ bool sort_famely(Racer &one,Racer &two); bool sort_name(Racer &one,Racer &two); bool sort_frace(Racer &one,Racer &two); bool sort_blaps(Racer &one,Racer &two); bool sort_pouls(Racer &one,Racer &two); bool sort_races(Racer &one,Racer &two); bool sort_tituls(Racer &one,Racer &two); bool sort_wons(Racer &one,Racer &two); inline bool sort_famely(Racer &one,Racer &two) { if(one.famely
< two.famely) return true; return
false; }; inline bool sort_name(Racer &one,Racer &two) { if(one.name
< two.name) return true; return
false; }; inline bool sort_frace(Racer &one,Racer &two) { if(one.frace
< two.frace) return true; return
false; }; inline bool sort_blaps(Racer &one,Racer &two) { if(one.blaps
> two.blaps) return true; return
false; }; inline bool sort_pouls(Racer &one,Racer &two) { if(one.pouls
> two.pouls) return true; return
false; }; inline bool sort_races(Racer &one,Racer &two) { if(one.races
> two.races) return true; return
false; }; inline bool sort_tituls(Racer &one,Racer &two) { if(one.tituls
> two.tituls) return true; return
false; }; inline bool sort_wons(Racer &one,Racer &two) { if(one.wons
> two.wons) return true; return
false; }; void Application::bd_sortby(int value) { switch(value) { case 1: //
Ôàìèëèÿ sort(racers.begin(),racers.end(),sort_famely); return; case 2: //
Èìÿ sort(racers.begin(),racers.end(),sort_name); return; case 3: //
Ãîíîê sort(racers.begin(),racers.end(),sort_races); return; case 4: //
Ïîáåä sort(racers.begin(),racers.end(),sort_wons); return; case 5: //
Ïîóëîâ sort(racers.begin(),racers.end(),sort_pouls); return; case 6: //
Ïåðâàÿ ãîíêà sort(racers.begin(),racers.end(),sort_frace); return; case 7: //
Òèòóëîâ sort(racers.begin(),racers.end(),sort_tituls); return; case 8: //
Ëó÷øèõ êðóãîâ sort(racers.begin(),racers.end(),sort_blaps); return; default: return; }; }; int Application::find_name(string value) { // for(int
i=0;i return 0; }; int Application::bd_findby(int value,string look) { switch(value) { case 1: //
Ôàìèëèÿ return
0; case 2: //
Èìÿ return
find_name(look); case 3: //
Ãîíîê return
0; case 4: //
Ïîáåä return
0; case 5: //
Ïîóëîâ return
0; case 6: //
Ïåðâàÿ ãîíêà return
0; case 7: //
Òèòóëîâ return
0; case 8: //
Ëó÷øèõ êðóãîâ return
0; default: return
0; }; }; //
--------------------------------------------------------------------- // Ïðîãðàììà Application app; int number; // Íîìåð òåêóùåãî ýëåìåíòà LRESULT CALLBACK WindowFunc(HWND,
UINT, WPARAM, LPARAM); char *szWinName = "MyClass"; HWND hwnd,hwndSort, hwndFind; // Îêíà - ñòàíäàðòíîå, ñîðòèðîâêè, ïîèñêà HWND button_last,button_next; // Êíîïêè HWND edit_find,
edit_famely,edit_name,edit_races,edit_wons,edit_pouls,edit_tituls,edit_frace,edit_blaps;
// Åäèòû HWND text_1,text_2,text_3,text_4,text_5,text_6,text_7,text_8,text_9,text_10,text_11,text_number;
// Òåêñòû MSG msg; WNDCLASS wcl; HMENU menu; Racer *find_racer,*find_result; void draw_sort(); void draw_sort() { char
val[5]; LVITEM lvi; ZeroMemory(&lvi, sizeof(lvi)); ListView_DeleteAllItems(hwndSort); lvi.mask = LVIF_TEXT; for(int i=0;i {
lvi.iItem = i;
lvi.iSubItem = 0;
_itoa(i+1,val,10);
lvi.pszText = val;
lvi.iItem = ListView_InsertItem(hwndSort, &lvi);
lvi.iSubItem++;
lvi.pszText = (char *) app.racers[i].famely.c_str();
ListView_SetItem(hwndSort, &lvi); };
char
text[50]; SetWindowText(edit_famely,
(char*)app.racers[number-1].famely.c_str()); SetWindowText(edit_name,
(char*)app.racers[number-1].name.c_str()); itoa(app.racers[number-1].tituls,text,10); SetWindowText(edit_tituls,
text); itoa(app.racers[number-1].wons,text,10); SetWindowText(edit_wons,
text); itoa(app.racers[number-1].pouls,text,10); SetWindowText(edit_pouls,
text); itoa(app.racers[number-1].blaps,text,10); SetWindowText(edit_blaps,
text); itoa(app.racers[number-1].races,text,10); SetWindowText(edit_races,
text); SetWindowText(edit_frace,app.racers[number-1].frace.c_str()); itoa(number,text,10); SetWindowText(text_number,text); }; void draw_find(int number, string famely); void draw_find(int number, string famely) { char
val[5]; LVITEM lvi; ZeroMemory(&lvi, sizeof(lvi)); ListView_DeleteAllItems(hwndFind); lvi.mask = LVIF_TEXT;
lvi.iItem = 0;
lvi.iSubItem = 0;
_itoa(number+1,val,10);
lvi.pszText = val;
lvi.iItem = ListView_InsertItem(hwndFind, &lvi);
lvi.iSubItem++;
lvi.pszText = (char *) famely.c_str();
ListView_SetItem(hwndFind, &lvi); }; int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE
hPrevInstance,LPSTR lpCmdLine,int nCmdShow) { // çàïîëíåíèå ñòðóêòóðû WNDCLASS
wcl.hInstance = hInstance;
wcl.lpszClassName = szWinName;
wcl.lpfnWndProc = WindowFunc;
wcl.style = 0;
wcl.hIcon = LoadIcon(NULL, IDI_ASTERISK);
wcl.hCursor = LoadCursor(NULL,IDC_ARROW);
wcl.lpszMenuName = NULL;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
wcl.hbrBackground = (HBRUSH)COLOR_WINDOW; //ðåãåñòðèðóåì îêîííûé
êëàññ RegisterClass(&wcl); // Èíèöèàëèçàöèÿ êîììîí êîíòðîëîâ InitCommonControls(); //ñîçäàåì ãëàâíîå îêíî è ýëåìåíòû
óïðàâëåíèÿ hwnd = CreateWindow(szWinName,
"Kursovik", WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME ^ WS_MAXIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT,
500, 350, HWND_DESKTOP, NULL, hInstance, NULL); // Ñîçäà¸ì îêíî ñ ðåçóëüòàòàìè ñîðòèðîâêè hwndSort = CreateWindowEx(0L,
WC_LISTVIEW, "",WS_VISIBLE | WS_BORDER | WS_CHILD |LVS_REPORT,250,
30, 100, 170,hwnd, NULL, hInstance, NULL); hwndFind = CreateWindowEx(0L,
WC_LISTVIEW, "",WS_VISIBLE | WS_BORDER | WS_CHILD |LVS_REPORT,370,
30, 100, 170,hwnd, NULL, hInstance,
NULL); // Âñòàâëÿåì ñòîëáöû LV_COLUMN lvc; memset(&lvc,
0, sizeof(lvc)); lvc.iSubItem
= 0; lvc.mask =
LVCF_FMT | LVCF_WIDTH | LVCF_TEXT |
LVCF_SUBITEM; lvc.fmt =
LVCFMT_LEFT; lvc.iSubItem++; lvc.cx =
30; lvc.pszText
= "#"; ListView_InsertColumn(hwndSort,
lvc.iSubItem, &lvc); ListView_InsertColumn(hwndFind,
lvc.iSubItem, &lvc); lvc.iSubItem++; lvc.cx =
70; lvc.pszText
= "Famely"; ListView_InsertColumn(hwndSort,
lvc.iSubItem, &lvc); ListView_InsertColumn(hwndFind,
lvc.iSubItem, &lvc); /* Äîáàâëÿåì êíîïêè */ button_last
= CreateWindow("button", "<< Last", WS_CHILD |
WS_VISIBLE, 150, 270, 70, 25, hwnd, NULL, hInstance, NULL); button_next =
CreateWindow("button", "Next >>", WS_CHILD |
WS_VISIBLE, 250, 270, 70, 25, hwnd, NULL, hInstance, NULL); /* Åäèò áîêñû */ edit_famely=CreateWindowEx(WS_EX_CLIENTEDGE,"edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,75,10,150,25,hwnd,NULL,hInstance,NULL); edit_name=CreateWindowEx(WS_EX_CLIENTEDGE,"edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,75,40,150,25,hwnd,NULL,hInstance,NULL); edit_tituls
=
CreateWindowEx(WS_EX_CLIENTEDGE,"edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,75,70,150,25,hwnd,NULL,hInstance,NULL); edit_wons
= CreateWindowEx(WS_EX_CLIENTEDGE,"edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,75,100,150,25,hwnd,NULL,hInstance,NULL); edit_pouls
=
CreateWindowEx(WS_EX_CLIENTEDGE,"edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,75,130,150,25,hwnd,NULL,hInstance,NULL); edit_blaps
= CreateWindowEx(WS_EX_CLIENTEDGE,"edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,75,160,150,25,hwnd,NULL,hInstance,NULL); edit_races
=
CreateWindowEx(WS_EX_CLIENTEDGE,"edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,75,190,150,25,hwnd,NULL,hInstance,NULL); edit_frace
= CreateWindowEx(WS_EX_CLIENTEDGE,"edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,75,220,150,25,hwnd,NULL,hInstance,NULL); edit_find
=
CreateWindowEx(WS_EX_CLIENTEDGE,"edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,320,230,150,25,hwnd,NULL,hInstance,NULL); /* Âíîñèì òåêñò */ text_1 =
CreateWindow("static","Famely",WS_CHILD|WS_VISIBLE,5,15,50,15,hwnd,NULL,hInstance,NULL); text_2 =
CreateWindow("static","Name",WS_CHILD|WS_VISIBLE,5,45,50,15,hwnd,NULL,hInstance,NULL); text_3 =
CreateWindow("static","Tituls",WS_CHILD|WS_VISIBLE,5,75,50,15,hwnd,NULL,hInstance,NULL); text_4 =
CreateWindow("static","Wons",WS_CHILD|WS_VISIBLE,5,105,50,15,hwnd,NULL,hInstance,NULL); text_5 =
CreateWindow("static","Pouls",WS_CHILD|WS_VISIBLE,5,135,50,15,hwnd,NULL,hInstance,NULL); text_6 =
CreateWindow("static","Best
laps",WS_CHILD|WS_VISIBLE,5,165,65,15,hwnd,NULL,hInstance,NULL); text_7 =
CreateWindow("static","Races",WS_CHILD|WS_VISIBLE,5,195,50,15,hwnd,NULL,hInstance,NULL); text_8 =
CreateWindow("static","First
race",WS_CHILD|WS_VISIBLE,5,225,65,15,hwnd,NULL,hInstance,NULL); text_9 =
CreateWindow("static","Sort
result:",WS_CHILD|WS_VISIBLE,250,5,75,15,hwnd,NULL,hInstance,NULL); text_10 =
CreateWindow("static","Find
result:",WS_CHILD|WS_VISIBLE,370,5,75,15,hwnd,NULL,hInstance,NULL); text_11 =
CreateWindow("static","Search:",WS_CHILD|WS_VISIBLE,260,235,60,15,hwnd,NULL,hInstance,NULL); text_number
=
CreateWindow("static","0",WS_CHILD|WS_VISIBLE,230,270,15,15,hwnd,NULL,hInstance,NULL); // îòîáðàæàåì è îáíîâëÿåì îêíî
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd); menu =
LoadMenu(hInstance, MAKEINTRESOURCE(ID_MENU)); SetMenu(hwnd, menu); //öèêë îáðàáîòêè ñîîáùåíèé while(GetMessage(&msg,
NULL, 0, 0)) { TranslateMessage(&msg);
DispatchMessage(&msg); } return 0; }; int i=0; // îêîííàÿ ôóíêöèÿ LRESULT CALLBACK WindowFunc(HWND hwnd, UINT iMsg,
WPARAM wParam, LPARAM lParam) { switch(iMsg) { case
WM_DESTROY:
PostQuitMessage(0); break; case WM_COMMAND: { if(((HWND)lParam
== button_last) && (HIWORD(wParam) == BN_CLICKED))
{ if(number>1) { number--; //
Ñîõðàíÿåì ýëåìåíò char
text[50]; 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); //
Çàïèñûâàåì íîâûé SetWindowText(edit_famely,
(char*)app.racers[number-1].famely.c_str()); SetWindowText(edit_name,
(char*)app.racers[number-1].name.c_str()); itoa(app.racers[number-1].tituls,text,10); SetWindowText(edit_tituls,
text); itoa(app.racers[number-1].wons,text,10); SetWindowText(edit_wons,
text); itoa(app.racers[number-1].pouls,text,10); SetWindowText(edit_pouls,
text); itoa(app.racers[number-1].blaps,text,10); SetWindowText(edit_blaps,
text); itoa(app.racers[number-1].races,text,10); SetWindowText(edit_races,
text); SetWindowText(edit_frace,app.racers[number-1].frace.c_str()); itoa(number,text,10); SetWindowText(text_number,text); }; }; //
Êíîïêà äàëåå if(((HWND)lParam
== button_next) && (HIWORD(wParam) == BN_CLICKED))
{ if(number { number--; //
Ñîõðàíÿåì ýëåìåíò char
text[50]; 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++; SetWindowText(edit_famely,
char*)app.racers[number].famely.c_str()); SetWindowText(edit_name,
(char*)app.racers[number].name.c_str()); itoa(app.racers[number].tituls,text,10); SetWindowText(edit_tituls,
text); itoa(app.racers[number].wons,text,10); SetWindowText(edit_wons,
text); itoa(app.racers[number].pouls,text,10); SetWindowText(edit_pouls,
text); itoa(app.racers[number].blaps,text,10); SetWindowText(edit_blaps,
text); itoa(app.racers[number].races,text,10); SetWindowText(edit_races,
text); SetWindowText(edit_frace,app.racers[number]. frace.c_str()); number++; itoa(number,text,10); SetWindowText(text_number,text); }; }; switch(wParam) { case
IDM_FILENEW: app.db_close(); app.db_add_item(); number=0; SetWindowText(edit_famely,
(char*)app.racers[number].famely.c_str()); SetWindowText(edit_name,
(char*)app.racers[number].name.c_str()); char text[50]; itoa(app.racers[number].tituls,text,10); SetWindowText(edit_tituls,
text); itoa(app.racers[number].wons,text,10); SetWindowText(edit_wons, text); itoa(app.racers[number].pouls,text,10); SetWindowText(edit_pouls,
text); itoa(app.racers[number].blaps,text,10); SetWindowText(edit_blaps,
text); itoa(app.racers[number].races,text,10); SetWindowText(edit_races,
text); SetWindowText(edit_frace,app.racers[number] .frace.c_str()); number++; itoa(number,text,10); SetWindowText(text_number,text); return
0; case
IDM_FILEOPEN: // Îòêðûâàåì ôàèë áàçû äàííûõ number=1; app.db_close(); //
Õàêðûâàåì áàçó äàííûõ OPENFILENAME ofn; char
szFile[260]; //
Initialize OPENFILENAME ZeroMemory(&ofn,
sizeof(ofn)); ofn.lStructSize
= sizeof(ofn); ofn.hwndOwner
= hwnd; ofn.lpstrFile
= szFile; ofn.lpstrFile[0]
= ' '; ofn.nMaxFile
= sizeof(szFile); ofn.lpstrFilter
= "Schnaider Yuri data base *.bd "; ofn.nFilterIndex
= 1; ofn.lpstrFileTitle
= NULL; ofn.nMaxFileTitle
= 0; ofn.lpstrInitialDir
= NULL; ofn.Flags
= OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; if
(GetOpenFileName(&ofn)==TRUE) // Reading { if(app.db_load(
(const char *) ofn.lpstrFile)) { SetWindowText(edit_famely,
(char*)app.racers[0].famely.c_str()); SetWindowText(edit_name,
(char*)app.racers[0].name.c_str()); char
text[10]; 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()); 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]
= ' '; ofn.nMaxFile
= sizeof(szFile); ofn.lpstrFilter
= "Schnaider Yuri data base *.bd "; 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 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 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 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 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 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 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 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 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_NAME 300 #define IDM_SORT_FAMELY 301 #define IDM_SORT_TITULS 302 #define IDM_SORT_WONS 303 #define IDM_SORT_POULS 304 #define IDM_SORT_BLAPS 305 #define IDM_SORT_RACES 306 #define IDM_SORT_FRACE 307 #define IDM_FIND_NAME 400 #define IDM_FIND_FAMELY 401 #define IDM_FIND_TITULS 402 #define IDM_FIND_WONS 403 #define IDM_FIND_POULS 404 #define IDM_FIND_BLAPS 405 #define IDM_FIND_RACES 406 #define IDM_FIND_FRACE 407 #define IDM_HELPABOUT 218 #endif "Rsrc.rc" 500 ICON MOVEABLE PURE LOADONCALL
DISCARDABLE "kursovik.ico" #include #include "main.h" 501 MENU BEGIN POPUP
"&File" BEGIN MENUITEM
"&New", IDM_FILENEW MENUITEM
"&Open...", IDM_FILEOPEN MENUITEM
"Save &as...", IDM_FILESAVEAS MENUITEM
SEPARATOR MENUITEM
"E&xit", IDM_FILEEXIT END POPUP
"&Edit" BEGIN MENUITEM
"&Add element", IDM_ADD MENUITEM
"&Delete element", IDM_DELETE END POPUP
"&Sort" BEGIN MENUITEM
"&By name", IDM_SORT_NAME MENUITEM
"&By famely", IDM_SORT_FAMELY MENUITEM
"&By tituls", IDM_SORT_TITULS MENUITEM
"&By wons", IDM_SORT_WONS MENUITEM
"&By pouls", IDM_SORT_POULS MENUITEM
"&By best laps", IDM_SORT_BLAPS MENUITEM
"&By races", IDM_SORT_RACES MENUITEM
"&By first race", IDM_SORT_FRACE END POPUP
"&Find" BEGIN MENUITEM
"&By name", IDM_FIND_NAME MENUITEM
"&By famely", IDM_FIND_FAMELY MENUITEM
"&By tituls", IDM_FIND_TITULS MENUITEM
"&By wons", IDM_FIND_WONS MENUITEM "&By pouls",
IDM_FIND_POULS MENUITEM
"&By best laps", IDM_FIND_BLAPS MENUITEM
"&By races", IDM_FIND_RACES MENUITEM
"&By first race", IDM_FIND_FRACE END POPUP
"&Help" BEGIN MENUITEM
"&About...", IDM_HELPABOUT END END 5. Ïåðñïåêòèâû
äîðàáîòêè. Â äàëüíåéøåì äîðàáîòêà àëãîðèòìîâ
ñîðòèðîâêè, ïîèñêà. Äîðàáîòêà èíòåðôåéñà ïîëüçîâàòåëÿ.
Äîðàáîòêà èëè ïîëíîñòüþ ïåðåñòðîåíèå ñòðóêòóðû áàçû äàííûõ.
Ðàçðàáîòêà àâòîìàòèçèðîâàííîãî ðàáî÷åãî ìåñòà ìåíåäæåðà ðîçíè÷íîé òîðãîâëè
Îñíîâíûå âîçìîæíîñòè Ñ++, îïåðàòîðû Case, ïîñòðîåíèå èíòåðôåéñà
Ðàçðàáîòêà áàçû äàííûõ «Ìàãàçèí áûòîâîé òåõíèêè “Ýëåêòðîí”» ñðåäñòâàìè ÑÓÁÄ MS Access
Áàçà äàííûõ MS Access òîðãîâîé îðãàíèçàöèè, çàíèìàþùåéñÿ ðåàëèçàöèåé ïòèöû-ðûáû
Ññûëî÷íûå òèïû. Äèíàìè÷åñêèå ïåðåìåííûå
Àâòîñòîÿíêè
Îáúåêòíî-îðèåíòèðîâàííîå ïðîãðàììèðîâàíèå Àâòîáóñû è ìàðøðóòû
Win32-ïðèëîæåíèå Êàðòîòåêà àóäèî äèñêîâ
Ñîçäàíèå áàçû äàííûõ ðàñïèñàíèå
Ðàçðàáîòêà èíôîðìàöèîííîé ñèñòåìû Ñëóæáû çàíÿòîñòè
Copyright (c) 2024 Stud-Baza.ru Ðåôåðàòû, êîíòðîëüíûå, êóðñîâûå, äèïëîìíûå ðàáîòû.