Exemplo n.º 1
0
 /// <summary>
 ///     Handles the login - looks big, but is mainly validation
 /// </summary>
 private void btnLogin_Click(object sender, EventArgs e)
 {
     // Sets a waitcursor
     Cursor.Current = Cursors.WaitCursor;
     // Initialises the id to 0
     int id = 0;
     string stuteach;
     // Checks for empty fields
     if (txtPass.Text == "" || txtUser.Text == "")
     {
         MessageBox.Show("Please enter a Username/Password", "Invalid Login",
             MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return;
     }
     // Checks that the user id is in the correct format
     try
     {
         id = Convert.ToInt16(txtUser.Text);
     }
     catch
     {
         MessageBox.Show("Username is in an invalid format", "Invalid Login",
             MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return;
     }
     // Sets stuteach
     if (studentLogin.Checked)
     {
         stuteach = "students";
     }
     else
     {
         stuteach = "teachers";
     }
     // If the account info is valid then handle the student/teacher opening
     if (AccountControl.checkAccount(id, txtPass.Text, stuteach) == true)
     {
         if (stuteach == "students")
         {
             Student stu = new Student(Convert.ToInt16(txtUser.Text));
             stu.Show();
             this.Hide();
         }
         else
         {
             Teacher teach = new Teacher(id);
             teach.Show();
             this.Hide();
         }
     }
     else
     {
         MessageBox.Show("The User ID or password was incorrect, please try again.",
             "Invalid Login",
             MessageBoxButtons.OK,
             MessageBoxIcon.Exclamation);
     }
     Cursor.Current = Cursors.Default;
 }
Exemplo n.º 2
0
 public void StudentConstructorTest()
 {
     int stuid = 0; // TODO: Initialize to an appropriate value
     Student target = new Student(stuid);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
Exemplo n.º 3
0
 public void levDistanceTest()
 {
     int stuid = 0; // TODO: Initialize to an appropriate value
     Student target = new Student(stuid); // TODO: Initialize to an appropriate value
     string s = string.Empty; // TODO: Initialize to an appropriate value
     int s_len = 0; // TODO: Initialize to an appropriate value
     string t = string.Empty; // TODO: Initialize to an appropriate value
     int t_len = 0; // TODO: Initialize to an appropriate value
     int expected = 0; // TODO: Initialize to an appropriate value
     int actual;
     actual = target.levDistance(s, s_len, t, t_len);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }