예제 #1
0
        private async void PartyForm_Load(object sender, EventArgs e)
        {
            _currentElection = await _electionService.GetCurrentElectionAsync();

            if (Party == null)
            {
                lblTitle.Text     = "Create Party";
                btnAdd.Text       = "ADD";
                btnDelete.Visible = false;

                var random = new Random();
                _argb = (int)(0xFF000000 + (random.Next(0xFFFFFF) & 0x7F7F7F));

                pbColor.BackColor = Color.FromArgb(_argb);
            }
            else
            {
                lblTitle.Text = "Edit Party";
                btnAdd.Text   = "UPDATE";

                txtName.Text           = Party.Title;
                txtName.SelectionStart = txtName.TextLength;
                txtShortName.Text      = Party.ShortName;
                pbColor.BackColor      = Party.Color;

                _argb = Party.Argb;

                btnDelete.Visible = true;
            }

            Text = lblTitle.Text;
        }
예제 #2
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                grdBallot.Visibility             = Visibility.Hidden;
                btnReset.Visibility              = Visibility.Collapsed;
                btnNext.Visibility               = Visibility.Collapsed;
                bdrLoadingMaintenance.Visibility = Visibility.Visible;

                _currentElection = await _electionService.GetCurrentElectionAsync();

                await SetBallotAsync(_voter);

                grdBallot.Visibility             = Visibility.Visible;
                btnReset.Visibility              = Visibility.Visible;
                btnNext.Visibility               = Visibility.Visible;
                bdrLoadingMaintenance.Visibility = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);

                MessageBox.Show(ex.GetBaseException().Message, "PROGRAM ERROR: " + ex.Source, MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
예제 #3
0
        //private void lblVoterID_Click(object sender, EventArgs e)
        //{
        //    G.WaitLang(this);

        //    var window = new VotersListWindow();
        //    var helper = new WindowInteropHelper(window);
        //    helper.Owner = Handle;

        //    G.EndWait(this);

        //    window.ShowDialog();

        //    G.WaitLang(this);

        //    var voter = window.GetNewData();
        //    G.EndWait(this);

        //    if (voter == null) return;

        //    lblName.Visible = true;
        //    lblStrand.Visible = true;

        //    lblVoterID.Text = voter.VoterID;
        //    lblVoterID.Tag = voter.ID;
        //    lblName.Text = voter.FullName;
        //    lblStrand.Text = voter.GradeStrand;

        //    if (lblName.Width > 255)
        //    {
        //        lblName.Width = 255;
        //        lblName.AutoSize = false;

        //        ttpCandidate.SetToolTip(lblName, voter.FullName);
        //    }
        //    else
        //    {
        //        ttpCandidate.SetToolTip(lblName, null);
        //    }

        //    txtAlias.Text = voter.FirstName;
        //    txtAlias.Focus();
        //    txtAlias.SelectAll();
        //}

        private async void CandidateForm_Load(object sender, EventArgs e)
        {
            _currentElection = await _electionService.GetCurrentElectionAsync();

            dtBirthdate.MaxDate = DateTime.Today;

            if (EditingCandidate == null)
            {
                lblTitle.Text = "Add Candidate";
                btnAdd.Text   = "ADD";

                await LoadPositionsAsync();

                cmbPosition.SelectedIndex = -1;
            }
            else
            {
                var party = await _partyService.GetPartyAsync(EditingCandidate.PartyId);

                SetParty(party);

                lblTitle.Text = "Edit Candidate";

                txtFirstName.Text   = EditingCandidate.FirstName;
                txtMiddleName.Text  = EditingCandidate.MiddleName;
                txtLastName.Text    = EditingCandidate.LastName;
                txtSuffix.Text      = EditingCandidate.Suffix;
                dtBirthdate.Checked = EditingCandidate.Birthdate.HasValue;
                if (dtBirthdate.Checked)
                {
                    dtBirthdate.Value = EditingCandidate.Birthdate.Value;
                }
                cmbSex.SelectedIndex      = (int)EditingCandidate.Sex - 1;
                cmbYearLevel.SelectedItem = EditingCandidate.YearLevel.ToString();
                txtSection.Text           = EditingCandidate.Section;
                txtAlias.Text             = EditingCandidate.Alias;

                pbImage.Image = Properties.Resources.default_candidate;
                if (!string.IsNullOrWhiteSpace(EditingCandidate.PictureFileName))
                {
                    var filePath = Path.Combine(App.ImageFolderPath, EditingCandidate.PictureFileName);
                    if (File.Exists(filePath))
                    {
                        using (var bmpTemp = new Bitmap(filePath))
                        {
                            pbImage.Image = new Bitmap(bmpTemp);
                        }
                    }
                }

                btnAdd.Text = "UPDATE";
            }

            Microsoft.Win32.SystemEvents.DisplaySettingsChanged += (s, ev) =>
            {
                G.PlaceWindowOnCenter(this);
            };

            Text = lblTitle.Text;
        }
예제 #4
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _currentElection = await _electionService.GetCurrentElectionAsync();

            if (Voter == null)
            {
                lblTitle.Content = "Add Voter";

                btnAdd.Content = "ADD";
            }
            else
            {
                lblTitle.Content = "Edit Voter";

                txtVoterID.Text          = Voter.Vin;
                txtLastName.Text         = Voter.LastName;
                txtFirstName.Text        = Voter.FirstName;
                txtMiddleName.Text       = Voter.MiddleName;
                cmbGradeLevel.Text       = Voter.YearLevel.ToString();
                txtStrandSection.Text    = Voter.Section;
                cmbSex.Text              = Voter.Sex.ToString();
                dpBirthdate.SelectedDate = Voter.Birthdate;

                btnAdd.Content = "UPDATE";
            }
        }
        private async void PositionForm_Load(object sender, EventArgs e)
        {
            _currentElection = await _electionService.GetCurrentElectionAsync();

            _window = (Tag as MaintenanceWindow);

            await LoadPositionsAsync();

            nudNumberOfWinners.Value    = Math.Min(2, nudNumberOfWinners.Maximum);
            nudNumberOfWinners.Value    = 1;
            cmbWhoCanVote.SelectedIndex = 0;
        }
