private void btnLogin_Click(object sender, EventArgs e) { //using if else statements to give nstrutions on what the user has selected and requests password and name to login if (cbUser.SelectedIndex == 0 && tbName.Text.Equals("Login") && tbPassword.Text.Equals("12345678")) { //opening another form FrmTestSetup fts = new FrmTestSetup(); this.Hide(); fts.Show(); } else { //else statement and boolean for incorrect statements entered bool found = false; int x = 0; string[,] array = fu.getStudentList(); //using a while loop for statements that found true the loop can execue while (x < 5 && found == false) { //using an array that has 3 columns if (array[x, 1].Equals(tbName.Text) && array[x, 3].Equals(tbPassword.Text)) { // taking information from the class and the file found = true; //opening another form frmTakeTest ftt = new frmTakeTest(x, array); this.Hide(); ftt.Show(); } x++; } //ef else statements to display message if anythhing found false if (found == false) { MessageBox.Show("was not able to match name and password "); } } }
public FrmReport() { InitializeComponent(); back = 0; FileUser file = new FileUser(); string[,] array = file.getStudentList(); double average = 0, highest = 0, lowest = 100; a.Items.Add("Student number"); b.Items.Add("Student Name"); c.Items.Add("Student Marks"); a.Items.Add("----------------"); b.Items.Add("----------------"); c.Items.Add("----------------"); for (int x = 0; x < 6; ++x) { average += Double.Parse(array[x, 2]); if (highest < Double.Parse(array[x, 2])) { highest = Double.Parse(array[x, 2]);; } if (lowest > Double.Parse(array[x, 2])) { lowest = Double.Parse(array[x, 2]); } a.Items.Add(array[x, 0]); b.Items.Add(array[x, 1]); c.Items.Add(array[x, 2]); } average = average / 5; Report.Items.Add("Aveage: " + average); Report.Items.Add("Highest " + highest); Report.Items.Add("Lowest " + lowest); }