CkhjgDaoImpl.java
上传用户:quasar007
上传日期:2022-08-11
资源大小:4067k
文件大小:3k
- package com.dao;
- import com.tool.SQLCode;
- import java.util.List;
- import com.domain.CkhjbForm;
- import com.tool.JDBConnection;
- import java.util.ArrayList;
- import java.sql.SQLException;
- import java.sql.ResultSet;
- //对客户级别表的操作(tb_Client_khjb)
- public class CkhjgDaoImpl
- implements CkhjgDao {
- //查询操作
- public List khjgSelect() {
- JDBConnection connection = new JDBConnection();
- List list = new ArrayList();
- CkhjbForm form = null;
- String sql = SQLCode.getSQLCode("sql.khjb.select");
- try {
- ResultSet rs = connection.executeQuery(sql);
- while (rs.next()) {
- form = new CkhjbForm();
- form.setKhjb_id(rs.getString(1));
- form.setKhjb_jbmc(rs.getString(2));
- form.setKhjb_zdyml(Float.valueOf(rs.getString(3)));
- form.setKhjb_bz(rs.getString(4));
- list.add(form);
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return list;
- }
- //删除操作
- public void khjgDelete(CkhjbForm khjb) {
- JDBConnection connection = new JDBConnection();
- String sql = SQLCode.getSQLCode("sql.khjb.delete");
- sql = connection.editSqlCode(sql, khjb.getKhjb_id());
- int aa = connection.executeUpdate(sql);
- connection.close();
- }
- //单独查找
- public CkhjbForm khjgSelectOne(CkhjbForm khjb) {
- JDBConnection connection = new JDBConnection();
- CkhjbForm form = null;
- String sql = SQLCode.getSQLCode("sql.khjb.selectOne");
- sql = connection.editSqlCode(sql, khjb.getKhjb_id());
- try {
- ResultSet rs = connection.executeQuery(sql);
- while (rs.next()) {
- form = new CkhjbForm();
- form.setKhjb_id(rs.getString(1));
- form.setKhjb_jbmc(rs.getString(2));
- form.setKhjb_zdyml(Float.valueOf(rs.getString(3)));
- form.setKhjb_bz(rs.getString(4));
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return form;
- }
- //修改操作
- public void khjbUpdate(CkhjbForm khjb) {
- JDBConnection connection = new JDBConnection();
- String sql = SQLCode.getSQLCode("sql.khjb.update");
- sql = connection.editSqlCode(sql, khjb.getKhjb_jbmc());
- sql = connection.editSqlCode(sql, khjb.getKhjb_zdyml());
- sql = connection.editSqlCode(sql, khjb.getKhjb_bz());
- sql = connection.editSqlCode(sql, khjb.getKhjb_id());
- System.out.print("sql="+sql);
- connection.executeUpdate(sql);
- connection.close();
- }
- //以数据库中的记录数,查找出多少记录计算,以便做帐号存贮--
- public int khjbCount() {
- int iCount = 0;
- JDBConnection connection = null;
- connection = new JDBConnection();
- String sql = SQLCode.getSQLCode("sql.khjb.count");
- ResultSet rs = null;
- try {
- rs = connection.executeQuery(sql);
- while (rs.next()) {
- CkhjbForm form = new CkhjbForm();
- iCount = rs.getInt("t");
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return iCount + 1;
- }
- //插入操作
- public void khjbInsert(CkhjbForm khjb) {
- JDBConnection connection = new JDBConnection();
- String sql = SQLCode.getSQLCode("sql.khjb.insert");
- sql = connection.editSqlCode(sql, khjb.getKhjb_id());
- sql = connection.editSqlCode(sql, khjb.getKhjb_jbmc());
- sql = connection.editSqlCode(sql, khjb.getKhjb_zdyml());
- sql = connection.editSqlCode(sql, khjb.getKhjb_bz());
- connection.executeUpdate(sql);
- connection.close();
- }
- }