Esempio n. 1
0
 private void button2_Click(object sender, EventArgs e)
 {
     BrukerLogin();
     if (Values.User1LoggedIn || Values.User2LoggedIn || Values.User3LoggedIn)
     {
         this.Hide();
         UserLoggedIn UserWindow = new UserLoggedIn();
         UserWindow.Show();
     }
 }
Esempio n. 2
0
        private void btn_LogIn_Click(object sender, EventArgs e)
        {
            Data1 ReadFile = new Data1();

            ReadFile.readFile();
            StopWhile = false;//This is fine because this only happends when the button is pressed, and the while statement does not run here.
            int i = 0;

            while (i < ReadFile.UserFileStringArray.Length && !StopWhile)
            {
                if (ReadFile.UserFileStringArray[i] == txtbBrukernavn.Text)
                {
                    ReadFile.UserLine = i;
                    StopWhile         = true;
                }
                i = i + 2;
            }
            if (txtbBrukernavn.Text == "" || txtbPassord.Text == "")
            {
                MessageBox.Show("Vennligst skriv inn Brukernavn og Passord");
                return;
            }

            if (ReadFile.UserFileStringArray[ReadFile.UserLine] != txtbBrukernavn.Text || ReadFile.UserFileStringArray[ReadFile.UserLine + 1] != txtbPassord.Text)
            {
                MessageBox.Show("Feil brukernavn og/eller passord");
            }

            else if (ReadFile.UserFileStringArray[ReadFile.UserLine] == txtbBrukernavn.Text && ReadFile.UserFileStringArray[ReadFile.UserLine + 1] == txtbPassord.Text)
            {
                MessageBox.Show("Du er nå logget inn, " + ReadFile.UserFileStringArray[ReadFile.UserLine]);
                File.WriteAllText("CurrentUserLoggedIn.txt", txtbBrukernavn.Text);
                StringCurrentUser = txtbBrukernavn.Text;
                UserLoggedIn open = new UserLoggedIn();
                this.Hide();
                open.ShowDialog();
            }
        }