Error Handling PEB

--HG--
branch : EDII
This commit is contained in:
animfalahuddin 2018-12-13 12:49:09 +07:00
parent 187886533c
commit c689d21f8a
1 changed files with 9 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.Iterator;
import org.adempiere.exceptions.AdempiereException;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
@ -59,6 +60,7 @@ public class MID_UploadPEB extends SvrProcess{
}
private void readAccess(File TPB) throws Exception{
String msg = "";
File f_Access = new File(p_File);
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
String databaseURL = "jdbc:ucanaccess://" + f_Access.getPath() + ";jackcessOpener=andromedia.midsuit.process.CryptCodecOpener";
@ -71,9 +73,12 @@ public class MID_UploadPEB extends SvrProcess{
while (rs.next()) {
int C_BPartner_ID = DB.getSQLValue(get_TrxName(), "SELECT C_BPartner_ID FROM C_Bpartner WHERE Name =? AND AD_Client_ID =? AND isCustomer ='Y'", new Object[] { rs.getString("NAMABELI"), getAD_Client_ID()});
int C_Currency_ID = DB.getSQLValue(get_TrxName(), "SELECT C_Currency_ID FROM C_Currency WHERE ISO_Code =? ", new Object[] { rs.getString("KDVAL"), getAD_Client_ID()});
int C_Currency_ID = DB.getSQLValue(get_TrxName(), "SELECT C_Currency_ID FROM C_Currency WHERE ISO_Code =?", new Object[] { rs.getString("KDVAL") });
int M_PriceList_ID = DB.getSQLValue(get_TrxName(), "SELECT M_PriceList_ID FROM M_PriceList WHERE C_Currency_ID =? AND AD_Client_ID =?", new Object[] { C_Currency_ID, getAD_Client_ID() });
int C_DocTypeTarget_ID = DB.getSQLValue(get_TrxName(), "SELECT C_DocType_ID FROM C_DocType WHERE Name =? AND AD_Client_ID =?", new Object[] { "'Sales Order'", getAD_Client_ID()});
int C_DocTypeTarget_ID = DB.getSQLValue(get_TrxName(), "SELECT C_DocType_ID FROM C_DocType WHERE Name =? AND AD_Client_ID =?", new Object[] { "Sales Order", getAD_Client_ID()});
if (C_BPartner_ID < 0) {msg += "- BPartner " + rs.getString("NAMABELI") + " tidak ada!\n";}
if (C_Currency_ID < 0) {msg += "- Currency " + rs.getString("KDVAL") + " tidak ada!\n";}
if (msg != "") throw new AdempiereException(msg);
String no_aju = rs.getString("CAR");
@ -98,6 +103,8 @@ public class MID_UploadPEB extends SvrProcess{
while (rsDtl.next()) {
int M_Product_ID = DB.getSQLValue(get_TrxName(), "SELECT M_Product_ID FROM M_Product WHERE Value =?", new Object[] { rsDtl.getString("KDBRG") });
int C_UOM_ID = DB.getSQLValue(get_TrxName(), " SELECT C_UOM_ID FROM C_UOM WHERE UOMSymbol =?", new Object[] { rsDtl.getString("JNSATUAN") });
if (M_Product_ID < 0) {throw new AdempiereException("Product " + rsDtl.getString("KDBRG") + " tidak ada!");}
if (C_UOM_ID < 0) {throw new AdempiereException("Uom " + rsDtl.getString("JNSATUAN") + " tidak ada!");}
MOrderLine oLine = new MOrderLine(getCtx(), 0, get_TrxName());
oLine.setHeaderInfo(order);