Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            MySqlConnection conn      = new MySqlConnection("server=localhost;user id=root;database=pharmacy management");
            string          user      = txtusername.Text;
            string          pass      = txtpassword.Text;
            string          user_type = comboBox1.Text;

            MySqlDataAdapter sda = new MySqlDataAdapter("select count(*) from login where username='******' and password='******'and user_type='" + comboBox1.Text + "'", conn);
            DataTable        dt  = new DataTable();

            sda.Fill(dt);
            if (dt.Rows[0][0].ToString() == "1")
            {
                MySqlDataAdapter sda1 = new MySqlDataAdapter("select user_type from login where username='******' and password='******'and user_type='" + comboBox1.Text + "'", conn);
                DataTable        dt1  = new DataTable();
                sda1.Fill(dt1);
                if (dt1.Rows[0][0].ToString() == "Admin")
                {
                    Form2 s = new Form2();
                    s.Show();
                    this.Hide();
                }
                if (dt1.Rows[0][0].ToString() == "Manager")
                {
                    Form2 s = new Form2();
                    s.Show();
                    this.Hide();
                }
                if (dt1.Rows[0][0].ToString() == "Employee")
                {
                    Form11 s = new Form11();
                    s.Show();
                    this.Hide();
                }
            }
            else
            {
                MessageBox.Show("Incorrect username and password", "alter", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }