private void btnProcessUpdate_Click(object sender, RoutedEventArgs e)
        {
            string   strProblemStatus;
            string   strProblemResolution;
            string   strValueForValidation;
            string   strProblemUpdate;
            decimal  decInvoiceAmount   = 0;
            DateTime datTransactionDate = DateTime.Now;
            bool     blnFatalError      = false;
            bool     blnThereIsAProblem = false;
            string   strErrorMessage    = "";
            long     intResult;
            string   strTransactionName = "";
            string   strNewLocation;
            string   strInvoiceNumber = "";
            int      intInvoiceID;
            int      intRecordsReturned;

            try
            {
                strProblemStatus = txtProblemStatus.Text;
                if (strProblemStatus.Length < 4)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Problem Status Was Not Entered\n";
                }
                strProblemResolution = txtProblemResolution.Text;
                if (strProblemStatus == "CLOSED")
                {
                    if (strProblemResolution.Length < 10)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "The Problem Resolution Was Not Long Enough\n";
                    }
                    strValueForValidation = txtInvoiceAmount.Text;
                    blnThereIsAProblem    = TheDataValidationClass.VerifyDoubleData(strValueForValidation);
                    if (blnThereIsAProblem == true)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "The Invoice Amount is not Numeric\n";
                    }
                    strInvoiceNumber = txtInvoiceNumber.Text;
                    if (strInvoiceNumber.Length < 2)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "The Invoice Number Was Not Entered\n";
                    }
                }
                strProblemUpdate = txtNewUpdate.Text;
                if (strProblemUpdate.Length < 15)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The New Update was not Long Enough\n";
                }
                strValueForValidation = txtUpdateDate.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDateData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Update Date is not a Date\n";
                }
                else
                {
                    datTransactionDate = Convert.ToDateTime(strValueForValidation);
                }
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMessage);
                    return;
                }

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

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

                blnFatalError = TheVehicleProblemClass.ChangeVehicleProblemStatus(MainWindow.gintProblemID, strProblemStatus);

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

                if (strProblemStatus == "CLOSED")
                {
                    blnFatalError = TheVehicleProblemClass.UpdateVehiclePRoblemCost(MainWindow.gintProblemID, Convert.ToSingle(decInvoiceAmount));

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

                    if (gblnInvoiceAttached == true)
                    {
                        intResult           = datTransactionDate.Year * 10000000000 + datTransactionDate.Month * 100000000 + datTransactionDate.Day * 1000000 + datTransactionDate.Hour * 10000 + datTransactionDate.Minute * 100 + datTransactionDate.Second;
                        strTransactionName += Convert.ToString(intResult);

                        strNewLocation = "\\\\bjc\\shares\\Documents\\WAREHOUSE\\WhseTrac\\VehicleProblemFiles\\" + strTransactionName + ".pdf";

                        System.IO.File.Copy(gstrInvoicePath, strNewLocation);
                    }
                    else
                    {
                        strNewLocation = "NO INVOICE ATTACHED";
                    }

                    blnFatalError = TheVehicleProblemDocumentClass.InsertVehicleInvoice(strInvoiceNumber, datTransactionDate, MainWindow.gintVehicleID, decInvoiceAmount, strNewLocation, MainWindow.gintVendorID);

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

                    TheFindVehicleInvoiceByInvoiceNumberDataSet = TheVehicleProblemDocumentClass.FindVehicleInvoiceByInvoiceNumber(strInvoiceNumber, MainWindow.gintVendorID, MainWindow.gintVehicleID, datTransactionDate);

                    intInvoiceID = TheFindVehicleInvoiceByInvoiceNumberDataSet.FindVehicleInvoiceByInvoiceNumber[0].InvoiceID;

                    blnFatalError = TheVehicleProblemClass.UpdateVehicleProblemResolution(MainWindow.gintProblemID, datTransactionDate, strProblemResolution, intInvoiceID);

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

                    blnFatalError = TheVehicleProblemClass.UpdateVehicleProblemSolved(MainWindow.gintProblemID, true);

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

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

                this.Close();
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Edit Selected Vehicle Problem // Process Update Button " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
        private void MitProcessInvoice_Click(object sender, RoutedEventArgs e)
        {
            string   strNewLocation;
            bool     blnFatalError = false;
            DateTime datTransactionDate;
            long     intResult;
            string   strTransactionName = "";
            string   strErrorMessage    = "";
            bool     blnThereIsAProblem = false;
            int      intCounter;
            int      intNumberOfRecords;
            bool     blnItemSelected = false;
            string   strInvoiceNumber;
            string   strValueForValidation;
            decimal  decInvoiceAmount = 0;
            int      intInvoiceID;
            int      intProblemID;
            string   strProblemResolution;

            try
            {
                strInvoiceNumber = txtInvoiceNumber.Text;
                if (strInvoiceNumber == "")
                {
                    blnFatalError    = true;
                    strErrorMessage += "Invoice Number is Not Entered\n";
                }
                if (cboVendor.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "Vendor not Selected\n";
                }
                strValueForValidation = txtAmount.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDoubleData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Invoice Amount was not Entered\n";
                }
                else
                {
                    decInvoiceAmount = Convert.ToDecimal(strValueForValidation);
                }
                if (cboAttachInvoice.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "Attaching an Invoice was not Selected\n";
                }
                intNumberOfRecords = TheOpenVehicleProblemsDataSet.openvehicleproblem.Rows.Count - 1;
                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    if (TheOpenVehicleProblemsDataSet.openvehicleproblem[intCounter].Selected == true)
                    {
                        blnItemSelected = true;
                    }
                }
                strProblemResolution = txtProblemResolution.Text;
                if (strProblemResolution == "")
                {
                    blnFatalError    = true;
                    strErrorMessage += "Problem Resolution was not Entered\n";
                }
                if (blnItemSelected == false)
                {
                    blnFatalError    = true;
                    strErrorMessage += "A Problem Was Not Selected\n";
                }
                if (gblnInvoiceAttached == true)
                {
                    if (decInvoiceAmount == 0)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "No Amount was Added with an Invoice Attaced\n";
                    }
                }
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMessage);
                    return;
                }


                datTransactionDate = DateTime.Now;

                if (gblnInvoiceAttached == true)
                {
                    intResult           = datTransactionDate.Year * 10000000000 + datTransactionDate.Month * 100000000 + datTransactionDate.Day * 1000000 + datTransactionDate.Hour * 10000 + datTransactionDate.Minute * 100 + datTransactionDate.Second;
                    strTransactionName += Convert.ToString(intResult);

                    strNewLocation = "\\\\bjc\\shares\\Documents\\WAREHOUSE\\WhseTrac\\VehicleProblemFiles\\" + strTransactionName + ".pdf";

                    System.IO.File.Copy(gstrInvoicePath, strNewLocation);
                }
                else
                {
                    strNewLocation = gstrInvoicePath;
                }

                blnFatalError = TheVehiclePRoblemDocumentationClass.InsertVehicleInvoice(strInvoiceNumber, datTransactionDate, MainWindow.gintVehicleID, decInvoiceAmount, strNewLocation, MainWindow.gintVendorID);

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

                TheFindVehicleInvoiceByInvoiceNumberDataSet = TheVehiclePRoblemDocumentationClass.FindVehicleInvoiceByInvoiceNumber(strInvoiceNumber, MainWindow.gintVendorID, MainWindow.gintVehicleID, datTransactionDate);

                intInvoiceID = TheFindVehicleInvoiceByInvoiceNumberDataSet.FindVehicleInvoiceByInvoiceNumber[0].InvoiceID;

                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    intProblemID = TheOpenVehicleProblemsDataSet.openvehicleproblem[intCounter].ProblemID;

                    if (TheOpenVehicleProblemsDataSet.openvehicleproblem[intCounter].Selected == true)
                    {
                        blnFatalError = TheVehicleProblemClass.UpdateVehicleProblemResolution(intProblemID, datTransactionDate, strProblemResolution, intInvoiceID);

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

                        blnFatalError = TheVehicleProblemClass.UpdateVehicleProblemSolved(intProblemID, true);

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

                        blnFatalError = TheVehicleProblemClass.ChangeVehicleProblemStatus(intProblemID, "CLOSED");

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



                TheMessagesClass.InformationMessage("The Problems have been Updated and Closed");

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

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