Управление информацией в автобусном парке

Автор: Пользователь скрыл имя, 15 Мая 2012 в 01:26, курсовая работа

Описание работы

С++ - это универсальный язык программирования, задуманный так, чтобы сделать программирование более приятным для серьезного программиста. За исключением второстепенных деталей С++ является надмножеством языка программирования C. Помимо возможностей, которые дает C, С++ предоставляет гибкие и эффективные средства определения новых типов. Используя определения новых типов, точно отвечающих концепциям приложения, программист может разделять разрабатываемую программу на легко поддающиеся контролю части. Такой метод построения программ часто называют абстракцией данных

Содержание

Содержание
Содержание___________________________________________________________2
Введение_____________________________________________________________ 3
Постановка задачи_____________________________________________________4
Условие задачи_______________________________________________________4
Обзор методов________________________________________________________4
Структура входных и выходных данных __________________________________5
Диаграмма классов_____________________________________________________6
Описание классов______________________________________________________7 6.1 CityBus____________________________________________________________7
6.2 ComfortBus________________________________________________________8
6.3 List_______________________________________________________________9
6.4 mylist ____________________________________________________________10
6.8 ListNotFree________________________________________________________11
7. Описание алгоритмов_________________________________________________10
7.1 Блок схемы алгоритмов программы___________________________________10
Алгоритмы по шагам_______________________________________________12
8.Текст программы______________________________________________________13
8.1 CityBus.h _________________________________________________________13
8.2 CityBus.cpp _______________________________________________________13
8.3 ComfortBus.h______________________________________________________16 8.4 ComfortBus.cpp ____________________________________________________17
8.5 mylist.h _________________________________________________________ 19 8.6 Iterator.h _________________________________________________________25
8.7 Iterator.cpp ________________________________________________________26 8.8 exceptions.h _______________________________________________________28
8.9 database.cpp _______________________________________________________28
8.10 Form1.h _________________________________________________________29
9. Результат работы программы___________________________________________56
10.Заключение__________________________________________________________58
11.Литература___________________________________________________________

Работа содержит 1 файл

!!!!!!!!Пояснительная записка.docx

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

mainptr.getT()->setSeats(Convert::ToInt32(form3->numericUpDown1->Value));

mainptr.getT()->setDriver1(and_SysStringToChar(form3->textBox3->Text));

mainptr.getT()->setDriver2(and_SysStringToChar(form3->textBox4->Text));

mainptr.getT()->setST(and_SysStringToChar(form3->comboBox2->Text));

 

mainptr = mainlist;

this->dataGridView1->Rows->Clear();

 

do

{

 

this->dataGridView1->Rows->Add(and_CharToSysString((*mainptr).getRegNumber()),

and_CharToSysString((*mainptr).getMark()),

and_CharToSysString((*mainptr).getState()),

(*mainptr).getSeats(),

and_CharToSysString((*mainptr).getST()));

 

 

if(mainlist.back() == mainptr.getptr()) break;

mainptr++;

}

while(1);

 

}

else

{

maincomptr.getT()->setMark(and_SysStringToChar(form3->textBox1->Text));

maincomptr.getT()->setRegNumber(and_SysStringToChar(form3->textBox2->Text));

maincomptr.getT()->setMark(and_SysStringToChar(form3->comboBox1->Text));

maincomptr.getT()->setSeats(Convert::ToInt32(form3->numericUpDown1->Value));

maincomptr.getT()->setDriver1(and_SysStringToChar(form3->textBox3->Text));

maincomptr.getT()->setDriver2(and_SysStringToChar(form3->textBox4->Text));

maincomptr.getT()->setwc(form3->checkBox1->Checked);

maincomptr.getT()->settv(form3->checkBox2->Checked);

 

maincomptr = maincomlist;

System::String ^ tmpwc;

System::String ^ tmptv;

this->dataGridView2->Rows->Clear();

 

 

 

do

{

if((*maincomptr).getbwc() == true)

tmpwc = "Yes";

else

tmpwc = "No";

if((*maincomptr).gettv() == true)

tmptv = "Yes";

else

tmptv = "No";

 

 

this->dataGridView2->Rows->Add(and_CharToSysString((*maincomptr).getRegNumber()),

and_CharToSysString((*maincomptr).getMark()),

and_CharToSysString((*maincomptr).getState()),

(*maincomptr).getSeats(),

tmptv,tmpwc);

 

 

if(mainlist.back() == mainptr.getptr()) break;

mainptr++;

}

while(1);

 

}

 

}

 

}

