private void button1_Click(object sender, EventArgs e)
        {
            conn.Open();
            dr = new MySqlDataAdapter("SELECT * FROM admin WHERE uname='" + textBox1.Text + "' AND pass='******'", conn);
            DataTable dt = new DataTable();

            dr.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                global.a_name = dt.Rows[0]["uname"].ToString();
                global.a_posi = dt.Rows[0]["posi"].ToString();
                MessageBox.Show("Welcome: " + global.a_name, "Welcome Admin", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Hide();
                landing_page nf = new landing_page();
                nf.Show();
            }
            else if (string.IsNullOrEmpty(textBox1.Text) && string.IsNullOrEmpty(textBox2.Text))
            {
                MessageBox.Show("Please Input Username and Password!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else if (string.IsNullOrEmpty(textBox1.Text))
            {
                MessageBox.Show("Please Input Username!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else if (string.IsNullOrEmpty(textBox2.Text))
            {
                MessageBox.Show("Please Input Password!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                MessageBox.Show("Invalid Account!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            conn.Close();
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            conn.Open();
            dr = new MySqlDataAdapter("SELECT * FROM admin WHERE uname='" + textBox1.Text + "' AND pass='******'", conn);
            DataTable dt = new DataTable();

            dr.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                global.a_name = dt.Rows[0]["uname"].ToString();
                MessageBox.Show("Welcome " + global.a_name);
                this.Hide();
                landing_page nf = new landing_page();
                nf.Show();
            }
            else
            {
                MessageBox.Show("invalid account");
            }
            conn.Close();
        }