private void buttonBack_Click(object sender, EventArgs e)
        {
            FormZalogowany formZalogowany = new FormZalogowany(id);

            formZalogowany.Show();
            this.Close();
        }
Exemplo n.º 2
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            warehouseDatabaseEntities1 context = new warehouseDatabaseEntities1();

            if (textBoxLogin.Text != string.Empty || textBoxHaslo.Text != string.Empty)
            {
                var user = context.Users.Where(u => u.login.Equals(textBoxLogin.Text)).FirstOrDefault();

                if (user != null)
                {
                    CheckPermissions checkPermissions = new CheckPermissions(user.usersID);

                    if (user.password.Equals(textBoxHaslo.Text))
                    {
                        this.id = user.usersID;
                        if (!checkPermissions.administrator())
                        {
                            FormZalogowany success = new FormZalogowany(this.id);
                            success.Show();
                            this.Hide();
                        }
                        else
                        {
                            FormAdmin admin = new FormAdmin();
                            admin.Show();
                            this.Hide();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Błędny login lub hasło");
                    }
                }
                else
                {
                    MessageBox.Show("Błędny login lub hasło");
                }
            }
            else
            {
                MessageBox.Show("Uzupełnij login i hasło");
            }
        }