Ejemplo n.º 1
0
        private void tabControlInfo_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBoxMother.Items.Clear();
            spouse unknown = new spouse();
            unknown.name.first = "Unknown";
            unknown.id = 0;

            comboBoxMother.Items.Add(new comboMother(unknown));
            foreach (ListViewItem lvi in listViewSpouses.Items)
            {
                comboBoxMother.Items.Add((new comboMother((spouse)lvi.Tag)));
            }
        }
Ejemplo n.º 2
0
        private void buttonAddSpouse_Click(object sender, EventArgs e)
        {
            spouse newSpouse = new spouse();
            newSpouse.name.first = textBoxSpouseFirstName.Text;
            newSpouse.name.middle = textBoxSpouseMiddleName.Text;
            newSpouse.name.last = textBoxSpouseLastName.Text;
            newSpouse.name.maiden = textBoxSpouseMaidenName.Text;

            //assign temp id
            Int32 tempID = 0;
            bool found = false;
            while (!found)
            {
                tempID--;
                found = true;
                foreach (ListViewItem lvi in listViewSpouses.Items)
                {
                    if (((spouse)lvi.Tag).id == tempID)
                        found = false;
                }
            }
            newSpouse.id = tempID;

            //MessageBox.Show(tempID.ToString());

            newSpouse.marriageDate.day = comboDaytoInt(comboBoxMarriageDay);
            newSpouse.marriageDate.month = comboMonthtoInt(comboBoxMarriageMonth);
            newSpouse.marriageDate.year = comboYeartoInt(comboBoxMarriageYear);
            newSpouse.marriageLocation.city = textBoxMarriageCity.Text;
            newSpouse.marriageLocation.county = comboBoxMarriageCounty.Text;
            newSpouse.marriageLocation.state = textBoxMarriageState.Text;
            newSpouse.marriageLocation.country = textBoxMarriageCountry.Text;

            string[] spouseLine = { newSpouse.name.ToString(), newSpouse.marriageDate.ToString(), newSpouse.marriageLocation.ToString() };
            ListViewItem newItem = new ListViewItem(spouseLine);
            newItem.Tag = newSpouse;
            listViewSpouses.Items.Add(newItem);

            //clear
            textBoxSpouseFirstName.Clear();
            textBoxSpouseLastName.Clear();
            textBoxSpouseMiddleName.Clear();
            textBoxSpouseMaidenName.Clear();
            textBoxMarriageCity.Clear();
            textBoxMarriageCountry.Clear();
            comboBoxMarriageCounty.Text="";
            textBoxMarriageState.Clear();
            comboBoxMarriageDay.SelectedIndex = 0;
            comboBoxMarriageMonth.SelectedIndex = 0;
            comboBoxMarriageYear.SelectedIndex = 0;
        }
