private void Edit_Click(object sender, EventArgs e)
        {
            using (AcademyEntities academyDb = new AcademyEntities())
            {
                if (academyDb.Groups.Any())
                {
                    this.Hide();

                    var id = Convert.ToInt32(GroupsView.CurrentRow.Cells["Id"].Value);
                    //EditSubjectDialog
                    EditGroupDialog editGroupDialog = new EditGroupDialog(id);
                    editGroupDialog.Show();

                    this.AddOwnedForm(editGroupDialog);
                }
                else
                {
                    MessageBox.Show("No groups existed!");
                }
            }
        }
Beispiel #2
0
        private void ShowCreateGroupDialog()
        {
            var dialog = new EditGroupDialog();

            dialog.Title = "Create new group";
            if (dialog.ShowDialog() == true)
            {
                //MessageBox.Show("You said: " + dialog.ResponseText);

                if (dialog.ResponseText.Length == 0)
                {
                    MessageBox.Show("Group name cannot be empty");

                    return;
                }

                if (Groups.Where(x => x.Name == dialog.ResponseText).Count() > 0)
                {
                    MessageBox.Show("Group with this name already exists");

                    return;
                }

                if (DGServices.SelectedItems.Count == 0)
                {
                    if (MessageBox.Show("There are no services selected. Do you want to continue?", "No selected services", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
                    {
                        return;
                    }
                }

                var group = new Group(dialog.ResponseText);
                group.AddServiceRange(DGServices.SelectedItems);

                Groups.Add(group);
            }
        }