- package com.dao;
- import java.util.List;
- import com.tool.JDBConnection;
- import java.util.ArrayList;
- import com.domain.FfzyForm;
- import com.tool.SQLCode;
- import java.util.List;
- import com.tool.JDBConnection;
- import java.util.ArrayList;
- import java.sql.ResultSet;
- import java.sql.*;
- import com.domain.CsxxForm;
- import com.domain.SkhfkForm;
- public class SfzyDaoImpl
- implements SfzyDao {
- private JDBConnection connection = new JDBConnection();
- //显示头5条的记录数
- public List sfzySelect() {
- List list = new ArrayList();
- FfzyForm form = null;
- String sql = SQLCode.getSQLCode("sql.sfzy.select");
- try {
- ResultSet rs = connection.executeQuery(sql);
- while (rs.next()) {
- form = new FfzyForm();
- form.setSfzy_id(rs.getString(1));
- form.setSfzy_sfmc(rs.getString(2));
- form.setSfzy_zyms(rs.getString(3));
- list.add(form);
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return list;
- }
- //显示多少条记录数
- public int toatl() {
- int iCount = 0;
- String sql = SQLCode.getSQLCode("sql.sfzy.total");
- ResultSet rs = null;
- try {
- rs = connection.executeQuery(sql);
- while (rs.next()) {
- iCount = rs.getInt("t");
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return iCount;
- }
- public FfzyForm sfzySelect(FfzyForm fzy) {
- FfzyForm form = null;
- String sql = SQLCode.getSQLCode("sql.sfzy.selectOne");
- sql = connection.editSqlCode(sql, fzy.getSfzy_id());
- try {
- ResultSet rs = connection.executeQuery(sql);
- while (rs.next()) {
- form = new FfzyForm();
- form.setSfzy_id(rs.getString(1));
- form.setSfzy_sfmc(rs.getString(2));
- form.setSfzy_zyms(rs.getString(3));
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return form;
- }
- public List csxxSelect(CsxxForm csxx) {
- List list = new ArrayList();
- CsxxForm form = null;
- String sql = SQLCode.getSQLCode("sql.csxx.select");
- sql = connection.editSqlCode(sql, csxx.getCsxx_sfmc());
- try {
- ResultSet rs = connection.executeQuery(sql);
- while (rs.next()) {
- form = new CsxxForm();
- form.setCxss_csjc(rs.getString(1));
- form.setCsxx_sfmc(rs.getString(2));
- form.setCsxx_csmc(rs.getString(3));
- form.setCsxx_yb(rs.getString(4));
- form.setCsxx_dhph(rs.getString(5));
- list.add(form);
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return list;
- }
- public int khxxMyd(SkhfkForm skhfk) {
- int iCount = 0;
- String sql = SQLCode.getSQLCode("sql.myd");
- sql = connection.editSqlCode(sql, skhfk.getKhfk_khmyd());
- ResultSet rs = null;
- try {
- rs = connection.executeQuery(sql);
- while (rs.next()) {
- iCount = rs.getInt("t");
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return iCount;
- }
- /**
- * sfzyFenYe
- *
- * @param number Integer
- * @return List
- */
- //分页的操作
- public List sfzyFenYe(Integer number) {
- List list = new ArrayList();
- FfzyForm form = null;
- String sql = SQLCode.getSQLCode("sql.sfzy.fenye");
- sql = connection.editSqlCode(sql, number);
- try {
- ResultSet rs = connection.executeQuery(sql);
- while (rs.next()) {
- form = new FfzyForm();
- form.setSfzy_id(rs.getString(1));
- form.setSfzy_sfmc(rs.getString(2));
- form.setSfzy_zyms(rs.getString(3));
- list.add(form);
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return list;
- }
- /**
- * totalCity
- *
- * @param skhfk SkhfkForm
- * @return int
- */
- //以省份为条件去查询城市的数量
- public int totalCity(CsxxForm csxx) {
- int iCount = 0;
- String sql = SQLCode.getSQLCode("sql.csxx.total");
- sql = connection.editSqlCode(sql, csxx.getCsxx_sfmc());
- ResultSet rs = null;
- try {
- rs = connection.executeQuery(sql);
- while (rs.next()) {
- iCount = rs.getInt("t");
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return iCount;
- }
- /**
- * selectCity
- *
- * @param number Integer
- * @return List
- */
- public List fenyeCity(Integer number, CsxxForm csxx) {
- List list = new ArrayList();
- CsxxForm form = null;
- String sql = SQLCode.getSQLCode("sql.csxx.fenye");
- sql = connection.editSqlCode(sql, number);
- sql = connection.editSqlCode(sql, csxx.getCsxx_sfmc());
- System.out.println("sql=" + sql);
- try {
- ResultSet rs = connection.executeQuery(sql);
- while (rs.next()) {
- form = new CsxxForm();
- form.setCxss_csjc(rs.getString(1));
- form.setCsxx_sfmc(rs.getString(2));
- form.setCsxx_csmc(rs.getString(3));
- form.setCsxx_yb(rs.getString(4));
- form.setCsxx_dhph(rs.getString(5));
- list.add(form);
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return list;
- }
- public List csxxPrinfSelect(CsxxForm csxx) {
- List list = new ArrayList();
- CsxxForm form = null;
- String sql = SQLCode.getSQLCode("sql.csxx.prinfSelect");
- sql = connection.editSqlCode(sql, csxx.getCsxx_sfmc());
- try {
- ResultSet rs = connection.executeQuery(sql);
- while (rs.next()) {
- form = new CsxxForm();
- form.setCxss_csjc(rs.getString(1));
- form.setCsxx_sfmc(rs.getString(2));
- form.setCsxx_csmc(rs.getString(3));
- form.setCsxx_yb(rs.getString(4));
- form.setCsxx_dhph(rs.getString(5));
- list.add(form);
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return list;
- }
- }