/// <summary>
        /// Save
        /// </summary>
        public void Save()
        {
            UnitsOfMeasurementAssociationsToolTDS unitsOfMeasurementAssociationsToolAddChanges = (UnitsOfMeasurementAssociationsToolTDS)Data.GetChanges();

            if (unitsOfMeasurementAssociationsToolAddChanges != null)
            {
                if (unitsOfMeasurementAssociationsToolAddChanges.AssociatedUnits.Rows.Count > 0)
                {
                    UnitsOfMeasurementAssociationsToolAssociatedUnitsGateway unitsOfMeasurementAssociationsToolAssociatedUnitsGateway = new UnitsOfMeasurementAssociationsToolAssociatedUnitsGateway(unitsOfMeasurementAssociationsToolAddChanges);

                    // Update associations
                    foreach (UnitsOfMeasurementAssociationsToolTDS.AssociatedUnitsRow row in (UnitsOfMeasurementAssociationsToolTDS.AssociatedUnitsDataTable)unitsOfMeasurementAssociationsToolAddChanges.AssociatedUnits)
                    {
                        int companyId = row.COMPANY_ID;

                        // Insert new unit of measurement
                        if ((row.Selected) && (!row.Deleted) && (!row.InDataBase))
                        {
                            int associationsId = row.AssociationsID;
                            int unitOfMeasurementId = row.UnitOfMeasurementID;
                            string module = row.Module;
                            bool byDefault = row.ByDefault;
                            bool deleted = row.Deleted;

                            UnitsOfMeasurementAssociations unitsOfMeasurementAssociations = new UnitsOfMeasurementAssociations(null);
                            unitsOfMeasurementAssociations.InsertDirect(associationsId, unitOfMeasurementId, module, byDefault, deleted, companyId);
                        }

                        // Update associations
                        if ((row.Selected) && (!row.Deleted) && (row.InDataBase))
                        {
                            int associationsId = row.AssociationsID;
                            int unitOfMeasurementId = row.UnitOfMeasurementID;
                            bool originalDeleted = false;
                            int originalCompanyId = companyId;

                            // Original values
                            int originalUnitOfMeasurementId = unitsOfMeasurementAssociationsToolAssociatedUnitsGateway.GetUnitOfMeasurementIdOriginal(associationsId);
                            string originalModule = unitsOfMeasurementAssociationsToolAssociatedUnitsGateway.GetModuleOriginal(associationsId);
                            bool originalByDefault = unitsOfMeasurementAssociationsToolAssociatedUnitsGateway.GetByDefaultOriginal(associationsId);

                            // New values
                            int newUnitOfMeasurementId = unitsOfMeasurementAssociationsToolAssociatedUnitsGateway.GetUnitOfMeasurementId(associationsId);
                            string newModule = unitsOfMeasurementAssociationsToolAssociatedUnitsGateway.GetModule(associationsId);
                            bool newByDefault = unitsOfMeasurementAssociationsToolAssociatedUnitsGateway.GetByDefault(associationsId);

                            UnitsOfMeasurementAssociations unitsOfMeasurementAssociations = new UnitsOfMeasurementAssociations(null);
                            unitsOfMeasurementAssociations.UpdateDirect(associationsId, unitOfMeasurementId, originalModule, originalByDefault, originalDeleted, originalCompanyId, associationsId, unitOfMeasurementId, newModule, newByDefault, originalDeleted, originalCompanyId);
                        }

                        // Delete associations
                        if ((row.Deleted) && (row.InDataBase))
                        {
                            UnitsOfMeasurementAssociations unitsOfMeasurementAssociations = new UnitsOfMeasurementAssociations(null);
                            unitsOfMeasurementAssociations.DeleteDirect(row.AssociationsID, row.COMPANY_ID);
                        }

                    }
                }
            }
        }
 // ////////////////////////////////////////////////////////////////////////
 // PUBLIC METHODS
 //
 /// <summary>
 /// LoadAll
 /// </summary>
 /// <param name="module">module</param>
 /// <param name="companyId">companyId</param>          
 public void LoadAll(string module, int companyId)
 {
     UnitsOfMeasurementAssociationsToolAssociatedUnitsGateway unitsOfMeasurementAssociationsToolAssociatedUnitsGateway = new UnitsOfMeasurementAssociationsToolAssociatedUnitsGateway(Data);
     unitsOfMeasurementAssociationsToolAssociatedUnitsGateway.LoadAll(module, companyId);
 }