private void LoadData(int projectId, int refId)
        {
            // Load Data
            SubcontractorHoursInformationBasicInformationGateway subcontractorHoursInformationBasicInformationGateway = new SubcontractorHoursInformationBasicInformationGateway(subcontractorHoursInformationTDS);
            if (subcontractorHoursInformationBasicInformationGateway.Table.Rows.Count > 0)
            {
                // Load subcontractor basic data
                tbxSubcontractor.Text = subcontractorHoursInformationBasicInformationGateway.GetSubcontractor(projectId, refId);

                if (subcontractorHoursInformationBasicInformationGateway.GetActive(projectId, refId))
                {
                    tbxState.Text = "Active";
                }
                else
                {
                    tbxState.Text = "Inactive";
                }

                tbxClient.Text = subcontractorHoursInformationBasicInformationGateway.GetClient(projectId, refId);
                tbxProject.Text = subcontractorHoursInformationBasicInformationGateway.GetProject(projectId, refId);
                hdfClientId.Value = subcontractorHoursInformationBasicInformationGateway.GetClientID(projectId, refId).ToString();

                tkrdpDate_.SelectedDate = (DateTime)(subcontractorHoursInformationBasicInformationGateway.GetDate(projectId, refId));

                decimal quantity = decimal.Parse(subcontractorHoursInformationBasicInformationGateway.GetQuantity(projectId, refId).ToString());
                tbxQuantity.Text = decimal.Round(quantity,1).ToString();

                if (subcontractorHoursInformationBasicInformationGateway.GetCountryId(projectId, refId) == 1) // Canada
                {
                    decimal rate = decimal.Parse(subcontractorHoursInformationBasicInformationGateway.GetRateCad(projectId, refId).ToString());
                    tbxRate.Text = decimal.Round(rate,2).ToString();

                    decimal total = decimal.Parse(subcontractorHoursInformationBasicInformationGateway.GetTotalCad(projectId, refId).ToString());
                    tbxTotal.Text = decimal.Round(total,2).ToString();
                }
                else // Usa
                {
                    decimal rate = decimal.Parse(subcontractorHoursInformationBasicInformationGateway.GetRateUsd(projectId, refId).ToString());
                    tbxRate.Text = decimal.Round(rate, 2).ToString();

                    decimal total = decimal.Parse(subcontractorHoursInformationBasicInformationGateway.GetTotalUsd(projectId, refId).ToString());
                    tbxTotal.Text = decimal.Round(total, 2).ToString();
                }

                hdfCountryId.Value = subcontractorHoursInformationBasicInformationGateway.GetCountryId(projectId, refId).ToString();
                tbxComments.Text =  subcontractorHoursInformationBasicInformationGateway.GetComment(projectId, refId);
            }
        }
        /// <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);
                    }
                }
            }
        }