Exemplo n.º 1
0
        private void bWeiter_Click(object sender, EventArgs e)
        {
            if (tBEmail.Text == "")
            {
                MessageBox.Show("Geben sie ein EMail-Adresse ein");
                return;
            }
            if (tBPasswort1.Text == "")
            {
                MessageBox.Show("Geben sie ein Passwort ein");
                return;
            }
            if (tBPasswort2.Text == "")
            {
                MessageBox.Show("Bitte Bestätigen sie ihr Passwort");
                return;
            }
            if (tBAdresse.Text == "")
            {
                MessageBox.Show("Geben sie ihre Adresse ein");
                return;
            }
            if (tBPasswort1.Text != tBPasswort2.Text)
            {
                MessageBox.Show("Passwörter stimmen nicht überrein.");
                return;
            }
            //sql connection and insert into
            string        connetionString = null;
            SqlConnection connection;
            SqlCommand    command;
            string        sql = null;

            connetionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\timos\Source\Repos\eBibliothek2\e-Bibliothek\e-Bibliothek\Database1.mdf;Integrated Security=True";
            // Create a new Benutzer object.
            Benutzer b1 = new Benutzer(tBEmail.Text, tBPasswort2.Text, dateTimePicker1.Value, tBAdresse.Text);

            //insert into
            sql        = String.Format("INSERT INTO Benutzer (BenutzerName, PassWd, BDate, Adresse) VALUES('{0}', '{1}', '{2}', '{3}'); ", b1.BenutzerName, b1.PassWD, b1.BDate, b1.Adresse);
            connection = new SqlConnection(connetionString);

            try
            {
                connection.Open();
                command = new SqlCommand(sql, connection);

                command.ExecuteNonQuery();
                //command.Dispose();
                connection.Close();
            }
            catch (Exception z)
            {
                MessageBox.Show("Can not open connection ! " + z);
            }

            LobbyForm lf = new LobbyForm();

            lf.Show();
            this.Hide();
        }
Exemplo n.º 2
0
        private void bLogin_Click(object sender, EventArgs e)
        {
            var sha1       = System.Security.Cryptography.SHA1.Create();
            var inputBytes = Encoding.ASCII.GetBytes(tBPasswd.Text);
            var hash       = sha1.ComputeHash(inputBytes);

            var sb = new StringBuilder();

            for (var i = 0; i < hash.Length; i++)
            {
                sb.Append(hash[i].ToString("X2"));
            }

            string passWDHash = sb.ToString();

            if (attempt == 0)
            {
                MessageBox.Show("All 3 attempts have failed");
                return;
            }

            SqlConnection scn = new SqlConnection();

            scn.ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\timos\Source\Repos\eBibliothek2\e-Bibliothek\e-Bibliothek\Database1.mdf;Integrated Security=True";
            SqlCommand scmd = new SqlCommand("select count (*) as cnt from Benutzer where BenutzerName=@usr and PassWD=@pwd", scn);

            scmd.Parameters.Clear();
            scmd.Parameters.AddWithValue("@usr", tBUserN.Text);
            scmd.Parameters.AddWithValue("@pwd", passWDHash);
            scn.Open();

            if (scmd.ExecuteScalar().ToString() == "1")
            {
                LobbyForm lf = new LobbyForm();
                lf.Show();
                this.Hide();
            }

            else
            {
                MessageBox.Show("YOU ARE NOT GRANTED WITH ACCESS");
                MessageBox.Show("You Have Only " + Convert.ToString(attempt) + " Attempt Left To Try");
                --attempt;
                tBUserN.Clear();
                tBPasswd.Clear();
            }
            scn.Close();
        }
Exemplo n.º 3
0
 private void btnBack_Click(object sender, EventArgs e)
 {
     LobbyForm lf = new LobbyForm();
     lf.Show();
     this.Hide();
 }