private: System::Void radioButton2_CheckedChanged(System::Object^  sender, System::EventArgs^  e)

//Вывод автобусов «На маршруте»

{

int count = this->dataGridView2->RowCount;

int i = count;

 

 

while(i)

{

this->dataGridView2->Rows[i-1]->Visible = true;

i--;

};

 

while(count)

{

if(this->dataGridView2->Rows[count-1]->Cells[2]->FormattedValue->ToString() != (System::String ^)"Route")

this->dataGridView2->Rows[count-1]->Visible = false;

count--;

}

count = this->dataGridView1->RowCount;

i = count;

 

while(i)

{

this->dataGridView1->Rows[i-1]->Visible = true;

i--;

};

 

while(count)

{

if(this->dataGridView1->Rows[count-1]->Cells[2]->FormattedValue->ToString() != (System::String ^)"Route")

this->dataGridView1->Rows[count-1]->Visible = false;

count--;

}

 

}

private: System::Void radioButton3_CheckedChanged(System::Object^  sender, System::EventArgs^  e)

//Вывод автобусов «На базе»

{

int count = this->dataGridView2->RowCount;

int i = count;

 

 

while(i)

{

this->dataGridView2->Rows[i-1]->Visible = true;

i--;

};

 

while(count)

{

if(this->dataGridView2->Rows[count-1]->Cells[2]->FormattedValue->ToString() != (System::String ^)"Base")

this->dataGridView2->Rows[count-1]->Visible = false;

count--;

}

count = this->dataGridView1->RowCount;

i = count;

 

while(i)

{

this->dataGridView1->Rows[i-1]->Visible = true;

i--;

};

 

while(count)

{

if(this->dataGridView1->Rows[count-1]->Cells[2]->FormattedValue->ToString() != (System::String ^)"Base")

this->dataGridView1->Rows[count-1]->Visible = false;

count--;

}

}

private: System::Void radioButton4_CheckedChanged(System::Object^  sender, System::EventArgs^  e)

//Вывод автобусов «На ремонте»

{

int count = this->dataGridView2->RowCount;

int i = count;

 

 

while(i)

{

this->dataGridView2->Rows[i-1]->Visible = true;

i--;

};

 

while(count)

{

if(this->dataGridView2->Rows[count-1]->Cells[2]->FormattedValue->ToString() != (System::String ^)"Repair")

this->dataGridView2->Rows[count-1]->Visible = false;

count--;

}

count = this->dataGridView1->RowCount;

i = count;

 

while(i)

{

this->dataGridView1->Rows[i-1]->Visible = true;

i--;

};

 

while(count)

{

if(this->dataGridView1->Rows[count-1]->Cells[2]->FormattedValue->ToString() != (System::String ^)"Repair")

this->dataGridView1->Rows[count-1]->Visible = false;

count--;

}

}

private: System::Void radioButton5_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {

int count = this->dataGridView2->RowCount;

int i = count;

 

 

while(i)

{

this->dataGridView2->Rows[i-1]->Visible = true;

i--;

};

 

while(count)

{

if(this->dataGridView2->Rows[count-1]->Cells[2]->FormattedValue->ToString() != (System::String ^)"Trash")

this->dataGridView2->Rows[count-1]->Visible = false;

count--;

}

count = this->dataGridView1->RowCount;

i = count;

 

while(i)

{

this->dataGridView1->Rows[i-1]->Visible = true;

i--;

};

 

while(count)

{

if(this->dataGridView1->Rows[count-1]->Cells[2]->FormattedValue->ToString() != (System::String ^)"Trash")

this->dataGridView1->Rows[count-1]->Visible = false;

count--;

}

}

