Beispiel #1
0
        /// <summary>
        /// Binds the page to data contained in a post election audit report.
        /// </summary>
        /// <param name="report">The report to bind to.</param>
        private void DataBindToReport(AuditReportBase report)
        {
            this.EnsureChildControls();

            // report dates
            _reportSummary.DataSource = report;
            if (report != null)
            {
                _reportSummary.MessagesDataSource = CmoAuditReview.GetAuditReportMessageIDs(CPProfile.Cid, CPProfile.ElectionCycle);

                // inadequate response dates
                report = report.InadequateNotice;
                if (_inadequateSummary.Visible = report != null)
                {
                    _reportSummary.CssClass               = "left column two-up";
                    _inadequateSummary.DataSource         = report;
                    _inadequateSummary.MessagesDataSource = _reportSummary.MessagesDataSource;
                    _inadequateSummary.DataBind();
                }
            }
            _reportSummary.DataBind();

            // force display of title when report is null
            if (report == null)
            {
                _reportSummary.Title = CPConvert.ToString(_postElectionAuditNavigation.SelectedReportType);
            }
        }
        /// <summary>
        /// Controls how data is retrieved and bound to the control.
        /// </summary>
        protected override void PerformSelect()
        {
            if (this.DataSourceID.Length == 0)
            {
                this.OnDataBinding(EventArgs.Empty);
            }
            var ds = this.DataSource;

            if (ds != null)
            {
                _viewState = new TollingEventsListViewState();
                Dictionary <int, string> mds = this.MessagesDataSource == null ? null : this.MessagesDataSource;
                foreach (var t in ds.OrderByDescending(t => t.TollingStartDate))
                {
                    string messageID;
                    _viewState.Events.Add(new TollingEventsListViewState.TollingEventListItem()
                    {
                        Description = t.Description,
                        StartDate   = t.StartDate,
                        EndDate     = t.TollingEndDate,
                        TollingDays = t.GetTollingDays(),
                        Deadline    = t.TollingDueDate,
                        EndReason   = CPConvert.ToString(t.TollingEndReason),
                        MessageID   = mds != null && mds.TryGetValue(t.IsInadequateResponse ? -t.TollingEventNumber : t.TollingEventNumber, out messageID) ? messageID : null
                    });
                }
            }
            this.MarkAsDataBound();
        }
 /// <summary>
 /// Retrieves a generic collection of all pre-election disclosure statements on record for the specified candidate and election cycle.
 /// </summary>
 /// <param name="candidateID">The ID of the candidate whose pre-election disclosure statements are to be retrieved.</param>
 /// <param name="electionCycle">The election cycle in which to search.</param>
 /// <returns>A generic List collection of all pre-election disclosure statements on record for the specified candidate and election cycle.</returns>
 public PreElectionDisclosureHistory GetPreElectionDisclosures(string candidateID, string electionCycle)
 {
     using (PreElectionDisclosureTds ds = new PreElectionDisclosureTds())
     {
         using (PreElectionDisclosuresTableAdapter ta = new PreElectionDisclosuresTableAdapter())
         {
             ta.Fill(ds.PreElectionDisclosures, candidateID, electionCycle);
         }
         PreElectionDisclosureHistory c = new PreElectionDisclosureHistory(ds.PreElectionDisclosures.Count);
         foreach (PreElectionDisclosureTds.PreElectionDisclosuresRow row in ds.PreElectionDisclosures.Rows)
         {
             // parse out the commmittee ID as a char
             char[] idArray = row.CommitteeID.Trim().ToCharArray();
             if (idArray.Length == 0)
             {
                 continue;
             }
             char id = idArray[0];
             //fetch applicable dates and create a new PreElectionDisclosure object as appropriate
             c.Add(new PreElectionDisclosure(row.Number, id, row.LastUpdated, DocumentType.PreGeneralDisclosure == CPConvert.ToDocumentType(row.TypeCode.Trim()))
             {
                 CommitteeName  = row.CommitteeName.Trim(),
                 PageCount      = row.PageCount,
                 StatusReason   = CPConvert.ToDocumentStatusReason(row.ReasonCode.Trim()),
                 Status         = CPConvert.ToDocumentStatus(row.StatusCode.Trim()),
                 DeliveryType   = CPConvert.ToDeliveryType(row.DeliveryCode.Trim()),
                 SubmissionType = CPConvert.ToSubmissionType(row.SubmissionCode.Trim()),
                 ReceivedDate   = row.IsReceivedDateNull() ? null : row.ReceivedDate as DateTime?,
                 StatusDate     = row.IsStatusDateNull() ? null : row.StatusDate as DateTime?,
                 PostmarkDate   = row.IsPostmarkDateNull() ? null : row.PostmarkDate as DateTime?
             });
         }
         return(c);
     }
 }
Beispiel #4
0
 /// <summary>
 /// Retrieves a generic collection of all statements of need on record for the specified candidate and election cycle.
 /// </summary>
 /// <param name="candidateID">The ID of the candidate whose statements of need are to be retrieved.</param>
 /// <param name="electionCycle">The election cycle in which to search.</param>
 /// <returns>A generic List collection of all statements of need on record for the specified candidate and election cycle.</returns>
 public StatementOfNeedHistory GetStatementsOfNeed(string candidateID, string electionCycle)
 {
     using (StatementOfNeedTds ds = new StatementOfNeedTds())
     {
         using (StatementsOfNeedTableAdapter ta = new StatementsOfNeedTableAdapter())
         {
             ta.Fill(ds.StatementsOfNeed, candidateID, electionCycle);
         }
         StatementOfNeedHistory c = new StatementOfNeedHistory(ds.StatementsOfNeed.Count);
         foreach (StatementOfNeedTds.StatementsOfNeedRow row in ds.StatementsOfNeed.Rows)
         {
             c.Add(new StatementOfNeed(row.Number, row.LastUpdated, DocumentType.StatementOfNeedGeneral == CPConvert.ToDocumentType(row.TypeCode.Trim()))
             {
                 PageCount      = row.PageCount,
                 StatusReason   = CPConvert.ToDocumentStatusReason(row.ReasonCode.Trim()),
                 Status         = CPConvert.ToDocumentStatus(row.StatusCode.Trim()),
                 DeliveryType   = CPConvert.ToDeliveryType(row.DeliveryCode.Trim()),
                 SubmissionType = CPConvert.ToSubmissionType(row.SubmissionCode.Trim()),
                 ReceivedDate   = row.IsReceivedDateNull() ? null : row.ReceivedDate as DateTime?,
                 StatusDate     = row.IsStatusDateNull() ? null : row.StatusDate as DateTime?,
                 PostmarkDate   = row.IsPostmarkDateNull() ? null : row.PostmarkDate as DateTime?
             });
         }
         return(c);
     }
 }
        /// <summary>
        /// Gets the submission type of a document as an HTML-formatted tooltip-enabled string.
        /// </summary>
        /// <param name="document">The <see cref="SubmissionDocument"/> to get a tooltip for.</param>
        internal string GetSubmissionTypeText(SubmissionDocument document)
        {
            SubmissionType type     = document.SubmissionType;
            string         cssClass = string.Empty;

            switch (type)
            {
            case SubmissionType.Regular:
                cssClass = this.RegularTooltipCssClass;
                break;

            case SubmissionType.Amendment:
                cssClass = this.AmendmentTooltipCssClass;
                break;

            case SubmissionType.Resubmission:
                cssClass = this.ResubmissionTooltipCssClass;
                break;

            case SubmissionType.InternalAmendment:
                cssClass = this.IAmendmentTooltipCssClass;
                break;

            case SubmissionType.Documentation:
                cssClass = this.DocumentationTooltipCssClass;
                break;
            }
            return(string.Format("{0} {1}", CPConvert.ToString(type), string.Format(Properties.Settings.Default.TooltipFormat, string.Format("{0} {1}", this.TooltipCssClass, cssClass))));
        }
