-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpurchase.cpp
207 lines (191 loc) · 6.43 KB
/
purchase.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "main.h"
#include "purchase.h"
#include "room.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "frxClass"
#pragma link "frxDBSet"
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::search_ticketClick(TObject *Sender)
{
if (flights->Text == "Ðåéñû")
ShowMessage("Âûáåðèòå ðåéñ!");
else {
String divisor = "4";
if (ticket_type[1] == 'e')
divisor = "2";
Form1->ADOQuery1->Close();
Form1->ADOQuery1->SQL->Clear();
Form1->ADOQuery1->SQL->Add("\
SELECT Ñàìîëåòû.Êîë_âî_ìåñò/" + divisor + " - \
(\
SELECT COUNT(Áèëåòû.Íîìåð_áèëåòà)\
FROM\
Áèëåòû\
INNER JOIN Ðåéñû\
ON Áèëåòû.Íîìåð_ðåéñà = Ðåéñû.Íîìåð_ðåéñà\
WHERE\
Áèëåòû.Òèï_áèëåòà = '" + ticket_type + "'\
AND\
Ðåéñû.Íîìåð_ðåéñà = '" + n_fl + "'\
)\
FROM\
Ñàìîëåòû\
INNER JOIN Ðåéñû\
ON Ñàìîëåòû.Íîìåð_ñàìîëåòà = Ðåéñû.Íîìåð_ñàìîëåòà\
WHERE\
Ðåéñû.Íîìåð_ðåéñà = '" + n_fl + "'");
Form1->ADOQuery1->Open();
number_ticket_amount->Caption =\
Form1->ADOQuery1->Fields->Fields[0]->AsString;
caption_ticket_amount->Visible = true;
number_ticket_amount->Visible = true;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::ComboBox1Select(TObject *Sender)
{
Form1->ADOQuery1->Active = false;
Form1->ADOQuery1->SQL->Text = "SELECT DISTINCT Ïóíêò_íàçíà÷åíèÿ FROM Ðåéñû\
WHERE Ïóíêò_îòïðàâëåíèÿ = '" + ComboBox1->Text + "'";
Form1->ADOQuery1->Active = true;
ComboBox2->Items->Clear();
for (; !Form1->ADOQuery1->Eof; Form1->ADOQuery1->Next())
ComboBox2->Items->Add\
(Form1->ADOQuery1->FieldByName("Ïóíêò_íàçíà÷åíèÿ")->AsString);
ComboBox2->ItemIndex=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::search_flightClick(TObject *Sender)
{
String tim3;
Form1->ADOQuery1->Active = false;
Form1->ADOQuery1->SQL->Text = "SELECT\
CAST(Äàòà_âûëåòà AS DATE) [date],\
CAST(Âðåìÿ_âûëåòà AS TIME) [time]\
FROM Ðåéñû\
WHERE Ïóíêò_îòïðàâëåíèÿ = '" + ComboBox1->Text + \
"' AND Ïóíêò_íàçíà÷åíèÿ = '" + ComboBox2->Text + "'";
Form1->ADOQuery1->Active = true;
flights->Items->Clear();
for (; !Form1->ADOQuery1->Eof; Form1->ADOQuery1->Next()) {
tim3 = Form1->ADOQuery1->FieldByName("date")->AsString + "@" +\
Form1->ADOQuery1->FieldByName("time")->AsString;
tim3 = tim3.SubString(0,16);
flights->Items->Add(tim3);
}
flights->ItemIndex=0;
if (flights->Text.IsEmpty())
flights->Text = "Ðåéñû íå íàéäåíû"; else {
tim3 = flights->Text.SubString(12,5);
Form1->ADOQuery1->Close();
Form1->ADOQuery1->SQL->Clear();
Form1->ADOQuery1->SQL->Add("\
SELECT Íîìåð_ðåéñà\
FROM Ðåéñû\
WHERE\
Ïóíêò_îòïðàâëåíèÿ = '" + ComboBox1->Text + "' AND\
Ïóíêò_íàçíà÷åíèÿ = '" + ComboBox2->Text + "' AND\
CAST(Âðåìÿ_âûëåòà AS TIME) = '" + tim3 + "'");
Form1->ADOQuery1->Open();
n_fl = Form1->ADOQuery1->Fields->Fields[0]->AsString;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::RadioButton5Click(TObject *Sender)
{
ticket_type = "econom";
}
//---------------------------------------------------------------------------
void __fastcall TForm2::RadioButton4Click(TObject *Sender)
{
ticket_type = "busine";
}
//---------------------------------------------------------------------------
void __fastcall TForm2::RadioButton3Click(TObject *Sender)
{
ticket_type = "first";
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormClose(TObject *Sender, TCloseAction &Action)
{
Form1->ADOQuery1->Active = false;
Form1->ADOQuery1->SQL->Text = "SELECT * FROM Ðåéñû";
Form1->ADOQuery1->Active = true;
Form1->Show();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{
if ((flights->Text == "Ðåéñû íå íàéäåíû")
|| (flights->Text == "Ðåéñû"))
ShowMessage("Âûáåðèòå ðåéñ!");
else {
Form1->ADOQuery1->Close();
Form1->ADOQuery1->SQL->Clear();
Form1->ADOQuery1->SQL->Add("\
SELECT DISTINCT Èìÿ, Ôàìèëèÿ, Îò÷åñòâî,\
Äàòà_Ðîæäåíèÿ, Ïîë, Ñåðèÿ_ïàñïîðòà, Íîìåð_ïàñïîðòà\
FROM Ïàññàæèðû INNER JOIN Áèëåòû\
ON Ïàññàæèðû.Íîìåð_ïàññàæèðà = Áèëåòû.Íîìåð_ïàññàæèðà\
WHERE Íîìåð_ðåéñà = '" + n_fl + "'");
Form1->ADOQuery1->Open();
dynamic_cast <TfrxMemoView *>
(frxReport1->FindObject("Memo16"))->Text = n_fl;
dynamic_cast <TfrxMemoView *>
(frxReport1->FindObject("Memo17"))->Text =
ComboBox1->Text + " - " + ComboBox2->Text;
dynamic_cast <TfrxMemoView *>
(frxReport1->FindObject("Memo18"))->Text = flights->Text;
frxReport1->ShowReport(false);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::takeseatClick(TObject *Sender)
{
if ((flights->Text == "Ðåéñû íå íàéäåíû")
|| (flights->Text == "Ðåéñû"))
ShowMessage("Âûáåðèòå ðåéñ!");
else {
Form2->Hide();
Form3->Show();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::flightsSelect(TObject *Sender)
{
Form1->ADOQuery1->Close();
Form1->ADOQuery1->SQL->Clear();
Form1->ADOQuery1->SQL->Add("\
SELECT Íîìåð_ðåéñà\
FROM Ðåéñû\
WHERE\
Ïóíêò_îòïðàâëåíèÿ = '" + ComboBox1->Text + "' AND\
Ïóíêò_íàçíà÷åíèÿ = '" + ComboBox2->Text + "' AND\
CAST(Âðåìÿ_âûëåòà AS TIME) = '" + flights->Text + "'");
Form1->ADOQuery1->Open();
n_fl = Form1->ADOQuery1->Fields->Fields[0]->AsString;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormShow(TObject *Sender)
{
ticket_type = "econom";
Form1->ADOQuery1->Active = false;
Form1->ADOQuery1->SQL->Text = "SELECT DISTINCT Ïóíêò_îòïðàâëåíèÿ FROM Ðåéñû";
Form1->ADOQuery1->Active = true;
for (; !Form1->ADOQuery1->Eof; Form1->ADOQuery1->Next())
ComboBox1->Items->Add\
(Form1->ADOQuery1->FieldByName("Ïóíêò_îòïðàâëåíèÿ")->AsString);
ComboBox1->ItemIndex=0;
}
//---------------------------------------------------------------------------