示例#1
0
        private void AdminLabel_Click(object sender, EventArgs e)
        {
            ActiveForm.Hide();
            EnterAdmin enterAdmin = new EnterAdmin();

            enterAdmin.ShowDialog();
            Close();
        }
示例#2
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            String loginField = LoginTextBox.Text;
            String passField  = PasswordTextBox.Text;

            byte[] data = System.Text.Encoding.ASCII.GetBytes(passField);
            data = new System.Security.Cryptography.SHA256Managed().ComputeHash(data);
            String hash = System.Text.Encoding.ASCII.GetString(data);

            OpenConnection(ConnectionString);
            int res = AuthAdmin(connect, loginField, hash);

            CloseConnection();

            if (res == 1)
            {
                ActiveForm.Hide();
                AdminForm adminForm = new AdminForm();
                adminForm.ShowDialog();
                Close();
            }
            else if (res == 0)
            {
                DialogResult msg = MessageBox.Show("Invalid password or login\nPlease, try again or return to the main menu", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (msg == DialogResult.Yes)
                {
                    ActiveForm.Hide();
                    EnterAdmin enterAdmin = new EnterAdmin();
                    enterAdmin.ShowDialog();
                    Close();
                }
                else if (msg == DialogResult.No)
                {
                    ActiveForm.Hide();
                    Security security = new Security();
                    security.ShowDialog();
                    Close();
                }
            }
        }