//menustrip public void menuStripViewSoldierList_Click(object sender, EventArgs e) { listViewSoldiers.View = View.Details; listViewSoldiers.GridLines = true; listViewSoldiers.FullRowSelect = true; setupListviewForSoldierObjectPrint(); try { List<Soldier> printSoldiers = new database(databaseFile).Soldiers(); foreach (Soldier s in printSoldiers) { s.printToListView(listViewSoldiers); } } catch { MessageBox.Show("There was a problem reading the database.\nPlease verify file location and try again."); } }
//compiles the soldier and changes database //for new soldiers, generates id and add it //for existing, updates (removes then adds) private void buttonSubmit_Click(object sender, EventArgs e) { if (textBoxSoldierFirstName.Text == "" && textBoxSoldierLastName.Text == "") { MessageBox.Show("Cannot Submit without a name!"); return; } database db = new database(databaseFile); detailsSoldier.soldierName.first = textBoxSoldierFirstName.Text; detailsSoldier.soldierName.middle = textBoxSoldierMiddleName.Text; detailsSoldier.soldierName.last = textBoxSoldierLastName.Text; detailsSoldier.soldierName.maiden = textBoxSoldierMaidenName.Text; detailsSoldier.birthDate.day = comboDaytoInt(comboBoxBirthDay); detailsSoldier.birthDate.month = comboMonthtoInt(comboBoxBirthMonth); detailsSoldier.birthDate.year = comboYeartoInt(comboBoxBirthYear); detailsSoldier.birthLocation.city = textBoxBirthCity.Text; detailsSoldier.birthLocation.county = comboBoxBirthCounty.Text; detailsSoldier.birthLocation.state = textBoxBirthState.Text; detailsSoldier.birthLocation.country = textBoxBirthCountry.Text; detailsSoldier.deathDate.day = comboDaytoInt(comboBoxDeathDay); detailsSoldier.deathDate.month = comboMonthtoInt(comboBoxDeathMonth); detailsSoldier.deathDate.year = comboYeartoInt(comboBoxDeathYear); detailsSoldier.deathLocation.city = textBoxDeathCity.Text; detailsSoldier.deathLocation.county = comboBoxDeathCounty.Text; detailsSoldier.deathLocation.state = textBoxDeathState.Text; detailsSoldier.deathLocation.country = textBoxDeathCountry.Text; detailsSoldier.cemetery = textBoxCemetery.Text; detailsSoldier.cemeteryLatitude = textBoxLatitude.Text; detailsSoldier.cemeteryLongitude = textBoxLongitude.Text; detailsSoldier.cemeteryLocation.city = textBoxCemeteryCity.Text; detailsSoldier.cemeteryLocation.county = comboBoxCemeteryCounty.Text; detailsSoldier.cemeteryLocation.state = textBoxCemeteryState.Text; detailsSoldier.cemeteryLocation.country = textBoxCemeteryCountry.Text; detailsSoldier.serviceAddedText = textBoxService.Text; detailsSoldier.residenceAddedText = textBoxResidenceText.Text; List<String> newPositionList = new List<String>(); foreach (ListViewItem lvi in listViewPositions.Items) { newPositionList.Add((String)lvi.Tag); } detailsSoldier.servicePositions = newPositionList; List<String> newTroopList = new List<String>(); foreach (ListViewItem lvi in listViewTroops.Items) { newTroopList.Add((String)lvi.Tag); } detailsSoldier.serviceTroops = newTroopList; List<String> newSuperiorsList = new List<String>(); foreach (ListViewItem lvi in listViewSuperiors.Items) { newSuperiorsList.Add((String)lvi.Tag); } detailsSoldier.serviceSuperiors = newSuperiorsList; detailsSoldier.pensionNumber = textBoxPension.Text; detailsSoldier.pensionText = textBoxPensionDetails.Text; List<spouse> newSpouseList = new List<spouse>(); foreach (ListViewItem lvi in listViewSpouses.Items) { if(((spouse)lvi.Tag).id>0) newSpouseList.Add((spouse)lvi.Tag); else { Int32 tempID = ((spouse)lvi.Tag).id; ((spouse)lvi.Tag).id = db.findNewSpouseID(); foreach (ListViewItem childItem in listViewChildren.Items) { if (((child)childItem.Tag).spouseID == tempID) { ((child)childItem.Tag).spouseID = ((spouse)lvi.Tag).id; } } newSpouseList.Add((spouse)lvi.Tag); } } detailsSoldier.spouses = newSpouseList; List<child> newChildrenList = new List<child>(); foreach (ListViewItem lvi in listViewChildren.Items) { newChildrenList.Add((child)lvi.Tag); } detailsSoldier.children = newChildrenList; List<residence> newResidenceList = new List<residence>(); foreach (ListViewItem lvi in listViewResidences.Items) { newResidenceList.Add((residence)lvi.Tag); } detailsSoldier.residences = newResidenceList; detailsSoldier.markerText = textBoxMarker.Text; detailsSoldier.addedText = textBoxExtra.Text; detailsSoldier.sources = textBoxSources.Text; //add soldier you have just compiled to database //################################################# if (newSoldier) { detailsSoldier.id = new database(databaseFile).findNewSoldierID(); db.addSoldier(detailsSoldier); } else db.updateSoldier(detailsSoldier); //add to other tables db.removeSpouses(detailsSoldier); foreach (spouse s in detailsSoldier.spouses) { db.addSpouse(s, detailsSoldier.id); } db.removeChildren(detailsSoldier); foreach (child c in detailsSoldier.children) { db.addChild(c, detailsSoldier.id); } db.removeResidences(detailsSoldier); foreach (residence r in detailsSoldier.residences) { db.addResidence(r, detailsSoldier.id); } db.removeRanks(detailsSoldier); foreach (String r in detailsSoldier.servicePositions) { db.addRank(r, detailsSoldier.id); } db.removeSuperiors(detailsSoldier); foreach (String s in detailsSoldier.serviceSuperiors) { db.addSuperior(s, detailsSoldier.id); } db.removeTroops(detailsSoldier); foreach (String t in detailsSoldier.serviceTroops) { db.addTroop(t, detailsSoldier.id); } //################################################### parentForm.menuStripViewSoldierList_Click(null, null); this.Close(); }
//sorting and filtering //refreshes the list to match the filter private void textBoxFilter_TextChanged(object sender, EventArgs e) { listViewSoldiers.Items.Clear(); List<Soldier> printSoldiers = new database().Soldiers(); String[] words = textBoxFilter.Text.Split(' '); bool containsAll; foreach (Soldier s in printSoldiers) { containsAll = true; foreach (String w in words) { w.ToLower(); if (!s.filter(w)) { containsAll = false; break; } } if(containsAll) s.printToListView(listViewSoldiers); } }
//disabled. Might reenable if future interest private void menuStripItemPrintLatexBook_Click(object sender, EventArgs e) { StreamWriter texfile; //NEW SaveFileDialog saveFileDialog1 = new SaveFileDialog();//NEW List<String> spouseStrings = new List<String>(); List<countySoldier> countyIndex = new List<countySoldier>(); saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";//NEW saveFileDialog1.FilterIndex = 2;//NEW saveFileDialog1.RestoreDirectory = true;//NEW if (saveFileDialog1.ShowDialog() == DialogResult.OK)//NEW { texfile = new StreamWriter(@saveFileDialog1.FileName.ToString());//NEW //StreamWriter file = new StreamWriter(@path + "book.txt"); // StreamWriter texfile = new StreamWriter(@path + "book.tex"); List<Soldier> soldiersToPrint = new database(databaseFile).Soldiers(); soldiersToPrint.Sort(); texfile.WriteLine("\\documentclass{article}"); texfile.WriteLine("\\usepackage{fullpage}"); texfile.WriteLine("\\usepackage{multicol}"); texfile.WriteLine("\\begin{document}"); foreach (Soldier s in soldiersToPrint) { //NAME //file.WriteLine("#" + s.soldierName.bookString() + "#"); texfile.WriteLine("\\noindent \\textbf{" + s.soldierName.bookString() + "}\n"); //BORN: if (s.birthDate.day == 0 && s.birthDate.month == 0 && s.birthDate.year == 0) //no date { if (s.birthLocation.ToString() != "") { //file.WriteLine("Born: " + s.birthLocation.ToString()); texfile.WriteLine("Born: " + s.birthLocation.ToString() + "\n"); } //else nothing. no born info } else { if (s.birthLocation.ToString() != "") { // file.WriteLine("Born: " + s.birthDate.BookString() + " in " + s.birthLocation.ToString()); texfile.WriteLine("Born: " + s.birthDate.BookString() + " in " + s.birthLocation.ToString() + "\n"); } else { //file.WriteLine("Born: " + s.birthDate.BookString()); texfile.WriteLine("Born: " + s.birthDate.BookString() + "\n"); } } //DIED: if (s.deathDate.day == 0 && s.deathDate.month == 0 && s.deathDate.year == 0) //no date { if (s.deathLocation.ToString() != "") { //file.WriteLine("Died: " + s.deathLocation.ToString()); texfile.WriteLine("Died: " + s.deathLocation.ToString() + "\n"); } //else nothing. no born info } else { if (s.deathLocation.ToString() != "") { //file.WriteLine("Died: " + s.deathDate.BookString() + " in " + s.deathLocation.ToString()); texfile.WriteLine("Died: " + s.deathDate.BookString() + " in " + s.deathLocation.ToString() + "\n"); } else { //file.WriteLine("Died: " + s.deathDate.BookString()); texfile.WriteLine("Died: " + s.deathDate.BookString() + "\n"); } } //BURIED: if (s.cemetery != "" || s.cemeteryLocation.ToString() != "" || s.cemeteryLatitude != "" || s.cemeteryLongitude != "") { //file.Write("Buried: " + s.cemetery + " " + s.cemeteryLocation.ToString()); //latitude and longitude texfile.Write("Buried: " + s.cemetery + " " + s.cemeteryLocation.ToString()); if (s.cemeteryLatitude != "") { //file.Write(" Latitude: " + s.cemeteryLatitude); texfile.Write(" Latitude: " + s.cemeteryLatitude); } if (s.cemeteryLongitude != "") { //file.Write(" Longitude: " + s.cemeteryLongitude); texfile.Write(" Longitude: " + s.cemeteryLongitude); } //file.WriteLine(); texfile.WriteLine("\n"); } //##################################### //String indexCounty; if (s.cemeteryLocation.county != "") { if (s.cemeteryLocation.isIllinoisCounty()) countyIndex.Add(new countySoldier(s.soldierName, s.cemeteryLocation.county)); } else if (s.deathLocation.county != "") { if (s.deathLocation.isIllinoisCounty()) countyIndex.Add(new countySoldier(s.soldierName, s.deathLocation.county)); } if (s.residences.Count > 0) { //file.WriteLine("Residences: "); texfile.WriteLine("Residences:\n"); foreach (residence r in s.residences) { //file.WriteLine(" " + r.ToString()); texfile.WriteLine(" " + r.ToString() + "\n"); } } if (s.spouses.Count > 0) { //file.WriteLine("Spouses: "); texfile.WriteLine("Spouses:\n"); foreach (spouse sp in s.spouses) { //file.WriteLine(" " + sp.ToString()); texfile.WriteLine(" " + sp.ToString() + "\n"); spouseStrings.Add(sp.name.bookString() + "(" + s.soldierName.bookString() + ")"); //spousePrint } } if (s.children.Count > 0) { //file.WriteLine("Children: "); texfile.WriteLine("Children: \n"); foreach (child c in s.children) { //file.WriteLine(" " + c.ToString()); texfile.WriteLine(" " + c.ToString() + "\n"); } } if (s.serviceAddedText != "" || s.servicePositions.Count > 0 || s.serviceSuperiors.Count > 0 || s.serviceTroops.Count > 0) { //file.WriteLine("Service: " + s.serviceAddedText); texfile.WriteLine("Service: " + s.serviceAddedText + "\n"); if (s.servicePositions.Count > 0) { //file.WriteLine(" Positions: "); texfile.WriteLine(" Positions: \n"); foreach (String p in s.servicePositions) { //file.WriteLine(" " + p); texfile.WriteLine(" " + p + "\n"); } } if (s.serviceTroops.Count > 0) { //file.WriteLine(" Troops:"); texfile.WriteLine(" Troops: \n"); foreach (String t in s.serviceTroops) { //file.WriteLine(" " + t); texfile.WriteLine(" " + t + "\n"); } } if (s.serviceSuperiors.Count > 0) { //file.WriteLine(" Superiors:"); texfile.WriteLine(" Superiors: \n"); foreach (String sup in s.serviceSuperiors) { //file.WriteLine(" " + sup); texfile.WriteLine(" " + sup + "\n"); } } } if (s.pensionNumber != "" || s.pensionText != "") { //file.WriteLine("Pension: " + s.pensionNumber + " " + s.pensionText); texfile.WriteLine("Pension: " + s.pensionNumber + " " + s.pensionText + "\n"); } if (s.markerText != "") { //file.WriteLine("Marker: " + s.markerText); texfile.WriteLine("Marker: " + s.markerText + "\n"); } if (s.addedText != "") { //file.WriteLine("Additional Info: " + s.addedText); texfile.WriteLine("Additional Info: " + s.addedText + "\n"); } if (s.sources != "") { //file.WriteLine("Sources: " + s.sources); texfile.WriteLine("Sources: " + s.sources + "\n"); } //indexes } texfile.WriteLine("County Index:\n"); countyIndex.Sort(); String prev = ""; List<String> soldiersInCounty = new List<String>(); foreach (countySoldier c in countyIndex) { if (c.county != prev) { soldiersInCounty.Sort(); foreach (String str in soldiersInCounty) { texfile.WriteLine(str + "\n"); } soldiersInCounty.Clear(); texfile.WriteLine(c.county + " County:\n"); prev = c.county; } soldiersInCounty.Add(c.soldierName.bookString()); //texfile.WriteLine(c.soldierName.bookString()+"\n"); } foreach (String str in soldiersInCounty) { texfile.WriteLine(str + "\n"); } spouseStrings.Sort(); texfile.WriteLine("Spouse Index:\n"); foreach (String str in spouseStrings) { texfile.WriteLine(str+"\n"); } texfile.WriteLine("\\end{document}"); //file.Close(); texfile.Close(); } }
//creates an empty database from the template database private void menuStripItemCreateDatabase_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog1 = new SaveFileDialog();//NEW saveFileDialog1.Filter = "s3db files (*.s3db)|*.s3db";//NEW //saveFileDialog1.FilterIndex = 1;//NEW saveFileDialog1.RestoreDirectory = true;//NEW //bool fileSpecified = true; if (saveFileDialog1.ShowDialog() == DialogResult.OK)//NEW { String path = new database().path; System.IO.File.Copy(path + "soldierdb_template.s3db", saveFileDialog1.FileName.ToString(), true); try { //txtBrowse.Text = browseFile.FileName; SoldiersForm secondaryDatabase = new SoldiersForm(saveFileDialog1.FileName.ToString(), this); secondaryDatabase.Show(); secondaryDatabase.buttonSubmitToMaster.Show(); secondaryDatabase.menuStripItemOpenDatabase.Enabled = false; secondaryDatabase.Text = "Secondary Database - " + saveFileDialog1.FileName.ToString(); } catch (Exception) { MessageBox.Show("Error opening file", "File Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
private void buttonSubmitToMaster_Click(object sender, EventArgs e) { database master = new database(); foreach (ListViewItem lvi in listViewSoldiers.Items) { Soldier newSoldier = (Soldier)lvi.Tag; newSoldier.id = master.findNewSoldierID(); foreach (spouse sps in newSoldier.spouses) { sps.id = -sps.id; } foreach (child c in newSoldier.children) { c.soldierID = newSoldier.id; c.spouseID = -c.spouseID; } foreach (spouse sps in newSoldier.spouses) { Int32 tempID = sps.id; sps.id = master.findNewSpouseID(); foreach (child c in newSoldier.children) { if (c.spouseID == tempID) { c.spouseID = sps.id; } } } master.addSoldier(newSoldier); foreach (spouse s in newSoldier.spouses) { master.addSpouse(s, newSoldier.id); } foreach (child c in newSoldier.children) { master.addChild(c, newSoldier.id); } foreach (residence r in newSoldier.residences) { master.addResidence(r, newSoldier.id); } foreach (String r in newSoldier.servicePositions) { master.addRank(r, newSoldier.id); } foreach (String s in newSoldier.serviceSuperiors) { master.addSuperior(s, newSoldier.id); } foreach (String t in newSoldier.serviceTroops) { master.addTroop(t, newSoldier.id); } } parentForm.menuStripViewSoldierList_Click(null, null); this.Close(); //MessageBox.Show("The master list should be refreshed before new entries will be shown. \nRefresh the list under the View menu."); }
//THIS NOW DOES SEARCHING. DOES NOT ADD TO DATABASE private void buttonSearch_Click(object sender, EventArgs e) { database db = new database(databaseFile); detailsSoldier.soldierName.first = textBoxSoldierFirstName.Text; detailsSoldier.soldierName.middle = textBoxSoldierMiddleName.Text; detailsSoldier.soldierName.last = textBoxSoldierLastName.Text; detailsSoldier.soldierName.maiden = textBoxSoldierMaidenName.Text; detailsSoldier.birthDate.day = comboDaytoInt(comboBoxBirthDay); detailsSoldier.birthDate.month = comboMonthtoInt(comboBoxBirthMonth); detailsSoldier.birthDate.year = comboYeartoInt(comboBoxBirthYear); detailsSoldier.birthLocation.city = textBoxBirthCity.Text; detailsSoldier.birthLocation.county = comboBoxBirthCounty.Text; detailsSoldier.birthLocation.state = textBoxBirthState.Text; detailsSoldier.birthLocation.country = textBoxBirthCountry.Text; detailsSoldier.deathDate.day = comboDaytoInt(comboBoxDeathDay); detailsSoldier.deathDate.month = comboMonthtoInt(comboBoxDeathMonth); detailsSoldier.deathDate.year = comboYeartoInt(comboBoxDeathYear); detailsSoldier.deathLocation.city = textBoxDeathCity.Text; detailsSoldier.deathLocation.county = comboBoxDeathCounty.Text; detailsSoldier.deathLocation.state = textBoxDeathState.Text; detailsSoldier.deathLocation.country = textBoxDeathCountry.Text; detailsSoldier.cemetery = textBoxCemetery.Text; detailsSoldier.cemeteryLatitude = textBoxLatitude.Text; detailsSoldier.cemeteryLongitude = textBoxLongitude.Text; detailsSoldier.cemeteryLocation.city = textBoxCemeteryCity.Text; detailsSoldier.cemeteryLocation.county = comboBoxCemeteryCounty.Text; detailsSoldier.cemeteryLocation.state = textBoxCemeteryState.Text; detailsSoldier.cemeteryLocation.country = textBoxCemeteryCountry.Text; detailsSoldier.serviceAddedText = textBoxService.Text; detailsSoldier.residenceAddedText = textBoxResidenceAddedText.Text; List<String> newPositionList = new List<String>(); foreach (ListViewItem lvi in listViewPositions.Items) { newPositionList.Add((String)lvi.Tag); } detailsSoldier.servicePositions = newPositionList; List<String> newTroopList = new List<String>(); foreach (ListViewItem lvi in listViewTroops.Items) { newTroopList.Add((String)lvi.Tag); } detailsSoldier.serviceTroops = newTroopList; List<String> newSuperiorsList = new List<String>(); foreach (ListViewItem lvi in listViewSuperiors.Items) { newSuperiorsList.Add((String)lvi.Tag); } detailsSoldier.serviceSuperiors = newSuperiorsList; detailsSoldier.pensionNumber = textBoxPension.Text; detailsSoldier.pensionText = textBoxPensionDetails.Text; List<spouse> newSpouseList = new List<spouse>(); foreach (ListViewItem lvi in listViewSpouses.Items) { //if (((spouse)lvi.Tag).id > 0) // newSpouseList.Add((spouse)lvi.Tag); //else //{ // Int32 tempID = ((spouse)lvi.Tag).id; // ((spouse)lvi.Tag).id = db.findNewSpouseID(); // foreach (ListViewItem childItem in listViewChildren.Items) // { // if (((child)childItem.Tag).spouseID == tempID) // { // ((child)childItem.Tag).spouseID = ((spouse)lvi.Tag).id; // } // } newSpouseList.Add((spouse)lvi.Tag); //} } detailsSoldier.spouses = newSpouseList; List<child> newChildrenList = new List<child>(); foreach (ListViewItem lvi in listViewChildren.Items) { newChildrenList.Add((child)lvi.Tag); } detailsSoldier.children = newChildrenList; List<residence> newResidenceList = new List<residence>(); foreach (ListViewItem lvi in listViewResidences.Items) { newResidenceList.Add((residence)lvi.Tag); } detailsSoldier.residences = newResidenceList; detailsSoldier.markerText = textBoxMarker.Text; detailsSoldier.addedText = textBoxExtra.Text; detailsSoldier.sources = textBoxSources.Text; //detailsSoldier is compiled //search now parentForm.setupListviewForSoldierObjectPrint(); foreach (Soldier s in db.Soldiers()) { if( s.soldierName.first.ToLower().Contains(detailsSoldier.soldierName.first.ToLower()) && s.soldierName.middle.ToLower().Contains(detailsSoldier.soldierName.middle.ToLower()) && s.soldierName.last.ToLower().Contains(detailsSoldier.soldierName.last.ToLower()) && s.soldierName.maiden.ToLower().Contains(detailsSoldier.soldierName.maiden.ToLower()) && (detailsSoldier.birthDate.day==0 ? true : detailsSoldier.birthDate.day==s.birthDate.day) && (detailsSoldier.birthDate.month==0 ? true : detailsSoldier.birthDate.month==s.birthDate.month) && (detailsSoldier.birthDate.year==0 ? true : detailsSoldier.birthDate.year==s.birthDate.year) && s.birthLocation.city.ToLower().Contains(detailsSoldier.birthLocation.city.ToLower()) && s.birthLocation.county.ToLower().Contains(detailsSoldier.birthLocation.county.ToLower()) && s.birthLocation.country.ToLower().Contains(detailsSoldier.birthLocation.country.ToLower()) && s.birthLocation.state.ToLower().Contains(detailsSoldier.birthLocation.state.ToLower()) && (detailsSoldier.deathDate.day==0 ? true : detailsSoldier.deathDate.day==s.deathDate.day) && (detailsSoldier.deathDate.month==0 ? true : detailsSoldier.deathDate.month==s.deathDate.month) && (detailsSoldier.deathDate.year==0 ? true : detailsSoldier.deathDate.year==s.deathDate.year) && s.deathLocation.city.ToLower().Contains(detailsSoldier.deathLocation.city.ToLower()) && s.deathLocation.county.ToLower().Contains(detailsSoldier.deathLocation.county.ToLower()) && s.deathLocation.country.ToLower().Contains(detailsSoldier.deathLocation.country.ToLower()) && s.deathLocation.state.ToLower().Contains(detailsSoldier.deathLocation.state.ToLower()) && s.cemetery.ToLower().Contains(detailsSoldier.cemetery.ToLower()) && s.cemeteryLatitude.ToLower().Contains(detailsSoldier.cemeteryLatitude.ToLower()) && s.cemeteryLongitude.ToLower().Contains(detailsSoldier.cemeteryLongitude.ToLower()) && s.cemeteryLocation.city.ToLower().Contains(detailsSoldier.cemeteryLocation.city.ToLower()) && s.cemeteryLocation.county.ToLower().Contains(detailsSoldier.cemeteryLocation.county.ToLower()) && s.cemeteryLocation.country.ToLower().Contains(detailsSoldier.cemeteryLocation.country.ToLower()) && s.cemeteryLocation.state.ToLower().Contains(detailsSoldier.cemeteryLocation.state.ToLower()) && s.pensionNumber.ToLower().Contains(detailsSoldier.pensionNumber.ToLower()) ) { bool valid = true; String[] serviceWords = detailsSoldier.serviceAddedText.Split(' '); foreach (String str in serviceWords) { if (!s.serviceAddedText.ToLower().Contains(str.ToLower())) { valid = false; break; } } String[] residenceWords = detailsSoldier.residenceAddedText.Split(' '); foreach (String str in residenceWords) { if (!s.residenceAddedText.ToLower().Contains(str.ToLower())) { valid = false; break; } } String[] markerWords = detailsSoldier.markerText.Split(' '); foreach (String str in markerWords) { if (!s.markerText.ToLower().Contains(str.ToLower())) { valid = false; break; } } String[] pensionWords = detailsSoldier.pensionText.Split(' '); foreach (String str in pensionWords) { if (!s.pensionText.ToLower().Contains(str.ToLower())) { valid = false; break; } } String[] sourcesWords = detailsSoldier.sources.Split(' '); foreach (String str in sourcesWords) { if (!s.sources.ToLower().Contains(str.ToLower())) { valid = false; break; } } String[] addedWords = detailsSoldier.addedText.Split(' '); foreach (String str in addedWords) { if (!s.addedText.ToLower().Contains(str.ToLower())) { valid = false; break; } } foreach (spouse sps in detailsSoldier.spouses) { bool found = false; foreach (spouse sps2 in s.spouses) { if(sps2.name.first.ToLower().Contains(sps.name.first.ToLower()) && sps2.name.middle.ToLower().Contains(sps.name.middle.ToLower()) && sps2.name.last.ToLower().Contains(sps.name.last.ToLower()) && sps2.name.maiden.ToLower().Contains(sps.name.maiden.ToLower()) && sps2.marriageLocation.city.ToLower().Contains(sps.marriageLocation.city.ToLower()) && sps2.marriageLocation.county.ToLower().Contains(sps.marriageLocation.county.ToLower()) && sps2.marriageLocation.state.ToLower().Contains(sps.marriageLocation.state.ToLower()) && sps2.marriageLocation.country.ToLower().Contains(sps.marriageLocation.country.ToLower()) && (sps.marriageDate.day==0 ? true : sps.marriageDate.day==sps2.marriageDate.day) && (sps.marriageDate.month==0 ? true : sps.marriageDate.month==sps2.marriageDate.month) && (sps.marriageDate.year==0 ? true : sps.marriageDate.year==sps2.marriageDate.year) ) { found = true; break; } } if (!found) { valid = false; break; } } foreach (child chld in detailsSoldier.children) { bool found = false; foreach (child chld2 in s.children) { if (chld2.name.first.ToLower().Contains(chld.name.first.ToLower()) && chld2.name.middle.ToLower().Contains(chld.name.middle.ToLower()) && chld2.name.last.ToLower().Contains(chld.name.last.ToLower()) && chld2.name.maiden.ToLower().Contains(chld.name.maiden.ToLower()) ) { found = true; break; } } if (!found) { valid = false; break; } } foreach (residence res in detailsSoldier.residences) { bool found = false; foreach (residence res2 in s.residences) { if(res2.place.city.ToLower().Contains(res.place.city.ToLower()) && res2.place.county.ToLower().Contains(res.place.county.ToLower()) && res2.place.state.ToLower().Contains(res.place.state.ToLower()) && res2.place.country.ToLower().Contains(res.place.country.ToLower()) && (res.moveInDate.day == 0 ? true : res.moveInDate.day == res2.moveInDate.day) && (res.moveInDate.month == 0 ? true : res.moveInDate.month == res2.moveInDate.month) && (res.moveInDate.year == 0 ? true : res.moveInDate.year == res2.moveInDate.year) && (res.moveOutDate.day == 0 ? true : res.moveOutDate.day == res2.moveOutDate.day) && (res.moveOutDate.month == 0 ? true : res.moveOutDate.month == res2.moveOutDate.month) && (res.moveOutDate.year == 0 ? true : res.moveOutDate.year == res2.moveOutDate.year) ) { found = true; break; } } if (!found) { valid = false; break; } } foreach (String str in detailsSoldier.servicePositions) { bool found = false; foreach (String str2 in s.servicePositions) { if (str2.ToLower().Contains(str.ToLower())) { found = true; break; } } if (!found) { valid = false; break; } } foreach (String str in detailsSoldier.serviceTroops) { bool found = false; foreach (String str2 in s.serviceTroops) { if (str2.ToLower().Contains(str.ToLower())) { found = true; break; } } if (!found) { valid = false; break; } } foreach (String str in detailsSoldier.serviceSuperiors) { bool found = false; foreach (String str2 in s.serviceSuperiors) { if (str2.ToLower().Contains(str.ToLower())) { found = true; break; } } if (!found) { valid = false; break; } } //finally, lets check if its valid, and if so, print it if (valid) { s.printToListView(parentForm.listViewSoldiers); } } } //parentForm.menuStripViewSoldierList_Click(null, null); this.Close(); }