Пример #1
0
        private void LoadDetailedData(int unitId)
        {
            UnitInformationUnitDetailsGateway unitInformationUnitDetailsGateway = new UnitInformationUnitDetailsGateway(unitInformationTDS);
            if (unitInformationUnitDetailsGateway.Table.Rows.Count > 0)
            {
                // Load for General Tab
                if (upnlGeneralDataEdit.Visible)
                {
                    if (unitInformationUnitDetailsGateway.GetAcquisitionDate(unitId).HasValue)
                    {
                        tkrdpAcquisitionDate.SelectedDate = unitInformationUnitDetailsGateway.GetAcquisitionDate(unitId);
                    }

                    if (unitInformationUnitDetailsGateway.GetDispositionDate(unitId).HasValue)
                    {
                        tkrdpDispositionDate.SelectedDate = unitInformationUnitDetailsGateway.GetDispositionDate(unitId);
                    }

                    tbxDispositionReason.Text = unitInformationUnitDetailsGateway.GetDispositionReason(unitId);
                    int companyLevelId = unitInformationUnitDetailsGateway.GetCompanyLevelId(unitId);

                    GetNodeForCategory(tvCategoriesRoot.Nodes, 0);
                    GetNodeForCompanyLevels(tvCompanyLevelsRoot.Nodes, 0, companyLevelId);

                    foreach (TreeNode nodes in tvCategoriesRoot.Nodes)
                    {
                        GetCategoriesParent(nodes);
                    }

                    foreach (TreeNode nodes in tvCompanyLevelsRoot.Nodes)
                    {
                        GetCompanyLevelsParent(nodes);
                    }
                }
                else
                {
                    if (unitInformationUnitDetailsGateway.GetAcquisitionDate(unitId).HasValue) tbxAcquisitionDateSummary.Text = ((DateTime)unitInformationUnitDetailsGateway.GetAcquisitionDate(unitId)).ToShortDateString();
                    if (unitInformationUnitDetailsGateway.GetDispositionDate(unitId).HasValue) tbxDispositionDateSummary.Text = ((DateTime)unitInformationUnitDetailsGateway.GetDispositionDate(unitId)).ToShortDateString();
                    tbxDispositionReasonSummary.Text = unitInformationUnitDetailsGateway.GetDispositionReason(unitId);
                    int companyLevelId = unitInformationUnitDetailsGateway.GetCompanyLevelId(unitId);

                    GetNodeForCategory(tvCategoriesRootSummary.Nodes, 0);
                    GetNodeForCompanyLevels(tvCompanyLevelsRootSummary.Nodes, 0, companyLevelId);

                    foreach (TreeNode nodes in tvCategoriesRootSummary.Nodes)
                    {
                        GetCategoriesParent(nodes);
                    }

                    foreach (TreeNode nodes in tvCompanyLevelsRootSummary.Nodes)
                    {
                        GetCompanyLevelsParent(nodes);
                    }
                }

                // Load for Plate and Technical Tabs
                if (unitInformationUnitDetailsGateway.GetType(unitId) == "Vehicle")
                {
                    if (upnlPlateDataEdit.Visible)
                    {
                        if (unitInformationUnitDetailsGateway.GetLicenseCountry(unitId).HasValue)
                        {
                            Int64 countryId = (Int64)unitInformationUnitDetailsGateway.GetLicenseCountry(unitId);
                            ddlLicenseCountry.SelectedValue = countryId.ToString();

                            if (unitInformationUnitDetailsGateway.GetLicenseState(unitId).HasValue)
                            {
                                Int64? stateId = null;

                                stateId = unitInformationUnitDetailsGateway.GetLicenseState(unitId);

                                if (stateId.HasValue)
                                {
                                    tbxLicenseState.Text = "";
                                    hdfLicenseStateId.Value = "";

                                    if (stateId.ToString() == "12435")
                                    {
                                        tbxLicenseState.Text = "Ontario";
                                        hdfLicenseStateId.Value = "12435";
                                    }
                                    else
                                    {
                                        if (ddlLicenseCountry.SelectedValue == "2")
                                        {
                                            tbxLicenseState.Text = "Michigan";
                                            hdfLicenseStateId.Value = "84026";
                                        }
                                    }
                                }
                            }
                        }

                        tbxLicensePlateNumber.Text = unitInformationUnitDetailsGateway.GetLicensePlateNumbver(unitId);
                    }
                    else
                    {
                        if (unitInformationUnitDetailsGateway.GetLicenseCountry(unitId).HasValue)
                        {
                            Int64 countryId = (Int64)unitInformationUnitDetailsGateway.GetLicenseCountry(unitId);
                            CountryGateway countryGateway = new CountryGateway();
                            countryGateway.LoadByCountryId(countryId);
                            tbxLicenseCountrySummary.Text = countryGateway.GetName(countryId);
                        }

                        if (unitInformationUnitDetailsGateway.GetLicenseState(unitId).HasValue)
                        {
                            Int64 stateId = (Int64)unitInformationUnitDetailsGateway.GetLicenseState(unitId);
                            ProvinceGateway provinceGateway = new ProvinceGateway();
                            provinceGateway.LoadByProvinceId(stateId);
                            tbxLicenseStateSummary.Text = provinceGateway.GetName(stateId);
                        }

                        tbxLicensePlateNumberSummary.Text = unitInformationUnitDetailsGateway.GetLicensePlateNumbver(unitId);
                    }

                    if (upnlTechnicalEdit.Visible)
                    {
                        tbxActualWeight.Text = unitInformationUnitDetailsGateway.GetActualWeight(unitId);
                        tbxRegisteredWeight.Text = unitInformationUnitDetailsGateway.GetRegisteredWeight(unitId);
                        tbxTireSizeFront.Text = unitInformationUnitDetailsGateway.GetTireSizeFront(unitId);
                        tbxTireSizeBack.Text = unitInformationUnitDetailsGateway.GetTireSizeBack(unitId);
                        ddlNumberOfAxes.SelectedValue = unitInformationUnitDetailsGateway.GetNumberOfAxes(unitId);
                        ddlFuelType.SelectedValue = unitInformationUnitDetailsGateway.GetFuelType(unitId);
                        tbxBeginningOdometer.Text = unitInformationUnitDetailsGateway.GetBeginningOdometer(unitId);
                        cbxIsReeferEquipped.Checked = unitInformationUnitDetailsGateway.GetIsReeferEquipped(unitId);
                        cbxIsPtoEquipped.Checked = unitInformationUnitDetailsGateway.GetIsPTOEquipped(unitId);
                    }
                    else
                    {
                        tbxActualWeightSummary.Text = unitInformationUnitDetailsGateway.GetActualWeight(unitId);
                        tbxRegisteredWeightSummary.Text = unitInformationUnitDetailsGateway.GetRegisteredWeight(unitId);
                        tbxTireSizeFrontSummary.Text = unitInformationUnitDetailsGateway.GetTireSizeFront(unitId);
                        tbxTireSizeBackSummary.Text = unitInformationUnitDetailsGateway.GetTireSizeBack(unitId);
                        tbxNumberOfAxesSummary.Text = unitInformationUnitDetailsGateway.GetNumberOfAxes(unitId);
                        tbxFuelTypeSummary.Text = unitInformationUnitDetailsGateway.GetFuelType(unitId);
                        tbxBeginningOdometerSummary.Text = unitInformationUnitDetailsGateway.GetBeginningOdometer(unitId);
                        cbxIsReeferEquippedSummary.Checked = unitInformationUnitDetailsGateway.GetIsReeferEquipped(unitId);
                        cbxIsPtoEquippedSummary.Checked = unitInformationUnitDetailsGateway.GetIsPTOEquipped(unitId);
                    }
                }

                // Load for Ownership tab
                if (upnlOwnershipEdit.Visible)
                {
                    ddlOwnerType.SelectedValue = unitInformationUnitDetailsGateway.GetOwnerType(unitId);
                    tbxOwnerName.Text = unitInformationUnitDetailsGateway.GetOwnerName(unitId);
                    tbxOwnerContact.Text = unitInformationUnitDetailsGateway.GetOwnerContact(unitId);

                    if (unitInformationUnitDetailsGateway.GetOwnerCountry(unitId).HasValue)
                    {
                        Int64 countryId = (Int64)unitInformationUnitDetailsGateway.GetOwnerCountry(unitId);
                        ddlOwnerCountry.SelectedValue = countryId.ToString();

                        ProvinceList provinceList = new ProvinceList();
                        provinceList.LoadByCountryIdAndAddItem(-1, "(Select a state)", countryId);
                        ddlOwnerState.DataSource = provinceList.Table;
                        ddlOwnerState.DataValueField = "ProvinceID";
                        ddlOwnerState.DataTextField = "Name";
                        ddlOwnerState.DataBind();

                        if (unitInformationUnitDetailsGateway.GetOwnerState(unitId).HasValue)
                        {
                            Int64 stateId = (Int64)unitInformationUnitDetailsGateway.GetOwnerState(unitId);
                            ddlOwnerState.SelectedValue = stateId.ToString();
                        }
                    }
                }
                else
                {
                    tbxOwnerTypeSummary.Text = unitInformationUnitDetailsGateway.GetOwnerType(unitId);
                    tbxOwnerNameSummary.Text = unitInformationUnitDetailsGateway.GetOwnerName(unitId);
                    tbxContactInfoSummary.Text = unitInformationUnitDetailsGateway.GetOwnerContact(unitId);

                    if (unitInformationUnitDetailsGateway.GetOwnerCountry(unitId).HasValue)
                    {
                        Int64 countryId = (Int64)unitInformationUnitDetailsGateway.GetOwnerCountry(unitId);
                        CountryGateway countryGateway = new CountryGateway();
                        countryGateway.LoadByCountryId(countryId);
                        tbxOwnerCountrySummary.Text = countryGateway.GetName(countryId);

                        if (unitInformationUnitDetailsGateway.GetOwnerState(unitId).HasValue)
                        {
                            Int64 stateId = (Int64)unitInformationUnitDetailsGateway.GetOwnerState(unitId);
                            ProvinceGateway provinceGateway = new ProvinceGateway();
                            provinceGateway.LoadByProvinceId(stateId);
                            tbxOwnerStateSummary.Text = provinceGateway.GetName(stateId);
                        }
                    }
                }

                // Load for Inspection Tab (Qualification data)
                if (upnlInspectionEdit.Visible)
                {
                    if (unitInformationUnitDetailsGateway.GetQualifiedDate(unitId).HasValue)
                    {
                        tkrdpQualifiedDate.SelectedDate = unitInformationUnitDetailsGateway.GetQualifiedDate(unitId);
                    }

                    if (unitInformationUnitDetailsGateway.GetNotQualifiedDate(unitId).HasValue)
                    {
                        tkrdpNotQualifiedDate.SelectedDate = (DateTime)unitInformationUnitDetailsGateway.GetNotQualifiedDate(unitId);
                    }

                    tbxIfNotQualifiedExplain.Text = unitInformationUnitDetailsGateway.GetNotQualifiedExplain(unitId);
                }
                else
                {
                    if (unitInformationUnitDetailsGateway.GetQualifiedDate(unitId).HasValue) tbxQualifiedDateSummary.Text = ((DateTime)unitInformationUnitDetailsGateway.GetQualifiedDate(unitId)).ToShortDateString();
                    if (unitInformationUnitDetailsGateway.GetNotQualifiedDate(unitId).HasValue) tbxNotQualifiedDateSummary.Text = ((DateTime)unitInformationUnitDetailsGateway.GetNotQualifiedDate(unitId)).ToShortDateString();
                    tbxIfNotQualifiedExplainSummary.Text = unitInformationUnitDetailsGateway.GetNotQualifiedExplain(unitId);
                }
            }
        }
        private void LoadDetailedData(int unitId)
        {
            UnitInformationUnitDetailsGateway unitInformationUnitDetailsGateway = new UnitInformationUnitDetailsGateway(unitInformationTDS);
            if (unitInformationUnitDetailsGateway.Table.Rows.Count > 0)
            {
                // Load for General Tab
                if (unitInformationUnitDetailsGateway.GetAcquisitionDate(unitId).HasValue) tbxAcquisitionDate.Text = ((DateTime)unitInformationUnitDetailsGateway.GetAcquisitionDate(unitId)).ToShortDateString();
                if (unitInformationUnitDetailsGateway.GetDispositionDate(unitId).HasValue) tbxDispositionDate.Text = ((DateTime)unitInformationUnitDetailsGateway.GetDispositionDate(unitId)).ToShortDateString();
                tbxDispositionReason.Text = unitInformationUnitDetailsGateway.GetDispositionReason(unitId);
                int companyLevelId = unitInformationUnitDetailsGateway.GetCompanyLevelId(unitId);

                GetNodeForCategory(tvCategoriesRoot.Nodes, 0);
                GetNodeForCompanyLevels(tvCompanyLevelsRoot.Nodes, 0, companyLevelId);

                foreach (TreeNode nodes in tvCategoriesRoot.Nodes)
                {
                    GetCategoriesParent(nodes);
                }

                foreach (TreeNode nodes in tvCompanyLevelsRoot.Nodes)
                {
                    GetCompanyLevelsParent(nodes);
                }

                // Load for Plate and Technical Tabs
                if (unitInformationUnitDetailsGateway.GetType(unitId) == "Vehicle")
                {
                    if (unitInformationUnitDetailsGateway.GetLicenseCountry(unitId).HasValue)
                    {
                        Int64 countryId = (Int64)unitInformationUnitDetailsGateway.GetLicenseCountry(unitId);
                        CountryGateway countryGateway = new CountryGateway();
                        countryGateway.LoadByCountryId(countryId);
                        tbxLicenseCountry.Text = countryGateway.GetName(countryId);
                    }

                    if (unitInformationUnitDetailsGateway.GetLicenseState(unitId).HasValue)
                    {
                        Int64 stateId = (Int64)unitInformationUnitDetailsGateway.GetLicenseState(unitId);
                        ProvinceGateway provinceGateway = new ProvinceGateway();
                        provinceGateway.LoadByProvinceId(stateId);
                        tbxLicenseState.Text = provinceGateway.GetName(stateId);
                    }

                    tbxLicensePlateNumber.Text = unitInformationUnitDetailsGateway.GetLicensePlateNumbver(unitId);
                    tbxActualWeight.Text = unitInformationUnitDetailsGateway.GetActualWeight(unitId);
                    tbxRegisteredWeight.Text = unitInformationUnitDetailsGateway.GetRegisteredWeight(unitId);
                    tbxTireSizeFront.Text = unitInformationUnitDetailsGateway.GetTireSizeFront(unitId);
                    tbxTireSizeBack.Text = unitInformationUnitDetailsGateway.GetTireSizeBack(unitId);
                    tbxNumberOfAxes.Text = unitInformationUnitDetailsGateway.GetNumberOfAxes(unitId);
                    tbxFuelType.Text = unitInformationUnitDetailsGateway.GetFuelType(unitId);
                    tbxBeginningOdometer.Text = unitInformationUnitDetailsGateway.GetBeginningOdometer(unitId);
                    cbxIsReeferEquipped.Checked = unitInformationUnitDetailsGateway.GetIsReeferEquipped(unitId);
                    cbxIsPtoEquipped.Checked = unitInformationUnitDetailsGateway.GetIsPTOEquipped(unitId);

                }

                // Load for Ownership tab
                tbxOwnerType.Text = unitInformationUnitDetailsGateway.GetOwnerType(unitId);
                tbxOwnerName.Text = unitInformationUnitDetailsGateway.GetOwnerName(unitId);
                tbxOwnerContact.Text = unitInformationUnitDetailsGateway.GetOwnerContact(unitId);

                if (unitInformationUnitDetailsGateway.GetOwnerCountry(unitId).HasValue)
                {
                    Int64 countryId = (Int64)unitInformationUnitDetailsGateway.GetOwnerCountry(unitId);
                    CountryGateway countryGateway = new CountryGateway();
                    countryGateway.LoadByCountryId(countryId);
                    tbxOwnerCountry.Text = countryGateway.GetName(countryId);

                    if (unitInformationUnitDetailsGateway.GetOwnerState(unitId).HasValue)
                    {
                        Int64 stateId = (Int64)unitInformationUnitDetailsGateway.GetOwnerState(unitId);
                        ProvinceGateway provinceGateway = new ProvinceGateway();
                        provinceGateway.LoadByProvinceId(stateId);
                        tbxOwnerState.Text = provinceGateway.GetName(stateId);
                    }
                }

                // Load for Inspection Tab (Qualification data)
                if (unitInformationUnitDetailsGateway.GetQualifiedDate(unitId).HasValue) tbxQualifiedDate.Text = ((DateTime)unitInformationUnitDetailsGateway.GetQualifiedDate(unitId)).ToShortDateString();
                if (unitInformationUnitDetailsGateway.GetNotQualifiedDate(unitId).HasValue) tbxNotQualifiedDate.Text = ((DateTime)unitInformationUnitDetailsGateway.GetNotQualifiedDate(unitId)).ToShortDateString();
                tbxIfNotQualifiedExplain.Text = unitInformationUnitDetailsGateway.GetNotQualifiedExplain(unitId);
            }
        }
        /// <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);
                    }
                }
            }
        }