Ejemplo n.º 1
0
        private async void buttonLogIn_Click(object sender, EventArgs e)
        {
            int cantSeconds = 30;

            try
            {
                AccountApp myAccount = new AccountApp(textBoxUser.Text, textBoxPass.Text, false);
                this.AccountConnected = myAccount;
                this.IDUser           = this.AccountConnected.GetID();
            }
            catch (ArgumentException ex)
            {
                ButtonType = MessageBoxButtons.OK;
                IconType   = MessageBoxIcon.Error;
                MessageBox.Show(ex.Message, ex.ParamName, this.ButtonType, this.IconType);
                textBoxUser.Text = string.Empty;
                textBoxPass.Text = string.Empty;
                return;
            }
            finally
            {
                HandleVisibleLogIn(false);
                Task <int> sleepTask    = Task.Run(() => Suspend(cantSeconds));
                Task <int> progressTask = Task.Run(() => UpdateBar(cantSeconds));
                await Task.WhenAll(sleepTask, progressTask);

                if (sleepTask.Result == 1 & progressTask.Result == 1)
                {
                    HandleVisibleLogIn(true);
                }
                ActualizarProgressBar(0);
            }

            this.Close();
        }
Ejemplo n.º 2
0
        private void linkLabelNewAccount_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                AccountApp myAccount = new AccountApp(textBoxUser.Text, textBoxPass.Text, true);
                this.AccountConnected = myAccount;
                this.IDUser           = myAccount.GetID();
            }
            catch (ArgumentException ex)
            {
                if (ex.Message.Contains("existe"))
                {
                    ButtonType = MessageBoxButtons.OK;
                    IconType   = MessageBoxIcon.Error;
                    MessageBox.Show(ex.Message, ex.ParamName, this.ButtonType, this.IconType);
                    textBoxUser.Text = string.Empty;
                    textBoxPass.Text = string.Empty;
                    return;
                }
            }

            textBoxUser.Text = string.Empty;
            textBoxPass.Text = string.Empty;

            ButtonType = MessageBoxButtons.OK;
            IconType   = MessageBoxIcon.Information;
            MessageBox.Show($"El usuario {this.AccountConnected.Username} fue creado exitosamente", "New Account", this.ButtonType, this.IconType);
        }