📄 goodsimportgoods.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: GoodsImportGoods.java
package mediastore.dao;
import java.io.*;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import mediastore.common.DBConnection;
import mediastore.rule.ImportItemSearchRule;
import mediastore.util.StrUtility;
import mediastore.web.form.*;
// Referenced classes of package mediastore.dao:
// GoodsImportInfo, GoodsInfo
public class GoodsImportGoods
{
public GoodsImportGoods()
{
}
public int insertNewGoodsRec(int billId, String goodsId, String goodsName, String createPerson, float importUnitPrice)
{
int nRet;
nRet = 0;
DBConnection dbc = null;
Connection conn = null;
Statement stmt = null;
String strSQL = null;
try
{
dbc = new DBConnection();
conn = dbc.getDBConnection();
conn.setAutoCommit(false);
stmt = conn.createStatement();
strSQL = "insert into TabGoodsImportGoods( BillID, GoodsID, GoodsName, ImportAmount, ImportUnitPrice, CreatePerson, CreateTime, ConfirmFlage) values (" + billId + ", '" + StrUtility.replaceString(goodsId, "'", "''") + "', '" + StrUtility.replaceString(goodsName, "'", "''") + "', 1, " + importUnitPrice + ", '" + StrUtility.replaceString(createPerson, "'", "''") + "', getdate(), '0')";
nRet = stmt.executeUpdate(strSQL);
if(nRet != 1)
{
nRet = -1;
throw new Exception("插入新记录错误");
}
conn.commit();
}
catch(Exception e)
{
nRet = -1;
}
finally
{
try
{
if(stmt != null)
stmt.close();
if(conn != null)
dbc.closeDBConnection(conn);
}
catch(SQLException ex) { }
}
return nRet;
}
public List getGoodsList(int billId)
{
List goodsList;
goodsList = new ArrayList();
DBConnection dbc = null;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String strSQL = null;
try
{
dbc = new DBConnection();
conn = dbc.getDBConnection();
stmt = conn.createStatement();
strSQL = "SELECT * FROM TabGoodsImportGoods WHERE BillID=" + billId + " Order by CreateTime";
GoodsImportGoodsInfo gigi;
for(rs = stmt.executeQuery(strSQL); rs.next(); goodsList.add(gigi))
{
gigi = new GoodsImportGoodsInfo();
gigi.setBillId(rs.getInt(1));
gigi.setGoodsId(rs.getString(2));
gigi.setGoodsName(rs.getString(3));
gigi.setImportAmount(rs.getInt(4));
gigi.setImportUnitPrice(rs.getFloat(5));
gigi.setCreatePerson(rs.getString(6));
gigi.setCreateTime(rs.getString(7));
gigi.setConfirmFlage(rs.getString(8));
}
rs.close();
rs = null;
}
catch(Exception exception) { }
finally
{
try
{
if(rs != null)
rs.close();
if(stmt != null)
stmt.close();
if(conn != null)
dbc.closeDBConnection(conn);
}
catch(SQLException e) { }
}
return goodsList;
}
public int deleteGoodsRec(int billId, String goodsId, String confirmFlage)
{
int nRet;
nRet = 0;
DBConnection dbc = null;
Connection conn = null;
Statement stmt = null;
try
{
if(confirmFlage.equals("1"))
{
int curImportAmount = getImportAmount(billId, goodsId);
float curImportUnitPrice = getImportUnitPrice(billId, goodsId);
float curTotalPrice = (float)curImportAmount * curImportUnitPrice;
GoodsImportInfo gii = new GoodsImportInfo();
float billTotalPrice = gii.getTotalPrice(billId);
float newTotalPrice = billTotalPrice - curTotalPrice;
System.out.println("newTotalPrice:" + newTotalPrice + " curTotalPrice:" + curTotalPrice + " ");
gii.updateTotalPrice(billId, newTotalPrice);
}
dbc = new DBConnection();
conn = dbc.getDBConnection();
String strSQL = "DELETE FROM TabGoodsImportGoods WHERE BillID=" + billId + " and GoodsID='" + StrUtility.replaceString(goodsId, "'", "''") + "' and ConfirmFlage='" + confirmFlage + "'";
stmt = conn.createStatement();
nRet = stmt.executeUpdate(strSQL);
if(nRet != 1)
nRet = -1;
}
catch(Exception e)
{
e.printStackTrace();
nRet = -1;
}
finally
{
try
{
if(stmt != null)
stmt.close();
if(conn != null)
dbc.closeDBConnection(conn);
}
catch(SQLException e) { }
}
return nRet;
}
public int updateAandUP(int billId, String goodsId, int importAmount, float unitPrice)
{
int nRet;
nRet = 0;
DBConnection dbc = null;
Connection conn = null;
Statement stmt = null;
String strSQL = null;
try
{
dbc = new DBConnection();
conn = dbc.getDBConnection();
stmt = conn.createStatement();
strSQL = "UPDATE TabGoodsImportGoods SET ImportAmount = " + importAmount + ", ImportUnitPrice = " + unitPrice + " WHERE BillID = " + billId + " and GoodsID='" + StrUtility.replaceString(goodsId, "'", "''") + "'";
stmt.executeUpdate(strSQL);
}
catch(Exception e)
{
nRet = -1;
}
finally
{
try
{
if(stmt != null)
stmt.close();
if(conn != null)
dbc.closeDBConnection(conn);
}
catch(SQLException e) { }
}
return nRet;
}
public int deleteAllGoods(int billId)
{
int nRet;
nRet = 0;
DBConnection dbc = null;
Connection conn = null;
Statement stmt = null;
try
{
dbc = new DBConnection();
conn = dbc.getDBConnection();
String strSQL = "DELETE FROM TabGoodsImportGoods WHERE BillID=" + billId + " ";
stmt = conn.createStatement();
nRet = stmt.executeUpdate(strSQL);
if(nRet != 1)
nRet = -1;
}
catch(Exception e)
{
e.printStackTrace();
nRet = -1;
}
finally
{
try
{
if(stmt != null)
stmt.close();
if(conn != null)
dbc.closeDBConnection(conn);
}
catch(SQLException e) { }
}
return nRet;
}
public int updateConfirmFlageToOne(int billId)
{
int nRet;
nRet = 0;
DBConnection dbc = null;
Connection conn = null;
Statement stmt = null;
String strSQL = null;
try
{
dbc = new DBConnection();
conn = dbc.getDBConnection();
stmt = conn.createStatement();
strSQL = "UPDATE TabGoodsImportGoods SET ConfirmFlage = '1' WHERE BillID = " + billId;
stmt.executeUpdate(strSQL);
}
catch(Exception e)
{
nRet = -1;
}
finally
{
try
{
if(stmt != null)
stmt.close();
if(conn != null)
dbc.closeDBConnection(conn);
}
catch(SQLException e) { }
}
return nRet;
}
public int getMaxBillIDNum()
{
int nRet;
nRet = 0;
DBConnection dbc = null;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String strSQL = null;
try
{
dbc = new DBConnection();
conn = dbc.getDBConnection();
stmt = conn.createStatement();
strSQL = "SELECT max(BillID) FROM TabGoodsImportGoods;";
rs = stmt.executeQuery(strSQL);
if(!rs.next())
{
nRet = -1;
throw new Exception("获得最大进货单号失败");
}
nRet = rs.getInt(1);
rs.close();
rs = null;
}
catch(Exception exception) { }
finally
{
try
{
if(rs != null)
rs.close();
if(stmt != null)
stmt.close();
if(conn != null)
dbc.closeDBConnection(conn);
}
catch(SQLException e) { }
}
return nRet;
}
public List getBillIdList()
{
List billIdList;
billIdList = new ArrayList();
DBConnection dbc = null;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String strSQL = null;
try
{
dbc = new DBConnection();
conn = dbc.getDBConnection();
stmt = conn.createStatement();
strSQL = "SELECT DISTINCT BillID FROM TabGoodsImportGoods Order by BillID";
String billIdStr;
for(rs = stmt.executeQuery(strSQL); rs.next(); billIdList.add(billIdStr))
billIdStr = String.valueOf(rs.getInt(1));
rs.close();
rs = null;
}
catch(Exception exception) { }
finally
{
try
{
if(rs != null)
rs.close();
if(stmt != null)
stmt.close();
if(conn != null)
dbc.closeDBConnection(conn);
}
catch(SQLException e) { }
}
return billIdList;
}
public List getCreatePersonList()
{
List createPersonList;
createPersonList = new ArrayList();
DBConnection dbc = null;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String strSQL = null;
try
{
dbc = new DBConnection();
conn = dbc.getDBConnection();
stmt = conn.createStatement();
strSQL = "SELECT DISTINCT CreatePerson FROM TabGoodsImportGoods Order by CreatePerson";
String curSendPersons;
for(rs = stmt.executeQuery(strSQL); rs.next(); createPersonList.add(curSendPersons))
curSendPersons = rs.getString(1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -