// Event handlers private void LoginHandler(object sender, EventArgs e) { UserModel user = RentACarLibrary.GlobalConfig.UserModelConnection.GetByUsername(view.Username); if (user == null) { AlertMessage am = new AlertMessage(AlertMessage.MessageType.Error, Messages.ErrorUserDoesntExist(view.Username)); view.ShowAlertMessage(am); view.SetControlFocus("Username"); return; } if (user.Password != view.Password) { AlertMessage am = new AlertMessage(AlertMessage.MessageType.Error, Messages.ERROR_WRONG_PASSWORD); view.ShowAlertMessage(am); view.SetControlFocus("Password"); return; } bool isAdmin = (user is AdminModel) ? true : false; RentACarLibrary.SessionData.LogUserIn(user); view.LoginSuccess(); view.ClearAllControls(); }