/// <summary>
        /// The OnDelete
        /// </summary>
        private async void OnDelete()
        {
            await DialogHost.Show(new MessageView(), "RootDialog", delegate(object sender, DialogClosingEventArgs args)
            {
                if (Equals(args.Parameter, false))
                {
                    return;
                }

                if (Equals(args.Parameter, true))
                {
                    _context.Users.Remove(SelectedUserAccount);


                    _context.SaveChanges();
                    DoRefresh(null);
                }
            });

            if (IsByUser == true)
            {
                TotalCount = UserAccountList.Count();
            }
            else
            {
                TotalCount = CustomerList.Count();
            }
        }
Beispiel #2
0
        // ------------------ LOGIN WINDOW STUFF ------------------ //

        /** Attempts to log a user in. */
        private void submit_button_Click(object sender, EventArgs e)
        {
            string username = username_textbox.Text;
            string password = password_textbox.Text;

            // Check what's in the username field and password field
            if (!(username.Equals("")) || !(password.Equals("")))
            { // if the fields are not empty
                // Update the list
                accountList = DatabaseConnection.ReadLoginAccounts();
                UserAccount checkerAccount = accountList.FindByUsername(username);
                if (checkerAccount != null)
                { // if an account was found
                    // check if the password matches
                    if (checkerAccount.Password.Equals(password))
                    {
                        // Found the account!
                        // Create a new instance of the other form
                        UserAccount_Form userAccount_Form = new UserAccount_Form(checkerAccount);
                        // Hide this form
                        this.Hide();
                        // Show the instance of the UserAccount_Form form.
                        userAccount_Form.ShowDialog();
                        // After "showDialog()" finishes, it will return here
                        this.Show();

                        username_textbox.Text = "";
                        password_textbox.Text = "";
                    }
                    else
                    { // no password found
                        // display an error message
                        // error_label.SetStyle("-fx-text-fill: red");
                        MessageBox.Show("Incorrect password was entered.");
                    }
                }
                else
                { // no username found
                    // display an error message
                    // errorLabel.setStyle("-fx-text-fill: red");
                    MessageBox.Show("Username was not found.");
                }
            }
            else
            {
                // display an error message
                // errorLabel.setStyle("-fx-text-fill: red");
                MessageBox.Show("You must enter text into both fields.");
            }
        }
Beispiel #3
0
        private void remove_account_button_Click(object sender, EventArgs e)
        {
            // Switch to the "remove account" panel
            ShowGroupBox(3);

            // load in the accounts
            allUserAccounts = DatabaseConnection.ReadLoginAccounts();

            foreach (UserAccount currentAccount in allUserAccounts.Accounts)
            {
                if (currentAccount.User_Level != 1)
                {
                    remove_account_account_selection.Items.Add(currentAccount.Username);
                }
            }
        }
        // private static MySqlConnection connectionString = new MySqlConnection("server=localhost;user id=tobymac208;password=Sparta_!3712;database=mydb");

        /** Read in the login_accounts table from the database. Return all of the accounts. */
        public static UserAccountList ReadLoginAccounts()
        {
            // I need an accountList to populate
            UserAccountList accountList = new UserAccountList();
            // This is the string that connects the code to the database
            string connectionString = "server = localhost;user id = tobymac208;password=Sparta_!3712;database = mydb";
            // This is the command that connects the database to my code
            MySqlConnection connection = new MySqlConnection(connectionString);
            // Here's the query command section.
            MySqlCommand command = connection.CreateCommand();

            command.CommandText = "SELECT * FROM login_accounts";

            // Now, I'm going to open up the connection to the database. Try-catch in case a SQLException is thrown
            try
            {
                connection.Open();
            }
            catch (Exception exc)
            {
                Console.WriteLine("An exception occurred. Exception: " + exc.Message);
            }

            // This will be the object that holds all of the information coming in from the database.
            MySqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                // This code would print out the content, in the current row, for "text"
                // Console.WriteLine(reader["text"].ToString());
                string username, password, firstname, lastname;
                int    age, user_level;

                username   = reader["username"].ToString();
                password   = reader["password"].ToString();
                firstname  = reader["firstname"].ToString();
                lastname   = reader["lastname"].ToString();
                age        = Convert.ToInt32(reader["age"].ToString());
                user_level = Convert.ToInt32(reader["user_level"].ToString());

                UserAccount newAccount = new UserAccount(username, password, firstname, lastname, age, user_level);
                accountList.AddAccount(newAccount);
            }
            connection.Close();
            return(accountList);
        } // end of
