Beispiel #1
0
        private void login_Click(object sender, EventArgs e)
        {
            String currUserName = null;
            String currPassword = null;

            if (usrName.Text.Length != 0 && pWord.Text.Length != 0)
            {
                currUserName = usrName.Text.ToString();
                currPassword = pWord.Text.ToString();

                bool foundID = false;

                for (int i = 0; i < Users.UsersList.Count && !foundID; i++)
                {
                    if (Users.UsersList[i].UserID.Equals(currUserName))
                    {
                        if (Users.UsersList[i].Password.Equals(currPassword))
                        {

                            selectedUser = Users.UsersList[i];
                            foundID = true;
                            //login success, close the form
                            this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        }

                        else
                            MessageBox.Show("Wrong password. Please try again.");
                    }

                }

                if (foundID == false)
                {
                    MessageBox.Show("Provided User ID isn't registered. Please, check you user ID and try again");
                }

            }
            else
            {
                MessageBox.Show("Please provide User ID");
            }
        }
Beispiel #2
0
 public void addUser(User toAdd)
 {
     UsersList.Add(toAdd);
 }
Beispiel #3
0
        private void register_Click(object sender, EventArgs e)
        {
            String currUserName = null;
            String currPassword = null;

            if (usrName.Text.Length != 0 && pWord.Text.Length != 0)
            {
                currUserName = usrName.Text.ToString();
                currPassword = pWord.Text.ToString();

                String foundID = null;

                for (int i = 0; i < Users.UsersList.Count && !userRegistered; i++)
                {
                    if (Users.UsersList[i].UserID.Equals(currUserName))
                    {
                        MessageBox.Show("There is a user already registered with given User ID. Please choose a different User ID and try again");
                    }
                    else
                    {
                        selectedUser = new Proj.Class.User(currUserName,currPassword);
                        Users.addUser(selectedUser);

                        ///register success, close the form
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        userRegistered = true;
                    }
                }

            }
            else
            {
                MessageBox.Show("Please provide User ID");
            }
        }
Beispiel #4
0
        private void logBtn_Click(object sender, EventArgs e)
        {
            logIn = new Form3(Users);
            //logIn.Show();
            var dialogResult = logIn.ShowDialog();
            if (dialogResult != System.Windows.Forms.DialogResult.Cancel)
            {
                currentUser = logIn.SelectedUser;

                if(logIn.UserRegistered == true) //if we have a new user/users registered
                Users = logIn.GetModifiedUserList;
            }
        }