private void GroupAdd()
        {
            string notWork = "";

            if (string.IsNullOrWhiteSpace(GroupName.Text))
            {
                notWork += $"{nameof(GroupName)} is null\n";
            }
            if (string.IsNullOrWhiteSpace(SokrGroupName.Text))
            {
                notWork += $"{nameof(SokrGroupName)} is null\n";
            }
            if (string.IsNullOrWhiteSpace(Potok.Text))
            {
                notWork += $"{nameof(Potok)} is null\n";
            }
            if (string.IsNullOrWhiteSpace(Seminar.Text))
            {
                notWork += $"{nameof(Seminar)} is null\n";
            }
            if (string.IsNullOrWhiteSpace(NumberPeople.Text))
            {
                notWork += $"{nameof(NumberPeople)} is null\n";
            }


            if (notWork == "")
            {
                if (WorkToMyDbContext.groups == null || WorkToMyDbContext.groups.Count == 0)
                {
                    ID = 1;
                }
                else
                {
                    ID = WorkToMyDbContext.groups.Max(x => x.GroupId) + 1;
                }

                var group = new Group()
                {
                    FullName        = GroupName.Text,
                    Abbreviation    = SokrGroupName.Text,
                    Potok           = Potok.Text,
                    Seminar         = Seminar.Text,
                    NumberOfPersons = Convert.ToInt32(NumberPeople.Text),
                    GroupId         = ID
                };
                WorkToMyDbContext.groups.Add(group);
                WorkToMyDbContext.SaveDB(typeof(Group).FullName);

                Close();
            }
            else
            {
                notWork = "Не добавится группа пока: \n" + notWork;
                MessageBox.Show(notWork);
            }
        }
Example #2
0
        private void GroupAdd()
        {
            string notWork = "";

            if (string.IsNullOrWhiteSpace(SubjectName.Text))
            {
                notWork += $"{nameof(SubjectName)} is null\n";
            }
            if (string.IsNullOrWhiteSpace(SokrSubjectName.Text))
            {
                notWork += $"{nameof(SokrSubjectName)} is null\n";
            }


            if (notWork == "")
            {
                if (WorkToMyDbContext.subjects == null || WorkToMyDbContext.subjects.Count == 0)
                {
                    ID = 1;
                }
                else
                {
                    ID = WorkToMyDbContext.subjects.Max(x => x.SubjectId) + 1;
                }
                var subject = new Subject()
                {
                    FullName     = SubjectName.Text,
                    Abbreviation = SokrSubjectName.Text,
                    SubjectId    = ID
                };
                WorkToMyDbContext.subjects.Add(subject);
                WorkToMyDbContext.SaveDB(typeof(Subject).FullName);
                Close();
            }
            else
            {
                notWork = "Не добавится группа пока: \n" + notWork;
                MessageBox.Show(notWork);
            }
        }