/// <summary>
        /// Save all udfs to database (direct)
        /// </summary>
        /// <param name="companyId">companyId</param>        
        public void Save(int companyId)
        {
            SubcontractorHoursAddTDS subcontractorsChanges = (SubcontractorHoursAddTDS)Data.GetChanges();

            if (subcontractorsChanges != null)
            {
                if (subcontractorsChanges.SubcontractorHours.Rows.Count > 0)
                {
                    SubcontractorHoursAddSubcontractorHoursGateway subcontractorHoursAddSubcontractorHoursGateway = new SubcontractorHoursAddSubcontractorHoursGateway(subcontractorsChanges);

                    foreach (SubcontractorHoursAddTDS.SubcontractorHoursRow row in (SubcontractorHoursAddTDS.SubcontractorHoursDataTable)subcontractorsChanges.SubcontractorHours)
                    {
                        // Insert new subcontractor hours
                        if ((!row.Deleted) && (!row.InDatabase))
                        {
                            int projectId = row.ProjectID;
                            int refId = row.RefID;
                            int subcontractorId = row.SubcontractorID;

                            decimal rateUsd = 0; if (!row.IsRateUsdNull()) rateUsd = row.RateUsd;
                            decimal totalUsd = 0; if (!row.IsTotalUsdNull()) totalUsd = row.TotalUsd;
                            string comment = ""; if (!row.IsCommentNull()) comment = row.Comment;

                            SubcontractorHoursSubcontractorHours subcontractorHoursSubcontractorHours = new SubcontractorHoursSubcontractorHours(null);
                            subcontractorHoursSubcontractorHours.InsertDirect(projectId, refId, subcontractorId, row.Date, row.Quantity, row.RateCad, row.TotalCad, rateUsd, totalUsd, comment, row.Deleted, row.COMPANY_ID);
                        }

                        //// Update subcontractor hours
                        //if ((!row.Deleted) && (row.InDatabase))
                        //{
                        //    int projectId = row.ProjectID;
                        //    int refId = row.RefID;
                        //    bool originalDeleted = false;
                        //    int originalCompanyId = companyId;

                        //    // Original values
                        //    int originalSubcontractorId = subcontractorHoursAddSubcontractorHoursGateway.GetSubcontractorIDOriginal(projectId, refId);
                        //    DateTime originalDate = subcontractorHoursAddSubcontractorHoursGateway.GetDateOriginal(projectId, refId);
                        //    double originalQuantity = subcontractorHoursAddSubcontractorHoursGateway.GetQuantityOriginal(projectId, refId);
                        //    decimal originalRateCad = subcontractorHoursAddSubcontractorHoursGateway.GetRateCadOriginal(projectId, refId);
                        //    decimal originalTotalCad = subcontractorHoursAddSubcontractorHoursGateway.GetTotalCadOriginal(projectId, refId);
                        //    decimal originalRateUsd = subcontractorHoursAddSubcontractorHoursGateway.GetRateUsdOriginal(projectId, refId);
                        //    decimal originalTotalUsd = subcontractorHoursAddSubcontractorHoursGateway.GetTotalUsdOriginal(projectId, refId);
                        //    string originalComment = subcontractorHoursAddSubcontractorHoursGateway.GetCommentOriginal(projectId, refId);

                        //    // New values
                        //    int newSubcontractorId = subcontractorHoursAddSubcontractorHoursGateway.GetSubcontractorID(projectId, refId);
                        //    DateTime newDate = subcontractorHoursAddSubcontractorHoursGateway.GetDate(projectId, refId);
                        //    double newQuantity = subcontractorHoursAddSubcontractorHoursGateway.GetQuantity(projectId, refId);
                        //    decimal newRateCad = subcontractorHoursAddSubcontractorHoursGateway.GetRateCad(projectId, refId);
                        //    decimal newTotalCad = subcontractorHoursAddSubcontractorHoursGateway.GetTotalCad(projectId, refId);
                        //    decimal newRateUsd = subcontractorHoursAddSubcontractorHoursGateway.GetRateUsd(projectId, refId);
                        //    decimal newTotalUsd = subcontractorHoursAddSubcontractorHoursGateway.GetTotalUsd(projectId, refId);
                        //    string newComment = subcontractorHoursAddSubcontractorHoursGateway.GetComment(projectId, refId);

                        //    SubcontractorHoursSubcontractorHours subcontractorHoursSubcontractorHours = new SubcontractorHoursSubcontractorHours(null);
                        //    subcontractorHoursSubcontractorHours.UpdateDirect(projectId, refId, originalSubcontractorId, originalDate, originalQuantity, originalRateCad, originalTotalCad, originalRateUsd, originalTotalUsd, originalComment, originalDeleted, originalCompanyId, projectId, refId, newSubcontractorId, newDate, newQuantity, newRateCad, newTotalCad, newRateUsd, newTotalUsd, newComment, originalDeleted, originalCompanyId);
                        //}

                        //// Delete subcontractor hours
                        //if ((row.Deleted) && (row.InDatabase))
                        //{
                        //    SubcontractorHoursSubcontractorHours subcontractorHoursSubcontractorHours = new SubcontractorHoursSubcontractorHours(null);
                        //    subcontractorHoursSubcontractorHours.DeleteDirect(row.ProjectID, row.RefID, row.COMPANY_ID);
                        //}
                    }
                }
            }
        }
        /// <summary>
        /// Save
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void Save(int companyId)
        {
            SubcontractorHoursInformationTDS aubcontractorHoursInformationChanges = (SubcontractorHoursInformationTDS)Data.GetChanges();

            if (aubcontractorHoursInformationChanges.BasicInformation.Rows.Count > 0)
            {
                SubcontractorHoursInformationBasicInformationGateway employeeInformationBasicInformationGateway = new SubcontractorHoursInformationBasicInformationGateway(aubcontractorHoursInformationChanges);

                // Update employee
                foreach (SubcontractorHoursInformationTDS.BasicInformationRow row in (SubcontractorHoursInformationTDS.BasicInformationDataTable)aubcontractorHoursInformationChanges.BasicInformation)
                {
                    // Insert new hours
                    if ((!row.Deleted) && (!row.InDatabase))
                    {
                        string comment = ""; if (!row.IsCommentNull()) comment = row.Comment;
                        SubcontractorHoursSubcontractorHours subcontractorHoursSubcontractorHours = new SubcontractorHoursSubcontractorHours(null);
                        subcontractorHoursSubcontractorHours.InsertDirect(row.ProjectID, row.RefID, row.SubcontractorID, row.Date, row.Quantity, row.RateCad, row.TotalCad, row.RateUsd, row.TotalUsd, 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
                        int originalSubcontractorId = employeeInformationBasicInformationGateway.GetSubcontractorIDOriginal(projectId, refId);
                        DateTime originalDate = employeeInformationBasicInformationGateway.GetDateOriginal(projectId, refId);
                        double originalQuantity = employeeInformationBasicInformationGateway.GetQuantityOriginal(projectId, refId);
                        decimal originalRateCad = employeeInformationBasicInformationGateway.GetRateCadOriginal(projectId, refId);
                        decimal originalTotalCad = employeeInformationBasicInformationGateway.GetTotalCadOriginal(projectId, refId);
                        decimal originalRateUsd = employeeInformationBasicInformationGateway.GetRateUsdOriginal(projectId, refId);
                        decimal originalTotalUsd = employeeInformationBasicInformationGateway.GetTotalUsdOriginal(projectId, refId);
                        string originalComment = employeeInformationBasicInformationGateway.GetCommentOriginal(projectId, refId);

                        // New values
                        int newSubcontractorId = employeeInformationBasicInformationGateway.GetSubcontractorID(projectId, refId);
                        DateTime newDate = employeeInformationBasicInformationGateway.GetDate(projectId, refId);
                        double newQuantity = employeeInformationBasicInformationGateway.GetQuantity(projectId, refId);
                        decimal newRateCad = employeeInformationBasicInformationGateway.GetRateCad(projectId, refId);
                        decimal newTotalCad = employeeInformationBasicInformationGateway.GetTotalCad(projectId, refId);
                        decimal newRateUsd = employeeInformationBasicInformationGateway.GetRateUsd(projectId, refId);
                        decimal newTotalUsd = employeeInformationBasicInformationGateway.GetTotalUsd(projectId, refId);
                        string newComment = employeeInformationBasicInformationGateway.GetComment(projectId, refId);

                        SubcontractorHoursSubcontractorHours subcontractorHoursSubcontractorHours = new SubcontractorHoursSubcontractorHours(null);
                        subcontractorHoursSubcontractorHours.UpdateDirect(projectId, refId, originalSubcontractorId, originalDate, originalQuantity, originalRateCad, originalTotalCad, originalRateUsd, originalTotalUsd, originalComment, originalDeleted, originalCompanyId, projectId, refId, newSubcontractorId, newDate, newQuantity, newRateCad, newTotalCad, newRateUsd, newTotalUsd, newComment, originalDeleted, originalCompanyId);
                    }

                    // Delete hours
                    if ((row.Deleted) && (row.InDatabase))
                    {
                        SubcontractorHoursSubcontractorHours subcontractorHoursSubcontractorHours = new SubcontractorHoursSubcontractorHours(null);
                        subcontractorHoursSubcontractorHours.DeleteDirect(row.ProjectID, row.RefID, row.COMPANY_ID);
                    }
                }
            }
        }