Esempio n. 1
0
        //add to the residence table
        public void addResidence(residence resToAdd, Int32 soldierID)
        {
            string sql = string.Format("insert into residences (soldier_id, b_date_day, b_date_month, b_date_year, e_date_day, e_date_month, e_date_year, city, county, state, country) values ({0}, {1}, {2}, {3}, {4}, {5}, {6}, '{7}', '{8}', '{9}', '{10}');",
                soldierID, resToAdd.moveInDate.day, resToAdd.moveInDate.month, resToAdd.moveInDate.year,
                resToAdd.moveOutDate.day, resToAdd.moveOutDate.month, resToAdd.moveOutDate.year,
                resToAdd.place.city, resToAdd.place.county, resToAdd.place.state, resToAdd.place.country);

            SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
            command.ExecuteNonQuery();
        }
Esempio n. 2
0
        private void buttonAddResidence_Click(object sender, EventArgs e)
        {
            residence newResidence = new residence();
            newResidence.place.city = textBoxResidenceCity.Text;
            newResidence.place.county = comboBoxResidenceCounty.Text;
            newResidence.place.state = textBoxResidenceState.Text;
            newResidence.place.country = textBoxResidenceCountry.Text;
            newResidence.moveInDate.day = comboDaytoInt(comboBoxMoveInDay);
            newResidence.moveInDate.month = comboMonthtoInt(comboBoxMoveInMonth);
            newResidence.moveInDate.year = comboYeartoInt(comboBoxMoveInYear);
            newResidence.moveOutDate.day = comboDaytoInt(comboBoxMoveOutDay);
            newResidence.moveOutDate.month = comboMonthtoInt(comboBoxMoveOutMonth);
            newResidence.moveOutDate.year = comboYeartoInt(comboBoxMoveOutYear);

            string[] resLine = { newResidence.place.ToString(), newResidence.moveInDate.ToString(), newResidence.moveOutDate.ToString() };
            ListViewItem newItem = new ListViewItem(resLine);
            newItem.Tag = newResidence;
            listViewResidences.Items.Add(newItem);

            //clear
            textBoxResidenceCity.Clear();
            textBoxResidenceCountry.Clear();
            comboBoxResidenceCounty.Text="";
            textBoxResidenceState.Clear();
            comboBoxMoveInDay.SelectedIndex = 0;
            comboBoxMoveInMonth.SelectedIndex = 0;
            comboBoxMoveInYear.SelectedIndex = 0;
            comboBoxMoveOutDay.SelectedIndex = 0;
            comboBoxMoveOutMonth.SelectedIndex = 0;
            comboBoxMoveOutYear.SelectedIndex = 0;
        }
Esempio 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;
        }