/// <summary>
        /// DeleteDirect
        /// </summary>
        /// <param name="workId">workId</param>
        /// <param name="companyId">companyId</param>
        public void DeleteDirect(int workId, int companyId)
        {
            // delete field cure records
            WorkFullLengthLiningInversionFieldCureRecordGateway workFullLengthLiningInversionFieldCureRecordGateway = new WorkFullLengthLiningInversionFieldCureRecordGateway();
            workFullLengthLiningInversionFieldCureRecordGateway.LoadByWorkId(workId, companyId);

            if (workFullLengthLiningInversionFieldCureRecordGateway.Table.Rows.Count > 0)
            {
                WorkFullLengthLiningInversionFieldCureRecord workFullLengthLiningInversionFieldCureRecord = new WorkFullLengthLiningInversionFieldCureRecord(null);
                workFullLengthLiningInversionFieldCureRecord.DeleteAllDirect(workId, companyId);
            }

            // Delete inversion
            WorkFullLengthLiningInversionGateway workFullLengthLiningInversionGateway = new WorkFullLengthLiningInversionGateway(Data);
            workFullLengthLiningInversionGateway.Delete(workId, companyId);
        }
        /// <summary>
        /// Save all field cure record to database (direct)
        /// </summary>
        /// <param name="companyId">companyId</param>        
        /// <param name="runDetails">runDetails</param>
        /// <param name="projectId">projectId</param>
        public void Save(int companyId, string runDetails, int projectId)
        {
            string[] runDetailsList = runDetails.Split('>');

            FlInversionFieldCureRecordTDS flInversionFieldCureRecordChanges = (FlInversionFieldCureRecordTDS)Data.GetChanges();

            if (flInversionFieldCureRecordChanges.InversionFieldCureRecord.Rows.Count > 0)
            {
                FlInversionFieldCureRecordGateway flInversionFieldCureRecordGateway = new FlInversionFieldCureRecordGateway(flInversionFieldCureRecordChanges);

                foreach (FlInversionFieldCureRecordTDS.InversionFieldCureRecordRow row in (FlInversionFieldCureRecordTDS.InversionFieldCureRecordDataTable)flInversionFieldCureRecordChanges.InversionFieldCureRecord)
                {
                    // Insert new field cure records
                    if ((!row.Deleted) && (!row.InDatabase))
                    {
                        DateTime readingTime = row.ReadingTime;
                        decimal? headFt = null; if (!row.IsHeadFtNull()) headFt = row.HeadFt;
                        decimal? boilerInF = null; if (!row.IsBoilerInFNull()) boilerInF = row.BoilerInF;
                        decimal? boilerOutF = null; if (!row.IsBoilerOutFNull()) boilerOutF = row.BoilerOutF;
                        decimal? pumpFlow = null; if (!row.IsPumpFlowNull()) pumpFlow = row.PumpFlow;
                        decimal? pumpPsi = null; if (!row.IsPumpPsiNull()) pumpPsi = row.PumpPsi;
                        decimal? mh1Top = null; if (!row.IsMH1TopNull()) mh1Top = row.MH1Top;
                        decimal? mh1Bot = null; if (!row.IsMH1BotNull()) mh1Bot = row.MH1Bot;
                        decimal? mh2Top = null; if (!row.IsMH2TopNull()) mh2Top = row.MH2Top;
                        decimal? mh2Bot = null; if (!row.IsMH2BotNull()) mh2Bot = row.MH2Bot;
                        decimal? mh3Top = null; if (!row.IsMH3TopNull()) mh3Top = row.MH3Top;
                        decimal? mh3Bot = null; if (!row.IsMH3BotNull()) mh3Bot = row.MH3Bot;
                        decimal? mh4Top = null; if (!row.IsMH4TopNull()) mh4Top = row.MH4Top;
                        decimal? mh4Bot = null; if (!row.IsMH4BotNull()) mh4Bot = row.MH4Bot;
                        string comments = ""; if (!row.IsCommentsNull()) comments = row.Comments;

                        for (int i = 0; i < runDetailsList.Length; i++)
                        {
                            AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway();
                            string sectionId = runDetailsList[i].ToString();
                            assetSewerSectionGateway.LoadBySectionId(sectionId, companyId);
                            int assetId = assetSewerSectionGateway.GetAssetID(sectionId);

                            WorkGateway workGateway = new WorkGateway();
                            int newWorkId = 0;
                            workGateway.LoadByProjectIdAssetIdWorkType(projectId, assetId, "Full Length Lining", companyId);
                            if (workGateway.Table.Rows.Count > 0)
                            {
                                newWorkId = workGateway.GetWorkId(assetId, "Full Length Lining", projectId);
                            }

                            WorkFullLengthLiningInversionFieldCureRecord workFullLengthLiningInversionFieldCureRecord = new WorkFullLengthLiningInversionFieldCureRecord(null);
                            workFullLengthLiningInversionFieldCureRecord.InsertDirect(newWorkId, row.RefID, readingTime, headFt, boilerInF, boilerOutF, pumpFlow, pumpPsi, mh1Top, mh1Bot, mh2Top, mh2Bot, mh3Top, mh3Bot, mh4Top, mh4Bot, comments, row.Deleted, row.COMPANY_ID);
                        }
                    }

                    // Update field cure records
                    if ((!row.Deleted) && (row.InDatabase))
                    {
                        int workId = row.WorkID;
                        int refId = row.RefID;
                        bool originalDeleted = false;
                        int originalCompanyId = companyId;

                        // original values
                        DateTime originalReadingTime= flInversionFieldCureRecordGateway.GetReadingTimeOriginal(workId, refId);
                        decimal? originalHeadFt = flInversionFieldCureRecordGateway.GetHeadFtOriginal(workId, refId);
                        decimal? originalBoilerInF = flInversionFieldCureRecordGateway.GetBoilerInFOriginal(workId, refId);
                        decimal? originalBoilerOutF = flInversionFieldCureRecordGateway.GetBoilerOutFOriginal(workId, refId);
                        decimal? originalPumpFlow = flInversionFieldCureRecordGateway.GetPumpFlowOriginal(workId, refId);
                        decimal? originalPumpPsi = flInversionFieldCureRecordGateway.GetPumpPsiOriginal(workId, refId);
                        decimal? originalMH1Top = flInversionFieldCureRecordGateway.GetMH1TopOriginal(workId, refId);
                        decimal? originalMH1Bot = flInversionFieldCureRecordGateway.GetMH1BotOriginal(workId, refId);
                        decimal? originalMH2Top = flInversionFieldCureRecordGateway.GetMH2TopOriginal(workId, refId);
                        decimal? originalMH2Bot = flInversionFieldCureRecordGateway.GetMH2BotOriginal(workId, refId);
                        decimal? originalMH3Top = flInversionFieldCureRecordGateway.GetMH3TopOriginal(workId, refId);
                        decimal? originalMH3Bot = flInversionFieldCureRecordGateway.GetMH3BotOriginal(workId, refId);
                        decimal? originalMH4Top = flInversionFieldCureRecordGateway.GetMH4TopOriginal(workId, refId);
                        decimal? originalMH4Bot = flInversionFieldCureRecordGateway.GetMH4BotOriginal(workId, refId);
                        string originalComments = flInversionFieldCureRecordGateway .GetCommentsOriginal(workId, refId);

                        // new values
                        DateTime newReadingTime = flInversionFieldCureRecordGateway.GetReadingTime(workId, refId);
                        decimal? newHeadFt = flInversionFieldCureRecordGateway.GetHeadFt(workId, refId);
                        decimal? newBoilerInF = flInversionFieldCureRecordGateway.GetBoilerInF(workId, refId);
                        decimal? newBoilerOutF = flInversionFieldCureRecordGateway.GetBoilerOutF(workId, refId);
                        decimal? newPumpFlow = flInversionFieldCureRecordGateway.GetPumpFlow(workId, refId);
                        decimal? newPumpPsi = flInversionFieldCureRecordGateway.GetPumpPsi(workId, refId);
                        decimal? newMH1Top = flInversionFieldCureRecordGateway.GetMH1Top(workId, refId);
                        decimal? newMH1Bot = flInversionFieldCureRecordGateway.GetMH1Bot(workId, refId);
                        decimal? newMH2Top = flInversionFieldCureRecordGateway.GetMH2Top(workId, refId);
                        decimal? newMH2Bot = flInversionFieldCureRecordGateway.GetMH2Bot(workId, refId);
                        decimal? newMH3Top = flInversionFieldCureRecordGateway.GetMH3Top(workId, refId);
                        decimal? newMH3Bot = flInversionFieldCureRecordGateway.GetMH3Bot(workId, refId);
                        decimal? newMH4Top = flInversionFieldCureRecordGateway.GetMH4Top(workId, refId);
                        decimal? newMH4Bot = flInversionFieldCureRecordGateway.GetMH4Bot(workId, refId);
                        string newComments = flInversionFieldCureRecordGateway .GetComments(workId, refId);

                        for (int i = 0; i < runDetailsList.Length; i++)
                        {
                            AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway();
                            string sectionId = runDetailsList[i].ToString();
                            assetSewerSectionGateway.LoadBySectionId(sectionId, companyId);
                            int assetId = assetSewerSectionGateway.GetAssetID(sectionId);

                            WorkGateway workGateway = new WorkGateway();
                            int newWorkId = 0;
                            workGateway.LoadByProjectIdAssetIdWorkType(projectId, assetId, "Full Length Lining", companyId);
                            if (workGateway.Table.Rows.Count > 0)
                            {
                                newWorkId = workGateway.GetWorkId(assetId, "Full Length Lining", projectId);
                            }

                            FlInversionFieldCureRecordGateway flInversionFieldCureRecordGatewayForReview = new FlInversionFieldCureRecordGateway();
                            flInversionFieldCureRecordGatewayForReview.LoadByWorkId(newWorkId, companyId);
                            if (flInversionFieldCureRecordGatewayForReview.Table.Rows.Count > 0)
                            {
                                WorkFullLengthLiningInversionFieldCureRecord workFullLengthLiningInversionFieldCureRecord = new WorkFullLengthLiningInversionFieldCureRecord(null);
                                workFullLengthLiningInversionFieldCureRecord.UpdateDirect(newWorkId, refId, originalReadingTime, originalHeadFt, originalBoilerInF, originalBoilerOutF, originalPumpFlow, originalPumpPsi, originalMH1Top, originalMH1Bot, originalMH2Top, originalMH2Bot, originalMH3Top, originalMH3Bot, originalMH4Top, originalMH4Bot, originalComments, originalDeleted, originalCompanyId, workId, refId, newReadingTime, newHeadFt, newBoilerInF, newBoilerOutF, newPumpFlow, newPumpPsi, newMH1Top, newMH1Bot, newMH2Top, newMH2Bot, newMH3Top, newMH3Bot, newMH4Top, newMH4Bot, originalComments, originalDeleted, originalCompanyId);
                            }
                            else
                            {
                                DateTime readingTime = row.ReadingTime;
                                decimal? headFt = null; if (!row.IsHeadFtNull()) headFt = row.HeadFt;
                                decimal? boilerInF = null; if (!row.IsBoilerInFNull()) boilerInF = row.BoilerInF;
                                decimal? boilerOutF = null; if (!row.IsBoilerOutFNull()) boilerOutF = row.BoilerOutF;
                                decimal? pumpFlow = null; if (!row.IsPumpFlowNull()) pumpFlow = row.PumpFlow;
                                decimal? pumpPsi = null; if (!row.IsPumpPsiNull()) pumpPsi = row.PumpPsi;
                                decimal? mh1Top = null; if (!row.IsMH1TopNull()) mh1Top = row.MH1Top;
                                decimal? mh1Bot = null; if (!row.IsMH1BotNull()) mh1Bot = row.MH1Bot;
                                decimal? mh2Top = null; if (!row.IsMH2TopNull()) mh2Top = row.MH2Top;
                                decimal? mh2Bot = null; if (!row.IsMH2BotNull()) mh2Bot = row.MH2Bot;
                                decimal? mh3Top = null; if (!row.IsMH3TopNull()) mh3Top = row.MH3Top;
                                decimal? mh3Bot = null; if (!row.IsMH3BotNull()) mh3Bot = row.MH3Bot;
                                decimal? mh4Top = null; if (!row.IsMH4TopNull()) mh4Top = row.MH4Top;
                                decimal? mh4Bot = null; if (!row.IsMH4BotNull()) mh4Bot = row.MH4Bot;
                                string comments = ""; if (!row.IsCommentsNull()) comments = row.Comments;

                                WorkFullLengthLiningInversionFieldCureRecord workFullLengthLiningInversionFieldCureRecord = new WorkFullLengthLiningInversionFieldCureRecord(null);
                                workFullLengthLiningInversionFieldCureRecord.InsertDirect(newWorkId, row.RefID, readingTime, headFt, boilerInF, boilerOutF, pumpFlow, pumpPsi, mh1Top, mh1Bot, mh2Top, mh2Bot, mh3Top, mh3Bot, mh4Top, mh4Bot, comments, row.Deleted, row.COMPANY_ID);
                            }
                        }
                    }

                    // Deleted field cure records
                    if ((row.Deleted) && (row.InDatabase))
                    {
                        for (int i = 0; i < runDetailsList.Length; i++)
                        {
                            AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway();
                            string sectionId = runDetailsList[i].ToString();
                            assetSewerSectionGateway.LoadBySectionId(sectionId, companyId);
                            int assetId = assetSewerSectionGateway.GetAssetID(sectionId);

                            WorkGateway workGateway = new WorkGateway();
                            int newWorkId = 0;
                            workGateway.LoadByProjectIdAssetIdWorkType(projectId, assetId, "Full Length Lining", companyId);
                            if (workGateway.Table.Rows.Count > 0)
                            {
                                newWorkId = workGateway.GetWorkId(assetId, "Full Length Lining", projectId);
                            }

                            WorkFullLengthLiningInversionFieldCureRecord workFullLengthLiningInversionFieldCureRecord = new WorkFullLengthLiningInversionFieldCureRecord(null);
                            workFullLengthLiningInversionFieldCureRecord.DeleteDirect(newWorkId, row.RefID, row.COMPANY_ID);
                        }
                    }
                }
            }
        }