Beispiel #6
0
 /// <summary>
 /// Retrieves a generic collection of all C-SMART/IDS requests on record for the specified candidate and election cycle.
 /// </summary>
 /// <param name="candidateID">The ID of the candidate whose C-SMART/IDS requests are to be retrieved.</param>
 /// <param name="electionCycle">The election cycle in which to search.</param>
 /// <returns>A generic List collection of all C-SMART/IDS requests on record for the specified candidate and election cycle.</returns>
 public CsmartIdsRequestHistory GetCsmartIdsRequests(string candidateID, string electionCycle)
 {
     using (CsmartIdsRequestTds ds = new CsmartIdsRequestTds())
     {
         using (CsmartIdsRequestsTableAdapter ta = new CsmartIdsRequestsTableAdapter())
         {
             ta.Fill(ds.CsmartIdsRequests, candidateID, electionCycle);
         }
         CsmartIdsRequestHistory c = new CsmartIdsRequestHistory(ds.CsmartIdsRequests.Count);
         foreach (CsmartIdsRequestTds.CsmartIdsRequestsRow row in ds.CsmartIdsRequests.Rows)
         {
             c.Documents.Add(new CsmartIdsRequest(row.Number, row.LastUpdated)
             {
                 PageCount      = row.PageCount,
                 StatusReason   = CPConvert.ToDocumentStatusReason(row.ReasonCode.Trim()),
                 Status         = CPConvert.ToDocumentStatus(row.StatusCode.Trim()),
                 DeliveryType   = CPConvert.ToDeliveryType(row.DeliveryCode.Trim()),
                 SubmissionType = CPConvert.ToSubmissionType(row.SubmissionCode.Trim()),
                 ReceivedDate   = row.IsReceivedDateNull() ? null : row.ReceivedDate as DateTime?,
                 StatusDate     = row.IsStatusDateNull() ? null : row.StatusDate as DateTime?,
                 PostmarkDate   = row.IsPostmarkDateNull() ? null : row.PostmarkDate as DateTime?,
             });
         }
         return(c);
     }
 }
