-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmethods.h
285 lines (186 loc) · 8.88 KB
/
methods.h
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
#ifndef METHODS_H_INCLUDED
#define METHODS_H_INCLUDED
#include <gtk/gtk.h>
#include "structs.h"
/****************************************************
Gtk
****************************************************/
/*to create the main window*/
void create_main();
/*to create the detailed room window for a room type*/
void create_room_win();
void room_dialogue_check(GtkMenuItem *ignore, struct room_dialogue_check *data);
/*to create the detailed guest window for a room*/
void create_guest_win();
void guest_dialogue_check(GtkMenuItem *ignore, struct guest_dialogue_check *data);
/*to show error message*/
void errmesg(const char *error);
/*to show a file-chooser-dialogue*/
char *choose_file(int type);
/*to close the current file*/
void file_close(GtkWidget *win);
/*to create a new file*/
void file_new(GtkWidget *win);
/*to open a existing file*/
void file_open(GtkWidget *win);
/*to save the current file*/
void file_save(GtkWidget *win);
/*to save the current file as another*/
void file_save_as(GtkWidget *win);
/*to close the current file*/
void file_quit(GtkWidget *win);
/*open a new dialogue to insert a new room type*/
void edit_new_type(GtkWidget *win);
/*open a new dialogue to insert a new room*/
void edit_new_room(GtkWidget *win);
/*open a new dialogue to insert a new guest_in info*/
void edit_new_guest_in(GtkWidget *win);
void edit_new_guest_out(GtkWidget *win);
/*to show the about dialogue*/
void help_about();
/*to show the help dialogue*/
void help_help(GtkWidget *win);
/*to create the main menu*/
void create_menu(GtkWidget *win, GtkWidget *menubar);
/*to show or refresh the data from the current file*/
void access_type_data();
void access_room_data();
void access_guest_data();
/*the common type dialogue*/
void type_dialogue(int is_edit);
/*the common room dialogue*/
void room_dialogue(int is_edit, struct room_dialogue_check *checkdata);
/*the common guest in dialogue*/
void guest_in_dialogue(struct guest_dialogue_check *checkdata);
/*the common guest out dialogue*/
void guest_out_dialogue();
/*the common guest modify dialogue*/
void guest_modify_dialogue();
/*to show room info in a type*/
void type_view_details();
/*to show room info in a type*/
void room_view_detail();
/*to find the active item in the treeview*/
void handle_room_find_focus(GtkWidget *ignored, GtkTreeSelection *selection);
/*to show guest info in a room when click the button*/
void handle_room_view_detail();
/*to destroy the current dialogue*/
void handle_destroy_dialogue(GtkWidget *ignored, GtkWidget *dialogue);
/*to hide the current dialogue*/
void handle_dialogue_hide(GtkWidget *ignored, GtkWidget *dialogue);
/*to show the popup menu when right clicked*/
int handle_popup_menu(struct popup_menu *pop_struct, GdkEvent *event);
/*to handle the new type*/
void handle_new_type(GtkWidget *ignored, struct new_type_data *data);
/*to edit the display of modified type*/
void handle_edit_type(GtkWidget *ignored, struct new_type_data *data);
/*assistant function*/
void handle_edit_type_dialogue();
/*delete the selected type and remove it from the list*/
void handle_type_delete();
/*assistant function*/
void handle_room_new_assistant(void *ignored, struct room_dialogue_check *data);
/*assistant function*/
void handle_room_edit_assistant(void *ignored, struct room_dialogue_check *data);
/*to handle the new room*/
void handle_room_new(GtkWidget *ignored, struct new_room_data *data);
/*to edit the display of modified room*/
void handle_room_modify(GtkWidget *ignored, struct new_room_data *data);
/*to delete a room from the treeview and the list*/
void handle_room_delete();
/*to find the active item in the treeview*/
void handle_guest_find_focus(GtkWidget *ignored, GtkTreeSelection *selection);
/*to handle the new guest_in*/
void handle_guest_in_new(GtkWidget *ignored, struct new_guest_in_data *data);
/*to handle the new guest_out*/
void handle_guest_out_new(GtkWidget *ignored, struct new_guest_out_data *data);
/*to edit the display of modified guest info*/
void handle_guest_modify(GtkWidget *ignored, struct new_guest_data *data);
/*to delete a guest info from the treeview and the list*/
void handle_guest_delete();
/*show type detail when double clicked*/
void handle_type_row_activated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, GtkTreeSelection* selection);
/*show room detail when double clicked*/
void handle_room_row_activated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, GtkTreeSelection* selection);
/*to show the result of the query*/
void handle_query_room(GtkWidget *ignored, struct query_room *data);
/*to show the result of the query*/
void handle_query_guest(GtkWidget *ignored, struct query_guest *data);
/**/
void handle_sta_by_year(GtkWidget *ignored, GtkEntry *entry);
/*****************************************************
Maintain Data
*****************************************************/
/*to load data from a file*/
struct basic_room_type_data *load_data();
/*to save data to a file*/
void save_data();
/*to insert a room type node*/
void type_insert(const char *type, int most_in);
/*to delete a room type node*/
void type_delete();
/*to change the info of a existing room type*/
void type_modify(const char *type, int most_in);
/*to insert a room node*/
void room_insert(struct basic_room_type_data *type, const char *room_number, const char *phone_number, float area, float price, int is_left);
/*to delete a room node*/
void room_delete();
/*to change the info of a existing room*/
void room_modify(struct basic_room_type_data *type, const char *room_number, const char *phone_number, float area, float price, int is_left);
/*to insert a guest-in info node, return the inserted node*/
void guest_in_insert(struct basic_room_data *room, const char *id, const char *name, const char *in_time);
/*to insert a guest-out info node, return the inserted node*/
void guest_out_insert(struct basic_guest_info *guest, const char *out_time, float pay);
/*to modify the guest info*/
void guest_modify(struct basic_room_data *room, const char *id, const char *name, const char *in_time, const char *out_time, float pay);
/*to delete a guest node*/
void guest_delete();
/*dialogue which query for room that meets with the given conditions*/
void query_room();
/*dialogue which query for guest info that meets with the given conditions*/
void query_guest();
/*a dialogue shows the statistics of every room type in month this year*/
void sta_by_month();
/*a dialogue shows the statistics of every room in the given year*/
void sta_by_year();
/*a dialogue show the top 10 guests*/
void sta_by_guest();
/*a dialogue show the 10 most popular rooms*/
void sta_by_room();
/*****************************************************
Query
*****************************************************/
/*query for room type by room type name*/
//void q_room_type_by_type(char *type, struct basic_room_type_data *type_liset);
/*query for room that meets with the given conditions*/
void q_room_by_conditions(GtkListStore *store, int is_room_number_limited, int is_phone_number_limited, int is_type_limited, int is_left_limited, int is_price_limited, int is_area_limited, struct basic_room_type_data *type, const char *room_number, const char *phone_number, int is_left, float uprice, float lprice, float uarea, float larea);
/*query for guest info that meets with the given conditions*/
void q_guest_info_by_conditions(GtkListStore *store, int is_id_limited, int is_name_limited, int is_in_time_limited, const char *id, const char *name_piece, const char *lin_time, const char *uin_time);
/*****************************************************
Statistics
*****************************************************/
void statistics_room_type_by_room_type(struct basic_room_type_data *typelist);
void statistics_room_type_by_month(struct basic_room_type_data *typelist);
void statistics_room_by_year(struct basic_room_type_data *typelist);
void statistics_most_in_by_id(struct basic_guest_info *guestlist);
#endif // METHODS_H_INCLUDED
/*****************************************************
Assistant
*****************************************************/
int get_hour(const char timech[]);
int get_num(const char **chs, char ch);
int is_year(int year);
int day_of_year(int year);
int day_of_month(int year, int month);
int date_2_day(int year, int month, int day);
float cal_day(const char time1[], const char time2[]);
void free_data(GtkWidget *ignored, void *data);
int cal_types();
void fill_type(int types, GType *type_list);
float cal_value(struct basic_room_type_data *type, int year, int month);
void cal_values(int types, int year, int month, int *column_num, GValue *value, float *total);
void cal_room_sta(GtkListStore *store, struct basic_room_data *room, int year, float *total_w, float *total_day);
void cal_rooms_sta(GtkListStore *store, int year);
void cal_top_10_guest(GtkListStore *store);
void cal_room_full(struct basic_room_data *room, struct room_interest *interest);
void cal_top_room(GtkListStore *store);