📄 contractproduct.java
字号:
//Source file: D:\work\五洋\javaBean\src\ContractProduct.java
package src.wuyang;
import src.com.*;
import java.sql.*;
import java.io.*;
public class ContractProduct extends ShangObject
{
/**
合同编号
*/
private String contractId;
/**
产品编号
*/
private String productId;
/**
数量
*/
private float quantity;
/**
单价
*/
private float unitPrice;
/**
买卖标记
0 卖
1 买
*/
private int salesFlag;
/**
* Access method for the contractId property.
*
* @return the current value of the contractId property
*/
public String getContractId() {
return contractId;}
/**
* Sets the value of the contractId property.
*
* @param aContractId the new value of the contractId property
*/
public void setContractId(String aContractId) {
contractId = aContractId;}
/**
* 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 = aProductId;}
/**
* 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 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 salesFlag property.
*
* @return the current value of the salesFlag property
*/
public int getSalesFlag() {
return salesFlag;}
/**
* Sets the value of the salesFlag property.
*
* @param aSalesFlag the new value of the salesFlag property
*/
public void setSalesFlag(int aSalesFlag) {
salesFlag = aSalesFlag;}
public ContractProduct()
{
primarykey1Name="contractId" ;
primarykey1Type=1;
primarykey2Name="productId" ;
primarykey2Type=1;
tableName ="ContractProduct";
viewName="ContractProduct";
numInOnePager=10;
}
public int loadAttr() {
try {
contractId= getRsString(rs,"contractId");
productId= getRsString(rs,"productId");
quantity= rs.getFloat("quantity");
unitPrice= rs.getFloat("unitPrice");
salesFlag= rs.getInt("salesFlag");
} catch(SQLException e) {
e.printStackTrace();
System.out.println("query failed!");
return -1;
}
return 1;
}
public int update() {
String sql= "{?=call sp_UpdateContractProduct(?,?,?,?,?)}";
try{
CallableStatement updStmt=conn.prepareCall(sql);
updStmt.registerOutParameter(1, java.sql.Types.INTEGER);
setStmtString(updStmt,2,contractId);
setStmtString(updStmt,3,productId);
updStmt.setFloat(4,quantity);
updStmt.setFloat(5,unitPrice);
updStmt.setInt(6,salesFlag);
updStmt.executeUpdate();
int rtcode = updStmt.getInt(1);
updStmt.close();
return rtcode;
}catch(SQLException E){
System.out.println(E.getMessage());
return -102;
}
}
public int insert() {
String sql= "{?=call sp_InsertContractProduct(?,?,?,?,?)}";
try{
CallableStatement updStmt=conn.prepareCall(sql);
updStmt.registerOutParameter(1, java.sql.Types.INTEGER);
setStmtString(updStmt,2,contractId);
setStmtString(updStmt,3,productId);
updStmt.setFloat(4,quantity);
updStmt.setFloat(5,unitPrice);
updStmt.setInt(6,salesFlag);
updStmt.executeUpdate();
int rtcode = updStmt.getInt(1);
updStmt.close();
return rtcode;
}catch(SQLException E){
System.out.println(E.getMessage());
return -102;
}
}
public int delete(int contractId,String productId) {
String sql ="delete from ContractProduct where contractId = "+contractId +"and productId = "+productId;
try {
Statement stmt=conn.createStatement();
stmt.execute(sql);
return 1;
}
catch(SQLException E)
{
System.out.println(E.getMessage());
return -102;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -