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

📄 goodnotequaloperate.java

📁 JAVA实现的酒店管理系统
💻 JAVA
字号:
package file1;

/*
 * Description:对货品损益记录的操作类
 * @Author:黄顺武
 * Create Time:2007-12-19
 */
import java.sql.SQLException;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import sun.jdbc.rowset.CachedRowSet;

public class GoodNotEqualOperate implements Operate {

	public GoodNotEqualOperate() {
	}

	public void insertToDB(Object object) {// 往数据库中插入货品损益记录
		GoodNotEqual goodNotEqual = (GoodNotEqual) object;
		try {
			DBConnection con = new DBConnection();
			StringBuffer sqlSB = new StringBuffer(
					"insert into GoodNotEqual values(");
			sqlSB.append(goodNotEqual.getGood_ID()).append(",'");
			sqlSB.append(goodNotEqual.getCheck_Time()).append("',");
			sqlSB.append(goodNotEqual.getNot_Equal_Number()).append(",'");
			sqlSB.append(goodNotEqual.getNot_Equal_State()).append("','");
			sqlSB.append(goodNotEqual.getNot_Equal_Reason()).append("')");
			con.addSql(sqlSB.toString());
			con.doDML();
		} catch (ClassNotFoundException cnfe) {
			cnfe.printStackTrace();
		} catch (SQLException sqle) {
			sqle.printStackTrace();
		}
	}

	public void deleteFromDB(Object object) {// 删除货品损益记录时调用的方法
		GoodNotEqual goodNotEqual = (GoodNotEqual) object;
		try {
			DBConnection con = new DBConnection();
			StringBuffer sqlSB = new StringBuffer(
					"delete from GoodNotEqual where ID=");
			sqlSB.append(goodNotEqual.getID());
			con.addSql(sqlSB.toString());
			con.doDML();
		} catch (ClassNotFoundException cnfe) {
			cnfe.printStackTrace();
		} catch (SQLException sqle) {
			sqle.printStackTrace();
		}
	}

	public void modifyToDB(Object object) {// 修改货品损益记录时调用的方法

		GoodNotEqual goodNotEqual = (GoodNotEqual) object;
		try {
			DBConnection con = new DBConnection();
			StringBuffer sqlSB = new StringBuffer("update GoodNotEqual set ");
			sqlSB.append("good_id=").append(goodNotEqual.getGood_ID()).append(
					",");
			sqlSB.append("check_time='").append(goodNotEqual.getCheck_Time())
					.append("',");
			sqlSB.append("not_equal_number=").append(
					goodNotEqual.getNot_Equal_Number()).append(",");
			sqlSB.append("not_equal_state='").append(
					goodNotEqual.getNot_Equal_State()).append("',");
			sqlSB.append("not_equal_reason='").append(
					goodNotEqual.getNot_Equal_Reason()).append("' ");
			sqlSB.append("where id=").append(goodNotEqual.getID());
			con.addSql(sqlSB.toString());
			con.doDML();
		} catch (ClassNotFoundException cnfe) {
			cnfe.printStackTrace();
		} catch (SQLException sqle) {
			sqle.printStackTrace();
		}
	}

	public ArrayList selectFromDB(Object object) {// 查询货品损益记录时调用的方法

		GoodNotEqual goodNotEqual = (GoodNotEqual) object;
		ArrayList valuesList = new ArrayList();
		CachedRowSet crs = null;
		try {
			DBConnection con = new DBConnection();
			StringBuffer sqlSB = new StringBuffer("");
			if (goodNotEqual.getID() == 0) {// 表示查询数据库中的全部货品损益记录,传参数的时候一定要注意
				sqlSB
						.append("select GoodNotEqual.ID,typeID,typeName,good_id,goodName,check_time,not_equal_number,not_equal_state,not_equal_reason from GoodNotEqual,Good,GoodType where GoodNotEqual.good_id=Good.ID and typeID=GoodType.ID");
			}
			if (goodNotEqual.getID() != -1 && goodNotEqual.getID() != 0) {// 表示查询数据库中的某一货品损益记录,传参数的时候一定要注意
				sqlSB
						.append("select GoodNotEqual.ID,typeID,typeName,good_id,goodName,check_time,not_equal_number,not_equal_state,not_equal_reason from GoodNotEqual,Good,GoodType where good_id=Good.ID and typeID=GoodType.ID and GoodNotEqual.ID="
								+ goodNotEqual.getID());
			}
			crs = con.getResultSet(sqlSB.toString());
			while (crs.next()) {
				GoodNotEqual good_NotEqual = new GoodNotEqual();
				good_NotEqual.setID(crs.getInt(1));
				good_NotEqual.setProperty("typeID", crs.getInt(2));
				good_NotEqual.setProperty("typeName", crs.getString(3).trim());
				good_NotEqual.setGood_ID(crs.getInt(4));
				good_NotEqual.setProperty("goodName", crs.getString(5).trim());
				good_NotEqual.setCheck_Time(crs.getString(6).trim());
				good_NotEqual.setNot_Equal_Number(crs.getInt(7));
				good_NotEqual.setNot_Equal_State(crs.getString(8).trim());
				good_NotEqual.setNot_Equal_Reason(crs.getString(9).trim());
				valuesList.add(good_NotEqual);
			}
		} catch (ClassNotFoundException cnfe) {
			cnfe.printStackTrace();
		} catch (SQLException sqle) {
			sqle.printStackTrace();
		}
		return valuesList;
	}
}

⌨️ 快捷键说明

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