Skip to content

Commit bcd87b5

Browse files
Add files via upload
1 parent 55c281f commit bcd87b5

File tree

2 files changed

+1254
-0
lines changed

2 files changed

+1254
-0
lines changed

Client.java

+189
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
// NAME: Ehtisham Naveed
2+
// Reg. No.: 597-FBAS/BSIT4/F20
3+
//**********************************
4+
5+
package ACP.Client;
6+
import ACP.Employee.Employee;
7+
import javax.swing.*;
8+
import java.time.*;
9+
10+
//########## Client ###########################################
11+
class Client
12+
{
13+
public static void main(String[] ss)
14+
{
15+
String intsearch; int search;
16+
int records;
17+
final int limit = 50;
18+
Employee obj[] = new Employee[1];
19+
obj[0] = new Employee();
20+
21+
menu:
22+
while(true)
23+
{
24+
try
25+
{
26+
String choice = JOptionPane.showInputDialog(null," ****** MAIN MENU ****** "+
27+
"\n 1. Add New Employee record"+
28+
"\n 2. Update Employee Information"+
29+
"\n 3. Delete Employee Record"+
30+
"\n 4. Search & view Employee"+
31+
"\n 0. Total Records"+
32+
"\n 00. View All Records"+
33+
"\n E. Exit");
34+
switch(choice)
35+
{
36+
// *********************
37+
// Add Record
38+
case "1":
39+
records = obj[0].read_All_Records();
40+
if(records >= limit)
41+
JOptionPane.showMessageDialog(null,"Reached Maximun Records Limit \"50\"");
42+
else
43+
{
44+
setInfo:
45+
while(true)
46+
{
47+
String insertoption = obj[0].set_Employee_Information();
48+
switch(insertoption)
49+
{
50+
case "Y": case "y":
51+
obj[0].write_Record("EmpDB.dat");
52+
break;
53+
54+
case "N": case "n":
55+
continue setInfo;
56+
}
57+
break;
58+
}
59+
}
60+
break;
61+
62+
// *********************
63+
// Update Information
64+
case "2":
65+
update:
66+
while(true)
67+
{
68+
try
69+
{
70+
intsearch = JOptionPane.showInputDialog("Enter ID Number:");
71+
search = Integer.parseInt(intsearch);
72+
obj[0].update_Record_Information(search);
73+
break;
74+
}
75+
catch(NullPointerException e){continue menu;}
76+
catch(NumberFormatException e)
77+
{
78+
JOptionPane.showMessageDialog(null,"Record not Found");
79+
continue menu;
80+
}
81+
}
82+
break;
83+
84+
// *********************
85+
// Delete Record
86+
case "3":
87+
delete:
88+
while(true)
89+
{
90+
try
91+
{
92+
intsearch = JOptionPane.showInputDialog("Enter ID Number:");
93+
search = Integer.parseInt(intsearch);
94+
if(intsearch.equals(""))
95+
throw new NumberFormatException();
96+
obj[0].delete_Record(search);
97+
break;
98+
}
99+
catch(NumberFormatException e)
100+
{
101+
JOptionPane.showMessageDialog(null,"Record not Found");
102+
continue menu;
103+
}
104+
}
105+
break;
106+
107+
// *********************
108+
// Search Record
109+
case "4":
110+
search:
111+
while(true)
112+
{
113+
try
114+
{
115+
String seachoption = JOptionPane.showInputDialog(null," ****** Search Menu ****** "+
116+
"\n 1. BY Emp ID"+
117+
"\n 2. By Employee Name"+
118+
"\n 3. By Age"+
119+
"\n 4. By Job Catagory"+
120+
"\n 00. Back");
121+
122+
switch(seachoption)
123+
{
124+
// *********************
125+
// Search by ID
126+
case "1":
127+
obj[0].read_Records_By("ID");
128+
break;
129+
130+
// *********************
131+
// Search by Name
132+
case "2":
133+
obj[0].read_Records_By("Name");
134+
break;
135+
136+
// *********************
137+
// Search by Age
138+
case "3":
139+
obj[0].read_Records_By("Age");
140+
break;
141+
142+
// *********************
143+
// Search by Job Category
144+
case "4":
145+
obj[0].read_Records_By("Job");
146+
break;
147+
148+
// *********************
149+
// Back to Main Menu
150+
case "00":
151+
continue menu;
152+
153+
default:
154+
JOptionPane.showMessageDialog(null,"ERROR: Invalid","ERROR",JOptionPane.ERROR_MESSAGE);
155+
continue search;
156+
}
157+
break;
158+
}
159+
catch(NullPointerException e) {continue menu;}
160+
}
161+
break;
162+
163+
// *********************
164+
// View Amount Total Records
165+
case "0":
166+
records = obj[0].read_All_Records();
167+
JOptionPane.showMessageDialog(null,"Total Records: \"" + records + "\'");
168+
break;
169+
170+
// *********************
171+
// View All Records
172+
case "00":
173+
obj[0].show_All_Records();
174+
break;
175+
176+
// *********************
177+
// Exit
178+
case "E": case "e":
179+
System.exit(0);
180+
break;
181+
182+
default:
183+
JOptionPane.showMessageDialog(null,"ERROR: Invalid", "ERROR" ,JOptionPane.ERROR_MESSAGE);
184+
continue menu;
185+
}
186+
}catch(NullPointerException e){System.exit(0);}
187+
}
188+
}
189+
}

0 commit comments

Comments
 (0)