KhcpxzDaoImpl.java
上传用户:quasar007
上传日期:2022-08-11
资源大小:4067k
文件大小:4k
源码类别:

企业管理

开发平台:

Java

  1. package com.dao;
  2. import com.tool.SQLCode;
  3. import java.util.List;
  4. import com.domain.KhcpxzForm;
  5. import com.tool.JDBConnection;
  6. import java.util.ArrayList;
  7. import java.sql.ResultSet;
  8. import java.sql.*;
  9. //对业务来往的操作(tb_Client_cpxs)
  10. public class KhcpxzDaoImpl
  11.     implements KhcpxzDao {
  12.   private JDBConnection connection = new JDBConnection();
  13.   public void cpxzInsert(KhcpxzForm cpxz) {
  14.     String sql = SQLCode.getSQLCode("sql.khcpx.insert");
  15.     sql = connection.editSqlCode(sql, cpxz.getCpxx_id());
  16.     sql = connection.editSqlCode(sql, cpxz.getCpxx_mc());
  17.     sql = connection.editSqlCode(sql, cpxz.getCpxx_cpdj());
  18.     sql = connection.editSqlCode(sql, cpxz.getCpxx_khId());
  19.     sql = connection.editSqlCode(sql, cpxz.getCpxx_xsrp());
  20.     sql = connection.editSqlCode(sql, cpxz.getCpxx_bz());
  21.     connection.executeUpdate(sql);
  22.     connection.close();
  23.   }
  24. //查询操作
  25.   public List cpxzSelect() {
  26.     List list = new ArrayList();
  27.     KhcpxzForm form = null;
  28.     String sql = SQLCode.getSQLCode("sql.khcpx.select");
  29.     try {
  30.       ResultSet rs = connection.executeQuery(sql);
  31.       while (rs.next()) {
  32.         form = new KhcpxzForm();
  33.         form.setCpxx_id(rs.getString(1));
  34.         form.setCpxx_mc(rs.getString(2));
  35.         form.setCpxx_cpdj(rs.getString(3));
  36.         form.setCpxx_khId(rs.getString(4));
  37.         form.setCpxx_xsrp(rs.getString(5));
  38.         form.setCpxx_bz(rs.getString(6));
  39.         form.setId(Integer.valueOf(rs.getString(7)));
  40.         list.add(form);
  41.       }
  42.     }
  43.     catch (SQLException ex) {
  44.     }
  45.     connection.close();
  46.     return list;
  47.   }
  48. //删除操作
  49.   public void cpxzDelete(KhcpxzForm cpxz) {
  50.     String sql = SQLCode.getSQLCode("sql.khcpx.delete");
  51.     sql = connection.editSqlCode(sql, cpxz.getCpxx_id());
  52.     connection.executeUpdate(sql);
  53.     connection.close();
  54.   }
  55.   //单独查询操作
  56.   public KhcpxzForm cpxzSelectOne(KhcpxzForm cpxz) {
  57.     KhcpxzForm form = null;
  58.     String sql = SQLCode.getSQLCode("sql.khcpx.selectOne");
  59.     sql = connection.editSqlCode(sql, cpxz.getId());
  60.     try {
  61.       ResultSet rs = connection.executeQuery(sql);
  62.       while (rs.next()) {
  63.         form = new KhcpxzForm();
  64.         form.setCpxx_id(rs.getString(1));
  65.         form.setCpxx_mc(rs.getString(2));
  66.         form.setCpxx_cpdj(rs.getString(3));
  67.         form.setCpxx_khId(rs.getString(4));
  68.         form.setCpxx_xsrp(rs.getString(5));
  69.         form.setCpxx_bz(rs.getString(6));
  70.         form.setId(Integer.valueOf(rs.getString(7)));
  71.       }
  72.     }
  73.     catch (SQLException ex) {
  74.     }
  75.     connection.close();
  76.     return form;
  77.   }
  78. //修改操作
  79.   public void cpxzUpdate(KhcpxzForm cpxz) {
  80.     String sql = SQLCode.getSQLCode("sql.khcpx.update");
  81.     sql = connection.editSqlCode(sql, cpxz.getCpxx_id());
  82.     sql = connection.editSqlCode(sql, cpxz.getCpxx_mc());
  83.     sql = connection.editSqlCode(sql, cpxz.getCpxx_cpdj());
  84.     sql = connection.editSqlCode(sql, cpxz.getCpxx_khId());
  85.     sql = connection.editSqlCode(sql, cpxz.getCpxx_xsrp());
  86.     sql = connection.editSqlCode(sql, cpxz.getCpxx_bz());
  87.     sql = connection.editSqlCode(sql, cpxz.getId());
  88.     connection.executeUpdate(sql);
  89.     connection.close();
  90.   }
  91.   public int countID() {
  92.     int iCount = 0;
  93.     String sql = SQLCode.getSQLCode("sql.khcpx.count");
  94.     ResultSet rs = null;
  95.     try {
  96.       rs = connection.executeQuery(sql);
  97.       while (rs.next()) {
  98.         iCount = rs.getInt("t");
  99.       }
  100.     }
  101.     catch (SQLException ex) {
  102.     }
  103.     connection.close();
  104.     return iCount + 1;
  105.   }
  106. }