/// <summary> /// DeleteAllDirect /// </summary> /// <param name="materialId">materialId</param> /// <param name="companyId">companyId</param> public void DeleteAllDirect(int materialId, int companyId) { // Delete exceptions MaterialsCostHistoryExceptions materialsCostHistoryExceptions = new MaterialsCostHistoryExceptions(null); materialsCostHistoryExceptions.DeleteAllDirect(materialId, companyId); // Delete costs MaterialsCostHistoryGateway materialsCostHistoryGateway = new MaterialsCostHistoryGateway(null); materialsCostHistoryGateway.DeleteAll(materialId, companyId); }
/// <summary> /// Save all materials to database (direct) /// </summary> /// <param name="companyId">companyId</param> public void Save(int companyId, int materialId) { MaterialsInformationTDS costHistoryExceptionsInformationChanges = (MaterialsInformationTDS)Data.GetChanges(); if (costHistoryExceptionsInformationChanges.CostHistoryExceptionsInformation.Rows.Count > 0) { MaterialsInformationCostHistoryExceptionsInformationGateway materialsInformationCostHistoryExceptionsInformationGateway = new MaterialsInformationCostHistoryExceptionsInformationGateway(costHistoryExceptionsInformationChanges); foreach (MaterialsInformationTDS.CostHistoryExceptionsInformationRow row in (MaterialsInformationTDS.CostHistoryExceptionsInformationDataTable)costHistoryExceptionsInformationChanges.CostHistoryExceptionsInformation) { // Insert new costs exceptions if ((!row.Deleted) && (!row.InDatabase)) { MaterialsCostHistoryExceptions materialsCostHistoryExceptions = new MaterialsCostHistoryExceptions(null); materialsCostHistoryExceptions.InsertDirect(row.CostID, row.RefID, materialId, row.Work_, row.Function_, row.UnitOfMeasurement, row.CostCad, row.CostUsd, row.Deleted, row.COMPANY_ID); } // Update costs exceptions if ((!row.Deleted) && (row.InDatabase)) { int costId = row.CostID; int refId = row.RefID; bool originalDeleted = row.Deleted; int originalCompanyId = companyId; // original values string originalWork = materialsInformationCostHistoryExceptionsInformationGateway.GetWork_Original(costId, refId); string originalFunction = materialsInformationCostHistoryExceptionsInformationGateway.GetFunction_Original(costId, refId); string originalUnitOfMeasurement = materialsInformationCostHistoryExceptionsInformationGateway.GetUnitOfMeasurementOriginal(costId, refId); decimal originalCostCad = materialsInformationCostHistoryExceptionsInformationGateway.GetCostCadOriginal(costId, refId); decimal originalCostUsd = materialsInformationCostHistoryExceptionsInformationGateway.GetCostUsdOriginal(costId, refId); // new values string newWork = materialsInformationCostHistoryExceptionsInformationGateway.GetWork_Original(costId, refId); string newFunction = materialsInformationCostHistoryExceptionsInformationGateway.GetFunction_Original(costId, refId); string newUnitOfMeasurement = materialsInformationCostHistoryExceptionsInformationGateway.GetUnitOfMeasurement(costId, refId); decimal newCostCad = materialsInformationCostHistoryExceptionsInformationGateway.GetCostCad(costId, refId); decimal newCostUsd = materialsInformationCostHistoryExceptionsInformationGateway.GetCostUsd(costId, refId); MaterialsCostHistoryExceptions materialsCostHistoryExceptions = new MaterialsCostHistoryExceptions(null); materialsCostHistoryExceptions.UpdateDirect(costId, refId, materialId, originalWork, originalFunction, originalUnitOfMeasurement, originalCostCad, originalCostUsd, originalDeleted, originalCompanyId, costId, refId, materialId, newWork, newFunction, newUnitOfMeasurement, newCostCad, newCostUsd, originalDeleted, originalCompanyId); } // Deleted costs exceptions if ((row.Deleted) && (row.InDatabase)) { MaterialsCostHistoryExceptions materialsCostHistoryExceptions = new MaterialsCostHistoryExceptions(null); materialsCostHistoryExceptions.DeleteDirect(row.CostID, row.RefID, row.COMPANY_ID); } } } }