//create a new form to display the graph
        private void CreateGraph_Click(object sender, EventArgs e)
        {
            SightingHistoryProcessing sightings = new SightingHistoryProcessing(connection);

            List<int> months = new List<int>();
            int[] values = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            int[] values2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

            List<TrackingEntry> tagged = new List<TrackingEntry>();
            List<TrackingEntry> notag = new List<TrackingEntry>();

            string thestart = StartDate.Value.Year + "-" + StartDate.Value.Month + "-" + StartDate.Value.Day;
            string theEnd = EndDate.Value.Year + "-" + EndDate.Value.Month + "-" + EndDate.Value.Day;

            DateTime start = new DateTime(StartDate.Value.Year, StartDate.Value.Month, StartDate.Value.Day);
            DateTime end = new DateTime(EndDate.Value.Year, EndDate.Value.Month, EndDate.Value.Day);

            List<DateTime> dates = new List<DateTime>();

            int index = Table.Rows.Add();

            int i = 0;
            for (int j = 0; j < values.Length; j++)
            {
                while (end > start)
                {

                    DataGridViewRow row = Table.Rows[index];
                    row.Cells["MonthYear"].Value = start.Month + "-" + start.Year;
                    row.Cells["Tagged"].Value = values[j];
                    row.Cells["nottagged"].Value = values2[j];
                    int val = start.Month;
                    start = start.AddMonths(1);
                    months.Add(val);
                    i++;
                }
            }
            //query interval of dates
            List<TrackingEntry> datelist = new List<TrackingEntry>();
            datelist = sightings.filterByDate(thestart, theEnd);
            //go through list and create a list of tagged and not tagged
            if (datelist == null)
            {
                MessageBox.Show("No Data Found", "Sighting History");
                return;
            }
            foreach(var item in datelist)
            {
                if (item.isTagged)
                {
                    tagged.Add(item);
                }
                else
                {
                    notag.Add(item);
                }
            }
            //compare tagged dates to date range - increment series if valid
            for (int ind = 0; ind < months.LongCount(); ind++)
            {
                DataGridViewRow row = Table.Rows[index];

                foreach (TrackingEntry entry in tagged)
                {
                    Date date = new Date();
                    date.date = entry.entryDate;
                    string year = date.year;
                    string month = date.month;

                    int counter = 0;
                    if (month == months[ind].ToString())
                    {
                        values[Int32.Parse(month) - 1] = values[Int32.Parse(month) - 1] + 1;

                    }
                    row.Cells["Tagged"].Value = values[Int32.Parse(month) - 1];

                }
                foreach (TrackingEntry entry in notag)
                {
                    Date date = new Date();
                    date.date = entry.entryDate;
                    string year = date.year;
                    string month = date.month;

                    if (month == months[ind].ToString())
                    {
                        values2[Int32.Parse(month) - 1] = values2[Int32.Parse(month) - 1] + 1;
                    }
                  row.Cells["NotTagged"].Value = values2[Int32.Parse(month) - 1];

                }

            }
        }
        private void onSubmit_Click(object sender, EventArgs e)
        {
            SightingHistoryProcessing sightings = new SightingHistoryProcessing(connection);
            //string thestart = StartDate.Value.ToShortDateString();
            string thestart = StartDate.Value.Year + "-" + StartDate.Value.Month + "-" + StartDate.Value.Day;
            string theEnd = EndDate.Value.Year + "-" + EndDate.Value.Month + "-" + EndDate.Value.Day;

            //check if all three are checked
            if(ByDate.Checked && Tag.Checked && NoTag.Checked)
            {
                //using query get by interval
                sightinghistorygrid.Rows.Clear();
                sightinghistorygrid.Refresh();

                List<TrackingEntry> dateTagNoTag = new List<TrackingEntry>();
                dateTagNoTag = sightings.filterTagDate(thestart, theEnd);

                if(dateTagNoTag == null)
                {
                    MessageBox.Show("No Records found", "Sighting History");
                    return;
                }

                foreach(var item in dateTagNoTag)
                {
                    int index = sightinghistorygrid.Rows.Add();
                    DataGridViewRow row = sightinghistorygrid.Rows[index];
                    row.Cells["Column1"].Value = item.species;
                    row.Cells["Column2"].Value = item.tagNumber;
                    row.Cells["Column3"].Value = item.entryDate;
                    row.Cells["Column4"].Value = item.taggerName;
                    row.Cells["Column5"].Value = item.taggerID;

                }

            }
            //check if tag and no tag is checked - NO date
            else if(Tag.Checked && NoTag.Checked && !ByDate.Checked)
            {
                //using query getall
                sightinghistorygrid.Rows.Clear();
                sightinghistorygrid.Refresh();

                List<TrackingEntry> TagNoTag = new List<TrackingEntry>();
                TagNoTag = sightings.filterTagNoTag();

                if (TagNoTag == null)
                {
                    MessageBox.Show("No Records found", "Sighting History");
                    return;
                }

                foreach (var item in TagNoTag)
                {
                    int index = sightinghistorygrid.Rows.Add();
                    DataGridViewRow row = sightinghistorygrid.Rows[index];
                    row.Cells["Column1"].Value = item.species;
                    row.Cells["Column2"].Value = item.tagNumber;
                    row.Cells["Column3"].Value = item.entryDate;
                    row.Cells["Column4"].Value = item.taggerName;
                    row.Cells["Column5"].Value = item.taggerID;

                }
            }
            //check if date and tag are checked
            else if (Tag.Checked && ByDate.Checked && !NoTag.Checked)
            {
                sightinghistorygrid.Rows.Clear();
                sightinghistorygrid.Refresh();

                List<TrackingEntry> dateTag = new List<TrackingEntry>();
                dateTag = sightings.filterTagDate(thestart, theEnd);

                if (dateTag == null)
                {
                    MessageBox.Show("No Records found", "Sighting History");
                    return;
                }

                foreach (var item in dateTag)
                {
                    int index = sightinghistorygrid.Rows.Add();
                    DataGridViewRow row = sightinghistorygrid.Rows[index];
                    row.Cells["Column1"].Value = item.species;
                    row.Cells["Column2"].Value = item.tagNumber;
                    row.Cells["Column3"].Value = item.entryDate;
                    row.Cells["Column4"].Value = item.taggerName;
                    row.Cells["Column5"].Value = item.taggerID;

                }

            }
            //check if date and no tag are checked
            else if (NoTag.Checked && ByDate.Checked && !Tag.Checked)
            {
                sightinghistorygrid.Rows.Clear();
                sightinghistorygrid.Refresh();
                List<TrackingEntry> dateNoTag = new List<TrackingEntry>();
                dateNoTag = sightings.filterNoTagDate(thestart, theEnd);

                if (dateNoTag == null)
                {
                    MessageBox.Show("No Records found", "Sighting History");
                    return;
                }

                foreach (var item in dateNoTag)
                {
                    int index = sightinghistorygrid.Rows.Add();
                    DataGridViewRow row = sightinghistorygrid.Rows[index];
                    row.Cells["Column1"].Value = item.species;
                    row.Cells["Column2"].Value = item.tagNumber;
                    row.Cells["Column3"].Value = item.entryDate;
                    row.Cells["Column4"].Value = item.taggerName;
                    row.Cells["Column5"].Value = item.taggerID;

                }
            }
            //check if only date checked
            if (ByDate.Checked)
            {
                sightinghistorygrid.Rows.Clear();
                sightinghistorygrid.Refresh();
                List<TrackingEntry> datelist = new List<TrackingEntry>();

                datelist = sightings.filterByDate(thestart, theEnd);

                if (datelist == null)
                {
                    MessageBox.Show("No Records found", "Sighting History");
                    return;
                }

                foreach (TrackingEntry item in datelist)
                {
                    int index = sightinghistorygrid.Rows.Add();
                    DataGridViewRow row = sightinghistorygrid.Rows[index];
                    row.Cells["Column1"].Value = item.species;
                    row.Cells["Column2"].Value = item.tagNumber;
                    row.Cells["Column3"].Value = item.entryDate;
                    row.Cells["Column4"].Value = item.taggerName;
                    row.Cells["Column5"].Value = item.taggerID;

                }
            }
            //check if tag checked
            else if (Tag.Checked && !ByDate.Checked && !NoTag.Checked)
            {
                sightinghistorygrid.Rows.Clear();
                sightinghistorygrid.Refresh();

                List<TrackingEntry> taggedlist = new List<TrackingEntry>();

                taggedlist = sightings.filterByTag();

                if (taggedlist == null)
                {
                    MessageBox.Show("No Records found", "Sighting History");
                    return;
                }

                foreach (TrackingEntry item in taggedlist)
                {
                    int index = sightinghistorygrid.Rows.Add();
                    DataGridViewRow row = sightinghistorygrid.Rows[index];
                    row.Cells["Column1"].Value = item.species;
                    row.Cells["Column2"].Value = item.tagNumber;
                    row.Cells["Column3"].Value = item.entryDate;
                    row.Cells["Column4"].Value = item.taggerName;
                    row.Cells["Column5"].Value = item.taggerID;

                }
            }
            //check if no tag checked
            else if (NoTag.Checked && !ByDate.Checked && !Tag.Checked)
            {
                sightinghistorygrid.Rows.Clear();
                sightinghistorygrid.Refresh();
                List<TrackingEntry> notaglist = new List<TrackingEntry>();

                notaglist = sightings.filterByNoTag();

                if (notaglist == null)
                {
                    MessageBox.Show("No Records found", "Sighting History");
                    return;
                }
                foreach (TrackingEntry item in notaglist)
                {
                    int index = sightinghistorygrid.Rows.Add();
                    DataGridViewRow row = sightinghistorygrid.Rows[index];
                    row.Cells["Column1"].Value = item.species;
                    row.Cells["Column2"].Value = item.tagNumber;
                    row.Cells["Column3"].Value = item.entryDate;
                    row.Cells["Column4"].Value = item.taggerName;
                    row.Cells["Column5"].Value = item.taggerID;

                }
            }
        }