-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathmain.c
148 lines (145 loc) · 4.88 KB
/
main.c
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
// Welcome to the program. The declaration of the functions and the library used is in .h file
#include "main.h"
/*---------------------------------------------------------------------------*/
int main () { // This program will run first. POS Interface configuration will be called, and ready to work.
screenClear ();
initDatabase ();
screenAdjust ();
return 0;
}
void switchHub () {
screenClear ();
char text[140];
char text1[140];
char text2[140];
if ( Session.user.role == 0 )
strcpy (text1, "Manager");
else if ( Session.user.role == 1 )
strcpy (text1, "Marketing");
else if ( Session.user.role == 2 )
strcpy (text1, "Sale");
sprintf (text, "Login as %s %c. (%s)", Session.user.firstname, Session.user.lastname[0], text1);
bannerInverse (Setting.storeName, Setting.storeAddress, "", text);
for ( int i = 0; i < 7; i++ )
bannerBlankBorder ();
bannerBlankBorderTextCen ("What do you want to do ?");
bannerBlankBorder ();
bannerBlankBorder ();
//These choice will be removed, when the program detects the permission level.
if ( Session.user.role == 0 ) { // Manager
bannerBlankBorderTextCen ("1. Go to POS System");
bannerBlankBorderTextCen ("2. Inventory management");
bannerBlankBorderTextCen ("3. Customer management");
bannerBlankBorderTextCen ("4. Personnel management");
bannerBlankBorderTextCen ("5. Promotion management");
bannerBlankBorderTextCen ("6. Sales Forecasting");
bannerBlankBorderTextCen ("7. View Report");
bannerBlankBorderTextCen ("8. Settings");
for ( int i = 10; i > 0; i-- )
bannerBlankBorder ();
} else if ( Session.user.role == 1 ) { // Marketing
bannerBlankBorderTextCen ("1. Go to POS System");
bannerBlankBorderTextCen ("2. Promotion management");
bannerBlankBorderTextCen ("3. Sales Forecasting");
bannerBlankBorderTextCen ("4. View Report");
bannerBlankBorderTextCen ("5. Settings");
for ( int i = 13; i > 0; i-- )
bannerBlankBorder ();
} else { // Sale
bannerBlankBorderTextCen ("1. Go to POS System");
bannerBlankBorderTextCen ("2. Settings");
for ( int i = 16; i > 0; i-- )
bannerBlankBorder ();
}
errorResponse == 1 ? bannerBlankBorderTextCen ("Invalid response. Please try again.") : bannerBlankBorder ();
bannerBlankBorder ();
bannerBlankBorderTextCen (" Type 'Q' to quit | ALTERNATE RESPONSE | Type 'B' to logoff");
bannerFullBorder ();
bannerUserInput ();
char flags;
scanf (" %1c", &flags);
errorResponse = 0;
screenClear ();
if ( Session.user.role == 0 ) { // Manager
switch ( toupper (flags)) {
case ('1'):
cashierInterface (0);
break;
case ('2'):
inventorySwitchHub ();
break;
case ('3'):
customerSwitchHub ();
break;
case ('4'):
personnelSwitchHub ();
break;
case ('5'):
promotionSwitchHub ();
break;
case ('6'):
forecastSwitchHub ();
break;
case ('7'):
reportSwitchHub ();
break;
case ('8'):
settingsSwitchHub ();
break;
case ('Q'):
terminate ();
break;
case ('B'):
deauthenticate ();
break;
default:
errorResponse = 1;
switchHub ();
}
} else if ( Session.user.role == 1 ) { // Marketing
switch ( toupper (flags)) {
case ('1'):
cashierInterface (0);
break;
case ('2'):
promotionSwitchHub ();
break;
case ('3'):
forecastSwitchHub ();
break;
case ('4'):
reportSwitchHub ();
break;
case ('5'):
settingsSwitchHub ();
break;
case ('Q'):
terminate ();
break;
case ('B'):
deauthenticate ();
break;
default:
errorResponse = 1;
switchHub ();
}
} else { // Sale
switch ( toupper (flags)) {
case ('1'):
cashierInterface (0);
break;
case ('2'):
settingsSwitchHub ();
break;
case ('Q'):
terminate ();
break;
case ('B'):
deauthenticate ();
break;
default:
errorResponse = 1;
switchHub ();
}
}
}