Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include <stdlib.h>
- #include "Unit1.h"
- #include "Unit2.h"
- #include "Fly.h"
- #include "Person.h"
- #include "Billet.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- Flight *F;
- Passenger *P;
- Tickets *T;
- int q=0;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- F->Add();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button3Click(TObject *Sender)
- {
- P->Add();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button4Click(TObject *Sender)
- {
- P->Del();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button5Click(TObject *Sender)
- {
- T->Add();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::N1Click(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormActivate(TObject *Sender)
- {
- F->Refresh();
- P->Refresh();
- T->Refresh();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::refresh(){
- T->Refcomb();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- T->Adaptability();
- F->Adaptability();
- P->Adaptability();
- refresh();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::PageControl1Change(TObject *Sender)
- {
- refresh();
- T->Adaptability();
- F->Adaptability();
- P->Adaptability();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button6Click(TObject *Sender)
- {
- T->Del();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button7Click(TObject *Sender)
- {
- T->Print();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormResize(TObject *Sender)
- {
- T->Adaptability();
- F->Adaptability();
- P->Adaptability();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- F->Del();
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- #ifndef Unit1H
- #define Unit1H
- //---------------------------------------------------------------------------
- #include <System.Classes.hpp>
- #include <Vcl.Controls.hpp>
- #include <Vcl.StdCtrls.hpp>
- #include <Vcl.Forms.hpp>
- #include <Vcl.Menus.hpp>
- #include <Vcl.ComCtrls.hpp>
- #include <Vcl.Grids.hpp>
- #include <Vcl.ExtCtrls.hpp>
- #include <Data.DB.hpp>
- #include <Data.Win.ADODB.hpp>
- #include <Vcl.DBGrids.hpp>
- //---------------------------------------------------------------------------
- class TForm1 : public TForm
- {
- __published: // IDE-managed Components
- TMainMenu *MainMenu1;
- TMenuItem *hf1;
- TPageControl *PageControl1;
- TTabSheet *TabSheet1;
- TTabSheet *TabSheet2;
- TTabSheet *TabSheet3;
- TLabel *Label1;
- TEdit *Edit1;
- TLabel *Label2;
- TEdit *Edit2;
- TLabel *Label3;
- TEdit *Edit3;
- TLabel *Label4;
- TLabel *Label5;
- TLabel *Label6;
- TLabel *Label7;
- TButton *Button1;
- TEdit *Edit4;
- TDateTimePicker *DateTimePicker1;
- TDateTimePicker *DateTimePicker2;
- TLabel *Label8;
- TButton *Button2;
- TDateTimePicker *DateTimePicker3;
- TEdit *Edit5;
- TLabel *Label9;
- TEdit *Edit6;
- TLabel *Label10;
- TEdit *Edit7;
- TLabel *Label11;
- TEdit *Edit8;
- TLabel *Label12;
- TDateTimePicker *DateTimePicker4;
- TPanel *Panel1;
- TPanel *Panel2;
- TButton *Button3;
- TButton *Button4;
- TPanel *Panel3;
- TComboBox *ComboBox1;
- TComboBox *ComboBox2;
- TLabel *Label13;
- TLabel *Label14;
- TButton *Button5;
- TButton *Button6;
- TMenuItem *N1;
- TDBGrid *DBGrid1;
- TADOConnection *ADOConnection1;
- TADOTable *ADOTable1;
- TDataSource *DataSource1;
- TPanel *Panel4;
- TADOTable *ADOTable2;
- TDBGrid *DBGrid2;
- TPanel *Panel5;
- TDataSource *DataSource2;
- TADOTable *ADOTable3;
- TDataSource *DataSource3;
- TDBGrid *DBGrid3;
- TButton *Button7;
- TLabel *Label15;
- TLabel *Label16;
- TDateTimePicker *DateTimePicker5;
- void __fastcall Button1Click(TObject *Sender);
- void __fastcall Button3Click(TObject *Sender);
- void __fastcall Button4Click(TObject *Sender);
- void __fastcall Button5Click(TObject *Sender);
- void __fastcall N1Click(TObject *Sender);
- void __fastcall refresh();
- void __fastcall FormActivate(TObject *Sender);
- void __fastcall FormCreate(TObject *Sender);
- void __fastcall PageControl1Change(TObject *Sender);
- void __fastcall Button6Click(TObject *Sender);
- void __fastcall Button7Click(TObject *Sender);
- void __fastcall FormResize(TObject *Sender);
- void __fastcall Button2Click(TObject *Sender);
- private: // User declarations
- public: // User declarations
- __fastcall TForm1(TComponent* Owner);
- };
- //---------------------------------------------------------------------------
- extern PACKAGE TForm1 *Form1;
- //---------------------------------------------------------------------------
- #endif
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit2.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm2 *Form2;
- //---------------------------------------------------------------------------
- __fastcall TForm2::TForm2(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm2::Button1Click(TObject *Sender)
- {
- Button1->Visible=false;
- Form2->Print();
- Form2->Visible=false;
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- #ifndef Unit2H
- #define Unit2H
- //---------------------------------------------------------------------------
- #include <System.Classes.hpp>
- #include <Vcl.Controls.hpp>
- #include <Vcl.StdCtrls.hpp>
- #include <Vcl.Forms.hpp>
- #include <Vcl.ExtCtrls.hpp>
- #include <Vcl.Imaging.pngimage.hpp>
- //---------------------------------------------------------------------------
- class TForm2 : public TForm
- {
- __published: // IDE-managed Components
- TLabel *Label1;
- TLabel *Label2;
- TLabel *Label3;
- TLabel *Label4;
- TLabel *Label5;
- TLabel *Label6;
- TLabel *Label7;
- TLabel *Label8;
- TLabel *Label9;
- TEdit *Edit1;
- TEdit *Edit2;
- TEdit *Edit3;
- TEdit *Edit4;
- TEdit *Edit5;
- TEdit *Edit6;
- TEdit *Edit7;
- TEdit *Edit8;
- TEdit *Edit9;
- TButton *Button1;
- TLabel *Label10;
- TEdit *Edit10;
- TEdit *Edit11;
- TLabel *Label11;
- TPanel *Panel1;
- TPanel *Panel2;
- TImage *Image1;
- TPanel *Panel3;
- void __fastcall Button1Click(TObject *Sender);
- private: // User declarations
- public: // User declarations
- __fastcall TForm2(TComponent* Owner);
- };
- //---------------------------------------------------------------------------
- extern PACKAGE TForm2 *Form2;
- //---------------------------------------------------------------------------
- #endif
- //---------------------------------------------------------------------------
- #pragma hdrstop
- #include "Billet.h"
- #include <vcl.h>
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- int q=0;
- //---------------------------------------------------------------------------
- void Tickets::Add(){
- int test=0;
- for (int i = 1; i <= Form1->DBGrid1->DataSource->DataSet->RecordCount; i++) {
- Form1->DBGrid1->DataSource->DataSet->RecNo = i;
- if(Form1->DBGrid1->Columns->Items[0]->Field->AsString==Form1->ComboBox1->Items->Strings[Form1->ComboBox1->ItemIndex]){
- q=i;
- }
- }
- Form1->DBGrid1->DataSource->DataSet->RecNo=q;
- if (StrToInt(Form1->DBGrid1->Columns->Items[8]->Field->AsString)!=0) {
- test=StrToInt(Form1->DBGrid1->Columns->Items[8]->Field->AsString)-1;
- Form1->ADOTable1->Edit();
- Form1->ADOTable1->FieldByName("Осталось мест")->AsString =test;
- Form1->ADOTable1->Post();
- Form1->ADOTable3->Insert();
- randomize();
- Form1->ADOTable3->FieldByName("№ Билета")->AsString = random(9999999);
- Form1->ADOTable3->FieldByName("Пассажир")->AsString = Form1->ComboBox2->Items->Strings[Form1->ComboBox2->ItemIndex];
- Form1->ADOTable3->FieldByName("Авиарейс")->AsString = Form1->ComboBox1->Items->Strings[Form1->ComboBox1->ItemIndex];
- Form1->ADOTable3->Post();
- }
- else {
- ShowMessage("Билетов на этот рейс больше нет");
- }
- }
- //-----------------------------------------------------------------------------
- void Tickets::Del(){
- int test= 0;
- if (Form1->DBGrid3->DataSource->DataSet->RecordCount!=0) {
- for (int i = 1; i <= Form1->DBGrid1->DataSource->DataSet->RecordCount; i++) {
- Form1->DBGrid1->DataSource->DataSet->RecNo = i;
- if(Form1->DBGrid1->Columns->Items[0]->Field->AsString==Form1->DBGrid3->Columns->Items[2]->Field->AsString){
- q=i;
- }
- }
- Form1->DBGrid1->DataSource->DataSet->RecNo=q;
- test=StrToInt(Form1->DBGrid1->Columns->Items[8]->Field->AsString)+1;
- Form1->ADOTable1->Edit();
- Form1->ADOTable1->FieldByName("Осталось мест")->AsString =test;
- Form1->ADOTable1->Post();
- Form1->ADOTable3->Delete();
- }
- else{
- ShowMessage("Добавьте билет");
- }
- }
- //-----------------------------------------------------------------------------
- void Tickets::Refresh(){
- Form1->DBGrid3->Refresh();
- }
- void Tickets::Adaptability(){
- for (int i=0;i<3;i++){
- Form1->DBGrid3->Columns->Items[i]->Width = (Form1->DBGrid3->Width/3)-10;
- }
- }
- //-----------------------------------------------------------------------------
- void Tickets::Refcomb(){
- Form1->ComboBox1->Clear();
- Form1->ComboBox2->Clear();
- for (int i = 1; i <= Form1->DBGrid1->DataSource->DataSet->RecordCount; i++) {
- Form1->DBGrid1->DataSource->DataSet->RecNo = i;
- Form1->ComboBox1->Items->Add(Form1->DBGrid1->Columns->Items[0]->Field->AsString);
- }
- for (int i =1; i <= Form1->DBGrid2->DataSource->DataSet->RecordCount; i++) {
- Form1->DBGrid2->DataSource->DataSet->RecNo = i;
- Form1->ComboBox2->Items->Add(Form1->DBGrid2->Columns->Items[0]->Field->AsString);
- }
- }
- //-----------------------------------------------------------------------------
- void Tickets::Print(){
- int p=0;
- if (Form1->DBGrid3->DataSource->DataSet->RecordCount!=0) {
- for (int i = 1; i <= Form1->DBGrid1->DataSource->DataSet->RecordCount; i++) {
- Form1->DBGrid1->DataSource->DataSet->RecNo = i;
- if(Form1->DBGrid1->Columns->Items[0]->Field->AsString==Form1->DBGrid3->Columns->Items[2]->Field->AsString){
- q=i;
- }
- }
- for (int i = 1; i <= Form1->DBGrid2->DataSource->DataSet->RecordCount; i++) {
- Form1->DBGrid2->DataSource->DataSet->RecNo = i;
- if(Form1->DBGrid2->Columns->Items[0]->Field->AsString==Form1->DBGrid3->Columns->Items[1]->Field->AsString){
- p=i;
- }
- }
- Form1->DBGrid1->DataSource->DataSet->RecNo=q;
- Form1->DBGrid2->DataSource->DataSet->RecNo=p;
- Form2->Edit3->Text=Form1->DBGrid3->Columns->Items[2]->Field->AsString;
- Form2->Edit2->Text=Form1->DBGrid3->Columns->Items[1]->Field->AsString;
- Form2->Edit4->Text=Form1->DBGrid1->Columns->Items[1]->Field->AsString;
- Form2->Edit8->Text=Form1->DBGrid1->Columns->Items[2]->Field->AsString;
- Form2->Edit5->Text=Form1->DBGrid1->Columns->Items[3]->Field->AsString;
- Form2->Edit9->Text=Form1->DBGrid1->Columns->Items[5]->Field->AsString;
- Form2->Edit6->Text=Form1->DBGrid1->Columns->Items[4]->Field->AsString;
- Form2->Edit7->Text=Form1->DBGrid1->Columns->Items[6]->Field->AsString;
- Form2->Edit1->Text=Form1->DBGrid3->Columns->Items[0]->Field->AsString;
- Form2->Edit10->Text=Form1->DBGrid1->Columns->Items[9]->Field->AsString;
- Form2->Edit11->Text=Form1->DBGrid2->Columns->Items[2]->Field->AsString;
- Form2->Show();
- }
- else{
- ShowMessage("Добавьте билет");
- }
- }
- //---------------------------------------------------------------------------
- #ifndef BilletH
- #define BilletH
- #include "Unit1.h"
- #include "Unit2.h"
- //---------------------------------------------------------------------------
- class Tickets{
- public:
- void Add();
- void Del();
- void Refresh();
- void Adaptability();
- void Refcomb();
- void Print();
- };
- #endif
- //---------------------------------------------------------------------------
- #pragma hdrstop
- #include "Person.h"
- #include <vcl.h>
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- //---------------------------------------------------------------------------
- void Passenger::Add(){
- Form1->ComboBox2->Clear();
- Form1->ADOTable2->Insert();
- Form1->ADOTable2->FieldByName("Номер/Серия паспорта")->AsString = Form1->Edit6->Text;
- Form1->ADOTable2->FieldByName("Место и дата выдачи")->AsString = Form1->Edit7->Text;
- Form1->ADOTable2->FieldByName("ФИО")->AsString = Form1->Edit8->Text;
- Form1->ADOTable2->FieldByName("Дата рождения")->AsString = Form1->DateTimePicker4->Date.FormatString("dd.MM.yyyy");
- Form1->ADOTable2->Post();
- }
- //---------------------------------------------------------------------------
- void Passenger::Del(){
- if (Form1->DBGrid2->DataSource->DataSet->RecordCount!=0) {
- Form1->ComboBox2->Clear();
- Form1->ADOTable2->Delete();
- }
- else{
- ShowMessage("Добавьте пассажира");
- }
- }
- //----------------------------------------------------------------------------
- void Passenger::Refresh(){
- Form1->DBGrid2->Refresh();
- }
- //----------------------------------------------------------------------------
- void Passenger::Adaptability(){
- for (int i=0;i<4;i++){
- Form1->DBGrid2->Columns->Items[i]->Width = (Form1->DBGrid2->Width/4)-5;
- }
- }
- //---------------------------------------------------------------------------
- #ifndef PersonH
- #define PersonH
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- class Passenger{
- public:
- void Add();
- void Del();
- void Refresh();
- void Adaptability();
- };
- #endif
- //---------------------------------------------------------------------------
- #pragma hdrstop
- #include "Fly.h"
- #include <vcl.h>
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- //---------------------------------------------------------------------------
- void Flight::Add(){
- Form1->ADOTable1->Insert();
- Form1->ADOTable1->FieldByName("ID Рейса")->AsInteger = StrToInt(Form1->Edit1->Text);
- Form1->ADOTable1->FieldByName("Аэропорт Отпр")->AsString = Form1->Edit2->Text;
- Form1->ADOTable1->FieldByName("Аэропорт Приб")->AsString = Form1->Edit3->Text;
- Form1->ADOTable1->FieldByName("Дата Отпр")->AsString =Form1->DateTimePicker1->Date.FormatString("dd.MM.yyyy");
- Form1->ADOTable1->FieldByName("Время Отпр")->AsString =Form1->DateTimePicker3->Date.FormatString("HH:mm");
- Form1->ADOTable1->FieldByName("Дата Приб")->AsString =Form1->DateTimePicker2->Date.FormatString("dd.MM.yyyy");
- Form1->ADOTable1->FieldByName("Стоимость")->AsString =Form1->Edit5->Text+" "+L"руб";
- Form1->ADOTable1->FieldByName("Колич мест")->AsString =Form1->Edit4->Text;
- Form1->ADOTable1->FieldByName("Осталось мест")->AsString =Form1->Edit4->Text;
- Form1->ADOTable1->FieldByName("Время прилета")->AsString =Form1->DateTimePicker5->Date.FormatString("HH:mm");
- Form1->ADOTable1->Post();
- }
- //---------------------------------------------------------------------------
- void Flight::Del(){
- if (Form1->DBGrid1->DataSource->DataSet->RecordCount!=0) {
- Form1->ADOTable1->Delete();
- }
- else {
- ShowMessage("Добавьте рейс");
- }
- }
- //---------------------------------------------------------------------------
- void Flight::Refresh(){
- Form1->DBGrid1->Refresh();
- }
- //---------------------------------------------------------------------------
- void Flight::Adaptability(){
- for (int i=0;i<10;i++){
- Form1->DBGrid1->Columns->Items[i]->Width = (Form1->DBGrid1->Width/10)-4;
- }
- }
- //---------------------------------------------------------------------------
- #ifndef FlyH
- #define FlyH
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- class Flight{
- public:
- void Add();
- void Refresh();
- void Del();
- void Adaptability();
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement