public VotingFormMainUI() { InitializeComponent(); String localLocation = Directory.GetCurrentDirectory(); string readText = File.ReadAllText(localLocation + "\\settingsFile.db"); string readCode = File.ReadAllText(localLocation + "\\VotingSettings\\" + readText + "\\vote.db"); String[] values = mb.Decrypt(readCode).Split('♥'); label1.Text = values[0]; label2.Text = values[1]; label3.Text = values[2]; label5.Text = values[3]; }
public void loadResults() { String localLocation = Directory.GetCurrentDirectory() + "\\Results"; string[] files = Directory.GetFiles(localLocation); foreach (string file in files) { resultBox.Text += (Path.GetFileName(file)); String location = localLocation + "\\" + file + ".db"; string readText = File.ReadAllText(localLocation + "//Results//" + file + ".db"); resultBox.Text += "\t" + mb.Decrypt(readText) + "\n"; } }
public NominateForm() { InitializeComponent(); String localLocation = Directory.GetCurrentDirectory(); string readText = File.ReadAllText(localLocation + "\\settingsFile.db"); string readCode = File.ReadAllText(localLocation + "\\VotingSettings\\" + readText + "\\reg.db"); String[] values = mb.Decrypt(readCode).Split('♥'); Nm.Text = values[0]; surN.Text = values[1]; GV.Text = values[2]; IDE.Text = values[3]; ELI.Text = values[4]; GEN.Text = values[5]; }
private void button1_Click(object sender, EventArgs e) { mainBackend mb = new mainBackend(); String localLocation = Directory.GetCurrentDirectory() + "//Registrations"; if (String.IsNullOrEmpty(nameVal.Text)) { ; } { bool found = false; String userName = nameVal.Text + " " + surnameVal.Text; String locatedFile = ""; string[] files = new DirectoryInfo(localLocation).GetFiles().Select(o => o.Name).ToArray(); for (int i = 0; i < files.Length; i++) { String nameTest = files[i].Substring(0, files[i].Length - 3); if (userName.ToLower().Equals(nameTest.ToLower())) { found = true; localLocation = localLocation + "//" + nameTest + ".db"; break; } } if (found == true) { string text = System.IO.File.ReadAllText(localLocation); string[] datafile = mb.Decrypt(text).Split('♥'); if (datafile[4].Equals("Vote") || datafile[4].Equals("Both")) { if (datafile[3].Equals(idVal.Text.ToString().Trim())) { using (StreamWriter writetext = new StreamWriter("temp.db")) { writetext.WriteLine(text); } MainVotingSection mvs = new MainVotingSection(); mvs.Show(); this.Hide(); } else { MessageBox.Show("You are not authenticated to vote, Sorry!", "Error"); this.Hide(); this.Show(); } } else { MessageBox.Show("You are not allowed to vote, Sorry!" + datafile[0] + datafile[1] + datafile[2] + datafile[3] + datafile[4], "Error"); this.Hide(); this.Show(); } } else { MessageBox.Show("We didnt find you in the system, sorry about that!", "Error"); this.Hide(); this.Show(); } } }
public void loadButtons() { String localLocation = Directory.GetCurrentDirectory() + "\\Registrations"; string[] files = Directory.GetFiles(localLocation); publicText = File.ReadAllText(Directory.GetCurrentDirectory() + "\\temp.db"); List <string> buttonsToLoad = new List <string>(); for (int i = 0; i < files.Length; i++) { string readText = System.IO.File.ReadAllText(files[i]); String[] data = mb.Decrypt(readText).Split('♥'); String[] pbt = mb.Decrypt(publicText).Split('♥'); //0 - name //1 - Surname //2 - Group //3 - ID //4 - Elligable //5 - Gender if (data[2].ToLower().Equals(pbt[2].ToLower())) { buttonsToLoad.Add(mb.Decrypt(readText)); //could potentially add gender based conditioning here } } int totalToLoad = buttonsToLoad.Count; int val = 0; if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[0].Split('♥'); button1.Text = s1[1] + " " + s1[2]; } else { button1.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[1].Split('♥'); button2.Text = s1[1] + " " + s1[2]; } else { button2.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[2].Split('♥'); button3.Text = s1[1] + " " + s1[2]; } else { button3.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[3].Split('♥'); button4.Text = s1[1] + " " + s1[2]; } else { button4.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[4].Split('♥'); button5.Text = s1[1] + " " + s1[2]; } else { button5.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[5].Split('♥'); button10.Text = s1[1] + " " + s1[2]; } else { button10.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[6].Split('♥'); button9.Text = s1[1] + " " + s1[2]; } else { button9.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[7].Split('♥'); button8.Text = s1[1] + " " + s1[2]; } else { button8.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[8].Split('♥'); button7.Text = s1[1] + " " + s1[2]; } else { button7.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[9].Split('♥'); button6.Text = s1[1] + " " + s1[2]; } else { button6.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[10].Split('♥'); button15.Text = s1[1] + " " + s1[2]; } else { button15.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[11].Split('♥'); button14.Text = s1[1] + " " + s1[2]; } else { button14.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[12].Split('♥'); button13.Text = s1[1] + " " + s1[2]; } else { button13.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[13].Split('♥'); button12.Text = s1[1] + " " + s1[2]; } else { button12.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[14].Split('♥'); button11.Text = s1[1] + " " + s1[2]; } else { button11.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[15].Split('♥'); button20.Text = s1[1] + " " + s1[2]; } else { button20.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[16].Split('♥'); button19.Text = s1[1] + " " + s1[2]; } else { button19.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[17].Split('♥'); button18.Text = s1[1] + " " + s1[2]; } else { button18.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[18].Split('♥'); button17.Text = s1[1] + " " + s1[2]; } else { button17.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[19].Split('♥'); button16.Text = s1[1] + " " + s1[2]; } else { button16.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[20].Split('♥'); button25.Text = s1[1] + " " + s1[2]; } else { button25.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[21].Split('♥'); button24.Text = s1[1] + " " + s1[2]; } else { button24.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[22].Split('♥'); button23.Text = s1[1] + " " + s1[2]; } else { button23.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[23].Split('♥'); button22.Text = s1[1] + " " + s1[2]; } else { button22.Visible = false; } if (val < totalToLoad) { val++; String[] s1 = buttonsToLoad[24].Split('♥'); button21.Text = s1[1] + " " + s1[2]; } else { button21.Visible = false; } }