当前位置:网站首页>Enterprise employee management system VI: UI layer

Enterprise employee management system VI: UI layer

2021-11-25 17:49:57 Liang Yunliang

public class EEMS {

	private static ManagerController managerController = new ManagerController();
	private static DeptController deptController = new DeptController();
	private static EmpController empController = new EmpController();

	public static void main(String[] args) {
		EEMS eems = new EEMS();

		Scanner scanner = new Scanner(System.in);
		
		boolean loginRes = managerController.login(scanner);
		if(loginRes) {
			boolean flag = true;
			while (flag) {
				eems.mainMenu();
				System.out.println(" Please select , Input q sign out ");
				String op = scanner.next();
				switch (op) {
				case "1":
					eems.deptMenu(scanner);
					break;
				case "2":
					eems.empMenu(scanner);
					break;
				case "q":
					flag = false;
					System.out.println("exit");
					break;
				default:
					System.out.println(" Input error ");
					break;
				}
			}
		}else {
			System.out.println(" Log in again ");
		}
		
		if (scanner != null) {
			scanner.close();
		}
	}


	private void mainMenu() {
		System.out.println("=========================");
		System.out.println("1  Department of management ");
		System.out.println("2  Employee management ");
		System.out.println("=========================");
	}

	private void empMenu(Scanner scanner) {
		System.out.println("============ Employee menu ===========");
		System.out.println("1  List all employees ");
		System.out.println("2  Find employees by number ");
		System.out.println("3  Find employees by name ");
		System.out.println("4  Find employees by department number ");
		System.out.println("5  Increase staff ");
		System.out.println("6  Modify employees ");
		System.out.println("7  Delete employee ");
		System.out.println("=========================");
		int op = scanner.nextInt();
		switch (op) {
		case 1:
			try {
				empController.listAllEmp();
			} catch (IOException e) {
				e.printStackTrace();
			}
			break;
		case 2:
			try {
				empController.getEmpByEmpno(scanner);
			} catch (IOException e) {
				e.printStackTrace();
			}
			break;
		case 3:
			try {
				empController.getEmpByEname(scanner);
			} catch (IOException e) {
				e.printStackTrace();
			}
			break;
		case 4:
			try {
				empController.getEmpByDeptno(scanner);
			} catch (IOException e) {
				e.printStackTrace();
			}
			break;
		case 5:
			try {
				empController.addEmp(scanner);
			} catch (IOException e) {
				e.printStackTrace();
			}
			break;
		case 6:
			try {
				empController.updateEmp(scanner);
			} catch (IOException e) {
				e.printStackTrace();
			}
			break;
		case 7:
			try {
				empController.deletEmpByEmpno(scanner);
			} catch (IOException e) {
				e.printStackTrace();
			}
			break;
		}
	}
	
	private void deptMenu(Scanner scanner) {
		System.out.println("============ Department menu ===========");
		System.out.println("1  List all departments ");
		System.out.println("2  Find department by number ");
		System.out.println("3  Find department by name ");
		System.out.println("4  Add departments ");
		System.out.println("5  Revision Department ");
		System.out.println("6  Delete Department ");
		System.out.println("=========================");
		int op = scanner.nextInt();
		switch (op) {
		case 1:
			try {
				deptController.listAllDept();
			} catch (IOException e) {
				e.printStackTrace();
			}
			break;
		case 2:
			try {
				deptController.listDeptByDeptno(scanner);
			} catch (IOException e) {
				e.printStackTrace();
			}
			break;
		case 3:
			try {
				deptController.listDeptByDname(scanner);
			} catch (IOException e) {
				e.printStackTrace();
			}
			break;
		case 4:
			try {
				deptController.addDept(scanner);
			} catch (IOException e) {
				e.printStackTrace();
			}
			break;
		case 5:
			try {
				deptController.updateDept(scanner);
			} catch (IOException e) {
				e.printStackTrace();
			}
			break;
		case 6:
			try {
				deptController.deleteDept(scanner);
			} catch (IOException e) {
				e.printStackTrace();
			}
			break;
		}
	}
}

     
  • 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.

版权声明
本文为[Liang Yunliang]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/11/20211109092935748g.html

随机推荐