《java开发的ERP.docx》由会员分享,可在线阅读,更多相关《java开发的ERP.docx(47页珍藏版)》请在优知文库上搜索。
1、packagecom.tsO17.zjh:importjava.text.NumbcrFonnat;importjava.uti1.Iterator;importjava.uti1.1.ist;importjava.uti1.Map:importjava,ti1.Scanner:importco.tsO17.zjh.dao.II)eptD0:importcoo.tsO17.zjh.ept!=nu1.1.)Isten.out.PrirH1.n(您输入的部名巳存在);return:Departmentdept=newDepartmentO:dept.SCtDeptNaec(dcptNamc):bo
2、o1.eanf1.ag=fa1.se;tryf1.ag=this.dao.doCrea1.c(dept);catch(Exceptione)e.printStackTrace();if(f1.ag)(.print1.n(添加部门成功.):e1.seSystem.out.PrintInc1.添加部门失败);pub1.icvoidde1.Depnrtment()System,out.print1.n():System.out.Print(清输入要划除的部1编号:);intdeptId=sen.next1.nt();Departmentdept=gctDciartcntById(dcptId):if
3、(dept=nu1.1.)(System.out.PrinUn(您输入的部门不存在);return:IEmpDAOempD0=DAOFactory.getI1.impDxW1.nstanceO:1.isteps=nu1.1.:try(cmps三e11p1.)A0.findByDeptId(deptId);catch(Exceptione)e.PrintStackTraceO:if(emps!=nu1.1.)(this.ShowDepnrtment(dept):if(emps.sizeO0).SyS1.Cm.OUhprini1.nC该部门中有员工存在.若就除该部门,则相应的员工也会被超除.确定S
4、*(yn)?*);Stringopt=sen.next();if(opt.Cqua1.sIgnoreCase(wy,)boo1.eanf1.ag=fa1.se:try(empD().doth?IeteByDeptId(deptId);f1.ag=this.dao.doDeIete(deptId):catch(Exceptionc)(e.printStackTrace();)if(f1.ag)System,out.Prin1.InC粼除部门成功):e1.seSystem.out.PrintJnC田除部门失S):)e1.seSystem,out.PriInIn(魂定要的,除该部门信息吗(yn)?*
5、):Stringopt三sen.next();if(opt.equa1sIgnoreCase(wyw)Ixxi1.eanf1.ag=fa1.se:tryIf1.ag=this.dao.doDeIete(deptId);catch(Exceptione)(e.PrintStackTraceO:)if(f1.ag)System,out.PrintIn(itt除部门成功.):e1.se(System.out.printing剧除部门失JS.):)pub1.icvoidfindA11()1.istdepts=nu1.1:try(depts=this.dao.FindA1.1.0:catch(Excep
6、tione)e.printStackTrace();iftIdO:break:CaSe2:this.fir1.ByDctnameO:break;case0:return:whi1.e(opt!=0);pub1.icvoidfindByDeptnameOSystem.out.print1.n();System.out.PrirHc请输入查找的部门名称:):Stringdcp1.Name=sen.nextO;Departmentdept=get1.epartBentByNa11e(deptNa三e);if(dept!=nu1.1.)this.ShouDcpartment(dept):e1.seSy
7、stem.out.PrintIn(.相关信息不存在);pub1.icvoidFindByDeptIdO(Systmout.rint1.n();System.out.Print(i1输入要查找的部门号:*);intdeptId=sen.nextInt();Departmentdept=geiDepart*entById(deptId):if(dept!=nu1.1.)(this.ShouDepartment(dept);e1.seSystem.out.Prin1.In(相关信息不存在);pub1.icvoidUpdateDepartmentOSystem.out.print1.n():SySum
8、.。U1.mih输入要更新的部:编号:intktId=sen.ncxt1.nt():Departmentdept=getOepartBentById(deptId);if(dept=nu1.1.)ISystem.out.PrintIn(您输入的部门不存在);return:this.ShowDepartment(dept);System.out.print1.n(更蓊部门信息”):System,out.print111(=);System.out.print请输入新的部门名称:*);StringdeptName=sen.next();DepartmentrepeatDcpt=get1.karx1
9、1cn1.ByNamc(dcptNa11c):whi1.e(repeatDept!=nu1.1.)(:cm.out.Prirn1.n(您输入的部名杯已存在,请更新输入.):de)tNaroe=sen.nextO:repeatDcpt=getDcpartmentByNaroe(dciNano):Departmentnew1.)ept=newDeparteent():new1.)ept.SetDeptId(deptId);ncwDept.SCtDeptName(dcptme):boo1.eanf1.ag=fa1.se:try(f1.ag=this.dao.doUpdate(nevDept):Cat
10、Ch(Exceptione)e.printStackTrace();if(f1.ag)(System.out.PrintIr(更新员工信息成功;e1.seSystem.out.PriZ1.n(更新员工信息失败):pub1.icvoidsho*CroupAvgSaIaryAboutDeptO(Map加PtMdPnu1.1.;MapavgSa1.ary=nu1.1.:try(tetMap=this.dao.RetDepartrncntWapO:avgSa1.arythis.dao.getAverageSaIiiryByGroupO;catch(Exceptione)e.PrintStackTrac
11、eO:System.out.print1.n();System.out.print1.n(t部门平均薪水System.out.print1.n();System.out.print1.n(t部门熔号V部门名称t平均薪水.):System,out.printIn(=*):Iteratorit=avgS1.ary.keySet().iterator();NumberFormatfouat=NumberFoi-Bat.ge11nstance();t11rriat.SetMaxiHuaFraction1.)iNISa):whi1.e(it.hasNcxiO)(Integerid=it.next();S
12、ystem,out.printIn(,t*+id.intVa1.ue(),tt+(ieptMap.get(id),getIteptNamt?O,tr+format,format(avgSa1.ary.get(id):System.out.print1.n();pub1.icvoidShowEnipCountAboutDept()MapempCountMap=nu1.1.:MapdeptMap=nu1.1.;tryempCountMap=this.dao.getE三pCountyGroup();dept=this.dao.getDepartment():CatCh(Exceptionc)e.PrintStackTraceO;System,out.print1.n():Systmou