예제 #6
0
        private async Task SetCurrentElectionAsync()
        {
            _currentElection = await _electionService.GetCurrentElectionAsync();

            if (_currentElection != null)
            {
                if (_currentElection.ClosedAt.HasValue)
                {
                    grdFinalizeCandidates.Visibility = Visibility.Collapsed;
                    grdVoting.Visibility             = Visibility.Collapsed;
                    grdVoteEnded.Visibility          = Visibility.Visible;
                }
                else
                {
                    if (_currentElection.CandidatesFinalizedAt.HasValue)
                    {
                        grdFinalizeCandidates.Visibility = Visibility.Collapsed;
                        grdVoting.Visibility             = Visibility.Visible;
                        grdVoteEnded.Visibility          = Visibility.Collapsed;
                    }
                    else
                    {
                        grdFinalizeCandidates.Visibility = Visibility.Visible;
                        grdVoting.Visibility             = Visibility.Collapsed;
                        grdVoteEnded.Visibility          = Visibility.Collapsed;
                    }
                }

                this.Title = $"{ _currentElection.Title } • { (string.IsNullOrWhiteSpace(_currentElection.ServerTag) ? "(No tag)" : _currentElection.ServerTag) }";
            }
            else
            {
                this.Title = "Student Election System";

                grdNoElection.Visibility = Visibility.Visible;
            }

            //var fileName = "D:/Videos/New Text Document.txt";
            //FileSecurity fSecurity = File.GetAccessControl(fileName);

            //fSecurity.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.ReadData, AccessControlType.Allow));

            //File.SetAccessControl(fileName, fSecurity);
            //DB.LoadData();
        }
