-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBookingFiles.cs
143 lines (99 loc) · 3.52 KB
/
BookingFiles.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
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.IO;
namespace ConsoleApp1
{
class BookingFiles
{
public void CreateDirectory()
{
Directory.CreateDirectory("C:\\CinemaBookingSystem");
}
public void CreateFiles()
{
if (!File.Exists(@"C:\CinemaBookingSystem\Booking.txt"))
{
File.Create(@"C:\CinemaBookingSystem\Booking.txt");
}
if (!File.Exists(@"C:\CinemaBookingSystem\Seats.txt"))
{
string[] seats = new string[3] {"30", "30", "30"};
File.WriteAllLines(@"C:\CinemaBookingSystem\Seats.txt", seats);
}
}
public void Booking(string Title, string Length, string AR, string DT, string Screen, string Type, string Seats, string Price, string Line)
{
string[] Booking = new string[9] { Title, Length, AR, DT, Screen, Type, Seats, Price, Line };
File.AppendAllLines(@"C:\CinemaBookingSystem\Booking.txt", Booking);
}
public void Seats(int num1, int num2, int num3)
{
string[] Seats = File.ReadAllLines(@"C:\CinemaBookingSystem\Seats.txt");
if (num1 == 1)
{
int result = Subtract1(num2);
Seats[0] = result.ToString();
string[] seats = { Seats[0], Seats[1], Seats[2] };
if (num3 == 1)
{
File.WriteAllLines(@"C:\CinemaBookingSystem\Seats.txt", seats);
}
}
else if (num1 == 2)
{
int result = Subtract2(num2);
Seats[2] = result.ToString();
string[] seats = { Seats[0], Seats[1], Seats[2] };
if (num3 == 1)
{
File.WriteAllLines(@"C:\CinemaBookingSystem\Seats.txt", seats);
}
}
else if (num1 == 3)
{
int result = Subtract3(num2);
Seats[2] = result.ToString();
string[] seats = { Seats[0], Seats[1], Seats[2] };
if (num3 == 1)
{
File.WriteAllLines(@"C:\CinemaBookingSystem\Seats.txt", seats);
}
}
}
public int Subtract1(int num1)
{
BookingFilms Films = new BookingFilms();
string[] Seats = File.ReadAllLines(@"C:\CinemaBookingSystem\Seats.txt");
int[] SeatNum = Array.ConvertAll(Seats, int.Parse);
if (SeatNum[0] < num1)
{
Films.Films();
}
return SeatNum[0] - num1;
}
public int Subtract2(int num1)
{
BookingFilms Films = new BookingFilms();
string[] Seats = File.ReadAllLines(@"C:\CinemaBookingSystem\Seats.txt");
int[] SeatNum = Array.ConvertAll(Seats, int.Parse);
if (SeatNum[1] < num1)
{
Films.Films();
}
return SeatNum[1] - num1;
}
public int Subtract3(int num1)
{
BookingFilms Films = new BookingFilms();
string[] Seats = File.ReadAllLines(@"C:\CinemaBookingSystem\Seats.txt");
int[] SeatNum = Array.ConvertAll(Seats, int.Parse);
if (SeatNum[2] < num1)
{
Films.Films();
}
return SeatNum[2] - num1;
}
}
}