private void Login_Click(object sender, EventArgs e)
        {
            ErrorLabel.Text = "";
            var login    = LoginTextBox.Text.Trim();
            var password = PasswordTextBox.Text.Trim();

            if (!string.IsNullOrEmpty(login) && !string.IsNullOrEmpty(password))
            {
                var user = UserRepository.FindUser(login, password);
                if (user != null)
                {
                    if (user.IsAdmin)
                    {
                        OpenForms.OpenAdminForm(this, user.IsAdmin);
                    }
                    else
                    {
                        OpenForms.OpenHostelAllocationForm(this, user.IsAdmin);
                    }
                }
                else
                {
                    ErrorLabel.Text = "Пароль или логин не корректны";
                }
            }
            else
            {
                if (UserRepository.IsFirstUser())
                {
                    OpenForms.OpenCreateFirstAdminForm(this);
                }
                else
                {
                    ErrorLabel.Text = "Введите логин или пароль";
                }
            }
        }
Пример #2
0
 private void OpenHostelAllocationForm_Click(object sender, System.EventArgs e)
 {
     OpenForms.OpenHostelAllocationForm(this, IsAdmin);
 }