Exemplo n.º 1
0
        //Add a new member
        private void btn_Add_Click(object sender, EventArgs e)
        {
            //Call class for fellowship member
            fMember newMember = new fMember();

            //Call subform to reveal
            addMem add_Window = new addMem(this);

            add_Window.ShowDialog();

            //Check if all fields are ready to receive
            if (!((CountryPass == null) && (NamePass == null) && (TitlePass == null)))
            {
                //Set Race string with Combo Box selected index
                setRace(RacePass);

                //Set Attributes...
                getFMemberData(newMember);

                //ADD member to fellowship
                Fellowship.Add(newMember);

                //Add to the listbox
                lbx_Members.Items.Add(newMember.Race + " - " + newMember.Name + " " + newMember.Title);
            }
            reset();
        }
Exemplo n.º 2
0
        //Edit an entry
        private void btn_EditMem_Click(object sender, EventArgs e)
        {
            //Retrieve index of desired editing
            int index = lbx_Members.SelectedIndex;
            int raceID;

            //Create new PlaceHolder
            fMember pHolder = new fMember();

            //Set placeholder member info to the same
            if (index < 0)
            {
                MessageBox.Show("Please select a member to Edit");
                return;
            }
            raceID      = setCbxIndex(Fellowship[index].Race);
            RacePass    = raceID;
            CountryPass = Fellowship[index].Country;
            NamePass    = Fellowship[index].Name;
            TitlePass   = Fellowship[index].Title;
            WeaponPass  = Fellowship[index].Weapon;

            //Call subform to reveal
            addMem add_Window = new addMem(this);

            add_Window.PopulateFields();
            add_Window.ShowDialog();
            // -----------------
            if (!((CountryPass == null) && (NamePass == null) && (TitlePass == null)))
            {
                //Set Race string with Combo Box selected index
                setRace(RacePass);

                //Set Attributes...
                getFMemberData(pHolder);

                //Replace old values
                Fellowship[index] = pHolder;

                //Replace in ListBox
                lbx_Members.Items.Clear();
                int i = 0;
                while (i < Fellowship.Count)
                {
                    lbx_Members.Items.Insert(i, Fellowship[i].Race + " - " + Fellowship[i].Name + " " + Fellowship[i].Title);
                    i++;
                }
            }
            //Toggle focus
            btn_Add.Focus();

            //Set passing vars to null or zero
            Race        = null;
            RacePass    = 0;
            CountryPass = null;
            NamePass    = null;
            TitlePass   = null;
            WeaponPass  = null;
        }
Exemplo n.º 3
0
 //Method to retrieve data
 private void getFMemberData(fMember newMember)
 {
     //Set attributes to passable data
     newMember.Race    = Race;
     newMember.Country = CountryPass;
     newMember.Name    = NamePass;
     newMember.Title   = TitlePass;
     newMember.Weapon  = WeaponPass;
 }
Exemplo n.º 4
0
        //Load a file that contains the right info
        private void btn_Load_Click(object sender, EventArgs e)
        {
            //Open dialog
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                inputFile = File.OpenText(openFileDialog1.FileName);

                MessageBox.Show("File Read Successfully!");
            }
            else
            {
                MessageBox.Show("File Open error");
            }

            //Create new member and error title
            String error = null;

            string line;
            int    x = 0;

            while ((line = inputFile.ReadLine()) != null)
            {
                fMember loadMember = new fMember();
                //MessageBox.Show(line);
                try
                {
                    Race        = line.Split(',')[0];
                    CountryPass = line.Split(',')[1];
                    NamePass    = line.Split(',')[2];
                    TitlePass   = line.Split(',')[3];
                    RacePass    = Convert.ToInt32(line.Split(',')[4]);
                }
                catch (Exception ex)
                {
                    error = "Improper data";
                    MessageBox.Show(ex.Message);
                }

                if (error == null)
                {
                    //Collect Race
                    setRace(RacePass);

                    //Set Attributes...
                    getFMemberData(loadMember);

                    //Add member...
                    Fellowship.Add(loadMember);
                }
            }
            for (int i = 0; i < Fellowship.Count; i++)
            {
                lbx_Members.Items.Add(Fellowship[i].Race + " - " + Fellowship[i].Name + " " + Fellowship[i].Title);
            }
            reset();
        }