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";
            }
        }