private void LoadAndBindStudentCredentails() { var s = (Thinkgate.Base.Classes.Student)Tile.TileParms.GetParm("student"); if (s == null) return; drGeneric_String drStringObj = new drGeneric_String(); drStringObj.Add("0"); DataSet ds = Base.Classes.Credentials.GetCredentialsForStudent(s.ID, StudentCredentialsView.Summary, drStringObj); DataTable dtCredential = new DataTable(); if (ds != null && ds.Tables.Count > 0) { dtCredential = ds.Tables[0]; } studentCredentialGrid.DataSource = dtCredential; studentCredentialGrid.DataBind(); }
/// <summary> /// Builds the QuestionSearchCriteria. Used both from Search Button and from Service /// </summary> public static AddendumSearchCriteriaV2 BuildSearchCriteriaObject(ThinkgateUser user, CriteriaController criteriaController, string requestedSortField = null) { /* Sort */ string sortField = null; NameValue nvSortField = SortFields().Find(x => x.Name == requestedSortField); // ensure that the user given value for sort is in the defined list of options if (nvSortField != null) sortField = nvSortField.Value; /* Item Banks - Remove from master list based on filter if given */ var itemBanks = ItemBankMasterList.GetItemBanksForUser(user); if (TestCategory != null && TestCategory == AssessmentCategories.District.ToString()) { for (var rowIndex = itemBanks.Rows.Count - 1; rowIndex >= 0; rowIndex--) { if (itemBanks.Rows[rowIndex]["Label"].ToString() == "Personal") { itemBanks.Rows[rowIndex].Delete(); } } } var selectedItemBanks = criteriaController.ParseCriteria<CheckBoxList.ValueObject>("ItemBank").Select(x => x.Text); if (selectedItemBanks.Any()) itemBanks.DeleteByLabel(selectedItemBanks); /* Text Search */ string searchText = string.Empty; string searchOption = string.Empty; var txtSearchList = criteriaController.ParseCriteria<TextWithDropdown.ValueObject>("TextSearch"); if (txtSearchList.Count > 0) { // we ensure that the value the user gave us for text search type is a valid option var confirmedOption = TextSearchDropdownValues().Find(x => x.Name == txtSearchList[0].Option) ?? TextSearchDropdownValues().First(); if (!String.IsNullOrEmpty(txtSearchList[0].Text)) { searchText = txtSearchList[0].Text; searchOption = confirmedOption.Value; } } /* Courses */ var selectedGrades = criteriaController.ParseCriteria<CheckBoxList.ValueObject>("Grade").Select(x => x.Text).ToList(); var selectedSubjects = criteriaController.ParseCriteria<CheckBoxList.ValueObject>("Subject").Select(x => x.Text).ToList(); var selectedCourses = criteriaController.ParseCriteria<CheckBoxList.ValueObject>("Course").Select(x => x.Text).ToList(); var selectedStandardSets = new drGeneric_String(criteriaController.ParseCriteria<CheckBoxList.ValueObject>("StandardSet").Select(x => x.Text)); // take straight to drGeneric_String because it's going to SQL var filteredCourses = CourseMasterList.GetStandardCoursesForUser(user).FilterByGradesSubjectsStandardSetsAndCourse(selectedGrades, selectedSubjects, selectedStandardSets, selectedCourses); /* Type/Genre */ var selectedAddendumGenres = new drGeneric_String(); var selectedAddendumTypes = new drGeneric_String(); var selectedTypesGenres = criteriaController.ParseCriteria<AddendumType.ValueObject>("AddendumType"); foreach (var selectedTypesGenre in selectedTypesGenres) { if (selectedTypesGenre.Genre != null) { selectedAddendumGenres.Add(selectedTypesGenre.Genre); } else { selectedAddendumTypes.Add(selectedTypesGenre.Text); } } if (selectedAddendumGenres.Count > 0) selectedAddendumTypes.Add("Passage"); var selectedExpirationStatus = criteriaController.ParseCriteria<DropDownList.ValueObject>("ExpirationStatus").FirstOrDefault() != null ? criteriaController.ParseCriteria<DropDownList.ValueObject>("ExpirationStatus").FirstOrDefault().Value : "I"; if (!ShowExpiredItems) { selectedExpirationStatus = "E"; } drGeneric_String_String selectedExpirationDateRange = new drGeneric_String_String(); foreach (var val in criteriaController.ParseCriteria<DateRange.ValueObject>("ExpirationDateRange")) { selectedExpirationDateRange.Add(val.Type == "Start" ? "CreatedDateStart" : "CreatedDateEnd", val.Date); } /* Build Criteria Object */ var asc = new AddendumSearchCriteriaV2() { ItemBanks = itemBanks, CourseList = filteredCourses, AddendumType = selectedAddendumTypes, AddendumGenre = selectedAddendumGenres, UserAccessItemReservations = "", Text = searchText, TextOpt = searchOption, SortKeyword = sortField, courseSelected = selectedCourses.Count > 0 ? true : false, ExpirationStatus = selectedExpirationStatus, ExpirationDateRange = selectedExpirationDateRange }; return asc; }
/// <summary> /// GetListOfStandards - Get string back of standard Id's to be used as a list. /// </summary> /// <param name="selectedStandards"></param> /// <returns>string</returns> private string GetListOfStandards(StandardSelections selectedStandards) { string stringListOfStandards = selectedStandards.Key; if (!stringListOfStandards.IsInt() && !string.IsNullOrEmpty(selectedStandards.StandardSet)) { var standardSetList = new drGeneric_String(); if (!String.IsNullOrEmpty(selectedStandards.StandardSet)) { standardSetList.Add(selectedStandards.StandardSet.Trim()); } var gradeList = new drGeneric_String(); if (!String.IsNullOrEmpty(selectedStandards.Grade)) { gradeList.Add(selectedStandards.Grade.Trim()); } var subjectList = new drGeneric_String(); if (!String.IsNullOrEmpty(selectedStandards.Subject)) { subjectList.Add(selectedStandards.Subject.Trim()); } var courseList = new drGeneric_String(); if (!String.IsNullOrEmpty(selectedStandards.Course)) { courseList.Add(selectedStandards.Course.Trim()); } DataTable filteredStandards = Base.Classes.Standards.SearchStandards(false, "", //TextSearch "", //TextSearchVal null, //itemBanks null, //StandardCourses null, standardSetList.Count > 0 ? standardSetList : null, gradeList.Count > 0 ? gradeList : null, subjectList.Count > 0 ? subjectList : null, courseList.Count > 0 ? courseList : null); List<object> listOfStandards = (from lststd in filteredStandards.DataSet.Tables[0].AsEnumerable() select lststd["StandardID"]).ToList(); stringListOfStandards = string.Join(",", listOfStandards); if (stringListOfStandards == "") stringListOfStandards = "0"; } return stringListOfStandards; }
private void BindPageControls() { List<string> selectedAlignments = GetSelectedNodeWithChildren(); DataSet ds = new DataSet(); bool flagFetchFreshData = true; if (Session["dsCredentials"] != null) { ds = (DataSet)Session["dsCredentials"]; try { if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { flagFetchFreshData = false; } } catch (Exception ex) { flagFetchFreshData = true; } } if (flagFetchFreshData) { drGeneric_String drStringObj = new drGeneric_String(); foreach (string str in selectedAlignments) { drStringObj.Add(str); } //include drStringObj in future ds = Base.Classes.Credentials.GetCredentials("ALL", "DETAIL"); Session["dsCredentials"] = ds; } if (ds != null && ds.Tables.Count == 4) { ds.Relations.Clear(); ds.Relations.Add(new DataRelation("CredentialUrls", ds.Tables[0].Columns["ID"], ds.Tables[3].Columns["CredentialId"], false)); ds.Relations.Add(new DataRelation("CredentialAlignments", ds.Tables[0].Columns["ID"], ds.Tables[2].Columns["CredentialId"], false)); ds.Relations.Add(new DataRelation("CredentialAlignmentsMaster", ds.Tables[2].Columns["AlignmentId"], ds.Tables[1].Columns["ID"], false)); List<int> iAlign = new List<int>(); if (!this.IsPostBack) { ds.Tables[0].DefaultView.RowFilter = ddlEarned.SelectedIndex == 0 ? "IsActive = true" : "IsActive= false"; gridCredentials.DataSource = ds.Tables[0].DefaultView; gridCredentials.DataBind(); } else { string filter = string.Empty; if (selectedAlignments.Count > 0 && selectedAlignments[0] == "0") { filter = ddlEarned.SelectedIndex == 0 ? "IsActive = true" : "IsActive= false"; } else { if (selectedAlignments.Count > 0) { ds.Tables[2].DefaultView.RowFilter = "AlignmentId in (" + string.Join(",", selectedAlignments.ToArray()) + ")"; foreach (DataRow dr in ds.Tables[2].DefaultView.ToTable().Rows) { iAlign.Add(Convert.ToInt32(dr["CredentialId"])); } if (iAlign.Count == 0) { iAlign.Add(0); } } string status = ddlEarned.SelectedIndex == 0 ? "IsActive = true" : "IsActive= false"; if (iAlign.Count > 0) filter = status + " AND ID in (" + string.Join(",", iAlign.ToArray()) + ")"; else filter = status; } ds.Tables[0].DefaultView.RowFilter = filter; gridCredentials.DataSource = ds.Tables[0].DefaultView; gridCredentials.DataBind(); } } BindAlignmentsTree(); System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "SetControlCSS", "setControlCSS();", true); }
private void BindPageControls() { lblStudentName.Text = _selectedStudent.StudentName; lblStudentName.Attributes.Add("initialValue", lblStudentName.Text); List<string> selectedAlignments = GetSelectedNodeWithChildren(); DataSet ds = new DataSet(); bool flagFetchFreshData = true; if (Session["dsStudentCredentials"] != null) { ds = (DataSet)Session["dsStudentCredentials"]; try { if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0]["StudentId"]) == GetDecryptedEntityId(X_ID)) { flagFetchFreshData = false; } } catch (Exception ex) { flagFetchFreshData = true; } } if (flagFetchFreshData) { drGeneric_String drStringObj = new drGeneric_String(); foreach (string str in selectedAlignments) { drStringObj.Add(str); } ds = Base.Classes.Credentials.GetCredentialsForStudent(_selectedStudent.ID, StudentCredentialsView.Detail, drStringObj); Session["dsStudentCredentials"] = ds; } if (ds != null) { if (ds.Tables.Count > 2) { ds.Relations.Clear(); ds.Relations.Add(new DataRelation("CredentialUrls", ds.Tables[0].Columns["CredentialID"], ds.Tables[2].Columns["CredentialID"], false)); } if (ds.Tables.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { DataSet dsComment = GetStudentComments(_selectedStudent.ID.ToString() + "_" + dr["CredentialID"].ToString(), Convert.ToInt32(Convert.IsDBNull(dr["ID"]) ? 0 : dr["ID"]), _selectedStudent.ID, Convert.ToInt32(dr["CredentialID"])); if (dsComment != null && dsComment.Tables.Count > 1) { dr["CommentsCount"] = dsComment.Tables[1].Rows.Count; } } ds.Tables[0].DefaultView.RowFilter = ddlEarned.SelectedIndex == 1 ? "Earned = 1" : "1=1"; gridStudentCredentials.DataSource = ds.Tables[0]; gridStudentCredentials.DataBind(); } if (ds.Tables.Count > 1 && ds.Tables[1].Rows.Count > 0 /*There should always be 1 row containing credentials count*/) { lblCredentialsEarned.Text = ds.Tables[1].Rows[0]["CredentialsCount"].ToString(); } } if (SessionObject.IsAlignmentDataAvailable == null) { SessionObject.IsAlignmentDataAvailable = Base.Classes.Credentials.IsAlignmentDataAvailable(); } if (SessionObject.IsAlignmentDataAvailable == true) { ddlAlignments.Visible = true; BindAlignmentsTree(); } else { ddlAlignments.Visible = false; } System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "RefreshCommentLink", "commentLinkEnable();", true); }