예제 #1
0
 /// <summary>
 /// Function called by login_button when clicked, handles login by:
 /// 1. Querying Database for matching username and password and selecting record.
 /// 2.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void login_button_Click(object sender, EventArgs e)
 {
     //check if fields are filled
     if (!(string.IsNullOrEmpty(user_id_box.Text) && string.IsNullOrEmpty(password_box.Text)))
     {
         //verify username and password
         using (var db = new Session1Entities1())
         {
             var user = (from u in db.Users
                         where u.userId == user_id_box.Text
                         where u.userPw == password_box.Text
                         select new { u, u.User_Type.userTypeId }).ToList();
             //if count of users in the list is not zero, user exists.
             if (user.Count() > 0 && user.First().userTypeId == 2)
             {
                 //username and password auth successful.
                 //launch next form
                 this.Hide();
                 var RMF = new ResourceManagementForm();
                 RMF.Closed += (s, args) => this.Close();
                 RMF.Show();
             }
             else
             {
                 MessageBox.Show("Invalid Username, Password or Unauthorised Access, this incident will be reported.");
             }
         }
     }
     else
     {
         MessageBox.Show("One or more fields are empty!!");
     }
 }
예제 #2
0
        private void back_button_Click(object sender, EventArgs e)
        {
            this.Hide();
            var RMF = new ResourceManagementForm();

            RMF.Closed += (s, args) => this.Close();
            RMF.Show();
        }