public FindOpenVehicleProblemsByVehicleIDDataSet FindOpenVehicleProblemsbyVehicleID(int intVehicleID)
        {
            try
            {
                aFindOpenVehicleProblemsByVehicleIDDataSet      = new FindOpenVehicleProblemsByVehicleIDDataSet();
                aFindOpenVehicleProblemsByVehicleIDTableAdapter = new FindOpenVehicleProblemsByVehicleIDDataSetTableAdapters.FindOpenVehicleProblemsByVehicleIDTableAdapter();
                aFindOpenVehicleProblemsByVehicleIDTableAdapter.Fill(aFindOpenVehicleProblemsByVehicleIDDataSet.FindOpenVehicleProblemsByVehicleID, intVehicleID);
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Vehicle Problems Class // Find Open Vehicle Problems By Vehicle ID // " + Ex.Message);
            }

            return(aFindOpenVehicleProblemsByVehicleIDDataSet);
        }
        private void UpdateVehicleStatus()
        {
            int intCounter;
            int intNumberOfRecords;
            int intVehicleID;
            int intRecordsReturned;
            bool blnFatalError = false;
            string strStatus;

            try
            {
                //getting the vehicles
                TheFindActiveVehiclesDataSet = TheVehicleClass.FindActiveVehicles();

                intNumberOfRecords = TheFindActiveVehiclesDataSet.FindActiveVehicles.Rows.Count - 1;

                for(intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    intVehicleID = TheFindActiveVehiclesDataSet.FindActiveVehicles[intCounter].VehicleID;

                    TheFindOpenVehicleProblemsByVehicleIDDataSet = TheVehicleProblemClass.FindOpenVehicleProblemsbyVehicleID(intVehicleID);
                    
                    intRecordsReturned = TheFindOpenVehicleProblemsByVehicleIDDataSet.FindOpenVehicleProblemsByVehicleID.Rows.Count;

                    if(intRecordsReturned > 0)
                    {
                        //checking to see what the status is
                        TheFindVehicleStatusByVehicleIDDataSet = TheVehicleStatusClass.FindVehicleStatusByVehicleID(intVehicleID);

                        intRecordsReturned = TheFindVehicleStatusByVehicleIDDataSet.FindVehicleStatusByVehicleID.Rows.Count;
                        
                        if(intRecordsReturned == 1)
                        {
                            strStatus = TheFindVehicleStatusByVehicleIDDataSet.FindVehicleStatusByVehicleID[0].VehicleStatus;

                            if((strStatus == "AVAILABLE") || (strStatus == "SIGNED OUT"))
                            {
                                blnFatalError = TheVehicleStatusClass.UpdateVehicleStatus(intVehicleID, "NEEDS WORK", DateTime.Now);

                                if (blnFatalError == true)
                                    throw new Exception();
                            }
                            if(strStatus == "NO PROBLEM")
                            {
                                blnFatalError = TheVehicleStatusClass.UpdateVehicleStatus(intVehicleID, "NEEDS WORK", DateTime.Now);

                                if (blnFatalError == true)
                                    throw new Exception();
                            }
                        }
                    }
                    else if (intRecordsReturned == 0)
                    {
                        TheFindVehicleStatusByVehicleIDDataSet = TheVehicleStatusClass.FindVehicleStatusByVehicleID(intVehicleID);

                        intRecordsReturned = TheFindVehicleStatusByVehicleIDDataSet.FindVehicleStatusByVehicleID.Rows.Count;

                        if(intRecordsReturned == 1)
                        {
                            if(TheFindVehicleStatusByVehicleIDDataSet.FindVehicleStatusByVehicleID[0].VehicleStatus != "NO PROBLEM")
                            {
                                blnFatalError = TheVehicleStatusClass.UpdateVehicleStatus(intVehicleID, "NO PROBLEM", DateTime.Now);

                                if (blnFatalError == true)
                                    throw new Exception();
                            }
                        }
                        else if (intRecordsReturned == 0)
                        {
                            blnFatalError = TheVehicleStatusClass.InsertVehicleStatus(intVehicleID, "NO PROBLEM", DateTime.Now);

                            if (blnFatalError == true)
                                throw new Exception();
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Event Log Tracker // Update Vehicle Status " + Ex.Message);
            }
        }
        private void mitProcess_Click(object sender, RoutedEventArgs e)
        {
            //this will process the information
            string strValueForValidation;
            bool   blnFatalError      = false;
            bool   blnThereIsAProblem = false;
            string strErrorMessage    = "";
            string strVehicleNumber;
            int    intRecordsReturned;

            try
            {
                strVehicleNumber = txtEnterBJCNumber.Text;
                TheFindVehicleMainByVehicleNumberDataSet = TheVehicleMainClass.FindActiveVehicleMainByVehicleNumber(strVehicleNumber);
                intRecordsReturned = TheFindVehicleMainByVehicleNumberDataSet.FindActiveVehicleMainByVehicleNumber.Rows.Count;
                if (intRecordsReturned == 0)
                {
                    blnFatalError    = true;
                    strErrorMessage += "Vehicle Number Entered Was Not Found\n";
                }
                else
                {
                    MainWindow.gintVehicleID = TheFindVehicleMainByVehicleNumberDataSet.FindActiveVehicleMainByVehicleNumber[0].VehicleID;
                }
                strValueForValidation = cboEmployee.SelectedItem.ToString();
                if (strValueForValidation == "Select Employee")
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Employee Was Not Selected\n";
                }
                if (rdoFailed.IsChecked == false)
                {
                    if (rdoPassed.IsChecked == false)
                    {
                        if (rdoPassedServiceRequired.IsChecked == false)
                        {
                            blnFatalError    = true;
                            strErrorMessage += "Passed, Passed Service Required, or Failure Was Not Checked\n";
                        }
                    }
                }
                strValueForValidation = txtOdometerReading.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyIntegerData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Odometer Reading is not an Integer\n";
                }
                else
                {
                    MainWindow.gintOdometerReading = Convert.ToInt32(strValueForValidation);
                }
                if (cboVehicleCleanliness.SelectedIndex == 0)
                {
                    blnFatalError    = true;
                    strErrorMessage += "Cleanliness Was Not Selected\n";
                }

                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMessage);
                    return;
                }


                MainWindow.gdatTransactionDate = DateTime.Now;

                blnFatalError = TheWeeklyInspectionClass.InsertWeeklyVehicleInspection(MainWindow.gintVehicleID, MainWindow.gdatTransactionDate, MainWindow.gintEmployeeID, MainWindow.gstrInspectionStatus, MainWindow.gintOdometerReading);

                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage("There Was a Problem, Contact ID");
                    return;
                }

                TheFindWeeklyVehicleInspectionIDDataSet = TheWeeklyInspectionClass.FindWeelyVehicleInspectionID(MainWindow.gintVehicleID, MainWindow.gintEmployeeID, MainWindow.gintOdometerReading, MainWindow.gdatTransactionDate);

                MainWindow.gintInspectionID = TheFindWeeklyVehicleInspectionIDDataSet.FindWeeklyVehicleInspectionID[0].TransactionID;

                blnFatalError = TheWeeklyVehicleCleanlinessClass.InsertWeeklyVehicleCleanliness(MainWindow.gintInspectionID, MainWindow.gintVehicleID, gblnVehicleCleanliness, MainWindow.gstrCleanlinessNotes);

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

                if ((rdoFailed.IsChecked == true) || (rdoPassedServiceRequired.IsChecked == true))
                {
                    VehicleInspectionProblem VehicleInspectionProblem = new VehicleInspectionProblem();
                    VehicleInspectionProblem.ShowDialog();
                }
                else if (rdoPassed.IsChecked == true)
                {
                    TheFindOpenVehicleProblemsbyVehicleIDDataSet = TheVehicleProblemClass.FindOpenVehicleProblemsbyVehicleID(MainWindow.gintVehicleID);

                    intRecordsReturned = TheFindOpenVehicleProblemsbyVehicleIDDataSet.FindOpenVehicleProblemsByVehicleID.Rows.Count;

                    if (intRecordsReturned > 0)
                    {
                        TheMessagesClass.ErrorMessage("There Are Open Problems with this Vehicle and\nYou Are Reporting No Problems, Please Correct");
                        return;
                    }
                }

                if (rdoFailed.IsChecked == true)
                {
                    PleaseWait PleaseWait = new PleaseWait();
                    PleaseWait.Show();

                    TheVehicleStatusClass.UpdateVehicleStatus(MainWindow.gintVehicleID, "DOWN", DateTime.Now);

                    TheSendEmailClass.EmailMessage(MainWindow.gstrVehicleNumber, MainWindow.gstrVehicleProblem);

                    PleaseWait.Close();
                }

                BulkToolsAssignedToVehicle BulkToolsAssignedToVehicle = new BulkToolsAssignedToVehicle();
                BulkToolsAssignedToVehicle.ShowDialog();

                txtEnterBJCNumber.Text = "";
                cboEmployee.Items.Clear();
                txtEnterLastName.Text               = "";
                txtOdometerReading.Text             = "";
                rdoFailed.IsChecked                 = false;
                rdoPassed.IsChecked                 = false;
                rdoPassedServiceRequired.IsChecked  = false;
                cboBodyDamageReported.SelectedIndex = 0;
                cboVehicleCleanliness.SelectedIndex = 0;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Manager Weekly Audit Data Entry // Process Menu Item " + Ex.Message);

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