Ejemplo n.º 1
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            try
            {
                string          myConnection  = "datasource=localhost;port=3306;database=pharma;username=root;password="******"SELECT * FROM pharma.users WHERE username='******' and password='******' ; ", myConn);

                MySqlDataReader myReader;
                myConn.Open();
                myReader = SelectCommand.ExecuteReader();

                int count = 0;
                while (myReader.Read())
                {
                    count = count + 1;
                }
                if (count == 1)
                {
                    MessageBox.Show("User name and Password is correct ..Access Granted");
                    this.Hide();
                    frmUsers f = new frmUsers();
                    f.ShowDialog();
                }
                else if (count > 1)
                {
                    MessageBox.Show("Duplicate User Name and Password ...Access Denied");
                }
                else
                {
                    MessageBox.Show("User Name and Password is Not Correct ..Please Try Again");
                }
                myConn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            try
            {
                string myConnection = "datasource=localhost;port=3306;database=pharma;username=root;password="******"SELECT * FROM pharma.users WHERE username='******' and password='******' ; ", myConn);

                MySqlDataReader myReader;
                myConn.Open();
                myReader = SelectCommand.ExecuteReader();

                int count = 0;
                while (myReader.Read())
                {
                    count = count + 1;
                }
                if (count == 1)
                {
                    MessageBox.Show("User name and Password is correct ..Access Granted");
                    this.Hide();
                    frmUsers f = new frmUsers();
                    f.ShowDialog();
                }
                else if (count > 1)
                {
                    MessageBox.Show("Duplicate User Name and Password ...Access Denied");
                }
                else
                    MessageBox.Show("User Name and Password is Not Correct ..Please Try Again");
                myConn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }