コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            StockDbContext db        = new StockDbContext();
            string         toCheck   = StockUtility.SHA256Hash(textBox1.Text);
            var            userQuery = db.Users.Where(u => u.HashedUsername == toCheck);

            try
            {
                if (textBox1.Text != "" && textBox2.Text != "")
                {
                    User user = userQuery.First <User>();

                    foreach (var u in userQuery)
                    {
                        string theloginpw = u.HashedPassword;
                    }

                    if (user.HashedPassword == StockUtility.SHA256Hash(textBox2.Text))
                    {
                        DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("A felhasználónév vagy jelszó nem megfelelő!", "Hiba", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        DialogResult = DialogResult.None;
                    }
                }
                else
                {
                    MessageBox.Show("Nincs kivel belépni!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                DialogResult = DialogResult.None;
                throw;
            }

            /*MessageBox.Show(user.ToString());
             * foreach (var u in user)
             * {
             *  MessageBox.Show(u.Username + " - " + u.Id.ToString() + " - " + u.HashedPassword.ToString() + " - " + u.Type.ToString());
             * }
             */
        }
コード例 #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != "" && textBox2.Text != "")
     {
         try
         {
             User           justRegistered = new User(textBox3.Text, StockUtility.SHA256Hash(textBox1.Text), StockUtility.SHA256Hash(textBox2.Text), checkBox1.Checked, checkBox2.Checked);
             StockDbContext db             = new StockDbContext();
             db.Users.Add(justRegistered);
             db.SaveChanges();
             this.Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message + " valamint minden mező kitöltése kötelező!", "Hiba", MessageBoxButtons.OK, MessageBoxIcon.Error);
             DialogResult = DialogResult.None;
         }
     }
     else
     {
         MessageBox.Show("A jelszónak legalább 1 karakter hosszúnak kell lennie", "Hiba", MessageBoxButtons.OK, MessageBoxIcon.Error);
         DialogResult = DialogResult.None;
     }
 }