protected void rgSchoolPricingModulesForEditing_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { int schoolID = DataIntegrity.ConvertToInt(Request.QueryString["ID"]); if (schoolID == 0) return; DataTable allPricingModules = ThinkgatePricingModule.GetAllPricingModuleIdsAndNames(); ThinkgateSchool school = new ThinkgateSchool(schoolID, true); lblHeaderItemID.Text = school.Id.ToString(); lblHeaderItemName.Text = String.Format("Pricing Modules in {0} School:", school.Name); rgSchoolPricingModulesForEditing.DataSource = ConvertToSchoolPricingModulesBindingTable(allPricingModules, school); }
protected void rgSchoolPricingModulesForEditing_UpdateCommand(Object source, GridCommandEventArgs e) { var editedItem = e.Item as GridEditableItem; if (editedItem == null) return; int newSchoolID = DataIntegrity.ConvertToInt(lblHeaderItemID.Text); if (newSchoolID == default(int)) return; ThinkgateSchool school = new ThinkgateSchool(newSchoolID, true); if (String.IsNullOrEmpty(school.Name)) return; //Get the new values: var newValues = new Hashtable(); e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem); int pricingModuleID = DataIntegrity.ConvertToInt(editedItem.GetDataKeyValue("ID").ToString()); if (pricingModuleID == default(int)) return; bool hasPermission = newValues["Member"] != null && DataIntegrity.ConvertToBool(newValues["Member"]); ThinkgatePricingModule pricingModule = new ThinkgatePricingModule(pricingModuleID); if (hasPermission) { school.PricingModules.Add(pricingModule); SessionObject sessionObject = (SessionObject)Session["SessionObject"]; ThinkgateUser user = sessionObject.LoggedInUser; school.UpdateSchoolPricingModules(pricingModuleID, user.UserName); lblResultMessage.Text = string.Format("Pricing Module {0} was added to School {1}.", pricingModule.Name, school.Name); } else { school.PricingModules.Remove(pricingModule); school.DeleteSchoolPricingModules(pricingModuleID); lblResultMessage.Text = string.Format("Pricing Module {0} was revoked from School {1}.", pricingModule.Name, school.Name); } }
protected DataTable ConvertToSchoolPricingModulesBindingTable(DataTable pricingModules, ThinkgateSchool school) { pricingModules.Columns.Add(new DataColumn("Member", typeof(bool))); pricingModules.Columns.Add(new DataColumn("Description", typeof(string))); foreach (DataRow row in pricingModules.Rows) { row["Member"] = school.ContainsPricingModule(DataIntegrity.ConvertToInt(row["ID"].ToString())); } return pricingModules; }
protected void BuildGrades() { if (_gradeVisible) { List<Grade> grades = null; // We only want the grades for this school. if (_level == EntityTypes.School) { ThinkgateSchool school = new ThinkgateSchool(_levelID, false); grades = CourseMasterList.GradesForSchoolsDict[_levelID]; //If the school type is not high school then remove high school grades from the dropdown. //MKR 07/30/2012 - We need to uncomment this but didn't want this to go to Sarasota yet. /*if (school.SchoolType == "Middle" || school.SchoolType == "Elementary") { grades.RemoveAll(g => g.ToString().Equals("9_12") || g.ToString().Equals("09") || g.ToString().Equals("10") || g.ToString().Equals("11") || g.ToString().Equals("12")); }*/ } // All grades for district. else if (_level == EntityTypes.District) grades = (from c in CourseMasterList.ClassCourseDict.Values select c.Grade).Distinct().ToList(); if(grades == null) return; DataTable dtGrade = new DataTable(); DataColumn gradeCol = dtGrade.Columns.Add("Grade", typeof(String)); // Add the grade names to the data table (making sure that they are unique). IEnumerable<String> gradeNames = (from g in grades select g.DisplayText).Distinct(); // Sort the grades. gradeNames = gradeNames.OrderBy(n => n, new GradeDisplayTextComparer()); foreach (String gradeName in gradeNames) { DataRow row = dtGrade.NewRow(); row["Grade"] = gradeName; dtGrade.Rows.Add(row); } // The only existing column is 'Grade'. We must add a column for 'CmbText'. dtGrade.Columns.Add("CmbText", typeof(String)); foreach (DataRow row in dtGrade.Rows) row["CmbText"] = row["Grade"]; DataRow newRow = dtGrade.NewRow(); newRow["Grade"] = "All"; newRow["CmbText"] = "Grade"; dtGrade.Rows.InsertAt(newRow, 0); // Data bind the combo box. cmbGrade.DataTextField = "CmbText"; cmbGrade.DataValueField = "Grade"; cmbGrade.DataSource = dtGrade; cmbGrade.DataBind(); // Initialize the current selection. RadComboBoxItem item = cmbGrade.Items.FindItemByValue((String)ViewState[_gradeFilterKey], true); Int32 selIdx = cmbGrade.Items.IndexOf(item); cmbGrade.SelectedIndex = selIdx; } }
protected void rgSchools_UpdateCommand(Object source, GridCommandEventArgs e) { var editedItem = e.Item as GridEditableItem; if (editedItem == null) return; //Get the new values: var newValues = new Hashtable(); e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem); int id = DataIntegrity.ConvertToInt(editedItem.GetDataKeyValue("ID").ToString()); string name = newValues["Name"] == null ? string.Empty : newValues["Name"].ToString(); int? page = DataIntegrity.ConvertToNullableInt(newValues["Page"]); int district = DataIntegrity.ConvertToInt(newValues["District"]); string abbreviation = newValues["Abbreviation"] == null ? string.Empty : newValues["Abbreviation"].ToString(); string phone = newValues["Phone"] == null ? string.Empty : newValues["Phone"].ToString(); string cluster = newValues["Cluster"] == null ? string.Empty : newValues["Cluster"].ToString(); string schoolType = newValues["SchoolType"] == null ? string.Empty : newValues["SchoolType"].ToString(); string schoolId = newValues["SchoolID"] == null ? string.Empty : newValues["SchoolID"].ToString(); string portalFlag = newValues["PortalFlag"] == null ? string.Empty : newValues["PortalFlag"].ToString(); if (id < 1) return; ThinkgateSchool school = new ThinkgateSchool(id, name, page, district, abbreviation, phone, cluster, schoolType, schoolId, portalFlag); school.UpdateSchool(); LoadSchools(); }
protected void rgUserSchoolsForEditing_UpdateCommand(Object source, GridCommandEventArgs e) { SessionObject sessionObject = (SessionObject)Session["SessionObject"]; _user = sessionObject.SelectedUser; if (_user == null) return; var editedItem = e.Item as GridEditableItem; if (editedItem == null) return; //Get the new values: var newValues = new Hashtable(); e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem); int? schoolID = DataIntegrity.ConvertToNullableInt(editedItem.GetDataKeyValue("ID").ToString()); if (schoolID == null) return; bool hasSchool = newValues["HasSchool"] != null && DataIntegrity.ConvertToBool(newValues["HasSchool"]); ThinkgateSchool school = new ThinkgateSchool((int)schoolID, false); if (hasSchool) { _user.addSchool(school); lblResultMessage.Text = string.Format("User {0} was added to school {1}.", _user.UserName, school.Name); } else { _user.removeSchool(school); lblResultMessage.Text = string.Format("User {0} was removed from school {1}.", _user.UserName, school.Name); } sessionObject.UpdateUserObject(_user); }