Esempio n. 1
0
 private void buttonOk_Click(object sender, EventArgs e)
 {
     this.Save();
     this.tv           = (TroopVisit)bindingList[dataGridView1.SelectedRows[0].Index];
     this.DialogResult = System.Windows.Forms.DialogResult.OK;
     this.Close();
 }
Esempio n. 2
0
 private DailyData()
 {
     this.TroopVisit             = new TroopVisit();
     this.NewSightings           = new List <IndividualSighting>();
     this.NewIndividuals         = new List <Individual>();
     this.NewReproductiveStates  = new List <IndividualReproductiveState>();
     this.NewTroopVisitObservers = new List <TroopVisitObserver>();
 }
Esempio n. 3
0
        public StateEditor(ISession session, Individual individual, T _state, string stateSelectQuery, bool currentTroopVisitsOnly = true)
        {
            InitializeComponent();

            this.individual = individual;
            if (currentTroopVisitsOnly)
            {
                this.tvs = new TroopVisitSelector(individual.CurrentTroop());
            }
            else
            {
                this.tvs = new TroopVisitSelector();
            }

            // Get the list of states
            this.comboBoxState.DataSource = session
                                            .CreateQuery(stateSelectQuery)
                                            .List <S>();

            if (_state != null)
            {
                this.state = _state;
                //this.individualReproductiveStateBindingSource.DataSource = state;
                this.troopVisit                 = state.TroopVisit;
                this.labelTroopVisit.Text       = state.TroopVisit.ToString();
                this.comboBoxState.SelectedItem = state.State;

                this.textBoxComments.Text = state.Comments;
            }
            else
            {
                // Set some defaults values
                this.state            = new T();
                this.state.Individual = individual;
                //this.timeDateTimePicker.Value = DateTime.Today;

                // We cannot set all the values so do not let
                // user hit ok for now
                this.buttonOk.Enabled = false;
            }

            if (comboBoxState.Items.Count <= 0)
            {
                MessageBox.Show("There are no States in the database to select from!");
                this.DialogResult = System.Windows.Forms.DialogResult.Abort;
                this.Close();
                return;
            }

            this.labelStateDescription.Text = ((S)comboBoxState.SelectedValue).Description;

            // hook up cotrol validation
            this.comboBoxState.SelectedValueChanged += new EventHandler(StateChangedEventHandler);

            ValidEntry();
        }
Esempio n. 4
0
        private void buttonTroopVisitSelect_Click(object sender, EventArgs e)
        {
            TroopVisitSelector tvs = new TroopVisitSelector();

            if (tvs.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this.troopVisit = tvs.TroopVisit;
                ChangeStage(Stage.NewIndividuals);
            }
        }
Esempio n. 5
0
        private void buttonTroopVisistSelect_Click(object sender, EventArgs e)
        {
            DialogResult result = tvs.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                this.labelTroopVisit.Text = tvs.TroopVisit.ToString();
                this.troopVisit           = tvs.TroopVisit;
            }
            ValidEntry();
        }
Esempio n. 6
0
        private void buttonTroopVisit_Click(object sender, EventArgs e)
        {
            TroopVisitEditor tve = new TroopVisitEditor(Session);

            if (tve.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this.troopVisit = tve.TroopVisit;
                Session.SaveOrUpdate(troopVisit);
                // Go to the next stage
                this.ChangeStage(Stage.NewIndividuals);
            }
        }
        public ReproductiveStateChanges(TroopVisit troopVisit)
        {
            this.troopVisit = troopVisit;
            this.Text       = "Reproducive States:- " + troopVisit.ToString();

            foreach (ReproductiveState r in Session
                     .CreateQuery("from ReproductiveState").List <ReproductiveState>())
            {
                ReproductiveStateButton b = new ReproductiveStateButton(r);
                b.Click += new System.EventHandler(ReproductiveStateButton_click);
                this.DataGridView.ContextMenuStrip.Items.Add(b);
            }
        }
