Exemplo n.º 1
0
        public void Initialization()
        {
            LibrarianDataManager.ClearAll();
            LibrarianDataManager.AddBook(new Book(
                                             "Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein",
                                             "Introduction to Algorithms",
                                             "MIT Press",
                                             "Third edition",
                                             2009,
                                             false,
                                             "Algorithms",
                                             "",
                                             5000
                                             ));
            LibrarianDataManager.AddBook(new Book(
                                             "Erich Gamma, Ralph Johnson, John Vlissides, Richard Helm",
                                             "Design Patterns: Elements of Reusable Object-Oriented Software",
                                             "Addison-Wesley Professional",
                                             "First edition",
                                             2003,
                                             true,
                                             "Algorithms",
                                             "",
                                             1700
                                             ));
            LibrarianDataManager.AddAVMaterial(new AVMaterial(
                                                   "Tony Hoare",
                                                   "Null References: The Billion DollarMistake",
                                                   "",
                                                   "",
                                                   700));
            LibrarianDataManager.AddCopies(3, new Copy(1, 1, 1));
            LibrarianDataManager.AddCopies(3, new Copy(2, 1, 1));
            LibrarianDataManager.AddCopies(2, new Copy(3, 1, 1));

            LibrarianDataManager.AddFaculty(new Faculty(
                                                "Sergey",
                                                "Afonso",
                                                "30001",
                                                "ViaMargutta, 3",
                                                Faculty.PROFESSOR_SUBTYPE
                                                ), "patron_1", "12345");
            LibrarianDataManager.AddFaculty(new Faculty(
                                                "Nadia",
                                                "Teixeira",
                                                "30002",
                                                "Via Sacra, 13",
                                                Faculty.PROFESSOR_SUBTYPE
                                                ), "patron_2", "12345");
            LibrarianDataManager.AddFaculty(new Faculty(
                                                "Elvira",
                                                "Espindola",
                                                "30003",
                                                "Via del Corso, 22",
                                                Faculty.PROFESSOR_SUBTYPE
                                                ), "patron_3", "12345");
            LibrarianDataManager.AddStudent(new Student(
                                                "Andrey",
                                                "Velo",
                                                "30004",
                                                "AvenidaMazatlan 250"
                                                ), "patron_4", "12345");
            LibrarianDataManager.AddGuest(new Guest(
                                              "Veronika",
                                              "Rama",
                                              "30005",
                                              "Stret Atocha, 27"
                                              ), "patron_5", "12345");
            LibrarianDataManager.AddLibrarian(new Librarian(
                                                  "LibrarianName",
                                                  "LibrarianSurname",
                                                  "30006",
                                                  "LibrarianAddress"
                                                  ), "librarian_1", "12345");
        }
Exemplo n.º 2
0
        private void save_user_Click(object sender, RoutedEventArgs e)
        {
            if (name_of_new_user.Text != null &&
                lastname_of_new_user.Text != null &&
                phone_of_new_user.Text != null &&
                town_of_new_user.Text != null &&
                street_of_new_user.Text != null &&
                house_of_new_user.Text != null &&
                flat_of_new_user.Text != null &&
                InputFieldsManager.CheckPasswordValidity(user_new_password))
            {
                string firstName  = InputFieldsManager.ReturnStringFromTextBox(name_of_new_user),
                       secondName = InputFieldsManager.ReturnStringFromTextBox(lastname_of_new_user),
                       phone      = InputFieldsManager.ReturnStringFromTextBox(phone_of_new_user),
                       address    = InputFieldsManager.ReturnStringFromTextBox(town_of_new_user) + ' ' +
                                    InputFieldsManager.ReturnStringFromTextBox(street_of_new_user) + ' ' +
                                    InputFieldsManager.ReturnStringFromTextBox(house_of_new_user) + ' ' +
                                    InputFieldsManager.ReturnStringFromTextBox(flat_of_new_user) + ' ';
                string password = InputFieldsManager.ReturnPasswordFromTextBox(user_new_password);
                string login    = firstName.Substring(0, 1) + '.' + secondName;

                bool IsNewUserAdded = false;
                if (InstructorCheckBoxType.IsChecked == true)
                {
                    IsNewUserAdded = LibrarianDataManager.AddFaculty(
                        new Faculty(firstName, secondName, phone, address, "Instructor"), login, password);
                }
                else if (librarianCheckBoxType.IsChecked == true)
                {
                    IsNewUserAdded = LibrarianDataManager.AddLibrarian(
                        new Librarian(firstName, secondName, phone, address), login, password);
                }
                else if (studentCheckBoxType.IsChecked == true)
                {
                    IsNewUserAdded = LibrarianDataManager.AddStudent(
                        new Student(firstName, secondName, phone, address), login, password);
                }
                else if (taCheckBoxType.IsChecked == true)
                {
                    IsNewUserAdded = LibrarianDataManager.AddFaculty(
                        new Faculty(firstName, secondName, phone, address, "TA"), login, password);
                }
                else if (professorCheckBoxType.IsChecked == true)
                {
                    IsNewUserAdded = LibrarianDataManager.AddFaculty(
                        new Faculty(firstName, secondName, phone, address, "Professor"), login, password);
                }
                else if (visitingProfessorCheckBoxType.IsChecked == true)
                {
                    IsNewUserAdded = LibrarianDataManager.AddGuest(
                        new Guest(firstName, secondName, phone, address), login, password);
                }

                //if all checks good so open window
                if (IsNewUserAdded)
                {
                    using (StreamWriter writer = new StreamWriter("id.txt"))
                    {
                        writer.Write(CredentialsManager.Authorize(login, password));
                    }
                }
                else
                {
                    MessageBox.Show("Error! Can not create an account.");
                }
            }
            else
            {
                MessageBox.Show("Error! Invalid fields.");
            }
            this.Close();
        }
Exemplo n.º 3
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.");
            }
        }