public void AddSpecialization(NewSpecialization toAdd)
        {
            if (toAdd != null)
            {
                Specialization i = new Specialization()
                {
                    Name = toAdd.SpecializationName,
                    FacultyID = toAdd.FacultyId,
                    DepartamentID = toAdd.DepartamentId
                };

                SPDatabase.DB.Specializations.AddObject(i);
                SPDatabase.DB.SaveChanges();
            }
        }
        public bool AddSpecialization(NewSpecialization toAdd)
        {
            Specialization s = this.repository.GetSpecialization(toAdd.SpecializationName);
            if (s != null && s.DepartamentID == toAdd.DepartamentId && s.FacultyID == toAdd.FacultyId)
                toAdd.AddError("Specjalizacja o takich danych już\nistnieje");

            if (toAdd.DepartamentId == 0 || toAdd.FacultyId == 0)
                toAdd.AddError("Wydział lub kierunek nie istnieje");

            if (toAdd.IsValid)
            {
                this.repository.AddSpecialization(toAdd);
                return true;
            }
            return false;
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            lblValidation.Text = string.Empty;

            Departament dep = null;
            if (lstDepartaments.Items.Count > 0)
                dep = DepartamentController.Instance.GetDepartament(lstDepartaments.SelectedItem.ToString());

            Faculty fac = null;
            if (lstFaculties.Items.Count > 0)
                fac = FacultyController.Instance.GetFaculty(lstFaculties.SelectedItem.ToString());

            NewSpecialization toAdd = new NewSpecialization()
            {
                SpecializationName = tbNewSpecializationName.Text,
                DepartamentId = dep == null? 0 : dep.DepartamentID,
                FacultyId = fac == null? 0 : fac.FacultyID
            };

            if (!SpecializationController.Instance.AddSpecialization(toAdd))
            {
                string errors = string.Empty;
                foreach (string error in toAdd.Errors)
                    errors = errors + error + "\n";
                lblValidation.Text = errors;
            }
            else
            {
                FillWithSpecializations();
                Clear();
                changes = true;
            }
        }