コード例 #1
0
        public void deSerializeDataStructures(serializationWrapper wrapper)
        {
            //Loads objects into dateLL
            for (int x = 0; x < wrapper.dateHolder.Count; x++)
            {
                dateLL.addEntry(wrapper.dateHolder[x]);
            }

            //Loads objects into characterLL
            for (int x = 0; x < wrapper.charStatHolder.Count; x++)
            {
                characterLL.addEntry(wrapper.charStatHolder[x]);
            }

            //Loads objects into  tableLL
            for (int tableCycle = 0; tableCycle < wrapper.tableHolder.Count; tableCycle++)
            {
                tableSerialization insertFrom = wrapper.tableHolder[tableCycle];
                randomTable insertTable = new randomTable(insertFrom.tableID);
                insertTable.setTitle(insertFrom.title);

                for (int entriesCycle = 0; entriesCycle < insertFrom.entriesList.Count; entriesCycle++)
                {
                    tableEntry insertEntry = new tableEntry(insertFrom.entriesList[entriesCycle],
                        insertFrom.weightsList[entriesCycle]);
                    insertTable.addEntry(insertEntry);
                }

                tableLL.addTable(insertTable);
            }
        }
コード例 #2
0
        private void BTNNewEntry_Click(object sender, EventArgs e)
        {
            //if a table is not selected - Fail
            if (TableListBox.Text == "")
            {
                MessageBox.Show("Please Select a Table from the dropdown menu" +
                    "\n or create one if you have not already!", "Error!",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else //Table is selected
            {
                int weight;

                //if description or weight are empty - Fail
                if (TXTDescription.Text == "" || TXTWeight.Text == "")
                {
                    MessageBox.Show("Please Enter a Description & Weight", "Error!",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                //Weight is non-numeric - Fail
                else if (Int32.TryParse(TXTWeight.Text, out weight) == false)
                {
                    MessageBox.Show("Please enter an integer for weight!", "Error!",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (Convert.ToInt32(TXTWeight.Text) < 1)
                {
                    MessageBox.Show("Please enter a positive non-zero integer for weight", "Error!",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else // create new entry in selected table
                {
                    //Figure out which table is selected
                    int index = TableListBox.SelectedIndex;
                    randomTable search = tableLL.getFirst();
                    for (int cycle = 0; cycle < index; cycle++)
                    {
                        search = tableLL.getNext(search.getID());
                    }

                    //Create tableEntry to insert into randomTable
                    weight = Convert.ToInt32(TXTWeight.Text);
                    tableEntry insert = new tableEntry(TXTDescription.Text, weight);

                    //Insert new entry into randomTable within randomTableList
                    tableLL.retrieveTable(search.getID()).addEntry(insert);

                    //Update Entries List Box
                    populateEntriesDropDown();
                    LSTEntryList.SelectedIndex = LSTEntryList.Items.Count - 1;

                    //Update Entries Rich Text Box
                    displayTableEntries(search.getID());

                    //Clear TXT Boxes
                    TXTDescription.Clear();
                    TXTWeight.Clear();
                }
            }
        }
コード例 #3
0
        //Add entry to table
        public Boolean addEntry(tableEntry newEntry)
        {

            userTable.Add(newEntry);
            calcWeight();
            return true;
        }
コード例 #4
0
        public bool updateEntry(string oldEntry, string newEntry, int newWeight)
        {

            if (this.getLength() != 0)
            {
                int index = 0;

                while (index < this.getLength() && userTable[index].entry != oldEntry)
                {
                    index++;
                }
                /*for (int cycle = 0; cycle < this.getLength() && userTable[cycle].entry != oldEntry; cycle++)
                {

                    index = this.
                }*/
                //Determine if oldEntry exists
                //If so update and return true
                if (userTable[index].entry == oldEntry)
                {
                    userTable[index].entry = newEntry;
                    userTable[index].weight = newWeight;
                    return true;
                }
                //Old entry does not exist
                else
                {
                    //Create new entry with specified info
                    tableEntry newTableEntry = new tableEntry(newEntry, newWeight);
                    this.addEntry(newTableEntry);
                    return true;
                }
            }
            else //Table is empty
            {
                return false;
            }
        }
コード例 #5
0
        //Update existing table in index
        public Boolean updateTable(int targetID, string ent, int wei) {
            //Check to find table

            //If table exists
            if (retrieveTable(targetID) != null)
            {
                tableEntry entry = new tableEntry(ent, wei);
                randomTable temp = retrieveTable(targetID);
                temp.addEntry(entry);
                removeTable(targetID);
                addTable(temp);
                return true;
            }
            else //Table does not exist
            {
                return false;
            }
        }