-
Notifications
You must be signed in to change notification settings - Fork 0
/
Admin_Manage_Tickets.cs
152 lines (113 loc) · 4.68 KB
/
Admin_Manage_Tickets.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
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;
namespace Movie_Ticketing_System
{
public partial class Admin_Manage_Tickets : 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";
public Admin_Manage_Tickets()
{
InitializeComponent();
SqlConnection connection = new SqlConnection(ConnectionString);
DataSet set = new DataSet();
DataTable datatable = new DataTable();
connection.Open();
string query = "SELECT * FROM Ticketbooking";
SqlCommand command = new SqlCommand(query, connection);
SqlDataAdapter adapter = new SqlDataAdapter(command);
command = adapter.SelectCommand;
adapter.Fill(datatable);
dataGridView1.DataSource = datatable;
dataGridView1.Columns[0].Width = 80;
dataGridView1.Columns[1].Width = 130;
dataGridView1.Columns[2].Width = 60;
dataGridView1.Columns[3].Width = 80;
dataGridView1.Columns[4].Width = 100;
dataGridView1.Columns[5].Width = 80;
dataGridView1.Columns[6].Width = 100;
dataGridView1.Columns[7].Width = 130;
dataGridView1.Columns[8].Width = 80;
dataGridView1.Columns[9].Width = 100;
dataGridView1.Columns[10].Width = 80;
dataGridView1.Columns[11].Width = 110;
dataGridView1.Columns[12].Width = 110;
dataGridView1.Columns[13].Width = 90;
connection.Close();
}
private void DeleteTicket_Click(object sender, EventArgs e)
{
try
{
DataSet set = new DataSet();
DataTable datatable = new DataTable();
SqlConnection connection = new SqlConnection(ConnectionString);
connection.Open();
string query = "DELETE FROM TicketBooking WHERE TicketNumber=@Ticket";
SqlCommand command = new SqlCommand(query, connection);
command.Parameters.AddWithValue("@Ticket", int.Parse(textBox1.Text));
command.ExecuteNonQuery();
query = "SELECT * FROM Ticketbooking";
command = new SqlCommand(query, connection);
SqlDataAdapter adapter = new SqlDataAdapter(command);
command = adapter.SelectCommand;
adapter.Fill(datatable);
dataGridView1.DataSource = datatable;
dataGridView1.Columns[0].Width = 80;
dataGridView1.Columns[1].Width = 130;
dataGridView1.Columns[2].Width = 60;
dataGridView1.Columns[3].Width = 80;
dataGridView1.Columns[4].Width = 100;
dataGridView1.Columns[5].Width = 80;
dataGridView1.Columns[6].Width = 100;
dataGridView1.Columns[7].Width = 130;
dataGridView1.Columns[8].Width = 80;
dataGridView1.Columns[9].Width = 100;
dataGridView1.Columns[10].Width = 80;
dataGridView1.Columns[11].Width = 110;
dataGridView1.Columns[12].Width = 110;
dataGridView1.Columns[13].Width = 90;
connection.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error- Cannot Delete " + ex.Message, "Error");
}
}
private void pictureBox5_Click(object sender, EventArgs e)
{
Form1 home = new Form1();
home.Show();
this.Hide();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
Admin_Page admin = new Admin_Page();
admin.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)
{
Admin_Login login = new Admin_Login();
login.Show();
this.Hide();
}
else
{
}
}
}
}