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

📄 purchproduct.java

📁 (Java+SQL)-大型企业JAVA的ERP系统
💻 JAVA
字号:
//Source file: D:\work\五洋\javaBean\src\PurchProduct.java

package src.wuyang;
import src.com.*;
import java.sql.*;
import java.io.*;

public class PurchProduct extends ShangObject
{
   
   /**
采购单编号
   */
   private String purchId;
   
   /**
产品编号
   */
   private String productId;
   
   /**
产地
   */
   private String productAdd;
   
   /**
件数
   */
   private float counting;
   
   /**
数量
   */
   private float quantity;
   
   /**
包装
   */
   private int pack;
   
   /**
单价
   */
   private float unitPrice;
   
   /**
实际数量
   */
   private float actQuantity;
   
   
   
   /**
* Access method for the purchId property.
*
* @return   the current value of the purchId property
   */
   public String getPurchId() {
      return purchId;}
   
   /**
* Sets the value of the purchId property.
*
* @param aPurchId the new value of the purchId property
   */
   public void setPurchId(String aPurchId) {
      purchId = setChnString(aPurchId);}
   
   /**
* Access method for the productId property.
*
* @return   the current value of the productId property
   */
   public String getProductId() {
      return productId;}
   
   /**
* Sets the value of the productId property.
*
* @param aProductId the new value of the productId property
   */
   public void setProductId(String aProductId) {
      productId = setChnString(aProductId);}
   
   /**
* Access method for the productAdd property.
*
* @return   the current value of the productAdd property
   */
   public String getProductAdd() {
      return productAdd;}
   
   /**
* Sets the value of the productAdd property.
*
* @param aProductId the new value of the productAdd property
   */
   public void setProductAdd(String aProductAdd) {
      productAdd = setChnString(aProductAdd);}
   
   /**
* Access method for the counting property.
*
* @return   the current value of the counting property
   */
   public float getCounting() {
      return counting;}
   
   /**
* Sets the value of the counting property.
*
* @param aCounting the new value of the counting property
   */
   public void setCounting(float aCounting) {
      counting = aCounting;}
   
   /**
* Access method for the quantity property.
*
* @return   the current value of the quantity property
   */
   public float getQuantity() {
      return quantity;}
   
   /**
* Sets the value of the quantity property.
*
* @param aQuantity the new value of the quantity property
   */
   public void setQuantity(float aQuantity) {
      quantity = aQuantity;}
   
   /**
* Access method for the pack property.
*
* @return   the current value of the pack property
   */
   public int getPack() {
      return pack;}
   
   /**
* Sets the value of the pack property.
*
* @param aPack the new value of the pack property
   */
   public void setPack(int aPack) {
      pack = aPack;}
   
   /**
* Access method for the unitPrice property.
*
* @return   the current value of the unitPrice property
   */
   public float getUnitPrice() {
      return unitPrice;}
   
   /**
* Sets the value of the unitPrice property.
*
* @param aUnitPrice the new value of the unitPrice property
   */
   public void setUnitPrice(float aUnitPrice) {
      unitPrice = aUnitPrice;}
   
   /**
* Access method for the actQuantity property.
*
* @return   the current value of the actQuantity property
   */
   public float getActQuantity() {
      return actQuantity;}
   