Beispiel #7
0
        /// <summary>
        /// Sets the tolling information for a tolling letter CMO message.
        /// </summary>
        /// <param name="message">The CMO message to update.</param>
        /// <returns>true if the tolling information was set or cleared successfully; otherwise, false.</returns>
        /// <remarks>The tolling information can only be successfully set if the message is a tolling letter and cleared if the message is not a tolling letter. The information will automatically be cleared for messages that are not tolling letters regardless of the message's tolling values.</remarks>
        private bool SetCmoMessageTolling(CmoMessage message)
        {
            if (message == null)
            {
                return(false);
            }

            string        candidateID = message.CandidateID;
            int           messageID   = message.ID;
            TollingLetter letter      = message.TollingLetter;

            if (message.IsInadequateResponseLetter)
            {
                // force interpretation of inadequate response letters as tolling letters
                if (letter == null)
                {
                    letter = message.TollingLetter = GetTollingLetter(CPConvert.ToCfisCode(AuditReportType.IdrInadequateResponse), message.IsIdrAdditionalInadequateLetter || message.IsDarAdditionalInadequateLetter ? "ADDINA" : "INARES", "INAD");
                }
                if (!message.TollingEventNumber.HasValue)
                {
                    message.TollingEventNumber = int.MinValue;
                }
            }
            bool hasTolling = message.TollingEventNumber.HasValue && letter != null;
            bool isTolling  = message.IsTollingLetter;

            using (Data.CmoEntities context = new Data.CmoEntities())
            {
                var tl = context.CmoTollingLetters.FirstOrDefault(l => l.CandidateId == message.CandidateID && l.MessageId == message.ID);
                if (tl != null)
                {
                    if (isTolling)
                    {
                        tl.EventNumber = message.TollingEventNumber ?? int.MinValue;
                    }
                    else
                    {
                        context.DeleteObject(tl);
                    }
                }
                else if (isTolling)
                {
                    context.AddToCmoTollingLetters(Data.CmoTollingLetter.CreateCmoTollingLetter(candidateID, messageID, message.TollingEventNumber ?? int.MinValue, letter.ID));
                }
                try
                {
                    int updates = context.SaveChanges();
                    return(isTolling ? updates > 0 : !hasTolling);
                }
                catch (OptimisticConcurrencyException)
                {
                    return(false);
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// Converts the <see cref="CandidateTds.CandidateRow"/> representation of a candidate into its <see cref="Candidate"/> object equivalent.
        /// </summary>
        /// <param name="row">A <see cref="CandidateTds.CandidateRow"/> containing the candidate to convert.</param>
        /// <returns>A <see cref="Candidate"/> equivalent to the candidate represented by <paramref name="row"/>.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="row"/> is a null reference.</exception>
        private Candidate Parse(CandidateTds.CandidateRow row)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row", "Row must be valid and cannot be null.");
            }
            return(new Candidate(row.CandidateID.Trim())
            {
                // basic information
                LastUpdated = row.LastUpdated,
                Honorific = CPConvert.ToHonorific(row.HonorificCode.Trim()),
                LastName = row.LastName.Trim(),
                FirstName = row.FirstName.Trim(),
                MiddleInitial = string.IsNullOrWhiteSpace(row.MiddleInitial) ? null : row.MiddleInitial.Trim().ToCharArray()[0] as char?,
                Address = new PostalAddress()
                {
                    StreetNumber = row.StreetNumber.Trim(),
                    StreetName = row.StreetName.Trim(),
                    Apartment = row.Apartment.Trim(),
                    City = row.City.Trim(),
                    State = row.State.Trim(),
                    Zip = new ZipCode(row.Zip.Trim())
                },
                DaytimePhone = new PhoneNumber(row.DaytimePhone.Trim())
                {
                    Extension = row.DaytimePhoneExt.Trim()
                },
                EveningPhone = new PhoneNumber(row.EveningPhone.Trim())
                {
                    Extension = row.EveningPhoneExt.Trim()
                },
                Fax = new PhoneNumber(row.Fax.Trim()),
                Email = row.Email.Trim(),

                // employer information
                Employer = new Entity()
                {
                    Type = EntityType.Employer,
                    LastName = row.EmployerName.Trim(),
                    Address = new PostalAddress()
                    {
                        StreetNumber = row.EmployerStreetNumber.Trim(),
                        StreetName = row.EmployerStreetName.Trim(),
                        City = row.EmployerCity.Trim(),
                        State = row.EmployerState.Trim(),
                        Zip = new ZipCode(row.EmployerZip.Trim())
                    },
                    DaytimePhone = new PhoneNumber(row.EmployerPhone.Trim())
                    {
                        Extension = row.EmployerPhoneExt.Trim()
                    },
                    Fax = new PhoneNumber(row.EmployerFax.Trim())
                }
            });
        }
Beispiel #9
0
        /// <summary>
        /// Retrieves a collection of post election events that affect tolling for the Draft Audit Report or Final Audit Report.
        /// </summary>
        /// <param name="candidateID">The ID of the candidate whose events are to be retrieved.</param>
        /// <param name="electionCycle">The election cycle in which to search.</param>
        /// <param name="far">true to retrieve events for the Final Audit Report; otherwise, false to retreive events for the Draft Audit Report.</param>
        /// <returns>A collection of tolling events that affect Draft Audit Report tolling.</returns>
        public List <TollingEvent> GetTollingEvents(string candidateID, string electionCycle, bool far)
        {
            DateTime?minStartDate = GetTollingStartDate(electionCycle);

            using (PostElectionTds ds = new PostElectionTds())
            {
                using (TollingEventsTableAdapter ta = new TollingEventsTableAdapter())
                {
                    ta.Fill(ds.TollingEvents, candidateID, electionCycle, far);
                }
                List <TollingEvent> events = new List <TollingEvent>(ds.TollingEvents.Count);
                foreach (PostElectionTds.TollingEventsRow row in ds.TollingEvents)
                {
                    if (row.IsStartDateNull())
                    {
                        continue;
                    }
                    TollingLetter letter = GetTollingLetter(row.SourceCode.Trim(), row.EventCode.Trim(), row.TypeCode.Trim()) ?? new TollingLetter(byte.MinValue)
                    {
                        SourceCode = new TollingCode(TollingCodeType.SourceCode, byte.MinValue)
                        {
                            Code = row.SourceCode.Trim()
                        },
                        EventCode = new TollingCode(TollingCodeType.EventCode, byte.MinValue)
                        {
                            Code = row.EventCode.Trim()
                        },
                        TypeCode = new TollingCode(TollingCodeType.TypeCode, byte.MinValue)
                        {
                            Code = row.TypeCode.Trim()
                        },
                        Description = row.Description,
                        Title       = row.Description
                    };
                    // first fetch end reason to determine end date inclusion in tolling days
                    TollingEndReason reason = CPConvert.ToTollingEndReason(row.EndReasonCode.Trim());
                    events.Add(new TollingEvent(row.StartDate, row.IsEndDateNull() ? DateTime.Now : row.EndDate)
                    {
                        Description          = letter.Description,
                        Title                = letter.Title,
                        TollingEventNumber   = row.EventNumber,
                        TollingLetter        = letter,
                        TollingStartDate     = minStartDate.HasValue && row.StartDate < minStartDate ? minStartDate.Value : row.StartDate,
                        TollingEndDate       = row.IsEndDateNull() ? null : (DateTime?)row.EndDate,
                        TollingDueDate       = row.IsDueDateNull() ? null : (DateTime?)row.DueDate,
                        TollingEndReason     = reason,
                        ReferenceEventNumber = row.RefEventNumber
                    });
                }
                return(events);
            }
        }
 private static DocumentStatusViewModel DocumentStatusFrom <T>(T source) where T : SubmissionDocument
 {
     return(source == null ? new DocumentStatusViewModel() : new DocumentStatusViewModel
     {
         DeliveryType = source.DeliveryType,
         PageCount = source.PageCount,
         PostmarkDate = source.PostmarkDate,
         ReceivedDate = source.ReceivedDate.HasValue ? source.ReceivedDate.Value : DateTime.MinValue,
         Status = CPConvert.ToString(source.Status),
         StatusDate = source.StatusDate,
         SubmissionType = source.SubmissionType
     });
 }
Beispiel #11
0
 /// <summary>
 /// Retrieves all campaign liaisons on record for the specified candidate and committee.
 /// </summary>
 /// <param name="candidateID">The ID of the candidate whose liaisons are to be retrieved.</param>
 /// <param name="committeeID">The ID of the committee whose liaisons are to be retrieved.</param>
 /// <returns>A collection of all campaign liaisons on record for the specified candidate and committee, indexed by liaison ID.</returns>
 public Dictionary <byte, Liaison> GetLiaisons(string candidateID, char committeeID)
 {
     using (AuthorizedCommitteeTds ds = new AuthorizedCommitteeTds())
     {
         using (CampaignLiaisonsTableAdapter ta = new CampaignLiaisonsTableAdapter())
         {
             ta.Fill(ds.CampaignLiaisons, candidateID, committeeID.ToString());
         }
         Dictionary <byte, Liaison> d = new Dictionary <byte, Liaison>(ds.CampaignLiaisons.Count);
         foreach (AuthorizedCommitteeTds.CampaignLiaisonsRow row in ds.CampaignLiaisons.Rows)
         {
             byte id;
             if (byte.TryParse(row.LiaisonID, out id))
             {
                 d.Add(id, new Liaison(id)
                 {
                     Type          = CPConvert.ToLiaisonType(row.LiaisonTypeCode.Trim()) == LiaisonType.Consultant ? EntityType.Consultant : EntityType.Liaison,
                     LiaisonType   = CPConvert.ToLiaisonType(row.LiaisonTypeCode.Trim()),
                     ContactOrder  = CPConvert.ToContactOrder(row.ContactOrderCode),
                     Honorific     = CPConvert.ToHonorific(row.HonorificCode.Trim()),
                     LastName      = row.LastName.Trim(),
                     FirstName     = row.FirstName.Trim(),
                     MiddleInitial = string.IsNullOrWhiteSpace(row.MI) ? null : row.MI.Trim().ToCharArray()[0] as char?,
                     Address       = new PostalAddress()
                     {
                         StreetNumber = row.StreetNumber.Trim(),
                         StreetName   = row.StreetName.Trim(),
                         Apartment    = row.Apartment.Trim(),
                         City         = row.City.Trim(),
                         State        = row.State.Trim(),
                         Zip          = new ZipCode(row.Zip.Trim())
                     },
                     DaytimePhone = new PhoneNumber(row.DaytimePhone.Trim())
                     {
                         Extension = row.DaytimePhoneExt.Trim()
                     },
                     EveningPhone = new PhoneNumber(row.EveningPhone.Trim())
                     {
                         Extension = row.EveningPhoneExt.Trim()
                     },
                     Fax                  = new PhoneNumber(row.Fax.Trim()),
                     Email                = row.Email.Trim(),
                     EntityName           = row.EntityName.Trim(),
                     HasManagerialControl = "Y".Equals(row.HasManagerialControl.Trim(), System.StringComparison.OrdinalIgnoreCase),
                     IsVGLiaison          = "Y".Equals(row.IsVGLiaison.Trim(), System.StringComparison.OrdinalIgnoreCase)
                 });
             }
         }
         return(d);
     }
 }
Beispiel #12
0
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     if (!Page.IsPostBack)
     {
         ActiveCandidate ac = CPProfile.ActiveCandidate;
         if (ac != null)
         {
             // general candidate information
             this.CandidateName.Text = string.Format("{0} (ID: {1})", ac.Name, ac.ID);
             if (ac.Office != null)
             {
                 this.OfficeLabel.Text = ac.Office.ToString();
             }
             this.ClassificationLabel.Text = CPConvert.ToString(ac.Classification);
             Election ec = CPApplication.Elections[CPProfile.ElectionCycle];
             if (ec != null)
             {
                 FinancialSummary fs = FinancialSummary.GetFinancialSummary(CPProfile.Cid, CPProfile.ElectionCycle);
                 if (fs != null)
                 {
                     Statement lastStatement;
                     if (ec.Statements.TryGetValue(fs.LastStatementSubmitted, out lastStatement))
                     {
                         // receipts
                         this.NetContributionsLabel.Text = FormatCurrency(fs.NetContributions);
                     }
                     this.NumberOfContributorsLabel.Text  = string.Format("{0:N0}", fs.ContributorCount);
                     this.MiscellaneousReceiptsLabel.Text = FormatCurrency(fs.MiscellaneousReceipts);
                     this.MatchingClaimsLabel.Text        = FormatCurrency(fs.MatchingClaims);
                     this.LoansReceivedLabel.Text         = FormatCurrency(fs.LoansReceived);
                     // disbursements
                     this.NetExpendituresLabel.Text = FormatCurrency(fs.NetExpenditures);
                     this.LoansPaidLabel.Text       = FormatCurrency(fs.LoansPaid);
                     this.OustandingBillsLabel.Text = FormatCurrency(fs.OutstandingBills);
                     if (!_isTIE)
                     {
                         this.PublicFundsReceivedLabel.Text = FormatCurrency(fs.PublicFundsReceived);
                         this.PublicFundsReturnedLabel.Text = FormatCurrency(fs.PublicFundsReturned);
                     }
                 }
                 if (_isTIE)
                 {
                     FSClassificationCol.Visible = FSClassificationHeader.Visible = FSClassificationCell.Visible = false;
                     ContributorsPanel.CssClass  = null;
                 }
             }
         }
     }
 }
