コード例 #1
0
        private void viewButton_Click(object sender, EventArgs e)
        {
            TextEditor_View view = new TextEditor_View();

            view.ShowDialog();
            this.Close();
        }
コード例 #2
0
        private void loginbutton_Click(object sender, EventArgs e)
        {
            {
                if (usernameBox.Text.Length == 0 || passwordBox.Text.Length == 0)
                {
                    MessageBox.Show("Please enter username and password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var userValue = User.userList.Where(p => p.userName == usernameBox.Text || p.password == passwordBox.Text).ToList();

                    if (userValue.Count == 0)
                    {
                        MessageBox.Show("Incorrect username and password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        User.selectedUsers = new List <Users>();
                        User.selectedUsers.Add(new Users
                        {
                            userName = userValue[0].userName,
                            password = userValue[0].password,
                            userType = userValue[0].userType
                        });

                        string type = User.selectedUsers[0].userType;
                        if (type == "View")
                        {
                            TextEditor_View text = new TextEditor_View();
                            text.ShowDialog();
                            this.Close();
                        }
                        else
                        {
                            TextEditor text = new TextEditor();
                            text.ShowDialog();
                            this.Close();
                        }
                    }
                }
            }
        }
コード例 #3
0
        private void register_button_Click(object sender, EventArgs e)
        {
            if (viewBox.Text == "Edit")
            {
                if (usernameText.Text.Length == 0 || firstNameText.Text.Length == 0 || lastNameText.Text.Length == 0 || DOB.Text.Length == 0 || passwordBox.Text.Length == 0 || confirmPasswordbox.Text.Length == 0 || viewBox.Text.Length == 0)

                {
                    MessageBox.Show("Please fill out all the fields.", "Stop", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop);
                    return;
                }
                if (passwordBox.Text != confirmPasswordbox.Text)
                {
                    MessageBox.Show("Password does not match. Please enter the same password.", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop);
                    return;
                }
                if (usernameText.Text.Length != 0 || firstNameText.Text.Length != 00 || lastNameText.Text.Length != 0 || DOB.Text.Length != 0 || passwordBox.Text.Length != 0 || confirmPasswordbox.Text.Length != 0)
                {
                    if (User.userList.Count == 0)
                    {
                        return;
                    }
                    else
                    {
                        var list = User.userList.Where(a => a.userName == usernameText.Text && a.firstName == firstNameText.Text && a.lastName == lastNameText.Text);
                        if (list.ToList().Count >= 1)
                        {
                            MessageBox.Show(usernameText.Text + " is already Registered", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop);
                            return;
                        }
                    }

                    string data = usernameText.Text + "," + passwordBox.Text + "," + viewBox.Text + "," + firstNameText.Text + "," + lastNameText.Text + "," + DateTime.Parse(DOB.Text).ToString("MM-dd-yyyy");
                    if (user.writeFile(data, config.folder + "\\login.txt"))
                    {
                        MessageBox.Show(firstNameText.Text + " " + lastNameText.Text + " is Registered", "", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        TextEditor text = new TextEditor();
                        text.ShowDialog();
                        this.Close();
                        string name = usernameText.Text;
                        text.setUsername(name);
                    }
                }
                else
                {
                    MessageBox.Show("Error in User Registration", "", MessageBoxButtons.OK, MessageBoxIcon.Question);
                }
            }
            if (viewBox.Text == "View")
            {
                if (usernameText.Text.Length == 0 || firstNameText.Text.Length == 0 || lastNameText.Text.Length == 0 || DOB.Text.Length == 0 || passwordBox.Text.Length == 0 || confirmPasswordbox.Text.Length == 0 || viewBox.Text.Length == 0)

                {
                    MessageBox.Show("Please fill out all the fields.", "Stop", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop);
                    return;
                }
                if (passwordBox.Text != confirmPasswordbox.Text)
                {
                    MessageBox.Show("Password does not match. Please enter the same password.", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop);
                    return;
                }
                if (usernameText.Text.Length != 0 || firstNameText.Text.Length != 00 || lastNameText.Text.Length != 0 || DOB.Text.Length != 0 || passwordBox.Text.Length != 0 || confirmPasswordbox.Text.Length != 0)
                {
                    if (User.userList.Count == 0)
                    {
                        return;
                    }
                    else
                    {
                        var list = User.userList.Where(a => a.userName == usernameText.Text && a.firstName == firstNameText.Text && a.lastName == lastNameText.Text);
                        if (list.ToList().Count >= 1)
                        {
                            MessageBox.Show(usernameText.Text + " is already Registered", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop);
                            return;
                        }
                    }
                    string data = usernameText.Text + "," + passwordBox.Text + "," + viewBox.Text + "," + firstNameText.Text + "," + lastNameText.Text + "," + DateTime.Parse(DOB.Text).ToString("MM/dd/yyyy");
                    if (user.writeFile(data, config.folder + "\\login.txt"))
                    {
                        MessageBox.Show(firstNameText.Text + " " + lastNameText.Text + " is Registered", "", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        TextEditor_View text = new TextEditor_View();
                        text.ShowDialog();
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Error in User Registration", "", MessageBoxButtons.OK, MessageBoxIcon.Question);
                }
            }
        }