示例#1
0
        /// <summary>
        /// Called when the Done button is pressed
        /// </summary>
        /// <param name="sender">
        /// autogenerated
        /// </param>
        /// <param name="e">
        /// autogenerated
        /// </param>
        private void CheckValidityButtonClick(object sender, RoutedEventArgs e)
        {
            List <Voter> results       = new List <Voter>();
            Int64        stateId       = -1;
            bool         stateIdParsed = Int64.TryParse(StateId.Text.Trim().TrimEnd(System.Environment.NewLine.ToCharArray()), out stateId);

            if (!StateId.Text.Equals(string.Empty))
            {
                // check state id first
                Voter v = _ui._station.Database.GetVoterByStateId(stateId);
                if (v != null)
                {
                    results.Add(v);
                }
            }
            else if (!DriversLicense.Text.Equals(string.Empty))
            {
                // check driver's license first
                Voter v = _ui._station.Database.GetVoterByDLNumber(DriversLicense.Text);
                if (v != null)
                {
                    results.Add(v);
                }
            }
            else
            {
                results = _ui._station.Database.GetVotersBySearchStrings
                              (LastName.Text, FirstName.Text, MiddleName.Text,
                              Address.Text, Municipality.Text, ZipCode.Text);
            }

            Voter       choice = null;
            VoterStatus vs     = VoterStatus.Unavailable;

            if (results == null || results.Count == 0)
            {
                FlexibleMessageBox.Show(_ui._stationNativeWindow, "No voters match your search. Please try again\nor have the voter register for a provisional ballot.");
            }
            else if (results.Count == 1)
            {
                vs = GetNewVoterStatus(results[0]);
                Window  dialog;
                Boolean result = false;
                _ui._stationWindow.Dispatcher.Invoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new Action(
                        delegate {
                    if (((int)vs != results[0].PollbookStatus) && ((vs == VoterStatus.SuspendedVoter) ||
                                                                   (vs == VoterStatus.MailBallotNotReturned) ||
                                                                   (vs == VoterStatus.OutOfCounty)))
                    {
                        dialog = new ConfirmSingleVoterWithConditionsDialog(results[0], vs);
                    }
                    else
                    {
                        dialog = new ConfirmSingleVoterDialog(results[0]);
                    }
                    dialog.Owner = _ui._stationWindow;
                    result       = (Boolean)dialog.ShowDialog();
                }));
                if (result)
                {
                    choice = results[0];
                }
            }
            else
            {
                ConfirmMultiVoterDialog dialog = null;
                Boolean result = false;

                _ui._stationWindow.Dispatcher.Invoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new Action(
                        delegate {
                    dialog       = new ConfirmMultiVoterDialog(results);
                    dialog.Owner = _ui._stationWindow;
                    result       = (Boolean)dialog.ShowDialog();
                }));

                if (result)
                {
                    choice = dialog.SelectedVoter;
                    vs     = GetNewVoterStatus(choice);
                    Window  dialog2;
                    Boolean result2 = false;

                    _ui._stationWindow.Dispatcher.Invoke(
                        System.Windows.Threading.DispatcherPriority.Normal,
                        new Action(
                            delegate {
                        if (((int)vs != choice.PollbookStatus) && ((vs == VoterStatus.SuspendedVoter) ||
                                                                   (vs == VoterStatus.MailBallotNotReturned) ||
                                                                   (vs == VoterStatus.OutOfCounty)))
                        {
                            dialog2 = new ConfirmSingleVoterWithConditionsDialog(choice, vs);
                        }
                        else
                        {
                            dialog2 = new ConfirmSingleVoterDialog(choice);
                        }
                        dialog2.Owner = _ui._stationWindow;
                        result2       = (Boolean)dialog2.ShowDialog();
                    }));
                    if (!result2)
                    {
                        choice = null;
                        vs     = VoterStatus.Unavailable;
                    }
                }
            }

            if (choice != null)
            {
                WaitingLabel.Content = "Waiting for response from manager...";
                EnableFields(false);
                Waiting = true;
                if (vs == (VoterStatus)choice.PollbookStatus)
                {
                    BallotResponse(choice, false, vs, vs);
                }
                else
                {
                    _ui.RequestStatusChange(choice, vs);
                }
            }
        }