From f70c4c0c2b6fcac4b94a644d1576b6b04cd47cb4 Mon Sep 17 00:00:00 2001 From: Lenard Mangay-ayam Date: Fri, 18 Dec 2020 04:43:44 +0800 Subject: [PATCH] Add Features and Bug Fixes # AdminHomeStarted # - Add Refresh Button # - Data will only be refresh when the refresh button has been clicked # # ManageParty # - Hide Buttons When the election already started # # Position # - Bug fixes, NullPointerException # # Votes # - Add GetAllVotes Function # # VoteCount # - Features added to VotersPanel # Signed-off-by: Lenard Mangay-ayam --- .../AdminHomeStarted.Designer.vb | 75 ++--- .../AdminController/AdminHomeStarted.vb | 56 ++-- .../AdminController/ManageParty.Designer.vb | 214 ++++++------ .../AdminController/ManageParty.vb | 13 +- Voting-SystemVB/Model/Position.vb | 2 +- Voting-SystemVB/Model/Votes.vb | 7 + .../VoterController/VoteCount.Designer.vb | 315 ++++++++++++++++++ .../VoterController/VoteCount.resx | 120 +++++++ Voting-SystemVB/VoterController/VoteCount.vb | 67 ++++ Voting-SystemVB/VotersPanel.Designer.vb | 40 +-- Voting-SystemVB/VotersPanel.vb | 4 +- Voting-SystemVB/Voting-SystemVB.vbproj | 9 + 12 files changed, 729 insertions(+), 193 deletions(-) create mode 100644 Voting-SystemVB/VoterController/VoteCount.Designer.vb create mode 100644 Voting-SystemVB/VoterController/VoteCount.resx create mode 100644 Voting-SystemVB/VoterController/VoteCount.vb diff --git a/Voting-SystemVB/AdminController/AdminHomeStarted.Designer.vb b/Voting-SystemVB/AdminController/AdminHomeStarted.Designer.vb index e3e5b6d..3168067 100644 --- a/Voting-SystemVB/AdminController/AdminHomeStarted.Designer.vb +++ b/Voting-SystemVB/AdminController/AdminHomeStarted.Designer.vb @@ -22,9 +22,9 @@ Partial Class AdminHomeStarted 'Do not modify it using the code editor. _ Private Sub InitializeComponent() - Dim ChartArea3 As System.Windows.Forms.DataVisualization.Charting.ChartArea = New System.Windows.Forms.DataVisualization.Charting.ChartArea() - Dim Legend3 As System.Windows.Forms.DataVisualization.Charting.Legend = New System.Windows.Forms.DataVisualization.Charting.Legend() - Dim Series3 As System.Windows.Forms.DataVisualization.Charting.Series = New System.Windows.Forms.DataVisualization.Charting.Series() + Dim ChartArea1 As System.Windows.Forms.DataVisualization.Charting.ChartArea = New System.Windows.Forms.DataVisualization.Charting.ChartArea() + Dim Legend1 As System.Windows.Forms.DataVisualization.Charting.Legend = New System.Windows.Forms.DataVisualization.Charting.Legend() + Dim Series1 As System.Windows.Forms.DataVisualization.Charting.Series = New System.Windows.Forms.DataVisualization.Charting.Series() Me.VPresident = New Guna.UI2.WinForms.Guna2Button() Me.Secretary = New Guna.UI2.WinForms.Guna2Button() Me.Treasurer = New Guna.UI2.WinForms.Guna2Button() @@ -32,6 +32,7 @@ Partial Class AdminHomeStarted Me.PRO = New Guna.UI2.WinForms.Guna2Button() Me.ViewChart = New System.Windows.Forms.Label() Me.ShowCandidates = New Guna.UI2.WinForms.Guna2GroupBox() + Me.ButtonRefresh = New Guna.UI2.WinForms.Guna2Button() Me.Panel1 = New System.Windows.Forms.Panel() Me.PanelChart = New System.Windows.Forms.Panel() Me.Chart1 = New System.Windows.Forms.DataVisualization.Charting.Chart() @@ -49,7 +50,6 @@ Partial Class AdminHomeStarted Me.Guna2Separator1 = New Guna.UI2.WinForms.Guna2Separator() Me.FlowLayoutPanel1 = New System.Windows.Forms.FlowLayoutPanel() Me.President = New Guna.UI2.WinForms.Guna2Button() - Me.Guna2Button2 = New Guna.UI2.WinForms.Guna2Button() Me.ShowCandidates.SuspendLayout() Me.Panel1.SuspendLayout() Me.PanelChart.SuspendLayout() @@ -184,7 +184,7 @@ Partial Class AdminHomeStarted Or System.Windows.Forms.AnchorStyles.Left) _ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.ShowCandidates.BorderColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(164, Byte), Integer), CType(CType(91, Byte), Integer)) - Me.ShowCandidates.Controls.Add(Me.Guna2Button2) + Me.ShowCandidates.Controls.Add(Me.ButtonRefresh) Me.ShowCandidates.Controls.Add(Me.Panel1) Me.ShowCandidates.Controls.Add(Me.ViewChart) Me.ShowCandidates.CustomBorderColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(164, Byte), Integer), CType(CType(91, Byte), Integer)) @@ -199,6 +199,27 @@ Partial Class AdminHomeStarted Me.ShowCandidates.Text = "Results as of 6:00am" Me.ShowCandidates.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault ' + 'ButtonRefresh + ' + Me.ButtonRefresh.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.ButtonRefresh.Animated = True + Me.ButtonRefresh.BackColor = System.Drawing.Color.Transparent + Me.ButtonRefresh.BorderRadius = 5 + Me.ButtonRefresh.Checked = True + Me.ButtonRefresh.CheckedState.FillColor = System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer), CType(CType(64, Byte), Integer), CType(CType(0, Byte), Integer)) + Me.ButtonRefresh.CheckedState.Parent = Me.ButtonRefresh + Me.ButtonRefresh.CustomImages.Parent = Me.ButtonRefresh + Me.ButtonRefresh.FillColor = System.Drawing.Color.Empty + Me.ButtonRefresh.Font = New System.Drawing.Font("Segoe UI", 9.0!) + Me.ButtonRefresh.ForeColor = System.Drawing.Color.White + Me.ButtonRefresh.HoverState.Parent = Me.ButtonRefresh + Me.ButtonRefresh.Location = New System.Drawing.Point(598, 7) + Me.ButtonRefresh.Name = "ButtonRefresh" + Me.ButtonRefresh.ShadowDecoration.Parent = Me.ButtonRefresh + Me.ButtonRefresh.Size = New System.Drawing.Size(103, 26) + Me.ButtonRefresh.TabIndex = 23 + Me.ButtonRefresh.Text = "Refresh" + ' 'Panel1 ' Me.Panel1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ @@ -222,17 +243,17 @@ Partial Class AdminHomeStarted ' 'Chart1 ' - ChartArea3.Name = "ChartAreaBar" - Me.Chart1.ChartAreas.Add(ChartArea3) + ChartArea1.Name = "ChartAreaBar" + Me.Chart1.ChartAreas.Add(ChartArea1) Me.Chart1.Dock = System.Windows.Forms.DockStyle.Fill - Legend3.Name = "Legend2" - Me.Chart1.Legends.Add(Legend3) + Legend1.Name = "Legend2" + Me.Chart1.Legends.Add(Legend1) Me.Chart1.Location = New System.Drawing.Point(0, 0) Me.Chart1.Name = "Chart1" - Series3.ChartArea = "ChartAreaBar" - Series3.Legend = "Legend2" - Series3.Name = "Series2" - Me.Chart1.Series.Add(Series3) + Series1.ChartArea = "ChartAreaBar" + Series1.Legend = "Legend2" + Series1.Name = "Series2" + Me.Chart1.Series.Add(Series1) Me.Chart1.Size = New System.Drawing.Size(687, 194) Me.Chart1.TabIndex = 1 Me.Chart1.Text = "Chart1" @@ -424,29 +445,7 @@ Partial Class AdminHomeStarted Me.President.Tag = "1" Me.President.Text = "President" ' - 'Guna2Button2 - ' - Me.Guna2Button2.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.Guna2Button2.Animated = True - Me.Guna2Button2.BackColor = System.Drawing.Color.Transparent - Me.Guna2Button2.BorderRadius = 5 - Me.Guna2Button2.ButtonMode = Guna.UI2.WinForms.Enums.ButtonMode.ToogleButton - Me.Guna2Button2.Checked = True - Me.Guna2Button2.CheckedState.FillColor = System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer), CType(CType(64, Byte), Integer), CType(CType(0, Byte), Integer)) - Me.Guna2Button2.CheckedState.Parent = Me.Guna2Button2 - Me.Guna2Button2.CustomImages.Parent = Me.Guna2Button2 - Me.Guna2Button2.FillColor = System.Drawing.Color.Empty - Me.Guna2Button2.Font = New System.Drawing.Font("Segoe UI", 9.0!) - Me.Guna2Button2.ForeColor = System.Drawing.Color.White - Me.Guna2Button2.HoverState.Parent = Me.Guna2Button2 - Me.Guna2Button2.Location = New System.Drawing.Point(598, 7) - Me.Guna2Button2.Name = "Guna2Button2" - Me.Guna2Button2.ShadowDecoration.Parent = Me.Guna2Button2 - Me.Guna2Button2.Size = New System.Drawing.Size(103, 26) - Me.Guna2Button2.TabIndex = 23 - Me.Guna2Button2.Text = "Display Chart" - ' - 'AdminHomeStarted2 + 'AdminHomeStarted ' Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 17.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font @@ -458,7 +457,7 @@ Partial Class AdminHomeStarted Me.Controls.Add(Me.ShowCandidates) Me.Font = New System.Drawing.Font("Century Gothic", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Margin = New System.Windows.Forms.Padding(4) - Me.Name = "AdminHomeStarted2" + Me.Name = "AdminHomeStarted" Me.Size = New System.Drawing.Size(916, 481) Me.ShowCandidates.ResumeLayout(False) Me.ShowCandidates.PerformLayout() @@ -499,5 +498,5 @@ Partial Class AdminHomeStarted Friend WithEvents Guna2Separator1 As Guna.UI2.WinForms.Guna2Separator Friend WithEvents FlowLayoutPanel1 As System.Windows.Forms.FlowLayoutPanel Friend WithEvents President As Guna.UI2.WinForms.Guna2Button - Friend WithEvents Guna2Button2 As Guna.UI2.WinForms.Guna2Button + Friend WithEvents ButtonRefresh As Guna.UI2.WinForms.Guna2Button End Class diff --git a/Voting-SystemVB/AdminController/AdminHomeStarted.vb b/Voting-SystemVB/AdminController/AdminHomeStarted.vb index a5cf086..10dd9b6 100644 --- a/Voting-SystemVB/AdminController/AdminHomeStarted.vb +++ b/Voting-SystemVB/AdminController/AdminHomeStarted.vb @@ -1,11 +1,18 @@ -Imports System.Windows.Forms.DataVisualization.Charting +' Good Luck sa nag babasa netong code nato +' Kahit ako di ko na maintindihan +' saka nakaka tamad irefactor + +Imports System.Windows.Forms.DataVisualization.Charting +Imports Guna.UI2.WinForms Public Class AdminHomeStarted Private Shared StudentsCount As Integer = 0 Private Shared VotersCount As Integer = 0 Private Shared Candidates As New Dictionary(Of Integer, List(Of Candidate)) - Private Shared SelectedPosition = 1 + Private Shared SelectedPosition As Guna2Button + Private Shared Results As New Dictionary(Of Integer, Dictionary(Of Integer, Integer)) + Private Shared LastRefresh As Date 'Creates Only One Instances Private Shared Instance As AdminHomeStarted @@ -48,30 +55,49 @@ Public Class AdminHomeStarted End Sub Private Sub BackgroundWorkerInit_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorkerInit.RunWorkerCompleted President.PerformClick() + RefreshData() End Sub 'Refresh Data Public Sub RefreshData() If BackgroundWorkerRefresh.IsBusy Then Return StartLoading() - BackgroundWorkerRefresh.RunWorkerAsync(SelectedPosition) + BackgroundWorkerRefresh.RunWorkerAsync() End Sub Private Sub BackgroundWorkerRefresh_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorkerRefresh.DoWork VotersCount = Votes.CountAllDone() - e.Result = Votes.CountVotes(e.Argument) + Results = Votes.CountAllVotes + LastRefresh = Date.Now() End Sub Private Sub BackgroundWorkerRefresh_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorkerRefresh.RunWorkerCompleted StopLoading() + DisplayChart() + End Sub - Dim Tally As Dictionary(Of Integer, Integer) = e.Result + Private Function GetVoteCount(item As Candidate) As Integer + Dim Result = 0 + If Results.ContainsKey(item.PositionID) AndAlso Results(item.PositionID).ContainsKey(item.ID) Then + Result = Results(item.PositionID)(item.ID) + End If + Return Result + End Function - Chart1.Series.Clear() + Private Sub ButtonRefresh_Click(sender As Object, e As EventArgs) Handles ButtonRefresh.Click + RefreshData() + End Sub - ShowCandidates.Text = "Results as of: " & Date.Now().ToString("hh:mm:ss tt") - For Each item In Candidates(SelectedPosition) - Dim vote = 0 - If Tally.ContainsKey(item.ID) Then vote = Tally(item.ID) + 'Display Chart + Private Sub ButtonPosition_Click(sender As Guna2Button, e As EventArgs) Handles President.Click, VPresident.Click, Treasurer.Click, Secretary.Click, PRO.Click, Auditor.Click + SelectedPosition = sender + DisplayChart() + End Sub + Private Sub DisplayChart() + Chart1.Series.Clear() + Dim SelectedPositionID = Integer.Parse(SelectedPosition.Tag) + ShowCandidates.Text = "Results as of: " & LastRefresh.ToString("hh:mm:ss tt") + For Each item In Candidates(SelectedPositionID) + Dim vote = GetVoteCount(item) Dim seriesItem = New Series() Dim nPoint As New DataPoint() nPoint.SetValueY(vote) @@ -84,17 +110,7 @@ Public Class AdminHomeStarted 'pero may bug sa display ng chart 'pag wala to eh Chart1.ResetAutoValues() - - - End Sub - Private Sub ButtonRefresh_Click(sender As Object, e As EventArgs) - RefreshData() End Sub - 'Display Chart - Private Sub DisplayChart(sender As Object, e As EventArgs) Handles President.Click, VPresident.Click, Treasurer.Click, Secretary.Click, PRO.Click, Auditor.Click - SelectedPosition = Integer.Parse(sender.tag) - RefreshData() - End Sub End Class diff --git a/Voting-SystemVB/AdminController/ManageParty.Designer.vb b/Voting-SystemVB/AdminController/ManageParty.Designer.vb index 8b19e54..adadce3 100644 --- a/Voting-SystemVB/AdminController/ManageParty.Designer.vb +++ b/Voting-SystemVB/AdminController/ManageParty.Designer.vb @@ -27,6 +27,7 @@ Partial Class ManageParty Me.ButtonRefresh = New Guna.UI2.WinForms.Guna2Button() Me.BackgroundWorkerRefresh = New System.ComponentModel.BackgroundWorker() Me.FlowLayoutPanel1 = New System.Windows.Forms.FlowLayoutPanel() + Me.PictureBox1 = New System.Windows.Forms.PictureBox() Me.Panel1 = New System.Windows.Forms.Panel() Me.Guna2Separator2 = New Guna.UI2.WinForms.Guna2Separator() Me.Guna2Separator1 = New Guna.UI2.WinForms.Guna2Separator() @@ -36,31 +37,30 @@ Partial Class ManageParty Me.Label8 = New System.Windows.Forms.Label() Me.Label7 = New System.Windows.Forms.Label() Me.Label6 = New System.Windows.Forms.Label() + Me.LabelPRO = New System.Windows.Forms.Label() + Me.LabelAuditor = New System.Windows.Forms.Label() + Me.LabelTreasurer = New System.Windows.Forms.Label() Me.LabelSecretary = New System.Windows.Forms.Label() Me.LabelVicePresident = New System.Windows.Forms.Label() Me.Label1President = New System.Windows.Forms.Label() Me.Label5 = New System.Windows.Forms.Label() Me.Label4 = New System.Windows.Forms.Label() Me.LabelParty = New System.Windows.Forms.Label() + Me.ButtonRemove = New Guna.UI2.WinForms.Guna2Button() + Me.ButtonUpdate = New Guna.UI2.WinForms.Guna2Button() Me.PanelMain = New System.Windows.Forms.Panel() - Me.LabelTreasurer = New System.Windows.Forms.Label() - Me.LabelAuditor = New System.Windows.Forms.Label() - Me.LabelPRO = New System.Windows.Forms.Label() Me.PanelSub = New System.Windows.Forms.Panel() - Me.BackgroundWorkerFetchMember = New System.ComponentModel.BackgroundWorker() - Me.ButtonUpdate = New Guna.UI2.WinForms.Guna2Button() Me.PanelNoParty = New System.Windows.Forms.Panel() - Me.Label2 = New System.Windows.Forms.Label() Me.Guna2Button1 = New Guna.UI2.WinForms.Guna2Button() Me.Guna2Button2 = New Guna.UI2.WinForms.Guna2Button() - Me.Guna2Button3 = New Guna.UI2.WinForms.Guna2Button() - Me.PictureBox1 = New System.Windows.Forms.PictureBox() + Me.Label2 = New System.Windows.Forms.Label() + Me.BackgroundWorkerFetchMember = New System.ComponentModel.BackgroundWorker() Me.FlowLayoutPanel1.SuspendLayout() + CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() Me.Panel1.SuspendLayout() Me.PanelMain.SuspendLayout() Me.PanelSub.SuspendLayout() Me.PanelNoParty.SuspendLayout() - CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'Label1 @@ -125,6 +125,17 @@ Partial Class ManageParty Me.FlowLayoutPanel1.Size = New System.Drawing.Size(230, 380) Me.FlowLayoutPanel1.TabIndex = 9 ' + 'PictureBox1 + ' + Me.PictureBox1.BackColor = System.Drawing.Color.LightGray + Me.PictureBox1.Location = New System.Drawing.Point(0, 0) + Me.PictureBox1.Margin = New System.Windows.Forms.Padding(0, 0, 0, 3) + Me.PictureBox1.Name = "PictureBox1" + Me.PictureBox1.Size = New System.Drawing.Size(220, 100) + Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom + Me.PictureBox1.TabIndex = 12 + Me.PictureBox1.TabStop = False + ' 'Panel1 ' Me.Panel1.BackColor = System.Drawing.Color.White @@ -145,7 +156,7 @@ Partial Class ManageParty Me.Panel1.Controls.Add(Me.Label5) Me.Panel1.Controls.Add(Me.Label4) Me.Panel1.Controls.Add(Me.LabelParty) - Me.Panel1.Controls.Add(Me.Guna2Button3) + Me.Panel1.Controls.Add(Me.ButtonRemove) Me.Panel1.Controls.Add(Me.ButtonUpdate) Me.Panel1.Controls.Add(Me.ButtonRefresh) Me.Panel1.Dock = System.Windows.Forms.DockStyle.Fill @@ -241,6 +252,42 @@ Partial Class ManageParty Me.Label6.TabIndex = 0 Me.Label6.Text = "Vice President:" ' + 'LabelPRO + ' + Me.LabelPRO.Anchor = System.Windows.Forms.AnchorStyles.Top + Me.LabelPRO.AutoSize = True + Me.LabelPRO.Font = New System.Drawing.Font("Segoe UI", 12.0!) + Me.LabelPRO.ForeColor = System.Drawing.Color.Black + Me.LabelPRO.Location = New System.Drawing.Point(145, 287) + Me.LabelPRO.Name = "LabelPRO" + Me.LabelPRO.Size = New System.Drawing.Size(162, 21) + Me.LabelPRO.TabIndex = 0 + Me.LabelPRO.Text = "Lenard Mangay-ayam" + ' + 'LabelAuditor + ' + Me.LabelAuditor.Anchor = System.Windows.Forms.AnchorStyles.Top + Me.LabelAuditor.AutoSize = True + Me.LabelAuditor.Font = New System.Drawing.Font("Segoe UI", 12.0!) + Me.LabelAuditor.ForeColor = System.Drawing.Color.Black + Me.LabelAuditor.Location = New System.Drawing.Point(145, 256) + Me.LabelAuditor.Name = "LabelAuditor" + Me.LabelAuditor.Size = New System.Drawing.Size(162, 21) + Me.LabelAuditor.TabIndex = 0 + Me.LabelAuditor.Text = "Lenard Mangay-ayam" + ' + 'LabelTreasurer + ' + Me.LabelTreasurer.Anchor = System.Windows.Forms.AnchorStyles.Top + Me.LabelTreasurer.AutoSize = True + Me.LabelTreasurer.Font = New System.Drawing.Font("Segoe UI", 12.0!) + Me.LabelTreasurer.ForeColor = System.Drawing.Color.Black + Me.LabelTreasurer.Location = New System.Drawing.Point(145, 225) + Me.LabelTreasurer.Name = "LabelTreasurer" + Me.LabelTreasurer.Size = New System.Drawing.Size(162, 21) + Me.LabelTreasurer.TabIndex = 0 + Me.LabelTreasurer.Text = "Lenard Mangay-ayam" + ' 'LabelSecretary ' Me.LabelSecretary.Anchor = System.Windows.Forms.AnchorStyles.Top @@ -310,6 +357,43 @@ Partial Class ManageParty Me.LabelParty.TabIndex = 0 Me.LabelParty.Text = "Sample Title" ' + 'ButtonRemove + ' + Me.ButtonRemove.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.ButtonRemove.Animated = True + Me.ButtonRemove.BackColor = System.Drawing.Color.Transparent + Me.ButtonRemove.BorderColor = System.Drawing.Color.LightGray + Me.ButtonRemove.CheckedState.Parent = Me.ButtonRemove + Me.ButtonRemove.CustomImages.Parent = Me.ButtonRemove + Me.ButtonRemove.FillColor = System.Drawing.Color.White + Me.ButtonRemove.Font = New System.Drawing.Font("Segoe UI", 12.0!) + Me.ButtonRemove.ForeColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(70, Byte), Integer), CType(CType(70, Byte), Integer)) + Me.ButtonRemove.HoverState.Parent = Me.ButtonRemove + Me.ButtonRemove.Location = New System.Drawing.Point(339, 335) + Me.ButtonRemove.Name = "ButtonRemove" + Me.ButtonRemove.ShadowDecoration.Parent = Me.ButtonRemove + Me.ButtonRemove.Size = New System.Drawing.Size(110, 36) + Me.ButtonRemove.TabIndex = 8 + Me.ButtonRemove.Text = "Remove Party" + ' + 'ButtonUpdate + ' + Me.ButtonUpdate.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.ButtonUpdate.Animated = True + Me.ButtonUpdate.BackColor = System.Drawing.Color.Transparent + Me.ButtonUpdate.BorderColor = System.Drawing.Color.LightGray + Me.ButtonUpdate.CheckedState.Parent = Me.ButtonUpdate + Me.ButtonUpdate.CustomImages.Parent = Me.ButtonUpdate + Me.ButtonUpdate.Font = New System.Drawing.Font("Segoe UI", 12.0!) + Me.ButtonUpdate.ForeColor = System.Drawing.Color.White + Me.ButtonUpdate.HoverState.Parent = Me.ButtonUpdate + Me.ButtonUpdate.Location = New System.Drawing.Point(455, 335) + Me.ButtonUpdate.Name = "ButtonUpdate" + Me.ButtonUpdate.ShadowDecoration.Parent = Me.ButtonUpdate + Me.ButtonUpdate.Size = New System.Drawing.Size(110, 36) + Me.ButtonUpdate.TabIndex = 8 + Me.ButtonUpdate.Text = "Update" + ' 'PanelMain ' Me.PanelMain.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ @@ -322,42 +406,6 @@ Partial Class ManageParty Me.PanelMain.Size = New System.Drawing.Size(837, 380) Me.PanelMain.TabIndex = 11 ' - 'LabelTreasurer - ' - Me.LabelTreasurer.Anchor = System.Windows.Forms.AnchorStyles.Top - Me.LabelTreasurer.AutoSize = True - Me.LabelTreasurer.Font = New System.Drawing.Font("Segoe UI", 12.0!) - Me.LabelTreasurer.ForeColor = System.Drawing.Color.Black - Me.LabelTreasurer.Location = New System.Drawing.Point(145, 225) - Me.LabelTreasurer.Name = "LabelTreasurer" - Me.LabelTreasurer.Size = New System.Drawing.Size(162, 21) - Me.LabelTreasurer.TabIndex = 0 - Me.LabelTreasurer.Text = "Lenard Mangay-ayam" - ' - 'LabelAuditor - ' - Me.LabelAuditor.Anchor = System.Windows.Forms.AnchorStyles.Top - Me.LabelAuditor.AutoSize = True - Me.LabelAuditor.Font = New System.Drawing.Font("Segoe UI", 12.0!) - Me.LabelAuditor.ForeColor = System.Drawing.Color.Black - Me.LabelAuditor.Location = New System.Drawing.Point(145, 256) - Me.LabelAuditor.Name = "LabelAuditor" - Me.LabelAuditor.Size = New System.Drawing.Size(162, 21) - Me.LabelAuditor.TabIndex = 0 - Me.LabelAuditor.Text = "Lenard Mangay-ayam" - ' - 'LabelPRO - ' - Me.LabelPRO.Anchor = System.Windows.Forms.AnchorStyles.Top - Me.LabelPRO.AutoSize = True - Me.LabelPRO.Font = New System.Drawing.Font("Segoe UI", 12.0!) - Me.LabelPRO.ForeColor = System.Drawing.Color.Black - Me.LabelPRO.Location = New System.Drawing.Point(145, 287) - Me.LabelPRO.Name = "LabelPRO" - Me.LabelPRO.Size = New System.Drawing.Size(162, 21) - Me.LabelPRO.TabIndex = 0 - Me.LabelPRO.Text = "Lenard Mangay-ayam" - ' 'PanelSub ' Me.PanelSub.Controls.Add(Me.Panel1) @@ -368,27 +416,6 @@ Partial Class ManageParty Me.PanelSub.Size = New System.Drawing.Size(607, 380) Me.PanelSub.TabIndex = 9 ' - 'BackgroundWorkerFetchMember - ' - ' - 'ButtonUpdate - ' - Me.ButtonUpdate.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.ButtonUpdate.Animated = True - Me.ButtonUpdate.BackColor = System.Drawing.Color.Transparent - Me.ButtonUpdate.BorderColor = System.Drawing.Color.LightGray - Me.ButtonUpdate.CheckedState.Parent = Me.ButtonUpdate - Me.ButtonUpdate.CustomImages.Parent = Me.ButtonUpdate - Me.ButtonUpdate.Font = New System.Drawing.Font("Segoe UI", 12.0!) - Me.ButtonUpdate.ForeColor = System.Drawing.Color.White - Me.ButtonUpdate.HoverState.Parent = Me.ButtonUpdate - Me.ButtonUpdate.Location = New System.Drawing.Point(455, 335) - Me.ButtonUpdate.Name = "ButtonUpdate" - Me.ButtonUpdate.ShadowDecoration.Parent = Me.ButtonUpdate - Me.ButtonUpdate.Size = New System.Drawing.Size(110, 36) - Me.ButtonUpdate.TabIndex = 8 - Me.ButtonUpdate.Text = "Update" - ' 'PanelNoParty ' Me.PanelNoParty.BackColor = System.Drawing.Color.White @@ -401,17 +428,6 @@ Partial Class ManageParty Me.PanelNoParty.Size = New System.Drawing.Size(607, 380) Me.PanelNoParty.TabIndex = 12 ' - 'Label2 - ' - Me.Label2.Anchor = System.Windows.Forms.AnchorStyles.None - Me.Label2.AutoSize = True - Me.Label2.Font = New System.Drawing.Font("Segoe UI", 24.0!) - Me.Label2.Location = New System.Drawing.Point(130, 118) - Me.Label2.Name = "Label2" - Me.Label2.Size = New System.Drawing.Size(361, 45) - Me.Label2.TabIndex = 7 - Me.Label2.Text = "There is no Party Added" - ' 'Guna2Button1 ' Me.Guna2Button1.Anchor = System.Windows.Forms.AnchorStyles.None @@ -450,35 +466,19 @@ Partial Class ManageParty Me.Guna2Button2.TabIndex = 10 Me.Guna2Button2.Text = "Refresh" ' - 'Guna2Button3 - ' - Me.Guna2Button3.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.Guna2Button3.Animated = True - Me.Guna2Button3.BackColor = System.Drawing.Color.Transparent - Me.Guna2Button3.BorderColor = System.Drawing.Color.LightGray - Me.Guna2Button3.CheckedState.Parent = Me.Guna2Button3 - Me.Guna2Button3.CustomImages.Parent = Me.Guna2Button3 - Me.Guna2Button3.FillColor = System.Drawing.Color.White - Me.Guna2Button3.Font = New System.Drawing.Font("Segoe UI", 12.0!) - Me.Guna2Button3.ForeColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(70, Byte), Integer), CType(CType(70, Byte), Integer)) - Me.Guna2Button3.HoverState.Parent = Me.Guna2Button3 - Me.Guna2Button3.Location = New System.Drawing.Point(339, 335) - Me.Guna2Button3.Name = "Guna2Button3" - Me.Guna2Button3.ShadowDecoration.Parent = Me.Guna2Button3 - Me.Guna2Button3.Size = New System.Drawing.Size(110, 36) - Me.Guna2Button3.TabIndex = 8 - Me.Guna2Button3.Text = "Remove Party" + 'Label2 ' - 'PictureBox1 + Me.Label2.Anchor = System.Windows.Forms.AnchorStyles.None + Me.Label2.AutoSize = True + Me.Label2.Font = New System.Drawing.Font("Segoe UI", 24.0!) + Me.Label2.Location = New System.Drawing.Point(130, 118) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(361, 45) + Me.Label2.TabIndex = 7 + Me.Label2.Text = "There is no Party Added" + ' + 'BackgroundWorkerFetchMember ' - Me.PictureBox1.BackColor = System.Drawing.Color.LightGray - Me.PictureBox1.Location = New System.Drawing.Point(0, 0) - Me.PictureBox1.Margin = New System.Windows.Forms.Padding(0, 0, 0, 3) - Me.PictureBox1.Name = "PictureBox1" - Me.PictureBox1.Size = New System.Drawing.Size(220, 100) - Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom - Me.PictureBox1.TabIndex = 12 - Me.PictureBox1.TabStop = False ' 'ManageParty ' @@ -489,13 +489,13 @@ Partial Class ManageParty Me.Name = "ManageParty" Me.Size = New System.Drawing.Size(913, 481) Me.FlowLayoutPanel1.ResumeLayout(False) + CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit() Me.Panel1.ResumeLayout(False) Me.Panel1.PerformLayout() Me.PanelMain.ResumeLayout(False) Me.PanelSub.ResumeLayout(False) Me.PanelNoParty.ResumeLayout(False) Me.PanelNoParty.PerformLayout() - CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) Me.PerformLayout() @@ -531,7 +531,7 @@ Partial Class ManageParty Friend WithEvents Guna2Button1 As Guna.UI2.WinForms.Guna2Button Friend WithEvents Guna2Button2 As Guna.UI2.WinForms.Guna2Button Friend WithEvents Label2 As System.Windows.Forms.Label - Friend WithEvents Guna2Button3 As Guna.UI2.WinForms.Guna2Button + Friend WithEvents ButtonRemove As Guna.UI2.WinForms.Guna2Button Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox End Class diff --git a/Voting-SystemVB/AdminController/ManageParty.vb b/Voting-SystemVB/AdminController/ManageParty.vb index 07d9d29..f63e2e2 100644 --- a/Voting-SystemVB/AdminController/ManageParty.vb +++ b/Voting-SystemVB/AdminController/ManageParty.vb @@ -27,12 +27,13 @@ Public Class ManageParty ' End If 'End Sub Private Sub ManageParty_Refresh() Implements MainControl.RefreshControl - If Election.HasNotStarted Then - ButtonAdd.Visible = True - Else - ButtonAdd.Visible = False - End If ButtonRefresh.PerformClick() + + ButtonAdd.Visible = Election.HasNotStarted + ButtonUpdate.Visible = Election.HasNotStarted + ButtonRefresh.Visible = Election.HasNotStarted + ButtonRemove.Visible = Election.HasNotStarted + End Sub @@ -159,7 +160,7 @@ Public Class ManageParty Return sLabel End Function - Private Sub ButtonUpdate_Click(sender As Object, e As EventArgs) Handles ButtonUpdate.Click, Guna2Button3.Click + Private Sub ButtonUpdate_Click(sender As Object, e As EventArgs) Handles ButtonUpdate.Click If Not IsNothing(PreviousButton) Then UpdateParty.ShowPopup(PreviousButton.Tag) End If diff --git a/Voting-SystemVB/Model/Position.vb b/Voting-SystemVB/Model/Position.vb index 7f72d63..3fedfcf 100644 --- a/Voting-SystemVB/Model/Position.vb +++ b/Voting-SystemVB/Model/Position.vb @@ -25,7 +25,7 @@ Public Shared Function GetDictionary() As Dictionary(Of Integer, List(Of Candidate)) Dim dict As New Dictionary(Of Integer, List(Of Candidate)) - AllPositions.ForEach(Sub(item) dict.Add(item, New List(Of Candidate))) + GetAll().ForEach(Sub(item) dict.Add(item, New List(Of Candidate))) Return dict End Function diff --git a/Voting-SystemVB/Model/Votes.vb b/Voting-SystemVB/Model/Votes.vb index 13aae91..0d211cb 100644 --- a/Voting-SystemVB/Model/Votes.vb +++ b/Voting-SystemVB/Model/Votes.vb @@ -31,6 +31,13 @@ Public Class Votes Return Result End Function + 'Count the votes of All Candidates + Public Shared Function CountAllVotes() As Dictionary(Of Integer, Dictionary(Of Integer, Integer)) + Dim Result As New Dictionary(Of Integer, Dictionary(Of Integer, Integer)) + Position.GetAll().ForEach(Sub(position_id As Integer) Result.Add(position_id, CountVotes(position_id))) + Return Result + End Function + Public Shared Sub SubmitVotes(Candidates As List(Of Integer)) If IsNothing(Student.GetCurrentUser()) Then Throw New NotLoggedInException diff --git a/Voting-SystemVB/VoterController/VoteCount.Designer.vb b/Voting-SystemVB/VoterController/VoteCount.Designer.vb new file mode 100644 index 0000000..82531ba --- /dev/null +++ b/Voting-SystemVB/VoterController/VoteCount.Designer.vb @@ -0,0 +1,315 @@ + _ +Partial Class VoteCount + Inherits System.Windows.Forms.UserControl + + 'UserControl overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Dim ChartArea2 As System.Windows.Forms.DataVisualization.Charting.ChartArea = New System.Windows.Forms.DataVisualization.Charting.ChartArea() + Dim StripLine2 As System.Windows.Forms.DataVisualization.Charting.StripLine = New System.Windows.Forms.DataVisualization.Charting.StripLine() + Dim Legend2 As System.Windows.Forms.DataVisualization.Charting.Legend = New System.Windows.Forms.DataVisualization.Charting.Legend() + Dim Series2 As System.Windows.Forms.DataVisualization.Charting.Series = New System.Windows.Forms.DataVisualization.Charting.Series() + Me.Label1 = New System.Windows.Forms.Label() + Me.LabelDesc = New System.Windows.Forms.Label() + Me.PositionGroup = New System.Windows.Forms.FlowLayoutPanel() + Me.BtnRefresh = New Guna.UI2.WinForms.Guna2Button() + Me.ButtonPresident = New Guna.UI2.WinForms.Guna2Button() + Me.ButtonVicePresident = New Guna.UI2.WinForms.Guna2Button() + Me.ButtonSecretary = New Guna.UI2.WinForms.Guna2Button() + Me.ButtonTreasurer = New Guna.UI2.WinForms.Guna2Button() + Me.ButtonAuditor = New Guna.UI2.WinForms.Guna2Button() + Me.ButtonPRO = New Guna.UI2.WinForms.Guna2Button() + Me.Guna2Panel1 = New Guna.UI2.WinForms.Guna2Panel() + Me.Chart1 = New System.Windows.Forms.DataVisualization.Charting.Chart() + Me.PositionGroup.SuspendLayout() + Me.Guna2Panel1.SuspendLayout() + CType(Me.Chart1, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Font = New System.Drawing.Font("Century Gothic", 14.0!, System.Drawing.FontStyle.Bold) + Me.Label1.ForeColor = System.Drawing.Color.White + Me.Label1.Location = New System.Drawing.Point(36, 32) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(185, 23) + Me.Label1.TabIndex = 1 + Me.Label1.Text = "Current Vote Count" + ' + 'LabelDesc + ' + Me.LabelDesc.AutoSize = True + Me.LabelDesc.Font = New System.Drawing.Font("Century Gothic", 10.0!) + Me.LabelDesc.ForeColor = System.Drawing.SystemColors.ControlDark + Me.LabelDesc.Location = New System.Drawing.Point(36, 64) + Me.LabelDesc.Name = "LabelDesc" + Me.LabelDesc.Size = New System.Drawing.Size(149, 19) + Me.LabelDesc.TabIndex = 2 + Me.LabelDesc.Text = "Results as of 6:54 am" + ' + 'PositionGroup + ' + Me.PositionGroup.Controls.Add(Me.BtnRefresh) + Me.PositionGroup.Controls.Add(Me.ButtonPresident) + Me.PositionGroup.Controls.Add(Me.ButtonVicePresident) + Me.PositionGroup.Controls.Add(Me.ButtonSecretary) + Me.PositionGroup.Controls.Add(Me.ButtonTreasurer) + Me.PositionGroup.Controls.Add(Me.ButtonAuditor) + Me.PositionGroup.Controls.Add(Me.ButtonPRO) + Me.PositionGroup.Location = New System.Drawing.Point(40, 101) + Me.PositionGroup.Name = "PositionGroup" + Me.PositionGroup.Size = New System.Drawing.Size(889, 37) + Me.PositionGroup.TabIndex = 3 + ' + 'BtnRefresh + ' + Me.BtnRefresh.Animated = True + Me.BtnRefresh.CheckedState.FillColor = System.Drawing.Color.FromArgb(CType(CType(46, Byte), Integer), CType(CType(43, Byte), Integer), CType(CType(63, Byte), Integer)) + Me.BtnRefresh.CheckedState.ForeColor = System.Drawing.Color.White + Me.BtnRefresh.CheckedState.Parent = Me.BtnRefresh + Me.BtnRefresh.CustomImages.Parent = Me.BtnRefresh + Me.BtnRefresh.FillColor = System.Drawing.Color.Empty + Me.BtnRefresh.Font = New System.Drawing.Font("Segoe UI", 9.0!) + Me.BtnRefresh.ForeColor = System.Drawing.Color.White + Me.BtnRefresh.HoverState.Parent = Me.BtnRefresh + Me.BtnRefresh.Location = New System.Drawing.Point(3, 3) + Me.BtnRefresh.Name = "BtnRefresh" + Me.BtnRefresh.ShadowDecoration.Parent = Me.BtnRefresh + Me.BtnRefresh.Size = New System.Drawing.Size(110, 34) + Me.BtnRefresh.TabIndex = 6 + Me.BtnRefresh.Tag = "6" + Me.BtnRefresh.Text = "Refresh" + ' + 'ButtonPresident + ' + Me.ButtonPresident.Animated = True + Me.ButtonPresident.BorderRadius = 10 + Me.ButtonPresident.ButtonMode = Guna.UI2.WinForms.Enums.ButtonMode.RadioButton + Me.ButtonPresident.CheckedState.FillColor = System.Drawing.Color.FromArgb(CType(CType(46, Byte), Integer), CType(CType(43, Byte), Integer), CType(CType(63, Byte), Integer)) + Me.ButtonPresident.CheckedState.ForeColor = System.Drawing.Color.White + Me.ButtonPresident.CheckedState.Parent = Me.ButtonPresident + Me.ButtonPresident.CustomImages.Parent = Me.ButtonPresident + Me.ButtonPresident.FillColor = System.Drawing.Color.Empty + Me.ButtonPresident.Font = New System.Drawing.Font("Segoe UI", 9.0!) + Me.ButtonPresident.ForeColor = System.Drawing.SystemColors.ControlDark + Me.ButtonPresident.HoverState.Parent = Me.ButtonPresident + Me.ButtonPresident.Location = New System.Drawing.Point(119, 3) + Me.ButtonPresident.Name = "ButtonPresident" + Me.ButtonPresident.ShadowDecoration.Parent = Me.ButtonPresident + Me.ButtonPresident.Size = New System.Drawing.Size(110, 34) + Me.ButtonPresident.TabIndex = 0 + Me.ButtonPresident.Tag = "1" + Me.ButtonPresident.Text = "President" + ' + 'ButtonVicePresident + ' + Me.ButtonVicePresident.Animated = True + Me.ButtonVicePresident.BorderRadius = 10 + Me.ButtonVicePresident.ButtonMode = Guna.UI2.WinForms.Enums.ButtonMode.RadioButton + Me.ButtonVicePresident.CheckedState.FillColor = System.Drawing.Color.FromArgb(CType(CType(46, Byte), Integer), CType(CType(43, Byte), Integer), CType(CType(63, Byte), Integer)) + Me.ButtonVicePresident.CheckedState.ForeColor = System.Drawing.Color.White + Me.ButtonVicePresident.CheckedState.Parent = Me.ButtonVicePresident + Me.ButtonVicePresident.CustomImages.Parent = Me.ButtonVicePresident + Me.ButtonVicePresident.FillColor = System.Drawing.Color.Empty + Me.ButtonVicePresident.Font = New System.Drawing.Font("Segoe UI", 9.0!) + Me.ButtonVicePresident.ForeColor = System.Drawing.SystemColors.ControlDark + Me.ButtonVicePresident.HoverState.Parent = Me.ButtonVicePresident + Me.ButtonVicePresident.Location = New System.Drawing.Point(235, 3) + Me.ButtonVicePresident.Name = "ButtonVicePresident" + Me.ButtonVicePresident.ShadowDecoration.Parent = Me.ButtonVicePresident + Me.ButtonVicePresident.Size = New System.Drawing.Size(110, 34) + Me.ButtonVicePresident.TabIndex = 1 + Me.ButtonVicePresident.Tag = "2" + Me.ButtonVicePresident.Text = "Vice President" + ' + 'ButtonSecretary + ' + Me.ButtonSecretary.Animated = True + Me.ButtonSecretary.BorderRadius = 10 + Me.ButtonSecretary.ButtonMode = Guna.UI2.WinForms.Enums.ButtonMode.RadioButton + Me.ButtonSecretary.CheckedState.FillColor = System.Drawing.Color.FromArgb(CType(CType(46, Byte), Integer), CType(CType(43, Byte), Integer), CType(CType(63, Byte), Integer)) + Me.ButtonSecretary.CheckedState.ForeColor = System.Drawing.Color.White + Me.ButtonSecretary.CheckedState.Parent = Me.ButtonSecretary + Me.ButtonSecretary.CustomImages.Parent = Me.ButtonSecretary + Me.ButtonSecretary.FillColor = System.Drawing.Color.Empty + Me.ButtonSecretary.Font = New System.Drawing.Font("Segoe UI", 9.0!) + Me.ButtonSecretary.ForeColor = System.Drawing.SystemColors.ControlDark + Me.ButtonSecretary.HoverState.Parent = Me.ButtonSecretary + Me.ButtonSecretary.Location = New System.Drawing.Point(351, 3) + Me.ButtonSecretary.Name = "ButtonSecretary" + Me.ButtonSecretary.ShadowDecoration.Parent = Me.ButtonSecretary + Me.ButtonSecretary.Size = New System.Drawing.Size(110, 34) + Me.ButtonSecretary.TabIndex = 2 + Me.ButtonSecretary.Tag = "3" + Me.ButtonSecretary.Text = "Secretary" + ' + 'ButtonTreasurer + ' + Me.ButtonTreasurer.Animated = True + Me.ButtonTreasurer.BorderRadius = 10 + Me.ButtonTreasurer.ButtonMode = Guna.UI2.WinForms.Enums.ButtonMode.RadioButton + Me.ButtonTreasurer.CheckedState.FillColor = System.Drawing.Color.FromArgb(CType(CType(46, Byte), Integer), CType(CType(43, Byte), Integer), CType(CType(63, Byte), Integer)) + Me.ButtonTreasurer.CheckedState.ForeColor = System.Drawing.Color.White + Me.ButtonTreasurer.CheckedState.Parent = Me.ButtonTreasurer + Me.ButtonTreasurer.CustomImages.Parent = Me.ButtonTreasurer + Me.ButtonTreasurer.FillColor = System.Drawing.Color.Empty + Me.ButtonTreasurer.Font = New System.Drawing.Font("Segoe UI", 9.0!) + Me.ButtonTreasurer.ForeColor = System.Drawing.SystemColors.ControlDark + Me.ButtonTreasurer.HoverState.Parent = Me.ButtonTreasurer + Me.ButtonTreasurer.Location = New System.Drawing.Point(467, 3) + Me.ButtonTreasurer.Name = "ButtonTreasurer" + Me.ButtonTreasurer.ShadowDecoration.Parent = Me.ButtonTreasurer + Me.ButtonTreasurer.Size = New System.Drawing.Size(110, 34) + Me.ButtonTreasurer.TabIndex = 3 + Me.ButtonTreasurer.Tag = "4" + Me.ButtonTreasurer.Text = "Treasurer" + ' + 'ButtonAuditor + ' + Me.ButtonAuditor.Animated = True + Me.ButtonAuditor.BorderRadius = 10 + Me.ButtonAuditor.ButtonMode = Guna.UI2.WinForms.Enums.ButtonMode.RadioButton + Me.ButtonAuditor.CheckedState.FillColor = System.Drawing.Color.FromArgb(CType(CType(46, Byte), Integer), CType(CType(43, Byte), Integer), CType(CType(63, Byte), Integer)) + Me.ButtonAuditor.CheckedState.ForeColor = System.Drawing.Color.White + Me.ButtonAuditor.CheckedState.Parent = Me.ButtonAuditor + Me.ButtonAuditor.CustomImages.Parent = Me.ButtonAuditor + Me.ButtonAuditor.FillColor = System.Drawing.Color.Empty + Me.ButtonAuditor.Font = New System.Drawing.Font("Segoe UI", 9.0!) + Me.ButtonAuditor.ForeColor = System.Drawing.SystemColors.ControlDark + Me.ButtonAuditor.HoverState.Parent = Me.ButtonAuditor + Me.ButtonAuditor.Location = New System.Drawing.Point(583, 3) + Me.ButtonAuditor.Name = "ButtonAuditor" + Me.ButtonAuditor.ShadowDecoration.Parent = Me.ButtonAuditor + Me.ButtonAuditor.Size = New System.Drawing.Size(110, 34) + Me.ButtonAuditor.TabIndex = 4 + Me.ButtonAuditor.Tag = "5" + Me.ButtonAuditor.Text = "Auditor" + ' + 'ButtonPRO + ' + Me.ButtonPRO.Animated = True + Me.ButtonPRO.BorderRadius = 10 + Me.ButtonPRO.ButtonMode = Guna.UI2.WinForms.Enums.ButtonMode.RadioButton + Me.ButtonPRO.CheckedState.FillColor = System.Drawing.Color.FromArgb(CType(CType(46, Byte), Integer), CType(CType(43, Byte), Integer), CType(CType(63, Byte), Integer)) + Me.ButtonPRO.CheckedState.ForeColor = System.Drawing.Color.White + Me.ButtonPRO.CheckedState.Parent = Me.ButtonPRO + Me.ButtonPRO.CustomImages.Parent = Me.ButtonPRO + Me.ButtonPRO.FillColor = System.Drawing.Color.Empty + Me.ButtonPRO.Font = New System.Drawing.Font("Segoe UI", 9.0!) + Me.ButtonPRO.ForeColor = System.Drawing.SystemColors.ControlDark + Me.ButtonPRO.HoverState.Parent = Me.ButtonPRO + Me.ButtonPRO.Location = New System.Drawing.Point(699, 3) + Me.ButtonPRO.Name = "ButtonPRO" + Me.ButtonPRO.ShadowDecoration.Parent = Me.ButtonPRO + Me.ButtonPRO.Size = New System.Drawing.Size(110, 34) + Me.ButtonPRO.TabIndex = 5 + Me.ButtonPRO.Tag = "6" + Me.ButtonPRO.Text = "P.R.O" + ' + 'Guna2Panel1 + ' + Me.Guna2Panel1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.Guna2Panel1.AutoScroll = True + Me.Guna2Panel1.Controls.Add(Me.Chart1) + Me.Guna2Panel1.FillColor = System.Drawing.Color.FromArgb(CType(CType(46, Byte), Integer), CType(CType(43, Byte), Integer), CType(CType(63, Byte), Integer)) + Me.Guna2Panel1.Location = New System.Drawing.Point(40, 161) + Me.Guna2Panel1.Name = "Guna2Panel1" + Me.Guna2Panel1.ShadowDecoration.Parent = Me.Guna2Panel1 + Me.Guna2Panel1.Size = New System.Drawing.Size(889, 358) + Me.Guna2Panel1.TabIndex = 4 + ' + 'Chart1 + ' + Me.Chart1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.Chart1.BackColor = System.Drawing.Color.Transparent + Me.Chart1.BackSecondaryColor = System.Drawing.Color.White + Me.Chart1.BorderSkin.BorderColor = System.Drawing.Color.White + ChartArea2.Area3DStyle.Inclination = 10 + ChartArea2.Area3DStyle.IsRightAngleAxes = False + ChartArea2.Area3DStyle.LightStyle = System.Windows.Forms.DataVisualization.Charting.LightStyle.Realistic + ChartArea2.AxisX.LabelStyle.ForeColor = System.Drawing.Color.White + ChartArea2.AxisX.LineColor = System.Drawing.Color.White + ChartArea2.AxisX.TitleForeColor = System.Drawing.Color.White + ChartArea2.AxisX2.LabelStyle.ForeColor = System.Drawing.Color.White + ChartArea2.AxisX2.LineColor = System.Drawing.Color.White + ChartArea2.AxisY.InterlacedColor = System.Drawing.Color.White + ChartArea2.AxisY.LabelStyle.ForeColor = System.Drawing.Color.White + ChartArea2.AxisY.LineColor = System.Drawing.Color.White + StripLine2.BackColor = System.Drawing.Color.White + StripLine2.BorderColor = System.Drawing.Color.White + ChartArea2.AxisY.StripLines.Add(StripLine2) + ChartArea2.AxisY2.LabelStyle.ForeColor = System.Drawing.Color.White + ChartArea2.AxisY2.LineColor = System.Drawing.Color.White + ChartArea2.AxisY2.TitleForeColor = System.Drawing.Color.White + ChartArea2.BackColor = System.Drawing.Color.Transparent + ChartArea2.BorderColor = System.Drawing.Color.White + ChartArea2.Name = "ChartAreaBar" + Me.Chart1.ChartAreas.Add(ChartArea2) + Legend2.BackColor = System.Drawing.Color.Transparent + Legend2.ForeColor = System.Drawing.Color.White + Legend2.Name = "Legend2" + Me.Chart1.Legends.Add(Legend2) + Me.Chart1.Location = New System.Drawing.Point(22, 25) + Me.Chart1.Name = "Chart1" + Series2.ChartArea = "ChartAreaBar" + Series2.Legend = "Legend2" + Series2.Name = "Series2" + Me.Chart1.Series.Add(Series2) + Me.Chart1.Size = New System.Drawing.Size(851, 311) + Me.Chart1.TabIndex = 2 + Me.Chart1.Text = "Chart1" + ' + 'VoteCount + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.BackColor = System.Drawing.Color.FromArgb(CType(CType(28, Byte), Integer), CType(CType(28, Byte), Integer), CType(CType(40, Byte), Integer)) + Me.Controls.Add(Me.Guna2Panel1) + Me.Controls.Add(Me.PositionGroup) + Me.Controls.Add(Me.LabelDesc) + Me.Controls.Add(Me.Label1) + Me.Name = "VoteCount" + Me.Size = New System.Drawing.Size(974, 557) + Me.PositionGroup.ResumeLayout(False) + Me.Guna2Panel1.ResumeLayout(False) + CType(Me.Chart1, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents LabelDesc As System.Windows.Forms.Label + Friend WithEvents PositionGroup As System.Windows.Forms.FlowLayoutPanel + Friend WithEvents ButtonPresident As Guna.UI2.WinForms.Guna2Button + Friend WithEvents ButtonVicePresident As Guna.UI2.WinForms.Guna2Button + Friend WithEvents ButtonSecretary As Guna.UI2.WinForms.Guna2Button + Friend WithEvents ButtonTreasurer As Guna.UI2.WinForms.Guna2Button + Friend WithEvents ButtonAuditor As Guna.UI2.WinForms.Guna2Button + Friend WithEvents ButtonPRO As Guna.UI2.WinForms.Guna2Button + Friend WithEvents Guna2Panel1 As Guna.UI2.WinForms.Guna2Panel + Friend WithEvents Chart1 As System.Windows.Forms.DataVisualization.Charting.Chart + Friend WithEvents BtnRefresh As Guna.UI2.WinForms.Guna2Button + +End Class diff --git a/Voting-SystemVB/VoterController/VoteCount.resx b/Voting-SystemVB/VoterController/VoteCount.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Voting-SystemVB/VoterController/VoteCount.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Voting-SystemVB/VoterController/VoteCount.vb b/Voting-SystemVB/VoterController/VoteCount.vb new file mode 100644 index 0000000..4f614ad --- /dev/null +++ b/Voting-SystemVB/VoterController/VoteCount.vb @@ -0,0 +1,67 @@ +Imports Guna.UI2.WinForms +Imports System.Windows.Forms.DataVisualization.Charting + +Public Class VoteCount + + Private Shared Candidates As New Dictionary(Of Integer, List(Of Candidate)) + Private Shared Results As Dictionary(Of Integer, Dictionary(Of Integer, Integer)) + Private Shared SelectedPosition = "ButtonPresident" + Private Shared Instance As VoteCount + Private Shared LastRefresh As Date + + Public Shared Function GetInstance() As VoteCount + If IsNothing(Instance) Then + Instance = New VoteCount + Instance.DoubleBuffered = True + End If + Return Instance + End Function + + Private Sub VoteCount_Load(sender As Object, e As EventArgs) Handles MyBase.Load + Candidates = Candidate.GetAll() + BtnRefresh.PerformClick() + End Sub + + Private Sub BtnRefresh_Click(sender As Object, e As EventArgs) Handles BtnRefresh.Click + Results = Votes.CountAllVotes() + LastRefresh = Date.Now() + Dim SelectedButton = DirectCast(PositionGroup.Controls(SelectedPosition), Guna2Button) + SelectedPosition = Nothing + SelectedButton.PerformClick() + End Sub + + Private Sub DisplayChart_Click(sender As Guna2Button, e As EventArgs) Handles ButtonPresident.Click, ButtonVicePresident.Click, ButtonSecretary.Click, ButtonTreasurer.Click, ButtonAuditor.Click, ButtonPRO.Click + If sender.Name.Equals(SelectedPosition) Then Return + + SelectedPosition = sender.Name + Dim SelectedPositionID = Integer.Parse(sender.Tag) + Chart1.Series.Clear() + LabelDesc.Text = "Results as of: " & LastRefresh.ToString("hh:mm:ss tt") + + For Each item In Candidates(SelectedPositionID) + Dim vote = GetVoteCount(item.PositionID, item.ID) + + Dim seriesItem = New Series() + Dim nPoint As New DataPoint() + nPoint.SetValueY(vote) + seriesItem.Name = item.Fullname + seriesItem.Points.Add(nPoint) + Chart1.Series.Add(seriesItem) + Next + + 'Di ko sure kung para san to + 'pero may bug sa display ng chart + 'pag wala to eh + Chart1.ResetAutoValues() + + End Sub + + Private Function GetVoteCount(PositionID As Integer, CandidateID As Integer) As Integer + Dim Result = 0 + If Results.ContainsKey(PositionID) AndAlso Results(PositionID).ContainsKey(CandidateID) Then + Result = Results(PositionID)(CandidateID) + End If + Return Result + End Function + +End Class diff --git a/Voting-SystemVB/VotersPanel.Designer.vb b/Voting-SystemVB/VotersPanel.Designer.vb index d2561cb..58edcd6 100644 --- a/Voting-SystemVB/VotersPanel.Designer.vb +++ b/Voting-SystemVB/VotersPanel.Designer.vb @@ -30,7 +30,7 @@ Partial Class VotersPanel Me.ButtonParty = New Guna.UI2.WinForms.Guna2Button() Me.ButtonVoteNow = New Guna.UI2.WinForms.Guna2Button() Me.ButtonVoteInfo = New Guna.UI2.WinForms.Guna2Button() - Me.Guna2Button4 = New Guna.UI2.WinForms.Guna2Button() + Me.ButtonVoteCount = New Guna.UI2.WinForms.Guna2Button() Me.ButtonLogout = New Guna.UI2.WinForms.Guna2Button() Me.Panel2 = New System.Windows.Forms.Panel() Me.Label1 = New System.Windows.Forms.Label() @@ -81,7 +81,7 @@ Partial Class VotersPanel Me.SideBarButton.Controls.Add(Me.ButtonParty) Me.SideBarButton.Controls.Add(Me.ButtonVoteNow) Me.SideBarButton.Controls.Add(Me.ButtonVoteInfo) - Me.SideBarButton.Controls.Add(Me.Guna2Button4) + Me.SideBarButton.Controls.Add(Me.ButtonVoteCount) Me.SideBarButton.Controls.Add(Me.ButtonLogout) Me.SideBarButton.Location = New System.Drawing.Point(5, 144) Me.SideBarButton.Name = "SideBarButton" @@ -168,25 +168,25 @@ Partial Class VotersPanel Me.ButtonVoteInfo.Tag = "4" Me.ButtonVoteInfo.Text = "VOTE INFO" ' - 'Guna2Button4 + 'ButtonVoteCount ' - Me.Guna2Button4.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Me.ButtonVoteCount.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.Guna2Button4.Animated = True - Me.Guna2Button4.CheckedState.Parent = Me.Guna2Button4 - Me.Guna2Button4.CustomImages.Parent = Me.Guna2Button4 - Me.Guna2Button4.FillColor = System.Drawing.Color.FromArgb(CType(CType(46, Byte), Integer), CType(CType(43, Byte), Integer), CType(CType(63, Byte), Integer)) - Me.Guna2Button4.Font = New System.Drawing.Font("Segoe UI", 9.0!) - Me.Guna2Button4.ForeColor = System.Drawing.SystemColors.ControlDark - Me.Guna2Button4.HoverState.Parent = Me.Guna2Button4 - Me.Guna2Button4.Location = New System.Drawing.Point(0, 160) - Me.Guna2Button4.Margin = New System.Windows.Forms.Padding(0) - Me.Guna2Button4.Name = "Guna2Button4" - Me.Guna2Button4.ShadowDecoration.Parent = Me.Guna2Button4 - Me.Guna2Button4.Size = New System.Drawing.Size(220, 40) - Me.Guna2Button4.TabIndex = 3 - Me.Guna2Button4.Tag = "5" - Me.Guna2Button4.Text = "CURRENT VOTE COUNT" + Me.ButtonVoteCount.Animated = True + Me.ButtonVoteCount.CheckedState.Parent = Me.ButtonVoteCount + Me.ButtonVoteCount.CustomImages.Parent = Me.ButtonVoteCount + Me.ButtonVoteCount.FillColor = System.Drawing.Color.FromArgb(CType(CType(46, Byte), Integer), CType(CType(43, Byte), Integer), CType(CType(63, Byte), Integer)) + Me.ButtonVoteCount.Font = New System.Drawing.Font("Segoe UI", 9.0!) + Me.ButtonVoteCount.ForeColor = System.Drawing.SystemColors.ControlDark + Me.ButtonVoteCount.HoverState.Parent = Me.ButtonVoteCount + Me.ButtonVoteCount.Location = New System.Drawing.Point(0, 160) + Me.ButtonVoteCount.Margin = New System.Windows.Forms.Padding(0) + Me.ButtonVoteCount.Name = "ButtonVoteCount" + Me.ButtonVoteCount.ShadowDecoration.Parent = Me.ButtonVoteCount + Me.ButtonVoteCount.Size = New System.Drawing.Size(220, 40) + Me.ButtonVoteCount.TabIndex = 3 + Me.ButtonVoteCount.Tag = "5" + Me.ButtonVoteCount.Text = "CURRENT VOTE COUNT" ' 'ButtonLogout ' @@ -419,7 +419,7 @@ Partial Class VotersPanel Friend WithEvents ButtonParty As Guna.UI2.WinForms.Guna2Button Friend WithEvents ButtonVoteNow As Guna.UI2.WinForms.Guna2Button Friend WithEvents ButtonVoteInfo As Guna.UI2.WinForms.Guna2Button - Friend WithEvents Guna2Button4 As Guna.UI2.WinForms.Guna2Button + Friend WithEvents ButtonVoteCount As Guna.UI2.WinForms.Guna2Button Friend WithEvents ButtonLogout As Guna.UI2.WinForms.Guna2Button Friend WithEvents Panel2 As System.Windows.Forms.Panel Friend WithEvents Label1 As System.Windows.Forms.Label diff --git a/Voting-SystemVB/VotersPanel.vb b/Voting-SystemVB/VotersPanel.vb index b64f43a..45fc5e1 100644 --- a/Voting-SystemVB/VotersPanel.vb +++ b/Voting-SystemVB/VotersPanel.vb @@ -56,7 +56,7 @@ Public Class VotersPanel End If End Sub - Private Sub MainButton_Click(sender As Guna2Button, e As EventArgs) Handles ButtonCandidate.Click, ButtonParty.Click, ButtonVoteNow.Click, ButtonVoteInfo.Click + Private Sub MainButton_Click(sender As Guna2Button, e As EventArgs) Handles ButtonCandidate.Click, ButtonParty.Click, ButtonVoteNow.Click, ButtonVoteInfo.Click, ButtonVoteCount.Click Dim tag As Integer = Integer.Parse(sender.Tag) 'If sender.Equals(SelectedButton) Then Return @@ -76,6 +76,8 @@ Public Class VotersPanel LoadControl(VoteNow.GetInstance()) Case 4 LoadControl(VoteInfo.GetInstance()) + Case 5 + LoadControl(VoteCount.GetInstance()) End Select End Sub diff --git a/Voting-SystemVB/Voting-SystemVB.vbproj b/Voting-SystemVB/Voting-SystemVB.vbproj index 799f4fb..82d3b26 100644 --- a/Voting-SystemVB/Voting-SystemVB.vbproj +++ b/Voting-SystemVB/Voting-SystemVB.vbproj @@ -380,6 +380,12 @@ UserControl + + VoteCount.vb + + + UserControl + VoteInfo.vb @@ -526,6 +532,9 @@ PartyInfo.vb + + VoteCount.vb + VoteInfo.vb