Beispiel #1
0
        //переходим к рабочему окну
        ///<summary>
        ///method that goes to another window
        ///</summary>
        private void GoToWork(User user)
        {
            Window window;

            switch (user.Type)
            {
            case Librarian.TYPE:
                window = new LibrarianWorkWindow(user.CardNumber);
                break;

            default:
                window = new WorkWindow(user.CardNumber);
                break;
            }
            window.Show();
            this.Close();
        }
        /// <summary>
        /// View info about book
        /// </summary>
        /// <param name="book"></param>
        /// <param name="patron"></param>
        /// <param name="workWindow"></param>
        public BookingInfoWindow(Book book, Patron patron, WorkWindow workWindow)
        {
            InitializeComponent();
            this.book       = book;
            this.workWindow = workWindow;
            this.patron     = patron;

            TitleLabel.Content = book.Title;
            Authors.Content    = book.Authors;

            if (LibrarianDataManager.IsAvailable(book.Id, patron.CardNumber))
            {
                BookButton.IsEnabled = true;
                InStockLabel.Content = "Available.";
            }
            else
            {
                BookButton.IsEnabled = false;
                InStockLabel.Content = "Not available.";
            }
            BestSellerLabel.Content = book.IsBestseller ? "Bestseller." : "";

            if (CountFine() > 0)
            {
                FineLabel.Visibility      = Visibility.Visible;
                finePriceLabel.Content    = CountFine();
                finePriceLabel.Visibility = Visibility.Visible;
            }

            if (BookButton.IsEnabled == false)
            {
                GoToQueue.IsEnabled = true;
            }
            else
            {
                GoToQueue.IsEnabled = false;
            }
        }
Beispiel #3
0
 /// <summary>
 /// window for patron to see all info and notification for it
 /// </summary>
 /// <param name="patron"></param>
 /// <param name="window"></param>
 public InfoAndNotificationsWindow(Patron patron, WorkWindow window)
 {
     InitializeComponent();
     this.window = window;
     this.patron = patron;
 }
Beispiel #4
0
 private void GoToWork(WorkWindow work)
 {
     work.Show();
     this.Close();
 }
Beispiel #5
0
        private void button_register_Click(object sender, RoutedEventArgs e)
        {
            if (textBox_name.Text != null &&
                textBox_last_name.Text != null &&
                textBox_phone_number.Text != null &&
                textBox_Address_town.Text != null &&
                textBox_Address_street.Text != null &&
                textBox_Address_building.Text != null &&
                textBox_Address_flat.Text != null &&
                InputFieldsManager.CheckPasswordValidity(passwordBox_registration))
            {
                string firstName  = InputFieldsManager.ReturnStringFromTextBox(textBox_name),
                       secondName = InputFieldsManager.ReturnStringFromTextBox(textBox_last_name),
                       phone      = InputFieldsManager.ReturnStringFromTextBox(textBox_phone_number),
                       address    = InputFieldsManager.ReturnStringFromTextBox(textBox_Address_town) + ' ' +
                                    InputFieldsManager.ReturnStringFromTextBox(textBox_Address_street) + ' ' +
                                    InputFieldsManager.ReturnStringFromTextBox(textBox_Address_building) + ' ' +
                                    InputFieldsManager.ReturnStringFromTextBox(textBox_Address_flat) + ' ';
                string password = InputFieldsManager.ReturnPasswordFromTextBox(passwordBox_registration);
                string login    = firstName.Substring(0, 1) + '.' + secondName;

                bool IsNewUserAdded = false;

                if (professor_type.IsChecked == true)
                {
                    IsNewUserAdded = LibrarianDataManager.AddFaculty(
                        new Faculty(firstName, secondName, phone, address, Faculty.PROFESSOR_SUBTYPE), login, password);
                }
                else if (VP_professor_type.IsChecked == true)
                {
                    IsNewUserAdded = LibrarianDataManager.AddGuest(
                        new Guest(firstName, secondName, phone, address), login, password);
                }
                else if (TA_type.IsChecked == true)
                {
                    IsNewUserAdded = LibrarianDataManager.AddFaculty(
                        new Faculty(firstName, secondName, phone, address, Faculty.TA_SUBTYPE), login, password);
                }
                else if (instructor_type.IsChecked == true)
                {
                    IsNewUserAdded = LibrarianDataManager.AddFaculty(
                        new Faculty(firstName, secondName, phone, address, Faculty.INSTRUCTOR_SUBTYPE), login, password);
                }
                else if (student_type.IsChecked == true)
                {
                    IsNewUserAdded = LibrarianDataManager.AddStudent(
                        new Student(firstName, secondName, phone, address), login, password);
                }

                //if all checks good so open window
                if (IsNewUserAdded)
                {
                    WorkWindow workWindow = new WorkWindow(CredentialsManager.Authorize(login, password));
                    GoToWork(workWindow);
                }
                else
                {
                    MessageBox.Show("Error! Can not create an account.");
                }
            }
            else
            {
                MessageBox.Show("Error! Invalid fields.");
            }
        }