   /**
* Sets the value of the actQuantity property.
*
* @param aActQuantity the new value of the actQuantity property
   */
   public void setActQuantity(float aActQuantity) {
      actQuantity = aActQuantity;}
public  PurchProduct()
 {
	primarykey1Name="purchId" ;
	primarykey1Type=1;
	primarykey2Name="productId" ;
	primarykey2Type=1;
	tableName ="PurchProduct";
	viewName="PurchProduct";
	numInOnePager=10;
}
public String getWhereClause(javax.servlet.ServletRequest request) {
String whereClause = "";
whereClause = addWhereClause(whereClause, "purchId", "=", "'",request.getParameter("purchId"));
whereClause = addWhereClause(whereClause, "productId", "=", "'",request.getParameter("productId"));
whereClause = addWhereClause(whereClause, "counting", "like", "'",request.getParameter("counting"));
whereClause = addWhereClause(whereClause, "quantity", "like", "'",request.getParameter("quantity"));
whereClause = addWhereClause(whereClause, "pack", "like", "'",request.getParameter("pack"));
whereClause = addWhereClause(whereClause, "unitPrice", "like", "'",request.getParameter("unitPrice"));
whereClause = addWhereClause(whereClause, "actQuantity", "like", "'",request.getParameter("actQuantity"));
return whereClause;
}
public int loadAttr() {
 try { 
purchId= getRsString(rs,"purchId");
productId= getRsString(rs,"productId");
productAdd= getRsString(rs,"productAdd");
counting= rs.getFloat("counting");
quantity= rs.getFloat("quantity");
pack= rs.getInt("pack");
unitPrice= rs.getFloat("unitPrice");
actQuantity= rs.getFloat("actQuantity");
} catch(SQLException e) {
e.printStackTrace();
System.out.println("query failed!");
return -1;
}
    return 1;
}

public int update() {
 String sql= "{?=call sp_UpdatePurchProduct(?,?,?,?,?,?)}";
try{
CallableStatement updStmt=conn.prepareCall(sql);
updStmt.registerOutParameter(1, java.sql.Types.INTEGER);
setStmtString(updStmt,2,purchId);
setStmtString(updStmt,3,productId);
setStmtString(updStmt,4,productAdd);
updStmt.setFloat(5,quantity);
updStmt.setInt(6,pack);
updStmt.setFloat(7,unitPrice);
updStmt.executeUpdate();
int rtcode = updStmt.getInt(1);
updStmt.close();
return rtcode; 
}catch(SQLException E){
System.out.println(E.getMessage());
return -102;
  }
}

/*
 修改2
 	@loginName varchar(30) 
	,@ip varchar(20) 
	,@machineName varchar(30)
	,@purchId varchar(10) 
	,@productId varchar(10)	
	,@acQquantity float		
*/
   public int updateAct() {  	
     String sql= "{?=call sp_UpdatePurchProductAct(?,?,?,?,?,?)}";
     try{
		CallableStatement updStmt=conn.prepareCall(sql);
		updStmt.registerOutParameter(1, java.sql.Types.INTEGER);/** 注册OUT参数 */
		setStmtString(updStmt, 2, theGlobal.loginName);
		setStmtString(updStmt, 3, theGlobal.ip);
		setStmtString(updStmt, 4, theGlobal.machineName);
		setStmtString(updStmt,5,purchId);
		setStmtString(updStmt,6,productId);
		updStmt.setFloat(7,actQuantity);
		updStmt.executeUpdate();
		int rtcode = updStmt.getInt(1);
		updStmt.close();
		return rtcode; 
	}catch(SQLException E){
	System.out.println(E.getMessage());
	System.out.println(" falied update");
	return -102;
	  }
  }

public int insert() {
 String sql= "{?=call sp_InsertPurchProduct(?,?,?,?,?,?)}";
try{
CallableStatement updStmt=conn.prepareCall(sql);
updStmt.registerOutParameter(1, java.sql.Types.INTEGER);
setStmtString(updStmt,2,purchId);
setStmtString(updStmt,2,purchId);
setStmtString(updStmt,3,productId);
setStmtString(updStmt,4,productAdd);
updStmt.setFloat(5,quantity);
updStmt.setInt(6,pack);
updStmt.setFloat(7,unitPrice);
updStmt.executeUpdate();
int rtcode = updStmt.getInt(1);
updStmt.close();
return rtcode; 
}catch(SQLException E){
System.out.println(E.getMessage());
return -102;
  }
}


public int delete(String primarykey1,String primarykey2){
	try	{
		String sqlStmt;
		Statement stmt = conn.createStatement();
		sqlStmt = "delete from " + tableName + " where " + primarykey1Name 
				+ " = '" + primarykey1 + "' and " + primarykey2Name 
				+ " = '" + primarykey2 + "'" ;
		stmt.executeUpdate(sqlStmt);
		return 0;
	} catch(SQLException e)	{
		e.printStackTrace();
		return -1;
	}
}
}

⌨️ 快捷键说明

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