Ejemplo n.º 3
0
        //returns a list of all the soldiers in the database.
        public List<Soldier> Soldiers()
        {
            List<Soldier> soldiers = new List<Soldier>();

            string readSoldiers = "select * from soldiers;";
            SQLiteCommand readcommand = new SQLiteCommand(readSoldiers, m_dbConnection);
            SQLiteDataReader reader = readcommand.ExecuteReader();

            while (reader.Read())
            {
                //all of the info in the soliers table
                Soldier newSoldier = new Soldier();
                newSoldier.id = Convert.ToInt32(reader["id"]);
                newSoldier.soldierName.first = reader["f_name"].ToString();
                newSoldier.soldierName.middle = reader["mid_name"].ToString();
                newSoldier.soldierName.last = reader["l_name"].ToString();
                newSoldier.soldierName.maiden = reader["maid_name"].ToString();
                newSoldier.birthDate.day = Convert.ToInt32(reader["b_date_day"]);
                newSoldier.birthDate.month = Convert.ToInt32(reader["b_date_month"]);
                newSoldier.birthDate.year = Convert.ToInt32(reader["b_date_year"]);
                newSoldier.birthLocation.city = reader["b_loc_city"].ToString();
                newSoldier.birthLocation.county = reader["b_loc_county"].ToString();
                newSoldier.birthLocation.state = reader["b_loc_state"].ToString();
                newSoldier.birthLocation.country = reader["b_loc_country"].ToString();
                newSoldier.deathDate.day = Convert.ToInt32(reader["d_date_day"]);
                newSoldier.deathDate.month = Convert.ToInt32(reader["d_date_month"]);
                newSoldier.deathDate.year = Convert.ToInt32(reader["d_date_year"]);
                newSoldier.deathLocation.city = reader["d_loc_city"].ToString();
                newSoldier.deathLocation.county = reader["d_loc_county"].ToString();
                newSoldier.deathLocation.state = reader["d_loc_state"].ToString();
                newSoldier.deathLocation.country = reader["d_loc_country"].ToString();
                newSoldier.cemetery = reader["c_name"].ToString();
                newSoldier.cemeteryLatitude = reader["c_latitude"].ToString();
                newSoldier.cemeteryLongitude = reader["c_longitude"].ToString();
                newSoldier.cemeteryLocation.city = reader["c_loc_city"].ToString();
                newSoldier.cemeteryLocation.county = reader["c_loc_county"].ToString();
                //newSoldier.cemeteryLocation.state = "Illinois";
                newSoldier.cemeteryLocation.state = reader["c_loc_state"].ToString();
                //newSoldier.cemeteryLocation.country = "USA";
                newSoldier.cemeteryLocation.country = reader["c_loc_country"].ToString();

                //read spouses
                string readSpouses = String.Format("select * from spouses where soldier_id={0};", newSoldier.id.ToString());
                readcommand = new SQLiteCommand(readSpouses, m_dbConnection);
                SQLiteDataReader spousesReader = readcommand.ExecuteReader();

                while (spousesReader.Read())
                {
                    spouse newSpouse = new spouse();
                    newSpouse.name.first = spousesReader["f_name"].ToString();
                    newSpouse.name.middle = spousesReader["mid_name"].ToString();
                    newSpouse.name.last = spousesReader["l_name"].ToString();
                    newSpouse.name.maiden = spousesReader["maid_name"].ToString();
                    newSpouse.id = Convert.ToInt32(spousesReader["id"]);
                    newSpouse.marriageDate.day = Convert.ToInt32(spousesReader["m_date_day"]);
                    newSpouse.marriageDate.month = Convert.ToInt32(spousesReader["m_date_month"]);
                    newSpouse.marriageDate.year = Convert.ToInt32(spousesReader["m_date_year"]);
                    newSpouse.marriageLocation.city = spousesReader["m_loc_city"].ToString();
                    newSpouse.marriageLocation.county = spousesReader["m_loc_county"].ToString();
                    newSpouse.marriageLocation.state = spousesReader["m_loc_state"].ToString();
                    newSpouse.marriageLocation.country = spousesReader["m_loc_country"].ToString();

                    newSoldier.spouses.Add(newSpouse);
                }

                //read children
                string readChildren = String.Format("select * from children where soldier_id={0};", newSoldier.id.ToString());
                readcommand = new SQLiteCommand(readChildren, m_dbConnection);
                SQLiteDataReader childrenReader = readcommand.ExecuteReader();

                while (childrenReader.Read())
                {
                    child newChild = new child();
                    newChild.name.first = childrenReader["f_name"].ToString();
                    newChild.name.middle = childrenReader["mid_name"].ToString();
                    newChild.name.last = childrenReader["l_name"].ToString();
                    newChild.name.maiden = childrenReader["maid_name"].ToString();
                    newChild.soldierID = Convert.ToInt32( childrenReader["soldier_id"]);
                    newChild.spouseID = Convert.ToInt32( childrenReader["spouse_id"]);

                    newSoldier.children.Add(newChild);
                }

                //read residences
                string readResidences = String.Format("select * from residences where soldier_id={0};", newSoldier.id.ToString());
                readcommand = new SQLiteCommand(readResidences, m_dbConnection);
                SQLiteDataReader resReader = readcommand.ExecuteReader();

                while (resReader.Read())
                {
                    residence newRes = new residence();
                    newRes.moveInDate.day = Convert.ToInt32(resReader["b_date_day"]);
                    newRes.moveInDate.month = Convert.ToInt32(resReader["b_date_month"]);
                    newRes.moveInDate.year = Convert.ToInt32(resReader["b_date_year"]);
                    newRes.moveOutDate.day = Convert.ToInt32(resReader["e_date_day"]);
                    newRes.moveOutDate.month = Convert.ToInt32(resReader["e_date_month"]);
                    newRes.moveOutDate.year = Convert.ToInt32(resReader["e_date_year"]);
                    newRes.place.city = resReader["city"].ToString();
                    newRes.place.county = resReader["county"].ToString();
                    newRes.place.state = resReader["state"].ToString();
                    newRes.place.country = resReader["country"].ToString();

                    newSoldier.residences.Add(newRes);
                }

                //read ranks
                string readPositions = String.Format("select * from ranks where soldier_id={0};", newSoldier.id.ToString());
                readcommand = new SQLiteCommand(readPositions, m_dbConnection);
                SQLiteDataReader posReader = readcommand.ExecuteReader();

                while (posReader.Read())
                {
                    newSoldier.servicePositions.Add(posReader["rank"].ToString());
                }

                //read troops
                string readTroops = String.Format("select * from troops where soldier_id={0};", newSoldier.id.ToString());
                readcommand = new SQLiteCommand(readTroops, m_dbConnection);
                SQLiteDataReader troopsReader = readcommand.ExecuteReader();

                while (troopsReader.Read())
                {
                    newSoldier.serviceTroops.Add(troopsReader["troop"].ToString());
                }

                //read superiors
                string readSuperiors = String.Format("select * from superiors where soldier_id={0};", newSoldier.id.ToString());
                readcommand = new SQLiteCommand(readSuperiors, m_dbConnection);
                SQLiteDataReader supReader = readcommand.ExecuteReader();

                while (supReader.Read())
                {
                    newSoldier.serviceSuperiors.Add(supReader["superior"].ToString());
                }

                newSoldier.serviceAddedText = reader["service_text"].ToString();
                newSoldier.residenceAddedText = reader["residence_text"].ToString();
                newSoldier.markerText = reader["marker_text"].ToString();
                newSoldier.pensionNumber = reader["pension_number"].ToString();
                newSoldier.pensionText = reader["pension_text"].ToString();
                newSoldier.sources = reader["sources"].ToString();
                newSoldier.addedText = reader["added_text"].ToString();

                soldiers.Add(newSoldier);
            }

            return soldiers;
        }
Ejemplo n.º 4
0
 public comboMother(spouse m)
 {
     mother = m;
 }
Ejemplo n.º 5
0
 //adds a spouse to the spouse table.
 //PRE: must have unique ID
 public void addSpouse(spouse spouseToAdd,Int32 soldierID)
 {
     string sql = string.Format("insert into spouses (id, soldier_id, f_name, mid_name, l_name, maid_name, m_date_day, m_date_month, m_date_year, m_loc_city, m_loc_county, m_loc_state, m_loc_country) values ({0}, {1}, '{2}', '{3}', '{4}', '{5}', {6}, {7}, {8}, '{9}', '{10}', '{11}', '{12}');",
         spouseToAdd.id, soldierID, spouseToAdd.name.first, spouseToAdd.name.middle, spouseToAdd.name.last, spouseToAdd.name.maiden,
         spouseToAdd.marriageDate.day, spouseToAdd.marriageDate.month, spouseToAdd.marriageDate.year,
         spouseToAdd.marriageLocation.city, spouseToAdd.marriageLocation.county, spouseToAdd.marriageLocation.state, spouseToAdd.marriageLocation.country);
     SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
     command.ExecuteNonQuery();
 }