-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ticket_Booking.cs
262 lines (188 loc) · 7.85 KB
/
Ticket_Booking.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
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;
using System.Data.SqlClient;
using System.IO;
namespace Movie_Ticketing_System
{
public partial class Ticket_Booking : Form
{
String ConnectionString = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Ali Khattak\Documents\Visual Studio 2013\Projects\Movie Ticketing System\Movie Ticketing System\CinemaTicketing_DBS.mdf;Integrated Security=True";
int UserID1;
int MovieID1;
int TicketNumber;
static string moviename;
public Ticket_Booking(int UserID,int MovieID,string MOVNAME)
{
InitializeComponent();
UserID1 = UserID;
MovieID1 = MovieID;
moviename = MOVNAME;
radioButton1.Checked = true;
dated_label.Text = "Dated: "+DateTime.Now.ToString("dd-MM-yyyy");
SqlConnection connection = new SqlConnection(ConnectionString);
connection.Open();
string query = "SELECT LTRIM(RTRIM(Name)),LTRIM(RTRIM(Seats)),Timing,MovieImage from Movies WHERE MID=@MovieID";
SqlCommand command = new SqlCommand(query, connection);
command.Parameters.AddWithValue("@MovieID",MovieID);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
showName_Label.Text = reader[0].ToString();
Seats_label.Text = reader[1].ToString();
time_combox.Items.Add (reader[2].ToString());
TicketBook_pic.Image = byteArrayToImage((byte[])reader[3]);
}
connection.Close();
connection.Open();
query = "SELECT ChildTicket,StandardMember,SilverMember,PlatinumMember,DiamondMember from TicketPricing";
command = new SqlCommand(query, connection);
reader = command.ExecuteReader();
while (reader.Read())
{
ChildLabel.Text = reader[0].ToString();
StandardLabel.Text = reader[1].ToString();
SilverLabel.Text = reader[2].ToString();
PlatinumLabel.Text = reader[3].ToString();
DiamondLabel.Text = reader[4].ToString();
}
connection.Close();
}
public Image byteArrayToImage(byte[] byteArrayIn)
{
MemoryStream ms = new MemoryStream(byteArrayIn);
Image returnImage = Image.FromStream(ms);
return returnImage;
}
private void Home_btn_TB_Click(object sender, EventArgs e)
{
Form1 first = new Form1();
first.Show();
this.Hide();
}
private void Next_button_Click(object sender, EventArgs e)
{
string showname = showName_Label.Text;
string selectCinema = Cinema_Combo.Text;
string city = City_Combo.Text;
string familytype;
int num_tickets;
if (radioButton1.Checked){
familytype = radioButton1.Text;
num_tickets = int.Parse(TicketsCombo.Text);
}
else
{
familytype = radioButton2.Text;
num_tickets = 1;
}
string ticketType = Ticket_type_combo.Text;
string time = time_combox.Text;
string BookingData = DateTime.Now.ToString("dd-MM-yyyy");
int TotallBill;
if (ticketType == "Child Member"){
TotallBill = num_tickets * int.Parse(ChildLabel.Text);
}
else if (ticketType == "Standard Member"){
TotallBill = num_tickets * int.Parse(StandardLabel.Text);
}
else if (ticketType == "Silver Member"){
TotallBill = num_tickets * int.Parse(SilverLabel.Text);
}
else if (ticketType == "Platinum Member"){
TotallBill = num_tickets * int.Parse(PlatinumLabel.Text);
}
else if (ticketType == "Diamond Member"){
TotallBill = num_tickets * int.Parse(DiamondLabel.Text);
}
else
{
TotallBill = 0;
}
string Billpayed = "No";
SqlConnection connection = new SqlConnection(ConnectionString);
connection.Open();
string query = "INSERT INTO TicketBooking(ShowName,CinemaName,CinemaCity,FamilyType,Num_Tickets,TicketType,TimeSelected,BookingDate,TotalBill,BillPayed,CMTS_ID,MID) VALUES (@ShowName,@Cinema,@City,@Familytype,@NumTickets,@tickettype,@time,@bookingdate,@TotalBill,@BillPayed,@CMts,@MovieID)";
SqlCommand command = new SqlCommand(query, connection);
command.Parameters.AddWithValue("@ShowName",showname);
command.Parameters.AddWithValue("@Cinema",selectCinema);
command.Parameters.AddWithValue("@City",city);
command.Parameters.AddWithValue("@Familytype",familytype);
command.Parameters.AddWithValue("@NumTickets",num_tickets);
command.Parameters.AddWithValue("@tickettype",ticketType);
command.Parameters.AddWithValue("@time",time);
command.Parameters.AddWithValue("@bookingdate",BookingData);
command.Parameters.AddWithValue("@TotalBill", TotallBill);
command.Parameters.AddWithValue("@BillPayed",Billpayed);
command.Parameters.AddWithValue("@CMts",UserID1);
command.Parameters.AddWithValue("@MovieID", MovieID1);
command.ExecuteNonQuery();
connection.Close();
connection.Open();
query = "SELECT TicketNumber from TicketBooking Where CMTS_ID=@CMTS and MID=@MovieId";
command = new SqlCommand(query, connection);
command.Parameters.AddWithValue("@CMTS", @UserID1);
command.Parameters.AddWithValue("@MovieId", MovieID1);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
TicketNumber = int.Parse(reader[0].ToString());
}
connection.Close();
Proceed_Form PF = new Proceed_Form(UserID1, MovieID1, TicketNumber);
PF.Show();
this.Hide();
}
private void Back_btn_TB_Click(object sender, EventArgs e)
{
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton2.Checked)
{
TicketsCombo.Enabled = false;
}
else
{
TicketsCombo.Enabled = true;
}
}
private void pictureBox5_Click(object sender, EventArgs e)
{
Form1 Home = new Form1();
Home.Show();
this.Hide();
}
private void pictureBox3_Click(object sender, EventArgs e)
{
Movie_Details detail = new Movie_Details( moviename,UserID1);
detail.Show();
this.Hide();
}
private void pictureBox4_Click(object sender, EventArgs e)
{
string message = "Are You Sure You Want to Logout?";
string title = "Log Out";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result = MessageBox.Show(message, title, buttons);
if (result == DialogResult.Yes)
{
Customer_Login customer = new Customer_Login();
customer.Show();
this.Show();
}
else
{
}
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
}
}