Пример #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var button = sender as Button;
            var tag    = button.Tag as string;
            var tagInt = Convert.ToInt32(tag);

            switch (tagInt)
            {
            case 0:
                //Нажата кнопка "Выдать книгу"
                checkOutBookWindow = new CheckOutBookWindow();
                checkOutBookWindow.ShowDialog();
                break;

            case 1:
                //Нажата кнопка "Выдать периодическое издание"
                checkOutPeriodicalWindow = new CheckOutPeriodicalWindow();
                checkOutPeriodicalWindow.ShowDialog();
                break;

            case 2:
                //Нажата кнопка "Принять/продлить документ"
                returnRenewWindow = new ReturnRenewWindow();
                returnRenewWindow.ShowDialog();
                break;

            case 3:
                //Нажата кнопка "Найти документ в базе данных"
                mainSearchWindow = new SearchWindows.MainSearchWindow();
                mainSearchWindow.ShowDialog();
                break;

            case 4:
                //Нажата кнопка "Зарегистрировать читателя"
                customerRegistrationWindow = new CustomerRegistrationWindow();
                customerRegistrationWindow.ShowDialog();
                break;

            case 5:
                //Нажата кнопка "Назад"
                Close();
                break;
            }
        }
Пример #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var button = sender as Button;
            var tag    = button.Tag as string;
            var tagInt = Convert.ToInt32(tag);

            switch (tagInt)
            {
            case 0:
                //Нажата кнопка "Поступление книги"
                addBookMainWindow = new AddBookMainWindow();
                addBookMainWindow.ShowDialog();
                break;

            case 1:
                //Нажата кнопка "Поступление периодического издания"
                addPeriodicalMainWindow = new AddPeriodicalMainWindow();
                addPeriodicalMainWindow.ShowDialog();
                break;

            case 2:
                //Нажата кнопка "Списание документа"
                documentWriteOffWindow = new DocumentWriteOffWindows.MainDocumentWriteOffWindow();
                documentWriteOffWindow.ShowDialog();
                break;

            case 3:
                //Нажата кнопка "Невозвращенные документы"
                overdueDocumentsOverviewWindow = new OverdueDocumentsOverviewWindow();
                overdueDocumentsOverviewWindow.ShowDialog();
                break;

            case 4:
                //Нажата кнопка "Поиск по базе данных документов"
                mainSearchwindow = new SearchWindows.MainSearchWindow();
                mainSearchwindow.ShowDialog();
                break;

            case 5:
                //Нажата кнопка "Назад"
                Close();
                break;
            }
        }
Пример #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            const string RenewDocumentQuery  = @"update [Coursework_2018].[dbo].[CustomerDocumentInteraction] set DueDate=@dueDate, IfRenewed=1 where CDInteractionID=@currentCDIID";
            const string AddRenewalDateQuery = @"insert [Coursework_2018].[dbo].[RenewalDates] (CDInteractionID, RenewalDate) values (@currentCDIID, getdate())";
            const string SetStatusTakenQuery = "update [Coursework_2018].[dbo].[CustomerDocumentInteraction] set Status = 'Taken' where CDInteractionID = @id";

            var button = sender as Button;
            var tag    = button.Tag as string;
            var tagInt = Convert.ToInt32(tag);

            switch (tagInt)
            {
            case 0:
                //Нажата кнопка "Продлить книгу"
                if (BooksDataGrid.SelectedItem != null)
                {
                    QueryResultClasses.CustomerOverviewWindow_BooksDataGrid currentBook = (QueryResultClasses.CustomerOverviewWindow_BooksDataGrid)BooksDataGrid.SelectedItem;
                    if (currentBook.Status == "Taken" || currentBook.Status == "Overdue")
                    {
                        using (TheContext db = new TheContext())
                        {
                            TimeSpan month = new TimeSpan(31, 0, 0, 0);

                            db.Database.ExecuteSqlCommand(RenewDocumentQuery, new SqlParameter("@dueDate", currentBook.DueDate + month), new SqlParameter("currentCDIID", currentBook.CDInteractionID));
                            if (currentBook.DueDate + month > DateTime.Now)
                            {
                                db.Database.ExecuteSqlCommand(SetStatusTakenQuery, new SqlParameter("@id", currentBook.CDInteractionID));
                            }
                            db.Database.ExecuteSqlCommand(AddRenewalDateQuery, new SqlParameter("@currentCDIID", currentBook.CDInteractionID));

                            //Обновление данных в DataGrid:
                            BooksDataGridQueryResult  = db.Database.SqlQuery <QueryResultClasses.CustomerOverviewWindow_BooksDataGrid>(BooksDataGridSqlQuery, new SqlParameter("@id", UserID)).ToList();
                            BooksDataGrid.ItemsSource = null;
                            BooksDataGrid.ItemsSource = BooksDataGridQueryResult;

                            MessageBox.Show("Книга продлена.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Выбранная книга уже возвращена в библиотеку.");
                    }
                }
                else
                {
                    MessageBox.Show("Выберите книгу для продления.");
                }
                break;

            case 1:
                //Нажата кнопка "Продлить периодическое издание"
                if (PeriodicalsDataGrid.SelectedItem != null)
                {
                    QueryResultClasses.CustomerOverviewWindow_PeriodicalsDataGrid currentPeriodical = (QueryResultClasses.CustomerOverviewWindow_PeriodicalsDataGrid)PeriodicalsDataGrid.SelectedItem;
                    if (currentPeriodical.Status == "Taken" || currentPeriodical.Status == "Overdue")
                    {
                        using (TheContext db = new TheContext())
                        {
                            TimeSpan month = new TimeSpan(31, 0, 0, 0);
                            db.Database.ExecuteSqlCommand(RenewDocumentQuery, new SqlParameter("@dueDate", currentPeriodical.DueDate + month), new SqlParameter("currentCDIID", currentPeriodical.CDInteractionID));
                            if (currentPeriodical.DueDate + month > DateTime.Now)
                            {
                                db.Database.ExecuteSqlCommand(SetStatusTakenQuery, new SqlParameter("@id", currentPeriodical.CDInteractionID));
                            }
                            db.Database.ExecuteSqlCommand(AddRenewalDateQuery, new SqlParameter("@currentCDIID", currentPeriodical.CDInteractionID));

                            //Обновление данных в DataGrid:
                            PeriodicalsDataGridQueryResult  = db.Database.SqlQuery <QueryResultClasses.CustomerOverviewWindow_PeriodicalsDataGrid>(PeriodicalsDataGridSqlQuery, new SqlParameter("@id", UserID)).ToList();
                            PeriodicalsDataGrid.ItemsSource = null;
                            PeriodicalsDataGrid.ItemsSource = PeriodicalsDataGridQueryResult;

                            MessageBox.Show("Периодическое издание продлено.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Выбранное издание уже возвращено в библиотеку.");
                    }
                }
                else
                {
                    MessageBox.Show("Выберите периодическое издание для продления.");
                }
                break;

            case 2:
                //Нажата кнопка "Искать документ в базе данных"
                SearchWindow = new SearchWindows.MainSearchWindow();
                SearchWindow.ShowDialog();
                break;

            case 3:
                //Нажата кнопка "Назад"
                Close();
                break;
            }
        }