コード例 #1
0
        //RESULTS HANDLING ************************************************************************************
        private void PopulateResultsGrid()
        {
            try
            {
                //display metrics grid
                pnlMetrics.Visible = grdMetrics.Rows.Count > 0 || ddlEntryType.SelectedValue == "H" || ddlEntryType.SelectedValue == "T";

                //allow edit for some (last column)
                grdResults.Columns[grdResults.Columns.Count - 1].Visible = btnSave.Visible;

                //taxon counts display
                grdResults.Columns[2].Visible  = ddlEntryType.SelectedValue == "T";
                grdResults.Columns[14].Visible = ddlEntryType.SelectedValue == "T";
                grdResults.Columns[15].Visible = ddlEntryType.SelectedValue == "T";


                grdResults.ShowFooter = true;
                grdResults.DataSource = db_WQX.GetT_WQX_RESULT(Session["ActivityIDX"].ConvertOrDefault <int>());
                grdResults.DataBind();

                //if there is no data, then fill in an empty row and hide the footer (stupid work around)
                if (grdResults.Rows.Count == 0)
                {
                    List <T_WQX_RESULT> rows = new List <T_WQX_RESULT>();
                    T_WQX_RESULT        row  = new T_WQX_RESULT();
                    row.ACTIVITY_IDX    = Session["ActivityIDX"].ConvertOrDefault <int>();
                    row.CHAR_NAME       = "";
                    row.DETECTION_LIMIT = "";
                    row.RESULT_MSR      = "";
                    row.RESULT_MSR_UNIT = "";
                    rows.Add(row);

                    grdResults.ShowFooter = false;
                    grdResults.DataSource = rows;
                    grdResults.DataBind();
                }
            }
            catch
            {
                lblMsg.Text = "Error displaying results.";
            }
        }
