public Dashboard(HEALTHCARE_PERSONNEL user) { InitializeComponent(); this.user = user; username.Content = this.user.email; date.Content = DateTime.Now; Dashboard_Load(); }
private void okButton_Click(object sender, RoutedEventArgs e) { //define variables int asciiVal; string strPassword, strUsername; //obtain username from textbox strUsername = nameTextBox.Text.ToString(); //obtain password from passwordtextbox strPassword = passwordTextBox.Password; //check to see if username or password are empty, request them to be filled if (String.IsNullOrEmpty(strUsername) || String.IsNullOrEmpty(strPassword)) { MessageBox.Show("Please fill in all slots"); return; } //convert string password to charArray char[] arrPassword = strPassword.ToCharArray(); //convert the first password character to an ascii value asciiVal = Convert.ToInt32(arrPassword[0]); //check to see if the first letter of the password is amongst the alphabet (capitalized and non-capitalized) if (!((asciiVal <= 90 && asciiVal >= 65) || (asciiVal <= 122 && asciiVal >= 97))) { MessageBox.Show("The password must start with a letter"); return; } //obtain password length int passLen = strPassword.Length; //loop through password array for (int loopcounter = 0; loopcounter < passLen; loopcounter++) { //check if password contains illegal characters if (!Char.IsLetterOrDigit(arrPassword[loopcounter])) { MessageBox.Show("The password can not contain characters other than letters and numbers"); return; } } //check to see if password is at least 6 characters or greater if (passLen < 6) { MessageBox.Show("A valid password needs to have at least six characters with both letters and numbers."); return; } //password passed all checks, is a valid password var userData = new HEALTHCARE_PERSONNEL(); if (userData.Login(strUsername, strPassword) == true) { MessageBox.Show("You are logged in as User #" + userData.empid); this.Hide(); nameTextBox.Clear(); passwordTextBox.Clear(); Dashboard dash = new Dashboard(userData); dash.Owner = this; dash.ShowDialog(); this.Show(); } else { MessageBox.Show("You could not be verified. Please try again."); } }