public void DeleteDepartament(DepartamentEdit toEdit) { Departament d = this.repository.GetDepartament(toEdit.DepartamentName); if (d != null && (d.Faculties.Count > 0 || d.Plans.Count > 0 || d.SubjectsDatas.Count > 0 || d.Institutes.Count > 0 || d.Specializations.Count > 0)) throw new UpdateException("Nie można usunąć wydziału,\nponieważ posiada powiązania"); else this.repository.DeleteDepartament(d); }
public void EditDepartament(DepartamentEdit d) { if (d != null) { Departament dd = this.GetDepartament(d.DepartamentID); if (dd != null) { dd.Name = d.DepartamentName; SPDatabase.DB.SaveChanges(); } } }
public bool EditDepartament(DepartamentEdit toEdit) { if (toEdit != null) { if (toEdit.Errors != null) toEdit.Errors.Clear(); Departament d = this.repository.GetDepartament(toEdit.DepartamentName); if (d != null && d.DepartamentID != toEdit.DepartamentID) toEdit.AddError("Wydział o podanej nazwie już istnieje"); if (toEdit.IsValid) { this.repository.EditDepartament(toEdit); return true; } } return false; }
private void listDepartaments_DoubleClick(object sender, EventArgs e) { lblValidation.Text = string.Empty; if (listDepartaments.SelectedIndex >= 0) { DepartamentEdit departament = DepartamentController.Instance.GetDepartamentEdit(listDepartaments.SelectedItem.ToString()); if (departament != null) { toEdit = departament; Enable(); txtNewDepartamentName.Text = departament.DepartamentName; } else { lblValidation.Text = "Wydzia³ nie istnieje"; toEdit = null; } } }
private void btnDelete_Click(object sender, EventArgs e) { lblValidation.Text = string.Empty; if (toEdit != null) { try { DepartamentController.Instance.DeleteDepartament(toEdit); FillWithDepartaments(); changes = true; toEdit = null; Disable(); Clear(); } catch (UpdateException ex) { lblValidation.Text = ex.Message; } } }
private void btnCancel_Click(object sender, EventArgs e) { if (toEdit != null) { toEdit = null; Disable(); Clear(); lblValidation.Text = string.Empty; } }