예제 #7
0
        private async void CandidateViewerForm_Load(object sender, EventArgs e)
        {
            _window = (Tag as MaintenanceWindow);

            _currentElection = await _electionService.GetCurrentElectionAsync();

            btnEdit.Visible   = !_currentElection.CandidatesFinalizedAt.HasValue;
            btnDelete.Visible = !_currentElection.CandidatesFinalizedAt.HasValue;

            _candidateParty = (await _candidateService.GetCandidateDetailsListByPartyAsync(CurrentCandidate.PartyId)).ToList();

            _index = _candidateParty.Select(x => x.Id).ToList().IndexOf(CurrentCandidate.Id);

            btnNext.Enabled = _index != _candidateParty.Count - 1;
            btnPrev.Enabled = _index != 0;

            lblCandidatePage.Text = (_index + 1) + " of " + (_candidateParty.Count);

            SetCandidate();
        }
예제 #8
0
        private async Task LoadElectionAsync()
        {
            _currentElection = await _electionService.GetCurrentElectionAsync();

            _canOpenNewElection = _currentElection == null || _currentElection.ClosedAt.HasValue;

            btnEdit.Visible = _currentElection.CandidatesFinalizedAt == null;

            if (_canOpenNewElection)
            {
                btnOpenOrCloseElection.Text = "OPEN NEW ELECTION";
            }
            else
            {
                btnOpenOrCloseElection.Text = "CLOSE ELECTION";
            }

            if (_currentElection != null)
            {
                lblCurrentElectionTitle.Text = _currentElection.Title;
                if (string.IsNullOrEmpty(_currentElection.Description))
                {
                    lblDescription.Text = "(no description)";
                    lblDescription.Font = new Font(lblDescription.Font, FontStyle.Italic);
                }
                else
                {
                    lblDescription.Text = _currentElection.Description;
                    lblDescription.Font = new Font(lblDescription.Font, FontStyle.Regular);
                }

                if (_currentElection.TookPlaceOn > DateTime.Today)
                {
                    lblTookPlaceOnLabel.Text = $"Will be conducted on { _currentElection.TookPlaceOn.ToString("MMMM d, yyyy") }";
                }
                else if (_currentElection.TookPlaceOn < DateTime.Today || _currentElection.ClosedAt.HasValue)
                {
                    lblTookPlaceOnLabel.Text = $"Took place on { _currentElection.TookPlaceOn.ToString("MMMM d, yyyy") }";
                }
                else
                {
                    lblTookPlaceOnLabel.Text = $"Conducting today, { _currentElection.TookPlaceOn.ToString("MMMM d, yyyy") }";
                }
                lblTookPlaceOn.Text = _currentElection.TookPlaceOn.Date.Humanize(dateToCompareAgainst: DateTime.Today);

                if (_currentElection.CandidatesFinalizedAt == null)
                {
                    lblCandidatesFinalizedAt.Text = "(not finalized yet)";
                    lblCandidatesFinalizedAt.Font = new Font(lblCandidatesFinalizedAt.Font, FontStyle.Regular);
                }
                else
                {
                    lblCandidatesFinalizedAt.Text = _currentElection.CandidatesFinalizedAt.Value.ToString("yyyy-MM-dd hh:mm:ss tt");
                    lblCandidatesFinalizedAt.Font = new Font(lblCandidatesFinalizedAt.Font, FontStyle.Bold);
                }

                if (_currentElection.ClosedAt == null)
                {
                    lblClosedAt.Text = "(not closed yet)";
                    lblClosedAt.Font = new Font(lblCandidatesFinalizedAt.Font, FontStyle.Regular);
                }
                else
                {
                    lblClosedAt.Text = _currentElection.ClosedAt.Value.ToString("yyyy-MM-dd hh:mm:ss tt");
                    lblClosedAt.Font = new Font(lblCandidatesFinalizedAt.Font, FontStyle.Bold);
                }
            }
        }
예제 #9
0
        private async void PrintForm_Load(object sender, EventArgs e)
        {
            _currentElection = await _electionService.GetCurrentElectionAsync();

            Print();
        }