Ðåôåðàòû. Áàçà äàííûõ ïèëîòîâ Ôîðìóëû 1

                                  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] = '\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 (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] = '\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);

Ñòðàíèöû: 1, 2, 3, 4, 5



2012 © Âñå ïðàâà çàùèùåíû
Ïðè èñïîëüçîâàíèè ìàòåðèàëîâ àêòèâíàÿ ññûëêà íà èñòî÷íèê îáÿçàòåëüíà.