Esempio n. 1
0
        public void create()
        {
            FileStream   fs = null;
            StreamWriter sw = null;

            try
            {
                fs = new FileStream("userdata.txt", FileMode.Append, FileAccess.Write);
                sw = new StreamWriter(fs);
                CAuth auth = new CAuth();
                sw.WriteLine(this.name + ";" + auth.cryptPassword(this.password));
                MessageBox.Show("Benutzer angelegt, Sie können sich jetzt anmelden", "Erfolg", MessageBoxButtons.OK);
            }
            catch (FileNotFoundException ex)
            {
                MessageBox.Show(ex.Message, "Fehler", MessageBoxButtons.OK);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Fehler", MessageBoxButtons.OK);
            }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                }
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }
Esempio n. 2
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            CAuth user = new CAuth(userName.Text, userPassword.Text);

            user.auth();

            if (user.Authed)
            {
                Main main = new Main();
                main.Show();
            }
            else
            {
                MessageBox.Show("Benutzer nicht gefunden", "Fehler", MessageBoxButtons.OK);
            }
        }