private void OnDeleteClass(object sender, EventArgs e) { if (MessageBox.Show("Are you sure? This will also delete the categories inside this class.", "Delete class", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (ClassList.Count == 1) { ClearTotals(); ClearGrade(); groupBoxTotals.Text = "Class Grade"; groupBoxGrade.Text = "Category Totals (%)"; dataGridView.Enabled = false; dataGridView.Rows.Clear(); comboBoxCategory.Enabled = false; comboBoxClass.Items.Remove(CurrentClass.Name); comboBoxCategory.Items.Clear(); comboBoxCategory.Items.Add("Create new category"); ClassList.Remove(CurrentClass); editClassToolStripMenuItem.Enabled = false; deleteClassToolStripMenuItem.Enabled = false; addCategoryToolStripMenu.Enabled = false; editCategoryToolStripMenuItem.Enabled = false; deleteCategoryToolStripMenuItem.Enabled = false; saveAsToolStripMenuItem.Enabled = false; saveToolStripMenuItem.Enabled = false; } else { comboBoxClass.Items.Remove(CurrentClass.Name); if (CurrentClassIndex != 0) { --CurrentClassIndex; } comboBoxClass.SelectedIndex = CurrentClassIndex + 1; if (CurrentClass.CategoryList.Count != 0) { UpdateTotals(); UpdateGrade(); LoadData(); } else { ClearTotals(); ClearGrade(); } groupBoxGrade.Text = CurrentClass.Name + " Grade"; groupBoxTotals.Text = "Category Totals (%)"; ClassList.RemoveAt(CurrentClassIndex + 1); dataGridView.Rows.Clear(); dataGridView.Enabled = false; comboBoxCategory.Items.Clear(); comboBoxCategory.Items.Add("Create new category"); foreach (Category c in CurrentClass.CategoryList) { comboBoxCategory.Items.Add(c.Name); } } } }
private void _F_RemoveClassInfo(ClassInfoViewModel classInfo) { var list = (from item in _EFDataContext.relations where item.ClassId == classInfo.ID select item).ToList(); //删除与班级对应的学生-班级关系记录 foreach (var relation in list) { _RelationShipDal.Remove(relation); } _ClassInfoDal.Remove(classInfo.ClassInfo); _RelationShipDal.Save(); ClassList.Remove(classInfo); //RefreshData(); }
public void SetClassTrue(string classStr, bool value) { if (value == GetClassTrue(classStr)) { return; } if (value) { ClassList.Add(classStr); } else { ClassList.Remove(classStr); } }
internal void SetContextual(string type, string value) { int length = ClassList.Length; for (int i = 0; i < length; i++) { if (ClassList[i].StartsWith(type)) { ClassList.Remove(ClassList[i]); break; } } if (!string.IsNullOrWhiteSpace(value) && value.StartsWith(type)) { ClassList.Add(value); } }