Beispiel #13
0
        /// <summary>
        /// Retrieves the selected extension type.
        /// </summary>
        /// <returns>The currently selected extension type if valid; otherwise, null.</returns>
        /// <exception cref="InvalidOperationException">The selected extension type is invalid.</exception>
        private ExtensionType?GetSelectedExtensionType()
        {
            string value = _types.SelectedValue;

            if (string.IsNullOrEmpty(value))
            {
                return(null);
            }
            if (!Enum.IsDefined(typeof(ExtensionType), value))
            {
                throw new InvalidOperationException("Selected extension type cannot be null.");
            }
            return(CPConvert.ParseEnum <ExtensionType>(value));
        }
Beispiel #14
0
        /// <summary>
        /// Retrieves a collection of the specified candidate's complete threshold status history for the specified election cycle.
        /// </summary>
        /// <param name="candidateID">The ID of the candidate whose Conflict of Interest Board receipts are to be retrieved.</param>
        /// <param name="electionCycle">The election cycle in which to search.</param>
        /// <returns>A collection of the specified candidate's complete threshold status history for the specified election cycle.</returns>
        public ThresholdHistory GetThresholdHistory(string candidateID, string electionCycle)
        {
            Election election = GetElections(CPProviders.SettingsProvider.MinimumElectionCycle)[electionCycle];

            if (election == null || string.IsNullOrEmpty(candidateID))
            {
                return(null);
            }
            using (ThresholdTds ds = new ThresholdTds())
            {
                using (ThresholdTableAdapter ta = new ThresholdTableAdapter())
                {
                    ta.Fill(ds.Threshold, candidateID, election.Cycle);
                }
                var statements           = this.GetStatements(election.Cycle);
                ThresholdHistory history = new ThresholdHistory();
                ThresholdStatus  status;
                foreach (ThresholdTds.ThresholdRow row in ds.Threshold.Rows)
                {
                    try
                    {
                        Statement statement;
                        if (!statements.TryGetValue((byte)row.Statement, out statement))
                        {
                            continue;
                        }
                        // if a new statement is being added, create a new status statement group
                        if (!history.History.TryGetValue(statement.Number, out status))
                        {
                            status = new ThresholdStatus(statement.Number);
                            history.History.Add(statement.Number, status);
                        }
                        NycBorough borough = CPConvert.ToNycBorough(row.BoroughCode.Trim());
                        status.Add(new ThresholdRevision(statement, CPConvert.ToThresholdRevisionType(row.Type.Trim()))
                        {
                            Date           = row.Date,
                            Number         = (ushort)row.Number,
                            NumberRequired = (ushort)row.NumberRequired,
                            Funds          = row.Funds,
                            FundsRequired  = row.FundsRequired,
                            Office         = (borough != NycBorough.Unknown) ? new NycPublicOffice(borough) : new NycPublicOffice(CPConvert.ToNycPublicOfficeType(row.OfficeCode.Trim()))
                        });
                    }
                    catch (InvalidCastException)
                    {
                    }
                }
                return(history);
            }
        }
 /// <summary>
 /// Raises the <see cref="GridView.RowDataBound"/> event.
 /// </summary>
 /// <param name="e">A <see cref="GridViewRowEventArgs"/> that contains event data.</param>
 protected override void OnRowDataBound(GridViewRowEventArgs e)
 {
     base.OnRowDataBound(e);
     // additional databinding because data values are not accessible until databinding events
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         SubmissionDocument document = e.Row.DataItem as SubmissionDocument;
         if (document != null)
         {
             // skip a column when grouping (first column is group-by column)
             e.Row.Cells[this.AllowGrouping ? 2 : 1].Text = GetSubmissionTypeText(document);
             // BUGFIX #58: Corrected typo in group condition detection when populating delivery type column
             e.Row.Cells[this.AllowGrouping ? 6 : 5].Text = CPConvert.ToString(document.DeliveryType);
         }
     }
 }
