Exemple #1
0
 private void OnUserCard(object sender, RoutedEventArgs e)
 {
     if (UsersTable.SelectedItem != null)
     {
         LibrarianUserView selectedUser = UsersTable.SelectedItem as LibrarianUserView;
         UserCard          modifyUser   = new UserCard(selectedUser.userID);
         modifyUser.ShowDialog();
         UpdateTable();
     }
 }
 private void OnBackClick(object sender, RoutedEventArgs e)
 {
     if (_userType == 5)
     {
         Close();
     }
     else
     {
         UserCard page = new UserCard(_userID);
         Close();
         page.ShowDialog();
     }
 }
        private void OnModifyUserClick(object sender, RoutedEventArgs e)
        {
            if (UserName.Text.Length == 0 || UserAdress.Text.Length == 0 || UserPhoneNumber.Text.Length == 0)
            {
                MessageBox.Show("One of fields is not filled!", "Error");
                return;
            }
            if (!ValidMail(UserAdress.Text))
            {
                MessageBox.Show("Invalid e-mail!", "Error");
                return;
            }

            if (_userType == 5)
            {
                Admin admin = (Admin)SDM.CurrentUser;
                admin.ModifyLibrarian
                (
                    _userID,
                    UserName.Text,
                    UserAdress.Text,
                    UserPhoneNumber.Text,
                    UserType.SelectedIndex
                );
                Close();
            }
            else
            {
                Librarian lib = (Librarian)SDM.CurrentUser;
                lib.ModifyUser
                (
                    _userID,
                    UserName.Text,
                    UserAdress.Text,
                    UserPhoneNumber.Text,
                    UserType.SelectedIndex
                );
                UserCard page = new UserCard(_userID);
                Close();
                page.ShowDialog();
            }
        }