Проектирование программного приложения

Автор: Пользователь скрыл имя, 06 Декабря 2011 в 03:08, курсовая работа

Краткое описание

Железнодорожное управление вокзала города Энска заказало логотип, рекламный ролик и программу обслуживания железнодорожных касс. Программа накапливает информацию: город следования, количество поездов на данное направление, среднее число посадочных мест в поезде, ожидаемый пассажиропоток. Программа по запросу на указанном направлении изменяет любое из информационных полей. Программа по запросу выдает информацию о тех направлениях, на которых наблюдается недогрузка поездов (загруженность поезда меньше 50%) и снимает с этих направлений избыточные поезда (считать допустимой загрузку на 89%)

Файлы: 1 файл

отчет.docx

— 140.93 Кб (Скачать)

      switch (message)

      {

      case WM_INITDIALOG:

            { 

                  fstream File;

                  File.open(FileName, ios::in|ios::out);

                  ClearAll(hDlg);

                  FillList(hDlg, File);

                  File.close();

            }

            return (INT_PTR)TRUE; 

      case WM_COMMAND:

            switch(LOWORD(wParam))

            {

            case IDC_LIST_CITY:

                  {

                        switch(HIWORD(wParam))

                        {

                        case LBN_SELCHANGE:

                              {

                                    N = SendMessage( GetDlgItem(hDlg, IDC_LIST_CITY), LB_GETCURSEL, 0, 0) + 1; 

                                    Record Info;

                                    fstream File;

                                    File.open(FileName, ios::in|ios::out);

                                    ReadInfo(File, Info, N);

                                    FillEdits(hDlg, Info);

                                    File.close();

                              }

                              break;

                        }

                  }

                  return (INT_PTR)TRUE;

            case IDC_BUTTON_ADD:

                  {

                        DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ADDCHANGE), hDlg, AddDialog); 

                        fstream File;

                        File.open(FileName, ios::in|ios::out);

                        ClearAll(hDlg);

                        FillList(hDlg, File);

                        File.close();

                  }

                  return (INT_PTR)TRUE;

            case IDC_BUTTON_CHANGE:

                  {

                        N = SendMessage( GetDlgItem(hDlg, IDC_LIST_CITY), LB_GETCURSEL, 0, 0) + 1; 

                        if(N)

                        {

                              DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ADDCHANGE), hDlg, ChangeDialog); 

                              fstream File;

                              File.open(FileName, ios::in|ios::out);

                              ClearAll(hDlg);

                              FillList(hDlg, File);

                              File.close();

                        }

                        else

                        {

                              MessageBox(hDlg, "Выберите запись", "Ошибка", MB_OK);

                        }

                  }

                  return (INT_PTR)TRUE;

            case IDC_BUTTON_MARK:

                  {

                        N = SendMessage( GetDlgItem(hDlg, IDC_LIST_CITY), LB_GETCURSEL, 0, 0) + 1; 

                        if(N)

                        {

                              Record Info;

                              fstream File;

                              File.open(FileName, ios::in|ios::out);

                              ReadInfo(File, Info, N);

                              Info.Delete = !Info.Delete;

                              WriteInfo(File, Info, N);

                              ClearEdits(hDlg);

                              FillEdits(hDlg, Info);

                              File.close();

                        }

                        else

                        {

                              MessageBox(hDlg, "Выберите запись", "Ошибка", MB_OK);

                        }

                  }

                  return (INT_PTR)TRUE;

            case IDC_BUTTON_DELETE:

                  {

                        fstream File;

                        File.open(FileName, ios::in|ios::out);

                        DeleteInfo(File);

                        File.open(FileName, ios::in|ios::out);

                        ClearAll(hDlg);

                        FillList(hDlg, File);

                        File.close();

                  }

                  return (INT_PTR)TRUE;

            case IDC_BUTTON_DO:

                  {

                        DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DO), hDlg, DoDialog);

                  }

                  return (INT_PTR)TRUE; 

            case IDCANCEL:

                  {

                        EndDialog(hDlg, LOWORD(wParam));

                  }

                  return (INT_PTR)TRUE;

            }

            break;

      }

      return (INT_PTR)FALSE;

} 

INT_PTR CALLBACK AddDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)

{

      UNREFERENCED_PARAMETER(lParam);

      switch (message)

      {

      case WM_INITDIALOG:

            return (INT_PTR)TRUE; 

      case WM_COMMAND:

            switch(LOWORD(wParam))

            {

            case IDOK:

                  {

                        Record Info;

                        memset(&Info, 0, sizeof(Record) );

                        fstream File;

                        File.open(FileName, ios::in|ios::out|ios::app);

                        File.close(); 

                        File.open(FileName, ios::in|ios::out);

                        if(GetInfo(hDlg, Info))

                        {

                              Info.Delete = false;

                              WriteInfo(File, Info, 0);

                        }

                        else

                        {

                              MessageBox(hDlg, "Неверный ввод информации", "Ошибка", MB_OK);

                        }

                        File.close();

                        EndDialog(hDlg, LOWORD(wParam));

                  }

                  return (INT_PTR)TRUE;

            case IDCANCEL:

                  {

                        EndDialog(hDlg, LOWORD(wParam));

                  }

                  return (INT_PTR)TRUE;

            }

            break;

      }

      return (INT_PTR)FALSE;

} 
 
 
 
 
 

INT_PTR CALLBACK ChangeDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)

{

      UNREFERENCED_PARAMETER(lParam);

      switch (message)

      {

      case WM_INITDIALOG:

            return (INT_PTR)TRUE; 

      case WM_COMMAND:

            switch(LOWORD(wParam))

            {

            case IDOK:

                  {

                        Record Info;

                        memset(&Info, 0, sizeof(Record) );

                        fstream File;

                        File.open(FileName, ios::in|ios::out);

                        ReadInfo(File, Info, N);

                        if(ChangeInfo(hDlg, Info))

                        {

                              WriteInfo(File, Info, N);

                        }

                        else

                        {

                              MessageBox(hDlg, "Неверный ввод информации", "Ошибка", MB_OK);

                        }

                        File.close();

                        EndDialog(hDlg, LOWORD(wParam));

                  }

                  return (INT_PTR)TRUE;

            case IDCANCEL:

                  {

                        EndDialog(hDlg, LOWORD(wParam));

                  }

                  return (INT_PTR)TRUE;

            }

            break;

      }

Информация о работе Проектирование программного приложения