コード例 #1
0
ファイル: Benefits.cs プロジェクト: luisurbinanet/apolloniax
        ///<summary>Used in FormInsPlan to sych database with changes user made to the benefit list for a plan.  Must supply an old list for comparison.  Only the differences are saved.</summary>
        public static void UpdateList(List <Benefit> oldBenefitList, List <Benefit> newBenefitList)
        {
            Benefit newBenefit;

            for (int i = 0; i < oldBenefitList.Count; i++)      //loop through the old list
            {
                newBenefit = null;
                for (int j = 0; j < newBenefitList.Count; j++)
                {
                    if (newBenefitList[j] == null || newBenefitList[j].BenefitNum == 0)
                    {
                        continue;
                    }
                    if (oldBenefitList[i].BenefitNum == newBenefitList[j].BenefitNum)
                    {
                        newBenefit = newBenefitList[j];
                        break;
                    }
                }
                if (newBenefit == null)
                {
                    //benefit with matching benefitNum was not found, so it must have been deleted
                    Delete(oldBenefitList[i]);
                    continue;
                }
                //benefit was found with matching benefitNum, so check for changes
                if (newBenefit.PlanNum != oldBenefitList[i].PlanNum ||
                    newBenefit.PatPlanNum != oldBenefitList[i].PatPlanNum ||
                    newBenefit.CovCatNum != oldBenefitList[i].CovCatNum
                    //|| newBenefit.OldCode != oldBenefitList[i].OldCode
                    || newBenefit.BenefitType != oldBenefitList[i].BenefitType ||
                    newBenefit.Percent != oldBenefitList[i].Percent ||
                    newBenefit.MonetaryAmt != oldBenefitList[i].MonetaryAmt ||
                    newBenefit.TimePeriod != oldBenefitList[i].TimePeriod ||
                    newBenefit.QuantityQualifier != oldBenefitList[i].QuantityQualifier ||
                    newBenefit.Quantity != oldBenefitList[i].Quantity ||
                    newBenefit.CodeNum != oldBenefitList[i].CodeNum ||
                    newBenefit.CoverageLevel != oldBenefitList[i].CoverageLevel)
                {
                    Benefits.Update(newBenefit);
                }
            }
            for (int i = 0; i < newBenefitList.Count; i++)      //loop through the new list
            {
                if (newBenefitList[i] == null)
                {
                    continue;
                }
                if (((Benefit)newBenefitList[i]).BenefitNum != 0)
                {
                    continue;
                }
                //benefit with benefitNum=0, so it's new
                Benefits.Insert((Benefit)newBenefitList[i]);
            }
        }