///<summary>Used in FormPayment to sych database with changes user made to the paySplit list for a payment. Must supply an old list for comparison. Only the differences are saved.</summary> public static void UpdateList(ArrayList oldSplitList, ArrayList newSplitList) { PaySplit newPaySplit; for (int i = 0; i < oldSplitList.Count; i++) //loop through the old list { newPaySplit = null; for (int j = 0; j < newSplitList.Count; j++) { if (newSplitList[j] == null || ((PaySplit)newSplitList[j]).SplitNum == 0) { continue; } if (((PaySplit)oldSplitList[i]).SplitNum == ((PaySplit)newSplitList[j]).SplitNum) { newPaySplit = (PaySplit)newSplitList[j]; break; } } if (newPaySplit == null) { //PaySplit with matching SplitNum was not found, so it must have been deleted PaySplits.Delete(((PaySplit)oldSplitList[i])); continue; } //PaySplit was found with matching SplitNum, so check for changes if (newPaySplit.DateEntry != ((PaySplit)oldSplitList[i]).DateEntry || newPaySplit.DatePay != ((PaySplit)oldSplitList[i]).DatePay || newPaySplit.PatNum != ((PaySplit)oldSplitList[i]).PatNum || newPaySplit.PayNum != ((PaySplit)oldSplitList[i]).PayNum || newPaySplit.PayPlanNum != ((PaySplit)oldSplitList[i]).PayPlanNum || newPaySplit.ProcDate != ((PaySplit)oldSplitList[i]).ProcDate || newPaySplit.ProcNum != ((PaySplit)oldSplitList[i]).ProcNum || newPaySplit.ProvNum != ((PaySplit)oldSplitList[i]).ProvNum || newPaySplit.SplitAmt != ((PaySplit)oldSplitList[i]).SplitAmt) { PaySplits.Update(newPaySplit); } } for (int i = 0; i < newSplitList.Count; i++) //loop through the new list { if (newSplitList[i] == null) { continue; } if (((PaySplit)newSplitList[i]).SplitNum != 0) { continue; } //entry with SplitNum=0, so it's new PaySplits.Insert(((PaySplit)newSplitList[i])); } }