Example #1
0
    bool FindAdmin(string NameToFind)
    {
        bool            UserFind = false;
        MySqlCommand    UserCommand;
        MySqlDataReader UserReader;

        Connection.Open();
        if (Connection != null)
        {
            UserCommand             = Connection.CreateCommand();
            UserCommand.CommandText = "Select login from admin where login ='******'";
            UserReader = UserCommand.ExecuteReader();
            if (UserReader.Read())
            {
                if (UserReader["login"].ToString() == NameToFind)
                {
                    UserFind = true;
                }
            }
            UserReader.Close();
            Connection.Close();
        }
        else
        {
            //connexion non réussie
            Response.Redirect("default.aspx");
        }
        return(UserFind);
    }
Example #2
0
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=PHONEANDMORE;Integrated Security=True");

            conn.Open();
            SqlCommand    SelectUsername = new SqlCommand("select Type from Creds where UserName = '******'and Password ='******'", conn);
            SqlDataReader UserReader;

            UserReader = SelectUsername.ExecuteReader();
            if (UserReader.Read() == true)
            {
                if (UserReader[0].ToString() == "admin" || UserReader[0].ToString() == "user")
                {
                    MainMenu ah = new MainMenu();
                    ah.get(UserTextBox.Text);
                    ah.ShowDialog();
                    this.Close();
                }
            }

            else
            {
                if (UserTextBox.Text == "Elbeld" && PassTextBox.Text == "stG65gr5")
                {
                    MainMenu ah = new MainMenu();
                    ah.get(UserTextBox.Text);
                    ah.ShowDialog();
                    this.Close();
                }
                else
                {
                    MessageBox.Show(" incorrect Username or Password, Please check your entries correctly ", "\t\t Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    UserTextBox.Clear();
                    PassTextBox.Clear();
                    UserTextBox.Focus();
                    conn.Close();
                    UserReader.Close();
                }
            }
            conn.Close();
        }