/// <summary>
        /// Save all Subcontractors Costing Sheet
        /// </summary>
        /// <param name="companyId">companyId</param>
        /// <param name="costingSheetId">costingSheetId</param>
        public void Save(int companyId, int costingSheetId)
        {
            ProjectCostingSheetAddTDS unitsInformationChanges = (ProjectCostingSheetAddTDS)Data.GetChanges();

            if (unitsInformationChanges.CombinedSubcontractorsInformation.Rows.Count > 0)
            {
                foreach (ProjectCostingSheetAddTDS.CombinedSubcontractorsInformationRow row in (ProjectCostingSheetAddTDS.CombinedSubcontractorsInformationDataTable)unitsInformationChanges.CombinedSubcontractorsInformation)
                {
                    // Insert new costing sheet Subcontractors
                    if ((!row.Deleted) && (!row.InDatabase))
                    {
                        ProjectCombinedCostingSheetSubcontractors projectCostingSheetSubcontractors = new ProjectCombinedCostingSheetSubcontractors(null);
                        projectCostingSheetSubcontractors.InsertDirect(costingSheetId, row.SubcontractorID, row.RefID, row.UnitOfMeasurement, row.Quantity, row.CostCad, row.TotalCostCad, row.CostUsd, row.TotalCostUsd, row.Deleted, row.COMPANY_ID, row.StartDate, row.EndDate, row.Comment, row.ProjectID);
                    }
                }
            }
        }
        /// <summary>
        /// Save all Subcontractors Costing Sheets
        /// </summary>
        /// <param name="companyId">companyId</param>
        /// <param name="costingSheetId">costingSheetId</param>
        public void Save(int companyId, int costingSheetId)
        {
            ProjectCostingSheetInformationTDS subcontractorsInformationChanges = (ProjectCostingSheetInformationTDS)Data.GetChanges();

            if (subcontractorsInformationChanges.CombinedSubcontractorsInformation.Rows.Count > 0)
            {
                ProjectCombinedCostingSheetInformationSubcontractorsInformationGateway projectCostingSheetInformationSubcontractorsInformationGateway = new ProjectCombinedCostingSheetInformationSubcontractorsInformationGateway(subcontractorsInformationChanges);

                foreach (ProjectCostingSheetInformationTDS.CombinedSubcontractorsInformationRow row in (ProjectCostingSheetInformationTDS.CombinedSubcontractorsInformationDataTable)subcontractorsInformationChanges.CombinedSubcontractorsInformation)
                {
                    // Insert new costing sheet Subcontractors
                    if ((!row.Deleted) && (!row.InDatabase))
                    {
                        ProjectCombinedCostingSheetSubcontractors subcontractors = new ProjectCombinedCostingSheetSubcontractors(null);
                        subcontractors.InsertDirect(costingSheetId, row.SubcontractorID, row.RefID, row.UnitOfMeasurement, row.Quantity, row.CostCad, row.TotalCostCad, row.CostUsd, row.TotalCostUsd, row.Deleted, row.COMPANY_ID, row.StartDate, row.EndDate, row.Comment, row.ProjectID);
                    }

                    // Update costing sheet Subcontractors
                    if ((!row.Deleted) && (row.InDatabase))
                    {
                        int subcontractorId = row.SubcontractorID;
                        int refId = row.RefID;
                        bool deleted = false;

                        //original values
                        string originalUnitOfMeasurement = projectCostingSheetInformationSubcontractorsInformationGateway.GetUnitOfMeasurementOriginal(costingSheetId, subcontractorId, refId);
                        double originalQuantity = projectCostingSheetInformationSubcontractorsInformationGateway.GetQuantityOriginal(costingSheetId, subcontractorId, refId);
                        decimal originalCostCad = projectCostingSheetInformationSubcontractorsInformationGateway.GetCostCadOriginal(costingSheetId, subcontractorId, refId);
                        decimal originalTotalCostCad = projectCostingSheetInformationSubcontractorsInformationGateway.GetTotalCostCadOriginal(costingSheetId, subcontractorId, refId);
                        decimal originalCostUsd = projectCostingSheetInformationSubcontractorsInformationGateway.GetCostUsdOriginal(costingSheetId, subcontractorId, refId);
                        decimal originalTotalCostUsd = projectCostingSheetInformationSubcontractorsInformationGateway.GetTotalCostUsdOriginal(costingSheetId, subcontractorId, refId);
                        DateTime originalStartDate = projectCostingSheetInformationSubcontractorsInformationGateway.GetStartDateOriginal(costingSheetId, subcontractorId, refId);
                        DateTime originalEndDate = projectCostingSheetInformationSubcontractorsInformationGateway.GetEndDateOriginal(costingSheetId, subcontractorId, refId);

                        //original values
                        string newUnitOfMeasurement = projectCostingSheetInformationSubcontractorsInformationGateway.GetUnitOfMeasurement(costingSheetId, subcontractorId, refId);
                        double newQuantity = projectCostingSheetInformationSubcontractorsInformationGateway.GetQuantity(costingSheetId, subcontractorId, refId);
                        decimal newCostCad = projectCostingSheetInformationSubcontractorsInformationGateway.GetCostCad(costingSheetId, subcontractorId, refId);
                        decimal newTotalCostCad = projectCostingSheetInformationSubcontractorsInformationGateway.GetTotalCostCad(costingSheetId, subcontractorId, refId);
                        decimal newCostUsd = projectCostingSheetInformationSubcontractorsInformationGateway.GetCostUsd(costingSheetId, subcontractorId, refId);
                        decimal newTotalCostUsd = projectCostingSheetInformationSubcontractorsInformationGateway.GetTotalCostUsd(costingSheetId, subcontractorId, refId);
                        DateTime newStartDate = projectCostingSheetInformationSubcontractorsInformationGateway.GetStartDate(costingSheetId, subcontractorId, refId);
                        DateTime newEndDate = projectCostingSheetInformationSubcontractorsInformationGateway.GetEndDate(costingSheetId, subcontractorId, refId);

                        ProjectCombinedCostingSheetSubcontractors subcontractors = new ProjectCombinedCostingSheetSubcontractors(null);
                        subcontractors.UpdateDirect(costingSheetId, subcontractorId, refId, originalUnitOfMeasurement, originalQuantity, originalCostCad, originalTotalCostCad, originalCostUsd, originalTotalCostUsd, deleted, companyId, originalStartDate, originalEndDate, newUnitOfMeasurement, newQuantity, newCostCad, newTotalCostCad, newCostUsd, newTotalCostUsd, deleted, companyId, newStartDate, newEndDate);
                    }

                    // Delete costing sheet Subcontractors
                    if ((row.Deleted) && (row.InDatabase))
                    {
                        ProjectCombinedCostingSheetSubcontractors subcontractors = new ProjectCombinedCostingSheetSubcontractors(null);
                        subcontractors.DeleteDirect(row.CostingSheetID, row.SubcontractorID, row.RefID, row.COMPANY_ID);
                    }
                }
            }
        }