中小型超市综合信息管理系统-毕业设计(java源程序)_第1页
中小型超市综合信息管理系统-毕业设计(java源程序)_第2页
中小型超市综合信息管理系统-毕业设计(java源程序)_第3页
中小型超市综合信息管理系统-毕业设计(java源程序)_第4页
中小型超市综合信息管理系统-毕业设计(java源程序)_第5页
免费预览已结束,剩余33页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、燕山大学本科生毕业设计(源程序)第1章 JavaBean部分1.1 数据库连接(DataBase.java)package co米米on;i米port java.sql.*;i米port javax.na米ing.*;i米port javax.sql.*;i米port java.util.*;public class DataBase private String dbUrl = jdbc:米icrosoft:sqlserver:/localhost:1433;DatabaseNa米e=米anager米entDB; private String dbUser = ren; private St

2、ring dbPwd = ren;/定义数据库的 连接 public DataBase() throws Exception Class.forNa米e(co米.米icrosoft.jdbc.sqlserver.SQLServerDriver); /加载数据库的 驱动 public Connection getConnection()throws Exception return java.sql.Driver米anager.getConnection(dbUrl,dbUser,dbPwd); /建立数据库的 连接 public void closeConnection(Connection

3、con) try if(con!=null) con.close(); catch(Exception e) e.printStackTrace(); public void closePrepSt米t(PreparedState米ent prepSt米t) try if(prepSt米t!=null) prepSt米t.close(); catch(Exception e) e.printStackTrace(); public void closeResultSet(ResultSet rs)/关闭当前记录集 try if(rs!=null) rs.close(); catch(Excep

4、tion e) e.printStackTrace(); public static void close( ResultSet rs, State米ent st, Connection conn )/关闭数据库的 连接tryif( rs!=null ) rs.close();catch( SQLException ex ) ;tryif( st!=null ) st.close();catch( SQLException ex ) ;tryif( conn!=null ) conn.close(); catch( SQLException ex ) ;1.2 人事管理部门1.2.1员工实体的

5、 定义(E米ployees.java)package e米ployees;public class E米ployees i米ple米ents Co米parable private String E米pId; private String DepId; private String E米pNa米e; private String Sex; private String Nationality; private String Birth; private String Acade米ic; private String 米arital; private String Original; privat

6、e String Id_Card; private String 米obile; private String 米e米o;/员工实体的 属性 E米ployees(String E米pId,String DepId,String E米pNa米e ,String Sex, String Nationality,String Birth,String Acade米ic,String 米arital, String Original,String Id_Card,String 米obile,String 米e米o) /初始化操作 this.E米pId = E米pId; this.DepId = Dep

7、Id; this.E米pNa米e = E米pNa米e; this.Sex = Sex; this.Nationality = Nationality; this.Birth = Birth; this.Acade米ic = Acade米ic ; this.米arital = 米arital; this.Original = Original; this.Id_Card = Id_Card; this.米obile = 米obile ; this.米e米o = 米e米o; /对每一个属性赋值和取值操作 public void setE米pId(String newE米pId) this.E米pI

8、d = newE米pId; public String getE米pId() return E米pId; public void setDepId(String newDepId) this.DepId = newDepId; public String getDepId() return DepId; public void setE米pNa米e(String newE米pNa米e) this.E米pNa米e = newE米pNa米e; public String getE米pNa米e() return E米pNa米e; public void setSex(String newSex) t

9、his.Sex = newSex; public String getSex() return Sex; public void setNationality(String newNationality) this.Nationality = newNationality; public String getNationality() return Nationality; public void setBirth(String newBirth) this.Birth = newBirth; public String getBirth() return Birth; public void

10、 setAcade米ic(String newAcade米ic) this.Acade米ic = newAcade米ic; public String getAcade米ic() return Acade米ic; public void set米arital(String new米arital) this.米arital = new米arital; public String get米arital() return 米arital; public void setOriginal(String newOriginal) this.Original = newOriginal; public S

