-
Notifications
You must be signed in to change notification settings - Fork 0
/
Admin_Manage_Movies.cs
188 lines (135 loc) · 5.63 KB
/
Admin_Manage_Movies.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
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_Movies : 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_Movies()
{
InitializeComponent();
SqlConnection connection = new SqlConnection(ConnectionString);
DataSet set = new DataSet();
DataTable datatable = new DataTable();
connection.Open();
string query = "SELECT MID,Name,Genre,Category,ReleaseDate,Year,Director,Cast,IMDBRating,RottenTomatos,Timing,Seats FROM Movies";
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;
connection.Close();
}
private void Delete_Movie_MM_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 MID=@MID";
SqlCommand command = new SqlCommand(query, connection);
command.Parameters.AddWithValue("@MID", int.Parse(textBox1.Text));
command.ExecuteNonQuery();
connection.Close();
connection.Open();
query = "DELETE FROM Movies WHERE MID=@MID";
command = new SqlCommand(query, connection);
command.Parameters.AddWithValue("@MID", int.Parse(textBox1.Text));
command.ExecuteNonQuery();
MessageBox.Show("Movie Successfully Deleted !", "Movie Deleted");
textBox1.Clear();
connection.Close();
if (this.dataGridView1.DataSource != null)
{
this.dataGridView1.DataSource = null;
}
else
{
this.dataGridView1.Rows.Clear();
}
connection.Open();
query = "SELECT MID,Name,Genre,Category,ReleaseDate,Year,Director,Cast,IMDBRating,RottenTomatos,Timing,Seats FROM Movies";
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 = 80;
dataGridView1.Columns[10].Width = 100;
dataGridView1.Columns[11].Width = 80;
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
{
}
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void panel2_Paint(object sender, PaintEventArgs e)
{
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
}
}