コード例 #1
0
ファイル: Login.cs プロジェクト: aromsar87/TP_GDD_2018
        private void btn_init_Click(object sender, EventArgs e)
        {
            string validationString = ValidateFields();

            if (validationString != string.Empty)
            {
                MessageBox.Show(validationString);
                return;
            }

            this.user = txt_user.Text.Trim();
            string pass = txt_pass.Text.Trim();
            int    countRoles;

            int result = UserConnection.Authenticate(user, pass);

            switch (result)
            {
            case 0: MessageBox.Show("Usuario Inexistente");
                ClearFields();
                txt_user.Focus();
                break;

            case 1: MessageBox.Show("Login incorrecto");
                UserConnection.RegisterFailedAttempt(user);
                ClearFields();
                txt_user.Focus();
                break;

            case 2: MessageBox.Show("Usuario Bloqueado. Por favor contáctese con el Administrador.");
                this.Close();
                break;

            case 3: countRoles = UserConnection.CountRoles(user);

                if (countRoles == 0)
                {
                    MessageBox.Show("No dispone de roles activos.");
                    this.Close();
                    return;
                }
                else
                {
                    this.InitSesion(countRoles);
                }

                break;

            default: break;
            }
        }