Beispiel #16
0
 /// <summary>
 /// Renders a single threshold revision to the specified writer.
 /// </summary>
 /// <param name="writer">A <see cref="HtmlTextWriter"/> that represents the output stream to render HTML content on the client.</param>
 /// <param name="entry">The threshold revision entry to render.</param>
 /// <param name="current">Whether or not the entry being rendered is the most current revision.</param>
 private void RenderThreshold(HtmlTextWriter writer, ThresholdRevision entry, bool current)
 {
     if (writer == null || entry == null)
     {
         return;
     }
     writer.RenderBeginTag(HtmlTextWriterTag.Tr);
     new TableCell()
     {
         CssClass = "expander"
     }.RenderControl(writer);
     new TableCell()
     {
         CssClass = "statementNumber", Text = current ? entry.Statement.ToDetailString() : null
     }.RenderControl(writer);
     new TableCell()
     {
         CssClass = "numActual", Text = entry.IsUndetermined ? "(n/a)" : entry.Number.ToString("N0")
     }.RenderControl(writer);
     new TableCell()
     {
         CssClass = "numRequired", Text = entry.IsUndetermined ? "(n/a)" : entry.NumberRequired.ToString("N0")
     }.RenderControl(writer);
     new TableCell()
     {
         CssClass = "amtActual", Text = entry.Funds.ToString("C")
     }.RenderControl(writer);
     new TableCell()
     {
         CssClass = "amtRequired", Text = entry.IsUndetermined ? "(n/a)" : entry.FundsRequired.ToString("C")
     }.RenderControl(writer);
     new TableCell()
     {
         CssClass = "version", Text = CPConvert.ToString(entry.Type)
     }.RenderControl(writer);
     new TableCell()
     {
         CssClass = "office", Text = entry.Office.ToAbbrevString()
     }.RenderControl(writer);
     new TableCell()
     {
         CssClass = "date", Text = entry.Date.ToString("d")
     }.RenderControl(writer);
     writer.RenderEndTag();
 }
Beispiel #17
0
 /// <summary>
 /// Parses and sets properties from values in a query string.
 /// </summary>
 /// <param name="queryString">The query string to parse.</param>
 public void ParseQueryString(NameValueCollection queryString)
 {
     if (queryString != null)
     {
         string view = queryString[ViewParameter];
         try
         {
             this.View = CPConvert.ParseEnum <CmoMailboxView>(queryString[ViewParameter]);
         }
         catch { }
         try
         {
             this.SortType = CPConvert.ParseEnum <CmoMailboxSortType>(queryString[SortByParameter]);
         }
         catch { }
         this.SortDescending = !AscendingSortValue.Equals(queryString[SortDirectionParameter], StringComparison.InvariantCultureIgnoreCase);
     }
 }
 private static AddressViewModel AddressFrom(PostalAddress address, bool aptFlag = true)
 {
     if (address == null)
     {
         address = new PostalAddress();
     }
     return(new AddressViewModel
     {
         StreetNumber = address.StreetNumber,
         StreetName = address.StreetName,
         Apartment = address.Apartment,
         City = address.City,
         StateCode = address.State,
         State = CPConvert.ParseStateCode(address.State),
         Zip = address.Zip != null?address.Zip.ToString() : null,
                   HasApartment = aptFlag
     });
 }
Beispiel #19
0
 /// <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);
 }
 private static DisclosureStatementViewModel DisclosureStatementFrom(DisclosureStatement source)
 {
     return(source == null ? new DisclosureStatementViewModel() : new DisclosureStatementViewModel
     {
         DeliveryType = source.DeliveryType,
         PageCount = source.PageCount,
         PostmarkDate = source.PostmarkDate,
         ReceivedDate = source.ReceivedDate.HasValue ? source.ReceivedDate.Value : DateTime.MinValue,
         Status = CPConvert.ToString(source.Status),
         StatusDate = source.StatusDate,
         SubmissionType = source.SubmissionType,
         IsSmallCampaign = source.SmallCampaign,
         Deferred = source.DeferredFiling,
         BackupDeliveryType = source.BackupDeliveryType,
         BackupPostmarkDate = source.BackupPostmarkDate,
         BackupReceivedDate = source.BackupReceivedDate,
         DataFormat = GetDataFormat(source)
     });
 }
Beispiel #21
0
 /// <summary>
 /// Retrieves Post Election Audit suspension information for a specfic candidate and election cycle.
 /// </summary>
 /// <param name="candidateID">The ID of the candidate whose suspension information is to be retrieved.</param>
 /// <param name="electionCycle">The election cycle in which to search.</param>
 /// <returns>Suspension information matching the specified criteria if found; otherwise, null.</returns>
 public Suspension GetSuspension(string candidateID, string electionCycle)
 {
     using (PostElectionTds ds = new PostElectionTds())
     {
         using (SuspensionTableAdapter ta = new SuspensionTableAdapter())
         {
             ta.Fill(ds.Suspension, candidateID, electionCycle);
         }
         foreach (PostElectionTds.SuspensionRow row in ds.Suspension)
         {
             return(row.IsSuspensionDateNull() ? null : new Suspension(row.SuspensionDate)
             {
                 SuspenderName = row.IsSuspenderNameNull() ? null : row.SuspenderName.Trim(),
                 SuspensionReason = CPConvert.ToSuspensionReason(row.SuspensionReasonCode.Trim())
             });
         }
     }
     return(null);
 }
Beispiel #22
0
        /// <summary>
        /// Retrieves a history of public funds determinations for a specific candidate and election cycle.
        /// </summary>
        /// <param name="candidateID">The ID of the candidate whose public funds determination history is to be retrieved.</param>
        /// <param name="electionCycle">The election cycle in which to search.</param>
        /// <returns>A history of public funds determinations for the specified candidate and election cycle.</returns>
        public PublicFundsHistory GetPublicFundsHistory(string candidateID, string electionCycle)
        {
            // retrieve CMO message IDs
            using (Data.CmoEntities context = new Data.CmoEntities())
            {
                var messages = from m in context.CmoMessages
                               join p in context.CmoAuditReviews
                               on new { m.CandidateId, m.MessageId } equals new { p.CandidateId, p.MessageId }
                where m.CandidateId == candidateID && m.ElectionCycle == electionCycle && m.PostDate.HasValue
                group p by p.ReviewNumber into pgroup
                select new { Run = pgroup.Key, MessageID = pgroup.Max(p => p.MessageId) };

                // retrieve payment records
                using (PaymentPlanTds ds = new PaymentPlanTds())
                {
                    PaymentPlanTds.PublicFundsHistoryDataTable table = ds.PublicFundsHistory;
                    using (PublicFundsHistoryTableAdapter ta = new PublicFundsHistoryTableAdapter())
                    {
                        ta.Fill(table, candidateID, electionCycle);
                    }
                    PublicFundsHistory history = new PublicFundsHistory(table.Count);
                    foreach (PaymentPlanTds.PublicFundsHistoryRow row in table)
                    {
                        PublicFundsDetermination payment = new PublicFundsDetermination(row.Date, row.Amount > 0)
                        {
                            ElectionType  = CPConvert.ToElectionType(row.ElectionTypeCode.Trim()),
                            PaymentAmount = row.Amount,
                            PaymentMethod = string.IsNullOrEmpty(row.CheckNumber.Trim()) ? PaymentMethod.Eft : PaymentMethod.Check,
                            Run           = row.Run
                        };
                        // associate message ID if found
                        var message = messages.FirstOrDefault(m => m.Run == row.Run);
                        if (message != null)
                        {
                            payment.MessageID = message.MessageID;
                        }
                        history.Determinations.Add(payment);
                    }
                    return(history);
                }
            }
        }
