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

            if (unitsInformationChanges.UnitsInformation.Rows.Count > 0)
            {
                ProjectCostingSheetInformationUnitsInformationGateway projectCostingSheetInformationUnitsInformationGateway = new ProjectCostingSheetInformationUnitsInformationGateway(unitsInformationChanges);

                foreach (ProjectCostingSheetInformationTDS.UnitsInformationRow row in (ProjectCostingSheetInformationTDS.UnitsInformationDataTable)unitsInformationChanges.UnitsInformation)
                {
                    // Insert new costing sheet Units
                    if ((!row.Deleted) && (!row.InDatabase))
                    {
                        ProjectCostingSheetUnits units = new ProjectCostingSheetUnits(null);
                        units.InsertDirect(costingSheetId, row.Work_, row.UnitID, row.RefID, row.UnitOfMeasurement, row.Quantity, row.CostCad, row.TotalCostCad, row.CostUsd, row.TotalCostUsd, row.Deleted, row.COMPANY_ID, row.StartDate, row.EndDate, row.Function_);
                    }

                    // Update costing sheet Units
                    if ((!row.Deleted) && (row.InDatabase))
                    {
                        string work_ = row.Work_;
                        int unitId = row.UnitID;
                        int refId = row.RefID;
                        bool deleted = false;

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

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

                        ProjectCostingSheetUnits units = new ProjectCostingSheetUnits(null);
                        units.UpdateDirect(costingSheetId, work_, unitId, refId, originalUnitOfMeasurement, originalQuantity, originalCostCad, originalTotalCostCad, originalCostUsd, originalTotalCostUsd, deleted, companyId, originalStartDate, originalEndDate, originalFunction_, newUnitOfMeasurement, newQuantity, newCostCad, newTotalCostCad, newCostUsd, newTotalCostUsd, deleted, companyId, newStartDate, newEndDate, newFunction_);
                    }

                    // Delete costing sheet Units
                    if ((row.Deleted) && (row.InDatabase))
                    {
                        ProjectCostingSheetUnits units = new ProjectCostingSheetUnits(null);
                        units.DeleteDirect(row.CostingSheetID, row.Work_, row.UnitID, row.RefID, row.COMPANY_ID);
                    }
                }
            }
        }
        /// <summary>
        /// Save all Units 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.UnitsInformation.Rows.Count > 0)
            {
                foreach (ProjectCostingSheetAddTDS.UnitsInformationRow row in (ProjectCostingSheetAddTDS.UnitsInformationDataTable)unitsInformationChanges.UnitsInformation)
                {
                    // Insert new costing sheet Units
                    if ((!row.Deleted) && (!row.InDatabase))
                    {
                        ProjectCostingSheetUnits units = new ProjectCostingSheetUnits(null);
                        units.InsertDirect(costingSheetId, row.Work_, row.UnitID, row.RefID, row.UnitOfMeasurement, row.Quantity, row.CostCad, row.TotalCostCad, row.CostUsd, row.TotalCostUsd, row.Deleted, row.COMPANY_ID, row.StartDate, row.EndDate, row.Function_);
                    }
                }
            }
        }