Ejemplo n.º 1
0
        public void Update(char VALUE = '0')
        {
            if (VALUE == 'C')//Player Character from character creation/update forms
            {
                Update('L');
                maxPages = maxCharIndex / 10;
                rowIndex = 0;
                // Updates index page
                if (pages < 0)
                {
                    currentCharIndex = 0;
                }
                else if (pages == maxPages)
                {
                    currentCharIndex = rowIndex + pages * 10;
                }
                else
                {
                    currentCharIndex = rowIndex + pages * 10;
                }

                for (int i = currentCharIndex; i < maxCharIndex && rowIndex <= 9; i++)
                {
                    rowIndex = dbListCharList.Rows.Add();
                    ConnectDataBases.GetUsersCharacters(i + 1, searchFor);

                    dbListCharList.Rows[rowIndex].Cells[0].Value = ConnectVariables.GetCharNameDP();
                    dbListCharList.Rows[rowIndex].Cells[1].Value = ConnectVariables.GetCharGenderDP();
                    dbListCharList.Rows[rowIndex].Cells[2].Value = ConnectVariables.GetCharClassDP();
                    dbListCharList.Rows[rowIndex].Cells[3].Value = ConnectVariables.GetCharRaceDP();
                    dbListCharList.Rows[rowIndex].Cells[4].Value = ConnectVariables.GetUsernameDP();
                    dbListCharList.Rows[rowIndex].Cells[5].Value = ConnectVariables.GetCharIDDP();
                    currentCharIndex = i;
                    Console.WriteLine("Current Page Index: " + pages);
                    Console.WriteLine("Max Page Index: " + maxPages);
                    Console.WriteLine("Row Index: " + rowIndex);
                    Console.WriteLine("Current Char Index: " + currentCharIndex);
                    Console.WriteLine("Max Char Index: " + maxCharIndex);
                }
                //Button Updates to page
                Update('O');
            }
            else if (VALUE == 'P')//Last Page
            {
                pages -= 1;
                Update('C');
            }
            else if (VALUE == 'N')//Next Page
            {
                pages += 1;
                Update('C');
            }
            else if (VALUE == 'L')
            {
                dbListCharList.Rows.Clear();
            }
            else if (VALUE == 'M')// Return to menu
            {
                currentCharIndex = 0;
                pages            = 0;
                Update('L');
                returnValue = 'M';
            }
            else if (VALUE == 'B')// Return to char Create form
            {
                currentCharIndex = 0;
                pages            = 0;
                Update('L');
                returnValue = 'B';
            }
            else if (VALUE == 'O')//update buttons
            {
                if (pages <= 0)
                {
                    pages = 0;
                    btnPrevious.Enabled = false;
                    btnNext.Enabled     = true;
                }
                else if (pages == maxPages)
                {
                    btnNext.Enabled     = false;
                    btnPrevious.Enabled = true;
                }
                else
                {
                    btnPrevious.Enabled = true;
                    btnNext.Enabled     = true;
                }
            }
            else if (VALUE == 'A')
            {
                maxCharIndex = ConnectDataBases.GetAllCharacters();
                searchFor    = 'A';
            }
            else if (VALUE == 'Z')
            {
                maxCharIndex = ConnectDataBases.GetUsersCharactersAmount();
                searchFor    = 'Z';
            }
            else if (VALUE == 'S')
            {
                partyCharSelet = true;
            }
        }