Beispiel #23
0
        /// <summary>
        /// Parses a typed data set of plan payments into a <see cref="PlanPaymentHistory"/> collection.
        /// </summary>
        /// <param name="ds">The typed data set to parse.</param>
        /// <returns>A collection representing the data contained in the data set.</returns>
        private PlanPaymentHistory ParsePlanPaymentHistory(PaymentPlanTds ds)
        {
            PlanPaymentHistory history = new PlanPaymentHistory(ds.PlanPayments.Count);

            foreach (PaymentPlanTds.PlanPaymentsRow row in ds.PlanPayments.Rows)
            {
                ushort checkNumber;
                if (ushort.TryParse(row.CheckNumber, out checkNumber))
                {
                    history.Add(new PlanPayment()
                    {
                        Amount      = Convert.ToUInt32(row.Amount),
                        CheckNumber = checkNumber,
                        Date        = row.Date,
                        Type        = CPConvert.ToPaymentType(row.TransactionCode.Trim())
                    });
                }
            }
            return(history);
        }
 public static BankAccountViewModel BankAccountFrom(BankAccount source, char committeeID)
 {
     return(source == null ? new BankAccountViewModel() : new BankAccountViewModel
     {
         CommitteeID = committeeID,
         ID = source.ID,
         BankName = source.BankName,
         City = source.City,
         State = CPConvert.ParseStateCode(source.State),
         StateCode = source.State,
         Zip = source.Zip == null ? null : source.Zip.ToString(),
         AccountNumber = source.Number,
         FriendlyName = source.Name,
         OpenedDate = source.OpeningDate,
         ClosedDate = source.ClosingDate,
         Balance = source.CurrentBalance,
         BalanceDate = source.CurrentBalanceDate,
         Type = source.Type == BankAccountType.Other ? source.OtherTypeSpecification : CPConvert.ToString(source.Type),
         Purpose = source.Purpose == BankAccountPurpose.Other ? source.OtherPurposeSpecification : CPConvert.ToString(source.Purpose),
         DirectDeposit = source.HasDirectDeposit
     });
 }
Beispiel #25
0
 /// <summary>
 /// Retrieves all bank accounts on record for the specified candidate, election cycle, and committee.
 /// </summary>
 /// <param name="candidateID">The ID of the candidate whose bank accounts are to be retrieved.</param>
 /// <param name="electionCycle">The election cycle in which to search.</param>
 /// <param name="committeeID">The ID of the committee whose bank accounts are to be retrieved.</param>
 /// <returns>A collection of all bank accounts on record for the specified candidate, election cycle, and committee, indexed by account ID.</returns>
 public Dictionary <byte, BankAccount> GetBankAccounts(string candidateID, string electionCycle, char committeeID)
 {
     using (AuthorizedCommitteeTds ds = new AuthorizedCommitteeTds())
     {
         using (BankAccountsTableAdapter ta = new BankAccountsTableAdapter())
         {
             ta.Fill(ds.BankAccounts, candidateID, electionCycle, committeeID.ToString());
         }
         Dictionary <byte, BankAccount> d = new Dictionary <byte, BankAccount>(ds.BankAccounts.Count);
         foreach (AuthorizedCommitteeTds.BankAccountsRow row in ds.BankAccounts.Rows)
         {
             byte id;
             if (byte.TryParse(row.BankAccountID, out id))
             {
                 d.Add(id, new BankAccount(id)
                 {
                     BankName                  = row.BankName.Trim(),
                     City                      = row.City.Trim(),
                     State                     = row.State.Trim(),
                     Zip                       = new ZipCode(row.Zip.Trim()),
                     Number                    = row.Number.Trim(),
                     Name                      = row.Name.Trim(),
                     OpeningDate               = row.IsOpeningDateNull() ? null : row.OpeningDate as DateTime?,
                     ClosingDate               = row.IsClosingDateNull() ? null : row.ClosingDate as DateTime?,
                     CurrentBalanceDate        = row.IsCurrentBalanceDateNull() ? null : row.CurrentBalanceDate as DateTime?,
                     CurrentBalance            = row.CurrentBalance,
                     Type                      = CPConvert.ToBankAccountType(row.AccountTypeCode.Trim()),
                     OtherTypeSpecification    = row.AccountTypeOther.Trim(),
                     Purpose                   = CPConvert.ToBankAccountPurpose(row.PurposeCode.Trim()),
                     OtherPurposeSpecification = row.PurposeOther.Trim()
                 });
             }
         }
         return(d);
     }
 }
Beispiel #26
0
        /// <summary>
        /// Raises the <see cref="Control.Init"/> event.
        /// </summary>
        /// <param name="e">An <see cref="EventArgs"/> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // check if a view is defined
            string viewName = Page.Request.QueryString[CmoMailbox.ViewParameter];

            _view = !string.IsNullOrEmpty(viewName) && Enum.IsDefined(typeof(CmoMailboxView), viewName) ? CPConvert.ParseEnum <CmoMailboxView>(viewName) : CmoMailbox.DefaultView;
        }