private: System::Void dataGridView1_CellMouseClick(System::Object^  sender, System::Windows::Forms::DataGridViewCellMouseEventArgs^  e) {

if (mainlist.getweight())

{

selectpos1 = this->dataGridView1->CurrentCellAddress.Y;

mainptr = mainlist;

for(int i = 0;i<selectpos1;i++)

mainptr++;

this->textBox1->Text = and_CharToSysString(mainptr.getT()->getDriver1());

this->textBox2->Text = and_CharToSysString(mainptr.getT()->getDriver2());

}

}

private: System::Void dataGridView2_CellMouseClick(System::Object^  sender, System::Windows::Forms::DataGridViewCellMouseEventArgs^  e) {

selectpos2 = this->dataGridView2->CurrentCellAddress.Y;

maincomptr = maincomlist;

for(int i = 0;i<selectpos2;i++)

maincomptr++;

this->textBox3->Text = and_CharToSysString(maincomptr.getT()->getDriver1());

this->textBox4->Text = and_CharToSysString(maincomptr.getT()->getDriver2());

 

}

private: System::Void toolStripButton2_Click(System::Object^  sender, System::EventArgs^  e)

//Сохранение файла

{

System::String ^ ttv;

System::String ^ twc;

this->openFileDialog1->AddExtension = true;

this->openFileDialog1->DefaultExt = and_CharToSysString(".cbd");

this->openFileDialog1->Filter = and_CharToSysString("Bus Database (*.cbd)|*.cbd");

openFileDialog1->ShowDialog();

System::String ^ Filename = gcnew System::String(openFileDialog1->FileName);

this->textBox5->Text = Filename;

char *str = and_SysStringToChar(Filename);

bool flag = false;

do

{

if (flag)

{

this->dataGridView1->Rows->Clear();

do

{

mainlist.pop_back();

if (!mainlist.getweight()) break;

} while (1);

flag = false;

}

 

try

{

mainlist.PopFromFile(str);

 

}

catch(ListNotFree)

{

flag = true;

 

 

}

} while (flag);

 

int len = strlen(str);

len-=3;

*(str+len++) = 'm';

*(str+len++) = 'b';

*(str+len++) = 'd';

 

flag = false;

do

{

if (flag)

{

this->dataGridView2->Rows->Clear();

do

{

maincomlist.pop_back();

if (!maincomlist.getweight()) break;

} while (1);

flag = false;

}

 

try

{

maincomlist.PopFromFile(str);

 

}

catch(ListNotFree)

{

flag = true;

 

 

}

} while (flag);

mainptr = mainlist;

maincomptr = maincomlist;

if (mainlist.getweight())

{

  do

  {

this->dataGridView1->Rows->Add

(and_CharToSysString((*mainptr).getRegNumber() ),

  and_CharToSysString((*mainptr).getMark() ),

  and_CharToSysString((*mainptr).getState() ),

  (*mainptr).getSeats() ,

   and_CharToSysString((*mainptr).getST()));

if (mainptr.getptr() == mainlist.back()) break;

mainptr++;     

  } while (1);

}

mainptr = mainlist;

 

if (maincomlist.front() != NULL)

{

  do

  {

  if((*maincomptr).gettv())

     ttv = "Yes";

  else

  ttv = "No";

  if((*maincomptr).getbwc())

  twc = "Yes";

  else

  twc  = "No";

 

 

this->dataGridView2->Rows->Add

(and_CharToSysString((*maincomptr).getRegNumber()),

  and_CharToSysString((*maincomptr).getMark()),

  and_CharToSysString((*maincomptr).getState()),

  Convert::ToString((*maincomptr).getSeats()),

  twc,

  ttv);

if (maincomptr.getptr() == maincomlist.back()) break;

maincomptr++;     

} while (1);

}

maincomptr = maincomlist;

this->groupBox3->Visible = true;

this->groupBox4->Visible = true;

}

private: System::Void toolStripButton3_Click(System::Object^  sender, System::EventArgs^  e)

//Сохранение файла

