-
Notifications
You must be signed in to change notification settings - Fork 1
/
report.cpp
320 lines (260 loc) · 8.68 KB
/
report.cpp
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
/*
File Name : report.cpp
Description :
Author : Garly Nugraha & Nazwa Fitriyani Zahra
Date : 08/12/2001
*/
/* ========== Header File ========== */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <ctype.h>
#include <time.h>
#include "reservation.h"
#include "administrator.h"
#include "room.h"
#include "report.h"
/* ======= End of Header File ====== */
void ReportMenu()
{
int Menu;
system("cls");
printf("|==================================|\n");
printf("| Report Menu |\n");
printf("|==================================|\n");
printf("|1. Show by Day |\n");
printf("|2. Show by Month |\n");
printf("|3. Show by Year |\n");
printf("|4. Show All |\n");
printf("|5. Back |\n");
printf("|==================================|\n");
printf("\n\n");
printf("Select Menu : ");
scanf("%d", &Menu);
switch(Menu){
case 1 :
/* Call Modul Filter Data Report Reservation by Day */
ReservationReportDay();
break;
case 2 :
/* Call Modul Filter Data Report Reservation by Month */
ReservationReportMonth();
break;
case 3 :
/* Call Modul Filter Data Report Reservation by Year */
ReservationReportYear();
break;
case 4 :
/* Call Modul Show All Data Reservation */
ReportShowAll();
break;
case 5 :
system("cls");
/* Call Modul Menu Administrator */
AdministratorMenu();
break;
default :
printf("ERROR : Sorry I don't know the answer to this one!!!");
getch();
system("cls");
/* Call Modul Menu Report */
ReportMenu();
break;
}
}
void ReservationReportDay()
{
FILE *f_reservation;
Reservation ReservationData;
int Check, Day, Month, Year;
system("cls");
printf("Insert Date (*Ex : 1 - 31) :");
fflush(stdin);
scanf("%d", &Day);
printf("Insert Month (*Ex : 1 - 12) :");
fflush(stdin);
scanf("%d", &Month);
printf("Insert Year (*Ex : 2022) :");
fflush(stdin);
scanf("%d", &Year);
/* Open File */
f_reservation = fopen("Reservation.DAT","rb");
/* Erro Handle About Open File */
if (!f_reservation)
{
printf ("ERROR : Sorry file cannot be open!!!\n");
getch();
system("cls");
/* Call Modul Menu Report */
ReportMenu();
}
Check = CheckReservationDate(ReservationData, Day, Month, Year);
if(Check != 0){
while(fread(&ReservationData, sizeof(ReservationData),1, f_reservation))
{
if(Day == ReservationData.ReservationDate.Day && Month == ReservationData.ReservationDate.Month && Year == ReservationData.ReservationDate.Year)
{
printf("\n\n");
printf("Report data on %d / %d / %d",ReservationData.ReservationDate.Day, ReservationData.ReservationDate.Month, ReservationData.ReservationDate.Year);
printf("\n");
printf("|===================================================================================|\n");
printf("| Reservation Data |\n");
printf("|===================================================================================|\n");
printf("| ID Guest Name Type Total Price |\n");
printf("|===================================================================================|\n");
printf(" %-7d %-20s %d %-15s %-12li %-20li\n", ReservationData.ReservationCode, ReservationData.FullName, ReservationData.RentRoomData.Code, ReservationData.RentRoomData.Name, ReservationData.RentRoomData.Price, ReservationData.GrandTotal);
printf("\n\n\n");
printf("Press Any Key to continue . . .");
getch();
system("cls");
/* Close File */
fclose(f_reservation);
/* Call Modul Menu Report */
ReportMenu();
}
}
} else{
printf("ERROR : No data for this time period");
system("cls");
/* Close File */
fclose(f_reservation);
/* Call Modul Menu Report */
ReportMenu();
}
}
void ReservationReportMonth()
{
FILE *f_reservation;
Reservation ReservationData;
int Check, Day, Month, Year;
system("cls");
printf("Insert Month (*Ex : 1 - 12):");
fflush(stdin);
scanf("%d", &Month);
printf("Insert Year (*Ex : 2022):");
fflush(stdin);
scanf("%d", &Year);
/* Open File */
f_reservation = fopen("Reservation.DAT","rb");
/* Error Handle About Open File */
if (!f_reservation)
{
printf ("ERROR : Sorry file cannot be open!!!\n");
getch();
system("cls");
/* Call Modul Menu Report */
ReportMenu();
}
Check = CheckReservationDate(ReservationData, Day, Month, Year);
if(Check != 0){
while(fread(&ReservationData, sizeof(ReservationData),1, f_reservation))
{
if(Month == ReservationData.ReservationDate.Month && Year == ReservationData.ReservationDate.Year){
printf("\n\n");
printf("Report data on %d / %d",ReservationData.ReservationDate.Month, ReservationData.ReservationDate.Year);
printf("\n");
printf("|===================================================================================|\n");
printf("| Reservation Data |\n");
printf("|===================================================================================|\n");
printf("| ID Guest Name Type Total Price |\n");
printf("|===================================================================================|\n");
printf(" %-7d %-20s %d %-15s %-12li %-20li\n", ReservationData.ReservationCode, ReservationData.FullName, ReservationData.RentRoomData.Code, ReservationData.RentRoomData.Name, ReservationData.RentRoomData.Price, ReservationData.GrandTotal);
printf("\n\n\n");
printf("Press Any Key to continue . . .");
getch();
system("cls");
/* Close File */
fclose(f_reservation);
/* Call Modul Menu Report */
ReportMenu();
}
}
} else{
printf("ERROR : No data for this time period");
system("cls");
/* Close File */
fclose(f_reservation);
/* Call Modul Menu Report */
ReportMenu();
}
}
void ReservationReportYear()
{
FILE *f_reservation;
Reservation ReservationData;
int Check, Day, Month, Year;
system("cls");
printf("Insert Year (*Ex : 2022):");
fflush(stdin);
scanf("%d", &Year);
/* Open File */
f_reservation = fopen("Reservation.DAT","rb");
/* Error Handle About Open File */
if (!f_reservation)
{
printf ("ERROR : Sorry file cannot be open!!!\n");
getch();
system("cls");
/* Call Modul Menu Report */
ReportMenu();
}
Check = CheckReservationDate(ReservationData, Day, Month, Year);
if(Check != 0){
while(fread(&ReservationData, sizeof(ReservationData),1, f_reservation))
{
if(Year == ReservationData.ReservationDate.Year){
printf("\n\n");
printf("Report data on %d",ReservationData.ReservationDate.Year);
printf("\n");
printf("|===================================================================================|\n");
printf("| Reservation Data |\n");
printf("|===================================================================================|\n");
printf("| ID Guest Name Type Total Price |\n");
printf("|===================================================================================|\n");
printf(" %-7d %-20s %d %-15s %-12li %-20li\n", ReservationData.ReservationCode, ReservationData.FullName, ReservationData.RentRoomData.Code, ReservationData.RentRoomData.Name, ReservationData.RentRoomData.Price, ReservationData.GrandTotal);
printf("\n\n\n");
printf("Press Any Key to continue . . .");
getch();
system("cls");
/* Close File */
fclose(f_reservation);
/* Call Modul Menu Report */
ReportMenu();
}
}
} else{
printf("ERROR : No data for this time period");
system("cls");
/* Close File */
fclose(f_reservation);
/* Call Modul Menu Report */
ReportMenu();
}
}
void ReportShowAll()
{
system("cls");
/* Call Modul Show Data Reservation */
ReservationData();
printf("Press Any Key to continue . . .");
getche();
system("cls");
/* Call Modul Menu Report */
ReportMenu();
}
int CheckReservationDate(Reservation ReservationData, int Day, int Month, int Year)
{
FILE *f_reservation;
/* Open File */
f_reservation = fopen("Reservation.DAT","rb");
while(fread(&ReservationData, sizeof(ReservationData), 1, f_reservation))
{
if(Day == ReservationData.ReservationDate.Day || Month == ReservationData.ReservationDate.Month || Year == ReservationData.ReservationDate.Year)
{
/* Close File */
fclose(f_reservation);
return 1;
}
}
}