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

            if (otherChanges != null)
            {
                if (otherChanges.OtherCosts.Rows.Count > 0)
                {
                    ActualCostsAddOtherCostsGateway actualCostsAddOtherCostsGateway = new ActualCostsAddOtherCostsGateway(otherChanges);

                    foreach (ActualCostsAddTDS.OtherCostsRow row in (ActualCostsAddTDS.OtherCostsDataTable)otherChanges.OtherCosts)
                    {
                        // Insert new other cost
                        if ((!row.Deleted) && (!row.InDatabase))
                        {
                            int projectId = row.ProjectID;
                            int refId = row.RefID;
                            string category = row.Category;

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

                            ActualCostsOtherCosts actualCostsOtherCosts = new ActualCostsOtherCosts(null);
                            actualCostsOtherCosts.InsertDirect(projectId, refId, category, row.Date, row.RateCad, rateUsd, comment, row.Deleted, row.COMPANY_ID);
                        }
                    }
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // PRIVATE METHODS
        //
        /// <summary>
        /// GetNewRefId
        /// </summary>
        /// <param name="projectId">projectId</param>
        /// <param name="companyId">companyId</param>
        /// <returns>New ID</returns>
        public int GetNewRefId(int projectId, int companyId)
        {
            int newRefId = 0;

            if (Table.Rows.Count == 0)
            {
                ActualCostsAddOtherCostsGateway rr = new ActualCostsAddOtherCostsGateway();
                rr.LoadAllByProjectId(projectId, companyId);

                foreach (ActualCostsAddTDS.OtherCostsRow row1 in (ActualCostsAddTDS.OtherCostsDataTable)rr.Table)
                {
                    if (newRefId < row1.RefID)
                    {
                        newRefId = row1.RefID;
                    }
                }
            }
            else
            {
                // ... If there are rows at the grid
                // ... ... Verify if there are rows for the same project at the grid
                bool existProject = false;
                foreach (ActualCostsAddTDS.OtherCostsRow row2 in (ActualCostsAddTDS.OtherCostsDataTable)Table)
                {
                    if (projectId == row2.ProjectID)
                    {
                        existProject = true;
                    }
                }

                // ... ... If there are rows at the grid get new Id
                if (existProject)
                {
                    foreach (ActualCostsAddTDS.OtherCostsRow row3 in (ActualCostsAddTDS.OtherCostsDataTable)Table)
                    {
                        if (projectId == row3.ProjectID)
                        {
                            if (newRefId < row3.RefID)
                            {
                                newRefId = row3.RefID;
                            }
                        }
                    }
                }
                else
                {
                    // ... ... There are no rows for the project at the grid, verify on de db.
                    ActualCostsAddOtherCostsGateway rrsc = new ActualCostsAddOtherCostsGateway();
                    rrsc.LoadAllByProjectId(projectId, companyId);

                    foreach (ActualCostsAddTDS.OtherCostsRow row3 in (ActualCostsAddTDS.OtherCostsDataTable)rrsc.Table)
                    {
                        if (newRefId < row3.RefID)
                        {
                            newRefId = row3.RefID;
                        }
                    }
                }
            }

            newRefId++;

            return newRefId;
        }
 // ////////////////////////////////////////////////////////////////////////
 // PUBLIC METHODS - DATASET
 //
 /// <summary>
 /// LoadAllByProjectId
 /// </summary>
 /// <param name="projectId">projectId</param>
 /// <param name="companyId">companyId</param>
 public void LoadAllByProjectId(int projectId, int companyId)
 {
     ActualCostsAddOtherCostsGateway actualCostsAddOtherCostsGateway = new ActualCostsAddOtherCostsGateway(Data);
     actualCostsAddOtherCostsGateway.LoadAllByProjectId(projectId, companyId);
 }