//Test if can regs
boolean allTamtEqualsZero = true;
Iterator rowsIter = correspondenceRow.getRowSet().getRows().iterator();
while (rowsIter.hasNext()) {
Row row = (Row)rowsIter.next();
if (correspondenceRow.isAdd()) {
if (row != correspondenceRow) {
Double tempTAmt = Double.parseDouble(ObjectUtil.findNewCell(row, "TI", "TAMT").getColumnValue().toString());
if (tempTAmt != 0.0) {
allTamtEqualsZero = false;
break;
}
}
} else {
Double tempTAmt = Double.parseDouble(ObjectUtil.findNewCell(row, "TI", "TAMT").getColumnValue().toString());
if (tempTAmt != 0.0) {
allTamtEqualsZero = false;
break;
}
}
}
if (allTamtEqualsZero) {
return -1;
}
//delete oldR
Vector newRAndOldRs = new Vector();//data struct: new_R-newR
rowsIter = correspondenceRow.getRowSet().getRows().iterator();
while (rowsIter.hasNext()) {
Row row = (Row)rowsIter.next();
int oldR = -1;
int newR = -1;
if ( (ObjectUtil.findOldCell(row, "TI", "R").getColumnValue() != null) && (ObjectUtil.findOldCell(row, "TI", "R").getColumnValue().toString().trim().length() > 0) ) {
oldR = Integer.parseInt(ObjectUtil.findOldCell(row, "TI", "R").getColumnValue().toString());
}
if ( (ObjectUtil.findNewCell(row, "TI", "R").getColumnValue() != null) && (ObjectUtil.findNewCell(row, "TI", "R").getColumnValue().toString().trim().length() > 0) ) {
newR = Integer.parseInt(ObjectUtil.findNewCell(row, "TI", "R").getColumnValue().toString());
}
if (!row.isDelete()) {
if (oldR != -1) {
TaxClass.deleteR(oldR);//USE TaxClass
TaxClass.deleteRI(oldR);//USE TaxClass
}
if (newR != -1) {
TaxClass.deleteR(newR);//USE TaxClass
TaxClass.deleteRI(newR);//USE TaxClass
}
} else {
if (!row.isAdd()) {
if (oldR != -1) {
TaxClass.deleteR(oldR);//USE TaxClass
TaxClass.deleteRI(oldR);//USE TaxClass
}
}
}
}
rowsIter = correspondenceRow.getRowSet().getRows().iterator();
int new_R = TaxClass.getMAXR() + 1;
while (rowsIter.hasNext()) {
Row row = (Row)rowsIter.next();
int newR = -1;
if ( (ObjectUtil.findNewCell(row, "TI", "R").getColumnValue() != null) && (ObjectUtil.findNewCell(row, "TI", "R").getColumnValue().toString().trim().length() > 0) ) {
newR = Integer.parseInt(ObjectUtil.findNewCell(row, "TI", "R").getColumnValue().toString());
}
String str = new_R + "-" + newR;
newRAndOldRs.add(str);
}
//add new R
rowsIter = correspondenceRow.getRowSet().getRows().iterator();
Iterator newRAndOldRsIter = newRAndOldRs.iterator();
while (rowsIter.hasNext()) {
Row row = (Row)rowsIter.next();
String str = (String)newRAndOldRsIter.next();
StringTokenizer st = new StringTokenizer(str, "-");
String tDate = ObjectUtil.findNewCell(correspondenceRow, "T", "DUE").getColumnValue().toString();
String txt512 = "";
if (ObjectUtil.findNewCell(correspondenceRow, "T", "TXT256").getColumnValue() != null)
txt512 = ObjectUtil.findNewCell(correspondenceRow, "T", "TXT256").getColumnValue().toString();
new_R = Integer.parseInt(st.nextElement().toString());
TaxClass.insertr(new_R, tDate, txt512);//USE TaxClass
}
//add newri
correspondenceRow.setModify(true);
rowsIter = correspondenceRow.getRowSet().getRows().iterator();
newRAndOldRsIter = newRAndOldRs.iterator();
int currentRI = 1;
while (rowsIter.hasNext()) {
Row row = (Row)rowsIter.next();
String str = (String)newRAndOldRsIter.next();
StringTokenizer st = new StringTokenizer(str, "-");
String tDate = ObjectUtil.findNewCell(correspondenceRow, "T", "DUE").getColumnValue().toString();
String txt512 = "";
String ld = CorrespondenceClass.getLD(correspondenceRow);