コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
            zalogowanoAdminForm adminForm = new zalogowanoAdminForm();

            adminForm.Show();
        }
コード例 #2
0
ファイル: loginForm.cs プロジェクト: Skrabka98/Bazy_danych
        public void buttonZaloguj_Click(object sender, EventArgs e)
        {
            bazaDanych bd    = new bazaDanych();
            String     login = textBoxLogin.Text;
            String     haslo = textBoxHaslo.Text;

            DataTable        dataTable = new DataTable();
            MySqlDataAdapter adapter   = new MySqlDataAdapter();
            MySqlCommand     command   = new MySqlCommand("SELECT * FROM `Login` WHERE `login` = @log and `haslo` = @haslo", bd.getConnection());

            command.Parameters.Add("@log", MySqlDbType.VarChar).Value   = login;
            command.Parameters.Add("@haslo", MySqlDbType.VarChar).Value = haslo;
            adapter.SelectCommand = command;
            adapter.Fill(dataTable);



            if (dataTable.Rows.Count > 0)
            {
                var upra     = dataTable.Rows[0]["uprawnienia"].ToString();
                var upraBool = bool.Parse(upra);
                var id       = dataTable.Rows[0]["id_uzytkownika"].ToString();


                if (upraBool == false)
                {
                    this.Hide();
                    zalogowanoUserForm user = new zalogowanoUserForm(id);
                    user.Show();
                }
                else if (upraBool == true)
                {
                    this.Hide();
                    zalogowanoAdminForm admin = new zalogowanoAdminForm();
                    admin.Show();
                }
            }
            else
            if (login.Trim().Equals(""))
            {
                MessageBox.Show("Podaj login");
            }
            else if (haslo.Trim().Equals(""))
            {
                MessageBox.Show("Podaj haslo");
            }
            else
            {
                MessageBox.Show("Błędny login lub hasło");
            }
        }