Beispiel #27
0
        /// <summary>
        /// Converts the <see cref="ActiveCandidateTds.ActiveCandidateRow"/> representation of an active candidate into its <see cref="ActiveCandidate"/> object equivalent.
        /// </summary>
        /// <param name="row">A <see cref="ActiveCandidateTds.ActiveCandidateRow"/> containing the active candidate to convert.</param>
        /// <returns>An <see cref="ActiveCandidate"/> equivalent to the active candidate represented by <paramref name="row"/>.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="row"/> is a null reference.</exception>
        private static ActiveCandidate Parse(ActiveCandidateTds.ActiveCandidateRow row)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row", "Row must be valid and cannot be null.");
            }
            char committeeID;

            return(new ActiveCandidate(row.CandidateID.Trim(), row.ElectionCycle.Trim())
            {
                // basic information
                LastUpdated = row.LastUpdated,
                Honorific = CPConvert.ToHonorific(row.HonorificCode.Trim()),
                LastName = row.LastName.Trim(),
                FirstName = row.FirstName.Trim(),
                MiddleInitial = string.IsNullOrWhiteSpace(row.MiddleInitial) ? null : row.MiddleInitial.Trim().ToCharArray()[0] as char?,
                Address = new PostalAddress()
                {
                    StreetNumber = row.StreetNumber.Trim(),
                    StreetName = row.StreetName.Trim(),
                    Apartment = row.Apartment.Trim(),
                    City = row.City.Trim(),
                    State = row.State.Trim(),
                    Zip = new ZipCode(row.Zip.Trim())
                },
                DaytimePhone = new PhoneNumber(row.DaytimePhone.Trim())
                {
                    Extension = row.DaytimePhoneExt.Trim()
                },
                EveningPhone = new PhoneNumber(row.EveningPhone.Trim())
                {
                    Extension = row.EveningPhoneExt.Trim()
                },
                Fax = new PhoneNumber(row.Fax.Trim()),
                Email = row.Email.Trim(),

                // employer information
                Employer = new Entity()
                {
                    Type = EntityType.Employer,
                    LastName = row.EmployerName.Trim(),
                    Address = new PostalAddress()
                    {
                        StreetNumber = row.EmployerStreetNumber.Trim(),
                        StreetName = row.EmployerStreetName.Trim(),
                        City = row.EmployerCity.Trim(),
                        State = row.EmployerState.Trim(),
                        Zip = new ZipCode(row.EmployerZip.Trim())
                    },
                    DaytimePhone = new PhoneNumber(row.EmployerPhone.Trim())
                    {
                        Extension = row.EmployerPhoneExt.Trim()
                    },
                    Fax = new PhoneNumber(row.EmployerFax.Trim())
                },

                // activation information
                Office = new NycPublicOffice(CPConvert.ToNycPublicOfficeType(row.OfficeCode.Trim()))
                {
                    Borough = CPConvert.ToNycBorough(row.BoroughCode.Trim()),
                    District = string.IsNullOrEmpty(row.DistrictCode.Trim()) ? byte.MinValue : Convert.ToByte(row.DistrictCode.Trim())
                },
                CertificationDate = row.IsCertificationDateNull() ? null : row.CertificationDate as DateTime?,
                FilerRegistrationDate = row.IsFilerRegistrationDateNull() ? null : row.FilerRegistrationDate as DateTime?,
                TerminationDate = row.IsTerminationDateNull() ? null : row.TerminationDate as DateTime?,
                TerminationReason = CPConvert.ToTerminationReason(row.TerminationReasonCode),
                Classification = CPConvert.ToCfbClassification(row.ClassificationCode.Trim()),
                PoliticalParty = (row.IsPoliticalPartyNull()) ? string.Empty : row.PoliticalParty.Trim(),
                IsDirectDepositAuthorized = "Y".Equals(row.HasDirectDeposit, StringComparison.InvariantCultureIgnoreCase),
                IsRRDirectDepositAuthorized = "Y".Equals(row.HasRRDirectDeposit, StringComparison.InvariantCultureIgnoreCase),
                AuditorName = row.IsAuditorNameNull() ? null : row.AuditorName.Trim(),
                CsuLiaisonName = row.IsCsuLiaisonNameNull() ? null : row.CsuLiaisonName.Trim(),

                // principal committee info
                PrincipalCommittee = row.IsPrincipalCommitteeNull() ? null : row.PrincipalCommittee.Trim(),
                PrincipalCommitteeID = !row.IsPrincipalCommitteeIDNull() && char.TryParse(row.PrincipalCommitteeID.Trim(), out committeeID) ? committeeID as char? : null
            });
        }
Beispiel #28
0
 /// <summary>
 /// Attempts to submit the current extension request.
 /// </summary>
 /// <returns>true if the extension request was successfully submitted; otherwise, false.</returns>
 private bool SubmitExtensionRequest()
 {
     try
     {
         byte     number;
         DateTime dueDate;
         DateTime requestedDate;
         if (TryParseReviewNumberListItemValue(_numberDropDown.SelectedValue, out number, out dueDate) && DateTime.TryParse(_dueDateDropDown.SelectedValue, out requestedDate))
         {
             Extension req = Extension.Add(CPProfile.Cid, _electionCycle.Text, CPConvert.ParseEnum <ExtensionType>(_types.SelectedValue), number, DateTime.Now, requestedDate, _reason.Text);
             if (req != null)
             {
                 // send e-mail notification
                 CPMailMessage message = new CPMailMessage();
                 message.Sender = CPProfile.GetMailAddress();
                 message.To.Add(CPApplication.AuditExtensionRequestsEmail);
                 message.IsBodyHtml = true;
                 message.Subject    = string.Format("Request for Extension to EC{0} {1} {2}", req.ElectionCycle, _typesValue.Text, req.ReviewNumber);
                 message.Body       = string.Format(EmailBodyFormat,
                                                    Cfis.GetCandidateName(CPProfile.Cid, true),
                                                    CPProfile.Cid,
                                                    message.Sender.DisplayName,
                                                    User.Identity.Name,
                                                    req.ElectionCycle,
                                                    _typesValue.Text,
                                                    _numberLabelText.Text,
                                                    _numberValue.Text,
                                                    _dueDateValue.Text);
                 message.Send();
                 return(true);
             }
         }
     }
     catch
     {
     }
     return(false);
 }
Beispiel #29
0
        /// <summary>
        /// Updates control fields with an active candidate's profile information.
        /// </summary>
        /// <param name="ac">The active candidate profile to display.</param>
        private void ShowCandidate(ActiveCandidate ac)
        {
            if (ac == null)
            {
                _errorMessage.Text    = string.Format("You do not currently have an active candidate profile for the {0} election.", CPProfile.ElectionCycle);
                _errorMessage.Visible = true;
                _details.Visible      = false;
            }
            else
            {
                PostalAddress address;

                // basic candidate info
                _ID.Value         = ac.ID;
                _salutation.Value = CPConvert.ToString(ac.Honorific);
                _lastName.Value   = ac.LastName;
                _firstName.Value  = ac.FirstName;
                _mi.Value         = ac.MiddleInitial.HasValue ? ac.MiddleInitial.Value.ToString() : null;
                address           = ac.Address;
                if (!object.Equals(address, null))
                {
                    _streetNumber.Value = address.StreetNumber;
                    _streetName.Value   = address.StreetName;
                    _apartment.Value    = address.Apartment;
                    _city.Value         = address.City;
                    _state.Value        = CPConvert.ParseStateCode(address.State);
                    if (!object.Equals(address.Zip, null))
                    {
                        _zip.Value = address.Zip.ToString();
                    }
                }
                if (!object.Equals(ac.DaytimePhone, null))
                {
                    _daytimePhone.Value = ac.DaytimePhone.ToString();
                }
                if (!object.Equals(ac.EveningPhone, null))
                {
                    _eveningPhone.Value = ac.EveningPhone.ToString();
                }
                if (!object.Equals(ac.Fax, null))
                {
                    _fax.Value = ac.Fax.ToString();
                }
                if (!string.IsNullOrEmpty(ac.Email))
                {
                    _email.Value = string.Format("<a href=\"mailto:{0}\">{0}</a>", ac.Email);
                }

                // employer info
                Entity employer = ac.Employer;
                if (!object.Equals(employer, null))
                {
                    _empName.Value = employer.Name;
                    address        = employer.Address;
                    if (!object.Equals(address, null))
                    {
                        _empStreetNumber.Value = address.StreetNumber;
                        _empStreetName.Value   = address.StreetName;
                        _empCity.Value         = address.City;
                        _empState.Value        = CPConvert.ParseStateCode(address.State);
                        if (!object.Equals(address.Zip, null))
                        {
                            _empZip.Value = address.Zip.ToString();
                        }
                    }
                    if (!object.Equals(employer.DaytimePhone, null))
                    {
                        _empPhone.Value = employer.DaytimePhone.ToString();
                    }
                    if (!object.Equals(employer.Fax, null))
                    {
                        _empFax.Value = employer.Fax.ToString();
                    }
                }

                // candidate activation info
                if (ac.FilerRegistrationDate.HasValue)
                {
                    _frDate.Value = ac.FilerRegistrationDate.Value.ToDateString();
                }
                else
                {
                    _frDate.Value = "(n/a)";
                }
                _party.Value = ac.PoliticalParty;
                if (_isTIE)
                {
                    _office.Visible = _certDate.Visible = _terminationDate.Visible = _boroDistrict.Visible = _classification.Visible = _ddAuth.Visible = _rrddAuth.Visible = false;
                }
                else
                {
                    _office.Value = CPConvert.ToString(ac.Office.Type);
                    if (ac.CertificationDate.HasValue)
                    {
                        _certDate.Value = ac.CertificationDate.Value.ToDateString();
                    }
                    else
                    {
                        _certDate.Value = "(n/a)";
                    }
                    if (ac.IsTerminated)
                    {
                        _terminationDate.Value   = ac.TerminationDate.Value.ToDateString();
                        _terminationDate.Visible = true;
                    }
                    if (_boroDistrict.Visible = (ac.Office.Type == NycPublicOfficeType.BoroughPresident) || (ac.Office.Type == NycPublicOfficeType.CityCouncilMember))
                    {
                        NycBorough borough;
                        byte       district;
                        if (ac.Office.TryGetBorough(out borough))
                        {
                            _boroDistrict.LabelText = "Borough";
                            _boroDistrict.Value     = CPConvert.ToString(borough);
                        }
                        else if (ac.Office.TryGetDistrict(out district))
                        {
                            _boroDistrict.LabelText = "District";
                            _boroDistrict.Value     = district.ToString();
                        }
                    }
                    _classification.Value = CPConvert.ToString(ac.Classification);
                    _ddAuth.Value         = ac.IsDirectDepositAuthorized ? "Yes" : "No";
                    if (_rrddAuth.Visible = HasRRAccounts(ac))
                    {
                        _rrddAuth.Value = ac.IsRRDirectDepositAuthorized ? "Yes" : "No";
                    }
                }
                _lastUpdated.Text = "Data last modified: " + ac.LastUpdated.ToDateString();
            }
        }
