-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ticked_Confimed.cs
210 lines (156 loc) · 6.56 KB
/
Ticked_Confimed.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
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 Ticked_Confimed : Form
{
int UserID1;
int MId;
int TicketNumber1;
string NumType;
string NumTickets;
string tickettype;
string CinemaName;
string CinemaCity;
string email;
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";
public Ticked_Confimed(int UserID,int MID,int TicketNumber)
{
InitializeComponent();
UserID1 = UserID;
MId = MID;
TicketNumber1 = TicketNumber;
TicketNumberLabel.Text = TicketNumber.ToString();
SqlConnection connection = new SqlConnection(ConnectionString);
connection.Open();
string query = "SELECT LTRIM(RTRIM(Name)),MovieImage from Movies WHERE MID=@MovieID";
SqlCommand command = new SqlCommand(query, connection);
command.Parameters.AddWithValue("@MovieID", MId);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
ShowNameLabel.Text = reader[0].ToString();
ConfirmationPic.Image = byteArrayToImage((byte[])reader[1]);
}
reader.Close();
query = "SELECT LTRIM(RTRIM(Name)) from UserPage WHERE CMTS_ID=@CMTS";
command = new SqlCommand(query, connection);
command.Parameters.AddWithValue("@CMTS", UserID1);
reader = command.ExecuteReader();
while (reader.Read())
{
UserNameLabel.Text = reader[0].ToString();
}
reader.Close();
query = "SELECT LTRIM(RTRIM(BookingDate)),LTRIM(RTRIM(TimeSelected)),Num_Tickets,LTRIM(RTRIM(CinemaName)),LTRIM(RTRIM(CinemaCity)),TotalBill,LTRIM(RTRIM(TicketType)) from TicketBooking WHERE TicketNumber=@tickerNum";
command = new SqlCommand(query, connection);
command.Parameters.AddWithValue("@tickerNum", TicketNumber);
reader = command.ExecuteReader();
while (reader.Read())
{
ShowDateLabel.Text = reader[0].ToString();
ShowTimeLabel.Text = reader[1].ToString();
NumTickets = reader[2].ToString();
CinemaName= reader[3].ToString();
CinemaCity = reader[4].ToString();
TotalBillLabel.Text = reader[5].ToString();
tickettype = reader[6].ToString();
}
CinemaCityLabel.Text = CinemaName + " - " + CinemaCity;
NumType = NumTickets+ " (" + tickettype + ")";
NumberTicketsLabel.Text = NumType;
connection.Close();
string QRVALUES = "Ticket Number : " + TicketNumber
+ "\nUserName : " + UserNameLabel.Text
+ "\nShow Name : " + ShowNameLabel.Text
+ "\nShow Date : " + ShowDateLabel.Text
+ "\nShow Time : " + ShowTimeLabel.Text
+ "\nNo. of Tickets : " + NumType
+ "\nCinema & City : " + CinemaCityLabel.Text
+ "\nTotal Bill : "+ TotalBillLabel.Text;
QRCoder.QRCodeGenerator obj = new QRCoder.QRCodeGenerator();
var mydata = obj.CreateQrCode(QRVALUES, QRCoder.QRCodeGenerator.ECCLevel.H);
var code = new QRCoder.QRCode(mydata);
pictureBox2.Image = code.GetGraphic(100);
}
public Image byteArrayToImage(byte[] byteArrayIn)
{
MemoryStream ms = new MemoryStream(byteArrayIn);
Image returnImage = Image.FromStream(ms);
return returnImage;
}
private void pictureBox5_Click(object sender, EventArgs e)
{
Form1 Home = new Form1();
Home.Show();
this.Hide();
}
private void pictureBox3_Click(object sender, EventArgs e)
{
string message = "Cannot Go Back!\nThis Action will Redirect you to User Home Page\nAre You Sure You Want to Proceed ?";
string title = "Error";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result = MessageBox.Show(message, title, buttons);
if (result == DialogResult.Yes)
{
SqlConnection connection = new SqlConnection(ConnectionString);
connection.Open();
string query = "SELECT Email from UserPage Where CMTS_ID=@userID";
SqlCommand command = new SqlCommand(query, connection);
command.Parameters.AddWithValue("@userID", UserID1);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
email = reader[0].ToString();
}
User_Page user = new User_Page(email);
user.Show();
this.Hide();
}
else
{
return;
}
}
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.Hide();
}
else
{
return;
}
}
int ticketname = 1;
private void DownloadButton_Click(object sender, EventArgs e)
{
ticketname++;
using (var bmp = new Bitmap(panel3.Width, panel3.Height))
{
panel3.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height));
bmp.Save(@"Tickets/" + TicketNumber1+"-"+ticketname+ ".bmp");
MessageBox.Show("Ticket Download!\nSaved in Project/Debug/Tickets","Downloaded");
}
}
private void Ticked_Confimed_Load(object sender, EventArgs e)
{
}
}
}