Beispiel #5
0
        // ------------------ END OF LOGIN WINDOW STUFF ------------------ //

        // ------------------ REGISTER WINDOW STUFF ------------------ //

        /** Register a new account */
        private void submit_register_button_Click(object sender, EventArgs e)
        {
            string username, password, re_enter_password, firstname, lastname;
            int    age = 0;

            username          = register_username_textbox.Text;
            password          = register_password_textbox1.Text;
            re_enter_password = register_password_textbox2.Text;
            firstname         = register_firstname_textbox.Text;
            lastname          = register_lastname_textbox.Text;
            try
            {
                age = Convert.ToInt32(register_age_textbox.Text);
            }
            catch (Exception exc)
            {
                MessageBox.Show("All fields must have information in them. Exception: " + exc.Message);
            }

            if (username.Trim().Count() > 0 && password.Trim().Count() > 0 && re_enter_password.Trim().Count() > 0 && password.Equals(re_enter_password) && firstname.Trim().Count() > 0 && lastname.Trim().Count() > 0 && register_age_textbox.Text.Trim().Count() > 0)
            {
                // Update the list
                accountList = DatabaseConnection.ReadLoginAccounts();
                UserAccount checkerAccount = accountList.FindByUsername(username);
                if (checkerAccount != null) // an account was found!
                {
                    MessageBox.Show("Creation failed! An account with that username already exists.");
                }
                else
                {
                    DatabaseConnection.CreateLoginAccount(new UserAccount(username, password, firstname, lastname, age, 0)); // ALWAYS ZERO FOR USER_LEVEL, by default.
                    MessageBox.Show("Account successfully created!");

                    register_groupbox.Hide();
                    login_groupbox.Show();

                    // Update the account list
                    accountList = DatabaseConnection.ReadLoginAccounts();
                }
            }
            else
            {
                MessageBox.Show("All fields must have information in them.");
            }
        }
        private async void OnAddUserAccount()
        {
            if (IsByUser == true)
            {
                await DialogHost.Show(new AddUserAccountView()

                                      );

                TotalCount = UserAccountList.Count();
            }
            else
            {
                await DialogHost.Show(new AddCustomerView());

                TotalCount = CustomerList.Count;
            }
            LoadData();
        }
        //calls this function when the bot recieves a message
        private async Task HandleCommandAsync(SocketMessage s)
        {
            var msg = s as SocketUserMessage;

            if (msg == null)
            {
                return;
            }
            var context = new SocketCommandContext(_client, msg);

            if (context.User.IsBot)
            {
                return;
            }

            // mute check
            var userAccount = UserAccountList.GetAccount(context.User);

            if (userAccount.IsMuted)
            {
                await context.Message.DeleteAsync();

                return;
            }

            //leveling up logic


            Leveling.UserSentMessage((SocketGuildUser)context.User, (SocketTextChannel)context.Channel);

            int argPos = 0;

            if (msg.HasStringPrefix(Config.bot.cmdPrefix, ref argPos) ||
                msg.HasMentionPrefix(_client.CurrentUser, ref argPos))
            {
                var result = await _service.ExecuteAsync(context, argPos, services);

                //if the results is not successful and is not an unknown command, print the reason why we got the error
                if (!result.IsSuccess && result.Error != CommandError.UnknownCommand)
                {
                    Console.WriteLine(result.ErrorReason);
                }
            }
        }
Beispiel #8
0
        // ------------------ END OF QUIZ WINDOW ------------------ //

        // ------------------ REMOVE ACCOUNT WINDOW ------------------ //
        /** Called when an admin is trying to remove an account */

        private void remove_acount_submit_button_Click(object sender, EventArgs e)
        {
            string selected = (string)remove_account_account_selection.SelectedItem;

            if (selected != null)
            {
                UserAccountList temporaryList = DatabaseConnection.ReadLoginAccounts();
                UserAccount     temporaryUser = temporaryList.FindByUsername(selected);
                DatabaseConnection.RemoveLoginAccount(temporaryUser);

                MessageBox.Show("Account removed, with username '" + selected + "'!");

                ShowGroupBox(1);
            }
            else
            {
                MessageBox.Show("You MUST select an account to remove.");
            }
        }
        private void LoadCommands()
        {
            CloseCommand = new RelayCommand(OnClose);

            EditUserAccountCommand = new RelayCommand(OnEditUserAccount);

            DeleteUserAccountCommand = new RelayCommand(OnDelete);

            EditCustomerCommand = new RelayCommand(OnEditCustomer);

            DeleteCustomerCommand = new RelayCommand(OnDelete);



            BatchDeleteCommand = new RelayCommand(OnUserAccountBatchDelete, () =>
                                                  (UserAccountList.Count(c => c.IsSelected) > 0));



            AddUserAccountCommand = new RelayCommand(OnAddUserAccount);
        }
Beispiel #10
0
        protected override void Setup()
        {
            base.Setup();

            // On page load initiate/set your data/variables and or properties here
            // Should pass in criteria for the specific user that is viewing the page, however using current identity
            UserMovieList = MELib.Movies.UserMovieList.GetUserMovieList();

            UserAccountList = MELib.Accounts.AccountList.GetAccountList();
            UserAccount     = UserAccountList.FirstOrDefault();

            if (UserMovieList.Count() > 0)
            {
                FoundUserMoviesInd = true;
            }
            else
            {
                FoundUserMoviesInd = false;
            }


            LoggedInUserName = Singular.Security.Security.CurrentIdentity.UserName;
        }
Beispiel #11
0
        private void crtrp_ReportUAccList_Load(object sender, EventArgs e)
        {
            UserAccountList rpt = new UserAccountList();

            crtrp_ReportUAccList.ReportSource = rpt;
        }