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

📄 importproduct.java

📁 (Java+SQL)-大型企业JAVA的ERP系统
💻 JAVA
字号:
//Source file: D:\tomcat\webapps\wuyang\WEB-INF\classes\src\wuyang\src\ImportProduct.java

package src.wuyang;

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

public class ImportProduct extends ShangObject
{   
   /**
进出口合同编号
   */
   private String contractId;
   
   /**
产品编号
   */
   private String productId;
   
   /**
数量
   */
   private float quantity;
   
   /**
单价
   */
   private float unitPrice;
   
   /**
委托书件数
   */
   private int customsNum;
   
   /**
装箱单数量
   */
   private float incaseNum;
   
   /**
* 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 = setChnString(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 = setChnString(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 customsNum property.
*
* @return   the current value of the customsNum property
   */
   public int getCustomsNum() 
   {
      return customsNum;
   }
   
   /**
* Sets the value of the customsNum property.
*
* @param aCustomsNum the new value of the customsNum property
   */
   public void setCustomsNum(int aCustomsNum) 
   {
      customsNum = aCustomsNum;
   }
   
   /**
* Access method for the incaseNum property.
*
* @return   the current value of the incaseNum property
   */
   public float getIncaseNum() 
   {
      return incaseNum;
   }
   
   /**
* Sets the value of the incaseNum property.
*
* @param aIncaseNum the new value of the incaseNum property
   */
   public void setIncaseNum(float aIncaseNum) 
   {
      incaseNum = aIncaseNum;
   }

	public ImportProduct() 
		{
		primarykey1Name = "contractId"; 
		primarykey1Type = 1; 
		primarykey2Name = "productId"; 
		primarykey2Type = 1; 
		tableName = "ImportProduct";  
		viewName = "ImportProduct";
		numInOnePager = 10;
		}

/*
	@loginName 	 varchar	(30),
	@ip 		 varchar	(20), 
	@machineName	 varchar	(30),
	@contractId 	 varchar	(10),
	@productId	 varchar	(10),
	@quantity	 float  	,
	@unitPrice	 float  	,
*/
	public int insert()
		{
		String sql= "{?=call sp_InsertImportProduct(?,?,?,?)}";
		try	{
			CallableStatement updStmt=conn.prepareCall(sql);
			updStmt.registerOutParameter(1, java.sql.Types.INTEGER);/** 注册OUT参数 */
			setStmtString(updStmt,2,contractId);
			setStmtString(updStmt,3,productId);
			updStmt.setFloat(4,quantity);
			updStmt.setFloat(5,unitPrice);
			updStmt.executeUpdate();
			int rtcode = updStmt.getInt(1);
			updStmt.close();
			return rtcode; 
			}
		catch(SQLException E)
			{
		      	System.out.println(E.getMessage());
		      	return -102;
      			}
		}

	public int update() 
		{
		String sql= "{?=call sp_UpdateImportProduct(?,?,?,?)}";
		try	{
			CallableStatement updStmt=conn.prepareCall(sql);
			updStmt.registerOutParameter(1, java.sql.Types.INTEGER);/** 注册OUT参数 */
			setStmtString(updStmt,2,contractId);
			setStmtString(updStmt,3,productId);
			updStmt.setFloat(4,quantity);
			updStmt.setFloat(5,unitPrice);
			updStmt.executeUpdate();
			int rtcode = updStmt.getInt(1);
			updStmt.close();
			return rtcode; 
			}
		catch(SQLException E)
			{
			System.out.println(E.getMessage());
			return -102;
			}
		}

	public int customsNum()
		{
		String sql= "UPDATE ImportProduct SET customsNum='"+getCustomsNum()+"' "+
			    "WHERE contractId='"+getContractId()+"' and productId='"+getProductId()+"'";
		System.out.println(sql);
		try	{
			Statement stmt=conn.createStatement();
			stmt.execute(sql);
			return 0;
			}
		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 + "'" ;
			if (primarykey2 != null && primarykey2.equals("")==false)
				{
				sqlStmt = sqlStmt + " and " + primarykey2Name + " = '"
					+ primarykey2 + "'" ;
				}
			System.out.println(sqlStmt);
			stmt.executeUpdate(sqlStmt);
			return 0;
			} 
		catch(SQLException e)
			{
			e.printStackTrace();
			return -1;
			}
		}

	public int loadAttr() 
		{
		try 	{
			contractId = getRsString(rs,"contractId");
			productId = getRsString(rs, "productId");
			quantity = rs.getFloat("quantity");
			unitPrice = rs.getFloat("unitPrice");
			customsNum = rs.getInt("customsNum");
			incaseNum = rs.getFloat("incaseNum");
			} 
		catch(SQLException e) 
			{
			e.printStackTrace();
			System.out.println("query failed!");
			return -1;
			}
		return 1;
		}

	public String getWhereClause(javax.servlet.ServletRequest request) 
		{
		String whereClause = "";
		String str;
		int queryMode = 1;
		
		if (request.getParameter("queryMode") != null)
			{
			queryMode = (new Integer(request.getParameter("queryMode"))).intValue();
			}
		switch(queryMode)
			{
			case 1: // 综合查询
				whereClause = addWhereClause(whereClause, "contractId", "=", "'", request.getParameter("contractId"));
				whereClause = addWhereClause(whereClause, "productId", "=", "'", request.getParameter("productId"));
				break;
			case 2: 
				break;
			}
		return whereClause;
		}

}

⌨️ 快捷键说明

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