📄 goodsimportinfo.java
字号:
whereStr = whereStr + " PaymentTime<='" + paymentTime2 + "' AND ";
int lenOfWhereStr = whereStr.length();
if(lenOfWhereStr - 4 >= 0)
whereStr = whereStr.substring(0, lenOfWhereStr - 4);
if(!whereStr.equals(""))
{
strSQL = strSQL + " WHERE " + whereStr;
strSQLForCount = strSQLForCount + " WHERE " + whereStr;
}
strSQL = strSQL + " Order by " + orderStr;
try
{
dbc = new DBConnection();
conn = dbc.getDBConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(strSQLForCount);
if(!rs.next())
{
nRet = -1;
throw new Exception("获得总记录数失败");
}
totalRecNum = rs.getInt(1);
rs.close();
rs = null;
rs = stmt.executeQuery(strSQL);
boolean rsresult = false;
boolean hasnext = false;
for(int j = 1; j <= startRecNum; j++)
rsresult = rs.next();
if(rsresult)
{
hasnext = true;
for(int i = 1; i <= recNumOfPage && hasnext; i++)
{
GoodsImportBillInfo gibi = new GoodsImportBillInfo();
gibi.setBillId(rs.getInt(1));
gibi.setSendPersons(rs.getString(2));
gibi.setInceptPersons(rs.getString(3));
gibi.setTotalPrice(rs.getFloat(4));
gibi.setImportTime(rs.getString(5));
gibi.setPaymentTime(rs.getString(6));
String cancelAbleFlage = "0";
cancelAbleFlage = getCancelAbleFlageByBillId(rs.getInt(1));
gibi.setCancelAbleFlage(cancelAbleFlage);
importBillList.add(gibi);
if(rs.next())
hasnext = true;
else
hasnext = false;
}
}
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) { }
}
ibsri.setImportBillList(importBillList);
ibsri.setTotalRecNum(totalRecNum);
return ibsri;
}
public int deleteImportBill(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 TabGoodsImportInfo WHERE BillID=" + billId;
stmt = conn.createStatement();
nRet = stmt.executeUpdate(strSQL);
if(nRet != 1)
nRet = -1;
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 String getCancelAbleFlageByBillId(int billId)
{
GoodsImportGoods gig = new GoodsImportGoods();
List goodsList = gig.getGoodsList(billId);
GoodsInfo gi = new GoodsInfo();
int tmpflage = 1;
for(int i = 0; i < goodsList.size(); i++)
{
GoodsImportGoodsInfo gigi = (GoodsImportGoodsInfo)goodsList.get(i);
String goodsId = gigi.getGoodsId();
int importAmount = gigi.getImportAmount();
int repertoryAmount = gi.getRepertoryAmount(goodsId);
if(repertoryAmount >= importAmount)
tmpflage *= 1;
else
tmpflage *= 0;
}
if(tmpflage == 1)
return "1";
else
return "0";
}
public void cancelImportBill(int billId, String adjustPerson)
{
GoodsImportGoods gig = new GoodsImportGoods();
List goodsList = gig.getGoodsList(billId);
GoodsInfo gi = new GoodsInfo();
int tmpflage = 1;
for(int i = 0; i < goodsList.size(); i++)
{
GoodsImportGoodsInfo gigi = (GoodsImportGoodsInfo)goodsList.get(i);
String goodsId = gigi.getGoodsId();
int importAmount = gigi.getImportAmount();
int repertoryAmount = gi.getRepertoryAmount(goodsId);
if(repertoryAmount >= importAmount)
tmpflage *= 1;
else
tmpflage *= 0;
}
if(tmpflage == 1)
{
for(int i = 0; i < goodsList.size(); i++)
{
GoodsImportGoodsInfo gigi = (GoodsImportGoodsInfo)goodsList.get(i);
String goodsId = gigi.getGoodsId();
int importAmount = gigi.getImportAmount();
float importUnitPrice = gigi.getImportUnitPrice();
int repertoryAmount = gi.getRepertoryAmount(goodsId);
if(repertoryAmount >= importAmount)
{
gi.exportAdjustAandU(goodsId, importAmount, importUnitPrice, adjustPerson);
gig.deleteGoodsRec(billId, goodsId, "1");
}
}
List newGoodsList = gig.getGoodsList(billId);
if(newGoodsList.size() <= 0)
deleteImportBill(billId);
}
}
public float getTotalPrice(int billId)
{
float totalPrice;
totalPrice = 0.0F;
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 TotalPrice FROM TabGoodsImportInfo WHERE BillID=" + billId;
rs = stmt.executeQuery(strSQL);
if(rs.next())
totalPrice = rs.getFloat(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 totalPrice;
}
public int updateTotalPrice(int billId, float newTotalPrice)
{
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 TabGoodsImportInfo SET TotalPrice = " + newTotalPrice + " 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 updatePaymentTime(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 TabGoodsImportInfo SET PaymentTime = getdate() 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;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -