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

            if (informationChanges.TemplateInformation.Rows.Count > 0)
            {
                ProjectCostingSheetTemplateInformationGateway projectCostingSheetTemplateInformationGateway = new ProjectCostingSheetTemplateInformationGateway(informationChanges);

                foreach (ProjectCostingSheetAddTDS.TemplateInformationRow row in (ProjectCostingSheetAddTDS.TemplateInformationDataTable)informationChanges.TemplateInformation)
                {
                    // Insert new costing sheet Template
                    if ((!row.Deleted) && (!row.InDatabase))
                    {
                        int? month = null; if (!row.IsMonthNull()) month = row.Month;
                        int? day = null; if (!row.IsDayNull()) day = row.Day;
                        int? year = null; if (!row.IsYearNull()) year = row.Year;

                        int? month2 = null; if (!row.IsMonthNull()) month2 = row.Month2;
                        int? day2 = null; if (!row.IsDayNull()) day2 = row.Day2;
                        int? year2 = null; if (!row.IsYearNull()) year2 = row.Year2;

                        ProjectCostingSheetTemplate projectCostingSheetTemplate = new ProjectCostingSheetTemplate(null);
                        projectCostingSheetTemplate.InsertDirect(row.Name, row.RAData, row.FLLData, row.PRData, row.JLData, row.MRData, row.MOBData, row.OtherData, row.LabourHourData, row.UnitData, row.MaterialData, row.SubcontractorData, row.MiscData, row.RevenueIncluded, row.Deleted, row.COMPANY_ID, month, day, year, month2, day2, year2);
                    }

                    // Update
                    if ((!row.Deleted) && (row.InDatabase))
                    {
                        int costingSheetTemplateId = row.CostingSheetTemplateID;
                        bool deleted = row.Deleted;

                        string originalName = projectCostingSheetTemplateInformationGateway.GetNameOriginal(costingSheetTemplateId);
                        bool originalRaData = projectCostingSheetTemplateInformationGateway.GetRADataOriginal(costingSheetTemplateId);
                        bool originalFLLData = projectCostingSheetTemplateInformationGateway.GetRAData(costingSheetTemplateId);
                        bool originalPRData = projectCostingSheetTemplateInformationGateway.GetPRDataOriginal(costingSheetTemplateId);
                        bool originalJLData = projectCostingSheetTemplateInformationGateway.GetJLDataOriginal(costingSheetTemplateId);
                        bool originalMRData = projectCostingSheetTemplateInformationGateway.GetMRDataOriginal(costingSheetTemplateId);
                        bool originalMOBData = projectCostingSheetTemplateInformationGateway.GetMOBDataOriginal(costingSheetTemplateId);
                        bool originalOtherData = projectCostingSheetTemplateInformationGateway.GetOtherDataOriginal(costingSheetTemplateId);
                        bool originalLabourHourData = projectCostingSheetTemplateInformationGateway.GetLabourHourDataOriginal(costingSheetTemplateId);
                        bool originalUnitData = projectCostingSheetTemplateInformationGateway.GetUnitDataOriginal(costingSheetTemplateId);
                        bool originalMaterialData = projectCostingSheetTemplateInformationGateway.GetMaterialDataOriginal(costingSheetTemplateId);
                        bool originalSubcontractorData = projectCostingSheetTemplateInformationGateway.GetSubcontractorDataOriginal(costingSheetTemplateId);
                        bool originalMiscData = projectCostingSheetTemplateInformationGateway.GetMiscDataOriginal(costingSheetTemplateId);
                        bool originalRevenueIncluded = projectCostingSheetTemplateInformationGateway.GetRevenueIncludedOriginal(costingSheetTemplateId);
                        int? originalMonth = null; if (projectCostingSheetTemplateInformationGateway.GetMonthOriginal(costingSheetTemplateId).HasValue) originalMonth = projectCostingSheetTemplateInformationGateway.GetMonthOriginal(costingSheetTemplateId).Value;
                        int? originalDay = null; if (projectCostingSheetTemplateInformationGateway.GetDayOriginal(costingSheetTemplateId).HasValue) originalDay = projectCostingSheetTemplateInformationGateway.GetDayOriginal(costingSheetTemplateId).Value;
                        int? originalYear = null; if (projectCostingSheetTemplateInformationGateway.GetYearOriginal(costingSheetTemplateId).HasValue) originalYear = projectCostingSheetTemplateInformationGateway.GetYearOriginal(costingSheetTemplateId).Value;

                        int? originalMonth2 = null; if (projectCostingSheetTemplateInformationGateway.GetMonth2Original(costingSheetTemplateId).HasValue) originalMonth = projectCostingSheetTemplateInformationGateway.GetMonth2Original(costingSheetTemplateId).Value;
                        int? originalDay2 = null; if (projectCostingSheetTemplateInformationGateway.GetDay2Original(costingSheetTemplateId).HasValue) originalDay = projectCostingSheetTemplateInformationGateway.GetDay2Original(costingSheetTemplateId).Value;
                        int? originalYear2 = null; if (projectCostingSheetTemplateInformationGateway.GetYear2Original(costingSheetTemplateId).HasValue) originalYear = projectCostingSheetTemplateInformationGateway.GetYear2Original(costingSheetTemplateId).Value;

                        string newName = projectCostingSheetTemplateInformationGateway.GetName(costingSheetTemplateId);
                        bool newRaData = projectCostingSheetTemplateInformationGateway.GetRAData(costingSheetTemplateId);
                        bool newFLLData = projectCostingSheetTemplateInformationGateway.GetRAData(costingSheetTemplateId);
                        bool newPRData = projectCostingSheetTemplateInformationGateway.GetPRData(costingSheetTemplateId);
                        bool newJLData = projectCostingSheetTemplateInformationGateway.GetJLData(costingSheetTemplateId);
                        bool newMRData = projectCostingSheetTemplateInformationGateway.GetMRData(costingSheetTemplateId);
                        bool newMOBData = projectCostingSheetTemplateInformationGateway.GetMOBData(costingSheetTemplateId);
                        bool newOtherData = projectCostingSheetTemplateInformationGateway.GetOtherData(costingSheetTemplateId);
                        bool newLabourHourData = projectCostingSheetTemplateInformationGateway.GetLabourHourData(costingSheetTemplateId);
                        bool newUnitData = projectCostingSheetTemplateInformationGateway.GetUnitData(costingSheetTemplateId);
                        bool newMaterialData = projectCostingSheetTemplateInformationGateway.GetMaterialData(costingSheetTemplateId);
                        bool newSubcontractorData = projectCostingSheetTemplateInformationGateway.GetSubcontractorData(costingSheetTemplateId);
                        bool newMiscData = projectCostingSheetTemplateInformationGateway.GetMiscData(costingSheetTemplateId);
                        bool newRevenueIncluded = projectCostingSheetTemplateInformationGateway.GetRevenueIncluded(costingSheetTemplateId);
                        int? newMonth = null; if (projectCostingSheetTemplateInformationGateway.GetMonth(costingSheetTemplateId).HasValue) newMonth = projectCostingSheetTemplateInformationGateway.GetMonth(costingSheetTemplateId).Value;
                        int? newDay = null; if (projectCostingSheetTemplateInformationGateway.GetDay(costingSheetTemplateId).HasValue) newDay = projectCostingSheetTemplateInformationGateway.GetDay(costingSheetTemplateId).Value;
                        int? newYear = null; if (projectCostingSheetTemplateInformationGateway.GetYear(costingSheetTemplateId).HasValue) newYear = projectCostingSheetTemplateInformationGateway.GetYear(costingSheetTemplateId).Value;
                        int? newMonth2 = null; if (projectCostingSheetTemplateInformationGateway.GetMonth2(costingSheetTemplateId).HasValue) newMonth2 = projectCostingSheetTemplateInformationGateway.GetMonth2(costingSheetTemplateId).Value;
                        int? newDay2 = null; if (projectCostingSheetTemplateInformationGateway.GetDay2(costingSheetTemplateId).HasValue) newDay2 = projectCostingSheetTemplateInformationGateway.GetDay2(costingSheetTemplateId).Value;
                        int? newYear2 = null; if (projectCostingSheetTemplateInformationGateway.GetYear2(costingSheetTemplateId).HasValue) newYear2 = projectCostingSheetTemplateInformationGateway.GetYear2(costingSheetTemplateId).Value;

                        ProjectCostingSheetTemplate projectCostingSheetTemplate = new ProjectCostingSheetTemplate(null);
                        projectCostingSheetTemplate.UpdateDirect(costingSheetTemplateId, originalName, originalRaData, originalFLLData, originalPRData, originalJLData, originalMRData, originalMOBData, originalOtherData, originalLabourHourData, originalUnitData, originalMaterialData, originalSubcontractorData, originalMiscData, originalRevenueIncluded, deleted, companyId, originalMonth, originalDay, originalYear, originalMonth2, originalDay2, originalYear2, newName, newRaData, newFLLData, newPRData, newJLData, newMRData, newMOBData, newOtherData, newLabourHourData, newUnitData, newMaterialData, newSubcontractorData, newMiscData, newRevenueIncluded, deleted, companyId, newMonth, newDay, newYear, newMonth2, newDay2, newYear2);
                    }

                    // Delete
                    if ((row.Deleted) && (row.InDatabase))
                    {
                        ProjectCostingSheetTemplate projectCostingSheetTemplate = new ProjectCostingSheetTemplate(null);
                        projectCostingSheetTemplate.DeleteDirect(0, 0);
                    }
                }
            }
        }