}
//get rid of all uniq num posts for period ids
dc.con.createStatement().executeQuery(dc.filterSQL(
"DELETE FROM UniqNum WHERE UniqName LIKE 'PeriodId=%'"));
//adjust the periodid for each activity
UniqNumGenerator uniqnum = new UniqNumGenerator();
ResultSet rsPeriods=null;
String select="SELECT CompId,Act_id,InvDate FROM Activity2 ";
if (inCompId>0)
select+=" WHERE CompId=" + inCompId;
select+=" ORDER BY CompId,Act_id";
ResultSet rsOldTrans = dc.con.createStatement().executeQuery(dc.filterSQL(select));
int lastCompId=-1;
rsOldTrans.last();
int numRecs=rsOldTrans.getRow();
rsOldTrans.beforeFirst();
while (rsOldTrans.next()) {
if (lastCompId!=rsOldTrans.getInt(1)){
//get all the periods for the CompId
lastCompId=rsOldTrans.getInt(1);
rsPeriods=dc.con.createStatement().executeQuery(dc.filterSQL(
"SELECT StartPeriod,EndPeriod FROM AccountingPeriods WHERE CompId=" + lastCompId));
}
Date invoiceDate=rsOldTrans.getDate(3);
int periodId=0;
rsPeriods.beforeFirst();
//find the appropriate period if it exists.
while (rsPeriods.next()) {
if (invoiceDate.compareTo(rsPeriods.getDate(1))>=0 && invoiceDate.compareTo(rsPeriods.getDate(2))<=0){
//increment period id counter
periodId=uniqnum.GetUniqueNumber("PeriodId="+ rsPeriods.getDate(1) + "-"
+ rsPeriods.getDate(2), 1, 999999999,new Integer(lastCompId));
break; //we found the period we need
}
}
dc.con.createStatement().executeQuery(dc.filterSQL(