Esempio n. 8
0
        public void Load(TroopVisit troopVisit)
        {
            RetrievedData = true;

            TroopVisit = troopVisit;

            // Load all the data with this troop visit reference
            ISession     session = NHibernateHelper.GetCurrentSession();
            ITransaction tx      = session.BeginTransaction();

            TroopVisit = session.Get <TroopVisit>(troopVisit.ID);
            NHibernateUtil.Initialize(TroopVisit.AMSleepingCliff);
            NHibernateUtil.Initialize(TroopVisit.PMSleepingCliff);
            tx.Commit();
        }
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            session = NHibernateHelper.OpenNewSession();
            tx      = session.BeginTransaction();

            // Get all troop visits before this date
            mostRecentTroopVisit = session
                                   .CreateQuery("select tv from TroopVisit as tv " +
                                                "left join fetch tv.Troop as t " +
                                                "where t.TroopID = :troopID and " +
                                                "tv.Date < :date " +
                                                "order by tv.Date desc")
                                   .SetParameter <string>("troopID", DailyData.Current.TroopVisit.Troop.TroopID)
                                   .SetParameter <DateTime>("date", DailyData.Current.TroopVisit.Date.Date)
                                   .SetMaxResults(1)
                                   .UniqueResult <TroopVisit>();

            // Lets get any individual sightings for this troop visit
            // that are uncertain
            if (mostRecentTroopVisit != null)
            {
                previousSightings = session
                                    .CreateQuery("select s from IndividualSighting as s " +
                                                 "left join fetch s.TroopVisit as tv " +
                                                 "left join fetch s.Individual as i " +
                                                 "left join fetch i.ReproductiveStateHistory " +
                                                 "left join fetch i.AgeClassHistory " +
                                                 "left join fetch i.SightingHistory " +
                                                 "left join fetch s.Sighting " +
                                                 "left join fetch i.Mother as m " +
                                                 "left join fetch m.ReproductiveStateHistory " +
                                                 "left join fetch m.AgeClassHistory " +
                                                 "left join fetch m.SightingHistory " +
                                                 "where tv = :troopVisit ")
                                    .SetParameter <TroopVisit>("troopVisit", mostRecentTroopVisit)
                                    .SetResultTransformer(new DistinctRootEntityResultTransformer())
                                    .List <IndividualSighting>();
            }

            // Absentees can only be existing members from this troop
            individuals = Individual.LoadAll(session);

            // Cache these values for later
            notSeen = session.Get <Sighting>("NS");
            seen    = session.Get <Sighting>("S");

            tx.Commit();
        }
Esempio n. 10
0
        public TroopVisitEditor(ISession session, TroopVisit troopVisit = null)
        {
            InitializeComponent();
            this.troopVisit = troopVisit;

            // Fill comboboxes
            System.Collections.Generic.IList <Location> locations = session
                                                                    .CreateQuery("select l from Location as l")
                                                                    .List <Location>();

            foreach (Location l in locations)
            {
                this.aMSleepingCliffComboBox.Items.Add(l);
                this.pMSleepingCliffComboBox.Items.Add(l);
            }

            this.troopComboBox.DataSource = session
                                            .CreateQuery("select t from Troop as t")
                                            .List <Troop>();

            // Are we editing or making a new entry?
            if (troopVisit != null)
            {
                // Read in values from troopvisit
                this.aMSleepingCliffComboBox.SelectedItem = troopVisit.AMSleepingCliff;
                this.pMSleepingCliffComboBox.SelectedItem = troopVisit.PMSleepingCliff;
                this.troopComboBox.SelectedItem           = troopVisit.Troop;
                this.dateDateTimePicker.Value             = troopVisit.Date;
                this.commentsTextBox.Text          = troopVisit.Comments;
                this.waterCheckBox.Checked         = troopVisit.Water;
                this.gPSRouteCheckBox.Checked      = troopVisit.GPSRoute;
                this.fullDayFollowCheckBox.Checked = troopVisit.FullDayFollow;
                this.distanceTextBox.Text          = troopVisit.Distance.ToString();
            }
            else
            {
                this.troopVisit = new TroopVisit();
            }

            // Hook up the crucial controls to the validity check
            this.troopComboBox.SelectedValueChanged           += new EventHandler(controlValueChanged);
            this.aMSleepingCliffComboBox.SelectedValueChanged += new EventHandler(controlValueChanged);
            this.pMSleepingCliffComboBox.SelectedValueChanged += new EventHandler(controlValueChanged);
            this.dateDateTimePicker.ValueChanged += new EventHandler(controlValueChanged);
            this.distanceTextBox.TextChanged     += new EventHandler(controlValueChanged);

            ValidEntry();
        }
