ImageVerifierCode 换一换
格式:DOCX , 页数:44 ,大小:25.05KB ,
资源ID:8654118      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/8654118.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(毕业设计源程序中小型超市综合信息管理系统.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

毕业设计源程序中小型超市综合信息管理系统.docx

1、毕业设计源程序中小型超市综合信息管理系统第1章 JavaBean部分1.1 数据库连接(DataBase.java)package common;import java.sql.*;import javax.naming.*;import javax.sql.*;import java.util.*;public class DataBase private String dbUrl = jdbc:microsoft:sqlserver:/localhost:1433;DatabaseName=ManagermentDB; private String dbUser = ren; privat

2、e String dbPwd = ren;/定义数据库的连接 public DataBase() throws Exception Class.forName(com.microsoft.jdbc.sqlserver.SQLServerDriver); /加载数据库的驱动 public Connection getConnection()throws Exception return java.sql.DriverManager.getConnection(dbUrl,dbUser,dbPwd); /建立数据库的连接 public void closeConnection(Connection

3、 con) try if(con!=null) con.close(); catch(Exception e) e.printStackTrace(); public void closePrepStmt(PreparedStatement prepStmt) try if(prepStmt!=null) prepStmt.close(); catch(Exception e) e.printStackTrace(); public void closeResultSet(ResultSet rs)/关闭当前记录集 try if(rs!=null) rs.close(); catch(Exce

4、ption e) e.printStackTrace(); public static void close( ResultSet rs, Statement st, Connection conn )/关闭数据库的连接 try if( rs!=null ) rs.close(); catch( SQLException ex ) ; try if( st!=null ) st.close(); catch( SQLException ex ) ; try if( conn!=null ) conn.close(); catch( SQLException ex ) ; 1.2 人事管理部门1

5、.2.1员工实体的定义(Employees.java)package employees;public class Employees implements Comparable private String EmpId; private String DepId; private String EmpName; private String Sex; private String Nationality; private String Birth; private String Academic; private String Marital; private String Original

6、; private String Id_Card; private String Mobile; private String Memo;/员工实体的属性 Employees(String EmpId,String DepId,String EmpName ,String Sex, String Nationality,String Birth,String Academic,String Marital, String Original,String Id_Card,String Mobile,String Memo) /初始化操作 this.EmpId = EmpId; this.DepI

7、d = DepId; this.EmpName = EmpName; this.Sex = Sex; this.Nationality = Nationality; this.Birth = Birth; this.Academic = Academic ; this.Marital = Marital; this.Original = Original; this.Id_Card = Id_Card; this.Mobile = Mobile ; this.Memo = Memo; /对每一个属性赋值和取值操作 public void setEmpId(String newEmpId) th

8、is.EmpId = newEmpId; public String getEmpId() return EmpId; public void setDepId(String newDepId) this.DepId = newDepId; public String getDepId() return DepId; public void setEmpName(String newEmpName) this.EmpName = newEmpName; public String getEmpName() return EmpName; public void setSex(String ne

9、wSex) this.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; publ

10、ic void setAcademic(String newAcademic) this.Academic = newAcademic; public String getAcademic() return Academic; public void setMarital(String newMarital) this.Marital = newMarital; public String getMarital() return Marital; public void setOriginal(String newOriginal) this.Original = newOriginal; p

11、ublic String getOriginal() return Original; public void setId_Card(String newId_Card) this.Id_Card = newId_Card; public String getId_Card() return Id_Card; public void setMobile(String newMobile) this.Mobile = newMobile; public String getMobile() return Mobile; public void setMemo(String newMemo) th

12、is.Memo = newMemo; public String getMemo() return Memo; public int compareTo(Object o) Employees n = (Employees)o; int lastCmp = EmpNpareTo(n.EmpName); return(lastCmp); 1.2.2员工实体的操作(EmployeesBean.java)package employees;import java.sql.*;import java.util.*;import javax.naming.*;import javax.sql.*;imp

13、ort employees.*;import common.*;public class EmployeesBean /得到员工的详细信息 public Employees getEmployeesDetails(String EmpId) throws Exception DataBase database = new DataBase(); boolean result = false; Connection con = null; PreparedStatement prepStmt = null; ResultSet rs = null; try con = database.getC

14、onnection(); String sql = select EmpId, DepId, EmpName , Sex, Nationality, Birth, Academic, Marital,Original, Id_Card, Mobile, Memo +from Employees where EmpId =?; prepStmt = con.prepareStatement(sql); prepStmt.setString(1,EmpId); rs = prepStmt.executeQuery(); if(rs.next() Employees employees = new

15、Employees(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); prepStmt.close(); return employees; else return null; finally database.closeResultSet(rs); d

16、atabase.closePrepStmt(prepStmt); database.closeConnection(con); /getEmployees()/得到所有员工的详细信息 public Collection getEmployees() throws Exception DataBase database = new DataBase(); boolean result = false; Connection con = null; PreparedStatement prepStmt = null; ResultSet rs = null; Employees = new Arr

17、ayList(); try con = database.getConnection(); String sql = select EmpId, DepId, EmpName , Sex, Nationality, Birth, Academic, Marital,Original, Id_Card, Mobile, Memo +from Employees ; prepStmt = con.prepareStatement(sql); rs = prepStmt.executeQuery(); while(rs.next() Employees bd = new Employees(rs.g

18、etString(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); Employees.add(bd); finally database.closeResultSet(rs); database.closePrepStmt(prepStmt); database.closeCo

19、nnection(con); Collections.sort(Employees); return Employees; / nsertEmployees 插入员工的信息 public int InsertEmployees(String EmpId,String EmpName,String Sex,String Nationality,String Birth, String Academic,String Marital,String Original,String Id_Card, String Mobile,String Memo,String DepId) throws Exce

20、ption Connection con = null; Statement Stmt = null; ResultSet rs=null; DataBase database = new DataBase(); int nResult = 0; try con = database.getConnection(); String sql = SELECT EmpId FROM Employees WHERE EmpId=+EmpId+; Stmt = con.createStatement(); rs = Stmt.executeQuery( sql ); if(rs.next() nRes

21、ult=2; else sql=insert into Employees(EmpId,EmpName,Sex,Nationality,Birth,Academic,Marital,Original,Id_Card,Mobile,Memo,DepId)VALUES( +EmpId+,+EmpName+,+Sex+,+Nationality+,+Birth+,+Academic+,+Marital+, +Original+,+Id_Card+,+Mobile+,+Memo+,+DepId+); nResult = Stmt.executeUpdate(sql); sql= insert into

22、 Users(UserId,UserName,PassWords)values(+EmpId+,+EmpName+,+666666+); nResult = Stmt.executeUpdate(sql); return nResult; catch( SQLException ex ) ex.printStackTrace( System.err ); nResult=0; return nResult; finally database.close(null,Stmt,con); /删除一个员工的所有信息 public int deleteOneEmployees(String EmpId

23、) throws Exception boolean result = false; Connection con = null; Statement Stmt = null; ResultSet rs=null; DataBase database = new DataBase(); int nResult = 0; try con = database.getConnection(); String sql = SELECT EmpId FROM Employees WHERE EmpId=+EmpId+; Stmt = con.createStatement(); rs = Stmt.e

24、xecuteQuery( sql ); if(rs.next() sql=DELETE from Employees where EmpId=+EmpId+; nResult = Stmt.executeUpdate(sql); sql=DELETE from Users where UserId=+EmpId+; nResult = Stmt.executeUpdate(sql); else nResult=2; return nResult; catch( SQLException ex ) ex.printStackTrace( System.err ); nResult=0; retu

25、rn nResult; finally database.close(null,Stmt,con); / 修改员工的信息 public int updateEmployees(String EmpId,String EmpName,String Sex,String Nationality,String Birth, String Academic,String Marital,String Original,String Id_Card, String Mobile,String Memo,String DepId) throws Exception Connection con = nul

26、l; Statement Stmt = null; ResultSet rs=null; DataBase database = new DataBase(); int nResult = 0; try con = database.getConnection(); String sql = UPDATE Employees SET EmpId=+EmpId+,EmpName=+EmpName+, Sex= +Sex+,Nationality=+Nationality+,Birth=+Birth+,Academic=+Academic+, Marital= +Marital+,Original

27、=+Original+, Id_Card=+Id_Card+,Mobile=+Mobile+, Memo= +Memo+, DepId=+DepId+ WHERE EmpId=+EmpId+; Stmt = con.createStatement(); nResult = Stmt.executeUpdate(sql); sql= update Users set UserId=+EmpId+,UserName=+EmpName+ where UserId=+EmpId+; nResult = Stmt.executeUpdate(sql); return nResult; catch( SQ

28、LException ex ) ex.printStackTrace( System.err ); nResult=0; return nResult; finally database.close(null,Stmt,con); 1.2.3部门实体的定义(departments.java)package departments;/* 部门类 */public class Departments private String DepId; /部门的编号 private String DepName; /部门的名称 Departments(String DepId,String DepName) /部门的初始化 this.DepId =DepId; this.DepName = DepName; public void setDepId(String newId) this.DepId = newId; public String getDepId() return DepId; public void setDepName(String newDepName) this.DepName = newDepName;

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1