package realcix20.classes;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.TreeMap;
import java.util.Vector;
import realcix20.classes.basic.BaseClass;
import realcix20.classes.basic.Cell;
import realcix20.classes.basic.ClassManager;
import realcix20.classes.basic.Row;
import realcix20.guis.utils.BooleanObject;
import realcix20.guis.utils.DialogManager;
import realcix20.guis.utils.TxtManager;
import realcix20.guis.views.MainView;
import realcix20.utils.DAO;
import realcix20.utils.GlobalValueManager;
import realcix20.utils.ObjectUtil;
import realcix20.utils.Resources;
public class RegClass extends BaseClass {
public RegClass(int clsId) {
super(clsId);
}
public RegClass(int clsId, boolean t) {
super(clsId, t);
}
public static void deleteRelativeThings(Row regRow) {
int r = Integer.parseInt(ObjectUtil.findNewCell(regRow, "R", "R").getColumnValue().toString());
deleteRelativeThings(r);
}
private static void deleteRelativeThings(int r){
//first,delete rpn
DAO dao = DAO.getInstance();
dao.update(Resources.DELETE_RPN_BY_R_SQL);
dao.setInt(1, r);
dao.executeUpdate();
//next,delete budgets(BI)
dao.update(Resources.DELETE_BI_BY_R_SQL);
dao.setInt(1, r);
dao.executeUpdate();
}
public static void delete(int r){
deleteRelativeThings(r);
DAO dao = DAO.getInstance();
// Delete childTables
dao.update(Resources.DELETE_RI_SQL);
dao.setInt(1, r);
dao.executeUpdate();
// Delete mainTables
dao.update(Resources.DELETE_R_SQL);
dao.setInt(1, r);
dao.executeUpdate();
}
public static void deleteRelativeThings(int r, int ri) {
//first,delete rpn
DAO dao = DAO.getInstance();
dao.update(Resources.DELETE_RPN_BY_R_RI_SQL);
dao.setInt(1, r);
dao.setInt(2, ri);
dao.executeUpdate();
//next,delete budgets(BI)
dao.update(Resources.DELETE_BI_BY_R_RI_SQL);
dao.setInt(1, r);
dao.setInt(2, ri);
dao.executeUpdate();
}
public static boolean validateDelete(Row regRow, MainView container) {
boolean result = true;
Iterator regItemRows = regRow.getRowSet().getRows().iterator();
boolean isUsedInCorrespondence = false;
while (regItemRows.hasNext()) {
Row regItemRow = (Row)regItemRows.next();
isUsedInCorrespondence = CorrespondenceClass.isRegUsedInCorrespondence(regItemRow);
if (isUsedInCorrespondence)
break;
}
if (isUsedInCorrespondence) {
DialogManager.showMessageDialog(container, TxtManager.getTxt("INFORMATION.REGUSEDINCORRESPONDENCE"));
return false;
}
boolean isUsedInTax = false;
regItemRows = regRow.getRowSet().getRows().iterator();
while (regItemRows.hasNext()) {
Row regItemRow = (Row)regItemRows.next();
isUsedInTax = TaxClass.isRegUsedInTax(regItemRow);
if (isUsedInTax)
break;
}
if (isUsedInTax) {
DialogManager.showMessageDialog(container, TxtManager.getTxt("INFORMATION.REGUSEDINTAX"));
return false;
}
return result;
}
//batch
public static boolean validateDelete(Row regRow, MainView container,Vector tableRow) {
boolean result = true;
Iterator regItemRows = regRow.getRowSet().getRows().iterator();
boolean isUsedInCorrespondence = false;
while (regItemRows.hasNext()) {
Row regItemRow = (Row)regItemRows.next();
isUsedInCorrespondence = CorrespondenceClass.isRegUsedInCorrespondence(regItemRow);
if (isUsedInCorrespondence)
break;
}
if (isUsedInCorrespondence) {
// DialogManager.showMessageDialog(container, TxtManager.getTxt("INFORMATION.REGUSEDINCORRESPONDENCE"));
tableRow.add(TxtManager.getTxt("INFORMATION.REGUSEDINCORRESPONDENCE"));
tableRow.add(new BooleanObject(false,false));
return false;
}
boolean isUsedInTax = false;
regItemRows = regRow.getRowSet().getRows().iterator();
while (regItemRows.hasNext()) {
Row regItemRow = (Row)regItemRows.next();
isUsedInTax = TaxClass.isRegUsedInTax(regItemRow);
if (isUsedInTax)
break;
}
if (isUsedInTax) {
//DialogManager.showMessageDialog(container, TxtManager.getTxt("INFORMATION.REGUSEDINTAX"));
tableRow.add(TxtManager.getTxt("INFORMATION.REGUSEDINTAX"));
tableRow.add(new BooleanObject(false,false));
return false;
}
return result;
}
public static int createCurrencyEvaluationReg(java.sql.Date date) {
int r = 0;
RegClass reg = (RegClass)ClassManager.createClass(510);
Row newRegRow = new Row(reg.getRowType());
newRegRow.setAdd(true);
ObjectUtil.findNewCell(newRegRow, "R", "R").setColumnValue(RegClass.getMaxR() + 1);
r = RegClass.getMaxR() + 1;
ObjectUtil.findNewCell(newRegRow, "R", "AT").setColumnValue(GlobalValueManager.getValue("APPLICATION.AT"));
ObjectUtil.findNewCell(newRegRow, "R", "RDATE").setColumnValue(date);
java.sql.Date now = new java.sql.Date(System.currentTimeMillis());
ObjectUtil.findNewCell(newRegRow, "R", "CREATED").setColumnValue(now);
ObjectUtil.findNewCell(newRegRow, "R", "CREATEDBY").setColumnValue(GlobalValueManager.getValue("SESSION.LOGINUSER"));
ObjectUtil.findNewCell(newRegRow, "R", "LASTCHANGED").setColumnValue(now);
ObjectUtil.findNewCell(newRegRow, "R", "LASTCHANGEDBY").setColumnValue(GlobalValueManager.getValue("SESSION.LOGINUSER"));
ObjectUtil.findNewCell(newRegRow, "R", "TXT256").setColumnValue(TxtManager.getTxt("VIEW.CURRENCYEVALUATION.TITLE"));
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_RI_XR_INFO_SQL);
ResultSet rs = dao.executeQuery();
try {
int i = 1;
double sum = 0.0;
while (rs.next()) {
if (rs.getDouble("LAMT") != 0.0) {
Row regItemRow = ObjectUtil.addnewChildRow(reg, newRegRow);
regItemRow.setAdd(true);
ObjectUtil.findNewCell(regItemRow, "RI", "RI").setColumnValue(i);
ObjectUtil.findNewCell(regItemRow, "RI", "TXT256").setColumnValue(TxtManager.getTxt("VIEW.CURRENCYEVALUATION.TITLE"));
ObjectUtil.findNewCell(regItemRow, "RI", "LD").setColumnValue(rs.getString("LD"));
ObjectUtil.findNewCell(regItemRow, "RI", "TC").setColumnValue(rs.getString("TC"));
ObjectUtil.findNewCell(regItemRow, "RI", "LC").setColumnValue(rs.getString("LC"));
ObjectUtil.findNewCell(regItemRow, "RI", "TAMT").setColumnValue(0);
ObjectUtil.findNewCell(regItemRow, "RI", "XR").setColumnValue(rs.getDouble("XR"));
ObjectUtil.findNewCell(regItemRow, "RI", "LAMT").setColumnValue(rs.getDouble("LAMT"));
newRegRow.getRowSet().getRows().add(regItemRow);
sum+=rs.getDouble("LAMT");
i++;
}
}
if(sum>0.000001){ //balance
Row regItemRow = ObjectUtil.addnewChildRow(reg, newRegRow);
regItemRow.setAdd(true);
ObjectUtil.findNewCell(regItemRow, "RI", "RI").setColumnValue(i);
ObjectUtil.findNewCell(regItemRow, "RI", "TXT256").setColumnValue(TxtManager.getTxt("VIEW.CURRENCYEVALUATION.BALANCE"));
ObjectUtil.findNewCell(regItemRow, "RI", "LD").setColumnValue(LedgerTypeClass.getDefLD("XVC"));
ObjectUtil.findNewCell(regItemRow, "RI", "TC").setColumnValue(FamilyClass.getLocalCurrency());
ObjectUtil.findNewCell(regItemRow, "RI", "XR").setColumnValue(1.0);
ObjectUtil.findNewCell(regItemRow, "RI", "LC").setColumnValue(FamilyClass.getLocalCurrency());
ObjectUtil.findNewCell(regItemRow, "RI", "TAMT").setColumnValue(0.0 - sum);
ObjectUtil.findNewCell(regItemRow, "RI", "LAMT").setColumnValue(0.0 - sum);
newRegRow.getRowSet().getRows().add(regItemRow);
i++;
}
if (i > 1) {
reg.classInsert_WholeObject(newRegRow, false);
// r = 0;
} else {
r = 0;
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
return r;
}
public static boolean isIPUsedInReg(Row ipRow) {
boolean result = false;
String im = ObjectUtil.findNewCell(ipRow, "IP", "IM").getColumnValue().toString();
String ip = ObjectUtil.findNewCell(ipRow, "IP", "IP").getColumnValue().toString();
RegClass reg = (RegClass)ClassManager.createClass(510);
StringBuffer sb = new StringBuffer(reg.getBasicSQL());
sb.append(" WHERE RI.IM=? AND RI.IP=?");
String sql = sb.toString();
DAO dao = DAO.getInstance();
dao.setObject(1, im);
dao.setObject(2, ip);
ResultSet rs = dao.executeQuery();
try {
if ( (rs.next()) && (im.equals(rs.getObject("IM"))) && (ip.equals(rs.getObject("IP"))) ) {
result = true;
}
rs.close();
} catch (SQLException sqle) {
sqle.printStackTrace();
}
return result;
}
public static boolean isPReferencedInReg(Row pRow) {
boolean result = false;
String ns = ObjectUtil.findNewCell(pRow, "P", "NS").getColumnValue().toString();
String p = ObjectUtil.findNewCell(pRow, "P", "P").getColumnValue().toString();
RegClass reg = (RegClass)ClassManager.createClass(510);
StringBuffer sb = new StringBuffer(reg.getBasicSQL());
sb.append(" WHERE RI.NS=? AND RI.P=?");
String sql = sb.toString();
DAO dao = DAO.getInstance();
dao.query(sql);
dao.setObject(1, ns);
dao.setObject(2, p);
ResultSet rs = dao.executeQuery();
try {
if ( (rs.next()) && (ns.equals(rs.getObject("NS"))) && (p.equals(rs.getObject("P"))) ) {
result = true;
}
rs.close();
} catch(SQLException sqle) {
sqle.printStackTrace();
}
return result;
}
public static boolean isLDUsedInReg(Row ldRow) {
boolean result = false;
String ld = ObjectUtil.findNewCell(ldRow, "LD", "LD").getColumnValue().toString();
RegClass reg = (RegClass)ClassManager.createClass(510);
StringBuffer sb = new StringBuffer(reg.getBasicSQL());
sb.append(" WHERE RI.LD=?");
String sql = sb.toString();
DAO dao = DAO.getInstance();
dao.query(sql);
dao.setString(1, ld);
ResultSet rs = dao.executeQuery();
try {
if (rs.next()) {
result = true;
}
rs.close();
} catch (SQLException sqle) {
sqle.printStackTrace();
}
return result;
}
public static boolean isFAUsedInReg(Row faRow) {
boolean result = false;
String fa = ObjectUtil.findNewCell(faRow, "FA", "FA").getColumnValue().toString();
RegClass reg = (RegClass)ClassManager.createClass(510);
StringBuffer sb = new StringBuffer(reg.getBasicSQL());
sb.append(" WHERE RI.FA=?");
String sql = sb.toString();
DAO dao = DAO.getInstance();
dao.query(sql);
dao.setString(1, fa);
ResultSet rs = dao.executeQuery();
try {
if (rs.next()) {
if (fa.equals(rs.getObject("FA")))
result = true;
}
rs.close();
} catch (SQLException sqle) {
sqle.printStackTrace();
}
return result;
}
public static boolean isUOMUsedInReg(Row uomRow) {
boolean result = false;
String uom = ObjectUtil.findNewCell(uomRow, "UOM", "UOM").getColumnValue().toString();
RegClass reg = (RegClass)ClassManager.createClass(510);
StringBuffer sb = new StringBuffer(reg.getBasicSQL());
sb.append(" WHERE RI.MUOM=? OR RI.IPUOM=?");
String sql = sb.toString();
DAO dao = DAO.getInstance();
dao.query(sql);
dao.setObject(1, uom);
dao.setObject(2, uom);
ResultSet rs = dao.executeQuery();
try {
if (rs.next())
result = true;
rs.close();
} catch (SQLException sqle) {
sqle.printStackTrace();
}
return result;
}
public static boolean isATUsedInReg(Row anaTypeRow) {
boolean result = false;
String at = ObjectUtil.findNewCell(anaTypeRow, "AT", "AT").getColumnValue().toString();
RegClass reg = (RegClass)ClassManager.createClass(510);
String sql = reg.getBasicSQL();
DAO dao = DAO.getInstance();
dao.query(sql);
ResultSet rs = dao.executeQuery();
try {
ResultSetMetaData rsmd = rs.getMetaData();
int i;
for (i = 1; i < rsmd.getColumnCount(); i++) {
if ( (rsmd.getTableName(i).equals("R")) && (rsmd.getColumnName(i).equals("AT")) )
break;
}
while (rs.next()) {
if (at.equals(rs.getObject(i))) {
result = true;
break;
}
}
} catch (SQLException sqle) {
sqle.printStackTrace();
}
return result;
}
public boolean isEqual(Row regRow1, Row regRow2) {
boolean result = false;
int r1 = 0;
Cell cell = ObjectUtil.findNewCell(regRow1, "RI", "R");
if (cell.getColumnValue() instanceof Number)
r1 = ((Number)cell.getColumnValue()).intValue();
else
r1 = Integer.parseInt((String)cell.getColumnValue());
int ri1 = 0;
cell = ObjectUtil.findNewCell(regRow1, "RI", "RI");
if (cell.getColumnValue() instanceof Number)
ri1 = ((Number)cell.getColumnValue()).intValue();
else
ri1 = Integer.parseInt((String)cell.getColumnValue());
int r2 = 0;
cell = ObjectUtil.findNewCell(regRow2, "RI", "R");
if (cell.getColumnValue() instanceof Number)
r2 = ((Number)cell.getColumnValue()).intValue();
else
r2 = Integer.parseInt((String)cell.getColumnValue());
int ri2 = 0;
cell = ObjectUtil.findNewCell(regRow2, "RI", "RI");
if (cell.getColumnValue() instanceof Number)
ri2 = ((Number)cell.getColumnValue()).intValue();
else
ri2 = Integer.parseInt((String)cell.getColumnValue());
result = ( (r1 == r2) && (ri1 == ri2) );
return result;
}
public boolean isCleared(Row row) {
boolean flag = false;
Cell cell1 = ObjectUtil.findOldCell(row, "RI", "R");
Cell cell2 = ObjectUtil.findOldCell(row, "RI", "RI");
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_CLEARED_REG_SQL);
dao.setObject(1, cell1.getColumnValue());
dao.setObject(2, cell2.getColumnValue());
ResultSet rs = dao.executeQuery();
try {
if (rs.next()) {
flag = true;
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
return flag;
}
public boolean isApOrAr(Row row) {
boolean flag = false;
Cell cell1 = ObjectUtil.findOldCell(row, "RI", "LD");
Cell cell2 = ObjectUtil.findOldCell(row, "R", "AT");
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_LT_FROM_LD);
dao.setObject(1, cell1.getColumnValue());
ResultSet rs = dao.executeQuery();
try {
if (rs.next()) {
String lt = rs.getString("LT");
if ( ( (lt.equals("AP")) || (lt.equals("AR")) ) && (cell2.getColumnValue().equals("REAL")) ) {
flag = true;
}
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
return flag;
}
public boolean setCleared(Vector rows) {
boolean result = false;
Iterator rowIter = rows.iterator();
while (rowIter.hasNext()) {
Row row = (Row)rowIter.next();
Cell cell1 = ObjectUtil.findOldCell(row, "RI", "R");
Cell cell2 = ObjectUtil.findOldCell(row, "RI", "RI");
DAO dao = DAO.getInstance();
dao.update(Resources.INSERT_RPN_SQL);
dao.setObject(1, cell1.getColumnValue());
dao.setObject(2, cell2.getColumnValue());
if (dao.executeUpdate())
result = true;
}
return result;
}
public boolean setUnCleared(Vector rows) {
boolean result = false;
Iterator rowIter = rows.iterator();
while (rowIter.hasNext()) {
Row row = (Row)rowIter.next();
Cell cell1 = ObjectUtil.findOldCell(row, "RI", "R");
Cell cell2 = ObjectUtil.findOldCell(row, "RI", "RI");
DAO dao = DAO.getInstance();
dao.update(Resources.DELETE_RPN_SQL);
dao.setObject(1, cell1.getColumnValue());
dao.setObject(2, cell2.getColumnValue());
if (dao.executeUpdate())
result = true;
}
return result;
}
public boolean assignAllBudgets(Vector regs) {
boolean result = false;
Iterator regsIter = regs.iterator();
while (regsIter.hasNext()) {
Vector regDatas = (Vector)regsIter.next();
result = assignToBudget(regDatas);
}
return result;
}
public boolean assignToBudget(Vector regDatas) {
boolean result = false;
Row row = (Row)regDatas.get(0);
Vector notAssignedRowDatas = (Vector)regDatas.get(1);
Vector assignedRowDatas = (Vector)regDatas.get(2);
int r = 0;
Cell cell = ObjectUtil.findNewCell(row, "RI", "R");
if (cell.getColumnValue() instanceof Number)
r = ((Number)cell.getColumnValue()).intValue();
else
r = Integer.parseInt((String)cell.getColumnValue());
int ri = 0;
cell = ObjectUtil.findNewCell(row, "RI", "RI");
if (cell.getColumnValue() instanceof Number)
ri = ((Number)cell.getColumnValue()).intValue();
else
ri = Integer.parseInt((String)cell.getColumnValue());
DAO dao = DAO.getInstance();
Iterator nardsIter = notAssignedRowDatas.iterator();
while (nardsIter.hasNext()) {
Vector rowData = (Vector)nardsIter.next();
dao.update(Resources.DELETE_BI_SQL);
dao.setObject(1, r);
dao.setObject(2, ri);
dao.setObject(3, rowData.get(0));
dao.setObject(4, rowData.get(1));
dao.setObject(5, rowData.get(2));
dao.executeUpdate();
}
Iterator ardIter = assignedRowDatas.iterator();
while (ardIter.hasNext()) {
Vector rowData = (Vector)ardIter.next();
dao.query(Resources.SELECT_BI_BY_ALLPK_SQL);
dao.setObject(1, r);
dao.setObject(2, ri);
dao.setObject(3, rowData.get(0));
dao.setObject(4, rowData.get(1));
dao.setObject(5, rowData.get(2));
ResultSet rs = dao.executeQuery();
try {
if (rs.next()) {
dao.update(Resources.UPDATE_BI_SQL);
dao.setObject(1, rowData.get(4));
dao.setObject(2, rowData.get(5));
cell = ObjectUtil.findNewCell(row, "RI", "TXT256");
dao.setObject(3, cell.getColumnValue());
dao.setObject(4, r);
dao.setObject(5, ri);
dao.setObject(6, rowData.get(0));
dao.setObject(7, rowData.get(1));
dao.setObject(8, rowData.get(2));
dao.executeUpdate();
} else {
dao.update(Resources.ADD_BI_SQL);
dao.setObject(1, r);
dao.setObject(2, ri);
dao.setObject(3, rowData.get(0));
dao.setObject(4, rowData.get(1));
dao.setObject(5, rowData.get(2));
dao.setObject(6, rowData.get(4));
dao.setObject(7, rowData.get(5));
cell = ObjectUtil.findNewCell(row, "RI", "TXT256");
dao.setObject(8, cell.getColumnValue());
dao.executeUpdate();
}
rs.close();
result = true;
} catch (Exception e) {
result = false;
e.printStackTrace();
}
}
return result;
}
public int getRowSignBySpecifyTax(Row row, String taxt, String tax, String taxi) {
int sign = 1;
int r = 0;
Cell cell = ObjectUtil.findNewCell(row, "RI", "R");
if (cell.getColumnValue() instanceof Number)
r = ((Number)cell.getColumnValue()).intValue();
else
r = Integer.parseInt((String)cell.getColumnValue());
int ri = 0;
cell = ObjectUtil.findNewCell(row, "RI", "RI");
if (cell.getColumnValue() instanceof Number)
ri = ((Number)cell.getColumnValue()).intValue();
else
ri = Integer.parseInt((String)cell.getColumnValue());
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_FROM_RITAXI_BY_ALL_PKS_SQL);
dao.setObject(1, r);
dao.setObject(2, ri);
dao.setObject(3, taxt);
dao.setObject(4, tax);
dao.setObject(5, taxi);
ResultSet rs = dao.executeQuery();
try {
if (rs.next())
sign = rs.getInt("SIGN");
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
return sign;
}
public boolean isRowTaxedBySpecifyTax(Row row, String taxt, String tax, String taxi) {
boolean result = false;
int r = 0;
Cell cell = ObjectUtil.findNewCell(row, "RI", "R");
if (cell.getColumnValue() instanceof Number)
r = ((Number)cell.getColumnValue()).intValue();
else
r = Integer.parseInt((String)cell.getColumnValue());
int ri = 0;
cell = ObjectUtil.findNewCell(row, "RI", "RI");
if (cell.getColumnValue() instanceof Number)
ri = ((Number)cell.getColumnValue()).intValue();
else
ri = Integer.parseInt((String)cell.getColumnValue());
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_FROM_RITAXI_BY_ALL_PKS_SQL);
dao.setObject(1, r);
dao.setObject(2, ri);
dao.setObject(3, taxt);
dao.setObject(4, tax);
dao.setObject(5, taxi);
ResultSet rs = dao.executeQuery();
try {
if (rs.next())
result = true;
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public boolean isRowTaxed(Row row) {
boolean result = false;
int r = 0;
Cell cell = ObjectUtil.findNewCell(row, "RI", "R");
if (cell.getColumnValue() instanceof Number)
r = ((Number)cell.getColumnValue()).intValue();
else
r = Integer.parseInt((String)cell.getColumnValue());
int ri = 0;
cell = ObjectUtil.findNewCell(row, "RI", "RI");
if (cell.getColumnValue() instanceof Number)
ri = ((Number)cell.getColumnValue()).intValue();
else
ri = Integer.parseInt((String)cell.getColumnValue());
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_FROM_RITAXI_BY_R_AND_RI_SQL);
dao.setObject(1, r);
dao.setObject(2, ri);
ResultSet rs = dao.executeQuery();
try {
if (rs.next())
result = true;
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public Vector findAllTaxableRegs(Row taxRow) {
Vector taxableRows = new Vector();
Iterator rowsIter = this.getRows().iterator();
while (rowsIter.hasNext()) {
Row row = (Row)rowsIter.next();
if (isRowTaxable(row))
taxableRows.add(row);
}
return taxableRows;
}
public Vector findAllNotTaxedByOtherTaxsRegs(Row taxRow) {
Vector taxableRows = new Vector();
Iterator rowsIter = this.getRows().iterator();
while (rowsIter.hasNext()) {
Row row = (Row)rowsIter.next();
if ( (isRowTaxable(row)) && (!isRowTaxByOtherTaxs(taxRow, row)) ) {
taxableRows.add(row);
}
}
return taxableRows;
}
public static boolean isRowTaxByOtherTaxs(Row taxRow, Row regRow) {
boolean result = false;
int r = 0;
Cell cell = ObjectUtil.findNewCell(regRow, "RI", "R");
if (cell.getColumnValue() instanceof Number)
r = ((Number)cell.getColumnValue()).intValue();
else
r = Integer.parseInt((String)cell.getColumnValue());
int ri = 0;
cell = ObjectUtil.findNewCell(regRow, "RI", "RI");
if (cell.getColumnValue() instanceof Number)
ri = ((Number)cell.getColumnValue()).intValue();
else
ri = Integer.parseInt((String)cell.getColumnValue());
cell = ObjectUtil.findNewCell(taxRow, "TAXI", "TAXT");
String taxt = (String)cell.getColumnValue();
cell = ObjectUtil.findNewCell(taxRow, "TAXI", "TAX");
String tax = (String)cell.getColumnValue();
cell = ObjectUtil.findNewCell(taxRow, "TAXI", "TAXI");
String taxi = (String)cell.getColumnValue();
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_FROM_RITAXI_BY_R_AND_RI_SQL);
dao.setObject(1, r);
dao.setObject(2, ri);
ResultSet rs = dao.executeQuery();
try {
while (rs.next()) {
if ( (!taxt.equals(rs.getString("TAXT"))) || (!tax.equals(rs.getString("TAX"))) ||
(!taxi.equals(rs.getString("TAXI"))) ) {
result = true;
}
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public static boolean isRowTaxable(Row row) {
boolean result = false;
Cell cell = ObjectUtil.findNewCell(row, "RI", "LD");
String ld = (String)cell.getColumnValue();
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_TAXABLE_FROM_LD_BY_LD_SQL);
dao.setString(1, ld);
ResultSet rs = dao.executeQuery();
try {
if (rs.next()) {
result = rs.getBoolean("TAXABLE");
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public static int getMaxR() {
int max = 0;
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_MAX_R_FROM_R_SQL);
ResultSet rs = dao.executeQuery();
try {
if (rs.next())
max = rs.getInt(1);
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
return max;
}
}