Esempio n. 1
0
        /* Edit */

        private void Edit(object sender, EventArgs e)
        {
            if (!CheckForSelectedItem())
            {
                return;
            }

            Hide();
            switch (_option)
            {
            case 1:
                var editAuthorWindow = new CreateEditAuthor(entitiesListBox.SelectedItem as Author);
                editAuthorWindow.Closed += (s, args) => Show();
                editAuthorWindow.ShowDialog();
                break;

            case 2:
                var editPublisherWindow = new CreateEditPublisher(entitiesListBox.SelectedItem as Publisher);
                editPublisherWindow.Closed += (s, args) => Show();
                editPublisherWindow.ShowDialog();
                break;

            case 3:
                var editStudentWindow = new CreateEditStudent(entitiesListBox.SelectedItem as Student);
                editStudentWindow.Closed += (s, args) => Show();
                editStudentWindow.ShowDialog();
                break;

            case 4:
                var editBookWindow = new CreateEditBook(entitiesListBox.SelectedItem as Book);
                editBookWindow.Closed += (s, args) => Show();
                editBookWindow.ShowDialog();
                break;

            case 5:
                var editLoanWindow = new CreateEditLoan(entitiesListBox.SelectedItem as Loan);
                editLoanWindow.Closed += (s, args) => Show();
                editLoanWindow.ShowDialog();
                break;

            default:
                CommonErrorMessage();
                break;
            }

            RefreshRepositories();
            RefreshList();
        }
Esempio n. 2
0
        /* Create */

        private void Create(object sender, EventArgs e)
        {
            Hide();
            switch (_option)
            {
            case 1:
                var createAuthorWindow = new CreateEditAuthor();
                createAuthorWindow.Closed += (s, args) => Show();
                createAuthorWindow.ShowDialog();
                break;

            case 2:
                var createPublisherWindow = new CreateEditPublisher();
                createPublisherWindow.Closed += (s, args) => Show();
                createPublisherWindow.ShowDialog();
                break;

            case 3:
                var createStudentWindow = new CreateEditStudent();
                createStudentWindow.Closed += (s, args) => Show();
                createStudentWindow.ShowDialog();
                break;

            case 4:
                var createBookWindow = new CreateEditBook();
                createBookWindow.Closed += (s, args) => Show();
                createBookWindow.ShowDialog();
                break;

            case 5:
                var createLoanWindow = new CreateEditLoan();
                createLoanWindow.Closed += (s, args) => Show();
                createLoanWindow.ShowDialog();
                break;

            default:
                CommonErrorMessage();
                break;
            }

            RefreshList();
        }