/// <summary> /// Save all Insurances Costing Sheet /// </summary> /// <param name="companyId">companyId</param> /// <param name="costingSheetId">costingSheetId</param> public void Save(int companyId, int costingSheetId) { ProjectCostingSheetAddTDS changes = (ProjectCostingSheetAddTDS)Data.GetChanges(); if (changes.InsurancesInformation.Rows.Count > 0) { foreach (ProjectCostingSheetAddTDS.InsurancesInformationRow row in (ProjectCostingSheetAddTDS.InsurancesInformationDataTable)changes.InsurancesInformation) { // Insert new costing sheet Insurances if ((!row.Deleted) && (!row.InDatabase)) { ProjectCostingSheetInsurances projectCostingSheetInsurances = new ProjectCostingSheetInsurances(null); projectCostingSheetInsurances.InsertDirect(costingSheetId, row.InsuranceCompanyID, row.RefID, row.Rate, row.Deleted, row.COMPANY_ID, row.StartDate, row.EndDate, row.Comment); } } } }
/// <summary> /// Save all Insurances Costing Sheets /// </summary> /// <param name="companyId">companyId</param> /// <param name="costingSheetId">costingSheetId</param> public void Save(int companyId, int costingSheetId) { ProjectCostingSheetInformationTDS insurancesInformationChanges = (ProjectCostingSheetInformationTDS)Data.GetChanges(); if (insurancesInformationChanges.InsurancesInformation.Rows.Count > 0) { ProjectCostingSheetInformationInsurancesInformationGateway projectCostingSheetInformationInsurancesInformationGateway = new ProjectCostingSheetInformationInsurancesInformationGateway(insurancesInformationChanges); foreach (ProjectCostingSheetInformationTDS.InsurancesInformationRow row in (ProjectCostingSheetInformationTDS.InsurancesInformationDataTable)insurancesInformationChanges.InsurancesInformation) { // Insert new costing sheet Insurances if ((!row.Deleted) && (!row.InDatabase)) { ProjectCostingSheetInsurances insurances = new ProjectCostingSheetInsurances(null); insurances.InsertDirect(costingSheetId, row.InsuranceCompanyID, row.RefID, row.Rate, row.Deleted, row.COMPANY_ID, row.StartDate, row.EndDate, row.Comment); } // Update costing sheet Insurances if ((!row.Deleted) && (row.InDatabase)) { int insuranceCompanyId = row.InsuranceCompanyID; int refId = row.RefID; bool deleted = false; //original values decimal originalRate = projectCostingSheetInformationInsurancesInformationGateway.GetRateOriginal(costingSheetId, insuranceCompanyId, refId); DateTime originalStartDate = projectCostingSheetInformationInsurancesInformationGateway.GetStartDateOriginal(costingSheetId, insuranceCompanyId, refId); DateTime originalEndDate = projectCostingSheetInformationInsurancesInformationGateway.GetEndDateOriginal(costingSheetId, insuranceCompanyId, refId); //original values decimal newRate = projectCostingSheetInformationInsurancesInformationGateway.GetRate(costingSheetId, insuranceCompanyId, refId); DateTime newStartDate = projectCostingSheetInformationInsurancesInformationGateway.GetStartDate(costingSheetId, insuranceCompanyId, refId); DateTime newEndDate = projectCostingSheetInformationInsurancesInformationGateway.GetEndDate(costingSheetId, insuranceCompanyId, refId); ProjectCostingSheetInsurances insurances = new ProjectCostingSheetInsurances(null); //insurances.UpdateDirect(costingSheetId, insuranceCompanyId, refId, originalRate, deleted, companyId, originalStartDate, originalEndDate, newRate, deleted, companyId, newStartDate, newEndDate); } // Delete costing sheet Insurances if ((row.Deleted) && (row.InDatabase)) { /*ProjectCostingSheetInsurances insurances = new ProjectCostingSheetInsurances(null); insurances.DeleteDirect(row.CostingSheetID, row.InsuranceCompanyID, row.RefID, row.COMPANY_ID);*/ } } } }