/// <summary>
        /// Save all Service to database (direct)
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void Save(int companyId)
        {
            ProjectNavigatorTDS serviceChanges = (ProjectNavigatorTDS)Data.GetChanges();

            if (serviceChanges != null)
            {
                if (serviceChanges.ProjectService.Rows.Count > 0)
                {
                    ProjectNavigatorProjectServiceGateway projectNavigatorProjectServiceGateway = new ProjectNavigatorProjectServiceGateway(serviceChanges);

                    foreach (ProjectNavigatorTDS.ProjectServiceRow row in (ProjectNavigatorTDS.ProjectServiceDataTable)serviceChanges.ProjectService)
                    {
                        // Insert new Service
                        if ((!row.Deleted) && (!row.InDatabase))
                        {
                            int? serviceId = null; if (!row.IsServiceIDNull()) serviceId = row.ServiceID;
                            string description = ""; if (!row.IsDescriptionNull()) description = row.Description;
                            string averageSize = ""; if (!row.IsAverageSizeNull()) averageSize = row.AverageSize;
                            decimal? averagePrice = null; if (!row.IsAveragePriceNull()) averagePrice = row.AveragePrice;

                            ProjectService projectService = new ProjectService(null);
                            projectService.InsertDirect(row.ProjectID, row.RefID, serviceId, description, averageSize, averagePrice, row.Quantity, row.Deleted, row.COMPANY_ID);
                        }

                        // Update Service
                        if ((!row.Deleted) && (row.InDatabase))
                        {
                            int projectId = row.ProjectID;
                            int refId = row.RefID;
                            bool originalDeleted = false;
                            int originalCompanyId = companyId;

                            // original values
                            int? originalServiceId = projectNavigatorProjectServiceGateway.GetServiceIDOriginal(projectId, refId);
                            string originalDescription = projectNavigatorProjectServiceGateway.GetDescriptionOriginal(projectId, refId);
                            string originalAverageSize = projectNavigatorProjectServiceGateway.GetAverageSizeOriginal(projectId, refId);
                            decimal? originalAveragePrice = projectNavigatorProjectServiceGateway.GetAveragePriceOriginal(projectId, refId);
                            int originalQuantity = projectNavigatorProjectServiceGateway.GetQuantityOriginal(projectId, refId);

                            // new values
                            int? newServiceId = projectNavigatorProjectServiceGateway.GetServiceID(projectId, refId);
                            string newDescription = projectNavigatorProjectServiceGateway.GetDescription(projectId, refId);
                            string newAverageSize = projectNavigatorProjectServiceGateway.GetAverageSize(projectId, refId);
                            decimal? newAveragePrice = projectNavigatorProjectServiceGateway.GetAveragePrice(projectId, refId);
                            int newQuantity = projectNavigatorProjectServiceGateway.GetQuantity(projectId, refId);

                            ProjectService projectService = new ProjectService(null);
                            projectService.UpdateDirect(projectId, refId,  originalServiceId, originalDescription, originalAverageSize, originalAveragePrice, originalQuantity, originalDeleted, originalCompanyId, projectId, refId, newServiceId, newDescription, newAverageSize, newAveragePrice, newQuantity, originalDeleted, originalCompanyId);
                        }

                        // Deleted Service
                        if ((row.Deleted) && (row.InDatabase))
                        {
                            ProjectService projectService = new ProjectService(null);
                            projectService.DeleteDirect(row.ProjectID, row.RefID, row.COMPANY_ID);
                        }
                    }
                }
            }
        }
        private void InsertProjectService(int originalProjectId)
        {
            // ... Data for current project
            ProjectTDS projectTDSTemp = new ProjectTDS();
            ProjectServiceGateway projectServiceGatewayTemp = new ProjectServiceGateway(projectTDSTemp);
            projectServiceGatewayTemp.LoadAllByProjectId(originalProjectId);

            ProjectServiceGateway projectServiceGateway = new ProjectServiceGateway(projectTDS);
            projectServiceGateway.LoadAllByProjectId(originalProjectId);

            // ... Definition of general variables
            int refId;
            int? serviceId = null;
            string description;
            string averageSize;
            decimal? averagePrice = null;
            int quantity;
            bool deleted;
            decimal total;

            foreach (ProjectTDS.LFS_PROJECT_SERVICERow row in projectTDSTemp.Tables["LFS_PROJECT_SERVICE"].Rows)
            {
                refId = row.RefID;
                try { serviceId = row.ServiceID; }
                catch { serviceId = null; }
                try { description = row.Description; }
                catch { description = ""; }
                try { averageSize = row.AverageSize; }
                catch { averageSize = ""; }
                try { averagePrice = row.AveragePrice; }
                catch { averagePrice = null; }
                quantity = row.Quantity;
                deleted = row.Deleted;
                try { total = row.AveragePrice * row.Quantity; }
                catch { total = 0; }

                // ... Insert Service
                ProjectService projectService = new ProjectService(projectTDS);
                projectService.Insert(0, refId, serviceId, description, averageSize, averagePrice, quantity, deleted, total, Int32.Parse(hdfCompanyId.Value.Trim()));
            }
        }