{

if(mainlist.getweight())

if(maincomlist.getweight())

{

System::String ^ Filename = gcnew System::String(this->textBox5->Text);

char *str = and_SysStringToChar(Filename);

mainlist.SendToFile(str);

int len = strlen(str);

len-=3;

*(str+len++) = 'm';

*(str+len++) = 'b';

*(str+len++) = 'd';

 

 

maincomlist.SendToFile(str);

}

 

}

};

}

 

Файл «Form2.h»

 

#pragma once

 

 

//#include "modellist.h"

//#include "servicelist.h"

#include "citybus.h"

//#include "functions.h"

#include <iostream>

 

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

 

 

 

 

 

 

namespace DataBase {

 

 

public ref class Form2 : public System::Windows::Forms::Form

{

public: bool cityflag;

public: System::Windows::Forms::TextBox^  textBox1;

public: System::Windows::Forms::TextBox^  textBox2;

public: System::Windows::Forms::ComboBox^  comboBox1;

public: System::Windows::Forms::ComboBox^  comboBox2;

 

 

public:

public: System::Windows::Forms::NumericUpDown^  numericUpDown1;

 

Form2(void)

{

InitializeComponent();

 

}

 

protected:

 

~Form2()

{

if (components)

{

delete components;

}

}

private: System::Windows::Forms::Label^  label1;

private: System::Windows::Forms::Label^  label2;

private: System::Windows::Forms::Label^  label3;

private: System::Windows::Forms::Label^  label4;

private: System::Windows::Forms::Label^  label5;

//private: System::Windows::Forms::TextBox^  textBox1;

//private: System::Windows::Forms::TextBox^  textBox2;

//private: System::Windows::Forms::ComboBox^  comboBox1;

//private: System::Windows::Forms::NumericUpDown^  numericUpDown1;

public: System::Windows::Forms::TextBox^  textBox3;

public: System::Windows::Forms::TextBox^  textBox4;

private: System::Windows::Forms::Button^  button1;

private: System::Windows::Forms::Button^  button2;

 

 

public: System::Windows::Forms::RadioButton^  radioButton1;

public: System::Windows::Forms::RadioButton^  radioButton2;

public: System::Windows::Forms::CheckBox^  checkBox1;

public: System::Windows::Forms::CheckBox^  checkBox2;

private: System::Windows::Forms::Label^  label6;

private: System::ComponentModel::IContainer^  components;

//private: System::Windows::Forms::ComboBox^  comboBox2;

 

protected:

 

private:

 

private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {

}

private: System::Void radioButton1_CheckedChanged(System::Object^  sender, System::EventArgs^  e)

//Проверка типа добавляемого автобуса

{

this->checkBox1->Visible = false;

this->checkBox2->Visible = false;   

this->label6->Visible = true;

this->comboBox2->Visible = true;

cityflag = true;

}

private: System::Void checkBox1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {

}

private: System::Void radioButton2_CheckedChanged(System::Object^  sender, System::EventArgs^  e)

//Проверка типа добавляемого автобуса

 

{

this->checkBox1->Visible = true;

this->checkBox2->Visible = true;   

this->label6->Visible = false;

this->comboBox2->Visible = false;

cityflag = false;

}

private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e)

//Проверка правильности введённых  полей

{

 if(this->radioButton1->Checked)

 {

 

if (

(this->textBox1->Text->Length) &&

(this->textBox2->Text->Length) &&

(this->comboBox1->Text->Length) &&

((this->comboBox1->Text == (System::String ^)"Base") ||

(this->comboBox1->Text == (System::String ^)"Route") ||

(this->comboBox1->Text == (System::String ^)"Repair") ||

(this->comboBox1->Text == (System::String ^)"Trash")) &&

 

(this->comboBox2->Text->Length) &&

((this->comboBox2->Text == (System::String ^)"Soft") ||

(this->comboBox2->Text == (System::String ^)"Hard"))

)

{

this->DialogResult::set(System::Windows::Forms::DialogResult::OK);

}

else

{

System::Windows::Forms::MessageBox::Show("You must fill necessary fields!" , "Entry error" ,MessageBoxButtons::OK,MessageBoxIcon::Exclamation);

}

}

else

{

if (

(this->textBox1->Text->Length) &&

(this->textBox2->Text->Length) &&

(this->comboBox1->Text->Length) &&

((this->comboBox1->Text == (System::String ^)"Base") ||

(this->comboBox1->Text == (System::String ^)"Route") ||

(this->comboBox1->Text == (System::String ^)"Repair") ||

(this->comboBox1->Text == (System::String ^)"Trash"))  

)

 

{

this->DialogResult::set(System::Windows::Forms::DialogResult::OK);

}

else

{

System::Windows::Forms::MessageBox::Show("You must fill necessary fields!" , "Entry error" ,MessageBoxButtons::OK,MessageBoxIcon::Exclamation);

}

 

}

}

 

private: System::Void comboBox1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {

}

private: System::Void Form2_Load(System::Object^  sender, System::EventArgs^  e) {

}

};

}

 

