Esempio n. 1
0
        private void sortInts(List <int> sortMethod, bool ascending)
        {
            //ascending true = A-Z, 1-10; false = Z-A, 10-1
            int interesting     = 0;
            int searchDirection = 0;

            if (ascending == true)
            {
                searchDirection = 1;
            }
            else
            {
                searchDirection = -1;
            }
            Philosophers temp = new Philosophers();

            for (int i = 0; i < sortMethod.Count - 1; i++)
            {
                interesting = i;
                for (int j = i + 1; j < sortMethod.Count; j++)
                {
                    if (sortMethod[interesting].CompareTo(sortMethod[j]) == searchDirection)
                    {
                        interesting = j;
                    }
                }
                if (i != interesting)                       //No reason to do this if i is in the right spot.
                {
                    loadPhilosopher(ref temp, i);           //Save values
                    listMover(i, interesting);              //All values at i are replaced.
                    unLoadPhilosopher(temp, interesting);   //Data that was at i is now at interesting
                }
            }
            populateListBox();
        }
Esempio n. 2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     using (var form = new AddPhilosopher())
     {
         Philosophers newGuy = new Philosophers();
         var          result = form.ShowDialog(this);
         if (result == DialogResult.OK)       //Grab values as it closes
         {
             //Verify that this is a new philosopher.
             newGuy.setName(form.name);
             newGuy.setNation(form.nationality);
             newGuy.setBorn(form.born);
             if (duplicateCheck(newGuy)) //Only add if this isn't a duplicate
             {
                 nameList.Add(form.name);
                 nationalityList.Add(form.nationality);
                 bornList.Add(form.born);
                 diedList.Add(form.died);
                 famousWorksList.Add(form.famousWorks);
                 biographyList.Add(form.biography);
                 URLList.Add(form.URL);
                 imageList.Add(defaultImage); //File uploads not supported for this version
                 populateListBox();
                 dbAccessed = true;
             }
         }
     }//Last chance to grab AddPhilosopher values.
 }
Esempio n. 3
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            int          choice = lstSelector.SelectedIndex;
            Philosophers Edit   = new Philosophers();

            Edit.superSet(nameList[choice], nationalityList[choice],
                          bornList[choice], diedList[choice], famousWorksList[choice],
                          biographyList[choice], URLList[choice], imageList[choice]);

            using (var form = new EditPhilosopher(Edit))
            {
                var result = form.ShowDialog();
                if (result == DialogResult.OK)     //Grab values as it closes
                {
                    //Don't check for duplicates because it's already in the database and will always return true.
                    nameList[choice]        = (form.name);
                    nationalityList[choice] = (form.nationality);
                    bornList[choice]        = (form.born);
                    diedList[choice]        = (form.died);
                    famousWorksList[choice] = (form.famousWorks);
                    biographyList[choice]   = (form.biography);
                    URLList[choice]         = (form.URL);
                    populateListBox();
                    dbAccessed = true;
                }
            }
        }
Esempio n. 4
0
 public void unLoadPhilosopher(Philosophers full, int index)
 {
     nameList[index]        = full.name;
     nationalityList[index] = full.nationality;
     bornList[index]        = full.born;
     diedList[index]        = full.died;
     famousWorksList[index] = full.famousWorks;
     biographyList[index]   = full.biography;
     URLList[index]         = full.URL;
     imageList[index]       = full.imageLink;
 }
Esempio n. 5
0
 public void loadPhilosopher(ref Philosophers empty, int index)
 {
     empty.name        = nameList[index];
     empty.nationality = nationalityList[index];
     empty.born        = bornList[index];
     empty.died        = diedList[index];
     empty.famousWorks = famousWorksList[index];
     empty.biography   = biographyList[index];
     empty.URL         = URLList[index];
     empty.imageLink   = imageList[index];
 }
Esempio n. 6
0
 public bool duplicateCheck(Philosophers toBeChecked)
 {
     for (int i = 0; i < nameList.Count; i++)
     {
         if (toBeChecked.areDuplicate(nameList[i], bornList[i], nationalityList[i]))
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 7
0
 public EditPhilosopher(Philosophers incoming)
 {
     InitializeComponent();
     Edit = incoming;
 }