Пример #1
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            if (isValidCredentials())
            {
                try
                {
                    String token = servico.logIn(txt_username.Text, txt_password.Text);

                    if (token != "")
                    {
                        bool res = servico.isAdmin(token);

                        if (res)
                        {
                            PATA.Properties.Settings.Default.token = token;
                            PATA.Properties.Settings.Default.Save();
                            txt_password.Text = "";
                            txt_username.Text = "";
                            Menu fMenu = new Menu(this);

                            fMenu.Show();
                            this.Hide();
                        }
                        else
                        {
                            DialogResult result1 = MessageBox.Show("Aplicação só disponível para administradores!",
                                                                   "Aviso",
                                                                   MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ocorreu um erro ao efetuar o login\n" + ex.Message.ToString());
                }
            }
        }