private void UpdateDatabase() { try { ProjectGateway projectGateway = new ProjectGateway(projectTDS); //LibraryFilesGateway libraryFilesGateway = new LibraryFilesGateway(libraryTDS); //libraryFilesGateway.Update(); //libraryTDS.AcceptChanges(); //Getting projectId for Notes table ProjectNotesGateway projectNotesGateway = new ProjectNotesGateway(projectTDS); projectGateway.Update3(); projectTDS.AcceptChanges(); // Save notes int companyId = Int32.Parse(hdfCompanyId.Value); //ProjectNavigatorProjectNotesGateway projectNavigatorNotesGateway = new ProjectNavigatorProjectNotesGateway(projectNavigatorTDS); //ProjectNavigatorProjectNotes projectNavigatorProjectNotes = new ProjectNavigatorProjectNotes(projectNavigatorTDS); //foreach (ProjectNavigatorTDS.ProjectNotesRow rowNotes in (ProjectNavigatorTDS.ProjectNotesDataTable)projectNavigatorNotesGateway.Table) //{ // if (!rowNotes.IsLIBRARY_FILES_IDNull()) // { // if (rowNotes.LIBRARY_FILES_ID == 0 && rowNotes.FILENAME != "") // { // libraryFilesGateway.LoadByFileName(rowNotes.FILENAME, companyId); // int newLibraryFilesId = libraryFilesGateway.GetlibraryFilesId(rowNotes.FILENAME); // rowNotes.LIBRARY_FILES_ID = newLibraryFilesId; // } // } //} //projectNavigatorProjectNotes.Save(companyId); // Save job info ProjectNavigatorProjectJobInfo projectNavigatorProjectJobInfo = new ProjectNavigatorProjectJobInfo(projectNavigatorTDS); projectNavigatorProjectJobInfo.Save(companyId); // Save services ProjectNavigatorProjectService projectNavigatorProjectService = new ProjectNavigatorProjectService(projectNavigatorTDS); projectNavigatorProjectService.UpdateForSave(); projectNavigatorProjectService.Save(companyId); // Save Cost Exceptions // ... Save Job Class Type Rate Classification ProjectNavigatorProjectJobClassTypeRate projectNavigatorProjectJobClassTypeRate = new ProjectNavigatorProjectJobClassTypeRate(projectNavigatorTDS); projectNavigatorProjectJobClassTypeRate.Save(companyId); // ... Save Work Function Fair Wage Classification ProjectNavigatorProjectWorkFunctionFairWage projectNavigatorProjectWorkFunctionFairWage = new ProjectNavigatorProjectWorkFunctionFairWage(projectNavigatorTDS); projectNavigatorProjectWorkFunctionFairWage.Save(companyId); // ... Save budget ProjectNavigatorProjectWorkFunctionBudget projectNavigatorProjectWorkFunctionBudget = new ProjectNavigatorProjectWorkFunctionBudget(projectNavigatorTDS); projectNavigatorProjectWorkFunctionBudget.Save(companyId); ProjectNavigatorProjectUnitsBudget projectNavigatorProjectUnitsBudget = new ProjectNavigatorProjectUnitsBudget(projectNavigatorTDS); projectNavigatorProjectUnitsBudget.Save(companyId); ProjectNavigatorProjectMaterialsBudget projectNavigatorProjectMaterialsBudget = new ProjectNavigatorProjectMaterialsBudget(projectNavigatorTDS); projectNavigatorProjectMaterialsBudget.Save(companyId); ProjectNavigatorProjectSubcontractorsBudget projectNavigatorProjectSubcontractorsBudget = new ProjectNavigatorProjectSubcontractorsBudget(projectNavigatorTDS); projectNavigatorProjectSubcontractorsBudget.Save(companyId); ProjectNavigatorProjectHotelsBudget projectNavigatorProjectHotelsBudget = new ProjectNavigatorProjectHotelsBudget(projectNavigatorTDS); projectNavigatorProjectHotelsBudget.Save(companyId); ProjectNavigatorProjectBondingsBudget projectNavigatorProjectBondingsBudget = new ProjectNavigatorProjectBondingsBudget(projectNavigatorTDS); projectNavigatorProjectBondingsBudget.Save(companyId); ProjectNavigatorProjectInsurancesBudget projectNavigatorProjectInsurancesBudget = new ProjectNavigatorProjectInsurancesBudget(projectNavigatorTDS); projectNavigatorProjectInsurancesBudget.Save(companyId); ProjectNavigatorProjectOtherCostsBudget projectNavigatorProjectOtherCostsBudget = new ProjectNavigatorProjectOtherCostsBudget(projectNavigatorTDS); projectNavigatorProjectOtherCostsBudget.Save(companyId); projectNavigatorTDS.AcceptChanges(); Session["projectNavigatorTDS"] = projectNavigatorTDS; Session["lfsProjectTDS"] = projectTDS; Session["lfsLibraryTDS"] = libraryTDS; } catch (Exception ex) { string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }
/// <summary> /// Update cost (direct to DB) /// </summary> /// <param name="originalProjectId">originalProjectId</param> /// <param name="originalRefId">originalRefId</param> /// <param name="originalSubject">originalSubject</param> /// <param name="originalLoginId">originalLoginId</param> /// <param name="originalDateTime_">originalDateTime_</param> /// <param name="originalNote">originalNote</param> /// <param name="originalDeleted">originalDeleted</param> /// <param name="originalCompanyId">originalCompanyId</param> /// <param name="originalLIBRARY_FILES_ID">originalLIBRARY_FILES_ID</param> /// /// <param name="newProjectId">newProjectId</param> /// <param name="newRefId">newRefId</param> /// <param name="newSubject">newSubject</param> /// <param name="newLoginId">newLoginId</param> /// <param name="newDateTime">newDateTime</param> /// <param name="newNote">newNote</param> /// <param name="newDeleted">newDeleted</param> /// <param name="newCompanyId">newCompanyId</param> /// <param name="newLIBRARY_FILES_ID">newLIBRARY_FILES_ID</param> public void UpdateDirect(int originalProjectId, int originalRefId, string originalSubject, int originalLoginId, DateTime originalDateTime, string originalNote, bool originalDeleted, int originalCompanyId, int? originalLIBRARY_FILES_ID, int newProjectId, int newRefId, string newSubject, int newLoginId, DateTime newDateTime, string newNote, bool newDeleted, int newCompanyId, int? newLIBRARY_FILES_ID) { ProjectNotesGateway projectNotesGateway = new ProjectNotesGateway(null); projectNotesGateway.Update(originalProjectId, originalRefId, originalSubject, originalLoginId, originalDateTime, originalNote, originalDeleted, originalCompanyId, originalLIBRARY_FILES_ID, newProjectId, newRefId, newSubject, newLoginId, newDateTime, newNote, newDeleted, newCompanyId, newLIBRARY_FILES_ID); }
/// <summary> /// DeleteDirect /// </summary> /// <param name="projectId">projectId</param> /// <param name="refId">refId</param> /// <param name="companyId">companyId</param> public void DeleteDirect(int projectId, int refId, int companyId) { ProjectNotesGateway projectNotesGateway = new ProjectNotesGateway(null); projectNotesGateway.Delete(projectId, refId, companyId); }
// //////////////////////////////////////////////////////////////////////// // PUBLIC METHODS - DATASET // /// <summary> /// LoadAllByProjectId /// </summary> /// <param name="projectId">ProjectId filter</param> public void LoadAllByProjectId(int projectId) { ProjectNotesGateway projectNotesGateway = new ProjectNotesGateway(Data); projectNotesGateway.LoadAllByProjectId(projectId); }
/// <summary> /// Insert a new note (direct to DB) /// </summary> /// <param name="projectId">projectId</param> /// <param name="refId">refId</param> /// <param name="subject">subject</param> /// <param name="loginId">loginId</param> /// <param name="dateTime">dateTime</param> /// <param name="note">note</param> /// <param name="deleted">deleted</param> /// <param name="companyId">companyId</param> /// <param name="LIBRARY_FILES_ID">LIBRARY_FILES_ID</param> public void InsertDirect(int projectId, int refId, string subject, int loginId, DateTime dateTime, string note, bool deleted, int companyId, int? LIBRARY_FILES_ID) { ProjectNotesGateway projectNotesGateway = new ProjectNotesGateway(null); projectNotesGateway.Insert(projectId, refId, subject, loginId, dateTime, note, deleted, companyId, LIBRARY_FILES_ID); }
private void InsertProjectNote(int originalProjectId) { // ... Data for current project ProjectTDS projectTDSTemp = new ProjectTDS(); ProjectNotesGateway projectNotesGatewayTemp = new ProjectNotesGateway(projectTDSTemp); projectNotesGatewayTemp.LoadAllByProjectId(originalProjectId); ProjectNotesGateway projectNotesGateway = new ProjectNotesGateway(projectTDS); projectNotesGateway.LoadAllByProjectId(originalProjectId); ProjectNotes projectNotes = new ProjectNotes(projectTDS); // ... Definition of general variables int refId; string subject; DateTime dateTime; int loginId; string note; bool deleted; int? libraryFilesId; foreach (ProjectTDS.LFS_PROJECT_NOTERow row in projectTDSTemp.Tables["LFS_PROJECT_NOTE"].Rows) { // ... Definition of general variables refId = row.RefID; subject = row.Subject; dateTime = row.DateTime; loginId = row.LoginID; try { note = row.Note; } catch { note = ""; } deleted = row.Deleted; try { libraryFilesId = row.LIBRARY_FILES_ID; } catch { libraryFilesId = null; } // ... Insert Notes projectNotes.Insert(0, subject, dateTime, loginId, note, deleted, libraryFilesId, Int32.Parse(hdfCompanyId.Value.Trim())); } }
/// <summary> /// Update4 - Duplicate proposal /// </summary> public void Update4() { ProjectCostingUpdatesGateway projectCostingUpdatesGateway = new ProjectCostingUpdatesGateway(Data); ProjectEngineerSubcontractorsGateway projectEngineerSubcontractorsGateway = new ProjectEngineerSubcontractorsGateway(Data); ProjectHistoryGateway projectHistoryGateway = new ProjectHistoryGateway(Data); ProjectNotesGateway projectNotesGateway = new ProjectNotesGateway(Data); ProjectSaleBillingPricingGateway projectSaleBillingPricingGateway = new ProjectSaleBillingPricingGateway(Data); ProjectServiceGateway projectServiceGateway = new ProjectServiceGateway(Data); ProjectSubcontractorGateway projectSubcontractorGateway = new ProjectSubcontractorGateway(Data); ProjectTechnicalGateway projectTechnicalGateway = new ProjectTechnicalGateway(Data); ProjectTermsPOGateway projectTermsPOGateway = new ProjectTermsPOGateway(Data); DataTable projectChanges = Table.GetChanges(); DataTable projectCostingUpdatesChanges = projectCostingUpdatesGateway.Table.GetChanges(); DataTable projectEngineerSubcontractorsChanges = projectEngineerSubcontractorsGateway.Table.GetChanges(); DataTable projectHistoryChanges = projectHistoryGateway.Table.GetChanges(); DataTable projectNotesChanges = projectNotesGateway.Table.GetChanges(); DataTable projectSaleBillingPricingChanges = projectSaleBillingPricingGateway.Table.GetChanges(); DataTable projectServiceChanges = projectServiceGateway.Table.GetChanges(); DataTable projectSubcontractorChanges = projectSubcontractorGateway.Table.GetChanges(); DataTable projectTechnicalChanges = projectTechnicalGateway.Table.GetChanges(); DataTable projectTermsPOChanges = projectTermsPOGateway.Table.GetChanges(); if ((projectChanges == null) && (projectCostingUpdatesChanges == null) && (projectEngineerSubcontractorsChanges == null) && (projectHistoryChanges == null) && (projectNotesChanges == null) && (projectSaleBillingPricingChanges == null) && (projectServiceChanges == null) && (projectSubcontractorChanges == null) && (projectTechnicalChanges == null) && (projectTermsPOChanges == null)) return; try { DB.Open(); DB.BeginTransaction(); Adapter.InsertCommand.Transaction = DB.Transaction; Adapter.UpdateCommand.Transaction = DB.Transaction; Adapter.DeleteCommand.Transaction = DB.Transaction; projectCostingUpdatesGateway.Adapter.InsertCommand.Transaction = DB.Transaction; projectCostingUpdatesGateway.Adapter.UpdateCommand.Transaction = DB.Transaction; projectCostingUpdatesGateway.Adapter.DeleteCommand.Transaction = DB.Transaction; projectEngineerSubcontractorsGateway.Adapter.InsertCommand.Transaction = DB.Transaction; projectEngineerSubcontractorsGateway.Adapter.UpdateCommand.Transaction = DB.Transaction; projectEngineerSubcontractorsGateway.Adapter.DeleteCommand.Transaction = DB.Transaction; projectHistoryGateway.Adapter.InsertCommand.Transaction = DB.Transaction; projectHistoryGateway.Adapter.UpdateCommand.Transaction = DB.Transaction; projectHistoryGateway.Adapter.DeleteCommand.Transaction = DB.Transaction; projectNotesGateway.Adapter.InsertCommand.Transaction = DB.Transaction; projectNotesGateway.Adapter.UpdateCommand.Transaction = DB.Transaction; projectNotesGateway.Adapter.DeleteCommand.Transaction = DB.Transaction; projectSaleBillingPricingGateway.Adapter.InsertCommand.Transaction = DB.Transaction; projectSaleBillingPricingGateway.Adapter.UpdateCommand.Transaction = DB.Transaction; projectSaleBillingPricingGateway.Adapter.DeleteCommand.Transaction = DB.Transaction; projectServiceGateway.Adapter.InsertCommand.Transaction = DB.Transaction; projectServiceGateway.Adapter.UpdateCommand.Transaction = DB.Transaction; projectServiceGateway.Adapter.DeleteCommand.Transaction = DB.Transaction; projectSubcontractorGateway.Adapter.InsertCommand.Transaction = DB.Transaction; projectSubcontractorGateway.Adapter.UpdateCommand.Transaction = DB.Transaction; projectSubcontractorGateway.Adapter.DeleteCommand.Transaction = DB.Transaction; projectTechnicalGateway.Adapter.InsertCommand.Transaction = DB.Transaction; projectTechnicalGateway.Adapter.UpdateCommand.Transaction = DB.Transaction; projectTechnicalGateway.Adapter.DeleteCommand.Transaction = DB.Transaction; projectTermsPOGateway.Adapter.InsertCommand.Transaction = DB.Transaction; projectTermsPOGateway.Adapter.UpdateCommand.Transaction = DB.Transaction; projectTermsPOGateway.Adapter.DeleteCommand.Transaction = DB.Transaction; if ((projectChanges != null) && (projectChanges.Rows.Count > 0)) { Adapter.Update(projectChanges); int newProjectId = DB.GetIdentCurrent("LFS_PROJECT", DB.Transaction); //Getting projectId for History table ProjectTDS.LFS_PROJECT_HISTORYRow rowHistory = ((ProjectTDS.LFS_PROJECT_HISTORYDataTable)projectHistoryGateway.Table).FindByProjectIDRefID(0, 1); rowHistory.ProjectID = newProjectId; projectHistoryChanges = projectHistoryGateway.Table.GetChanges(); //Getting projectId for Costing Updates table if (projectCostingUpdatesGateway.Table.Rows.Count > 0) { ProjectTDS.LFS_PROJECT_COSTING_UPDATESRow rowProjectCosting = ((ProjectTDS.LFS_PROJECT_COSTING_UPDATESDataTable)projectCostingUpdatesGateway.Table).FindByProjectID(0); rowProjectCosting.ProjectID = newProjectId; projectCostingUpdatesChanges = projectCostingUpdatesGateway.Table.GetChanges(); } //Getting projectId for Engineer Subcontractors table if (projectEngineerSubcontractorsGateway.Table.Rows.Count > 0) { ProjectTDS.LFS_PROJECT_ENGINEER_SUBCONTRACTORSRow rowEngineerSubcontractors = ((ProjectTDS.LFS_PROJECT_ENGINEER_SUBCONTRACTORSDataTable)projectEngineerSubcontractorsGateway.Table).FindByProjectID(0); rowEngineerSubcontractors.ProjectID = newProjectId; projectEngineerSubcontractorsChanges = projectEngineerSubcontractorsGateway.Table.GetChanges(); } //Getting projectId for Notes table foreach (ProjectTDS.LFS_PROJECT_NOTERow rowNotes in (ProjectTDS.LFS_PROJECT_NOTEDataTable)projectNotesGateway.Table) { if (rowNotes.ProjectID == 0) { rowNotes.ProjectID = newProjectId; } } projectNotesChanges = projectNotesGateway.Table.GetChanges(); //Getting projectId for SaleBillingPricing if (projectSaleBillingPricingGateway.Table.Rows.Count > 0) { ProjectTDS.LFS_PROJECT_SALE_BILLING_PRICINGRow rowSaleBillingPricing = ((ProjectTDS.LFS_PROJECT_SALE_BILLING_PRICINGDataTable)projectSaleBillingPricingGateway.Table).FindByProjectID(0); rowSaleBillingPricing.ProjectID = newProjectId; projectSaleBillingPricingChanges = projectSaleBillingPricingGateway.Table.GetChanges(); } //Getting projectId for Subcontractors foreach (ProjectTDS.LFS_PROJECT_SUBCONTRACTORRow rowSubcontractor in (ProjectTDS.LFS_PROJECT_SUBCONTRACTORDataTable)projectSubcontractorGateway.Table) { if (rowSubcontractor.ProjectID == 0) { rowSubcontractor.ProjectID = newProjectId; } } projectSubcontractorChanges = projectSubcontractorGateway.Table.GetChanges(); //Getting projectId for Services foreach (ProjectTDS.LFS_PROJECT_SERVICERow rowService in (ProjectTDS.LFS_PROJECT_SERVICEDataTable)projectServiceGateway.Table) { if (rowService.ProjectID == 0) { rowService.ProjectID = newProjectId; } } projectServiceChanges = projectServiceGateway.Table.GetChanges(); //Getting projectId for Technical if (projectTechnicalGateway.Table.Rows.Count > 0) { ProjectTDS.LFS_PROJECT_TECHNICALRow rowTechnical = ((ProjectTDS.LFS_PROJECT_TECHNICALDataTable)projectTechnicalGateway.Table).FindByProjectID(0); rowTechnical.ProjectID = newProjectId; projectTechnicalChanges = projectTechnicalGateway.Table.GetChanges(); } //Getting projectId for Terms if (projectTermsPOGateway.Table.Rows.Count > 0) { ProjectTDS.LFS_PROJECT_TERMSRow rowTerms = ((ProjectTDS.LFS_PROJECT_TERMSDataTable)projectTermsPOGateway.Table).FindByProjectID(0); rowTerms.ProjectID = newProjectId; projectTermsPOChanges = projectTermsPOGateway.Table.GetChanges(); } } if ((projectCostingUpdatesChanges != null) && (projectCostingUpdatesChanges.Rows.Count > 0)) { projectCostingUpdatesGateway.Adapter.Update(projectCostingUpdatesChanges); } if ((projectEngineerSubcontractorsChanges != null) && (projectEngineerSubcontractorsChanges.Rows.Count > 0)) { projectEngineerSubcontractorsGateway.Adapter.Update(projectEngineerSubcontractorsChanges); } if ((projectHistoryChanges != null) && (projectHistoryChanges.Rows.Count > 0)) { projectHistoryGateway.Adapter.Update(projectHistoryChanges); } if ((projectNotesChanges != null) && (projectNotesChanges.Rows.Count > 0)) { projectNotesGateway.Adapter.Update(projectNotesChanges); } if ((projectSaleBillingPricingChanges != null) && (projectSaleBillingPricingChanges.Rows.Count > 0)) { projectSaleBillingPricingGateway.Adapter.Update(projectSaleBillingPricingChanges); } if ((projectServiceChanges != null) && (projectServiceChanges.Rows.Count > 0)) { projectServiceGateway.Adapter.Update(projectServiceChanges); } if ((projectSubcontractorChanges != null) && (projectSubcontractorChanges.Rows.Count > 0)) { projectSubcontractorGateway.Adapter.Update(projectSubcontractorChanges); } if ((projectTechnicalChanges != null) && (projectTechnicalChanges.Rows.Count > 0)) { projectTechnicalGateway.Adapter.Update(projectTechnicalChanges); } if ((projectTermsPOChanges != null) && (projectTermsPOChanges.Rows.Count > 0)) { projectTermsPOGateway.Adapter.Update(projectTermsPOChanges); } DB.CommitTransaction(); } catch (DBConcurrencyException dBConcurrencyException) { DB.RollbackTransaction(); throw new Exception("Concurrency error: Another user already updated the data you are working on. Your operation has been cancelled.", dBConcurrencyException); } catch (SqlException sqlException) { DB.RollbackTransaction(); byte severityLevel = sqlException.Class; if (severityLevel <= 16) { throw new Exception("Low severity error. Your operation has been cancelled. SQL Error " + severityLevel + "."); } if ((severityLevel >= 17) && (severityLevel <= 19)) { throw new Exception("Mid severity error. Your operation has been cancelled. SQL Error " + severityLevel + "."); } if (severityLevel >= 20) { throw new Exception("High severity error. Your operation has been cancelled. SQL Error " + severityLevel + "."); } } catch (Exception e) { DB.RollbackTransaction(); throw new Exception("Unknow error. Your operation has been cancelled.", e); } finally { DB.Close(); } }
// //////////////////////////////////////////////////////////////////////// // PUBLIC METHODS // /// <summary> /// Load /// </summary> /// <param name="projectId">projectId</param> /// <param name="companyId">companyId</param> /// <para>Load Original table to process data for Project Costing report without filters </para> public void Load(int projectId, int companyId) { // Initialization of Gateways ProjectGateway projectGateway = new ProjectGateway(Data); projectGateway.LoadByProjectId(projectId); int companiesId = (int)projectGateway.GetClientID(projectId); ProjectJobInfoGateway projectJobInfoGateway = new ProjectJobInfoGateway(Data); projectJobInfoGateway.LoadAllByProjectId(projectId); ProjectSaleBillingPricingGateway projectSaleBillingPricingGateway = new ProjectSaleBillingPricingGateway(Data); projectSaleBillingPricingGateway.LoadAllByProjectId(projectId); ProjectTechnicalGateway projectTechnicalGateway = new ProjectTechnicalGateway(Data); projectTechnicalGateway.LoadByProjectId(projectId); ProjectTermsPOGateway projectTermsPOGateway = new ProjectTermsPOGateway(Data); projectTermsPOGateway.LoadByProjectId(projectId); ProjectSubcontractorGateway projectSubcontractorGateway = new ProjectSubcontractorGateway(Data); projectSubcontractorGateway.LoadByProjectId(projectId); ProjectEngineerSubcontractorsGateway projectEngineerSubcontractorsGateway = new ProjectEngineerSubcontractorsGateway(Data); projectEngineerSubcontractorsGateway.LoadAllByProjectId(projectId); ProjectHistoryGateway projectHistoryGateway = new ProjectHistoryGateway(Data); projectHistoryGateway.LoadFirstRow(projectId); ProjectNotesGateway projectNoteGateway = new ProjectNotesGateway(Data); projectNoteGateway.LoadByProjectId(projectId); ProjectServiceGateway projectServiceGateway = new ProjectServiceGateway(Data); projectServiceGateway.LoadByProjectId(projectId); // For Updates // ...Get the loginId for submitted field at report // ...Update LFS_PROJECT this.UpdateForReport(projectId, companiesId, projectGateway.GetSalesmanID(projectId), (projectGateway.GetProjectLeadID(projectId)).GetValueOrDefault(), companyId); // ...Update LFS_PROJECT_ENGINEER_SUBCONTRACTOR ProjectSynopsisEngineerSubcontractors projectSynopsisEngineerSubcontractors = new ProjectSynopsisEngineerSubcontractors(Data); if (projectSynopsisEngineerSubcontractors.Table.Rows.Count > 0) { projectSynopsisEngineerSubcontractors.UpdateForReport(projectId, companiesId, companyId); } // ...Update LFS_PROJECT_SUBCONTRACTOR ProjectSynopsisSubcontractor projectSynopsisSubcontractor = new ProjectSynopsisSubcontractor(Data); if (projectSynopsisSubcontractor.Table.Rows.Count > 0) { projectSynopsisSubcontractor.UpdateForReport(projectId, companiesId, companyId); } // ...Update LFS_PROJECT_NOTE ProjectSynopsisNote projectSynopsisNote = new ProjectSynopsisNote(Data); if (projectSynopsisNote.Table.Rows.Count > 0) { projectSynopsisNote.UpdateForReport(projectId, companyId); } // ...Update LFS_PROJECT_SERVICE and Total Average Price ProjectSynopsisService projectSynopsisService = new ProjectSynopsisService(Data); if (projectSynopsisService.Table.Rows.Count > 0) { ProjectSynopsisReportTDS.LFS_PROJECTRow rowTotalAveragePrice = ((ProjectSynopsisReportTDS.LFS_PROJECTDataTable)Table).FindByProjectID(projectId); rowTotalAveragePrice.TotalAveragePrice = projectSynopsisService.UpdateForReport(projectId, companyId); } }