コード例 #1
0
        /// <summary>
        /// Save all Job Info to database (direct)
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void Save(int companyId)
        {
            ProjectNavigatorTDS jobInfoChanges = (ProjectNavigatorTDS)Data.GetChanges();

            if (jobInfoChanges != null)
            {
                if (jobInfoChanges.ProjectJobInfo.Rows.Count > 0)
                {
                    ProjectNavigatorProjectJobInfoGateway projectNavigatorProjectJobInfoGateway = new ProjectNavigatorProjectJobInfoGateway(jobInfoChanges);

                    foreach (ProjectNavigatorTDS.ProjectJobInfoRow row in (ProjectNavigatorTDS.ProjectJobInfoDataTable)jobInfoChanges.ProjectJobInfo)
                    {
                        // Insert new Job Info
                        if (!row.InDatabase)
                        {
                            ProjectJobInfo projectService = new ProjectJobInfo(null);
                            projectService.InsertDirect(row.ProjectID, row.TypeOfWorkMhRehab, row.TypeOfWorkJuntionLining, row.TypeOfWorkProjectManagement, row.TypeOfWorkFullLenghtLining, row.TypeOfWorkPointRepairs, row.TypeOfWorkRehabAssessment, row.TypeOfWorkGrout, row.TypeOfWorkOther, row.COMPANY_ID, row.Agreement, row.Agreement, row.Role);
                        }

                        // Update Job Info
                        if (row.InDatabase)
                        {
                            int projectId = row.ProjectID;
                            int originalCompanyId = companyId;

                            // original values
                            bool originalTypeOfWorkMhRehab = projectNavigatorProjectJobInfoGateway.GetTypeOfWorkMhRehabOriginal(projectId);
                            bool originalTypeOfWorkJuntionLining = projectNavigatorProjectJobInfoGateway.GetTypeOfWorkJuntionLiningOriginal(projectId);
                            bool originalTypeOfWorkProjectManagement = projectNavigatorProjectJobInfoGateway.GetTypeOfWorkProjectManagementOriginal(projectId);
                            bool originalTypeOfWorkFullLenghtLining = projectNavigatorProjectJobInfoGateway.GetTypeOfWorkFullLenghtLiningOriginal(projectId);
                            bool originalTypeOfWorkPointRepairs = projectNavigatorProjectJobInfoGateway.GetTypeOfWorkPointRepairsOriginal(projectId);
                            bool originalTypeOfWorkRehabAssessment = projectNavigatorProjectJobInfoGateway.GetTypeOfWorkRehabAssessmentOriginal(projectId);
                            bool originalTypeOfWorkGrout = projectNavigatorProjectJobInfoGateway.GetTypeOfWorkGroutOriginal(projectId);
                            bool originalTypeOfWorkOther = projectNavigatorProjectJobInfoGateway.GetTypeOfWorkOtherOriginal(projectId);
                            bool originalAgreement = projectNavigatorProjectJobInfoGateway.GetAgreementOriginal(projectId);
                            bool originalWrittenQuote = projectNavigatorProjectJobInfoGateway.GetWrittenQuoteOriginal(projectId);
                            string originalRole = projectNavigatorProjectJobInfoGateway.GetRoleOriginal(projectId);

                            // new values
                            bool newTypeOfWorkMhRehab = projectNavigatorProjectJobInfoGateway.GetTypeOfWorkMhRehab(projectId);
                            bool newTypeOfWorkJuntionLining = projectNavigatorProjectJobInfoGateway.GetTypeOfWorkJuntionLining(projectId);
                            bool newTypeOfWorkProjectManagement = projectNavigatorProjectJobInfoGateway.GetTypeOfWorkProjectManagement(projectId);
                            bool newTypeOfWorkFullLenghtLining = projectNavigatorProjectJobInfoGateway.GetTypeOfWorkFullLenghtLining(projectId);
                            bool newTypeOfWorkPointRepairs = projectNavigatorProjectJobInfoGateway.GetTypeOfWorkPointRepairs(projectId);
                            bool newTypeOfWorkRehabAssessment = projectNavigatorProjectJobInfoGateway.GetTypeOfWorkRehabAssessment(projectId);
                            bool newTypeOfWorkGrout = projectNavigatorProjectJobInfoGateway.GetTypeOfWorkGrout(projectId);
                            bool newTypeOfWorkOther = projectNavigatorProjectJobInfoGateway.GetTypeOfWorkOther(projectId);
                            bool newAgreement = projectNavigatorProjectJobInfoGateway.GetAgreement(projectId);
                            bool newWrittenQuote = projectNavigatorProjectJobInfoGateway.GetWrittenQuote(projectId);
                            string newRole = projectNavigatorProjectJobInfoGateway.GetRole(projectId);

                            ProjectJobInfo projectService = new ProjectJobInfo(null);
                            projectService.UpdateDirect(projectId, originalTypeOfWorkMhRehab, originalTypeOfWorkJuntionLining, originalTypeOfWorkProjectManagement, originalTypeOfWorkFullLenghtLining, originalTypeOfWorkPointRepairs, originalTypeOfWorkRehabAssessment, originalTypeOfWorkGrout, originalTypeOfWorkOther, originalCompanyId, originalAgreement, originalWrittenQuote, originalRole, projectId, newTypeOfWorkMhRehab, newTypeOfWorkJuntionLining, newTypeOfWorkProjectManagement, newTypeOfWorkFullLenghtLining, newTypeOfWorkPointRepairs, newTypeOfWorkRehabAssessment, newTypeOfWorkGrout, newTypeOfWorkOther, originalCompanyId,  newAgreement, newWrittenQuote, newRole);
                        }
                    }
                }
            }
        }