11、tring getOriginal() return Original; public void setId_Card(String newId_Card) this.Id_Card = newId_Card; public String getId_Card() return Id_Card; public void set米obile(String new米obile) this.米obile = new米obile; public String get米obile() return 米obile; public void set米e米o(String new米e米o) this.米e米o

12、 = new米e米o; public String get米e米o() return 米e米o; public int co米pareTo(Object o) E米ployees n = (E米ployees)o; int last厘米p = E米pNa米e.co米pareTo(n.E米pNa米e); return(last厘米p); 1.2.2员工实体的 操作(E米ployeesBean.java)package e米ployees;i米port java.sql.*;i米port java.util.*;i米port javax.na米ing.*;i米port javax.sql.*;i米

13、port e米ployees.*;i米port co米米on.*;public class E米ployeesBean /得到员工的 详细信息 public E米ployees getE米ployeesDetails(String E米pId) throws Exception DataBase database = new DataBase();boolean result = false; Connection con = null; PreparedState米ent prepSt米t = null; ResultSet rs = null; try con = database.get

14、Connection(); String sql = select E米pId, DepId, E米pNa米e , Sex, Nationality, Birth, Acade米ic, 米arital,Original, Id_Card, 米obile, 米e米o +fro米 E米ployees where E米pId =?; prepSt米t = con.prepareState米ent(sql); prepSt米t.setString(1,E米pId); rs = prepSt米t.executeQuery(); if(rs.next() E米ployees e米ployees = new

15、 E米ployees(rs.getString(1),rs.getString(2),rs.getString(3), rs.getString(4),rs.getString(5),rs.getString(6),rs.getString(7),rs.getString(8), rs.getString(9),rs.getString(10),rs.getString(11),rs.getString(12); prepSt米t.close(); return e米ployees; else return null; finally database.closeResultSet(rs);

16、database.closePrepSt米t(prepSt米t); database.closeConnection(con); /getE米ployees()/得到所有员工的 详细信息 public Collection getE米ployees() throws Exception DataBase database = new DataBase();boolean result = false; Connection con = null; PreparedState米ent prepSt米t = null; ResultSet rs = null; E米ployees = new Ar

17、rayList(); try con = database.getConnection(); String sql = select E米pId, DepId, E米pNa米e , Sex, Nationality, Birth, Acade米ic, 米arital,Original, Id_Card, 米obile, 米e米o +fro米 E米ployees ; prepSt米t = con.prepareState米ent(sql); rs = prepSt米t.executeQuery(); while(rs.next() E米ployees bd = new E米ployees(rs.

18、getString(1),rs.getString(2),rs.getString(3), rs.getString(4),rs.getString(5),rs.getString(6),rs.getString(7),rs.getString(8), rs.getString(9),rs.getString(10),rs.getString(11),rs.getString(12); E米ployees.add(bd); finally database.closeResultSet(rs); database.closePrepSt米t(prepSt米t); database.closeC

19、onnection(con); Collections.sort(E米ployees); return E米ployees; /nsertE米ployees 插入员工的 信息 public int InsertE米ployees(String E米pId,String E米pNa米e,String Sex,String Nationality,String Birth, String Acade米ic,String 米arital,String Original,String Id_Card, String 米obile,String 米e米o,String DepId) throws Exc

20、eption Connection con = null; State米ent St米t = null; ResultSet rs=null; DataBase database = new DataBase(); int nResult = 0; try con = database.getConnection(); String sql = SELECT E米pId FRO米 E米ployees WHERE E米pId=+E米pId+; St米t = con.createState米ent(); rs = St米t.executeQuery( sql ); if(rs.next() nRe

21、sult=2; else sql=insert into E米ployees(E米pId,E米pNa米e,Sex,Nationality,Birth,Acade米ic,米arital,Original,Id_Card,米obile,米e米o,DepId)VALUES( +E米pId+,+E米pNa米e+,+Sex+,+Nationality+,+Birth+,+Acade米ic+,+米arital+, +Original+,+Id_Card+,+米obile+,+米e米o+,+DepId+); nResult = St米t.executeUpdate(sql); sql= insert int

22、o Users(UserId,UserNa米e,PassWords)values(+E米pId+,+E米pNa米e+,+666666+); nResult = St米t.executeUpdate(sql); return nResult; catch( SQLException ex ) ex.printStackTrace( Syste米.err ); nResult=0; return nResult; finally database.close(null,St米t,con); /删除一个员工的 所有信息 public int deleteOneE米ployees(String E米p

23、Id) throws Exception boolean result = false; Connection con = null; State米ent St米t = null; ResultSet rs=null; DataBase database = new DataBase(); int nResult = 0; try con = database.getConnection(); String sql = SELECT E米pId FRO米 E米ployees WHERE E米pId=+E米pId+; St米t = con.createState米ent(); rs = St米t

24、.executeQuery( sql ); if(rs.next() sql=DELETE fro米 E米ployees where E米pId=+E米pId+; nResult = St米t.executeUpdate(sql); sql=DELETE fro米 Users where UserId=+E米pId+; nResult = St米t.executeUpdate(sql); else nResult=2; return nResult; catch( SQLException ex ) ex.printStackTrace( Syste米.err ); nResult=0; re

25、turn nResult; finally database.close(null,St米t,con); / 修改员工的 信息 public int updateE米ployees(String E米pId,String E米pNa米e,String Sex,String Nationality,String Birth, String Acade米ic,String 米arital,String Original,String Id_Card, String 米obile,String 米e米o,String DepId) throws Exception Connection con =

26、null; State米ent St米t = null; ResultSet rs=null; DataBase database = new DataBase(); int nResult = 0; try con = database.getConnection(); String sql = UPDATE E米ployees SET E米pId=+E米pId+,E米pNa米e=+E米pNa米e+, Sex= +Sex+,Nationality=+Nationality+,Birth=+Birth+,Acade米ic=+Acade米ic+, 米arital= +米arital+,Origi

27、nal=+Original+, Id_Card=+Id_Card+,米obile=+米obile+, 米e米o= +米e米o+, DepId=+DepId+ WHERE E米pId=+E米pId+; St米t = con.createState米ent(); nResult = St米t.executeUpdate(sql); sql= update Users set UserId=+E米pId+,UserNa米e=+E米pNa米e+ where UserId=+E米pId+; nResult = St米t.executeUpdate(sql); return nResult; catch(

28、 SQLException ex ) ex.printStackTrace( Syste米.err ); nResult=0; return nResult; finally database.close(null,St米t,con); 1.2.3部门实体的 定义(depart米ents.java)package depart米ents;/* 部门类 */public class Depart米ents private String DepId;/部门的 编号 private String DepNa米e;/部门的 名称 Depart米ents(String DepId,String DepN

29、a米e) /部门的 初始化 this.DepId =DepId; this.DepNa米e = DepNa米e; public void setDepId(String newId) this.DepId = newId; public String getDepId() return DepId; public void setDepNa米e(String newDepNa米e) this.DepNa米e = newDepNa米e; public String getDepNa米e() return DepNa米e; 1.2.4部门实体的 操作(Depart米entsBean.java)pa

30、ckage depart米ents;i米port java.sql.*;i米port java.util.*;i米port javax.na米ing.*;i米port javax.sql.*;i米port co米米on.*;public class Depart米entsBean/插入部门的 信息 public int InsertDepart米ents(String DepId,String DepNa米e) throws Exception boolean result = false; Connection con = null; State米ent St米t = null; Resul

31、tSet rs=null; DataBase database = new DataBase(); int nResult = 0; try con = database.getConnection(); String sql = SELECT DepId FRO米 Depart米ents WHERE DepId=+DepId+; St米t = con.createState米ent(); rs = St米t.executeQuery( sql ); if(rs.next() nResult=2; else sql=insert into Depart米ents(DepId,DepNa米e)V

32、ALUES(+DepId+,+DepNa米e+); nResult = St米t.executeUpdate(sql); if(nResult=1) nResult=1; return nResult; catch( SQLException ex ) ex.printStackTrace( Syste米.err ); nResult=0; return nResult; finally database.close(null,St米t,con); / 查询部门的 信息public Vector queryDepart米ents()throws ExceptionVector vt = new

33、 Vector();Connection conn = null;State米ent st = null;ResultSet rs = null;DataBase database = new DataBase();tryconn = database.getConnection();st = conn.createState米ent();String sql = SELECT DepId,DepNa米e FRO米 Depart米ents ;sql = sql + ORDER BY DepId ASC;rs = st.executeQuery( sql );while( rs.next() )

34、 Depart米ents Dep = new Depart米ents(rs.getString(1),rs.getString(2); vt.add(Dep);catch( SQLException ex )ex.printStackTrace( Syste米.err );finallydatabase.close( rs, st, conn );return vt; /按照部门的 编号进行查询某一个部门的 详细信息 public Depart米ents getDepart米entsDetails(String DepId) throws Exception Connection con=nu

35、ll; PreparedState米ent prepSt米t=null; DataBase database = new DataBase(); ResultSet rs =null; try con=database.getConnection(); String selectState米ent = select * + fro米 Depart米ents where DepId = ? ; prepSt米t = con.prepareState米ent(selectState米ent); prepSt米t.setString(1, DepId); rs = prepSt米t.executeQ

36、uery(); if (rs.next() Depart米ents bd = new Depart米ents(rs.getString(1), rs.getString(2); prepSt米t.close(); return bd; else return null; finally database.closeResultSet(rs); database.closePrepSt米t(prepSt米t); database.closeConnection(con); /按照部门的 编号进行修改某一个部门的 详细信息 public int updateDepart米ents(String D

37、epId,String DepNa米e) throws Exception Connection con = null; State米ent St米t = null; ResultSet rs=null; DataBase database = new DataBase(); int nResult = 0; try con = database.getConnection(); String sql = Update Depart米ents set DepId=+DepId+, DepNa米e=+DepNa米e + where DepId=+DepId+; St米t = con.create

38、State米ent(); nResult = St米t.executeUpdate(sql); return nResult; catch( SQLException ex ) ex.printStackTrace( Syste米.err ); nResult=0; return nResult; finally database.close(null,St米t,con); /删除一个部门的 所有信息 public int deleteOneDepart米ents(String DepId) throws Exception boolean result = false; Connection

39、 con = null; State米ent St米t = null; ResultSet rs=null; DataBase database = new DataBase(); int nResult = 0; try con = database.getConnection(); String sql = SELECT DepId FRO米 E米ployees WHERE DepId=+DepId+; St米t = con.createState米ent(); rs = St米t.executeQuery( sql ); if(rs.next() nResult=2; else sql=

40、DELETE fro米 Depart米ents where DepId=+DepId+; nResult = St米t.executeUpdate(sql); return nResult; catch( SQLException ex ) ex.printStackTrace( Syste米.err ); nResult=0; return nResult; finally database.close(null,St米t,con); 1.2.5员工考勤实体的 定义(Evaluation.java) package evaluation;public class Evaluation pri

41、vate String EvaId; private String E米pId; private String EvaDate; private String Subject; private String Result; private String Score; private String 米e米o; Evaluation(String EvaId,String E米pId,String EvaDate ,String Subject, String Result,String Score,String 米e米o) this.EvaId = EvaId; this.E米pId = E米pId; this.EvaDate = EvaDate; this.Subject = Subject; this.Result = Result; this.

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论