-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfrmPassengerDetails.cs
307 lines (250 loc) · 10.8 KB
/
frmPassengerDetails.cs
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Cyanair_Airline_Booking_System
{
public partial class frmPassengerDetails : Form
{
//DATABASE CONNECTION
public CyanairDataConnection myNewCyanDatabaseConnection;
public SystemUsers mySystemUsers;
public FlightRoute OutboundFlight01;
public FlightRoute OutboundFlight02;
public frmPassengerDetails()
{
InitializeComponent();
}
//Creating an object from the Bookings Class (Bookings.cs)
public Bookings newBookingObject = new Bookings();
private void frmPassengerDetails_Load(object sender, EventArgs e)
{
//Focus on the first field
txtFullName.Focus();
lblOutwardFlightLeg1DepDest.Text =
OutboundFlight01.DepartAirportName + " TO " + OutboundFlight01.DestinAirportName;
lblOutwardFlightLeg1TimeDur.Text =
OutboundFlight01.TimeOfFlight + " - " + OutboundFlight01.Duration + " Minutes Duration";
//NEED A VALIDATION HERE !
lblOutwardFlightLeg2DepDest.Text =
OutboundFlight02.DepartAirportName + " TO " + OutboundFlight02.DestinAirportName;
lblOutwardFlightLeg2TimeDur.Text =
OutboundFlight02.TimeOfFlight + " - " + OutboundFlight02.Duration + " Minutes Duration";
//Maximise the screen
this.WindowState = FormWindowState.Maximized;
//Set Panel to Center of Screen - Fullscreen centered
pnlPassengerDetails.Left = (this.ClientSize.Width - pnlPassengerDetails.Size.Width) / 2;
/*=====================SETTING ATTRIBUTES========================*/
//1. FULL NAME
newBookingObject.fullname = "Iram Dev";
//2. PASSPORT NUMBER
newBookingObject.passportnumber = "PA1234567";
//3. NATIONALITY
newBookingObject.nationality = "Irish";
//4. PHONE NUMBER
newBookingObject.phonenumber = "0870123456";
//5. EMAIL ADDRESS
newBookingObject.emailaddress = "[email protected]";
//6. GENDER
newBookingObject.gender = "F";
}
private void btnMakeBooking_Click(object sender, EventArgs e)
{
/*=====================ensures that representative cannot proceed with booking
* until all of the fields have been filled========================*/
string warningErrorMessage = "";
//1. FULL NAME
if (txtFullName.Text != "")
{
newBookingObject.fullname = txtFullName.Text;
}
else
{
warningErrorMessage += "Please enter the Full Name of the Passenger" + Environment.NewLine;
}
//2. PASSPORT NUMBER
if (txtPassportNumber.Text != "")
{
newBookingObject.passportnumber = txtPassportNumber.Text;
}
else
{
warningErrorMessage += "Please enter the Passport Number of the Passenger" + Environment.NewLine;
}
//3. NATIONALITY
if (txtNationality.Text != "")
{
newBookingObject.nationality = txtNationality.Text;
}
else
{
warningErrorMessage += "Please enter the Nationality of the Passenger" + Environment.NewLine;
}
//4. PHONE NUMBER
if (txtPhoneNumber.Text != "")
{
newBookingObject.phonenumber = txtPhoneNumber.Text;
}
else
{
warningErrorMessage += "Please enter the Phone Number of the Passenger" + Environment.NewLine;
}
//5. EMAIL ADDRESS
if (txtEmailAddress.Text != "")
{
newBookingObject.emailaddress = txtEmailAddress.Text;
}
else
{
warningErrorMessage += "Please enter the Email Address of the Passenger" + Environment.NewLine;
}
//6. GENDER
if (txtGender.Text != "")
{
newBookingObject.gender = txtGender.Text;
}
else
{
warningErrorMessage += "Please enter the Gender of the Passenger";
}
if (warningErrorMessage != "")
{
MessageBox.Show(warningErrorMessage);
return;
}
else
{
//IF all fields are completed, the system will ask the flight representative to confirm the booking
//if YES --> proceeds to confirmation screen where it will generate a reference number
//if NO --> returns back to edit form. [cancel]
DialogResult dialogResult = MessageBox.Show(null, "Are you sure you want to proceed creating this booking?", "Cyanair: Confirm Booking", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
//open booking confirmation form
frmBookingConfirmation BookingConfirmation = new frmBookingConfirmation();
//DATABASE CONNECTION
BookingConfirmation.myNewCyanDatabaseConnection = myNewCyanDatabaseConnection;
BookingConfirmation.mySystemUsers = mySystemUsers;
//MOVING OBJECTS TO NEXT PAGE?
BookingConfirmation.OutboundFlight01 = OutboundFlight01;
BookingConfirmation.OutboundFlight02 = OutboundFlight02;
BookingConfirmation.newBookingObject = newBookingObject;
BookingConfirmation.ShowDialog();
this.Close();
}
}
}
private void btnCancelBooking_Click(object sender, EventArgs e)
{
DialogResult dialogResult = MessageBox.Show(null, "Are you sure you want to cancel this booking?" + Environment.NewLine + "Please note: this will result in a loss of data.", "Cyanair: Cancel Booking?", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
//opens booking system
Cyanair BookingSystem = new Cyanair();
BookingSystem.ShowDialog();
this.Close();
this.Dispose();
}
}
private void btnNext_Click(object sender, EventArgs e)
{
/*=====================ensures that representative cannot proceed with booking
* until all of the fields have been filled========================*/
string warningErrorMessage = "";
//1. FULL NAME
if (txtFullName.Text != "")
{
newBookingObject.fullname = txtFullName.Text;
}
else
{
warningErrorMessage += "Please enter the Full Name of the Passenger" + Environment.NewLine;
}
//2. PASSPORT NUMBER
if (txtPassportNumber.Text != "")
{
newBookingObject.passportnumber = txtPassportNumber.Text;
}
else
{
warningErrorMessage += "Please enter the Passport Number of the Passenger" + Environment.NewLine;
}
//3. NATIONALITY
if (txtNationality.Text != "")
{
newBookingObject.nationality = txtNationality.Text;
}
else
{
warningErrorMessage += "Please enter the Nationality of the Passenger" + Environment.NewLine;
}
//4. PHONE NUMBER
if (txtPhoneNumber.Text != "")
{
newBookingObject.phonenumber = txtPhoneNumber.Text;
}
else
{
warningErrorMessage += "Please enter the Phone Number of the Passenger" + Environment.NewLine;
}
//5. EMAIL ADDRESS
if (txtEmailAddress.Text != "")
{
newBookingObject.emailaddress = txtEmailAddress.Text;
}
else
{
warningErrorMessage += "Please enter the Email Address of the Passenger" + Environment.NewLine;
}
//6. GENDER
if (txtGender.Text != "")
{
newBookingObject.gender = txtGender.Text;
}
else
{
warningErrorMessage += "Please enter the Gender of the Passenger";
}
if (warningErrorMessage != "")
{
MessageBox.Show(warningErrorMessage);
return;
}
else
{
//open booking confirmation form
frmBookingConfirmation BookingConfirmation = new frmBookingConfirmation();
//DATABASE CONNECTION
BookingConfirmation.myNewCyanDatabaseConnection = myNewCyanDatabaseConnection;
//MOVING OBJECTS TO NEXT PAGE?
BookingConfirmation.OutboundFlight01 = OutboundFlight01;
BookingConfirmation.OutboundFlight02 = OutboundFlight02;
BookingConfirmation.newBookingObject = newBookingObject;
BookingConfirmation.mySystemUsers = mySystemUsers;
BookingConfirmation.ShowDialog();
this.Close();
this.Dispose();
}
}
private void txtGender_TextChanged(object sender, EventArgs e)
{
txtGender.MaxLength = 1;
}
private void pnlPassengerDetails_Paint(object sender, PaintEventArgs e)
{
}
private void lblOutwardFlightLeg1_Click(object sender, EventArgs e)
{
}
private void btnHelp_Click(object sender, EventArgs e)
{
frmHelp Help = new frmHelp();
Help.ShowDialog();
}
}
}