-
Notifications
You must be signed in to change notification settings - Fork 0
/
Seans.cs
175 lines (170 loc) · 7.15 KB
/
Seans.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
using CinemaHallSimulation.Entity;
using CinemaHallSimulation.Helpers;
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 CinemaHallSimulation
{
public partial class Seans : Form
{
public Seans()
{
InitializeComponent();
}
private void Seans_Load(object sender, EventArgs e)
{
List<Hall> halls = HelperHall.GetHallList();
comboBox1.DataSource = halls;
comboBox1.ValueMember = "HallId";
comboBox1.DisplayMember = "Name";
}
private void Button1_Click(object sender, EventArgs e)
{
if (comboBox1.SelectedValue == null)
{
MessageBox.Show("İlk önce salon seçmeniz gerekmektedir.", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
groupBox1.Visible = true;
checkBox1.Checked = false;
checkBox2.Checked = false;
checkBox3.Checked = false;
checkBox4.Checked = false;
checkBox5.Checked = false;
checkBox1.Enabled = true;
checkBox2.Enabled = true;
checkBox3.Enabled = true;
checkBox4.Enabled = true;
checkBox5.Enabled = true;
button2.Enabled = true;
List<Showtimes> showtimes = HelperShowtimes.GetShowtimesListByHallIdAndDate(Convert.ToInt32(comboBox1.SelectedValue), dateTimePicker1.Value);
foreach (var item in showtimes)
{
if (item.Clock == 1)
{
checkBox1.Checked = true;
checkBox1.Enabled = false;
}
if (item.Clock == 2)
{
checkBox2.Checked = true;
checkBox2.Enabled = false;
}
if (item.Clock == 3)
{
checkBox3.Checked = true;
checkBox3.Enabled = false;
}
if (item.Clock == 4)
{
checkBox4.Checked = true;
checkBox4.Enabled = false;
}
if (item.Clock == 5)
{
checkBox5.Checked = true;
checkBox5.Enabled = false;
}
}
}
if (checkBox1.Checked && checkBox2.Checked && checkBox3.Checked && checkBox4.Checked && checkBox5.Checked)
{
button2.Enabled = false;
}
}
private void Button2_Click(object sender, EventArgs e)
{
if (checkBox1.Enabled == true && checkBox1.Checked == true)
{
Showtimes showtimes = new Showtimes();
showtimes.HallId = Convert.ToInt32(comboBox1.SelectedValue);
showtimes.Clock = 1;
showtimes.Date = dateTimePicker1.Value;
var a = HelperShowtimes.ShowtimesCUD(showtimes, System.Data.Entity.EntityState.Added);
CreateChairs(a);
checkBox1.Enabled = false;
}
if (checkBox2.Enabled == true && checkBox2.Checked == true)
{
Showtimes showtimes = new Showtimes();
showtimes.HallId = Convert.ToInt32(comboBox1.SelectedValue);
showtimes.Clock = 2;
showtimes.Date = dateTimePicker1.Value;
var a = HelperShowtimes.ShowtimesCUD(showtimes, System.Data.Entity.EntityState.Added);
CreateChairs(a);
checkBox2.Enabled = false;
}
if (checkBox3.Enabled == true && checkBox3.Checked == true)
{
Showtimes showtimes = new Showtimes();
showtimes.HallId = Convert.ToInt32(comboBox1.SelectedValue);
showtimes.Clock = 3;
showtimes.Date = dateTimePicker1.Value;
var a = HelperShowtimes.ShowtimesCUD(showtimes, System.Data.Entity.EntityState.Added);
CreateChairs(a);
checkBox3.Enabled = false;
}
if (checkBox4.Enabled == true && checkBox4.Checked == true)
{
Showtimes showtimes = new Showtimes();
showtimes.HallId = Convert.ToInt32(comboBox1.SelectedValue);
showtimes.Clock = 4;
showtimes.Date = dateTimePicker1.Value;
var a = HelperShowtimes.ShowtimesCUD(showtimes, System.Data.Entity.EntityState.Added);
CreateChairs(a);
checkBox4.Enabled = false;
}
if (checkBox5.Enabled == true && checkBox5.Checked == true)
{
Showtimes showtimes = new Showtimes();
showtimes.HallId = Convert.ToInt32(comboBox1.SelectedValue);
showtimes.Clock = 5;
showtimes.Date = dateTimePicker1.Value;
var a = HelperShowtimes.ShowtimesCUD(showtimes, System.Data.Entity.EntityState.Added);
CreateChairs(a);
checkBox5.Enabled = false;
}
MessageBox.Show("Seans veya seanslar başarıyla eklendi.", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (checkBox1.Checked && checkBox2.Checked && checkBox3.Checked && checkBox4.Checked && checkBox5.Checked)
{
button2.Enabled = false;
}
}
private void CreateChairs((Showtimes, bool) a)
{
char[] letters = new char[] { 'A', 'B', 'C', 'D', 'E', 'F' };
char[] numbers = new char[] { '1', '2', '3', '4', '5' };
int letterIndex = 0;
int numberIndex = 0;
for (int i = 1; i <= 30; i++)
{
if (i % 5 == 0)
{
Chair chair = new Chair();
chair.Name = letters[letterIndex].ToString() + numbers[numberIndex].ToString();
chair.IsSold = false;
chair.ShowtimesId = a.Item1.ShowtimesId;
var b = HelperChair.ChairCUD(chair, System.Data.Entity.EntityState.Added);
letterIndex++;
numberIndex = 0;
}
else
{
Chair chair = new Chair();
chair.Name = letters[letterIndex].ToString() + numbers[numberIndex].ToString();
chair.IsSold = false;
chair.ShowtimesId = a.Item1.ShowtimesId;
var b = HelperChair.ChairCUD(chair, System.Data.Entity.EntityState.Added);
numberIndex++;
}
}
}
}
}