Пример #1
0
 void DgReportSheet_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         FamilyTree ft = FamilyTree.Instance;
         if (e.ColumnIndex >= startColumnIndex && e.ColumnIndex <= endColumnIndex)
         {
             DataGridViewCell cell = dgReportSheet.Rows[e.RowIndex].Cells[e.ColumnIndex];
             int value             = (int)cell.Value;
             if (value >= 1 && value <= 7) // allows any type of record to search census
             {
                 IDisplayColourCensus person = (IDisplayColourCensus)dgReportSheet.Rows[e.RowIndex].DataBoundItem;
                 int censusYear;
                 if (_country.Equals(Countries.UNITED_STATES))
                 {
                     censusYear = (1790 + (e.ColumnIndex - startColumnIndex) * 10);
                 }
                 else if (_country.Equals(Countries.CANADA))
                 {
                     if (e.ColumnIndex <= dgReportSheet.Columns["Can1901"].Index)
                     {
                         censusYear = (1851 + (e.ColumnIndex - startColumnIndex) * 10);
                     }
                     else
                     {
                         censusYear = (1901 + (e.ColumnIndex - dgReportSheet.Columns["Can1901"].Index) * 5);
                     }
                 }
                 else if (_country.Equals(Countries.IRELAND))
                 {
                     censusYear = (1901 + (e.ColumnIndex - startColumnIndex) * 10);
                 }
                 else
                 {
                     if (e.ColumnIndex == C1939.Index)
                     {
                         censusYear = 1939;
                     }
                     else
                     {
                         censusYear = (1841 + (e.ColumnIndex - startColumnIndex) * 10);
                     }
                 }
                 string censusCountry = person.BestLocation(new FactDate(censusYear.ToString())).CensusCountry;
                 if (censusYear == 1939 &&
                     !cbCensusSearchProvider.SelectedItem.Equals("Find My Past") &&
                     !cbCensusSearchProvider.SelectedItem.Equals("Ancestry"))
                 {
                     MessageBox.Show($"Unable to search the 1939 National Register on {cbCensusSearchProvider.SelectedItem}.", "FTAnalyzer");
                 }
                 else
                 {
                     try
                     {
                         ft.SearchCensus(censusCountry, censusYear, ft.GetIndividual(person.IndividualID), cbCensusSearchProvider.SelectedIndex, cbRegion.Text);
                     }
                     catch (CensusSearchException ex)
                     {
                         MessageBox.Show(ex.Message);
                     }
                 }
             }
         }
         else if (e.ColumnIndex >= 0)
         {
             string     indID    = (string)dgReportSheet.CurrentRow.Cells["IndividualID"].Value;
             Individual ind      = ft.GetIndividual(indID);
             Facts      factForm = new Facts(ind);
             factForm.Show();
         }
     }
 }