Main Form for users after login
Inheritance: System.Windows.Forms.Form
Ejemplo n.º 1
0
        /// <summary>
        /// Handles logging in, supposed to run in a seperated thread
        /// </summary>
        private void login()
        {
            if (ComboBox_Login.SelectedItem == null)
            {
                return;
            }
            WhatsappAccount Account = (WhatsappAccount)ComboBox_Login.SelectedItem;

            // Verify Account
            WhatsAppHelper Helper = new WhatsAppHelper();
            bool           Result = Helper.verifyAccount(Account.CountryCode, Account.Phonenumber, Account.Password);

            if (Result == true)
            {
                // Account is valid, show main form
                Form_Main frmMain = new Form_Main(Account);
                this.Close();
                frmMain.ShowDialog();
            }
            else
            {
                DialogResult Re = MessageBox.Show("The selected acocunt does not appear to be working, do you want to remove it?", "Error: Account not working", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (Re == DialogResult.Yes)
                {
                    // Delete account
                    Database.Query("DELETE FROM accounts WHERE phonenumber='" + Account.Phonenumber + "'");

                    // Reload combobox
                    updateAccounts();

                    // Hide status label
                    Label_Status.Visible = false;
                    Label_Status.Text    = "Please wait while we verify your account.";

                    // Enable controls
                    SetControlsEnabled(true);
                }
                else
                {
                    // Reload combobox
                    updateAccounts();

                    // Hide status label
                    Label_Status.Visible = false;
                    Label_Status.Text    = "Please wait while we verify your account.";

                    // Enable controls
                    SetControlsEnabled(true);
                }
            }
        }
        /// <summary>
        /// Handles logging in, supposed to run in a seperated thread
        /// </summary>
        private void login()
        {
            if (ComboBox_Login.SelectedItem == null)
                return;
            WhatsappAccount Account = (WhatsappAccount)ComboBox_Login.SelectedItem;

            // Verify Account
            WhatsAppHelper Helper = new WhatsAppHelper();
            bool Result = Helper.verifyAccount(Account.CountryCode, Account.Phonenumber, Account.Password);
            if (Result == true)
            {
                // Account is valid, show main form
                Form_Main frmMain = new Form_Main(Account);
                this.Close();
                frmMain.ShowDialog();
            }
            else
            {
                DialogResult Re = MessageBox.Show("The selected acocunt does not appear to be working, do you want to remove it?", "Error: Account not working", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (Re == DialogResult.Yes)
                {
                    // Delete account
                    Database.Query("DELETE FROM accounts WHERE phonenumber='" + Account.Phonenumber + "'");

                    // Reload combobox
                    updateAccounts();

                    // Hide status label
                    Label_Status.Visible = false;
                    Label_Status.Text = "Please wait while we verify your account.";

                    // Enable controls
                    SetControlsEnabled(true);
                }
                else
                {
                    // Reload combobox
                    updateAccounts();

                    // Hide status label
                    Label_Status.Visible = false;
                    Label_Status.Text = "Please wait while we verify your account.";

                    // Enable controls
                    SetControlsEnabled(true);
                }
            }
        }