private void FrmVoteWithPincs_Load(object sender, EventArgs e) { #region Populate the Candidate List var candidateList = LoadElection.ElectionList(); var list = candidateList.First(x => x.CandidatePin == CandidatePin); lblCandidatePin.Text = list.CandidatePin; lblFullname.Text = list.Firstname + " " + list.Lastname; lblPhonenumber.Text = list.Phonenumber; lblEmail.Text = list.Email; //lblManifesto.Text = list.Manifesto; Text = list.Post; var data = list.Img; var ms = new MemoryStream(data); picImage.Image = Image.FromStream(ms); #endregion #region Populating the Voters List string msg = ""; var voter = new VoterRegistration(); var getVoter = new Voters(); getVoter = voter.SearchVoters(VoterPin, out msg); lblVoterPin.Text = getVoter.VoterPin; lblVoterFullname.Text = getVoter.Firstname + @" " + getVoter.Lastname; lblVoterEmail.Text = getVoter.Email; picVoterImg.Image = getVoter.VoterImg; #endregion }
private void btnView_Click(object sender, EventArgs e) { if (cmbPost.SelectedIndex != -1) { grdCandidate.Rows.Clear(); var loadElection = LoadElection.ElectionList(); var selectedCandidates = loadElection.Where(x => x.Post == cmbPost.Text).ToList(); candidates = selectedCandidates; foreach (var candidate in candidates) { int n = grdCandidate.Rows.Add(); grdCandidate.Rows[n].Cells[0].Value = candidate.CandidatePin.ToUpper(); grdCandidate.Rows[n].Cells[1].Value = candidate.Firstname.ToUpper(); grdCandidate.Rows[n].Cells[2].Value = candidate.Lastname.ToUpper(); grdCandidate.Rows[n].Cells[3].Value = candidate.Email; } } }
private void cmbElectionId_SelectedIndexChanged(object sender, EventArgs e) { //var noOfCandidates = // _electionList.Where(x => x.Post == cmbElectionId.Text).Select(x => x.NoOfCandidates).First(); var loadElection = LoadElection.ElectionList(); var selectedCandidates = loadElection.Where(x => x.Post == cmbElectionId.Text).ToList(); candidates = selectedCandidates; var countCnd = selectedCandidates.Count; var metroLinks = new List <MetroLink> { linkLabel4, linkLabel3, linkLabel2, linkLabel1 }; #region LotsOfLogic if (countCnd == 0) { radioButton1.Visible = false; radioButton2.Visible = false; radioButton3.Visible = false; radioButton4.Visible = false; linkLabel4.Visible = false; linkLabel3.Visible = false; linkLabel2.Visible = false; linkLabel1.Visible = false; } else if (countCnd == 1) { int counter = 0; foreach (var radio in from object control in metroPanel.Controls select control as MetroRadioButton) { if (radio != null) { radio.Text = selectedCandidates[counter].Fullname; metroLinks[counter].Text = selectedCandidates[counter].CandidatePin; counter++; } if (counter != countCnd) { continue; } break; } radioButton2.Visible = false; radioButton3.Visible = false; radioButton1.Visible = false; radioButton4.Visible = true; linkLabel3.Visible = false; linkLabel2.Visible = false; linkLabel1.Visible = false; linkLabel4.Visible = true; } else if (countCnd == 2) { int counter = 0; foreach (var radio in from object control in metroPanel.Controls select control as MetroRadioButton) { if (radio != null) { radio.Text = selectedCandidates[counter].Fullname; metroLinks[counter].Text = selectedCandidates[counter].CandidatePin; counter++; } if (counter != countCnd) { continue; } break; } radioButton1.Visible = true; radioButton4.Visible = true; radioButton2.Visible = false; radioButton3.Visible = false; linkLabel2.Visible = false; linkLabel1.Visible = false; linkLabel4.Visible = true; linkLabel3.Visible = true; } else if (countCnd == 3) { int counter = 0; foreach (var control in metroPanel.Controls) { var radio = control as MetroRadioButton; if (radio != null) { radio.Text = selectedCandidates[counter].Fullname; metroLinks[counter].Text = selectedCandidates[counter].CandidatePin; counter++; } if (counter != countCnd) { continue; } break; } radioButton1.Visible = true; radioButton2.Visible = true; radioButton4.Visible = true; radioButton3.Visible = false; linkLabel1.Visible = false; linkLabel2.Visible = true; linkLabel3.Visible = true; linkLabel4.Visible = true; } else if (countCnd == 4) { int counter = 0; foreach (var radio in from object control in metroPanel.Controls select control as MetroRadioButton) { if (radio != null) { radio.Text = selectedCandidates[counter].Fullname; metroLinks[counter].Text = selectedCandidates[counter].CandidatePin; counter++; } if (counter != countCnd) { continue; } break; } radioButton1.Visible = true; radioButton2.Visible = true; radioButton4.Visible = true; radioButton3.Visible = true; linkLabel1.Visible = true; linkLabel2.Visible = true; linkLabel3.Visible = true; linkLabel4.Visible = true; } #endregion #region CodeNeedToChange //switch (noOfCandidates) //{ // case 2: // radioButton3.Visible = false; // radioButton4.Visible = false; // linkLabel3.Visible = false; // linkLabel4.Visible = false; // break; // case 3: // radioButton4.Visible = false; // linkLabel4.Visible = false; // radioButton3.Visible = true; // linkLabel3.Visible = true; // break; //} //if (selectedCandidates.Count == 2) //{ // radios[0].Text = selectedCandidates[0].Fullname; // radios[1].Text = selectedCandidates[1].Fullname; //} //else if (selectedCandidates.Count == 3) //{ // radios[0].Text = selectedCandidates[0].Fullname; // radios[1].Text = selectedCandidates[1].Fullname; // radios[2].Text = selectedCandidates[2].Fullname; //} //else if (selectedCandidates.Count == 4) //{ // radios[0].Text = selectedCandidates[0].Fullname; // radios[1].Text = selectedCandidates[1].Fullname; // radios[2].Text = selectedCandidates[2].Fullname; // radios[3].Text = selectedCandidates[3].Fullname; //} #endregion metroPanel.Visible = true; radioButton4.Checked = false; radioButton3.Checked = false; radioButton2.Checked = false; radioButton1.Checked = false; btnCastVote.Enabled = false; }