-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
1647 lines (1466 loc) · 43.4 KB
/
main.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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <iostream>
#include <winsock.h>
#include <mysql.h>
#include <conio.h>
#include <direct.h>
#include <windows.h>
#include <sstream>
#include <ctime>
#include <iomanip>
using namespace std;
// Deceleration of Global Variables
MYSQL* connection;
short int login_fail = 1;
int menu_select;
char retry_key;
char user_type[2] = "3";
int exit_status = 0;
// Use to set the Pointer
void setPointer(short int xpnt, short int ypnt)
{
COORD position = { xpnt, ypnt };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), position);
}
// Use to print TopPart
void top_printing()
{
system("CLS");
setPointer(60, 12);
cout << "EMPLOYEE MANAGEMENT SYSTEM" << endl;
}
// Use to open the program in FullScreen
void fullscreen()
{
keybd_event(VK_MENU, 0x38, 0, 0); //Press down Alt
keybd_event(VK_RETURN, 0x1c, 0, 0); //Press down Enter
keybd_event(VK_MENU, 0x38, KEYEVENTF_KEYUP, 0); //Release Alternate
keybd_event(VK_RETURN, 0x1c, KEYEVENTF_KEYUP, 0);//Release Enter
}
// Class for handling the Database
class Mysql
{
public:
MYSQL_ROW row;
MYSQL_RES* res;
// Making the connection
int mysql_connection()
{
connection = mysql_init(0);
connection = mysql_real_connect(connection, "localhost", "root", "", "cpp_test", 3306 , NULL, 0);
if (connection)
{
return TRUE;
}
else
{
return FALSE;
}
}
// Query Executor for Insertion
int query_executor(const char* final_query)
{
int query_state = 0;
query_state = mysql_query(connection, final_query);
if(query_state == 0)
{
return 1;
}
else
{
return 0;
}
}
// Query For select
void query_select(const char* final_query)
{
if(connection)
{
int qstate = mysql_query(connection, final_query);
if(!qstate)
{
res = mysql_store_result(connection);
}
}
}
};
class Admin
{
Mysql adminMain;
public:
void admin_panel()
{
re_try_admin:
top_printing();
setPointer(60, 17);
cout << "Admin Panel";
setPointer(60, 19);
cout << "1. Search Employee";
setPointer(60, 21);
cout << "2. Register Employee";
setPointer(60, 23);
cout << "3. Update Employee";
setPointer(60, 25);
cout << "4. Delete Employee";
setPointer(60, 27);
cout << "5. Employee Salary";
setPointer(60, 29);
cout << "6. View Salary";
setPointer(60, 31);
cout << "7. Work Assignment";
setPointer(60, 33);
cout << "8. Advance Salary";
setPointer(60, 35);
cout << "9. Username/Password Change";
setPointer(60, 37);
cout << "10. Notice";
setPointer(92, 19);
cout << "11. View Work";
setPointer(92, 21);
cout << "12. View Notice";
setPointer(92, 23);
cout << "13. Delete Notice";
setPointer(92, 25);
cout << "14. Logout";
setPointer(60, 39);
cout << "Press the number .... ";
cin >> menu_select;
fflush(stdin);
switch (menu_select)
{
case 1:
employee_searching();
break;
case 2:
employee_registration();
break;
case 3:
employee_update();
break;
case 4:
employee_delete();
break;
case 5:
employee_salary();
break;
case 6:
view_salary();
break;
case 7:
work_assignment();
break;
case 8:
advance_salary();
break;
case 9:
username_password_change();
break;
case 10:
notice();
break;
case 11:
view_work();
break;
case 12:
view_notice();
break;
case 13:
notice_delete();
break;
case 14:
logout();
break;
default:
setPointer(60, 42);
cout << "Wrong Input!";
setPointer(60, 44);
cout << "Hit Enter to re-enter and Esc to exit ....";
retry_key = _getch();
if (retry_key == 27)
{
exit(0);
}
else
{
goto re_try_admin;
}
}
}
void employee_searching()
{
int search_id = 0, search_post = 0, rows_in_employee = 0, table_y = 22;
string search_name;
top_printing();
setPointer(60, 17);
cout << "Search Method";
setPointer(60, 19);
cout << "1. By Employee ID";
setPointer(60, 21);
cout << "2. By Name";
setPointer(60, 23);
cout << "3. By Post";
setPointer(60, 26);
cout << "Press the number .... ";
cin >> menu_select;
fflush(stdin);
if(menu_select == 1)
{
setPointer(60, 29);
cout << "Employee ID : ";
fflush(stdin);
cin >> search_id;
stringstream query_holder;
query_holder << "select * from employee where id = "<<search_id<<"";
string temp_query = query_holder.str();
const char* final_query = temp_query.c_str();
adminMain.query_select(final_query);
rows_in_employee = mysql_num_rows(adminMain.res);
if(rows_in_employee==0)
{
setPointer(60, 32);
cout << "No Record Found";
}
else
{
top_printing();
setPointer(60, 17);
cout << "Query Result";
setPointer(30, 20);
cout << "ID" << setw(40) << "Name" << setw(20) << "Age" << setw(20) << "Post Code" << setw(20) << "Phone";
setPointer(30, 21);
cout << "------------------------------------------------------------------------------------------------------";
while((adminMain.row = mysql_fetch_row(adminMain.res)))
{
setPointer(30,table_y++);
cout <<adminMain.row[0]<< setw(40) <<adminMain.row[1]<< setw(20) <<adminMain.row[2]<< setw(20) <<adminMain.row[3] << setw(20) << adminMain.row[4];
}
}
}
else if (menu_select == 2)
{
setPointer(60, 29);
cout << "Employee Name : ";
fflush(stdin);
getline(cin, search_name);
stringstream query_holder;
query_holder << "select * from employee where name = '"<<search_name<<"'";
string temp_query = query_holder.str();
const char* final_query = temp_query.c_str();
adminMain.query_select(final_query);
rows_in_employee = mysql_num_rows(adminMain.res);
if(rows_in_employee == 0)
{
setPointer(60, 32);
cout << "No Record Found";
}
else
{
top_printing();
setPointer(60, 17);
cout << "Query Result";
setPointer(30, 20);
cout << "ID" << setw(40) << "Name" << setw(20) << "Age" << setw(20) << "Post Code" << setw(20) << "Phone";
setPointer(30, 21);
cout << "------------------------------------------------------------------------------------------------------";
while((adminMain.row = mysql_fetch_row(adminMain.res)))
{
setPointer(30,table_y++);
cout <<adminMain.row[0]<< setw(40) <<adminMain.row[1]<< setw(20) <<adminMain.row[2]<< setw(20) <<adminMain.row[3] << setw(20) << adminMain.row[4];
}
}
}
else
{
setPointer(60, 29);
cout << "Employee Post : ";
fflush(stdin);
cin >> search_post;
stringstream query_holder;
query_holder << "select * from employee where post_code = "<<search_post<<"";
string temp_query = query_holder.str();
const char* final_query = temp_query.c_str();
adminMain.query_select(final_query);
rows_in_employee = mysql_num_rows(adminMain.res);
if(rows_in_employee==0)
{
setPointer(60, 32);
cout << "No Record Found";
}
else
{
top_printing();
setPointer(60, 17);
cout << "Query Result";
setPointer(30, 20);
cout << "ID" << setw(40) << "Name" << setw(20) << "Age" << setw(20) << "Post Code" << setw(20) << "Phone";
setPointer(30, 21);
cout << "------------------------------------------------------------------------------------------------------";
while((adminMain.row = mysql_fetch_row(adminMain.res)))
{
setPointer(30,table_y++);
cout <<adminMain.row[0]<< setw(40) <<adminMain.row[1]<< setw(20) <<adminMain.row[2]<< setw(20) <<adminMain.row[3] << setw(20) << adminMain.row[4];
}
}
}
}
void employee_registration()
{
retry_registeration:
string emp_name, phone, username_in, password_in;
int age = 0, post_code = 0, rows_in_userpass = 0, insert_result = 0, insert_result2 = 0;
float emp_salary = 0, pf = 0;
top_printing();
setPointer(60, 17);
cout << "Registration";
setPointer(60, 18);
cout << "Fill in the Details :";
setPointer(60, 22);
cout << "Employee Name :";
setPointer(60, 24);
cout << "Age :";
setPointer(60, 26);
cout << "Post :";
setPointer(60, 28);
cout << "Phone :";
setPointer(76, 22);
fflush(stdin);
getline(cin, emp_name);
setPointer(76, 24);
fflush(stdin);
cin >> age;
if(age<18 || age >88)
{
setPointer(60, 31);
cout << "Wrong AGE!";
setPointer(60, 44);
cout << "Hit Enter to re-enter and Esc to exit ....";
retry_key = _getch();
if (retry_key == 27)
{
exit(0);
}
else
{
goto retry_registeration;
};
}
setPointer(76, 26);
fflush(stdin);
cin >> post_code;
if(post_code != 1 && post_code != 2)
{
setPointer(60, 31);
cout << "Wrong Input!";
setPointer(60, 44);
cout << "Hit Enter to re-enter and Esc to exit ....";
retry_key = _getch();
if (retry_key == 27)
{
exit(0);
}
else
{
goto retry_registeration;
}
}
setPointer(76, 28);
fflush(stdin);
getline(cin,phone);
if(phone.size()<10)
{
setPointer(60, 31);
cout << "Wrong Phone!";
setPointer(60, 44);
cout << "Hit Enter to re-enter and Esc to exit ....";
retry_key = _getch();
if (retry_key == 27)
{
exit(0);
}
else
{
goto retry_registeration;
}
}
retry_credentials:
setPointer(60, 31);
cout << "Login Credentials :";
setPointer(60, 33);
cout << "USERNAME : ";
setPointer(60, 35);
cout << "PASSWORD : ";
setPointer(76, 33);
fflush(stdin);
cin >> username_in;
stringstream query_holder;
query_holder << "select * from userpass where username = '"<<username_in<<"'";
string temp_query = query_holder.str();
const char* final_query = temp_query.c_str();
adminMain.query_select(final_query);
adminMain.row = mysql_fetch_row(adminMain.res);
rows_in_userpass = mysql_num_rows(adminMain.res);
if(rows_in_userpass!=0)
{
setPointer(60, 37);
cout << "Username is Already Taken! Retry";
_getch();
setPointer(86, 33);
cout <<"\b\b\b\b\b\b\b\b\b\b ";
setPointer(92, 37);
cout << "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b ";
goto retry_credentials;
}
setPointer(76, 35);
fflush(stdin);
cin >> password_in;
stringstream query_holder2;
query_holder2 << "INSERT INTO `employee`(`id`, `name`, `age`, `post_code`, `phone`) VALUES (NULL,'"<<emp_name<<"', '"<<age<<"', '"<<post_code<<"', '"<<phone<<"')";
string temp_query2 = query_holder2.str();
const char* final_query2 = temp_query2.c_str();
insert_result = adminMain.query_executor(final_query2);
stringstream query_holder3;
query_holder3 << "INSERT INTO `userpass` (`id`, `username`, `password`, `post_code`) VALUES (NULL,'"<<username_in<<"', '"<<password_in<<"','"<<post_code<<"')";
string temp_query3 = query_holder3.str();
const char* final_query3 = temp_query3.c_str();
insert_result2 = adminMain.query_executor(final_query3);
if(insert_result == 1 && insert_result2 == 1)
{
setPointer(60, 38);
cout << "Recorded!!";
setPointer(60, 39);
cout << "Hit Enter to continue....";
_getch();
stringstream query_holder4;
query_holder4 << "SELECT * FROM `employee` WHERE `name` LIKE '"<<emp_name<<"'";
string temp_query4 = query_holder4.str();
const char* final_query4 = temp_query4.c_str();
adminMain.query_select(final_query4);
adminMain.row = mysql_fetch_row(adminMain.res);
top_printing();
setPointer(60, 17);
cout << "Registration";
setPointer(60, 19);
cout << "Salary Input";
setPointer(60, 21);
cout << "Salary : ";
fflush(stdin);
cin >> emp_salary;
pf = 0.1*emp_salary;
stringstream query_holder5;
query_holder5 << "INSERT INTO `salary`(`id`, `emp_id`, `pf`, `advance_salary`, `salary_deduction`, `rent`, `travel`, `salary`) VALUES ('NULL','"<<adminMain.row[0]<<"','"<<pf<<"','NULL','NULL','NULL','NULL','"<<emp_salary<<"')";
string temp_query5 = query_holder5.str();
const char* final_query5 = temp_query5.c_str();
adminMain.query_executor(final_query5);
setPointer(60, 24);
cout << "Salary Recorded!!";
setPointer(60, 26);
cout << "Hit Enter to continue....";
_getch();
top_printing();
setPointer(60, 17);
cout << "Registration";
setPointer(60, 19);
cout << "Employee Details Successfully Inserted.";
setPointer(60, 21);
cout << "Employee ID : " << adminMain.row[0];
setPointer(60, 24);
cout << "Hit Enter to continue....";
_getch();
}
else
{
setPointer(60, 37);
cout << "Insert Failed!";
_getch();
}
}
void employee_update()
{
string emp_name, phone;
int employee_id = 0, rows_in_employee, age = 0, post_code = 0, update_result = 0;
retry_update:
top_printing();
setPointer(60, 17);
cout << "Employee Update";
setPointer(60, 20);
cout << "Employee ID :";
setPointer(74, 20);
fflush(stdin);
cin >> employee_id;
stringstream query_holder;
query_holder << "select * from employee where id = "<<employee_id<<"";
string temp_query = query_holder.str();
const char* final_query = temp_query.c_str();
adminMain.query_select(final_query);
adminMain.row = mysql_fetch_row(adminMain.res);
rows_in_employee = mysql_num_rows(adminMain.res);
if(rows_in_employee==0)
{
setPointer(60, 32);
cout << "No Record Found";
setPointer(60, 33);
cout << "Hit Enter to re-enter and Esc to exit ....";
retry_key = _getch();
if (retry_key == 27)
{
exit(0);
}
else
{
goto retry_update;
}
}
else
{
setPointer(60, 32);
cout << "Record Found";
setPointer(60, 33);
cout << "Hit Enter to continue....";
_getch();
top_printing();
setPointer(60, 17);
cout << "Registration";
setPointer(60, 18);
cout << "Fill in the Details :";
setPointer(60, 22);
cout << "Employee Name :";
setPointer(60, 24);
cout << "Age :";
setPointer(60, 26);
cout << "Post :";
setPointer(60, 28);
cout << "Phone :";
setPointer(76, 22);
fflush(stdin);
getline(cin, emp_name);
setPointer(76, 24);
fflush(stdin);
cin >> age;
if(age<18 || age >88)
{
setPointer(60, 31);
cout << "Wrong AGE!";
setPointer(60, 44);
cout << "Hit Enter to re-enter and Esc to exit ....";
retry_key = _getch();
if (retry_key == 27)
{
exit(0);
}
else
{
goto retry_update;
};
}
setPointer(76, 26);
fflush(stdin);
cin >> post_code;
if(post_code != 1 && post_code != 2)
{
setPointer(60, 31);
cout << "Wrong Input!";
setPointer(60, 44);
cout << "Hit Enter to re-enter and Esc to exit ....";
retry_key = _getch();
if (retry_key == 27)
{
exit(0);
}
else
{
goto retry_update;
}
}
setPointer(76, 28);
fflush(stdin);
getline(cin,phone);
if(phone.size()<10)
{
setPointer(60, 31);
cout << "Wrong Phone!";
setPointer(60, 44);
cout << "Hit Enter to re-enter and Esc to exit ....";
retry_key = _getch();
if (retry_key == 27)
{
exit(0);
}
else
{
goto retry_update;
}
}
stringstream query_holder2;
query_holder2 << "UPDATE `employee` SET `name`='"<<emp_name<<"',`age`='"<<age<<"',`post_code`='"<<post_code<<"',`phone`='"<<phone<<"' WHERE id = "<<employee_id<<"";
string temp_query2 = query_holder2.str();
const char* final_query2 = temp_query2.c_str();
update_result = adminMain.query_executor(final_query2);
if(update_result == 1)
{
setPointer(60, 38);
cout << "Recorded Updated!!";
setPointer(60, 39);
cout << "Hit Enter to continue....";
_getch();
}
else
{
setPointer(60, 37);
cout << "Update Failed!";
setPointer(60, 44);
cout << "Hit Enter to re-enter and Esc to exit ....";
retry_key = _getch();
if (retry_key == 27)
{
exit(0);
}
else
{
goto retry_update;
}
}
}
}
void employee_delete()
{
int employee_id = 0, delete_emp = 0, delete_emp2 = 0;
top_printing();
setPointer(60, 17);
cout << "Employee Delete";
setPointer(60, 20);
cout << "Employee ID :";
setPointer(74, 20);
fflush(stdin);
cin >> employee_id;
stringstream query_holder;
query_holder << "DELETE FROM `employee` WHERE id = "<<employee_id<<"";
string temp_query = query_holder.str();
const char* final_query = temp_query.c_str();
delete_emp = adminMain.query_executor(final_query);
stringstream query_holder2;
query_holder2 << "DELETE FROM `userpass` WHERE id = "<<employee_id<<"";
string temp_query2 = query_holder2.str();
const char* final_query2 = temp_query2.c_str();
delete_emp2 = adminMain.query_executor(final_query2);
if(delete_emp == 1 && delete_emp2 == 1)
{
setPointer(60, 23);
cout << "Deleted!!";
}
else
{
setPointer(60, 23);
cout << "Deletation Failed!!";
}
}
void work_assignment()
{
string work, employee_name;
int employee_name_search = 0, work_assign_result = 0;
retry_work_assignment:
top_printing();
setPointer(60, 17);
cout << "Work Assignment";
setPointer(60, 18);
cout << "Fill in the Details :";
setPointer(60, 22);
cout << "Work Name :";
setPointer(60, 24);
cout << "Employee Name :";
setPointer(76, 22);
fflush(stdin);
getline(cin, work);
setPointer(76, 24);
fflush(stdin);
getline(cin, employee_name);
stringstream query_holder;
query_holder << "SELECT * FROM `employee` WHERE `name` LIKE '"<<employee_name<<"'";
string temp_query = query_holder.str();
const char* final_query = temp_query.c_str();
adminMain.query_select(final_query);
adminMain.row = mysql_fetch_row(adminMain.res);
employee_name_search = mysql_num_rows(adminMain.res);
if(employee_name_search == 0)
{
setPointer(60, 32);
cout << "There is no Employee named " << employee_name;
setPointer(60, 44);
cout << "Hit Enter to re-enter and Esc to exit ....";
retry_key = _getch();
if (retry_key == 27)
{
exit(0);
}
else
{
goto retry_work_assignment;
}
}
else
{
stringstream query_holder2;
query_holder2 << "INSERT INTO `work`(`id`, `work_name`, `work_by`, `work_to`) VALUES ('NULL','"<<work<<"','Admin','"<<employee_name<<"')";
string temp_query2 = query_holder2.str();
const char* final_query2 = temp_query2.c_str();
work_assign_result = adminMain.query_executor(final_query2);
if(work_assign_result == 1)
{
setPointer(60, 32);
cout << "Work Assisgned!!";
}
else
{
setPointer(60, 32);
cout << "Work Not Assisgned!!";
setPointer(60, 44);
cout << "Hit Enter to re-enter and Esc to exit ....";
retry_key = _getch();
if (retry_key == 27)
{
exit(0);
}
else
{
goto retry_work_assignment;
}
}
}
}
void advance_salary()
{
float advance_salary_amount;
string employee_name, temp_employee_id;
int employee_name_search = 0, advance_salary_result = 0;
retry_advance_salary:
top_printing();
setPointer(60, 17);
cout << "Advance Salary";
setPointer(60, 18);
cout << "Fill in the Details :";
setPointer(60, 22);
cout << "Employee Name :";
setPointer(60, 24);
cout << "Total Amount :";
setPointer(77, 22);
fflush(stdin);
getline(cin, employee_name);
setPointer(77, 24);
fflush(stdin);
cin >> advance_salary_amount;
stringstream query_holder;
query_holder << "SELECT * FROM `employee` WHERE `name` = '"<<employee_name<<"'";
string temp_query = query_holder.str();
const char* final_query = temp_query.c_str();
adminMain.query_select(final_query);
adminMain.row = mysql_fetch_row(adminMain.res);
employee_name_search = mysql_num_rows(adminMain.res);
temp_employee_id = adminMain.row[0];
if(employee_name_search == 0)
{
setPointer(60, 32);
cout << "There is no Employee named " << employee_name;
setPointer(60, 44);
cout << "Hit Enter to re-enter and Esc to exit ....";
retry_key = _getch();
if (retry_key == 27)
{
exit(0);
}
else
{
goto retry_advance_salary;
}
}
else
{
stringstream query_holder2;
query_holder2 << "UPDATE `salary` SET `advance_salary`='"<< advance_salary_amount <<"' WHERE emp_id = "<< temp_employee_id <<"";
string temp_query2 = query_holder2.str();
const char* final_query2 = temp_query2.c_str();
advance_salary_result = adminMain.query_executor(final_query2);
if(advance_salary_result == 1)
{
setPointer(60, 32);
cout << "Advance Salary Recorded!!";
}
else
{
setPointer(60, 32);
cout << "Advance Salary NOT Recorded!!";
setPointer(60, 44);
cout << "Hit Enter to re-enter and Esc to exit ....";
retry_key = _getch();
if (retry_key == 27)
{
exit(0);
}
else
{
goto retry_advance_salary;
}
}
}
}
void notice()
{
string notice_title, notice_body, notice_by;
int notice_result = 0;
retry_notice:
top_printing();
setPointer(60, 17);
cout << "Notice";
setPointer(60, 18);
cout << "Fill in the Details :";
setPointer(60, 22);
cout << "Notice Title :";
setPointer(60, 24);
cout << "Notice Body :";
setPointer(60, 26);
cout << "Notice BY :";
setPointer(76, 22);
fflush(stdin);
getline(cin, notice_title);
setPointer(76, 24);
fflush(stdin);
getline(cin, notice_body);
setPointer(76, 26);
fflush(stdin);
getline(cin, notice_by);
stringstream query_holder;
query_holder << "INSERT INTO `notice`(`id`, `notice_title`, `notice_body`, `notice_by`) VALUES ('NULL','"<<notice_title<<"','"<<notice_body<<"','"<<notice_by<<"')";
string temp_query = query_holder.str();
const char* final_query = temp_query.c_str();
notice_result = adminMain.query_executor(final_query);
if(notice_result == 1)
{
setPointer(60, 32);
cout << "Notice Posted!!";
}
else
{
setPointer(60, 32);
cout << "Notice Post Failed!!";
setPointer(60, 44);
cout << "Hit Enter to re-enter and Esc to exit ....";
retry_key = _getch();
if (retry_key == 27)
{
exit(0);
}
else
{
goto retry_notice;
}
}
}
void username_password_change()
{
int employee_id = 0, rows_in_employee = 0, update_result = 0;
string username, password;
retry_update:
top_printing();
setPointer(60, 17);
cout << "Username/Password Update";
setPointer(60, 20);
cout << "Employee ID :";
setPointer(74, 20);
cin >> employee_id;
stringstream query_holder;
query_holder << "select * from employee where id = "<<employee_id<<"";
string temp_query = query_holder.str();
const char* final_query = temp_query.c_str();
adminMain.query_select(final_query);
adminMain.row = mysql_fetch_row(adminMain.res);
rows_in_employee = mysql_num_rows(adminMain.res);
if(rows_in_employee==0)
{
setPointer(60, 32);
cout << "No Record Found";
setPointer(60, 33);
cout << "Hit Enter to re-enter and Esc to exit ....";
retry_key = _getch();
if (retry_key == 27)
{