Esempio n. 11
0
        bool checkIDValidity(List <Individual> individuals, TroopVisit troopVisit, Individual.SexEnum sex, string ID)
        {
            bool valid = true;
            int  dummy = 0;

            // Valid if of form troopid + sex + number, length 4 and not already in use
            valid &= ID.StartsWith(troopVisit.Troop.TroopID + sex.ToString()) || ID.StartsWith(troopVisit.Troop.TroopID + sex.ToString());
            valid &= int.TryParse(ID.Substring(2, 2), out dummy);
            valid &= ID.Length == 4;

            //foreach (Individual i in individuals)
            //{
            //    if (i.ID == ID)
            //        valid = false;
            //}
            return(valid);
        }
        /// <summary>
        /// Will get the most recent entry in collection
        /// before the troopVisit date that is for the troopVisit troop
        /// retireving only a certain entry if specified.
        /// </summary>
        /// <param name="troopVisit"></param>
        /// <param name="collection"></param>
        /// <param name="certainOnly"></param>
        /// <returns></returns>
        public static T GetCurrentOnTroopVisit(TroopVisit troopVisit, ICollection <T> collection, bool certainOnly = false)
        {
            T mostRecent = default(T);

            foreach (T a in collection)
            {
                if (a.TroopVisit.Troop.TroopID == troopVisit.Troop.TroopID &&
                    a.TroopVisit.Date <= troopVisit.Date &&
                    (certainOnly == false || a.State.Certain))
                {
                    if (mostRecent == null || mostRecent.TroopVisit.Date < a.TroopVisit.Date ||
                        (mostRecent.TroopVisit.Date == a.TroopVisit.Date && mostRecent.State.Priority < a.State.Priority))
                    {
                        mostRecent = a;
                    }
                }
            }
            return(mostRecent);
        }
        public bool Finish()
        {
            if (radioButtonNew.Checked)
            {
                // Check to see if this already exists
                tx = session.BeginTransaction();
                TroopVisit existingTroopVisit = session.CreateQuery("select tv from TroopVisit as tv "
                                                                    + "where tv.Date = :date and tv.Troop = :troop")
                                                .SetParameter <DateTime>("date", this.dateDateTimePicker.Value.Date)
                                                .SetParameter <Troop>("troop", (Troop)this.troopComboBox.SelectedValue)
                                                .UniqueResult <TroopVisit>();
                tx.Commit();

                if (existingTroopVisit != null) // i.e data already exists for today
                {
                    if (MessageBox.Show("There is a current troop visit already entered for this date and troop." +
                                        "Press OK to edit the existing data for this troop visit.",
                                        "Data already entered", MessageBoxButtons.OKCancel,
                                        MessageBoxIcon.Information,
                                        MessageBoxDefaultButton.Button1) == DialogResult.OK)
                    {
                        DailyData.Current.Load(existingTroopVisit);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    DailyData.Current.TroopVisit.Troop = (Troop)this.troopComboBox.SelectedValue;
                    DailyData.Current.TroopVisit.Date  = this.dateDateTimePicker.Value.Date;
                }
            }
            else
            {
                DailyData.Current.Load(troopVisits[dataGridViewRecentTroopVisits.CurrentRow.Index]);
            }

            return(true);
        }
Esempio n. 14
0
        public SightingChanges(TroopVisit tv)
        {
            this.bindingSource = new BindingSource();

            this.troop      = tv.Troop;
            this.troopVisit = tv;
            this.Text       = "Current Sightings:- " + tv.ToString();

            // Add context menu to datagridview
            ContextMenuStrip  rowContextMenu = new ContextMenuStrip();
            ToolStripMenuItem notSeenButton  = new ToolStripMenuItem();

            notSeenButton.Text   = "Set to Not Seen";
            notSeenButton.Click += new System.EventHandler(notSeenButton_Click);
            ToolStripMenuItem editButton = new ToolStripMenuItem();

            editButton.Text   = "Advanced entry";
            editButton.Click += new System.EventHandler(editButton_Click);
            //this.DataGridView.ContextMenuStrip = rowContextMenu;
            this.DataGridView.ContextMenuStrip.Items.AddRange(new ToolStripItem[] { notSeenButton, editButton });
        }
        public void LoadData()
        {
            ISession     session = NHibernateHelper.GetCurrentSession();
            ITransaction tx      = session.BeginTransaction();

            females = Individual.LoadAllFemales(session);

            adult   = session.Get <AgeClass>("A");
            unknown = session.Get <ReproductiveState>("U");

            BindingList <ReproductiveState> states = new BindingList <ReproductiveState>(session
                                                                                         .CreateQuery("from ReproductiveState").List <ReproductiveState>());

            this.comboBoxState.DataSource    = states;
            this.comboBoxStateNew.DataSource = new BindingList <ReproductiveState>(states);

            // Get troop visit before this date
            TroopVisit mostRecentTroopVisit = session
                                              .CreateQuery("select tv from TroopVisit as tv " +
                                                           "left join fetch tv.Troop as t " +
                                                           //"left join fetch tv.Observers " +
                                                           "where t.TroopID = :troopID and " +
                                                           "tv.Date < :date " +
                                                           "order by tv.Date desc")
                                              .SetParameter <string>("troopID", DailyData.Current.TroopVisit.Troop.TroopID)
                                              .SetParameter <DateTime>("date", DailyData.Current.TroopVisit.Date.Date)
                                              .SetMaxResults(1)
                                              .UniqueResult <TroopVisit>();

            // If we have a previous troop visit date, then lets get all the
            // previous reproductive states
            if (mostRecentTroopVisit != null)
            {
                initialReproductiveStates = (List <IndividualReproductiveState>)session
                                            .CreateQuery("select r from IndividualReproductiveState as r " +
                                                         "left join fetch r.TroopVisit as tv " +
                                                         "left join fetch tv.Observers " +
                                                         "where tv = :troopVisit ")
                                            .SetParameter <TroopVisit>("troopVisit", mostRecentTroopVisit)
                                            .SetResultTransformer(new DistinctRootEntityResultTransformer())
                                            .List <IndividualReproductiveState>();
            }

            List <IndividualReproductiveState> tempReproductivestateList = new List <IndividualReproductiveState>(initialReproductiveStates);

            // Lets also get all the current ones for today, if they are already entered
            if (DailyData.Current.RetrievedData)
            {
                todaysReproductiveStates = (List <IndividualReproductiveState>)session
                                           .CreateQuery("select r from IndividualReproductiveState as r " +
                                                        "left join fetch r.TroopVisit as tv " +
                                                        "left join fetch tv.Observers " +
                                                        "where tv = :troopVisit ")
                                           .SetParameter <TroopVisit>("troopVisit", DailyData.Current.TroopVisit)
                                           .SetResultTransformer(new DistinctRootEntityResultTransformer())
                                           .List <IndividualReproductiveState>();

                // List todays entries if there are any
                foreach (IndividualReproductiveState s in todaysReproductiveStates)
                {
                    bool replacement = false;
                    for (int i = 0; i < todaysReproductiveStates.Count; i++)
                    {
                        if (tempReproductivestateList[i].Individual.ID == s.Individual.ID)
                        {
                            tempReproductivestateList[i] = s;
                            replacement = true;
                            break;
                        }
                    }
                    if (!replacement)
                    {
                        tempReproductivestateList.Add(s);
                    }
                }
            }

            tx.Commit();

            females = females.FindAll(new Predicate <Individual>(x =>
                                                                 x.CurrentTroop(DailyData.Current.TroopVisit.Date) != null &&
                                                                 x.CurrentTroop(DailyData.Current.TroopVisit.Date).TroopID == DailyData.Current.TroopVisit.Troop.TroopID));

            // Add any new individuals from previous page
            females.AddRange(DailyData.Current.NewIndividuals.FindAll(
                                 new Predicate <Individual>(x =>
                                                            x.Sex == Individual.SexEnum.F)));

            // Remove females who already have entries
            foreach (IndividualReproductiveState irs in tempReproductivestateList)
            {
                int index = females.FindIndex(new Predicate <Individual>(x =>
                                                                         x.ID == irs.Individual.ID));
                if (index >= 0)
                {
                    females.RemoveAt(index);
                }
            }


            if (females.Count == 0)
            {
                this.comboBoxFemales.Enabled  = false;
                this.buttonAdd.Enabled        = false;
                this.comboBoxStateNew.Enabled = false;
            }
            else
            {
                this.comboBoxFemales.DataSource = females;
            }

            // Set missing individuals to unknown automatically
            // Check to see if the individual was not seen today, replace with unknown if so
            for (int i = 0; i < tempReproductivestateList.Count; i++)
            {
                IndividualReproductiveState current = tempReproductivestateList[i];

                // We do not need to replace exising unknow entries for today
                if (current.State != unknown &&
                    current.TroopVisit.Date.Date != DailyData.Current.TroopVisit.Date.Date &&
                    DailyData.Current.MissingToday.FindIndex(
                        x => x.ID == current.Individual.ID) > -1)
                {
                    IndividualReproductiveState irs = new IndividualReproductiveState();
                    irs.TroopVisit = DailyData.Current.TroopVisit;
                    irs.Individual = current.Individual;
                    irs.State      = unknown;
                    irs.Comments   = "AUTOMATICALLY GENERATED ENTRY :- Not seen on this troop visit.";
                    tempReproductivestateList[i] = irs;
                }
            }

            // Finally lets remove any individuals who have been listed as migrated
            // fropm the list
            foreach (Individual i in DailyData.Current.MigratedToday)
            {
                int index = tempReproductivestateList.FindIndex(x => x.Individual.ID == i.ID);
                if (index >= 0)
                {
                    tempReproductivestateList.RemoveAt(index);
                }
            }

            this.boundReproductiveStates  = new SortableBindingList <IndividualReproductiveState>(tempReproductivestateList);
            this.dataGridView1.DataSource = boundReproductiveStates;

            FinishedLoading(this, null);
        }
Esempio n. 16
0
        public IndividualEditor(TroopVisit troopVisitFirstObserved, Individual individual = null)
        {
            InitializeComponent();
            this.troopVisitFirstObserved = troopVisitFirstObserved;

            // Fill combo boxes
            this.comboBoxSex.Items.Add(Individual.SexEnum.M);
            this.comboBoxSex.Items.Add(Individual.SexEnum.F);

            this.comboBoxAgeClass.DataSource = Session
                                               .CreateQuery("select a from AgeClass as a")
                                               .List <AgeClass>();

            this.comboBoxSighting.DataSource = Session
                                               .CreateQuery("select t from Sighting as t " +
                                                            "where Observed = 1")
                                               .List <Sighting>();

            this.individuals = Individual.LoadAll(Session);

            // Just want the females
            this.comboBoxMother.DataSource = individuals
                                             .FindAll(new Predicate <Individual>(x => x.Sex == Domain.Individual.SexEnum.F));

            if (individual != null)
            {
                isNew = false;
                // set values for the control from the individual
                this.individual = Session.Get <Individual>(individual.ID);
                this.bindingSourceIndividual.DataSource = Individual;
                this.comboBoxSex.SelectedItem           = Individual.Sex;
                if (Individual.FirstAgeClass() != null)
                {
                    this.comboBoxAgeClass.SelectedItem = Individual
                                                         .FirstAgeClass().AgeClass;
                }
                this.comboBoxSighting.SelectedItem = Individual
                                                     .FirstSighting().Sighting;
                this.comboBoxMother.SelectedItem = Individual
                                                   .Mother;

                // Set the descriptions
                this.labelSightingDescription.Text =
                    ((Sighting)comboBoxSighting.SelectedValue).Description;
                this.labelAgeClassDescription.Text =
                    ((AgeClass)comboBoxAgeClass.SelectedValue).Description;
            }
            else
            {
                isNew = true;
                // create a new individual
                this.individual = new Individual();
                this.bindingSourceIndividual.DataSource = individual;

                // Clear the combo boxes
                this.comboBoxMother.SelectedIndex   = -1;
                this.comboBoxSighting.SelectedIndex = -1;
                this.comboBoxAgeClass.SelectedIndex = -1;
            }


            this.comboBoxSighting.SelectedValueChanged += new EventHandler(comboBoxSighting_SelectedValueChanged);
            this.comboBoxAgeClass.SelectedValueChanged += new EventHandler(comboBoxAgeClass_SelectedValueChanged);

            this.textBoxName.TextChanged               += new EventHandler(ValidityCheck);
            this.comboBoxSex.SelectedValueChanged      += new EventHandler(ValidityCheck);
            this.comboBoxAgeClass.SelectedValueChanged += new EventHandler(ValidityCheck);
            this.comboBoxSighting.SelectedValueChanged += new EventHandler(ValidityCheck);
            this.textBoxTrappingID.TextChanged         += new EventHandler(ValidityCheck);
        }
Esempio n. 17
0
        public void LoadData()
        {
            this.currentNotSeen.Clear();

            // Should never happen but...
            if (DailyData.Current.TroopVisit == null)
            {
                MessageBox.Show("There is no current troop visit, cannot load data.");
                return;
            }

            session = NHibernateHelper.OpenNewSession();
            tx      = session.BeginTransaction();

            // Cache these values for later
            notSeen    = session.Get <Sighting>("NS");
            seen       = session.Get <Sighting>("S");
            absent     = session.Get <Sighting>("A");
            immigrated = session.Get <Sighting>("IM");

            // Get the last 5 (maxUncertainSightings) troop visits before this date
            lastTroopVisits = new List <TroopVisit>(session
                                                    .CreateQuery("select tv from TroopVisit as tv " +
                                                                 "left join fetch tv.Troop as t " +
                                                                 "where t.TroopID = :troopID and " +
                                                                 "tv.Date < :date " +
                                                                 "order by tv.Date desc")
                                                    .SetParameter <string>("troopID", DailyData.Current.TroopVisit.Troop.TroopID)
                                                    .SetParameter <DateTime>("date", DailyData.Current.TroopVisit.Date.Date)
                                                    .SetMaxResults(maxUncertainSightings)
                                                    .List <TroopVisit>());

            // Note the mostRecentTroopVisit prior to this one
            if (lastTroopVisits.Count > 0)
            {
                mostRecentTroopVisit = lastTroopVisits[0];
            }

            // Get all the individuals
            individuals = Individual.LoadAll(session);

            // We want all individual sightings for this troop visit and the last
            // if possible
            List <IndividualSighting> currentIndividualSightings = null;

            if (mostRecentTroopVisit != null && DailyData.Current.RetrievedData)
            {
                currentIndividualSightings = new List <IndividualSighting>(
                    session.CreateQuery("select s from IndividualSighting as s " +
                                        "where s.TroopVisit = :troopVisit or " +
                                        "s.TroopVisit = :troopVisit2")
                    .SetParameter <TroopVisit>("troopVisit", mostRecentTroopVisit)
                    .SetParameter <TroopVisit>("troopVisit2", DailyData.Current.TroopVisit)
                    //.SetMaxResults(maxUncertainSightings)
                    .List <IndividualSighting>());
            }
            else if (mostRecentTroopVisit != null)
            {
                TroopVisit tv = DailyData.Current.RetrievedData ? DailyData.Current.TroopVisit : mostRecentTroopVisit;
                currentIndividualSightings = new List <IndividualSighting>(
                    session.CreateQuery("select s from IndividualSighting as s " +
                                        "where s.TroopVisit = :troopVisit ")
                    .SetParameter <TroopVisit>("troopVisit", tv)
                    //.SetMaxResults(maxUncertainSightings)
                    .List <IndividualSighting>());
            }

            tx.Commit();

            // A list for sorting
            List <IndividualSighting> sightings = new List <IndividualSighting>();

            // List an entry for each individual
            foreach (Individual i in individuals)
            {
                // Find any sightings for this troop visit or the last troop visit
                // for this individual
                List <IndividualSighting> individualSightingCandidates = new List <IndividualSighting>();
                if (currentIndividualSightings != null)
                {
                    individualSightingCandidates = currentIndividualSightings.FindAll(x => x.Individual.ID == i.ID);
                }

                if (individualSightingCandidates.Count > 0) // Does this individual have an uncertain entry to list?
                {
                    // we want the most recent one to be displayed
                    IndividualSighting mostRecent = null;
                    foreach (IndividualSighting s in individualSightingCandidates)
                    {
                        if (mostRecent == null || s.TroopVisit.Date > mostRecent.TroopVisit.Date)
                        {
                            mostRecent = s;
                        }
                    }
                    sightings.Add(mostRecent);
                }
                else // if not add the current certain sighting that is an inclusion
                {
                    IndividualSighting s = i.CurrentSighting(DailyData.Current.TroopVisit,
                                                             true);
                    if (s != null && s.State.Inclusion)
                    {
                        sightings.Add(s);
                    }
                }
            }

            // Sort reverse date order
            sightings.Sort((x, y) => - 1 * x.TroopVisit.Date.CompareTo(y.TroopVisit.Date));

            // Add to the datagridview
            currentNotSeen = new BindingList <IndividualSighting>(sightings);
            this.individualSightingBindingSource.DataSource = currentNotSeen;

            // Filter individuals not from this troop only, either current troop == null
            // or current troop is differnet
            individuals = individuals.FindAll(new Predicate <Individual>(x =>
                                                                         x.CurrentTroop(DailyData.Current.TroopVisit.Date) == null || (
                                                                             x.CurrentTroop(DailyData.Current.TroopVisit.Date) != null &&
                                                                             (x.CurrentTroop(DailyData.Current.TroopVisit.Date).TroopID != DailyData.Current.TroopVisit.Troop.TroopID))));

            // Add to combo box
            this.comboBoxIndividuals.DataSource = individuals;

            CheckComplete();
            this.FinishedLoading(this, null);
        }