protected void gridMeasCallback_OnCallback(object sender, EventArgs e) { Debug.Print(" $$ gridMeasCallback_OnCallback " + System.DateTime.Now.ToString()); RefreshSession_selmeas(); PivotSelMeas.DataSource = (DataTable)Session["proj_meas"]; //["tbl_selmeas"]; PivotSelMeas.DataBind(); PivotSelMeas.ReloadData(); var selmeas = gridSelMeas.GetSelectedFieldValues(gridSelMeas.KeyFieldName); selected_measlist = selmeas.ConvertAll(x => Convert.ToInt32(x)); int n_selmeas = selected_measlist.Count; selmeas_n2.Text = String.Format("({0} selected)", n_selmeas.ToString()); }
protected void Page_Load(object sender, EventArgs e) { Debug.Print("********************* Page_Load " + System.DateTime.Now.ToString() + " **************************"); if (!IsPostBack) { Debug.Print("--- is NOT Postback " + System.DateTime.Now.ToString()); PrintStatus(); InitializeSessionVars(); PrintStatus(); //Bind Subject Sets DataTable dtsets = uwac.trk.dataops.GetSubjSets(Master.Master_studyID); cboSubjSet.DataSource = dtsets; cboSubjSet.DataBind(); Session["subjsets"] = dtsets; //Bind the Measures DataTable dt = uwac.trk.dataops.GetAllStudymeas(Request.QueryString["pk"], Master.Master_studyIDfull); gridSelMeas.DataSource = dt; gridSelMeas.DataBind(); Session["meas"] = dt; //Bind the IntHx DataTable dtinthx = uwac.trk.dataops.GetAllIntHxTimept(Request.QueryString["pk"], Master.Master_studyIDfull); gridSelIntHx.DataSource = dtinthx; gridSelIntHx.DataBind(); Session["inthx"] = dtinthx; // Not a postback and there is a defined DataProject - preload the selected Measures and Variables if (Request.QueryString["pk"] != null) { lbl0.Text = "Edit Data Project"; lblPK.Text = "#" + Request.QueryString["pk"]; LoadDataproject_SelectedItems(Convert.ToInt32(Request.QueryString["pk"].ToString())); btnUpdate.Visible = true; btnNew.Visible = false; } else { //Always start fresh if it is not a PostBack and there is no pk Debug.Print(" **** Start Fresh - NO PK ****" + System.DateTime.Now.ToString()); lbl0.Text = "Create Data Project"; lblPK.Text = ""; btnUpdate.Visible = false; btnNew.Visible = true; txtTitle.Text = "** Enter Title Here **"; HtmlEditor.Html = "** Enter Summary Here ** <br/>** Then select:<br/> - set of subjects<br/> - measures<br/> - variables<br/><br/><i>Click the Full Screen button (upper right icon or F11) to expand this editor.</i>"; HtmlEditor.ActiveView = DevExpress.Web.ASPxHtmlEditor.HtmlEditorView.Design; } SetRowFilterMenuToContains(gridSelMeas); SetRowFilterMenuToContains(gridSelVars); } // IS PostBack else { Debug.Print("--- is Postback " + System.DateTime.Now.ToString()); PrintStatus(); if (Session["meas"] != null & Session["proj_meas"] == null) { gridSelMeas.DataSource = Session["meas"]; gridSelMeas.DataBind(); } if (Session["proj_subj"] != null) { PivotSelSubj.DataSource = Session["proj_subj"]; PivotSelSubj.DataBind(); } if (Session["subjsets"] != null) { //fix? cboSubjSet.DataSource = Session["subjsets"]; cboSubjSet.DataBind(); } if (Session["meas"] != null) { gridSelMeas.DataSource = Session["meas"]; gridSelMeas.DataBind(); } if (Session["proj_meas"] != null) { PivotSelMeas.DataSource = Session["proj_meas"]; PivotSelMeas.DataBind(); PivotSelMeas.Visible = true; } else { Debug.Print(" **** Not Binding VARS yet - no meas selected ****" + System.DateTime.Now.ToString()); Debug.Print(""); } if (Session["inthx"] != null & Session["proj_inthx"] != null) { gridSelIntHx.DataSource = Session["inthx"]; gridSelIntHx.DataBind(); PivotSelIntHx.DataSource = Session["proj_inthx"]; PivotSelIntHx.DataBind(); PivotSelIntHx.Visible = true; } if (Session["vars"] != null) { gridSelVars.DataSource = Session["vars"]; gridSelVars.DataBind(); } if (Session["proj_vars"] != null) { gridProjVars.DataSource = Session["proj_vars"]; gridProjVars.DataBind(); gridProjVars.Visible = true; } } int n_proj_subj = (Session["proj_subj"] != null) ? ((DataTable)Session["proj_subj"]).Rows.Count : 0; int n_proj_meas = (Session["proj_meas"] != null) ? ((DataTable)Session["proj_meas"]).Rows.Count : 0; int n_proj_vars = (Session["proj_vars"] != null) ? ((DataTable)Session["proj_vars"]).Rows.Count : 0; int n_proj_data = (Session["proj_data"] != null) ? ((DataTable)Session["proj_data"]).Rows.Count : 0; int n_proj_inthx = (Session["n_proj_inthx"] != null) ? ((DataTable)Session["n_proj_inthx"]).Rows.Count : 0; lblStatus.Text = String.Format("This project has {0} subjects, {1} measures, {2} vars saved.", n_proj_subj.ToString(), n_proj_meas.ToString(), n_proj_vars.ToString()); selsubj_n.Text = String.Format("({0} selected)", n_proj_subj); selmeas_n.Text = String.Format("({0} selected)", gridSelMeas.GetSelectedFieldValues("studymeasID").Count); selmeas_n2.Text = String.Format("({0} selected)", gridSelMeas.GetSelectedFieldValues("studymeasID").Count); selvars_n.Text = String.Format("({0} selected)", gridSelVars.GetSelectedFieldValues("fldpk").Count); selvars_n2.Text = String.Format("({0} selected)", gridSelVars.GetSelectedFieldValues("fldpk").Count); PivotSelSubj.Visible = (n_proj_subj > 0) ? true : false; PivotSelMeas.Visible = (gridSelMeas.GetSelectedFieldValues("studymeasID").Count > 0) ? true : false; gridProjVars.ClientVisible = (gridSelVars.GetSelectedFieldValues("fldpk").Count > 0) ? true : false; PivotSelIntHx.Visible = (gridSelIntHx.GetSelectedFieldValues("timept").Count > 0) ? true : false; PrintStatus(); Debug.Print(" --- Page_Load complete " + System.DateTime.Now.ToString()); }
protected void LoadDataproject_SelectedItems(int pk) { Debug.Print(" ***** LoadDataproject_SelectedItems" + System.DateTime.Now.ToString()); SQL_utils sql = new SQL_utils("data"); int studyID = sql.IntScalar_from_SQLstring("select studyID from dp.DataProject where dataproj_pk = " + pk.ToString()); if (Master.Master_studyID != studyID) { Master.Master_studyID = studyID; } DataTable dtProj = sql.DataTable_from_SQLstring("select * from dp.DataProject where dataproj_pk = " + pk.ToString()); lblTitle.Text = dtProj.Rows[0]["projTitle"].ToString(); txtTitle.Text = dtProj.Rows[0]["projTitle"].ToString(); HtmlEditor.Html = dtProj.Rows[0]["projSummary"].ToString(); #region Selected Subjects string subjset_pk_txt = dtProj.Rows[0]["subjset_pk"].ToString(); int selected_subjset_pk; bool result = Int32.TryParse(subjset_pk_txt, out selected_subjset_pk); if (result) { DataTable dts = uwac.trk.dataops.GetSelectedSubjects(selected_subjset_pk, Master.Master_studyID); cboSubjSet.SelectedItem = cboSubjSet.Items.FindByValue(selected_subjset_pk.ToString()); if (dts.Rows.Count > 0) { selected_subjlist = dts.AsEnumerable().Select(f => f.Field <int>("subjID")).ToList(); Session["selected_subjlist"] = selected_subjlist; Session["proj_subj"] = dts; PivotSelSubj.DataSource = Session["proj_subj"]; PivotSelSubj.DataBind(); selsubj_n.Text = String.Format("({0} selected)", dts.Rows.Count.ToString()); } } #endregion #region Selected Measures string sqlm = "select a.StudyMeasName, a.studymeasID, MeasName, a.measureID, Category, timepoint_text TimePt, tblname" + ", dbo.fnStudymeas_IsREL(studymeasID) as isREL " + " from uwautism_research_backend..vwStudyMeas a " + " left join def.tbl b ON a.measureID = b.measureID " + " where a.studymeasID in " + " (select studymeasID from dp.Meas where measureID not in (815,816,817,819) and dataproj_pk = " + pk.ToString() + ")"; DataTable dt_selm = sql.DataTable_from_SQLstring(sqlm); if (dt_selm.Rows.Count > 0) { selected_measlist = dt_selm.AsEnumerable().Select(f => f.Field <int>("studymeasID")).ToList(); Session["proj_meas"] = dt_selm; Session["selected_measlist"] = selected_measlist; PivotSelMeas.DataSource = Session["proj_meas"]; PivotSelMeas.DataBind(); PivotSelMeas.Visible = true; CheckSelectedMeas(selected_measlist); } else { PivotSelMeas.Visible = false; } #endregion #region Selected IntHx //string sqlih = "select measureID, measname, measfullname from uwautism_research_backend..tblmeasure where measureID in (815,816,817,819) " + // " and measureID in (select measureID from uwautism_research_data.dp.Meas where dataproj_pk = " + pk.ToString() + ")"; //DataTable dt_selih = sql.DataTable_from_SQLstring(sqlih); //if (dt_selih.Rows.Count > 0) //{ // selected_inthxlist = dt_selih.AsEnumerable().Select(f => f.Field<int>("measureID")).ToList(); // Session["proj_inthx"] = dt_selih; // Session["selected_inthxlist"] = selected_inthxlist; // PivotSelIntHx.DataSource = Session["proj_inthx"]; // PivotSelIntHx.DataBind(); // PivotSelIntHx.Visible = true; // //TOFIX CheckSelectedIntHx(selected_inthxlist); //} //else //{ // PivotSelIntHx.Visible = false; //} string sqlih = String.Format("select string as timept from dbo.UDF_CSVToTable((select inthx_timepts from dp.dataproject where dataproj_pk = {0}), ',') order by 1", pk.ToString()); DataTable dt_selih = sql.DataTable_from_SQLstring(sqlih); if (dt_selih.Rows.Count > 0) { selected_inthxlist = dt_selih.AsEnumerable().Select(f => f.Field <string>("timept")).ToList(); Session["proj_inthx"] = dt_selih; Session["selected_inthxlist"] = selected_inthxlist; PivotSelIntHx.DataSource = Session["proj_inthx"]; PivotSelIntHx.DataBind(); PivotSelIntHx.Visible = true; CheckSelectedIntHx(selected_inthxlist); } else { PivotSelIntHx.Visible = false; } #endregion #region Selected Variables //Gets the vars for all the measures saved in this project, the "inDataproj" field has the fldpk for those that are selected var x = selected_measlist.ConvertAll(n => n.ToString()); string smID_csv = String.Join(",", x); bool include_inthx_vars = (dt_selih.Rows.Count > 0) ? true : false; DataTable dtv = uwac.trk.dataops.GetVarsForDataproject(pk, smID_csv, include_inthx_vars); if (dtv.Rows.Count > 0) { Session["vars"] = dtv; selected_varslist = dtv.AsEnumerable().Select(f => f.Field <int>("inDataproj")).ToList(); Session["selected_varslist"] = selected_varslist; DataView vw = dtv.AsDataView(); vw.RowFilter = "inDataproj > 0"; DataTable dtv_selvars = vw.ToTable(); // Here, since we are just loading the saved info from the DB we load the saved vars // Later, // when the selected measures change we change Session["vars"] -> which is bound to gridSelVars // when the selected vars change we change Session["proj_vars"] -> which is bound to gridProjVars gridSelVars.DataSource = Session["vars"]; gridSelVars.DataBind(); //Actually select these in the grid CheckSelectedVars(selected_varslist); Session["proj_vars"] = dtv_selvars; gridProjVars.DataSource = Session["proj_vars"]; gridProjVars.DataBind(); } #endregion #region Composite Variables //DataTable dtcv = uwac.trk.dataops.GetCompvarsForDataproject(pk); //gridCompvar.DataSource = dtcv; //gridCompvar.DataBind(); #endregion sql.Close(); }