-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
120 lines (89 loc) · 2.22 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
#include "headers.h"
#include "./models/employee.h"
#include "./models/employeeSalary.h"
#include "./services/close.h"
#include "./services/fileLoader.h"
#include "./services/lookup.h"
#include "./services/salary.h"
// extern FILE *file;
int main(void) {
char file_address[256];
char firstName[50];
char lastName[50];
char yn;
Employee *emp;
EmployeeSalary *es;
initscr(); // initalize ncurses window
cbreak(); // disable line buffering
echo(); // disable echo from user
// get screen size
int yMax, xMax;
getmaxyx(stdscr, yMax, xMax);
printw("Assignment 2 - revisited\nLets make this app in C\n\n");
printw("Enter employee filename (full path): ");
getstr(file_address);
loadEmployees(file_address);
printw("Enter employee first name: ");
getstr(firstName);
printw("Enter employee last name: ");
getstr(lastName);
noecho();
clear();
emp = lookupEmployeeID(file_address, firstName, lastName);
if (emp == NULL) {
clear();
printw("%s %s not found :(", firstName, lastName);
refresh();
closeProg();
}
clear();
printw("Employee information found for: %s %s\nAnd employee ID is: %s\n",
emp->empFirstName, emp->empLastName, emp->empID);
printw(
"Would you like to retreive the employee's salary information? (Y/N):\n");
refresh();
yn = getchar();
yn = tolower(yn);
while (yn != 'n' && yn != 'y') {
printw("\nPlease enter Y or N\n");
refresh();
yn = getchar();
}
if (yn == 'n') {
free(emp);
closeProg();
exit(0);
}
echo();
printw("Enter employee salaray filename (full path): ");
getstr(file_address);
noecho();
clear();
lookupSalaryFile(file_address);
es = printEmployeeSalary(file_address, emp);
refresh();
printw("Would you like to caculate decutions & print salary schedule/year? "
"(Y/N):\n");
refresh();
yn = getchar();
yn = tolower(yn);
while (yn != 'n' && yn != 'y') {
printw("\nPlease enter Y or N\n");
refresh();
yn = getchar();
}
if (yn == 'n') {
free(emp);
free(es);
closeProg();
exit(0);
}
clear();
// printCompanyPaySchedule(file_address);
printPaySchedule(es);
refresh();
free(emp);
free(es);
closeProg();
return 0;
}