private FindDuplicateVehicleAssignmentsDataSet FindDuplicateVehicleAssignments()
        {
            try
            {
                aFindDuplicateVehicleAsignmentsDataSet = new FindDuplicateVehicleAssignmentsDataSet();
                aFindDuplicateVehicleAssignmentsTableAdapter = new FindDuplicateVehicleAssignmentsDataSetTableAdapters.FindDuplicateVehicleAssignmentsTableAdapter();
                aFindDuplicateVehicleAssignmentsTableAdapter.Fill(aFindDuplicateVehicleAsignmentsDataSet.FindDuplicateVehicleAssignments);
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Event Log Tracker // Main Window // Find Duplicate Vehicle Assignments " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }


            return aFindDuplicateVehicleAsignmentsDataSet;
        }
        private void UpdateGrid()
        {
            //setting variables
            int intNumberOfRecords;
            bool blnFatalError = false;
            DateTime datEndDate = DateTime.Now;
            DateTime datStartDate = DateTime.Now;

            try
            {
                TheFindDuplicateVehicleAssignmentsDataSet = FindDuplicateVehicleAssignments();

                intNumberOfRecords = TheFindDuplicateVehicleAssignmentsDataSet.FindDuplicateVehicleAssignments.Rows.Count;

                if(intNumberOfRecords > 0)
                {
                    blnFatalError = TheSendEmailClass.SendEmail("*****@*****.**", "New Event Log Entry", "We Have a Duplicate Vehicle Assignment Event");
                    if (blnFatalError == true)
                        throw new Exception();

                    TheMessagesClass.ErrorMessage("We Have a Duplicate Vehicle Assignment Event");
                }

                TheFindDuplicateProjectMatrixDataSet = TheProjectMatrixClass.FindDuplicateProjectMatrix();

                intNumberOfRecords = TheFindDuplicateProjectMatrixDataSet.FindDuplicateProjectMatrix.Rows.Count;

                if(intNumberOfRecords > 0)
                {
                    blnFatalError = CreateDuplicateProjectEmail();

                    if (blnFatalError == true)
                        throw new Exception();
                }

                datEndDate = TheDateSearchClass.RemoveTime(datEndDate);

                datStartDate = TheDateSearchClass.SubtractingDays(datEndDate, 5);

                datEndDate = TheDateSearchClass.AddingDays(datEndDate, 1);

                TheFindEventLogByDateRangeDataSet = TheEventLogClass.FindEventLogByDateRange(datStartDate, datEndDate);

                intNumberOfRecords = TheFindEventLogByDateRangeDataSet.FindEventLogEntriesByDateRange.Rows.Count;

                if (intNumberOfRecords != gintNumberOfRecords)
                {
                    gintNumberOfRecords = intNumberOfRecords;
                    intNumberOfRecords -= 1;

                    blnFatalError = TheSendEmailClass.SendEmail("*****@*****.**", "New Event Log Entry", TheFindEventLogByDateRangeDataSet.FindEventLogEntriesByDateRange[0].LogEntry);

                    if (blnFatalError == true)
                        throw new Exception();

                    blnFatalError = TheSendEmailClass.SendEmail("*****@*****.**", "New Event Log Entry", TheFindEventLogByDateRangeDataSet.FindEventLogEntriesByDateRange[0].LogEntry);

                    if (blnFatalError == true)
                        throw new Exception();

                    dgrResults.ItemsSource = TheFindEventLogByDateRangeDataSet.FindEventLogEntriesByDateRange;

                }

                dgrResults.ItemsSource = TheFindEventLogByDateRangeDataSet.FindEventLogEntriesByDateRange;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Event Log Tracker // Main Window // Update Grid " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }           
            
        }