Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 16.88 KB | None | 0 0
  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #pragma hdrstop
  5. #include <stdlib.h>
  6. #include "Unit1.h"
  7. #include "Unit2.h"
  8. #include "Fly.h"
  9. #include "Person.h"
  10. #include "Billet.h"
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma resource "*.dfm"
  14. TForm1 *Form1;
  15. Flight *F;
  16. Passenger *P;
  17. Tickets *T;
  18. int q=0;
  19. //---------------------------------------------------------------------------
  20. __fastcall TForm1::TForm1(TComponent* Owner)
  21.     : TForm(Owner)
  22. {
  23.  
  24. }
  25. //---------------------------------------------------------------------------
  26.  
  27. void __fastcall TForm1::Button1Click(TObject *Sender)
  28. {
  29.     F->Add();
  30. }
  31. //---------------------------------------------------------------------------
  32.  
  33. void __fastcall TForm1::Button3Click(TObject *Sender)
  34. {
  35.     P->Add();
  36. }
  37. //---------------------------------------------------------------------------
  38.  
  39. void __fastcall TForm1::Button4Click(TObject *Sender)
  40. {
  41.     P->Del();
  42. }
  43. //---------------------------------------------------------------------------
  44. void __fastcall TForm1::Button5Click(TObject *Sender)
  45. {
  46.     T->Add();
  47. }
  48. //---------------------------------------------------------------------------
  49.  
  50. void __fastcall TForm1::N1Click(TObject *Sender)
  51. {
  52.     Close();
  53. }
  54. //---------------------------------------------------------------------------
  55.  
  56. void __fastcall TForm1::FormActivate(TObject *Sender)
  57. {
  58.     F->Refresh();
  59.     P->Refresh();
  60.     T->Refresh();
  61.  
  62. }
  63. //---------------------------------------------------------------------------
  64.  
  65. void __fastcall TForm1::refresh(){
  66.     T->Refcomb();
  67. }
  68. //---------------------------------------------------------------------------
  69.  
  70. void __fastcall TForm1::FormCreate(TObject *Sender)
  71. {
  72.     T->Adaptability();
  73.     F->Adaptability();
  74.     P->Adaptability();
  75.     refresh();
  76. }
  77. //---------------------------------------------------------------------------
  78.  
  79. void __fastcall TForm1::PageControl1Change(TObject *Sender)
  80. {
  81.     refresh();
  82.     T->Adaptability();
  83.     F->Adaptability();
  84.     P->Adaptability();
  85.  }
  86. //---------------------------------------------------------------------------
  87.  
  88. void __fastcall TForm1::Button6Click(TObject *Sender)
  89. {
  90.     T->Del();
  91. }
  92. //---------------------------------------------------------------------------
  93.  
  94. void __fastcall TForm1::Button7Click(TObject *Sender)
  95. {
  96.     T->Print();
  97. }
  98. //---------------------------------------------------------------------------
  99.  
  100.  
  101. void __fastcall TForm1::FormResize(TObject *Sender)
  102. {
  103.     T->Adaptability();
  104.     F->Adaptability();
  105.     P->Adaptability();
  106. }
  107. //---------------------------------------------------------------------------
  108. void __fastcall TForm1::Button2Click(TObject *Sender)
  109. {
  110.     F->Del();
  111. }
  112. //---------------------------------------------------------------------------
  113. //---------------------------------------------------------------------------
  114.  
  115. #ifndef Unit1H
  116. #define Unit1H
  117. //---------------------------------------------------------------------------
  118. #include <System.Classes.hpp>
  119. #include <Vcl.Controls.hpp>
  120. #include <Vcl.StdCtrls.hpp>
  121. #include <Vcl.Forms.hpp>
  122. #include <Vcl.Menus.hpp>
  123. #include <Vcl.ComCtrls.hpp>
  124. #include <Vcl.Grids.hpp>
  125. #include <Vcl.ExtCtrls.hpp>
  126. #include <Data.DB.hpp>
  127. #include <Data.Win.ADODB.hpp>
  128. #include <Vcl.DBGrids.hpp>
  129. //---------------------------------------------------------------------------
  130. class TForm1 : public TForm
  131. {
  132. __published:    // IDE-managed Components
  133.     TMainMenu *MainMenu1;
  134.     TMenuItem *hf1;
  135.     TPageControl *PageControl1;
  136.     TTabSheet *TabSheet1;
  137.     TTabSheet *TabSheet2;
  138.     TTabSheet *TabSheet3;
  139.     TLabel *Label1;
  140.     TEdit *Edit1;
  141.     TLabel *Label2;
  142.     TEdit *Edit2;
  143.     TLabel *Label3;
  144.     TEdit *Edit3;
  145.     TLabel *Label4;
  146.     TLabel *Label5;
  147.     TLabel *Label6;
  148.     TLabel *Label7;
  149.     TButton *Button1;
  150.     TEdit *Edit4;
  151.     TDateTimePicker *DateTimePicker1;
  152.     TDateTimePicker *DateTimePicker2;
  153.     TLabel *Label8;
  154.     TButton *Button2;
  155.     TDateTimePicker *DateTimePicker3;
  156.     TEdit *Edit5;
  157.     TLabel *Label9;
  158.     TEdit *Edit6;
  159.     TLabel *Label10;
  160.     TEdit *Edit7;
  161.     TLabel *Label11;
  162.     TEdit *Edit8;
  163.     TLabel *Label12;
  164.     TDateTimePicker *DateTimePicker4;
  165.     TPanel *Panel1;
  166.     TPanel *Panel2;
  167.     TButton *Button3;
  168.     TButton *Button4;
  169.     TPanel *Panel3;
  170.     TComboBox *ComboBox1;
  171.     TComboBox *ComboBox2;
  172.     TLabel *Label13;
  173.     TLabel *Label14;
  174.     TButton *Button5;
  175.     TButton *Button6;
  176.     TMenuItem *N1;
  177.     TDBGrid *DBGrid1;
  178.     TADOConnection *ADOConnection1;
  179.     TADOTable *ADOTable1;
  180.     TDataSource *DataSource1;
  181.     TPanel *Panel4;
  182.     TADOTable *ADOTable2;
  183.     TDBGrid *DBGrid2;
  184.     TPanel *Panel5;
  185.     TDataSource *DataSource2;
  186.     TADOTable *ADOTable3;
  187.     TDataSource *DataSource3;
  188.     TDBGrid *DBGrid3;
  189.     TButton *Button7;
  190.     TLabel *Label15;
  191.     TLabel *Label16;
  192.     TDateTimePicker *DateTimePicker5;
  193.     void __fastcall Button1Click(TObject *Sender);
  194.     void __fastcall Button3Click(TObject *Sender);
  195.     void __fastcall Button4Click(TObject *Sender);
  196.     void __fastcall Button5Click(TObject *Sender);
  197.     void __fastcall N1Click(TObject *Sender);
  198.     void __fastcall refresh();
  199.     void __fastcall FormActivate(TObject *Sender);
  200.     void __fastcall FormCreate(TObject *Sender);
  201.     void __fastcall PageControl1Change(TObject *Sender);
  202.     void __fastcall Button6Click(TObject *Sender);
  203.     void __fastcall Button7Click(TObject *Sender);
  204.     void __fastcall FormResize(TObject *Sender);
  205.     void __fastcall Button2Click(TObject *Sender);
  206.  
  207. private:    // User declarations
  208. public:     // User declarations
  209.     __fastcall TForm1(TComponent* Owner);
  210. };
  211. //---------------------------------------------------------------------------
  212. extern PACKAGE TForm1 *Form1;
  213. //---------------------------------------------------------------------------
  214. #endif
  215. //---------------------------------------------------------------------------
  216.  
  217. #include <vcl.h>
  218. #pragma hdrstop
  219.  
  220. #include "Unit2.h"
  221. //---------------------------------------------------------------------------
  222. #pragma package(smart_init)
  223. #pragma resource "*.dfm"
  224. TForm2 *Form2;
  225. //---------------------------------------------------------------------------
  226. __fastcall TForm2::TForm2(TComponent* Owner)
  227.     : TForm(Owner)
  228. {
  229. }
  230. //---------------------------------------------------------------------------
  231. void __fastcall TForm2::Button1Click(TObject *Sender)
  232. {
  233. Button1->Visible=false;
  234. Form2->Print();
  235. Form2->Visible=false;
  236. }
  237. //---------------------------------------------------------------------------
  238. //---------------------------------------------------------------------------
  239.  
  240. #ifndef Unit2H
  241. #define Unit2H
  242. //---------------------------------------------------------------------------
  243. #include <System.Classes.hpp>
  244. #include <Vcl.Controls.hpp>
  245. #include <Vcl.StdCtrls.hpp>
  246. #include <Vcl.Forms.hpp>
  247. #include <Vcl.ExtCtrls.hpp>
  248. #include <Vcl.Imaging.pngimage.hpp>
  249. //---------------------------------------------------------------------------
  250. class TForm2 : public TForm
  251. {
  252. __published:    // IDE-managed Components
  253.     TLabel *Label1;
  254.     TLabel *Label2;
  255.     TLabel *Label3;
  256.     TLabel *Label4;
  257.     TLabel *Label5;
  258.     TLabel *Label6;
  259.     TLabel *Label7;
  260.     TLabel *Label8;
  261.     TLabel *Label9;
  262.     TEdit *Edit1;
  263.     TEdit *Edit2;
  264.     TEdit *Edit3;
  265.     TEdit *Edit4;
  266.     TEdit *Edit5;
  267.     TEdit *Edit6;
  268.     TEdit *Edit7;
  269.     TEdit *Edit8;
  270.     TEdit *Edit9;
  271.     TButton *Button1;
  272.     TLabel *Label10;
  273.     TEdit *Edit10;
  274.     TEdit *Edit11;
  275.     TLabel *Label11;
  276.     TPanel *Panel1;
  277.     TPanel *Panel2;
  278.     TImage *Image1;
  279.     TPanel *Panel3;
  280.     void __fastcall Button1Click(TObject *Sender);
  281. private:    // User declarations
  282. public:     // User declarations
  283.     __fastcall TForm2(TComponent* Owner);
  284. };
  285. //---------------------------------------------------------------------------
  286. extern PACKAGE TForm2 *Form2;
  287. //---------------------------------------------------------------------------
  288. #endif
  289. //---------------------------------------------------------------------------
  290.  
  291. #pragma hdrstop
  292.  
  293. #include "Billet.h"
  294. #include <vcl.h>
  295. //---------------------------------------------------------------------------
  296. #pragma package(smart_init)
  297. int q=0;
  298. //---------------------------------------------------------------------------
  299. void Tickets::Add(){
  300.     int test=0;
  301.     for (int i = 1; i <= Form1->DBGrid1->DataSource->DataSet->RecordCount; i++) {
  302.         Form1->DBGrid1->DataSource->DataSet->RecNo = i;
  303.         if(Form1->DBGrid1->Columns->Items[0]->Field->AsString==Form1->ComboBox1->Items->Strings[Form1->ComboBox1->ItemIndex]){
  304.         q=i;
  305.         }
  306.     }
  307.     Form1->DBGrid1->DataSource->DataSet->RecNo=q;
  308.     if (StrToInt(Form1->DBGrid1->Columns->Items[8]->Field->AsString)!=0) {
  309.         test=StrToInt(Form1->DBGrid1->Columns->Items[8]->Field->AsString)-1;
  310.         Form1->ADOTable1->Edit();
  311.         Form1->ADOTable1->FieldByName("Осталось мест")->AsString =test;
  312.         Form1->ADOTable1->Post();
  313.         Form1->ADOTable3->Insert();
  314.         randomize();
  315.         Form1->ADOTable3->FieldByName("№ Билета")->AsString = random(9999999);
  316.         Form1->ADOTable3->FieldByName("Пассажир")->AsString = Form1->ComboBox2->Items->Strings[Form1->ComboBox2->ItemIndex];
  317.         Form1->ADOTable3->FieldByName("Авиарейс")->AsString = Form1->ComboBox1->Items->Strings[Form1->ComboBox1->ItemIndex];
  318.         Form1->ADOTable3->Post();
  319.     }
  320.     else {
  321.         ShowMessage("Билетов на этот рейс больше нет");
  322.     }
  323. }
  324. //-----------------------------------------------------------------------------
  325.  
  326. void Tickets::Del(){
  327.         int test= 0;
  328.     if (Form1->DBGrid3->DataSource->DataSet->RecordCount!=0) {
  329.     for (int i = 1; i <= Form1->DBGrid1->DataSource->DataSet->RecordCount; i++) {
  330.         Form1->DBGrid1->DataSource->DataSet->RecNo = i;
  331.         if(Form1->DBGrid1->Columns->Items[0]->Field->AsString==Form1->DBGrid3->Columns->Items[2]->Field->AsString){
  332.         q=i;
  333.         }
  334.     }
  335.     Form1->DBGrid1->DataSource->DataSet->RecNo=q;
  336.     test=StrToInt(Form1->DBGrid1->Columns->Items[8]->Field->AsString)+1;
  337.     Form1->ADOTable1->Edit();
  338.     Form1->ADOTable1->FieldByName("Осталось мест")->AsString =test;
  339.     Form1->ADOTable1->Post();
  340.     Form1->ADOTable3->Delete();
  341.     }
  342.     else{
  343.     ShowMessage("Добавьте билет");
  344.     }
  345. }
  346. //-----------------------------------------------------------------------------
  347.  
  348. void Tickets::Refresh(){
  349.     Form1->DBGrid3->Refresh();
  350. }
  351. void Tickets::Adaptability(){
  352.     for (int i=0;i<3;i++){
  353.         Form1->DBGrid3->Columns->Items[i]->Width = (Form1->DBGrid3->Width/3)-10;
  354.     }
  355. }
  356. //-----------------------------------------------------------------------------
  357.  
  358. void Tickets::Refcomb(){
  359.     Form1->ComboBox1->Clear();
  360.     Form1->ComboBox2->Clear();
  361.     for (int i = 1; i <= Form1->DBGrid1->DataSource->DataSet->RecordCount; i++) {
  362.         Form1->DBGrid1->DataSource->DataSet->RecNo = i;
  363.         Form1->ComboBox1->Items->Add(Form1->DBGrid1->Columns->Items[0]->Field->AsString);
  364.     }
  365.     for (int i =1; i <= Form1->DBGrid2->DataSource->DataSet->RecordCount; i++) {
  366.         Form1->DBGrid2->DataSource->DataSet->RecNo = i;
  367.         Form1->ComboBox2->Items->Add(Form1->DBGrid2->Columns->Items[0]->Field->AsString);
  368.     }
  369. }
  370. //-----------------------------------------------------------------------------
  371.  
  372. void Tickets::Print(){
  373.     int p=0;
  374. if (Form1->DBGrid3->DataSource->DataSet->RecordCount!=0) {
  375.         for (int i = 1; i <= Form1->DBGrid1->DataSource->DataSet->RecordCount; i++) {
  376.         Form1->DBGrid1->DataSource->DataSet->RecNo = i;
  377.         if(Form1->DBGrid1->Columns->Items[0]->Field->AsString==Form1->DBGrid3->Columns->Items[2]->Field->AsString){
  378.         q=i;
  379.         }
  380.     }
  381.     for (int i = 1; i <= Form1->DBGrid2->DataSource->DataSet->RecordCount; i++) {
  382.         Form1->DBGrid2->DataSource->DataSet->RecNo = i;
  383.         if(Form1->DBGrid2->Columns->Items[0]->Field->AsString==Form1->DBGrid3->Columns->Items[1]->Field->AsString){
  384.         p=i;
  385.         }
  386.     }
  387.     Form1->DBGrid1->DataSource->DataSet->RecNo=q;
  388.     Form1->DBGrid2->DataSource->DataSet->RecNo=p;
  389.     Form2->Edit3->Text=Form1->DBGrid3->Columns->Items[2]->Field->AsString;
  390.     Form2->Edit2->Text=Form1->DBGrid3->Columns->Items[1]->Field->AsString;
  391.     Form2->Edit4->Text=Form1->DBGrid1->Columns->Items[1]->Field->AsString;
  392.     Form2->Edit8->Text=Form1->DBGrid1->Columns->Items[2]->Field->AsString;
  393.     Form2->Edit5->Text=Form1->DBGrid1->Columns->Items[3]->Field->AsString;
  394.     Form2->Edit9->Text=Form1->DBGrid1->Columns->Items[5]->Field->AsString;
  395.     Form2->Edit6->Text=Form1->DBGrid1->Columns->Items[4]->Field->AsString;
  396.     Form2->Edit7->Text=Form1->DBGrid1->Columns->Items[6]->Field->AsString;
  397.     Form2->Edit1->Text=Form1->DBGrid3->Columns->Items[0]->Field->AsString;
  398.     Form2->Edit10->Text=Form1->DBGrid1->Columns->Items[9]->Field->AsString;
  399.     Form2->Edit11->Text=Form1->DBGrid2->Columns->Items[2]->Field->AsString;
  400.     Form2->Show();
  401. }
  402.  else{
  403.  ShowMessage("Добавьте билет");
  404.  }
  405. }
  406.  
  407. //---------------------------------------------------------------------------
  408.  
  409. #ifndef BilletH
  410. #define BilletH
  411. #include "Unit1.h"
  412. #include "Unit2.h"
  413. //---------------------------------------------------------------------------
  414.     class Tickets{
  415.       public:
  416.       void Add();
  417.       void Del();
  418.       void Refresh();
  419.       void Adaptability();
  420.       void Refcomb();
  421.       void Print();
  422.     };
  423.  
  424. #endif
  425. //---------------------------------------------------------------------------
  426.  
  427. #pragma hdrstop
  428.  
  429. #include "Person.h"
  430. #include <vcl.h>
  431. //---------------------------------------------------------------------------
  432. #pragma package(smart_init)
  433. //---------------------------------------------------------------------------
  434.  
  435. void Passenger::Add(){
  436.     Form1->ComboBox2->Clear();
  437.     Form1->ADOTable2->Insert();
  438.     Form1->ADOTable2->FieldByName("Номер/Серия  паспорта")->AsString = Form1->Edit6->Text;
  439.     Form1->ADOTable2->FieldByName("Место и дата выдачи")->AsString = Form1->Edit7->Text;
  440.     Form1->ADOTable2->FieldByName("ФИО")->AsString = Form1->Edit8->Text;
  441.     Form1->ADOTable2->FieldByName("Дата рождения")->AsString = Form1->DateTimePicker4->Date.FormatString("dd.MM.yyyy");
  442.     Form1->ADOTable2->Post();
  443.  
  444. }
  445. //---------------------------------------------------------------------------
  446.  
  447. void Passenger::Del(){
  448.     if (Form1->DBGrid2->DataSource->DataSet->RecordCount!=0) {
  449.     Form1->ComboBox2->Clear();
  450.     Form1->ADOTable2->Delete();
  451.     }
  452.     else{
  453.     ShowMessage("Добавьте пассажира");
  454.     }
  455. }
  456. //----------------------------------------------------------------------------
  457.  
  458. void Passenger::Refresh(){
  459.    Form1->DBGrid2->Refresh();
  460. }
  461. //----------------------------------------------------------------------------
  462. void Passenger::Adaptability(){
  463.     for (int i=0;i<4;i++){
  464.         Form1->DBGrid2->Columns->Items[i]->Width = (Form1->DBGrid2->Width/4)-5;
  465.     }
  466. }
  467. //---------------------------------------------------------------------------
  468.  
  469. #ifndef PersonH
  470. #define PersonH
  471. #include "Unit1.h"
  472. //---------------------------------------------------------------------------
  473.     class Passenger{
  474.       public:
  475.       void Add();
  476.       void Del();
  477.       void Refresh();
  478.       void Adaptability();
  479.     };
  480.  
  481. #endif
  482. //---------------------------------------------------------------------------
  483.  
  484. #pragma hdrstop
  485.  
  486. #include "Fly.h"
  487. #include <vcl.h>
  488. //---------------------------------------------------------------------------
  489. #pragma package(smart_init)
  490. //---------------------------------------------------------------------------
  491.  
  492. void Flight::Add(){
  493.     Form1->ADOTable1->Insert();
  494.     Form1->ADOTable1->FieldByName("ID Рейса")->AsInteger = StrToInt(Form1->Edit1->Text);
  495.     Form1->ADOTable1->FieldByName("Аэропорт Отпр")->AsString = Form1->Edit2->Text;
  496.     Form1->ADOTable1->FieldByName("Аэропорт Приб")->AsString = Form1->Edit3->Text;
  497.     Form1->ADOTable1->FieldByName("Дата Отпр")->AsString =Form1->DateTimePicker1->Date.FormatString("dd.MM.yyyy");
  498.     Form1->ADOTable1->FieldByName("Время Отпр")->AsString =Form1->DateTimePicker3->Date.FormatString("HH:mm");
  499.     Form1->ADOTable1->FieldByName("Дата Приб")->AsString =Form1->DateTimePicker2->Date.FormatString("dd.MM.yyyy");
  500.     Form1->ADOTable1->FieldByName("Стоимость")->AsString =Form1->Edit5->Text+" "+L"руб";
  501.     Form1->ADOTable1->FieldByName("Колич мест")->AsString =Form1->Edit4->Text;
  502.     Form1->ADOTable1->FieldByName("Осталось мест")->AsString =Form1->Edit4->Text;
  503.     Form1->ADOTable1->FieldByName("Время прилета")->AsString =Form1->DateTimePicker5->Date.FormatString("HH:mm");
  504.     Form1->ADOTable1->Post();
  505. }
  506. //---------------------------------------------------------------------------
  507.  
  508. void Flight::Del(){
  509.     if (Form1->DBGrid1->DataSource->DataSet->RecordCount!=0) {
  510.         Form1->ADOTable1->Delete();
  511.     }
  512.     else {
  513.         ShowMessage("Добавьте рейс");
  514.     }
  515. }
  516. //---------------------------------------------------------------------------
  517.  
  518. void Flight::Refresh(){
  519. Form1->DBGrid1->Refresh();
  520. }
  521. //---------------------------------------------------------------------------
  522. void Flight::Adaptability(){
  523.     for (int i=0;i<10;i++){
  524.         Form1->DBGrid1->Columns->Items[i]->Width = (Form1->DBGrid1->Width/10)-4;
  525.     }
  526. }
  527. //---------------------------------------------------------------------------
  528.  
  529. #ifndef FlyH
  530. #define FlyH
  531. #include "Unit1.h"
  532. //---------------------------------------------------------------------------
  533. class Flight{
  534.   public:
  535.   void Add();
  536.   void Refresh();
  537.   void Del();
  538.   void Adaptability();
  539. };
  540.  
  541. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement