/// <summary>
        /// Save
        /// </summary>
        /// <param name="categoriesSelected">categoriesSelected</param>
        /// <param name="companyId">companyId</param>
        public void Save(ArrayList categoriesSelected, int companyId)
        {
            UnitInformationTDS unitsInformationChanges = (UnitInformationTDS)Data.GetChanges();

            if (unitsInformationChanges.UnitDetails.Rows.Count > 0)
            {
                UnitInformationUnitDetailsGateway unitInformationUnitDetailsGateway = new UnitInformationUnitDetailsGateway(unitsInformationChanges);

                // Update unit
                foreach (UnitInformationTDS.UnitDetailsRow unitDetailsRow in (UnitInformationTDS.UnitDetailsDataTable)unitsInformationChanges.UnitDetails)
                {
                    // Unchanged values
                    int unitId = unitDetailsRow.UnitID;
                    string state = unitInformationUnitDetailsGateway.GetState(unitId);
                    string type = unitInformationUnitDetailsGateway.GetType(unitId);
                    bool deleted = false;
                    string notes = ""; if (!unitDetailsRow.IsNotesNull()) notes = unitDetailsRow.Notes;
                    string originalCategories = ""; if (!unitDetailsRow.IsCategoriesNull()) originalCategories = unitDetailsRow.Categories;

                    // Original Unit values
                    string originalUnitCode = unitInformationUnitDetailsGateway.GetUnitCodeOriginal(unitId);
                    string originalDescription = unitInformationUnitDetailsGateway.GetDescriptionOriginal(unitId);
                    string originalVin = unitInformationUnitDetailsGateway.GetVinOriginal(unitId);
                    string originalManufacturer = unitInformationUnitDetailsGateway.GetManufacturerOriginal(unitId);
                    string originalModel = unitInformationUnitDetailsGateway.GetModelOriginal(unitId);
                    string originalYear_ = unitInformationUnitDetailsGateway.GetYear_Original(unitId);
                    bool originalIsTowable = unitInformationUnitDetailsGateway.GetIsTowableOriginal(unitId);
                    int originalCompanyLevelId = unitInformationUnitDetailsGateway.GetCompanyLevelIdOriginal(unitId);
                    DateTime? originalAcquisitionDate = null; if (unitInformationUnitDetailsGateway.GetAcquisitionDateOriginal(unitId).HasValue) originalAcquisitionDate = (DateTime)unitInformationUnitDetailsGateway.GetAcquisitionDateOriginal(unitId);
                    DateTime? originalDispositionDate = null; if (unitInformationUnitDetailsGateway.GetDispositionDateOriginal(unitId).HasValue) originalDispositionDate = (DateTime)unitInformationUnitDetailsGateway.GetDispositionDateOriginal(unitId);
                    string originalDispositionReason = unitInformationUnitDetailsGateway.GetDispositionReasonOriginal(unitId);
                    string originalOwnerType = unitInformationUnitDetailsGateway.GetOwnerTypeOriginal(unitId);
                    Int64? originalOwnerCountry = null; if (unitInformationUnitDetailsGateway.GetOwnerCountryOriginal(unitId).HasValue) originalOwnerCountry = (Int64)unitInformationUnitDetailsGateway.GetOwnerCountryOriginal(unitId);
                    Int64? originalOwnerState = null; if (unitInformationUnitDetailsGateway.GetOwnerStateOriginal(unitId).HasValue) originalOwnerState = (Int64)unitInformationUnitDetailsGateway.GetOwnerStateOriginal(unitId);
                    string originalOwnerName = unitInformationUnitDetailsGateway.GetOwnerNameOriginal(unitId);
                    string originalOwnerContact = unitInformationUnitDetailsGateway.GetOwnerContactOriginal(unitId);
                    DateTime? originalQualifiedDate = null; if (unitInformationUnitDetailsGateway.GetQualifiedDateOriginal(unitId).HasValue) originalQualifiedDate = (DateTime)unitInformationUnitDetailsGateway.GetQualifiedDateOriginal(unitId);
                    DateTime? originalNotQualifiedDate = null; if (unitInformationUnitDetailsGateway.GetNotQualifiedDateOriginal(unitId).HasValue) originalNotQualifiedDate = (DateTime)unitInformationUnitDetailsGateway.GetNotQualifiedDateOriginal(unitId);
                    string originalNotQualifiedExplain = unitInformationUnitDetailsGateway.GetNotQualifiedExplainOriginal(unitId);
                    string originalInsuranceClass = unitInformationUnitDetailsGateway.GetInsuranceClassOriginal(unitId);
                    string originalInsuranceClassRyderSpecified = unitInformationUnitDetailsGateway.GetInsuranceClassRyderSpecifiedOriginal(unitId);
                    decimal? originalPurchasePrice = null; if (unitInformationUnitDetailsGateway.GetPurchasePriceOriginal(unitId).HasValue) originalPurchasePrice = unitInformationUnitDetailsGateway.GetPurchasePriceOriginal(unitId).Value;
                    DateTime? originalScrapDate = null; if (unitInformationUnitDetailsGateway.GetScrapDateOriginal(unitId).HasValue) originalScrapDate = (DateTime)unitInformationUnitDetailsGateway.GetScrapDateOriginal(unitId);
                    decimal? originalSaleProceeds = null; if (unitInformationUnitDetailsGateway.GetSaleProceedsOriginal(unitId).HasValue) originalSaleProceeds = unitInformationUnitDetailsGateway.GetSaleProceedsOriginal(unitId).Value;
                    int? originalLibraryCategoriesId = null; if (unitInformationUnitDetailsGateway.GetLibraryCategoriesIdOriginal(unitId).HasValue) originalLibraryCategoriesId = unitInformationUnitDetailsGateway.GetLibraryCategoriesIdOriginal(unitId).Value;

                    // New Unit values
                    string newUnitCode = unitInformationUnitDetailsGateway.GetUnitCode(unitId);
                    string newDescription = unitInformationUnitDetailsGateway.GetDescription(unitId);
                    string newVin = unitInformationUnitDetailsGateway.GetVin(unitId);
                    string newManufacturer = unitInformationUnitDetailsGateway.GetManufacturer(unitId);
                    string newModel = unitInformationUnitDetailsGateway.GetModel(unitId);
                    string newYear_ = unitInformationUnitDetailsGateway.GetYear_(unitId);
                    bool newIsTowable = unitInformationUnitDetailsGateway.GetIsTowable(unitId);
                    int newCompanyLevelId = unitInformationUnitDetailsGateway.GetCompanyLevelId(unitId);
                    DateTime? newAcquisitionDate = null; if (unitInformationUnitDetailsGateway.GetAcquisitionDate(unitId).HasValue) newAcquisitionDate = (DateTime)unitInformationUnitDetailsGateway.GetAcquisitionDate(unitId);
                    DateTime? newDispositionDate = null; if (unitInformationUnitDetailsGateway.GetDispositionDate(unitId).HasValue) newDispositionDate = (DateTime)unitInformationUnitDetailsGateway.GetDispositionDate(unitId);
                    string newDispositionReason = unitInformationUnitDetailsGateway.GetDispositionReason(unitId);
                    string newOwnerType = unitInformationUnitDetailsGateway.GetOwnerType(unitId);
                    Int64? newOwnerCountry = null; if (unitInformationUnitDetailsGateway.GetOwnerCountry(unitId).HasValue) newOwnerCountry = (Int64)unitInformationUnitDetailsGateway.GetOwnerCountry(unitId);
                    Int64? newOwnerState = null; if (unitInformationUnitDetailsGateway.GetOwnerState(unitId).HasValue) newOwnerState = (Int64)unitInformationUnitDetailsGateway.GetOwnerState(unitId);
                    string newOwnerName = unitInformationUnitDetailsGateway.GetOwnerName(unitId);
                    string newOwnerContact = unitInformationUnitDetailsGateway.GetOwnerContact(unitId);
                    DateTime? newQualifiedDate = null; if (unitInformationUnitDetailsGateway.GetQualifiedDate(unitId).HasValue) newQualifiedDate = (DateTime)unitInformationUnitDetailsGateway.GetQualifiedDate(unitId);
                    DateTime? newNotQualifiedDate = null; if (unitInformationUnitDetailsGateway.GetNotQualifiedDate(unitId).HasValue) newNotQualifiedDate = (DateTime)unitInformationUnitDetailsGateway.GetNotQualifiedDate(unitId);
                    string newNotQualifiedExplain = unitInformationUnitDetailsGateway.GetNotQualifiedExplain(unitId);

                    string newCategories = "";

                    if (categoriesSelected.Count > 0)
                    {
                        foreach (int categoryId in categoriesSelected)
                        {
                            CategoryGateway categoryGateway = new CategoryGateway();
                            categoryGateway.LoadByCategoryId(categoryId, companyId);
                            newCategories = newCategories + categoryGateway.GetName(categoryId) + ", ";
                        }

                        if (newCategories.Length > 2)
                        {
                            newCategories = newCategories.Substring(0, newCategories.Length - 2);
                        }
                    }

                    string newInsuranceClass = unitInformationUnitDetailsGateway.GetInsuranceClass(unitId);
                    string newInsuranceClassRyderSpecified = unitInformationUnitDetailsGateway.GetInsuranceClassRyderSpecified(unitId);
                    decimal? newPurchasePrice = null; if (unitInformationUnitDetailsGateway.GetPurchasePrice(unitId).HasValue) newPurchasePrice = unitInformationUnitDetailsGateway.GetPurchasePrice(unitId).Value;
                    DateTime? newScrapDate = null; if (unitInformationUnitDetailsGateway.GetScrapDate(unitId).HasValue) newScrapDate = (DateTime)unitInformationUnitDetailsGateway.GetScrapDate(unitId);
                    decimal? newSaleProceeds = null; if (unitInformationUnitDetailsGateway.GetSaleProceeds(unitId).HasValue) newSaleProceeds = unitInformationUnitDetailsGateway.GetSaleProceeds(unitId).Value;
                    int? newLibraryCategoriesId = null; if (unitInformationUnitDetailsGateway.GetLibraryCategoriesId(unitId).HasValue) newLibraryCategoriesId = unitInformationUnitDetailsGateway.GetLibraryCategoriesId(unitId).Value;

                    // Update unit
                    UpdateUnit(unitId, originalUnitCode, originalDescription, originalVin, originalManufacturer, originalModel, originalYear_, originalIsTowable, originalCompanyLevelId, originalAcquisitionDate, originalDispositionDate, originalDispositionReason,  originalOwnerType, originalOwnerCountry, originalOwnerState, originalOwnerName, originalOwnerContact, originalQualifiedDate, originalNotQualifiedDate, originalNotQualifiedExplain, state, type, deleted, companyId, notes, originalCategories, originalInsuranceClass, originalInsuranceClassRyderSpecified, originalPurchasePrice, originalScrapDate, originalSaleProceeds, originalLibraryCategoriesId, unitId, newUnitCode, newDescription, newVin, newManufacturer, newModel, newYear_, newIsTowable, newCompanyLevelId, newAcquisitionDate, newDispositionDate, newDispositionReason,  newOwnerType, newOwnerCountry, newOwnerState, newOwnerName, newOwnerContact, newQualifiedDate, newNotQualifiedDate, newNotQualifiedExplain, state, type, deleted, companyId, notes, newCategories, newInsuranceClass, newInsuranceClassRyderSpecified, newPurchasePrice, newScrapDate, newSaleProceeds, newLibraryCategoriesId);
                    UpdateUnitCategory(unitId, companyId, categoriesSelected, newCompanyLevelId);

                    if (type == "Vehicle")
                    {
                        // Original Unit Vehicle values
                        Int64? originalLicenseCountry = null; if (unitInformationUnitDetailsGateway.GetLicenseCountryOriginal(unitId).HasValue) originalLicenseCountry = (Int64)unitInformationUnitDetailsGateway.GetLicenseCountryOriginal(unitId);
                        Int64? originalLicenseState = null; if (unitInformationUnitDetailsGateway.GetLicenseStateOriginal(unitId).HasValue) originalLicenseState = (Int64)unitInformationUnitDetailsGateway.GetLicenseStateOriginal(unitId);
                        string originalLicensePlateNumber = unitInformationUnitDetailsGateway.GetLicensePlateNumbverOriginal(unitId);
                        string originalAportionedTagNumber = unitInformationUnitDetailsGateway.GetAportionedTagNumberOriginal(unitId);
                        string originalActualWeight = unitInformationUnitDetailsGateway.GetActualWeightOriginal(unitId);
                        string originalRegisteredWeight = unitInformationUnitDetailsGateway.GetRegisteredWeightOriginal(unitId);
                        string originalTireSizeFront = unitInformationUnitDetailsGateway.GetTireSizeFrontOriginal(unitId);
                        string originalTireSizeBack = unitInformationUnitDetailsGateway.GetTireSizeBackOriginal(unitId);
                        string originalNumberOfAxes = unitInformationUnitDetailsGateway.GetNumberOfAxesOriginal(unitId);
                        string originalFuelType = unitInformationUnitDetailsGateway.GetFuelTypeOriginal(unitId);
                        string originalBeginningOdometer = unitInformationUnitDetailsGateway.GetBeginningOdometerOriginal(unitId);
                        bool originalIsReeferEquipped = unitInformationUnitDetailsGateway.GetIsReeferEquippedOriginal(unitId);
                        bool originalIsPtoEquipped = unitInformationUnitDetailsGateway.GetIsPTOEquippedOriginal(unitId);

                        // New Unit Vehicle values
                        Int64? newLicenseCountry = null; if (unitInformationUnitDetailsGateway.GetLicenseCountry(unitId).HasValue) newLicenseCountry = (Int64)unitInformationUnitDetailsGateway.GetLicenseCountry(unitId);
                        Int64? newLicenseState = null; if (unitInformationUnitDetailsGateway.GetLicenseState(unitId).HasValue) newLicenseState = (Int64)unitInformationUnitDetailsGateway.GetLicenseState(unitId);
                        string newLicensePlateNumber = unitInformationUnitDetailsGateway.GetLicensePlateNumbver(unitId);
                        string newAportionedTagNumber = unitInformationUnitDetailsGateway.GetAportionedTagNumber(unitId);
                        string newActualWeight = unitInformationUnitDetailsGateway.GetActualWeight(unitId);
                        string newRegisteredWeight = unitInformationUnitDetailsGateway.GetRegisteredWeight(unitId);
                        string newTireSizeFront = unitInformationUnitDetailsGateway.GetTireSizeFront(unitId);
                        string newTireSizeBack = unitInformationUnitDetailsGateway.GetTireSizeBack(unitId);
                        string newNumberOfAxes = unitInformationUnitDetailsGateway.GetNumberOfAxes(unitId);
                        string newFuelType = unitInformationUnitDetailsGateway.GetFuelType(unitId);
                        string newBeginningOdometer = unitInformationUnitDetailsGateway.GetBeginningOdometer(unitId);
                        bool newIsReeferEquipped = unitInformationUnitDetailsGateway.GetIsReeferEquipped(unitId);
                        bool newIsPtoEquipped = unitInformationUnitDetailsGateway.GetIsPTOEquipped(unitId);

                        UpdateUnitVehicle(unitId, originalLicenseCountry, originalLicenseState, originalLicensePlateNumber, originalAportionedTagNumber, originalActualWeight, originalRegisteredWeight, originalTireSizeFront, originalTireSizeBack, originalNumberOfAxes, originalFuelType, originalBeginningOdometer, originalIsReeferEquipped, originalIsPtoEquipped, deleted, companyId, unitId, newLicenseCountry, newLicenseState, newLicensePlateNumber, newAportionedTagNumber, newActualWeight, newRegisteredWeight, newTireSizeFront, newTireSizeBack, newNumberOfAxes, newFuelType, newBeginningOdometer, newIsReeferEquipped, newIsPtoEquipped, deleted, companyId);
                    }
                }
            }
        }