private void mitProcess_Click(object sender, RoutedEventArgs e)
        {
            bool blnFatalError = false;
            int  intRecordsReturned;
            int  intTransactionID;

            try
            {
                TheFindVehicleInShopbyProblemIDDataSet = TheVehiclesInShopClass.FindVehicleInShopByProblemID(MainWindow.gintProblemID);

                intRecordsReturned = TheFindVehicleInShopbyProblemIDDataSet.FindVehicleInShopByProblemID.Rows.Count;

                if (intRecordsReturned > 0)
                {
                    intTransactionID = TheFindVehicleInShopbyProblemIDDataSet.FindVehicleInShopByProblemID[0].TransactionID;

                    blnFatalError = TheVehiclesInShopClass.UpdateVehicleInShopVendorID(intTransactionID, MainWindow.gintVendorID);

                    if (blnFatalError == true)
                    {
                        throw new Exception();
                    }
                }
                else if (intRecordsReturned < 1)
                {
                    blnFatalError = TheVehiclesInShopClass.InsertVehicleInShop(MainWindow.gintVehicleID, DateTime.Now, MainWindow.gintVendorID, MainWindow.gstrVehicleProblem, MainWindow.gintProblemID);

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

                MessageBoxResult result = MessageBox.Show("Do You Want To Print A Copy of the problem", "Please Choose", MessageBoxButton.YesNo, MessageBoxImage.Question);

                if (result == MessageBoxResult.Yes)
                {
                    TheVehicleProblemPrintClass.PrintVehicleProblemInfo();
                }

                TheMessagesClass.InformationMessage("Vehicle Has Been Sent To Shop");

                ResetControls();
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Send Vehicle To Shop // Process Button " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
        private void mitUpdateProblem_Click(object sender, RoutedEventArgs e)
        {
            //setting up local variables
            bool     blnFatalError      = false;
            string   strErrorMessage    = "";
            string   strVehicleUpdate   = "";
            DateTime datTransactionDate = DateTime.Now;
            int      intRecordsReturned;
            //bool blnItemFound = false;
            int intTransactionID;

            try
            {
                strVehicleUpdate = txtVehicleUpdate.Text;
                if (strVehicleUpdate == "")
                {
                    blnFatalError    = true;
                    strErrorMessage += "Vehicle Update Was Not Entered\n";
                }
                else
                {
                    if (strVehicleUpdate.Length < 20)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "Vehicle Update WAs Not Long Enough\n";
                    }
                }
                if (gblnVehicleInShop == true)
                {
                    if (cboSelectVendor.SelectedIndex < 1)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "Vendor Was Not Selected\n";
                    }
                }
                if (cboVehicleInShop.SelectedIndex < 1)
                {
                    blnFatalError   = true;
                    strErrorMessage = "Vehicle In Shop Was Not Selected\n";
                }
                if (cboWorkComplete.SelectedIndex < 1)
                {
                    blnFatalError   = true;
                    strErrorMessage = "Work Complete Was Not Selected\n";
                }
                if (gblnOrderselected == false)
                {
                    blnFatalError    = true;
                    strErrorMessage += "Vehicle Problem Was Not Selected\n";
                }

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

                blnFatalError = TheVehicleProblemsClass.InsertVehicleProblemUpdate(MainWindow.gintProblemID, MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID, strVehicleUpdate, datTransactionDate);

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

                if (gblnWorkComplete == false)
                {
                    if (gblnVehicleInShop == true)
                    {
                        TheFindVehicleInShopByProblemIDDataSet = TheVehiclesInShopClass.FindVehicleInShopByProblemID(MainWindow.gintProblemID);

                        intRecordsReturned = TheFindVehicleInShopByProblemIDDataSet.FindVehicleInShopByProblemID.Rows.Count;

                        if (intRecordsReturned < 1)
                        {
                            blnFatalError = TheVehiclesInShopClass.InsertVehicleInShop(MainWindow.gintVehicleID, datTransactionDate, MainWindow.gintVendorID, MainWindow.gstrVehicleProblem, MainWindow.gintProblemID);

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

                            blnFatalError = TheVehicleProblemsClass.ChangeVehicleProblemStatus(MainWindow.gintProblemID, "WIP");

                            if (blnFatalError == true)
                            {
                                throw new Exception();
                            }
                        }
                        else
                        {
                            if (TheFindVehicleInShopByProblemIDDataSet.FindVehicleInShopByProblemID[0].VendorID == MainWindow.gintVendorID)
                            {
                            }
                            else
                            {
                                blnFatalError = TheVehicleProblemsClass.UpdateVehicleProblemVendorID(MainWindow.gintProblemID, MainWindow.gintVendorID);

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

                                intTransactionID = TheFindVehicleInShopByProblemIDDataSet.FindVehicleInShopByProblemID[0].TransactionID;

                                blnFatalError = TheVehiclesInShopClass.UpdateVehicleInShopVendorID(intTransactionID, MainWindow.gintVendorID);

                                if (blnFatalError == true)
                                {
                                    throw new Exception();
                                }
                            }
                        }
                    }
                    else
                    {
                        intRecordsReturned = TheFindVehiclesInShopByVehlcleIDDataSet.FindVehiclesInShopByVehicleID.Rows.Count;

                        blnFatalError = TheVehicleProblemsClass.ChangeVehicleProblemStatus(MainWindow.gintProblemID, "NEED WORK");

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

                        if (intRecordsReturned > 0)
                        {
                            blnFatalError = TheVehiclesInShopClass.RemoveVehicleInShop(MainWindow.gintVehicleID);

                            if (blnFatalError == true)
                            {
                                throw new Exception();
                            }
                        }
                    }
                }
                else if (gblnWorkComplete == true)
                {
                    gstrProblemStatus = "AWAITING INVOICE";

                    blnFatalError = TheVehicleProblemsClass.ChangeVehicleProblemStatus(MainWindow.gintProblemID, gstrProblemStatus);

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

                    blnFatalError = TheVehiclesInShopClass.RemoveVehicleInShop(MainWindow.gintVehicleID);

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

                MessageBoxResult result = MessageBox.Show("Do You Want To Print A Copy of the problem", "Please Choose", MessageBoxButton.YesNo, MessageBoxImage.Question);

                if (result == MessageBoxResult.Yes)
                {
                    TheVehicleProblemPrintClass.PrintVehicleProblemInfo();
                }

                TheMessagesClass.InformationMessage("The Vehicle Has Been Updated");

                ResetControls();
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Update Vehicle Problem // Update Problem Menu Item " + Ex.Message);

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