Exemple #1
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            PersonLogic personLogic = new PersonLogic();

            if (personIDTxtBx.Text == "" ||
                leaderTxtBx.Text == "" ||
                companionTxtBx.Lines.Length == 0)
            {
                MessageBox.Show("Please fill out all fields before saving to the database", "Invalid Data");
            }
            else if (!Int32.TryParse(personIDTxtBx.Text, out int result))
            {
                MessageBox.Show("ID must be a number!", "Invalid Data");
            }
            else if (personLogic.GetPerson(result) == null)
            {
                MessageBox.Show("Please select a valid person ID", "Invalid Data");
            }
            else
            {
                ReadOnlyValues(true);
                ChangeToEditMode(false);
                currentAdventure.MainPersonID   = result;
                currentAdventure.LeaderName     = leaderTxtBx.Text;
                currentAdventure.CompanionNames = string.Join(",", companionTxtBx.Lines.ToArray());
                currentAdventure.Fatal          = fatal.Checked;
                currentAdventure.Successful     = successful.Checked;

                adventureLogic.UpdateAdventure();
                MessageBox.Show("Successfully saved the Role.", "Success!");
            }
        }
Exemple #2
0
        private void newBtn_Click(object sender, EventArgs e)
        {
            PersonLogic   personLogic   = new PersonLogic();
            LocationLogic locationLogic = new LocationLogic();
            Random        rand          = new Random();

            currentAdventure          = adventureLogic.Generate(rand.Next(1, 20), personLogic.GetRandomID(rand), rand);
            currentAdventure.Person   = personLogic.GetPerson(currentAdventure.MainPersonID);
            currentAdventure.Location = locationLogic.GetLocation(currentAdventure.WhereToLocationID);
            Display();
        }
        private void searchIDBtn_Click(object sender, EventArgs e)
        {
            PrevBtn.Visible = false;
            NextBtn.Visible = false;

            if (Int32.TryParse(idTxtBx.Text, out int result))
            {
                Person person = personLogic.GetPerson(result);
                if (person == null)
                {
                    MessageBox.Show("Person with ID was not found", "404: Not Found");
                }
                else
                {
                    currentRace = person.RaceType.ToLower();

                    if (person.RaceType == "elf")
                    {
                        currentElf = elfLogic.GetElf(result);
                    }
                    if (person.RaceType == "dwarf")
                    {
                        currentDwarf = dwarfLogic.GetDwarf(result);
                    }
                    if (person.RaceType == "human")
                    {
                        currentHuman = humanLogic.GetHuman(result);
                    }
                    if (person.RaceType == "wizard")
                    {
                        currentWizard = wizardLogic.GetWizard(result);
                    }
                    if (person.RaceType.ToLower() == "hobbit")
                    {
                        currentHobbit = hobbitLogic.GetHobbit(result);
                    }
                    Display();
                }
            }
            else
            {
                MessageBox.Show("ID must be a number!", "Error");
            }
        }
Exemple #4
0
        private void personIDTxtBx_TextChanged(object sender, EventArgs e)
        {
            PersonLogic personLogic = new PersonLogic();

            if (Int32.TryParse(personIDTxtBx.Text, out int result))
            {
                Person person = personLogic.GetPerson(result);

                if (person == null)
                {
                    personNameLbl.Text = "INVALID";
                }
                else
                {
                    personNameLbl.Text = person.Name;
                }
            }
            else
            {
                MessageBox.Show("This field must be numbers only!", "Invalid Data");
            }
        }