示例#1
0
        private async void button_Login_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(textBox_Username.Text) || string.IsNullOrWhiteSpace(textBox_Password.Text))
            {
                MessageBox.Show("Input needed", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                textBox_Username.Focus();
                return;
            }

            if (await api.IsAccessibleAsync())
            {
                SHOW_PROGRESSBAR(true);
                var resp = await Auth.LoginAsync(api, textBox_Username.Text, textBox_Password.Text);

                if (resp.IsSuccess)
                {
                    MessageBox.Show($"Welcome, {textBox_Username.Text}", "Login success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                    mainScreen.LoadAuthentication();
                }
                else
                {
                    MessageBox.Show(resp.Message, "Login failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

                SHOW_PROGRESSBAR(false);
                textBox_Username.Focus();
            }
            else
            {
                MessageBox.Show(Switcher.NOT_ACCESSIBLE, "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                SHOW_PROGRESSBAR(false);
            }
        }
示例#2
0
 private void button_ChangeAuth_Click(object sender, EventArgs e)
 {
     if (Auth.IsAuthenticated)
     {
         var dr = MessageBox.Show("Logout from the system?", "Logout?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             Auth.Logout();
             LoadAuthentication();
         }
     }
     else
     {
         new Acc.Login(this, api).ShowDialog();
     }
 }