/// <summary>
        /// Get the PredictedObserved Details based on the Predicted Observed Id, and then call
        /// BindCurrentAcceptedValues, passing the requrid details
        /// </summary>
        /// <param name="variable"></param>
        /// <param name="predictedObservedId"></param>
        private void BindCurrentAcceptedChartAndValues(bool updateChart)
        {
            string variable            = ddlVariables.SelectedItem.Text;
            int    predictedObservedId = int.Parse(Convert.ToString(hfPredictedObservedID.Value));

            PredictedObservedDetail currPODetails = PredictedObservedDS.GetByPredictedObservedID(predictedObservedId);

            POValuesList = BindCurrentAcceptedValuesssssss(variable, currPODetails);

            POValuesDT            = Genfuncs.ToDataTable(POValuesList);
            Session["POValuesDT"] = POValuesDT;

            gvPOValues.DataSource = POValuesDT;
            gvPOValues.PageSize   = Convert.ToInt32(ddlPageSize.SelectedValue);

            gvPOValues.DataBind();

            UpdatePanel2.Update();

            if (updateChart == true)
            {
                BindCurrentAcceptedChart(variable, POValuesList);
                UpdatePanel4.Update();
            }
        }
        private void BindPredictedObservedTestsDiffs()
        {
            //lblTests.Text = "Tests for " + variable;
            //get the data to be displayed in the chart and grid
            int pullRequestId = int.Parse(hfPullRequestID.Value.ToString());

            POTestsList = PredictedObservedDS.GetCurrentAcceptedTestsDiffsSubset(pullRequestId);

            POTestsDT            = Genfuncs.ToDataTable(POTestsList);
            Session["POTestsDT"] = POTestsDT;
        }
        private void BindSimFilesGrid(int pullRequestId, DateTime runDate, int acceptPullRequestId, int PercentPassed)
        {
            //how many files are in the accepted Pull Request Set
            //what happens if they do not match
            lblMissing.Text       = string.Empty;
            hfPullRequestId.Value = pullRequestId.ToString();
            if (acceptPullRequestId > 0)
            {
                List <string> missingTables = ApsimFilesDS.GetMissingTables(pullRequestId, acceptPullRequestId);
                if (missingTables != null && missingTables.Count > 0)
                {
                    lblMissing.Text = "Missing FileName.TableName(s): " + string.Join(",", missingTables) + ".";
                }

                List <string> newTables = ApsimFilesDS.GetNewTables(pullRequestId, acceptPullRequestId);
                if (newTables != null && newTables.Count > 0)
                {
                    StringBuilder message = new StringBuilder();
                    message.AppendLine("New predicted/observed tables have been added by this pull request:");
                    message.AppendLine(string.Join(",", newTables));
                    lblNewFiles.Text = message.ToString();
                }
            }

            lblPullRequestId.Text = "Simulation Files for Pull Request Id: " + pullRequestId.ToString();
            if (PercentPassed == 100)
            {
                //btnDifferences.Visible = false;
                btnTestsCharts.Visible = true;
                btnTestsGrids.Visible  = true;
            }
            else
            {
                //btnDifferences.Visible = true;
                //btnDifferences.Text = "Pull Request " + pullRequestId.ToString() + " Tests - Differences ";

                btnTestsCharts.Visible = true;
                btnTestsCharts.Text    = "Pull Request " + pullRequestId.ToString() + " Tests - Graphical Results";
                btnTestsGrids.Visible  = true;
                btnTestsGrids.Text     = "Pull Request " + pullRequestId.ToString() + " Tests - Tabulated Results";
            }

            SimFilesList = ApsimFilesDS.GetSimFilesByPullRequestIDandDate(pullRequestId, runDate);
            SimFilesDT   = Genfuncs.ToDataTable(SimFilesList);

            Session["SimFilesDT"] = SimFilesDT;

            gvSimFiles.DataSource = SimFilesDT;
            gvSimFiles.DataBind();

            //ClientScript.RegisterStartupScript(this.GetType(), "CreateGridHeader", "<script>CreateGridHeader('GridDataDiv_SimFiles', 'ContentPlaceHolder1_gvSimFiles', 'GridHeaderDiv_SimFiles');</script>");
        }
        /// <summary>
        /// Retrieve the Tests data for the specified predicted observed id
        /// </summary>
        /// <param name="predictedObservedId"></param>
        private void BindCurrentAcceptedTests()
        {
            int predictedObservedId = int.Parse(hfPredictedObservedID.Value.ToString());

            POTestsList = PredictedObservedDS.GetCurrentAcceptedTestsSubset(predictedObservedId);

            POTestsDT            = Genfuncs.ToDataTable(POTestsList);
            Session["POTestsDT"] = POTestsDT;

            //if (gvPOTests.Rows.Count > 0)
            //{
            //    //NOTE:  This is registered using the ClientScript (not ScriptManager), with different parameters, as this grid is NOT in an update panel
            //    ClientScript.RegisterStartupScript(this.GetType(), "CreateGridHeader", "<script>CreateGridHeader('GridDataDiv_POTests', 'ContentPlaceHolder1_gvPOTests', 'GridHeaderDiv_POTests');</script>");
            //}
        }
        private void BindApsimFilesGrid()
        {
            ApsimFileList = ApsimFilesDS.GetPullRequestsWithStatus();
            ApsimFileDT   = Genfuncs.ToDataTable(ApsimFileList);

            Session["ApsimFileDT"]  = ApsimFileDT;
            gvApsimFiles.DataSource = ApsimFileDT;
            gvApsimFiles.DataBind();

            AcceptStatsLog acceptedPR = AcceptStatsLogDS.GetLatestAcceptedStatsLog();

            if (acceptedPR != null)
            {
                lblAcceptedDetails.Text   = string.Format("Current Accepted Stats are for Pull Request Id {0}, submitted by {1}, accepted on {2}.", acceptedPR.PullRequestId, acceptedPR.SubmitPerson, acceptedPR.LogAcceptDate.ToString("dd-MMM-yyyy HH:MM tt"));
                hfAcceptedFileCount.Value = acceptedPR.FileCount.ToString();
            }
        }
        private void BindSimFilesGrid(int pullRequestId)
        {
            lblMissing.Text       = string.Empty;
            hfPullRequestId.Value = pullRequestId.ToString();

            lblPullRequestId.Text = "Simulation Files for Pull Request Id: " + pullRequestId.ToString();

            //btnDifferences.Visible = true;
            //btnDifferences.Text = "Pull Request " + pullRequestId.ToString() + " Tests - Differences " ;

            btnTestsCharts.Visible = true;
            btnTestsCharts.Text    = "Pull Request " + pullRequestId.ToString() + " Tests - Graphical Results";
            btnTestsGrids.Visible  = true;
            btnTestsGrids.Text     = "Pull Request " + pullRequestId.ToString() + " Tests - Tabulated Results";

            SimFilesList = ApsimFilesDS.GetSimFilesByPullRequestID(pullRequestId);
            SimFilesDT   = Genfuncs.ToDataTable(SimFilesList);

            Session["SimFilesDT"] = SimFilesDT;
            gvSimFiles.DataSource = SimFilesDT;
            gvSimFiles.DataBind();

            //ClientScript.RegisterStartupScript(this.GetType(), "CreateGridHeader", "<script>CreateGridHeader('GridDataDiv_SimFiles', 'ContentPlaceHolder1_gvSimFiles', 'GridHeaderDiv_SimFiles');</script>");
        }