コード例 #2
0
        //population of drop-downs for the currently selected row
        protected void grdResults_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow &&
                ((e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit))
            {
                //populate more modal
                Utils.BindList(ddlLabName, dsLabName, "LAB_IDX", "LAB_NAME");
                Utils.BindList(ddlPrepMethod, dsPrepMethod, "SAMP_PREP_IDX", "SAMP_PREP_METHOD_ID");

                T_WQX_RESULT r = db_WQX.GetT_WQX_RESULT_ByIDX(grdResults.DataKeys[e.Row.RowIndex].Values[0].ConvertOrDefault <int>());
                if (r != null)
                {
                    ddlLabName.SelectedValue    = r.LAB_IDX.ToStringNullSafe();
                    ddlPrepMethod.SelectedValue = r.LAB_SAMP_PREP_IDX.ToStringNullSafe();
                    txtPrepStartDate.Text       = r.LAB_SAMP_PREP_START_DT.ToStringNullSafe();
                    txtDilution.Text            = r.DILUTION_FACTOR.ToStringNullSafe();
                }

                //Characteristic
                DropDownList d1 = (DropDownList)e.Row.FindControl("ddlChar");
                dsChar.SelectParameters["RBPInd"].DefaultValue = (ddlEntryType.SelectedValue == "H" ? "true" : "false");
                PopulateDropDown(d1, dsChar, grdResults.DataKeys[e.Row.RowIndex].Values[1].ToString(), "CHAR_NAME", "CHAR_NAME");
                d1.Focus();

                //Taxa
                int col = GetColumnIndexByName(grdResults, "Taxonomy");
                if (grdResults.Columns[col].Visible)
                {
                    PopulateDropDown((DropDownList)e.Row.FindControl("ddlTaxa"), dsTaxa, grdResults.DataKeys[e.Row.RowIndex].Values[1].ToStringNullSafe(), "VALUE", "TEXT");
                }

                //Unit
                dsRefData.SelectParameters["tABLE"].DefaultValue = "MeasureUnit";
                PopulateDropDown((DropDownList)e.Row.FindControl("ddlUnit"), dsRefData, grdResults.DataKeys[e.Row.RowIndex].Values[2].ToStringNullSafe(), "VALUE", "VALUE");

                //Anal Method
                col = GetColumnIndexByName(grdResults, "Analytical Method");
                if (grdResults.Columns[col].Visible)
                {
                    PopulateDropDown((DropDownList)e.Row.FindControl("ddlAnalMethod"), dsAnalMethod, grdResults.DataKeys[e.Row.RowIndex].Values[3].ToStringNullSafe(), "ANALYTIC_METHOD_IDX", "AnalMethodDisplayName");
                }

                //Samp Fraction
                dsRefData.SelectParameters["tABLE"].DefaultValue = "ResultSampleFraction";
                PopulateDropDown((DropDownList)e.Row.FindControl("ddlSampFraction"), dsRefData, grdResults.DataKeys[e.Row.RowIndex].Values[4].ToStringNullSafe(), "VALUE", "VALUE");

                //value type
                dsRefData.SelectParameters["tABLE"].DefaultValue = "ResultValueType";
                PopulateDropDown((DropDownList)e.Row.FindControl("ddlResultValueType"), dsRefData, grdResults.DataKeys[e.Row.RowIndex].Values[5].ToStringNullSafe(), "VALUE", "VALUE");

                //result status
                dsRefData.SelectParameters["tABLE"].DefaultValue = "ResultStatus";
                PopulateDropDown((DropDownList)e.Row.FindControl("ddlResultStatus"), dsRefData, grdResults.DataKeys[e.Row.RowIndex].Values[6].ToStringNullSafe(), "VALUE", "VALUE");


                //Bio Intent
                col = GetColumnIndexByName(grdResults, "Biological Intent");
                if (grdResults.Columns[col].Visible)
                {
                    dsRefData.SelectParameters["tABLE"].DefaultValue = "BiologicalIntent";
                    PopulateDropDown((DropDownList)e.Row.FindControl("ddlBioIntent"), dsRefData, grdResults.DataKeys[e.Row.RowIndex].Values[7].ToStringNullSafe(), "VALUE", "VALUE");
                }


                //Bio Intent
                col = GetColumnIndexByName(grdResults, "Frequency Class");
                if (grdResults.Columns[col].Visible)
                {
                    dsRefData.SelectParameters["tABLE"].DefaultValue = "FrequencyClassDescriptor";
                    PopulateDropDown((DropDownList)e.Row.FindControl("ddlFreqClass"), dsRefData, grdResults.DataKeys[e.Row.RowIndex].Values[8].ToStringNullSafe(), "VALUE", "VALUE");
                }
            }

            if (e.Row.RowType == DataControlRowType.Footer)
            {
                //Characteristic
                dsChar.SelectParameters["RBPInd"].DefaultValue = (ddlEntryType.SelectedValue == "H" ? "true" : "false");
                PopulateDropDown((DropDownList)e.Row.FindControl("ddlNewChar"), dsChar, null, "CHAR_NAME", "CHAR_NAME");

                //Taxa
                int col = GetColumnIndexByName(grdResults, "Taxonomy");
                if (grdResults.Columns[col].Visible)
                {
                    PopulateDropDown((DropDownList)e.Row.FindControl("ddlNewTaxa"), dsTaxa, null, "VALUE", "TEXT");
                }

                //Unit
                dsRefData.SelectParameters["tABLE"].DefaultValue = "MeasureUnit";
                PopulateDropDown((DropDownList)e.Row.FindControl("ddlNewUnit"), dsRefData, null, "VALUE", "VALUE");

                //Anal Method
                PopulateDropDown((DropDownList)e.Row.FindControl("ddlNewAnalMethod"), dsAnalMethod, null, "ANALYTIC_METHOD_IDX", "AnalMethodDisplayName");

                //Samp Fraction
                dsRefData.SelectParameters["tABLE"].DefaultValue = "ResultSampleFraction";
                PopulateDropDown((DropDownList)e.Row.FindControl("ddlNewSampFraction"), dsRefData, null, "VALUE", "VALUE");

                //value type
                dsRefData.SelectParameters["tABLE"].DefaultValue = "ResultValueType";
                PopulateDropDown((DropDownList)e.Row.FindControl("ddlNewResultValueType"), dsRefData, null, "VALUE", "VALUE");

                //result status
                dsRefData.SelectParameters["tABLE"].DefaultValue = "ResultStatus";
                PopulateDropDown((DropDownList)e.Row.FindControl("ddlNewResultStatus"), dsRefData, null, "VALUE", "VALUE");


                //Bio Intent
                col = GetColumnIndexByName(grdResults, "Biological Intent");
                if (grdResults.Columns[col].Visible)
                {
                    dsRefData.SelectParameters["tABLE"].DefaultValue = "BiologicalIntent";
                    PopulateDropDown((DropDownList)e.Row.FindControl("ddlNewBioIntent"), dsRefData, null, "VALUE", "VALUE");
                }

                //Frequency Class
                col = GetColumnIndexByName(grdResults, "Frequency Class");
                if (grdResults.Columns[col].Visible)
                {
                    dsRefData.SelectParameters["tABLE"].DefaultValue = "FrequencyClassDescriptor";
                    PopulateDropDown((DropDownList)e.Row.FindControl("ddlNewFreqClass"), dsRefData, null, "VALUE", "VALUE");
                }
            }
        }