Beispiel #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (Usuario != "ADMIN" || Contraseña != "admin1234")
     {
         MDIParent1 obj = new MDIParent1();
         obj.Show();
     }
     else
     {
         Application.Exit();
     }
 }
Beispiel #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection();

            con.ConnectionString = @"Data Source=SAJID-PC\SQLEXPRESS;Initial Catalog=Library_Management;Integrated Security=True;Pooling=False";
            con.Open();
            SqlCommand     cmd = new SqlCommand("select * from library_person where userName='******'and password='******'", con);
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            DataTable      dt  = new DataTable();

            da.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                MDIParent1 md = new MDIParent1();
                this.Hide();
                md.Show();
            }
            else
            {
                MessageBox.Show("Invalid Login please check username and password");
            }
            con.Close();
        }
Beispiel #3
0
        private void 帮助ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form m1 = new MDIParent1();

            m1.Show();
        }
        private void performLogin()
        {
            if ((usernameTb.TextLength == 0) || (passwordTb.TextLength == 0))
            {
                MessageBox.Show("Please Fill All Blanks");
                return;
            }

            if (checkUserExists())
            {
                String password = passwordTb.Text;
                byte[] salt = shg.generateSalt(saltByteSize);
                byte[] hash = shg.generateHash(password, salt, hashingIterations, hashByteSize);

                String finalHash = Convert.ToBase64String(salt) + ":" + Convert.ToBase64String(hash);
                var dbPassword = getDBPassword();

                if (checkPasswordsMatch(password, dbPassword))
                {
                    MessageBox.Show("Access Granted");
                    String username = usernameTb.Text;
                    String query = "SELECT * FROM useraccounts WHERE Username='******'";
                    String[] userDetails = crud.getRecordRowDetails(stringconn, query, 4);
                    bool hasPermission = bool.Parse(userDetails[3]);
                    if (hasPermission)
                    {
                        MDIParent1 mdiparent = new MDIParent1();
                        mdiparent.Show();
                        this.Hide();
                    }
                }
                else
                {
                    MessageBox.Show("Access Denied");
                }
            }
            else
            {
                MessageBox.Show("User does not exist");
            }
        }