private void logoutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult ans = MessageBox.Show("Do you Want to Logout?", "Confirmation", MessageBoxButtons.YesNo);

            if (ans == DialogResult.Yes)
            {
                MessageBox.Show("You are Successfully Logout please add Username AND password to Login!");
                Login formLogin = new Login();
                formLogin.Show(this);
                this.Hide();
            }

            else
            {
                Librarymdiparent mdiparent = new Librarymdiparent();
                mdiparent.Show();
                this.Hide();
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string username, password;

            username = textBox1.Text;
            password = textBox2.Text;
            con.Open();
            OleDbCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from Admin where username = '******' and password = '******'";
            OleDbDataReader reader = cmd.ExecuteReader();

            int count = 0;

            while (reader.Read())
            {
                count = count + 1;
            }
            //Checking If the Admins username and password is unique or not  in the database
            if (count == 1)
            {
                MessageBox.Show("You are successfully Logged in");
                Librarymdiparent mdiparent = new Librarymdiparent();
                mdiparent.Show();
                this.Hide();
            }
            //If username and password is more than 1 then
            if (count > 1)
            {
                MessageBox.Show("Can't be duplicate Admin");
            }
            else
            {
                MessageBox.Show("Username and password is incorrect");
            }
            con.Close();
        }