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

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_CWP_POINTREPAIRS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_CWP_POINTREPAIRS_DELETE"])))
                {
                    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["client_id"] == null) || ((string)Request.QueryString["project_id"] == null) || ((string)Request.QueryString["asset_id"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in pr_delete.aspx");
                }

                // Tag Page
                TagPage();

                // Prepare initial data
                // ... for client
                int companyId = Int32.Parse(hdfCompanyId.Value);
                int currentClientId = Int32.Parse(hdfCurrentClientId.Value.ToString());
                CompaniesGateway companiesGateway = new CompaniesGateway();
                companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId);

                // ... for project
                int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value.ToString());
                ProjectGateway projectGateway = new ProjectGateway();
                projectGateway.LoadByProjectId(currentProjectId);
                string name = projectGateway.GetName(currentProjectId);
                if (name.Length > 23) name = name.Substring(0, 20) + "...";
                lblTitleProjectName.Text = " > Project: " + name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ") > Selected Section";

                // If coming from
                // ... pr_navigator2.aspx
                if (Request.QueryString["source_page"] == "pr_navigator2.aspx")
                {
                    StoreNavigatorState();
                    ViewState["update"] = "no";

                    pointRepairsTDS = new PointRepairsTDS();

                    int workId = Int32.Parse(hdfWorkId.Value);
                    int assetId = Int32.Parse(hdfAssetId.Value);

                    PointRepairsSectionDetails pointRepairsSectionDetails = new PointRepairsSectionDetails(pointRepairsTDS);
                    pointRepairsSectionDetails.LoadByWorkId(workId, companyId);

                    PointRepairsWorkDetails pointRepairsWorkDetails = new PointRepairsWorkDetails(pointRepairsTDS);
                    pointRepairsWorkDetails.LoadByWorkIdAssetId(workId, assetId, companyId);

                    PointRepairsRepairDetails pointRepairsRepairDetails = new PointRepairsRepairDetails(pointRepairsTDS);
                    pointRepairsRepairDetails.LoadAllByWorkId(workId, companyId);

                    // Store dataset
                    Session["pointRepairsTDS"] = pointRepairsTDS;
                }

                // ... pr_summary.aspx
                if (Request.QueryString["source_page"] == "pr_summary.aspx")
                {
                    StoreNavigatorState();
                    ViewState["update"] = Request.QueryString["update"];

                    // Restore dataset
                    pointRepairsTDS = (PointRepairsTDS)Session["pointRepairsTDS"];
                }
            }
            else
            {
                // Restore datasets
                pointRepairsTDS = (PointRepairsTDS)Session["pointRepairsTDS"];
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_CWP_POINTREPAIRS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_CWP_POINTREPAIRS_EDIT"])))
                {
                    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["client_id"] == null) || ((string)Request.QueryString["project_id"] == null) ||  ((string)Request.QueryString["asset_id"] == null) || ((string)Request.QueryString["active_tab"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in pr_summary.aspx");
                }

                // Tag Page
                TagPage();

                // If coming from
                int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
                int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value.ToString());
                int assetId = Int32.Parse(hdfAssetId.Value.Trim());
                int workId = Int32.Parse(hdfWorkId.Value);

                Session.Remove("pointRepairsRepairsTempDummy");
                Session.Remove("pointRepairsCommentsTempDummy");

                // ... pr_navigator2.aspx
                if (Request.QueryString["source_page"] == "pr_navigator2.aspx")
                {
                    StoreNavigatorState();
                    ViewState["update"] = "no";

                    // ... Set initial tab
                    if ((string)Session["dialogOpenedPr"] != "1")
                    {
                        hdfActiveTab.Value = Request.QueryString["active_tab"];

                        pointRepairsTDS = new PointRepairsTDS();
                        pointRepairsRepairsTemp = new PointRepairsTDS.RepairDetailsDataTable();
                        pointRepairsCommentsTemp = new PointRepairsTDS.CommentDetailsDataTable();

                        PointRepairsSectionDetails pointRepairsSectionDetails = new PointRepairsSectionDetails(pointRepairsTDS);
                        pointRepairsSectionDetails.LoadByWorkId(workId, companyId);

                        PointRepairsWorkDetails pointRepairsWorkDetails = new PointRepairsWorkDetails(pointRepairsTDS);
                        pointRepairsWorkDetails.LoadByWorkIdAssetId(workId, assetId, companyId);

                        PointRepairsRepairDetails pointRepairsRepairDetails = new PointRepairsRepairDetails(pointRepairsTDS);
                        pointRepairsRepairDetails.LoadAllByWorkId(workId, companyId);

                        PointRepairsCommentDetails pointRepairsCommentDetails = new PointRepairsCommentDetails(pointRepairsTDS);
                        pointRepairsCommentDetails.LoadAllByWorkIdWorkType(workId, companyId, "Point Repairs");
                    }
                    else
                    {
                        hdfActiveTab.Value = (string)Session["activeTabPr"];

                        // Restore datasets
                        pointRepairsTDS = (PointRepairsTDS)Session["pointRepairsTDS"];
                        pointRepairsRepairsTemp = (PointRepairsTDS.RepairDetailsDataTable)Session["pointRepairsRepairsTemp"];
                        pointRepairsCommentsTemp = (PointRepairsTDS.CommentDetailsDataTable)Session["pointRepairsCommentsTemp"];
                    }

                    tcPrDetails.ActiveTabIndex = Int32.Parse(hdfActiveTab.Value);

                    Session["filterExpression"] = "Deleted = 0";

                    // Store dataset
                    Session["pointRepairsTDS"] = pointRepairsTDS;
                    Session["pointRepairsRepairsTemp"] = pointRepairsRepairsTemp;
                    Session["pointRepairsCommentsTemp"] = pointRepairsCommentsTemp;
                }

                // ... pr_delete.aspx or pr_edit.aspx
                if ((Request.QueryString["source_page"] == "pr_delete.aspx") || (Request.QueryString["source_page"] == "pr_edit.aspx"))
                {
                    StoreNavigatorState();
                    ViewState["update"] = Request.QueryString["update"];

                    // Restore dataset
                    pointRepairsTDS = (PointRepairsTDS)Session["pointRepairsTDS"];
                    pointRepairsRepairsTemp = (PointRepairsTDS.RepairDetailsDataTable)Session["pointRepairsRepairsTemp"];
                    pointRepairsCommentsTemp = (PointRepairsTDS.CommentDetailsDataTable)Session["pointRepairsCommentsTemp"];

                    // ... Set initial tab
                    if ((string)Session["dialogOpenedPr"] != "1")
                    {
                        hdfActiveTab.Value = Request.QueryString["active_tab"];
                    }
                    else
                    {
                        hdfActiveTab.Value = (string)Session["activeTabPr"];
                    }

                    tcPrDetails.ActiveTabIndex = Int32.Parse(hdfActiveTab.Value);

                    ApplyFilter();

                    switch ((string)Session["filterExpression"])
                    {
                        case "Deleted = 0":
                            ddlFilter.SelectedIndex = 0;
                            break;

                        case "Type='Robotic Reaming' AND Deleted = 0":
                            ddlFilter.SelectedIndex = 1;
                            break;

                        case "Type='Point Lining' AND Deleted = 0":
                            ddlFilter.SelectedIndex = 2;
                            break;

                        case "Type='Grouting' AND Deleted = 0":
                            ddlFilter.SelectedIndex = 3;
                            break;

                        default:
                            ddlFilter.SelectedIndex = 0;
                            break;
                    }
                }

                // Prepare initial data
                // ... for client
                int currentClientId = Int32.Parse(hdfCurrentClientId.Value.ToString());

                CompaniesGateway companiesGateway = new CompaniesGateway();
                companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId);

                // ... for project
                ProjectGateway projectGateway = new ProjectGateway();
                projectGateway.LoadByProjectId(currentProjectId);
                string name = projectGateway.GetName(currentProjectId);
                if (name.Length > 23) name = name.Substring(0, 20) + "...";
                lblTitleProjectName.Text = " > Project: " + name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ") > Selected Section";

                // ... Data for current point repairs work
                LoadPointRepairsData(currentProjectId, assetId, companyId);
            }
            else
            {
                // Restore datasets
                pointRepairsTDS = (PointRepairsTDS)Session["pointRepairsTDS"];
                pointRepairsRepairsTemp = (PointRepairsTDS.RepairDetailsDataTable)Session["pointRepairsRepairsTemp"];
                pointRepairsCommentsTemp = (PointRepairsTDS.CommentDetailsDataTable)Session["pointRepairsCommentsTemp"];

                // Set initial tab
                int activeTab = Int32.Parse(hdfActiveTab.Value);
                tcPrDetails.ActiveTabIndex = activeTab;

                ApplyFilter();
            }
        }
        private void UpdateDatabase()
        {
            // Get ids
            int workId = Int32.Parse(hdfWorkId.Value);
            int assetId = Int32.Parse(hdfAssetId.Value);
            int companyId = Int32.Parse(hdfCompanyId.Value);

            // Delete
            DB.Open();
            DB.BeginTransaction();
            try
            {
                PointRepairsWorkDetails pointRepairsWorkDetails = new PointRepairsWorkDetails(pointRepairsTDS);
                pointRepairsWorkDetails.DeleteDirect(workId, assetId, companyId);

                DB.CommitTransaction();
            }
            catch (Exception ex)
            {
                DB.RollbackTransaction();

                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }
        }
        private void Delete()
        {
            Page.Validate();

            if (Page.IsValid)
            {
                // Delete Point Repairs
                int workId = Int32.Parse(hdfWorkId.Value);

                PointRepairsSectionDetails pointRepairsSectionDetails = new PointRepairsSectionDetails(pointRepairsTDS);
                pointRepairsSectionDetails.Delete(workId);

                PointRepairsRepairDetails pointRepairsRepairDetails = new PointRepairsRepairDetails(pointRepairsTDS);
                pointRepairsRepairDetails.DeleteAll();

                PointRepairsWorkDetails pointRepairsWorkDetails = new PointRepairsWorkDetails(pointRepairsTDS);
                pointRepairsWorkDetails.Delete(workId);

                // Update database
                UpdateDatabase();

                // Store datasets
                Session["pointRepairsTDS"] = pointRepairsTDS;

                // Redirect
                string url = "";
                url = "./pr_navigator2.aspx?source_page=pr_delete.aspx&client_id=" + hdfCurrentClientId.Value + "&project_id=" + hdfCurrentProjectId.Value + GetNavigatorState() + "&update=yes";
                Response.Redirect(url);
            }
        }
        private void UpdateDatabase()
        {
            // Get ids & location
            int projectId = Int32.Parse(hdfCurrentProjectId.Value.Trim());
            ProjectGateway projectGateway = new ProjectGateway();
            projectGateway.LoadByProjectId(projectId);

            Int64 countryId = projectGateway.GetCountryID(projectId);
            Int64? provinceId = null; if (projectGateway.GetProvinceID(projectId).HasValue) provinceId = (Int64)projectGateway.GetProvinceID(projectId);
            Int64? countyId = null; if (projectGateway.GetCountyID(projectId).HasValue) countyId = (Int64)projectGateway.GetCountyID(projectId);
            Int64? cityId = null; if (projectGateway.GetCityID(projectId).HasValue) cityId = (Int64)projectGateway.GetCityID(projectId);

            string workType = hdfWorkType.Value.Trim();
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int workId = Int32.Parse(hdfWorkId.Value);
            int workIdFll = Int32.Parse(hdfWorkIdFll.Value);
            int sectionAssetId = Int32.Parse(hdfAssetId.Value);

            DB.Open();
            DB.BeginTransaction();
            try
            {
                // Save repair details
                PointRepairsRepairDetails pointRepairsRepairDetails = new PointRepairsRepairDetails(pointRepairsTDS);
                pointRepairsRepairDetails.Save(companyId);

                // Save comment details
                PointRepairsCommentDetails pointRepairsCommentDetails = new PointRepairsCommentDetails(pointRepairsTDS);
                pointRepairsCommentDetails.Save(companyId);

                // Save section details
                PointRepairsSectionDetails pointRepairsSectionDetails = new PointRepairsSectionDetails(pointRepairsTDS);
                pointRepairsSectionDetails.Save(countryId, provinceId, countyId, cityId, projectId, companyId);

                // Save work details
                PointRepairsWorkDetails pointRepairsWorkDetails = new PointRepairsWorkDetails(pointRepairsTDS);
                pointRepairsWorkDetails.Save(countryId, provinceId, countyId, cityId, projectId, sectionAssetId, companyId);

                DB.CommitTransaction();

                // Store datasets
                pointRepairsTDS.AcceptChanges();
                Session["pointRepairsTDS"] = pointRepairsTDS;
            }
            catch (Exception ex)
            {
                DB.RollbackTransaction();

                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }
        }
        private void Save()
        {
            // Validate data
            bool validData = true;

            validData = ValidatePage();

            if (validData)
            {
                // If the gridview is edition mode
                if (grdRepairs.EditIndex >= 0)
                {
                    grdRepairs.UpdateRow(grdRepairs.EditIndex, true);
                }

                GrdRepairsAdd();

                // Save data
                int companyId = Int32.Parse(hdfCompanyId.Value);
                int assetId = Int32.Parse(hdfAssetId.Value);
                int workId = Int32.Parse(hdfWorkId.Value);
                int workIdRa = Int32.Parse(hdfWorkIdRa.Value);
                int workIdFll = Int32.Parse(hdfWorkIdFll.Value);

                // Get Section Details
                string newStreet = ""; if (tbxStreet.Text != "") newStreet = tbxStreet.Text.Trim();
                string newUsmh = ""; if (tbxUSMH.Text != "") newUsmh = tbxUSMH.Text.Trim();
                string newUsmhAddress = ""; if (tbxUSMHMN.Text != "") newUsmhAddress = tbxUSMHMN.Text.Trim();
                string newDsmh = ""; if (tbxDSMH.Text != "") newDsmh = tbxDSMH.Text.Trim();
                string newDsmhAddress = ""; if (tbxDSMHMN.Text != "") newDsmhAddress = tbxDSMHMN.Text.Trim();
                string newMapSize = ""; if (tbxMapSize.Text != "") newMapSize = tbxMapSize.Text.Trim();
                string newSize = ""; if (tbxConfirmedSize.Text != "") newSize = tbxConfirmedSize.Text.Trim();
                string newMapLength = ""; if (tbxMapLength.Text != "") newMapLength = tbxMapLength.Text.Trim();
                string newSteelTapeThroughSewer = tbxSteelTapeLength.Text.Trim();
                string newVideoLength = ""; if (tbxVideoLength.Text != "") newVideoLength = tbxVideoLength.Text.Trim();
                int? newLaterals = null; if (tbxLaterals.Text != "") newLaterals = Int32.Parse(tbxLaterals.Text.Trim());
                int? newLiveLaterals = null; if (tbxLiveLaterals.Text != "") newLiveLaterals = Int32.Parse(tbxLiveLaterals.Text.Trim());
                string newSubArea = ""; if (tbxGeneralDataSubArea.Text != "") newSubArea = tbxGeneralDataSubArea.Text.Trim();

                // Update section details
                PointRepairsSectionDetails pointRepairsSectionDetails = new PointRepairsSectionDetails(pointRepairsTDS);
                pointRepairsSectionDetails.Update(workId, assetId, newStreet, newMapSize, newSize, newMapLength, newSteelTapeThroughSewer, newLaterals, newLiveLaterals, newSteelTapeThroughSewer, newUsmh, newDsmh, newUsmhAddress, newDsmhAddress, newSubArea);

                // Get Work Details
                string newGeneralClientId = ""; if (tbxGeneralDataClientId.Text != "") newGeneralClientId = tbxGeneralDataClientId.Text.Trim();
                string newMeasurementsTakenBy = ""; if (tbxGeneralDataMeasurementsTakenBy.Text != "") newMeasurementsTakenBy = tbxGeneralDataMeasurementsTakenBy.Text.Trim();
                DateTime? newRepairConfirmationDate = null; if (tkrdpGeneralDataRepairConfirmationDate.SelectedDate.HasValue) newRepairConfirmationDate = tkrdpGeneralDataRepairConfirmationDate.SelectedDate.Value;
                bool newByPassRequired = ckbxGeneralDataBypassRequired.Checked;
                string newRoboticDistances = ""; if (tbxGeneralDataRoboticDistances.Text != "") newRoboticDistances = tbxGeneralDataRoboticDistances.Text.Trim();
                DateTime? newGeneralProposedLiningDate = null; if (tkrdpGeneralDataProposedLiningDate.SelectedDate.HasValue) newGeneralProposedLiningDate = tkrdpGeneralDataProposedLiningDate.SelectedDate.Value;
                DateTime? newGeneralDeadlineLiningDate = null; if (tkrdpGeneralDataDeadlineLiningDate.SelectedDate.HasValue) newGeneralDeadlineLiningDate = tkrdpGeneralDataDeadlineLiningDate.SelectedDate.Value;
                DateTime? newGeneralFinalVideo = null; if (tkrdpGeneralDataFinalVideo.SelectedDate.HasValue) newGeneralFinalVideo = tkrdpGeneralDataFinalVideo.SelectedDate.Value;
                int? newEstimatedJoints = null; if (tbxGeneralDataEstimatedJoints.Text != "") newEstimatedJoints = Int32.Parse(tbxGeneralDataEstimatedJoints.Text.Trim());
                int? newJointsTestSealed = null; if (tbxGeneralDataJointsTestSealed.Text != "") newJointsTestSealed = Int32.Parse(tbxGeneralDataJointsTestSealed.Text.Trim());
                bool newGeneralIssueIdentified = ckbxGeneralDataIssueIdentified.Checked;
                bool newGeneralLfsIssue = ckbxGeneralDataLfsIssue.Checked;
                bool newGeneralClientIssue = ckbxGeneralDataClientIssue.Checked;
                bool newGeneralSalesIssue = ckbxGeneralDataSalesIssue.Checked;
                bool newGeneralIssueGivenToClient = ckbxGeneralDataIssueGivenToClient.Checked;
                bool newGeneralIssueResolved = ckbxGeneralDataIssueResolved.Checked;
                bool newGeneralIssueInvestigation = ckbxGeneralDataIssueInvestigation.Checked;

                // FLL
                // ... P1 Data
                DateTime? newPrepDataP1Date = null; if (tkrdpGeneralDataP1Date.SelectedDate.HasValue) newPrepDataP1Date = tkrdpGeneralDataP1Date.SelectedDate.Value;

                // ... Prep Data
                int? newPrepDataCXIsRemoved = null; if (tbxGeneralDataCXIsRemoved.Text != "") newPrepDataCXIsRemoved = Int32.Parse(tbxGeneralDataCXIsRemoved.Text.Trim());

                // ... M1 Data
                string newTrafficControl = ddlGeneralDataTrafficControl.SelectedValue;

                // RA
                // ... Rehab Assessment Data
                DateTime? newPreFlushDate = null; if (tkrdpGeneralDataPreFlushDate.SelectedDate.HasValue) newPreFlushDate = tkrdpGeneralDataPreFlushDate.SelectedDate.Value;
                DateTime? newPreVideoDate = null; if (tkrdpGeneralDataPreVideoDate.SelectedDate.HasValue) newPreVideoDate = tkrdpGeneralDataPreVideoDate.SelectedDate.Value;

                // Material
                string newMaterial = ddlGeneralDataMaterial.SelectedValue;

                // ... Update work details
                PointRepairsWorkDetails pointRepairsWorkDetails = new PointRepairsWorkDetails(pointRepairsTDS);
                pointRepairsWorkDetails.Update(workId, newGeneralClientId, newMeasurementsTakenBy, newRepairConfirmationDate, newByPassRequired, newRoboticDistances, newGeneralProposedLiningDate, newGeneralDeadlineLiningDate, newGeneralFinalVideo, newEstimatedJoints, newJointsTestSealed, newGeneralIssueIdentified, newGeneralLfsIssue, newGeneralClientIssue, newGeneralSalesIssue, newGeneralIssueGivenToClient, newGeneralIssueResolved, newGeneralIssueInvestigation, newPrepDataP1Date, newPrepDataCXIsRemoved, newTrafficControl, newMaterial, newVideoLength, newPreVideoDate, newPreFlushDate);

                // Store datasets
                Session["pointRepairsTDS"] = pointRepairsTDS;

                // Update database
                UpdateDatabase();

                ViewState["update"] = "yes";

                // Redirect
                string url = "";
                if (Request.QueryString["source_page"] == "pr_navigator2.aspx")
                {
                    url = "./pr_navigator2.aspx?source_page=pr_edit.aspx&client_id=" + hdfCurrentClientId.Value + "&project_id=" + hdfCurrentProjectId.Value + GetNavigatorState() + "&update=yes";
                }

                if (Request.QueryString["source_page"] == "pr_summary.aspx")
                {
                    string activeTab = hdfActiveTab.Value;
                    url = "./pr_summary.aspx?source_page=pr_edit.aspx&client_id=" + hdfCurrentClientId.Value + "&project_id=" + hdfCurrentProjectId.Value + "&asset_id=" + hdfAssetId.Value + "&active_tab=" + activeTab + GetNavigatorState() + "&update=yes";
                }

                Response.Redirect(url);
            }
        }
        private void Apply()
        {
            // Validate data
            bool validData = true;

            validData = ValidatePage();

            if (validData)
            {
                // Save data
                int companyId = Int32.Parse(hdfCompanyId.Value);
                int assetId = Int32.Parse(hdfAssetId.Value);
                int workId = Int32.Parse(hdfWorkId.Value);
                int workIdRa = Int32.Parse(hdfWorkIdRa.Value);
                int workIdFll = Int32.Parse(hdfWorkIdFll.Value);

                // Get Section Details
                string newStreet = ""; if (tbxStreet.Text != "") newStreet = tbxStreet.Text.Trim();
                string newUsmh = ""; if (tbxUSMH.Text != "") newUsmh = tbxUSMH.Text.Trim();
                string newUsmhAddress = ""; if (tbxUSMHMN.Text != "") newUsmhAddress = tbxUSMHMN.Text.Trim();
                string newDsmh = ""; if (tbxDSMH.Text != "") newDsmh = tbxDSMH.Text.Trim();
                string newDsmhAddress = ""; if (tbxDSMHMN.Text != "") newDsmhAddress = tbxDSMHMN.Text.Trim();
                string newMapSize = ""; if (tbxMapSize.Text != "") newMapSize = tbxMapSize.Text.Trim();
                string newSize = ""; if (tbxConfirmedSize.Text != "") newSize = tbxConfirmedSize.Text.Trim();
                string newMapLength = ""; if (tbxMapLength.Text != "") newMapLength = tbxMapLength.Text.Trim();
                string newSteelTapeThroughSewer = tbxSteelTapeLength.Text.Trim();
                string newVideoLength = ""; if (tbxVideoLength.Text != "") newVideoLength = tbxVideoLength.Text.Trim();
                int? newLaterals = null; if (tbxLaterals.Text != "") newLaterals = Int32.Parse(tbxLaterals.Text.Trim());
                int? newLiveLaterals = null; if (tbxLiveLaterals.Text != "") newLiveLaterals = Int32.Parse(tbxLiveLaterals.Text.Trim());
                string newSubArea = ""; if (tbxGeneralDataSubArea.Text != "") newSubArea = tbxGeneralDataSubArea.Text.Trim();

                // Update section details
                PointRepairsSectionDetails pointRepairsSectionDetails = new PointRepairsSectionDetails(pointRepairsTDS);
                pointRepairsSectionDetails.Update(workId, assetId, newStreet, newMapSize, newSize, newMapLength, newSteelTapeThroughSewer, newLaterals, newLiveLaterals, newSteelTapeThroughSewer, newUsmh, newDsmh, newUsmhAddress, newDsmhAddress, newSubArea);

                // Get Work Details
                string newGeneralClientId = ""; if (tbxGeneralDataClientId.Text != "") newGeneralClientId = tbxGeneralDataClientId.Text.Trim();
                string newMeasurementsTakenBy = ""; if (tbxGeneralDataMeasurementsTakenBy.Text != "") newMeasurementsTakenBy = tbxGeneralDataMeasurementsTakenBy.Text.Trim();
                DateTime? newRepairConfirmationDate = null; if (tkrdpGeneralDataRepairConfirmationDate.SelectedDate.HasValue) newRepairConfirmationDate = tkrdpGeneralDataRepairConfirmationDate.SelectedDate.Value;
                bool newByPassRequired = ckbxGeneralDataBypassRequired.Checked;
                string newRoboticDistances = ""; if (tbxGeneralDataRoboticDistances.Text != "") newRoboticDistances = tbxGeneralDataRoboticDistances.Text.Trim();
                DateTime? newGeneralProposedLiningDate = null; if (tkrdpGeneralDataProposedLiningDate.SelectedDate.HasValue) newGeneralProposedLiningDate = tkrdpGeneralDataProposedLiningDate.SelectedDate.Value;
                DateTime? newGeneralDeadlineLiningDate = null; if (tkrdpGeneralDataDeadlineLiningDate.SelectedDate.HasValue) newGeneralDeadlineLiningDate = tkrdpGeneralDataDeadlineLiningDate.SelectedDate.Value;
                DateTime? newGeneralFinalVideo = null; if (tkrdpGeneralDataFinalVideo.SelectedDate.HasValue) newGeneralFinalVideo = tkrdpGeneralDataFinalVideo.SelectedDate.Value;
                int? newEstimatedJoints = null; if (tbxGeneralDataEstimatedJoints.Text != "") newEstimatedJoints = Int32.Parse(tbxGeneralDataEstimatedJoints.Text.Trim());
                int? newJointsTestSealed = null; if (tbxGeneralDataJointsTestSealed.Text != "") newJointsTestSealed = Int32.Parse(tbxGeneralDataJointsTestSealed.Text.Trim());
                bool newGeneralIssueIdentified = ckbxGeneralDataIssueIdentified.Checked;
                bool newGeneralLfsIssue = ckbxGeneralDataLfsIssue.Checked;
                bool newGeneralClientIssue = ckbxGeneralDataClientIssue.Checked;
                bool newGeneralSalesIssue = ckbxGeneralDataSalesIssue.Checked;
                bool newGeneralIssueGivenToClient = ckbxGeneralDataIssueGivenToClient.Checked;
                bool newGeneralIssueResolved = ckbxGeneralDataIssueResolved.Checked;
                bool newGeneralIssueInvestigation = ckbxGeneralDataIssueInvestigation.Checked;

                // FLL
                // ... P1 Data
                DateTime? newPrepDataP1Date = null; if (tkrdpGeneralDataP1Date.SelectedDate.HasValue) newPrepDataP1Date = tkrdpGeneralDataP1Date.SelectedDate.Value;

                // ... Prep Data
                int? newPrepDataCXIsRemoved = null; if (tbxGeneralDataCXIsRemoved.Text != "") newPrepDataCXIsRemoved = Int32.Parse(tbxGeneralDataCXIsRemoved.Text.Trim());

                // ... M1 Data
                string newTrafficControl = ddlGeneralDataTrafficControl.SelectedValue;

                // RA
                // ... Rehab Assessment Data
                DateTime? newPreFlushDate = null; if (tkrdpGeneralDataPreFlushDate.SelectedDate.HasValue) newPreFlushDate = tkrdpGeneralDataPreFlushDate.SelectedDate.Value;
                DateTime? newPreVideoDate = null; if (tkrdpGeneralDataPreVideoDate.SelectedDate.HasValue) newPreVideoDate = tkrdpGeneralDataPreVideoDate.SelectedDate.Value;

                // Material
                string newMaterial = ddlGeneralDataMaterial.SelectedValue;

                // ... Update work details
                PointRepairsWorkDetails pointRepairsWorkDetails = new PointRepairsWorkDetails(pointRepairsTDS);
                pointRepairsWorkDetails.Update(workId, newGeneralClientId, newMeasurementsTakenBy, newRepairConfirmationDate, newByPassRequired, newRoboticDistances, newGeneralProposedLiningDate, newGeneralDeadlineLiningDate, newGeneralFinalVideo, newEstimatedJoints, newJointsTestSealed, newGeneralIssueIdentified, newGeneralLfsIssue, newGeneralClientIssue, newGeneralSalesIssue, newGeneralIssueGivenToClient, newGeneralIssueResolved, newGeneralIssueInvestigation, newPrepDataP1Date, newPrepDataCXIsRemoved, newTrafficControl, newMaterial, newVideoLength, newPreVideoDate, newPreFlushDate);

                // Store datasets
                Session["pointRepairsTDS"] = pointRepairsTDS;

                // Update database
                UpdateDatabase();

                ViewState["update"] = "yes";
            }
        }