KhcpxzDaoImpl.java
上传用户:quasar007
上传日期:2022-08-11
资源大小:4067k
文件大小:4k
- package com.dao;
- import com.tool.SQLCode;
- import java.util.List;
- import com.domain.KhcpxzForm;
- import com.tool.JDBConnection;
- import java.util.ArrayList;
- import java.sql.ResultSet;
- import java.sql.*;
- //对业务来往的操作(tb_Client_cpxs)
- public class KhcpxzDaoImpl
- implements KhcpxzDao {
- private JDBConnection connection = new JDBConnection();
- public void cpxzInsert(KhcpxzForm cpxz) {
- String sql = SQLCode.getSQLCode("sql.khcpx.insert");
- sql = connection.editSqlCode(sql, cpxz.getCpxx_id());
- sql = connection.editSqlCode(sql, cpxz.getCpxx_mc());
- sql = connection.editSqlCode(sql, cpxz.getCpxx_cpdj());
- sql = connection.editSqlCode(sql, cpxz.getCpxx_khId());
- sql = connection.editSqlCode(sql, cpxz.getCpxx_xsrp());
- sql = connection.editSqlCode(sql, cpxz.getCpxx_bz());
- connection.executeUpdate(sql);
- connection.close();
- }
- //查询操作
- public List cpxzSelect() {
- List list = new ArrayList();
- KhcpxzForm form = null;
- String sql = SQLCode.getSQLCode("sql.khcpx.select");
- try {
- ResultSet rs = connection.executeQuery(sql);
- while (rs.next()) {
- form = new KhcpxzForm();
- form.setCpxx_id(rs.getString(1));
- form.setCpxx_mc(rs.getString(2));
- form.setCpxx_cpdj(rs.getString(3));
- form.setCpxx_khId(rs.getString(4));
- form.setCpxx_xsrp(rs.getString(5));
- form.setCpxx_bz(rs.getString(6));
- form.setId(Integer.valueOf(rs.getString(7)));
- list.add(form);
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return list;
- }
- //删除操作
- public void cpxzDelete(KhcpxzForm cpxz) {
- String sql = SQLCode.getSQLCode("sql.khcpx.delete");
- sql = connection.editSqlCode(sql, cpxz.getCpxx_id());
- connection.executeUpdate(sql);
- connection.close();
- }
- //单独查询操作
- public KhcpxzForm cpxzSelectOne(KhcpxzForm cpxz) {
- KhcpxzForm form = null;
- String sql = SQLCode.getSQLCode("sql.khcpx.selectOne");
- sql = connection.editSqlCode(sql, cpxz.getId());
- try {
- ResultSet rs = connection.executeQuery(sql);
- while (rs.next()) {
- form = new KhcpxzForm();
- form.setCpxx_id(rs.getString(1));
- form.setCpxx_mc(rs.getString(2));
- form.setCpxx_cpdj(rs.getString(3));
- form.setCpxx_khId(rs.getString(4));
- form.setCpxx_xsrp(rs.getString(5));
- form.setCpxx_bz(rs.getString(6));
- form.setId(Integer.valueOf(rs.getString(7)));
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return form;
- }
- //修改操作
- public void cpxzUpdate(KhcpxzForm cpxz) {
- String sql = SQLCode.getSQLCode("sql.khcpx.update");
- sql = connection.editSqlCode(sql, cpxz.getCpxx_id());
- sql = connection.editSqlCode(sql, cpxz.getCpxx_mc());
- sql = connection.editSqlCode(sql, cpxz.getCpxx_cpdj());
- sql = connection.editSqlCode(sql, cpxz.getCpxx_khId());
- sql = connection.editSqlCode(sql, cpxz.getCpxx_xsrp());
- sql = connection.editSqlCode(sql, cpxz.getCpxx_bz());
- sql = connection.editSqlCode(sql, cpxz.getId());
- connection.executeUpdate(sql);
- connection.close();
- }
- public int countID() {
- int iCount = 0;
- String sql = SQLCode.getSQLCode("sql.khcpx.count");
- ResultSet rs = null;
- try {
- rs = connection.executeQuery(sql);
- while (rs.next()) {
- iCount = rs.getInt("t");
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return iCount + 1;
- }
- }