/// ////////////////////////////////////////////////////////////////////////
        /// EVENTS
        ///
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!Convert.ToBoolean(Session["sgLFS_APP_VIEW"]))
                {
                    Response.Redirect("./../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) && ((string)Request.QueryString["record_deleted"] == null))
                {
                    Response.Redirect("./../error_page.aspx?error=" + "Invalid query string in view_fulllength.aspx");
                }

                // Prepare initial values
                Session.Remove("pointRepairDummy");
                addRecordTDS = new AddRecordTDS();

                // If coming from navigator2.aspx or view_scopesheet.aspx
                if (((string)Request.QueryString["source_page"] == "navigator2.aspx") || ((string)Request.QueryString["source_page"] == "view_scopesheet.aspx"))
                {
                    int companyId = Convert.ToInt32(Session["companyID"]);
                    Guid id = (Guid)Session["lfsMasterAreaId"];

                    //... Get lfs master area record
                    LFSRecordGateway lfsRecordGateway = new LFSRecordGateway();
                    tdsLfsRecord = lfsRecordGateway.GetRecordByIdCompanyId(id, companyId);

                    AddRecordPointRepairsGateway addRecordPointRepairsGateway = new AddRecordPointRepairsGateway(addRecordTDS);
                    addRecordPointRepairsGateway.LoadById(id, companyId);

                    //... Store datasets
                    Session["tdsLfsRecord"] = tdsLfsRecord;
                    Session["addRecordTDS"] = addRecordTDS;
                    pointRepairs = addRecordTDS.PointRepairs;
                    Session["pointRepairs"] = pointRepairs;
                }

                // If coming from delete_record.aspx
                if ((string)Request.QueryString["record_deleted"] == "false")
                {
                    //... Restore dataset lfs record
                    tdsLfsRecord = (TDSLFSRecord)Session["tdsLfsRecord"];
                    addRecordTDS = (AddRecordTDS)Session["addRecordTDS"];
                }

                // Prepare initial data
                // ... for client
                CompaniesGateway companiesGateway = new CompaniesGateway();
                tbxCOMPANIES_ID.Text = companiesGateway.GetName((int)tdsLfsRecord.LFS_MASTER_AREA.Rows[0]["COMPANIES_ID"], Convert.ToInt32(Session["companyID"]));

                // ... for traffic control
                LFSTrafficControlGateway lfsTrafficControlGateway = new LFSTrafficControlGateway();
                DataSet dsLfsTrafficControl = lfsTrafficControlGateway.GetLFSTrafficControlForDropDownList("");

                ddlDegreeOfTrafficControl.DataSource = dsLfsTrafficControl;
                ddlDegreeOfTrafficControl.DataTextField = "TrafficControl";

                // Databind
                Page.DataBind();

                TDSLFSRecord.LFS_MASTER_AREARow lfsMasterAreaRow = tdsLfsRecord.LFS_MASTER_AREA.FindByIDCOMPANY_ID(new Guid(tbxID.Text), Convert.ToInt32(Session["companyID"]));
                ddlDegreeOfTrafficControl.SelectedValue = (lfsMasterAreaRow.IsDegreeOfTrafficControlNull()) ? "" : lfsMasterAreaRow.DegreeOfTrafficControl;
            }
            else
            {
                // Restore datasets
                tdsLfsRecord = (TDSLFSRecord)Session["tdsLfsRecord"];
                addRecordTDS = (AddRecordTDS)Session["addRecordTDS"];
            }
        }
        /// ////////////////////////////////////////////////////////////////////////
        /// EVENTS
        ///
        //
        // Page_Load
        //
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                //--- Security check
                if (!Convert.ToBoolean(Session["sgLFS_APP_VIEW"]))
                {
                    Response.Redirect("./../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                //--- Validate query string
                if (((string)Request.QueryString["source_page"] == null) && ((string)Request.QueryString["record_deleted"] == null))
                {
                    Response.Redirect("./../error_page.aspx?error=" + "Invalid query string in view_fulllength.aspx");
                }

                //--- If coming from navigator2.aspx or view_fulllength.aspx
                if (((string)Request.QueryString["source_page"] == "navigator2.aspx") || ((string)Request.QueryString["source_page"] == "view_fulllength.aspx"))
                {
                    //--- Get lfs master area record
                    LFSRecordGateway lfsRecordGateway = new LFSRecordGateway();
                    tdsLfsRecord = lfsRecordGateway.GetRecordByIdCompanyId((Guid)Session["lfsMasterAreaId"], Convert.ToInt32(Session["companyID"]));

                    hdfId.Value = ((Guid)Session["lfsMasterAreaId"]).ToString();
                    //--- Store datasets
                    Session["tdsLfsRecord"] = tdsLfsRecord;
                }

                //--- If coming from view_fulllength_m1.aspx, view_fulllength_m2.aspx, or delete_record.aspx
                if (((string)Request.QueryString["source_page"] == "view_fulllength_m1.aspx") || ((string)Request.QueryString["source_page"] == "view_fulllength_m2.aspx") || ((string)Request.QueryString["record_deleted"] == "false"))
                {
                    //--- Restore dataset lfs record
                    tdsLfsRecord = (TDSLFSRecord)Session["tdsLfsRecord"];
                }

                //--- Prepare initial data for client
                CompaniesGateway companiesGateway = new CompaniesGateway();
                tbxCOMPANIES_ID.Text = companiesGateway.GetName((int)tdsLfsRecord.LFS_MASTER_AREA.Rows[0]["COMPANIES_ID"], Convert.ToInt32(Session["companyID"]));

                //--- Databind
                Page.DataBind();
            }
            else
            {
                //--- Restore dataset lfs record
                tdsLfsRecord = (TDSLFSRecord)Session["tdsLfsRecord"];
            }
        }
        /// ////////////////////////////////////////////////////////////////////////
        /// EVENTS
        ///
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                //--- Security check
                if (!Convert.ToBoolean(Session["sgLFS_APP_VIEW"]))
                {
                    Response.Redirect("./../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Prepare initial
                Session.Remove("lfsM2TablesDummy");

                //... Restore data set lfs record
                tdsLfsRecord = (TDSLFSRecord)Session["tdsLfsRecord"];

                // ... for client
                CompaniesGateway companiesGateway = new CompaniesGateway();
                tbxCOMPANIES_ID.Text = companiesGateway.GetName((int)tdsLfsRecord.LFS_MASTER_AREA.Rows[0]["COMPANIES_ID"], Convert.ToInt32(Session["companyID"]));

                // ... for measurement type
                LFSMeasurementTypeGateway lfsMeasurementTypeGateway = new LFSMeasurementTypeGateway();
                DataSet dsLfsMeasurementType = lfsMeasurementTypeGateway.GetLFSMeasurementTypeForDropDownList("");

                ddlMeasurementType.DataSource = dsLfsMeasurementType;
                ddlMeasurementType.DataTextField = "MeasurementType";

                // Load LfsM2Tables data
                int companyId = Convert.ToInt32(Session["companyID"]);
                Guid id = new Guid(Request.QueryString["id"].ToString());
                hdfId.Value = Request.QueryString["id"].ToString();

                viewFullLengthLiningTDS = new ViewFullLengthLiningTDS();
                ViewFullLengthLiningLfsM2TablesGateway viewFullLengthLiningLfsM2TablesGateway = new ViewFullLengthLiningLfsM2TablesGateway(viewFullLengthLiningTDS);
                viewFullLengthLiningLfsM2TablesGateway.LoadById(id, companyId);

                Session["viewFullLengthLiningTDS"] = viewFullLengthLiningTDS;
                lfsM2Tables = viewFullLengthLiningTDS.LfsM2Tables;
                Session["lfsM2Tables"] = lfsM2Tables;

                // Databind
                Page.DataBind();

                TDSLFSRecord.LFS_MASTER_AREARow lfsMasterAreaRow = tdsLfsRecord.LFS_MASTER_AREA.FindByIDCOMPANY_ID(new Guid(tbxID.Text), Convert.ToInt32(Session["companyID"]));
                ddlMeasurementType.SelectedValue = (lfsMasterAreaRow.IsMeasurementTypeNull()) ? "" : lfsMasterAreaRow.MeasurementType;
            }
            else
            {
                // Restore data set lfs record
                tdsLfsRecord = (TDSLFSRecord)Session["tdsLfsRecord"];
                viewFullLengthLiningTDS = (ViewFullLengthLiningTDS)Session["viewFullLengthLiningTDS"];
            }
        }
        //
        // GetRecordRCTAndExpandedRecordsByIdCompanyId
        //
        // Returns a typed dataset containing a record. The dataset contains
        // one row for LFS_MASTER_AREA, zero or more rows for LFS_POINT_REPAIRS,
        // zero or more rows for LFS_M2_TABLES, and zero or more tables for
        // LFS_JUNCTION_LINER. It also returns LFS_MASTER_AREA_RCT,
        // LFS_POINT_REPAIRS_RCT, LFS_M2_TABLES_RCT, and LFS_JUNCTION_LINER_RCT.
        // Besides it expands LFS_MASTER_AREA_RCT, LFS_POINT_REPAIRS_RCT,
        // LFS_M2_TABLES_RCT, and LFS_JUNCTION_LINER.
        //
        // This method is intended to be used in the Record Change Tracking tool.
        //
        public TDSLFSRecordForRCT GetRecordRCTAndExpandedRecordsByIdCompanyId(string id, int companyId)
        {
            TDSLFSRecordForRCT result = new TDSLFSRecordForRCT();
            TDSLFSRecordForRCT auxiliar = new TDSLFSRecordForRCT();

            LoginGateway loginGateway = new LoginGateway();
            CompaniesGateway companiesGateway = new CompaniesGateway();

            //--- Get lfs record and rct records
            TDSLFSRecord tdsLfsRecord = this.GetRecordAndRCTByIdCompanyId(new Guid(id), companyId);
            result.Merge(tdsLfsRecord, true, System.Data.MissingSchemaAction.Ignore);

            //--- Prepare master area 2
            TDSLFSRecord.LFS_MASTER_AREARow lfsMasterAreaRow = tdsLfsRecord.LFS_MASTER_AREA.FindByIDCOMPANY_ID(new Guid(id), companyId);
            TDSLFSRecordForRCT.LFS_MASTER_AREA2Row lfsMasterArea2Row = result.LFS_MASTER_AREA2.NewLFS_MASTER_AREA2Row();

            for (int i = 0; i < tdsLfsRecord.LFS_MASTER_AREA.Columns.Count; i++)
            {
                lfsMasterArea2Row[i] = lfsMasterAreaRow[i];
            }
            lfsMasterArea2Row.NAME = companiesGateway.GetName(lfsMasterAreaRow.COMPANIES_ID, companyId);

            result.LFS_MASTER_AREA2.AddLFS_MASTER_AREA2Row(lfsMasterArea2Row);

            //--- Expand master area rct
            TDSLFSRecordForRCT.LFS_MASTER_AREA_RCT_EXPANDEDRow prevLfsMasterAreaRctExpandedRow = null;

            foreach(TDSLFSRecord.LFS_MASTER_AREA_RCTRow lfsMasterAreaRctRow in tdsLfsRecord.LFS_MASTER_AREA_RCT)
            {
                //--- ... Create current record
                TDSLFSRecordForRCT.LFS_MASTER_AREA_RCT_EXPANDEDRow lfsMasterAreaRctExpandedRow = result.LFS_MASTER_AREA_RCT_EXPANDED.NewLFS_MASTER_AREA_RCT_EXPANDEDRow();

                //--- ... Copy data from previous record to current record (if previous record exists)
                if (prevLfsMasterAreaRctExpandedRow != null)
                {
                    for (int i = 0; i < result.LFS_MASTER_AREA_RCT_EXPANDED.Columns.Count; i++)
                    {
                        if (result.LFS_MASTER_AREA_RCT_EXPANDED.Columns[i].ColumnName != "RctID")
                        {
                            lfsMasterAreaRctExpandedRow[i] = prevLfsMasterAreaRctExpandedRow[i];
                        }
                    }
                }

                //--- ... Expand current record
                lfsMasterAreaRctExpandedRow.ID = lfsMasterAreaRctRow.ID;
                lfsMasterAreaRctExpandedRow.COMPANY_ID = lfsMasterAreaRctRow.COMPANY_ID;

                #region Expand changes

                foreach (string columnValueItem in RecordChangeTracking.Split(lfsMasterAreaRctRow.Changes))
                {
                    switch (RecordChangeTracking.GetColumnName(columnValueItem))
                    {
                        case "ID":
                            break;
                        case "COMPANY_ID":
                            break;
                        case "RecordID":
                            lfsMasterAreaRctExpandedRow.RecordID = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "ClientID":
                            lfsMasterAreaRctExpandedRow.ClientID = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "COMPANIES_ID":
                            lfsMasterAreaRctExpandedRow.COMPANIES_ID = Convert.ToInt32(RecordChangeTracking.GetValue(columnValueItem));
                            lfsMasterAreaRctExpandedRow.NAME = companiesGateway.GetName(lfsMasterAreaRctExpandedRow.COMPANIES_ID, companyId);
                            break;
                        case "SubArea":
                            lfsMasterAreaRctExpandedRow.SubArea = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "Street":
                            lfsMasterAreaRctExpandedRow.Street = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "USMH":
                            lfsMasterAreaRctExpandedRow.USMH = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "DSMH":
                            lfsMasterAreaRctExpandedRow.DSMH = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "Size_":
                            lfsMasterAreaRctExpandedRow.Size_ = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "ScaledLength":
                            lfsMasterAreaRctExpandedRow.ScaledLength = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "P1Date":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.P1Date = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetP1DateNull();
                            break;
                        case "ActualLength":
                            lfsMasterAreaRctExpandedRow.ActualLength = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "LiveLats":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.LiveLats = Convert.ToDouble(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetLiveLatsNull();
                            break;
                        case "CXIsRemoved":
                            lfsMasterAreaRctExpandedRow.CXIsRemoved = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "M1Date":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.M1Date = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetM1DateNull();
                            break;
                        case "M2Date":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.M2Date = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetM2DateNull();
                            break;
                        case "InstallDate":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.InstallDate = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetInstallDateNull();
                            break;
                        case "FinalVideo":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.FinalVideo = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetFinalVideoNull();
                            break;
                        case "Comments":
                            lfsMasterAreaRctExpandedRow.Comments = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "IssueIdentified":
                            lfsMasterAreaRctExpandedRow.IssueIdentified = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "IssueResolved":
                            lfsMasterAreaRctExpandedRow.IssueResolved = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "FullLengthLining":
                            lfsMasterAreaRctExpandedRow.FullLengthLining = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "SubcontractorLining":
                            lfsMasterAreaRctExpandedRow.SubcontractorLining = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "OutOfScopeInArea":
                            lfsMasterAreaRctExpandedRow.OutOfScopeInArea = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "IssueGivenToBayCity":
                            lfsMasterAreaRctExpandedRow.IssueGivenToBayCity = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "ConfirmedSize":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.ConfirmedSize = Convert.ToInt32(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetConfirmedSizeNull();
                            break;
                        case "InstallRate":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.InstallRate = Convert.ToDecimal(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetInstallRateNull();
                            break;
                        case "DeadlineDate":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.DeadlineDate = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetDeadlineDateNull();
                            break;
                        case "ProposedLiningDate":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.ProposedLiningDate = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetProposedLiningDateNull();
                            break;
                        case "SalesIssue":
                            lfsMasterAreaRctExpandedRow.SalesIssue = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "LFSIssue":
                            lfsMasterAreaRctExpandedRow.LFSIssue = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "ClientIssue":
                            lfsMasterAreaRctExpandedRow.ClientIssue = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "InvestigationIssue":
                            lfsMasterAreaRctExpandedRow.InvestigationIssue = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "PointLining":
                            lfsMasterAreaRctExpandedRow.PointLining = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "Grouting":
                            lfsMasterAreaRctExpandedRow.Grouting = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "LateralLining":
                            lfsMasterAreaRctExpandedRow.LateralLining = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "VacExDate":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.VacExDate = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetVacExDateNull();
                            break;
                        case "PusherDate":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.PusherDate = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetPusherDateNull();
                            break;
                        case "LinerOrdered":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.LinerOrdered = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetLinerOrderedNull();
                            break;
                        case "Restoration":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.Restoration = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetRestorationNull();
                            break;
                        case "GroutDate":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.GroutDate = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetGroutDateNull();
                            break;
                        case "JLiner":
                            lfsMasterAreaRctExpandedRow.JLiner = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "RehabAssessment":
                            lfsMasterAreaRctExpandedRow.RehabAssessment = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "EstimatedJoints":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.EstimatedJoints = Convert.ToInt32(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetEstimatedJointsNull();
                            break;
                        case "JointsTestSealed":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.JointsTestSealed = Convert.ToInt32(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetJointsTestSealedNull();
                            break;
                        case "PreFlushDate":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.PreFlushDate = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetPreFlushDateNull();
                            break;
                        case "PreVideoDate":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.PreVideoDate = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetPreVideoDateNull();
                            break;
                        case "USMHMN":
                            lfsMasterAreaRctExpandedRow.USMHMN = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "DSMHMN":
                            lfsMasterAreaRctExpandedRow.DSMHMN = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "USMHDepth":
                            lfsMasterAreaRctExpandedRow.USMHDepth = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "DSMHDepth":
                            lfsMasterAreaRctExpandedRow.DSMHDepth = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "MeasurementsTakenBy":
                            lfsMasterAreaRctExpandedRow.MeasurementsTakenBy = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "SteelTapeThruPipe":
                            lfsMasterAreaRctExpandedRow.SteelTapeThruPipe = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "USMHAtMouth1200":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.USMHAtMouth1200 = Convert.ToDouble(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetUSMHAtMouth1200Null();
                            break;
                        case "USMHAtMouth100":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.USMHAtMouth100 = Convert.ToDouble(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetUSMHAtMouth100Null();
                            break;
                        case "USMHAtMouth200":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.USMHAtMouth200 = Convert.ToDouble(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetUSMHAtMouth200Null();
                            break;
                        case "USMHAtMouth300":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.USMHAtMouth300 = Convert.ToDouble(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetUSMHAtMouth300Null();
                            break;
                        case "USMHAtMouth400":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.USMHAtMouth400 = Convert.ToDouble(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetUSMHAtMouth400Null();
                            break;
                        case "USMHAtMouth500":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.USMHAtMouth500 = Convert.ToDouble(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetUSMHAtMouth500Null();
                            break;
                        case "DSMHAtMouth1200":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.DSMHAtMouth1200 = Convert.ToDouble(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetDSMHAtMouth1200Null();
                            break;
                        case "DSMHAtMouth100":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.DSMHAtMouth100 = Convert.ToDouble(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetDSMHAtMouth100Null();
                            break;
                        case "DSMHAtMouth200":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.DSMHAtMouth200 = Convert.ToDouble(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetDSMHAtMouth200Null();
                            break;
                        case "DSMHAtMouth300":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.DSMHAtMouth300 = Convert.ToDouble(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetDSMHAtMouth300Null();
                            break;
                        case "DSMHAtMouth400":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.DSMHAtMouth400 = Convert.ToDouble(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetDSMHAtMouth400Null();
                            break;
                        case "DSMHAtMouth500":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.DSMHAtMouth500 = Convert.ToDouble(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetDSMHAtMouth500Null();
                            break;
                        case "HydrantAddress":
                            lfsMasterAreaRctExpandedRow.HydrantAddress = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "DistanceToInversionMH":
                            lfsMasterAreaRctExpandedRow.DistanceToInversionMH = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "RampsRequired":
                            lfsMasterAreaRctExpandedRow.RampsRequired = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "DegreeOfTrafficControl":
                            lfsMasterAreaRctExpandedRow.DegreeOfTrafficControl = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "StandarBypass":
                            lfsMasterAreaRctExpandedRow.StandarBypass = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "HydroWireDetails":
                            lfsMasterAreaRctExpandedRow.HydroWireDetails = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "PipeMaterialType":
                            lfsMasterAreaRctExpandedRow.PipeMaterialType = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "CappedLaterals":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.CappedLaterals = Convert.ToInt32(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetCappedLateralsNull();
                            break;
                        case "RoboticPrepRequired":
                            lfsMasterAreaRctExpandedRow.RoboticPrepRequired = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "PipeSizeChange":
                            lfsMasterAreaRctExpandedRow.PipeSizeChange = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "M1Comments":
                            lfsMasterAreaRctExpandedRow.M1Comments = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "VideoDoneFrom":
                            lfsMasterAreaRctExpandedRow.VideoDoneFrom = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "ToManhole":
                            lfsMasterAreaRctExpandedRow.ToManhole = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "CutterDescriptionDuringMeasuring":
                            lfsMasterAreaRctExpandedRow.CutterDescriptionDuringMeasuring = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "FullLengthPointLiner":
                            lfsMasterAreaRctExpandedRow.FullLengthPointLiner = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "BypassRequired":
                            lfsMasterAreaRctExpandedRow.BypassRequired = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "RoboticDistances":
                            lfsMasterAreaRctExpandedRow.RoboticDistances = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "TrafficControlDetails":
                            lfsMasterAreaRctExpandedRow.TrafficControlDetails = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "LineWithID":
                            lfsMasterAreaRctExpandedRow.LineWithID = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "SchoolZone":
                            lfsMasterAreaRctExpandedRow.SchoolZone = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "RestaurantArea":
                            lfsMasterAreaRctExpandedRow.RestaurantArea = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "CarwashLaundromat":
                            lfsMasterAreaRctExpandedRow.CarwashLaundromat = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "HydroPulley":
                            lfsMasterAreaRctExpandedRow.HydroPulley = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "FridgeCart":
                            lfsMasterAreaRctExpandedRow.FridgeCart = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "TwoInchPump":
                            lfsMasterAreaRctExpandedRow.TwoInchPump = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "SixInchBypass":
                            lfsMasterAreaRctExpandedRow.SixInchBypass = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "Scaffolding":
                            lfsMasterAreaRctExpandedRow.Scaffolding = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "WinchExtension":
                            lfsMasterAreaRctExpandedRow.WinchExtension = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "ExtraGenerator":
                            lfsMasterAreaRctExpandedRow.ExtraGenerator = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "GreyCableExtension":
                            lfsMasterAreaRctExpandedRow.GreyCableExtension = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "EasementMats":
                            lfsMasterAreaRctExpandedRow.EasementMats = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "MeasurementType":
                            lfsMasterAreaRctExpandedRow.MeasurementType = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "DropPipe":
                            lfsMasterAreaRctExpandedRow.DropPipe = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "DropPipeInvertDepth":
                            lfsMasterAreaRctExpandedRow.DropPipeInvertDepth = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "Deleted":
                            lfsMasterAreaRctExpandedRow.Deleted = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "MeasuredFromManhole":
                            lfsMasterAreaRctExpandedRow.MeasuredFromManhole = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "MainLined":
                            lfsMasterAreaRctExpandedRow.MainLined = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "BenchingIssue":
                            lfsMasterAreaRctExpandedRow.BenchingIssue = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "Archived":
                            lfsMasterAreaRctExpandedRow.Archived = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "ScaledLength1":
                            break;
                        case "History":
                            lfsMasterAreaRctExpandedRow.History = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "NumLats":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.NumLats = Convert.ToInt32(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetNumLatsNull();
                            break;
                        case "NotLinedYet":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsMasterAreaRctExpandedRow.NotLinedYet = Convert.ToInt32(RecordChangeTracking.GetValue(columnValueItem)); else lfsMasterAreaRctExpandedRow.SetNotLinedYetNull();
                            break;
                        case "AllMeasured":
                            lfsMasterAreaRctExpandedRow.AllMeasured = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "City":
                            lfsMasterAreaRctExpandedRow.City = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "ProvState":
                            lfsMasterAreaRctExpandedRow.ProvState = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        default:
                            throw new Exception ("Invalid column in LFS_MASTER_AREA_RCT_EXPANDED.");
                    }
                }

                #endregion

                lfsMasterAreaRctExpandedRow.Operation = lfsMasterAreaRctRow.Operation;
                lfsMasterAreaRctExpandedRow.ChangedBy = lfsMasterAreaRctRow.ChangedBy;
                lfsMasterAreaRctExpandedRow.USERNAME = loginGateway.GetUsername(lfsMasterAreaRctRow.ChangedBy, companyId);
                lfsMasterAreaRctExpandedRow.Changed = lfsMasterAreaRctRow.Changed;

                //--- ... Make a copy of current record as previous record
                prevLfsMasterAreaRctExpandedRow = auxiliar.LFS_MASTER_AREA_RCT_EXPANDED.NewLFS_MASTER_AREA_RCT_EXPANDEDRow();

                for (int i = 0; i < result.LFS_MASTER_AREA_RCT_EXPANDED.Columns.Count; i++)
                {
                    if (result.LFS_MASTER_AREA_RCT_EXPANDED.Columns[i].ColumnName != "RctID")
                    {
                        prevLfsMasterAreaRctExpandedRow[i] = lfsMasterAreaRctExpandedRow[i];
                    }
                }

                //--- ... Add current record to result
                result.LFS_MASTER_AREA_RCT_EXPANDED.AddLFS_MASTER_AREA_RCT_EXPANDEDRow(lfsMasterAreaRctExpandedRow);
            }

            //--- Expand point repairs rct
            TDSLFSRecordForRCT.LFS_POINT_REPAIRS_RCT_EXPANDEDRow prevLfsPointRepairsRctExpandedRow = null;

            foreach(TDSLFSRecord.LFS_POINT_REPAIRS_RCTRow lfsPointRepairsRctRow in tdsLfsRecord.LFS_POINT_REPAIRS_RCT)
            {
                //--- ... Create current record
                TDSLFSRecordForRCT.LFS_POINT_REPAIRS_RCT_EXPANDEDRow lfsPointRepairsRctExpandedRow = result.LFS_POINT_REPAIRS_RCT_EXPANDED.NewLFS_POINT_REPAIRS_RCT_EXPANDEDRow();

                //--- ... Copy data from previous record to current record (if previous record exists)
                if ((prevLfsPointRepairsRctExpandedRow != null) && (prevLfsPointRepairsRctExpandedRow.RefID == lfsPointRepairsRctRow.RefID))
                {
                    for (int i = 0; i < result.LFS_POINT_REPAIRS_RCT_EXPANDED.Columns.Count; i++)
                    {
                        if (result.LFS_POINT_REPAIRS_RCT_EXPANDED.Columns[i].ColumnName != "RctID")
                        {
                            lfsPointRepairsRctExpandedRow[i] = prevLfsPointRepairsRctExpandedRow[i];
                        }
                    }
                }

                //--- ... Expand current record
                lfsPointRepairsRctExpandedRow.ID = lfsPointRepairsRctRow.ID;
                lfsPointRepairsRctExpandedRow.RefID = lfsPointRepairsRctRow.RefID;
                lfsPointRepairsRctExpandedRow.COMPANY_ID = lfsPointRepairsRctRow.COMPANY_ID;

                #region Expand changes

                foreach (string columnValueItem in RecordChangeTracking.Split(lfsPointRepairsRctRow.Changes))
                {
                    switch (RecordChangeTracking.GetColumnName(columnValueItem))
                    {
                        case "ID":
                            break;
                        case "RefID":
                            break;
                        case "COMPANY_ID":
                            break;
                        case "DetailID":
                            lfsPointRepairsRctExpandedRow.DetailID = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "RepairSize":
                            lfsPointRepairsRctExpandedRow.RepairSize = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "InstallDate":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsPointRepairsRctExpandedRow.InstallDate = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsPointRepairsRctExpandedRow.SetInstallDateNull();
                            break;
                        case "Distance":
                            lfsPointRepairsRctExpandedRow.Distance = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "Cost":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsPointRepairsRctExpandedRow.Cost = Convert.ToDecimal(RecordChangeTracking.GetValue(columnValueItem)); else lfsPointRepairsRctExpandedRow.SetCostNull();
                            break;
                        case "Reinstates":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsPointRepairsRctExpandedRow.Reinstates = Convert.ToInt32(RecordChangeTracking.GetValue(columnValueItem)); else lfsPointRepairsRctExpandedRow.SetReinstatesNull();
                            break;
                        case "LTAtMH":
                            lfsPointRepairsRctExpandedRow.LTAtMH = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "VTAtMH":
                            lfsPointRepairsRctExpandedRow.VTAtMH = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "LinerDistance":
                            lfsPointRepairsRctExpandedRow.LinerDistance = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "Direction":
                            lfsPointRepairsRctExpandedRow.Direction = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "MHShot":
                            lfsPointRepairsRctExpandedRow.MHShot = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "Comments":
                            lfsPointRepairsRctExpandedRow.Comments = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "Deleted":
                            lfsPointRepairsRctExpandedRow.Deleted = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "ExtraRepair":
                            lfsPointRepairsRctExpandedRow.ExtraRepair = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "Cancelled":
                            lfsPointRepairsRctExpandedRow.Cancelled = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "Approved":
                            lfsPointRepairsRctExpandedRow.Approved = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "NotApproved":
                            lfsPointRepairsRctExpandedRow.NotApproved = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "Archived":
                            lfsPointRepairsRctExpandedRow.Archived = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        default:
                            throw new Exception ("Invalid column in LFS_POINT_REPAIRS_RCT_EXPANDED.");
                    }
                }

                #endregion

                lfsPointRepairsRctExpandedRow.Operation = lfsPointRepairsRctRow.Operation;
                lfsPointRepairsRctExpandedRow.ChangedBy = lfsPointRepairsRctRow.ChangedBy;
                lfsPointRepairsRctExpandedRow.USERNAME = loginGateway.GetUsername(lfsPointRepairsRctRow.ChangedBy, companyId);
                lfsPointRepairsRctExpandedRow.Changed = lfsPointRepairsRctRow.Changed;

                //--- ... Make a copy of current record as previous record
                prevLfsPointRepairsRctExpandedRow = auxiliar.LFS_POINT_REPAIRS_RCT_EXPANDED.NewLFS_POINT_REPAIRS_RCT_EXPANDEDRow();

                for (int i = 0; i < result.LFS_POINT_REPAIRS_RCT_EXPANDED.Columns.Count; i++)
                {
                    if (result.LFS_POINT_REPAIRS_RCT_EXPANDED.Columns[i].ColumnName != "RctID")
                    {
                        prevLfsPointRepairsRctExpandedRow[i] = lfsPointRepairsRctExpandedRow[i];
                    }
                }

                //--- ... Add current record to result
                result.LFS_POINT_REPAIRS_RCT_EXPANDED.AddLFS_POINT_REPAIRS_RCT_EXPANDEDRow(lfsPointRepairsRctExpandedRow);
            }

            //--- Expand m2 tables rct
            TDSLFSRecordForRCT.LFS_M2_TABLES_RCT_EXPANDEDRow prevLfsM2TablesRctExpandedRow = null;

            foreach(TDSLFSRecord.LFS_M2_TABLES_RCTRow lfsM2TablesRctRow in tdsLfsRecord.LFS_M2_TABLES_RCT)
            {
                //--- ... Create current record
                TDSLFSRecordForRCT.LFS_M2_TABLES_RCT_EXPANDEDRow lfsM2TablesRctExpandedRow = result.LFS_M2_TABLES_RCT_EXPANDED.NewLFS_M2_TABLES_RCT_EXPANDEDRow();

                //--- ... Copy data from previous record to current record (if previous record exists)
                if ((prevLfsM2TablesRctExpandedRow != null) && (prevLfsM2TablesRctExpandedRow.RefID == lfsM2TablesRctRow.RefID))
                {
                    for (int i = 0; i < result.LFS_M2_TABLES_RCT_EXPANDED.Columns.Count; i++)
                    {
                        if (result.LFS_M2_TABLES_RCT_EXPANDED.Columns[i].ColumnName != "RctID")
                        {
                            lfsM2TablesRctExpandedRow[i] = prevLfsM2TablesRctExpandedRow[i];
                        }
                    }
                }

                //--- ... Expand current record
                lfsM2TablesRctExpandedRow.ID = lfsM2TablesRctRow.ID;
                lfsM2TablesRctExpandedRow.RefID = lfsM2TablesRctRow.RefID;
                lfsM2TablesRctExpandedRow.COMPANY_ID = lfsM2TablesRctRow.COMPANY_ID;

                #region Expand changes

                foreach (string columnValueItem in RecordChangeTracking.Split(lfsM2TablesRctRow.Changes))
                {
                    switch (RecordChangeTracking.GetColumnName(columnValueItem))
                    {
                        case "ID":
                            break;
                        case "RefID":
                            break;
                        case "COMPANY_ID":
                            break;
                        case "VideoDistance":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsM2TablesRctExpandedRow.VideoDistance = Convert.ToSingle(RecordChangeTracking.GetValue(columnValueItem)); else lfsM2TablesRctExpandedRow.SetVideoDistanceNull();
                            break;
                        case "ClockPosition":
                            lfsM2TablesRctExpandedRow.ClockPosition = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "LiveOrAbandoned":
                            lfsM2TablesRctExpandedRow.LiveOrAbandoned = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "DistanceToCentreOfLateral":
                            lfsM2TablesRctExpandedRow.DistanceToCentreOfLateral = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "LateralDiameter":
                            lfsM2TablesRctExpandedRow.LateralDiameter = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "LateralType":
                            lfsM2TablesRctExpandedRow.LateralType = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "DateTimeOpened":
                            lfsM2TablesRctExpandedRow.DateTimeOpened = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "Comments":
                            lfsM2TablesRctExpandedRow.Comments = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "ReverseSetup":
                            lfsM2TablesRctExpandedRow.ReverseSetup = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "Deleted":
                            lfsM2TablesRctExpandedRow.Deleted = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "Archived":
                            lfsM2TablesRctExpandedRow.Archived = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        default:
                            throw new Exception ("Invalid column in LFS_POINT_REPAIRS_RCT_EXPANDED.");
                    }
                }

                #endregion

                lfsM2TablesRctExpandedRow.Operation = lfsM2TablesRctRow.Operation;
                lfsM2TablesRctExpandedRow.ChangedBy = lfsM2TablesRctRow.ChangedBy;
                lfsM2TablesRctExpandedRow.USERNAME = loginGateway.GetUsername(lfsM2TablesRctRow.ChangedBy, companyId);
                lfsM2TablesRctExpandedRow.Changed = lfsM2TablesRctRow.Changed;

                //--- ... Make a copy of current record as previous record
                prevLfsM2TablesRctExpandedRow = auxiliar.LFS_M2_TABLES_RCT_EXPANDED.NewLFS_M2_TABLES_RCT_EXPANDEDRow();

                for (int i = 0; i < result.LFS_M2_TABLES_RCT_EXPANDED.Columns.Count; i++)
                {
                    if (result.LFS_M2_TABLES_RCT_EXPANDED.Columns[i].ColumnName != "RctID")
                    {
                        prevLfsM2TablesRctExpandedRow[i] = lfsM2TablesRctExpandedRow[i];
                    }
                }

                //--- ... Add current record to result
                result.LFS_M2_TABLES_RCT_EXPANDED.AddLFS_M2_TABLES_RCT_EXPANDEDRow(lfsM2TablesRctExpandedRow);
            }

            //--- Expand junction liners rct
            TDSLFSRecordForRCT.LFS_JUNCTION_LINER_RCT_EXPANDEDRow prevLfsJunctionLinerRctExpandedRow = null;

            foreach(TDSLFSRecord.LFS_JUNCTION_LINER_RCTRow lfsJunctionLinerRctRow in tdsLfsRecord.LFS_JUNCTION_LINER_RCT)
            {
                //--- ... Create current record
                TDSLFSRecordForRCT.LFS_JUNCTION_LINER_RCT_EXPANDEDRow lfsJunctionLinerRctExpandedRow = result.LFS_JUNCTION_LINER_RCT_EXPANDED.NewLFS_JUNCTION_LINER_RCT_EXPANDEDRow();

                //--- ... Copy data from previous record to current record (if previous record exists)
                if ((prevLfsJunctionLinerRctExpandedRow != null) && (prevLfsJunctionLinerRctExpandedRow.RefID == lfsJunctionLinerRctRow.RefID))
                {
                    for (int i = 0; i < result.LFS_JUNCTION_LINER_RCT_EXPANDED.Columns.Count; i++)
                    {
                        if (result.LFS_JUNCTION_LINER_RCT_EXPANDED.Columns[i].ColumnName != "RctID")
                        {
                            lfsJunctionLinerRctExpandedRow[i] = prevLfsJunctionLinerRctExpandedRow[i];
                        }
                    }
                }

                //--- ... Expand current record
                lfsJunctionLinerRctExpandedRow.ID = lfsJunctionLinerRctRow.ID;
                lfsJunctionLinerRctExpandedRow.RefID = lfsJunctionLinerRctRow.RefID;
                lfsJunctionLinerRctExpandedRow.COMPANY_ID = lfsJunctionLinerRctRow.COMPANY_ID;

                #region Expand changes

                foreach (string columnValueItem in RecordChangeTracking.Split(lfsJunctionLinerRctRow.Changes))
                {
                    switch (RecordChangeTracking.GetColumnName(columnValueItem))
                    {
                        case "ID":
                            break;
                        case "RefID":
                            break;
                        case "COMPANY_ID":
                            break;
                        case "DetailID":
                            lfsJunctionLinerRctExpandedRow.DetailID = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "MN":
                            lfsJunctionLinerRctExpandedRow.MN = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "DistanceFromUSMH":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsJunctionLinerRctExpandedRow.DistanceFromUSMH = Convert.ToDouble(RecordChangeTracking.GetValue(columnValueItem)); else lfsJunctionLinerRctExpandedRow.SetDistanceFromUSMHNull();
                            break;
                        case "ConfirmedLatSize":
                            lfsJunctionLinerRctExpandedRow.ConfirmedLatSize = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "LateralMaterial":
                            lfsJunctionLinerRctExpandedRow.LateralMaterial = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "SharedLateral":
                            lfsJunctionLinerRctExpandedRow.SharedLateral = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "CleanoutRequired":
                            lfsJunctionLinerRctExpandedRow.CleanoutRequired = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "PitRequired":
                            lfsJunctionLinerRctExpandedRow.PitRequired = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "MHShot":
                            lfsJunctionLinerRctExpandedRow.MHShot = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "MainConnection":
                            lfsJunctionLinerRctExpandedRow.MainConnection = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "Transition":
                            lfsJunctionLinerRctExpandedRow.Transition = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "CleanoutInstalled":
                            lfsJunctionLinerRctExpandedRow.CleanoutInstalled = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "PitInstalled":
                            lfsJunctionLinerRctExpandedRow.PitInstalled = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "CleanoutGrouted":
                            lfsJunctionLinerRctExpandedRow.CleanoutGrouted = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "CleanoutCored":
                            lfsJunctionLinerRctExpandedRow.CleanoutCored = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "PrepCompleted":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsJunctionLinerRctExpandedRow.PrepCompleted = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsJunctionLinerRctExpandedRow.SetPrepCompletedNull();
                            break;
                        case "MeasuredLatLength":
                            lfsJunctionLinerRctExpandedRow.MeasuredLatLength = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "MeasurementsTakenBy":
                            lfsJunctionLinerRctExpandedRow.MeasurementsTakenBy = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "LinerInstalled":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsJunctionLinerRctExpandedRow.LinerInstalled = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsJunctionLinerRctExpandedRow.SetLinerInstalledNull();
                            break;
                        case "FinalVideo":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsJunctionLinerRctExpandedRow.FinalVideo = Convert.ToDateTime(RecordChangeTracking.GetValue(columnValueItem)); else lfsJunctionLinerRctExpandedRow.SetFinalVideoNull();
                            break;
                        case "RestorationComplete":
                            lfsJunctionLinerRctExpandedRow.RestorationComplete = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "LinerOrdered":
                            lfsJunctionLinerRctExpandedRow.LinerOrdered = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "LinerInStock":
                            lfsJunctionLinerRctExpandedRow.LinerInStock = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "LinerPrice":
                            if (RecordChangeTracking.GetValue(columnValueItem) != "") lfsJunctionLinerRctExpandedRow.LinerPrice = Convert.ToDecimal(RecordChangeTracking.GetValue(columnValueItem)); else lfsJunctionLinerRctExpandedRow.SetLinerPriceNull();
                            break;
                        case "Comments":
                            lfsJunctionLinerRctExpandedRow.Comments = RecordChangeTracking.GetValue(columnValueItem);
                            break;
                        case "Deleted":
                            lfsJunctionLinerRctExpandedRow.Deleted = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        case "Archived":
                            lfsJunctionLinerRctExpandedRow.Deleted = Convert.ToBoolean(RecordChangeTracking.GetValue(columnValueItem));
                            break;
                        default:
                            throw new Exception ("Invalid column in LFS_JUNCTION_LINER_RCT_EXPANDED.");
                    }
                }

                #endregion

                lfsJunctionLinerRctExpandedRow.Operation = lfsJunctionLinerRctRow.Operation;
                lfsJunctionLinerRctExpandedRow.ChangedBy = lfsJunctionLinerRctRow.ChangedBy;
                lfsJunctionLinerRctExpandedRow.USERNAME = loginGateway.GetUsername(lfsJunctionLinerRctRow.ChangedBy, companyId);
                lfsJunctionLinerRctExpandedRow.Changed = lfsJunctionLinerRctRow.Changed;

                //--- ... Make a copy of current record as previous record
                prevLfsJunctionLinerRctExpandedRow = auxiliar.LFS_JUNCTION_LINER_RCT_EXPANDED.NewLFS_JUNCTION_LINER_RCT_EXPANDEDRow();

                for (int i = 0; i < result.LFS_JUNCTION_LINER_RCT_EXPANDED.Columns.Count; i++)
                {
                    if (result.LFS_JUNCTION_LINER_RCT_EXPANDED.Columns[i].ColumnName != "RctID")
                    {
                        prevLfsJunctionLinerRctExpandedRow[i] = lfsJunctionLinerRctExpandedRow[i];
                    }
                }

                //--- ... Add current record to result
                result.LFS_JUNCTION_LINER_RCT_EXPANDED.AddLFS_JUNCTION_LINER_RCT_EXPANDEDRow(lfsJunctionLinerRctExpandedRow);
            }

            return result;
        }
        /// ////////////////////////////////////////////////////////////////////////
        /// EVENTS
        ///
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                // Security check
                if (!Convert.ToBoolean(Session["sgLFS_APP_VIEW"]))
                {
                    Response.Redirect("./../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) && ((string)Request.QueryString["record_deleted"] == null))
                {
                    Response.Redirect("./../error_page.aspx?error=" + "Invalid query string in view_fulllength.aspx");
                }

                //... Prepare initial
                Session.Remove("pointRepairDummy");
                addRecordTDS = new AddRecordTDS();

                // If coming from navigator2.aspx or view_pointliner.aspx
                if (((string)Request.QueryString["source_page"] == "navigator2.aspx") || ((string)Request.QueryString["source_page"] == "view_pointliner.aspx"))
                {
                    int companyId = Convert.ToInt32(Session["companyID"]);
                    Guid id = (Guid)Session["lfsMasterAreaId"];

                    // Get lfs master area record
                    LFSRecordGateway lfsRecordGateway = new LFSRecordGateway();
                    tdsLfsRecord = lfsRecordGateway.GetRecordByIdCompanyId(id, companyId);

                    AddRecordPointRepairsGateway addRecordPointRepairsGateway = new AddRecordPointRepairsGateway(addRecordTDS);
                    addRecordPointRepairsGateway.LoadById(id, companyId);

                    //... Store datasets
                    Session["tdsLfsRecord"] = tdsLfsRecord;
                    Session["addRecordTDS"] = addRecordTDS;
                    pointRepairs = addRecordTDS.PointRepairs;
                    Session["pointRepairs"] = pointRepairs;
                }

                // If coming from delete_record.aspx
                if ((string)Request.QueryString["record_deleted"] == "false")
                {
                    //... Restore dataset lfs record
                    tdsLfsRecord = (TDSLFSRecord)Session["tdsLfsRecord"];
                    addRecordTDS = (AddRecordTDS)Session["addRecordTDS"];
                }

                // Prepare initial data for client
                CompaniesGateway companiesGateway = new CompaniesGateway();
                tbxCOMPANIES_ID.Text = companiesGateway.GetName((int)tdsLfsRecord.LFS_MASTER_AREA.Rows[0]["COMPANIES_ID"], Convert.ToInt32(Session["companyID"]));

                // Databind
                Page.DataBind();
            }
            else
            {
                // Restore dataset lfs record
                tdsLfsRecord = (TDSLFSRecord)Session["tdsLfsRecord"];
                addRecordTDS = (AddRecordTDS)Session["addRecordTDS"];
            }
        }
        /// ////////////////////////////////////////////////////////////////////////
        /// EVENTS
        ///
        //
        // Page_Load
        //
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                //--- Security check
                if (!Convert.ToBoolean(Session["sgLFS_APP_VIEW"]))
                {
                    Response.Redirect("./../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                //--- Restore dataset lfs record
                tdsLfsRecord = (TDSLFSRecord)Session["tdsLfsRecord"];

                //--- Prepare initial data
                hdfId.Value = Request.QueryString["id"].ToString();

                //--- ... for client
                CompaniesGateway companiesGateway = new CompaniesGateway();
                tbxCOMPANIES_ID.Text = companiesGateway.GetName((int)tdsLfsRecord.LFS_MASTER_AREA.Rows[0]["COMPANIES_ID"], Convert.ToInt32(Session["companyID"]));

                //--- ... for traffic control
                LFSTrafficControlGateway lfsTrafficControlGateway = new LFSTrafficControlGateway();
                DataSet dsLfsTrafficControl = lfsTrafficControlGateway.GetLFSTrafficControlForDropDownList("");

                ddlDegreeOfTrafficControl.DataSource = dsLfsTrafficControl;
                ddlDegreeOfTrafficControl.DataTextField = "TrafficControl";

                //--- Databind
                Page.DataBind();

                TDSLFSRecord.LFS_MASTER_AREARow lfsMasterAreaRow = tdsLfsRecord.LFS_MASTER_AREA.FindByIDCOMPANY_ID(new Guid(tbxID.Text), Convert.ToInt32(Session["companyID"]));
                ddlDegreeOfTrafficControl.SelectedValue = (lfsMasterAreaRow.IsDegreeOfTrafficControlNull()) ? "" : lfsMasterAreaRow.DegreeOfTrafficControl;
            }
            else
            {
                //--- Restore dataset lfs record
                tdsLfsRecord = (TDSLFSRecord)Session["tdsLfsRecord"];
            }
        }
        /// ////////////////////////////////////////////////////////////////////////
        /// EVENTS
        ///
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!Convert.ToBoolean(Session["sgLFS_APP_VIEW"]))
                {
                    Response.Redirect("./../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) && ((string)Request.QueryString["record_deleted"] == null))
                {
                    Response.Redirect("./../error_page.aspx?error=" + "Invalid query string in view_jlinersheet.aspx");
                }

                // Prepare initial data
                Session.Remove("jlinerDummy");
                lblMaxNumber.Visible = false;

                // If coming from navigator2.aspx or view_jlinersheet.aspx
                if (((string)Request.QueryString["source_page"] == "navigator2.aspx") || ((string)Request.QueryString["source_page"] == "view_jlinersheet.aspx"))
                {
                    //... Get lfs master area record
                    LFSRecordGateway lfsRecordGateway = new LFSRecordGateway();
                    viewJLinersheetTDS = new ViewJLinersheetTDS();

                    ViewJLinersheetJunctionLinerGateway viewJLinersheetJunctionLinerGateway = new ViewJLinersheetJunctionLinerGateway(viewJLinersheetTDS);
                    viewJLinersheetJunctionLinerGateway.LoadById((Guid)Session["lfsMasterAreaId"], Convert.ToInt32(Session["companyID"]));

                    tdsLfsRecord = lfsRecordGateway.GetRecordByIdCompanyId((Guid)Session["lfsMasterAreaId"], Convert.ToInt32(Session["companyID"]));

                    //... Store datasets
                    Session["tdsLfsRecord"] = tdsLfsRecord;
                    Session["viewJLinersheetTDS"] = viewJLinersheetTDS;
                    jliner = viewJLinersheetTDS.JunctionLiner;
                    Session["jliner"] = jliner;
                }

                // If coming from delete_record.aspx
                if ((string)Request.QueryString["record_deleted"] == "false")
                {
                    //... Restore dataset lfs record
                    tdsLfsRecord = (TDSLFSRecord)Session["tdsLfsRecord"];
                    viewJLinersheetTDS = (ViewJLinersheetTDS)Session["viewJLinersheetTDS"];
                }

                // ... for client
                CompaniesGateway companiesGateway = new CompaniesGateway();
                tbxCOMPANIES_ID.Text = companiesGateway.GetName((int)tdsLfsRecord.LFS_MASTER_AREA.Rows[0]["COMPANIES_ID"], Convert.ToInt32(Session["companyID"]));

                // Databind
                Page.DataBind();

                ddlMainLined.SelectedIndex = (tdsLfsRecord.LFS_MASTER_AREA[0].IsMainLinedNull()) ? 2 : ((tdsLfsRecord.LFS_MASTER_AREA[0].MainLined == "Yes") ? 0 : 1);
                ddlBenchingIssue.SelectedIndex = (tdsLfsRecord.LFS_MASTER_AREA[0].IsBenchingIssueNull()) ? 2 : ((tdsLfsRecord.LFS_MASTER_AREA[0].BenchingIssue == "Yes") ? 0 : 1);
            }
            else
            {
                //--- Restore dataset lfs record
                tdsLfsRecord = (TDSLFSRecord)Session["tdsLfsRecord"];
                viewJLinersheetTDS = (ViewJLinersheetTDS)Session["viewJLinersheetTDS"];
            }
        }