public void AddSubjectType(NewSubjectType toAdd)
        {
            if (toAdd != null)
            {
                SubjectType st = new SubjectType()
                {
                    Name = toAdd.SubjectTypeName,
                };

                SPDatabase.DB.SubjectTypes.AddObject(st);
                SPDatabase.DB.SaveChanges();
            }
        }
        public bool AddSubjectType(NewSubjectType toAdd)
        {
            SubjectType st = this.repository.GetSubjectType(toAdd.SubjectTypeName);
            if (st != null && st.Name.ToLower().Equals(toAdd.SubjectTypeName.ToLower()))
                toAdd.AddError("Typ przedmiotu o takiej nazwie już\nistnieje");

            if (toAdd.IsValid)
            {
                this.repository.AddSubjectType(toAdd);
                return true;
            }

            return false;
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            lblValidation.Text = string.Empty;
            NewSubjectType toAdd = new NewSubjectType()
            {
                SubjectTypeName = tbNewSubjectTypeName.Text
            };

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