private void butOK_Click(object sender, System.EventArgs e) { InstCur.LName = textLName.Text; InstCur.FName = textFName.Text; InstCur.Suffix = textSuffix.Text; Instructors.InsertOrUpdate(InstCur, IsNew); DialogResult = DialogResult.OK; }
private void FillList() { int previousSelected = -1; if (listInstructors.SelectedIndex != -1) { previousSelected = Instructors.List[listInstructors.SelectedIndex].InstructorNum; } Instructors.Refresh(); listInstructors.Items.Clear(); for (int i = 0; i < Instructors.List.Length; i++) { listInstructors.Items.Add(Instructors.List[i].LName + ", " + Instructors.List[i].FName + ", " + Instructors.List[i].Suffix); if (Instructors.List[i].InstructorNum == previousSelected) { listInstructors.SelectedIndex = i; } } }
private void butDelete_Click(object sender, System.EventArgs e) { if (IsNew) { DialogResult = DialogResult.Cancel; } else { if (!MsgBox.Show(this, true, "Delete this Instructor?")) { return; } try{ Instructors.Delete(InstCur); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } DialogResult = DialogResult.OK; }