コード例 #1
0
        private void deleteData_Click(object sender, EventArgs e)
        {
            if (BooksList.CurrentCell.ContextMenuStrip == changeData)
            {
                if (BooksList[0, BooksList.CurrentCell.RowIndex].Value == null)
                {
                    return;
                }

                bookName = BooksList[0, BooksList.CurrentCell.RowIndex].Value.ToString();
                BooksList.Rows.Remove(BooksList.CurrentRow);
                BooksBase.getBooksBase().deleteBook(bookName);
                BooksList.SelectionChanged += BooksList_SelectionChanged_1;
            }
            if (UsersList.CurrentCell.ContextMenuStrip == changeData)
            {
                if (UsersList[0, UsersList.CurrentCell.RowIndex].Value == null)
                {
                    return;
                }

                userName = UsersList[0, UsersList.CurrentCell.RowIndex].Value.ToString();
                UsersList.Rows.Remove(UsersList.CurrentRow);
                UsersBase.getUserBase().deleteUser(userName);
                UsersList.SelectionChanged += UsersList_SelectionChanged_1;
            }
        }
コード例 #2
0
        private void SetLists()
        {
            allBooks = new List <Book>();
            allUsers = new List <User>();
            allBooks = BooksBase.getBooksBase().getAllBooks();
            allUsers = UsersBase.getUserBase().getAllUsers();

            BooksList.Rows.Clear();
            if (allBooks.Count != 0)
            {
                BooksList.RowCount = allBooks.Count + 1;
                for (int i = 0; i < BooksList.RowCount - 1; i++)
                {
                    BooksList[0, i].Value = allBooks[i].name;
                    BooksList[1, i].Value = allBooks[i].author;
                    BooksList[2, i].Value = allBooks[i].genre;
                    BooksList[3, i].Value = allBooks[i].cost;
                }
            }

            UsersList.Rows.Clear();
            if (allUsers.Count != 0)
            {
                UsersList.RowCount = allUsers.Count + 1;
                for (int i = 0; i < UsersList.RowCount - 1; i++)
                {
                    UsersList[0, i].Value = allUsers[i].login;
                    UsersList[1, i].Value = allUsers[i].type;
                }
            }
        }
コード例 #3
0
        private void unregUserCheck()
        {
            if (loginText.Text.Length == 0 || loginText.Text.Replace(" ", "").Length == 0 ||
                passwordText.Text.Length == 0 || passwordText.Text.Replace(" ", "").Length == 0 ||
                (adminType.Checked == false && userType.Checked == false))
            {
                uncorrectDataText.Text = "Необходимо заполнить каждое поле";
            }
            else if (UsersBase.getUserBase().findUser(loginText.Text, passwordText.Text))
            {
                uncorrectDataText.Text = "Пользователь с таким именем уже существует";
                return;
            }
            else
            {
                User currentUser = new User();
                currentUser.login    = loginText.Text;
                currentUser.password = passwordText.Text;

                if (userType.Checked == true)
                {
                    currentUser.type = "user";
                }
                else if (adminType.Checked == true)
                {
                    currentUser.type = "admin";
                }

                UsersBase.getUserBase().addUser(currentUser.login, currentUser.password, currentUser.type);
                MessageBox.Show("Добавлен пользователь " + currentUser.login + " с уровнем доступа " + currentUser.type);
                this.Close();
            }
        }
コード例 #4
0
ファイル: UsersBase.cs プロジェクト: VadimRom28/LovelyLib
 public static UsersBase getUserBase()
 {
     if (instance == null)
     {
         instance = new UsersBase();
     }
     return(instance);
 }
コード例 #5
0
        private void regUserCheck()
        {
            if (accessType == AccessType.admin && adminType.Checked == false ||
                accessType == AccessType.user && userType.Checked == false)
            {
                UsersBase.getUserBase().changeUserType(loginText.Text);
                MessageBox.Show("Пользователь " + loginText.Text + " теперь имеет уровень доступа " +
                                UsersBase.getUserBase().getUser(loginText.Text).type);
            }

            this.Close();
        }
コード例 #6
0
ファイル: ChooseLib.cs プロジェクト: VadimRom28/LovelyLib
        private void selectLibButton_Click(object sender, EventArgs e)
        {
            if (libUserBase.SelectedIndex != -1)
            {
                selectedLib.lib  = LibBase.getLibBase().getLib(LoginForm.ourUserName, libUserBase.SelectedItem.ToString());
                selectedLib.user = UsersBase.getUserBase().getUser(LoginForm.ourUserName);

                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Вы не выбрали библиотеку");
            }
        }
コード例 #7
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            loginUser    = loginText;
            passwordUser = passwordText;

            if (loginUser.Text.Length == 0 || passwordText.Text.Length == 0)
            {
                uncorrectDataText.Text = "Необходимо заполнить каждое поле";
                return;
            }

            if (loginText.Text.Contains(' ') || passwordText.Text.Contains(' '))
            {
                uncorrectDataText.Text = "Нельзя использовать пробел";
                return;
            }

            if (ourUsers.findUser(loginUser.Text, passwordText.Text))
            {
                if (UsersBase.getUserBase().getUserType(loginUser.Text, passwordText.Text) == "admin")
                {
                    userType = UserType.admin;
                    AdminBaseForm adminBaseForm = new AdminBaseForm();
                    adminBaseForm.Show();
                    this.Hide();
                    return;
                }

                if (UsersBase.getUserBase().getUserType(loginUser.Text, passwordText.Text) == "user")
                {
                    userType    = UserType.client;
                    ourUserName = loginText.Text;
                    ChooseLib chooseLib = new ChooseLib();
                    chooseLib.Show();
                    this.Hide();
                }
            }
            else
            {
                uncorrectDataText.Text = "Неверное имя пользователя или пароль";
            }
        }
コード例 #8
0
        private void setData()
        {
            if (AdminBaseForm.userName.Length != 0)
            {
                loginText.Enabled    = false;
                passwordText.Enabled = false;

                User currentUser = new User();
                currentUser = UsersBase.getUserBase().getUser(AdminBaseForm.userName);

                loginText.Text    = currentUser.login;
                passwordText.Text = currentUser.password;
                if (currentUser.type == "admin")
                {
                    accessType        = AccessType.admin;
                    adminType.Checked = true;
                }
                else if (currentUser.type == "user")
                {
                    accessType       = AccessType.user;
                    userType.Checked = true;
                }
            }
        }