示例#1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string username = txtUsername.Text;
            string password = txtPassword.Text;

            var ad      = new AccountsData();
            var sd      = new StaffData();
            var message = new UserMessage();

            bool allInputsValid = ValidateInputs(username, password);        //check all users inputs are valid
            var  accountInfo    = ad.GetAccountPassword(username, password); //get account password from database
            bool passwordMatch  = accountInfo.Item1;                         //return if passwords matched between input and hashed stored password

            Int32.TryParse(accountInfo.Item2, out var staffId);              //get the staffs id that's trying to log in

            if (allInputsValid && passwordMatch)
            {
                //if everything's valid, get all that staffs information, store in a data structure
                var staff = sd.GetStaffInformation(staffId, username, password);
                //reset login data and hide login component
                SetupTextBoxes();
                Hide();
                //bring the logged in menu up, user is now logged in
                var menuInterface = new MenuInterface(staff, this);
                menuInterface.ShowDialog();
            }
            else if (allInputsValid)
            {
                message.Show("Your password does not match the password we have stored for your account.");
            }
        }
示例#2
0
 //temp function for fast login when testing components during development
 public void TempStaffSetupFastLogin()
 {
     try
     {
         var staff = new StaffAccounts("Jesse", "Harasym", "admin", "admin123", "*****@*****.**", "Administrator",
                                       1,
                                       10);
         var cs = new MenuInterface(staff, this);
         cs.ShowDialog();
     }
     catch (Exception ex)
     {
         Console.WriteLine("Something went wrong with fast login " + ex);
     }
 }