Файл «Form3.h»

 

#pragma once

 

 

//#include "modellist.h"

//#include "servicelist.h"

#include "citybus.h"

//#include "functions.h"

#include <iostream>

 

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

 

namespace DataBase {

 

 

public ref class Form3 : public System::Windows::Forms::Form

{

public: bool cityflag;

public: System::Windows::Forms::TextBox^  textBox1;

public: System::Windows::Forms::TextBox^  textBox2;

public: System::Windows::Forms::ComboBox^  comboBox1;

public: System::Windows::Forms::ComboBox^  comboBox2;

 

 

public:

public: System::Windows::Forms::NumericUpDown^  numericUpDown1;

 

Form3(void)

{

InitializeComponent();

 

}

 

protected:

 

~Form3()

{

if (components)

{

delete components;

}

}

 

private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {

}

private: System::Void radioButton1_CheckedChanged(System::Object^  sender, System::EventArgs^  e)

//Проверка редактируемой записи

 

 

{

 this->checkBox1->Visible = false;

 this->checkBox2->Visible = false;   

this->label6->Visible = true;

this->comboBox2->Visible = true;

cityflag = true;

}

private: System::Void checkBox1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {

}

private: System::Void radioButton2_CheckedChanged(System::Object^  sender, System::EventArgs^  e)

//Проверка редактируемой записи

{

 this->checkBox1->Visible = true;

 this->checkBox2->Visible = true;   

this->label6->Visible = false;

this->comboBox2->Visible = false;

cityflag = false;

}

private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e)

//Проверка правильности введённых  полей

 

{

 if(this->radioButton1->Checked)

 {

 

if (

(this->textBox1->Text->Length) &&

(this->textBox2->Text->Length) &&

(this->comboBox1->Text->Length) &&

((this->comboBox1->Text == (System::String ^)"Base") ||

(this->comboBox1->Text == (System::String ^)"Route") ||

(this->comboBox1->Text == (System::String ^)"Repair") ||

(this->comboBox1->Text == (System::String ^)"Trash")) &&

 

(this->comboBox2->Text->Length) &&

((this->comboBox2->Text == (System::String ^)"Soft") ||

(this->comboBox2->Text == (System::String ^)"Hard"))

)

 

{

this->DialogResult::set(System::Windows::Forms::DialogResult::OK);

}

else

{

System::Windows::Forms::MessageBox::Show("You must fill necessary fields!" , "Entry error" ,MessageBoxButtons::OK,MessageBoxIcon::Exclamation);

}

}

else

{

if (

(this->textBox1->Text->Length) &&

(this->textBox2->Text->Length) &&

(this->comboBox1->Text->Length) &&

((this->comboBox1->Text == (System::String ^)"Base") ||

(this->comboBox1->Text == (System::String ^)"Route") ||

(this->comboBox1->Text == (System::String ^)"Repair") ||

(this->comboBox1->Text == (System::String ^)"Trash"))  

)

 

{

this->DialogResult::set(System::Windows::Forms::DialogResult::OK);

}

else

{

System::Windows::Forms::MessageBox::Show("You must fill necessary fields!" , "Entry error" ,MessageBoxButtons::OK,MessageBoxIcon::Exclamation);

Информация о работе Управление информацией в автобусном парке