您好,欢迎光临本网站![请登录][注册会员]  
文件名称: java仓库管理
  所属分类: Java
  开发工具:
  文件大小: 130kb
  下载次数: 0
  上传时间: 2012-06-25
  提 供 者: shiyi*****
 详细说明: 货架仓库管理package real.action.dao; import java.io.PrintStream; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.swing.ComboBoxModel; import real.action.data.SupplierData; import real.action.sql.ConnectionFactory; public class SupplierDao { private Connection conn; private Statement statement; private PreparedStatement preparedStatement;//SQL 语句被 预编译并存储在 PreparedStatement 对象中。然后可以使用此对象多次高效地执行该语句。 private ResultSet resultSet;//结果集 public boolean addSupplier(SupplierData s)//添加供应商 { String sql = "insert into suppliers values(?,?,?,?,?,?,?,?)"; try { this.conn = ConnectionFactory.getConnection(); this.preparedStatement = this.conn.prepareStatement(sql); this.preparedStatement.setInt(1, s.getSupplierId()); this.preparedStatement.setString(2, s.getSupplierName()); this.preparedStatement.setString(3, s.getSupplierAddress()); this.preparedStatement.setString(4, s.getPostCode()); this.preparedStatement.setString(5, s.getSupplierTelephone()); this.preparedStatement.setString(6, s.getSupplierFax()); this.preparedStatement.setString(7, s.getSupplierRelationer()); this.preparedStatement.setString(8, s.getSupplierEmail()); int flag = this.preparedStatement.executeUpdate(); if (flag > 0) { return true; } } catch (Exception e) { e.printStackTrace(); } return false; } public boolean isExistSupplierData() { boolean flag = true; int row = 0; String sql = "select count(sup_id) as count from suppliers"; try { this.conn = ConnectionFactory.getConnection(); this.statement = this.conn.createStatement(); this.resultSet = this.statement.executeQuery(sql); if (this.resultSet.next()) { row = this.resultSet.getInt("count"); } if (row == 0) { return false; } } catch (Exception e) { e.printStackTrace(); } return flag; } public boolean isExistSupplierById(int number)//ID已存在 { boolean flag = false; String sql = "select sup_id from suppliers"; try { this.conn = ConnectionFactory.getConnection(); this.statement = this.conn.createStatement(); this.resultSet = this.statement.executeQuery(sql); while (this.resultSet.next()) { SupplierData supplierData = new SupplierData(); supplierData.setSupplierId(this.resultSet.getInt(1));//设置ID if (supplierData.getSupplierId() == number) {//比较ID flag = true; break; } } } catch (Exception e) { e.printStackTrace(); } return flag; } public List getFindAllSupplierId()//获取所有供应商id { List listsupplierId = new ArrayList();//滚动列表 String sql = "select sup_id from suppliers "; try { this.conn = ConnectionFactory.getConnection(); this.statement = this.conn.createStatement(); this.resultSet = this.statement.executeQuery(sql); while (this.resultSet.next()) listsupplierId.add(Integer.valueOf(this.resultSet.getInt(1))); } catch (Exception e) { e.printStackTrace(); } return listsupplierId; } public SupplierData getSupplierbySupplierName(String name) { SupplierData supplierData = null; String sql = "select * from suppliers where sup_name = ?"; try { this.conn = ConnectionFactory.getConnection(); this.preparedStatement = this.conn.prepareStatement(sql); this.preparedStatement.setString(1, name); this.resultSet = this.preparedStatement.executeQuery(); if (this.resultSet.next()) { supplierData = new SupplierData(); supplierData.setSupplierId(this.resultSet.getInt(1)); supplierData.setSupplierName(this.resultSet.getString(2)); supplierData.setSupplierAddress(this.resultSet.getString(3)); supplierData.setPostCode(this.resultSet.getString(4)); supplierData.setSupplierTelephone(this.resultSet.getString(5)); supplierData.setSupplierFax(this.resultSet.getString(6)); supplierData.setSupplierRelationer(this.resultSet.getString(7)); supplierData.setSupplierEmail(this.resultSet.getString(8)); } } catch (Exception e) { e.printStackTrace(); } return supplierData; } public Map getAllSupplier() { Map supplierData = new HashMap();//基于哈希表的 Map 接口的实现。此实现提供所有可选的映射操作 String sql = "select sup_id,sup_name,sup_address,postcode,sup_telephone,sup_fax,sup_relationer,sup_email from suppliers"; try { conn = ConnectionFactory.getConnection(); preparedStatement = conn.prepareStatement(sql); resultSet = preparedStatement.executeQuery(); while (resultSet.next())// 在此映射中关联指定值与指定键。使供应商ID与名称关联 supplierData.put(Integer.valueOf(resultSet.getInt("sup_id")), resultSet.getString("sup_name")); } catch (Exception e) { e.printStackTrace(); } return supplierData;//返回映射关系 } public SupplierData getSupplierbySupplierId(String number) { SupplierData supplierData = null; String sql = "select sup_id,sup_name,sup_address,postcode,sup_telephone,sup_fax,sup_relationer,sup_email from suppliers where sup_id = ?"; try { this.conn = ConnectionFactory.getConnection(); this.preparedStatement = this.conn.prepareStatement(sql); this.preparedStatement.setString(1, number); this.resultSet = this.preparedStatement.executeQuery(); if (this.resultSet.next()) { supplierData = new SupplierData(); supplierData.setSupplierId(this.resultSet.getInt(1)); supplierData.setSupplierName(this.resultSet.getString(2)); supplierData.setSupplierAddress(this.resultSet.getString(3)); supplierData.setPostCode(this.resultSet.getString(4)); supplierData.setSupplierTelephone(this.resultSet.getString(5)); supplierData.setSupplierFax(this.resultSet.getString(6)); supplierData.setSupplierRelationer(this.resultSet.getString(7)); supplierData.setSupplierEmail(this.resultSet.getString(8)); } } catch (Exception e) { e.printStackTrace(); } return supplierData; } public List getFindSupplier() { List lstSupplierData = new ArrayList(); String sql = "select sup_id,sup_name,sup_address,postcode,sup_telephone,sup_fax,sup_relationer,sup_email from suppliers"; try { this.conn = ConnectionFactory.getConnection(); this.statement = this.conn.createStatement(); this.resultSet = this.statement.executeQuery(sql); while (this.resultSet.next()) { lstSupplierData.add(Integer.valueOf(this.resultSet.getInt(1))); lstSupplierData.add(this.resultSet.getString(2)); lstSupplierData.add(this.resultSet.getString(3)); lstSupplierData.add(this.resultSet.getString(4)); lstSupplierData.add(this.resultSet.getString(5)); lstSupplierData.add(this.resultSet.getString(6)); lstSupplierData.add(this.resultSet.getString(7)); lstSupplierData.add(this.resultSet.getString(8)); } } catch (Exception e) { e.printStackTrace(); } return lstSupplierData; } public boolean updateSupplierById(SupplierData s)//按ID更新供应商 { boolean flag = false; String sql = "update suppliers set sup_name = ?,sup_address = ? ,postcode = ? ,sup_telephone = ? ,sup_fax = ? , sup_relationer = ? , sup_email = ? where sup_id = ?"; try { this.conn = ConnectionFactory.getConnection(); this.preparedStatement = this.conn.prepareStatement(sql); this.preparedStatement.setInt(8, s.getSupplierId()); this.preparedStatement.setString(1, s.getSupplierName()); this.preparedStatement.setString(2, s.getSupplierAddress()); this.preparedStatement.setString(3, s.getPostCode()); this.preparedStatement.setString(4, s.getSupplierTelephone()); this.preparedStatement.setString(5, s.getSupplierFax()); this.preparedStatement.setString(6, s.getSupplierRelationer()); this.preparedStatement.setString(7, s.getSupplierEmail()); int insertReow = this.preparedStatement.executeUpdate(); if (insertReow > 0) flag = true; } catch (Exception e) { e.printStackTrace(); } return flag; } public boolean deleteSupplierById(int number) { boolean flag = false; String sql = "delete from suppliers where sup_id=?"; try { this.conn = ConnectionFactory.getConnection(); this.preparedStatement = this.conn.prepareStatement(sql); this.preparedStatement.setInt(1, number); int insertReow = this.preparedStatement.executeUpdate(); if (insertReow > 0) { flag = true; } } catch (Exception e) { e.printStackTrace(); } return flag; } public List getSupplier()//获取所有供应商 { List lstSuppplierData = new ArrayList(); String sql = "select sup_id,sup_name,sup_address,postcode,sup_telephone,sup_fax,sup_relationer,sup_email from suppliers"; try { this.conn = ConnectionFactory.getConnection(); this.statement = this.conn.createStatement(); this.resultSet = this.statement.executeQuery(sql); while (this.resultSet.next()) { lstSuppplierData.add(Integer.valueOf(this.resultSet.getInt(1))); lstSuppplierData.add(this.resultSet.getString(2)); lstSuppplierData.add(this.resultSet.getString(3)); lstSuppplierData.add(this.resultSet.getString(4)); lstSuppplierData.add(this.resultSet.getString(5)); lstSuppplierData.add(this.resultSet.getString(6)); lstSuppplierData.add(this.resultSet.getString(7)); lstSuppplierData.add(this.resultSet.getString(8)); } } catch (Exception e) { e.printStackTrace(); } return lstSuppplierData; } public List getFoundSuppliers(String string)//获取指定ID供应商 { List lstSupplierData = new ArrayList(); try { this.conn = ConnectionFactory.getConnection(); this.statement = this.conn.createStatement(); this.resultSet = this.statement.executeQuery(string); while (this.resultSet.next()) { lstSupplierData.add(Integer.valueOf(this.resultSet.getInt(1))); lstSupplierData.add(this.resultSet.getString(2)); lstSupplierData.add(this.resultSet.getString(3)); lstSupplierData.add(this.resultSet.getString(4)); lstSupplierData.add(this.resultSet.getString(5)); lstSupplierData.add(this.resultSet.getString(6)); lstSupplierData.add(this.resultSet.getString(7)); lstSupplierData.add(this.resultSet.getString(8)); } } catch (Exception e) { e.printStackTrace(); } return lstSupplierData; } public ComboBoxModel getProductId() { // TODO Auto-generated method stub return null; } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: java
 输入关键字,在本站1000多万海量源码库中尽情搜索: