/// <summary> /// Save all to database (direct) /// </summary> /// <param name="companyId">companyId</param> public void Save(int companyId) { ActualCostsAddTDS otherChanges = (ActualCostsAddTDS)Data.GetChanges(); if (otherChanges != null) { if (otherChanges.OtherCosts.Rows.Count > 0) { ActualCostsAddOtherCostsGateway actualCostsAddOtherCostsGateway = new ActualCostsAddOtherCostsGateway(otherChanges); foreach (ActualCostsAddTDS.OtherCostsRow row in (ActualCostsAddTDS.OtherCostsDataTable)otherChanges.OtherCosts) { // Insert new other cost if ((!row.Deleted) && (!row.InDatabase)) { int projectId = row.ProjectID; int refId = row.RefID; string category = row.Category; decimal rateUsd = 0; if (!row.IsRateUsdNull()) rateUsd = row.RateUsd; string comment = ""; if (!row.IsCommentNull()) comment = row.Comment; ActualCostsOtherCosts actualCostsOtherCosts = new ActualCostsOtherCosts(null); actualCostsOtherCosts.InsertDirect(projectId, refId, category, row.Date, row.RateCad, rateUsd, comment, row.Deleted, row.COMPANY_ID); } } } } }
/// <summary> /// Save /// </summary> /// <param name="companyId">companyId</param> public void Save(int companyId) { ActualCostsInformationTDS hotelCostsInformationChanges = (ActualCostsInformationTDS)Data.GetChanges(); if (hotelCostsInformationChanges.OtherCostsBasicInformation.Rows.Count > 0) { ActualCostsInformationOtherCostsBasicInformationGateway actualCostsInformationOtherCostsBasicInformationGateway = new ActualCostsInformationOtherCostsBasicInformationGateway(hotelCostsInformationChanges); // Update employee foreach (ActualCostsInformationTDS.OtherCostsBasicInformationRow row in (ActualCostsInformationTDS.OtherCostsBasicInformationDataTable)hotelCostsInformationChanges.OtherCostsBasicInformation) { // Insert new hours if ((!row.Deleted) && (!row.InDatabase)) { string comment = ""; if (!row.IsCommentNull()) comment = row.Comment; ActualCostsOtherCosts actualCostsOtherCosts = new ActualCostsOtherCosts(null); actualCostsOtherCosts.InsertDirect(row.ProjectID, row.RefID, row.Category, row.Date, row.RateCad, row.RateUsd, comment, row.Deleted, row.COMPANY_ID); } // Update hours if ((!row.Deleted) && (row.InDatabase)) { int projectId = row.ProjectID; int refId = row.RefID; bool originalDeleted = false; int originalCompanyId = companyId; // Original values string originalCategoryId = actualCostsInformationOtherCostsBasicInformationGateway.GetCategoryOriginal(projectId, refId); DateTime originalDate = actualCostsInformationOtherCostsBasicInformationGateway.GetDateOriginal(projectId, refId); decimal originalRateCad = actualCostsInformationOtherCostsBasicInformationGateway.GetRateCadOriginal(projectId, refId); decimal originalRateUsd = actualCostsInformationOtherCostsBasicInformationGateway.GetRateUsdOriginal(projectId, refId); string originalComment = actualCostsInformationOtherCostsBasicInformationGateway.GetCommentOriginal(projectId, refId); // New values string newCategoryId = actualCostsInformationOtherCostsBasicInformationGateway.GetCategory(projectId, refId); DateTime newDate = actualCostsInformationOtherCostsBasicInformationGateway.GetDate(projectId, refId); decimal newRateCad = actualCostsInformationOtherCostsBasicInformationGateway.GetRateCad(projectId, refId); decimal newRateUsd = actualCostsInformationOtherCostsBasicInformationGateway.GetRateUsd(projectId, refId); string newComment = actualCostsInformationOtherCostsBasicInformationGateway.GetComment(projectId, refId); ActualCostsOtherCosts actualCostsOtherCosts = new ActualCostsOtherCosts(null); actualCostsOtherCosts.UpdateDirect(projectId, refId, originalCategoryId, originalDate, originalRateCad, originalRateUsd, originalComment, originalDeleted, originalCompanyId, projectId, refId, newCategoryId, newDate, newRateCad, newRateUsd, newComment, originalDeleted, originalCompanyId); } // Delete hours if ((row.Deleted) && (row.InDatabase)) { ActualCostsOtherCosts actualCostsOtherCosts = new ActualCostsOtherCosts(null); actualCostsOtherCosts.DeleteDirect(row.ProjectID, row.RefID, row.COMPANY_ID); } } } }