Beispiel #30
0
        /// <overview>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </overview>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            _plan = PaymentPlan.GetPaymentPlan(CPProfile.Cid, CPProfile.ElectionCycle);
            if (_plan == null)
            {
                return;
            }
            CultureInfo        enCulture = CultureInfo.CreateSpecificCulture("en-US");
            Table              table;
            bool               altColor;
            PaymentInstallment current = _plan.Schedule.Current;

            // overview
            // overview: next payment
            Panel overview = MakeSectionPanel(Properties.Resources.OverviewTitle);

            overview.CssClass += " cp-PaymentPlanOverviewPanel";
            table              = MakeSectionTable();
            table.CssClass    += " cp-leftcolumn";
            overview.Controls.Add(table);
            table.Rows.Add(MakeLabeledDataRow(
                               "Next due date",
                               (current == null) ? "(n/a)" : current.DueDate.ToString(Properties.Resources.DateFormat)
                               ));
            table.Rows.Add(MakeLabeledDataRow(
                               "Payment amount:",
                               (current == null) ? "(n/a)" : current.AmountDue.ToString("C", enCulture)
                               ));
            // overview: plan dates
            table           = MakeSectionTable();
            table.CssClass += " cp-leftcolumn";
            overview.Controls.Add(table);
            table.Rows.Add(MakeLabeledDataRow(
                               "Initial payment:",
                               _plan.FirstPaymentDate.ToString(Properties.Resources.DateFormat)
                               ));
            table.Rows.Add(MakeLabeledDataRow(
                               "Final payment:",
                               _plan.FinalPaymentDueDate.ToString(Properties.Resources.DateFormat)
                               ));
            // overview: totals
            table = MakeSectionTable();
            overview.Controls.Add(table);
            table.Rows.Add(MakeLabeledDataRow(
                               "Total amount:",
                               _plan.Total.ToString("C", enCulture)
                               ));
            table.Rows.Add(MakeLabeledDataRow(
                               "Amount outstanding:",
                               _plan.GetBalance().ToString("C", enCulture)
                               ));
            if (_plan.PastDueBalance > 0)
            {
                table.Rows.Add(MakeLabeledDataRow("Balance past due:", _plan.PastDueBalance.ToString("C", enCulture)));
            }

            // schedule
            Panel schedule = MakeSectionPanel(Properties.Resources.ScheduleTitle);

            schedule.CssClass += " cp-PaymentPlanSchedulePanel";
            table              = MakeSectionTable();
            schedule.Controls.Add(table);
            table.Rows.Add(MakeHeaderRow("Payment Schedule", "Start Date", "End Date"));
            foreach (PaymentPlanSummary summary in _plan.Summaries)
            {
                table.Rows.Add(MakeDataRow(
                                   string.Format("{0} {1} {2} of {3}", summary.PaymentCount, CPConvert.ToString(_plan.Period),
                                                 (summary.PaymentCount > 0) ? "payments" : "payment",
                                                 summary.PeriodPaymentAmount.ToString("C", enCulture)), summary.FirstPaymentDate.ToString(Properties.Resources.DateFormat), summary.FinalPaymentDueDate.ToString(Properties.Resources.DateFormat)
                                   ));
            }

            // balances
            Panel balances = MakeSectionPanel(Properties.Resources.BalancesTitle);

            balances.CssClass += " cp-PaymentPlanBalancesPanel";
            table              = MakeSectionTable();
            balances.Controls.Add(table);
            table.Rows.Add(MakeHeaderRow("Payment #", "Due Date", "Amount Due", "Amount Paid"));
            altColor = false;
            foreach (PaymentInstallment installment in _plan.Installments)
            {
                uint?amountPaid = installment.AmountPaid;
                table.Rows.Add(MakeDataRow(altColor,
                                           installment.Number.ToString(),
                                           installment.DueDate.ToString(Properties.Resources.DateFormat),
                                           installment.AmountDue.ToString("C", enCulture),
                                           (amountPaid == null) ? "--" : ((uint)amountPaid).ToString("C", enCulture)
                                           ));
            }

            // history
            Panel history = MakeSectionPanel(Properties.Resources.HistoryTitle);

            history.CssClass += " cp-PaymentPlanHistoryPanel";
            table             = MakeSectionTable();
            history.Controls.Add(table);
            table.Rows.Add(MakeHeaderRow("Date", "Amount"));
            altColor = false;
            foreach (PlanPayment payment in _plan.Payments)
            {
                table.Rows.Add(MakeDataRow(altColor,
                                           payment.Date.ToString(Properties.Resources.DateFormat),
                                           payment.Amount.ToString("C", enCulture)
                                           ));
                altColor = !altColor;
            }

            _container          = new Panel();
            _container.CssClass = "PaymentPlanWebPart";
            _container.Controls.Add(overview);
            _container.Controls.Add(schedule);
            balances.CssClass += " cp-leftcolumn";
            _container.Controls.Add(balances);
            _container.Controls.Add(history);
            this.Controls.Add(_container);
        }