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

📄 newppm.java

📁 自己做的一个企业招标系统,B/S结构。开发工具Eclipse
💻 JAVA
字号:
/**
 * 
 */
package com.centralsoft.zhaobiao.admin;

import java.sql.*;

import com.centralsoft.zhaobiao.admin.*;
import com.centralsoft.zhaobiao.util.*;

/**
 * @author zw
 *
 */
public class NewPPM {
	public NewPPM() {
	}
	/**
	 * 根据产品id删除该ppm记录
	 * @param product_id
	 */
	public void delPPMProductid(long product_id) {
		Connection conn = null;
		dataBase db = new dataBase();
		conn = db.getConnection();
		PreparedStatement ps = null;
		ResultSet rs = null;
		String sql = "select * from PPM where product_id = ?";
		try {
			ps = conn.prepareStatement(sql);
			ps.setLong(1,product_id);
			rs = ps.executeQuery();
			while (rs.next()) {
				delPPMid(rs.getLong("id"));
			}
		} catch (Exception e) {
			System.out.println(e.getMessage());
		} finally {
			try {
				if (rs != null) {
					rs.close();
				}
				if (ps != null) {
					ps.close();
				}
				db.closeConn();
			} catch (Exception e) {
				System.out.println(e.getMessage());
			}
		}
	}
	/**
	 * 根据ppmid删除该PPM记录,在删除该ppm记录时,会删除与之对应的price记录
	 * @param id
	 */
	public void delPPMid(long id) {
		Connection conn = null;
		dataBase db = new dataBase();
		conn = db.getConnection();
		PreparedStatement ps1 = null;
		PreparedStatement ps2 = null;
		ResultSet rs1 = null;
		ResultSet rs2 = null;
		String sql1 = "select * from PPM where id = ?";
		String sql2 = "delect from PPM where id = ?";
		try {
			ps1 = conn.prepareStatement(sql1);
			ps1.setLong(1,id);
			rs1 = ps1.executeQuery();
			if (rs1.next()) {
				NewPrice newprice = new NewPrice();
				newprice.delPrice(rs1.getLong("price_id"));
			}
		} catch (Exception e) {
			System.out.println(e.getMessage());
		} finally {
			try {
				if (rs1 != null) {
					rs1.close();
				}
				if (ps1 != null) {
					ps1.close();
				}
			} catch (Exception e) {
				System.out.println(e.getMessage());
			}
		}
		try {
			ps2 = conn.prepareStatement(sql2);
			ps2.setLong(1,id);
			ps2.executeUpdate();
		} catch (Exception e) {
			System.out.println(e.getMessage());
		} finally {
			try {
				if (ps2 != null) {
					ps2.close();
				}
			} catch (Exception e) {
				System.out.println(e.getMessage());
			}
		}
		db.closeConn();
	}
}

⌨️ 快捷键说明

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