Пример #1
0
        public FindDailyVehicleInspectionForGPSDataSet FindDailyVehicleInspectionForGPS(int intVehicleID, DateTime datInspectionDate, int intEmployeeID, string strInspectionStatus, int intOdometerReading)
        {
            try
            {
                aFindDailyVehicleInspectionForGPSDataSet      = new FindDailyVehicleInspectionForGPSDataSet();
                aFindDailyVehicleInspectionForGPSTableAdapter = new FindDailyVehicleInspectionForGPSDataSetTableAdapters.FindDailyVehicleInspectionForGPSTableAdapter();
                aFindDailyVehicleInspectionForGPSTableAdapter.Fill(aFindDailyVehicleInspectionForGPSDataSet.FindDailyVehicleInspectionForGPS, intVehicleID, datInspectionDate, intEmployeeID, strInspectionStatus, intOdometerReading);
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Inspections Class // Find Daily Vehicle Inspection For GPS " + Ex.Message);
            }

            return(aFindDailyVehicleInspectionForGPSDataSet);
        }
        private bool ProcessDailyVehicleInspection()
        {
            string   strValueForValidation;
            bool     blnThereIsAProblem = false;
            bool     blnFatalError      = false;
            string   strErrorMessage    = "";
            DateTime datTransactionDate = DateTime.Now;
            int      intRecordsReturned;
            string   strVehicleNumber;

            try
            {
                strValueForValidation = txtEnterDate.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDateData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Date is not a Date\n";
                }
                else
                {
                    datTransactionDate = Convert.ToDateTime(strValueForValidation);
                }
                strValueForValidation = txtEnterID.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyIntegerData(strValueForValidation);
                if (cboSelectEmployee.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Employee Was Not Selected\n";
                }
                strVehicleNumber = txtVehicleNumber.Text;
                if (strVehicleNumber.Length < 4)
                {
                    blnFatalError    = true;
                    strErrorMessage += "Vehicle Number is not Long Enough\n";
                }
                else
                {
                    TheFindActiveVehicleMainByVehicleNumberDataSet = TheVehicleMainClass.FindActiveVehicleMainByVehicleNumber(strVehicleNumber);

                    intRecordsReturned = TheFindActiveVehicleMainByVehicleNumberDataSet.FindActiveVehicleMainByVehicleNumber.Rows.Count;

                    if (intRecordsReturned < 1)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "The Vehicle Was Not Found\n";
                    }
                    else
                    {
                        gintVehicleID = TheFindActiveVehicleMainByVehicleNumberDataSet.FindActiveVehicleMainByVehicleNumber[0].VehicleID;
                    }
                }
                strValueForValidation = txtOdometer.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyIntegerData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Odometer is not a Integer\n";
                }
                else
                {
                    gintOdometerReading = Convert.ToInt32(strValueForValidation);
                }

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

                TheFindDailyVehicleInspectionForGPSDataSet = TheInspectionsClass.FindDailyVehicleInspectionForGPS(gintVehicleID, datTransactionDate, gintEmployeeID, gstrInspectionStatus, gintOdometerReading);

                intRecordsReturned = TheFindDailyVehicleInspectionForGPSDataSet.FindDailyVehicleInspectionForGPS.Rows.Count;

                if (intRecordsReturned > 0)
                {
                    blnFatalError = true;
                    TheMessagesClass.ErrorMessage("This Inspection Has Been Entered\n");
                    return(blnFatalError);
                }

                if (gstrInspectionStatus == "PASSED")
                {
                    TheFindOpenVehicleMainProblemsByVehicleIDDataSet = TheVehicleProblemClass.FindOpenVehicleMainProblemsByVehicleID(gintVehicleID);

                    intRecordsReturned = TheFindOpenVehicleMainProblemsByVehicleIDDataSet.FindOpenVehicleMainProblemsByVehicleID.Rows.Count;

                    if (intRecordsReturned > 0)
                    {
                        blnFatalError = true;
                        TheMessagesClass.ErrorMessage("There are Open Vehicle Problems, The Inspection Will Not Be Processed");
                        return(blnFatalError);
                    }
                }

                blnFatalError = TheInspectionsClass.InsertDailyVehicleInspection(gintVehicleID, datTransactionDate, gintEmployeeID, gstrInspectionStatus, gintOdometerReading);

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

                blnFatalError = TheVehicleHistoryClass.InsertVehicleHistory(gintVehicleID, gintEmployeeID, gintWarehouseEmployeeID);

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

                TheFindDailyVehicleInspectionForGPSDataSet = TheInspectionsClass.FindDailyVehicleInspectionForGPS(gintVehicleID, datTransactionDate, gintEmployeeID, gstrInspectionStatus, gintOdometerReading);

                gintInspectionID = TheFindDailyVehicleInspectionForGPSDataSet.FindDailyVehicleInspectionForGPS[0].TransactionID;

                blnFatalError = TheInspectGPSClass.InsertInspectGPS(gintInspectionID, "DAILY", gblnGPSInstalled);

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

                blnFatalError = TheVehicleMainClass.UpdateVehicleMainEmployeeID(gintVehicleID, gintEmployeeID);

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

                if (gstrInspectionStatus == "PASSED SERVICE REQUIRED")
                {
                    VehicleInspectionProblem VehicleInspectionProblem = new VehicleInspectionProblem();
                    VehicleInspectionProblem.ShowDialog();
                }
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Daily Vehicle Data Entry // Main Window // Process Daily Vehicle Inspection " + Ex.Message);

                blnFatalError = true;
            }

            return(blnFatalError);
        }