⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 city.java

📁 电信的网厅的整站代码
💻 JAVA
字号:
/*
 * 创建日期 2005-8-1
 */
package com.doone.fj1w.fjmgr.monitor;

import com.doone.data.DataTable;
import com.doone.fj1w.fjmgr.order.DAO;
import com.doone.util.FileLogger;

/**
 * @author huzx
 */
public class City extends DAO {
	/** 地市编码* */
	private String citycode = "";

	/** 地市名称* */
	private String cityname = "";

	/** 地市简称* */
	private String cityshortname = "";

	private int pageSize = 20; // 默认每页20条

	public City() {
		FileLogger.getLogger().debug("City 数据库链接" + _dac);
	}

	public DataTable getCityByCode(String citycode) {
		DataTable dataTable = null;
		String sql = "select CITYCODE,CITYNAME,CITYSHORTNAME from td_city where CITYCODE=? order by citycode";
		Object[] value = new Object[1];
		value[0] = citycode;

		try {
			dataTable = _dac.executeQuery(sql, value);
		} catch (Exception e) {
			FileLogger.getLogger().debug(e.getMessage());
		}

		return dataTable;
	}

	public void addCity() {
		String sql = "insert into td_city(CITYCODE,CITYNAME,CITYSHORTNAME) values(?,?,?)";
		Object[] value = new Object[3];
		value[0] = citycode;
		value[1] = cityname;
		value[2] = cityshortname;

		try {
			_dac.executeUpdate(sql, 1000, value);
		} catch (Exception e) {
			FileLogger.getLogger().debug(e.getMessage());
		}
	}

	public void delCity(String citycode) {
		String sqlPri = "delete td_city where CITYCODE=?";
		String sqlSub = "delete td_area where citycode= ?";
		Object[] value = new Object[1];
		value[0] = citycode;
		try {
			_dac.beginTransaction(1000);
			_dac.executeUpdate(sqlSub, 1000, value);
			_dac.executeUpdate(sqlPri, 1000, value);
			_dac.endTransaction(true);
		} catch (Exception e) {

			try {
				_dac.endTransaction(false);
			} catch (Exception ee) {
				FileLogger.getLogger().debug(ee.getMessage());
			}
		}
	}

	public void updateCity() {
		String sql = "update td_city set CITYNAME = ?,CITYSHORTNAME=? where CITYCODE =?";
		Object[] value = new Object[3];
		value[0] = cityname;
		value[1] = cityshortname;
		value[2] = citycode;
		try {
			_dac.executeUpdate(sql, 1000, value);
		} catch (Exception e) {
			FileLogger.getLogger().debug(e.getMessage());
		}
	}

	public int getCitySize() {
		DataTable dataTable = null;
		String sql = "select count(t.CITYCODE) from td_city t where 1=1 ";

		try {
			dataTable = _dac.executeQuery(sql);
		} catch (Exception e) {
			FileLogger.getLogger().debug(e.getMessage());
		}
		return Integer.parseInt(dataTable.getRow(0).getString(0));
	}

	public DataTable getCityList(int pageNo) {
		DataTable dataTable = null;
		String sql = "select t.CITYCODE,t.CITYNAME,t.CITYSHORTNAME from td_city t  where t.CITYCODE<>'0590' order by citycode";

		sql = "SELECT * FROM ( SELECT row_.*, rownum rownum_ FROM(" + sql
				+ ")row_ WHERE rownum <= " + pageNo * pageSize
				+ ") WHERE rownum_ > " + (pageNo - 1) * pageSize;
		try {
			dataTable = _dac.executeQuery(sql);
		} catch (Exception e) {
			FileLogger.getLogger().debug(e.getMessage());
		}
		return dataTable;
	}

	/**
	 * @param citycode
	 *            要设置的 citycode。
	 */
	public void setCitycode(String citycode) {
		this.citycode = citycode;
	}

	/**
	 * @param cityname
	 *            要设置的 cityname。
	 */
	public void setCityname(String cityname) {
		this.cityname = cityname;
	}

	/**
	 * @param cityshortname
	 *            要设置的 cityshortname。
	 */
	public void setCityshortname(String cityshortname) {
		this.cityshortname = cityshortname;
	}

	/**
	 * @param pageSize
	 *            要设置的 pageSize。
	 */
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -