/// <summary> /// Retrieves the payment plan on record for the specified candidate and election cycle. /// </summary> /// <param name="candidateID">The ID of the candidate whose statement reviews are to be retrieved.</param> /// <param name="electionCycle">The election cycle in which to search.</param> public PaymentPlan GetPaymentPlan(string candidateID, string electionCycle) { using (PaymentPlanTds ds = new PaymentPlanTds()) { using (PaymentPlanTableAdapter ta = new PaymentPlanTableAdapter()) { ta.Fill(ds.PaymentPlan, candidateID, electionCycle); } PaymentPlan plan; foreach (PaymentPlanTds.PaymentPlanRow row in ds.PaymentPlan.Rows) { // payment schedule using (PaymentScheduleTableAdapter ta = new PaymentScheduleTableAdapter()) { ta.Fill(ds.PaymentSchedule, candidateID, electionCycle); } // payment history using (PlanPaymentsTableAdapter ta = new PlanPaymentsTableAdapter()) { ta.Fill(ds.PlanPayments, candidateID, electionCycle); } plan = new PaymentPlan() { // basic plan info FirstPaymentDate = row.FirstPaymentDate, Total = Convert.ToUInt32(row.TotalAmount), PaymentCount = Convert.ToUInt16(row.Installments), Period = CPConvert.ToPaymentPeriod(row.PeriodTypeCode.Trim()), PeriodPaymentAmount = Convert.ToUInt32(row.PeriodPaymentAmount), GracePeriod = Convert.ToByte(row.GracePeriod), // payment schedule Schedule = ParsePaymentSchedule(ds), // payment history History = ParsePlanPaymentHistory(ds) }; // balances plan.ComputeBalances(); // summaries plan.Summarize(); return(plan); } } return(null); }