Example #1
0
        public void SignIn(object sender, EventArgs e)
        {
            Member member = new Member();

            if (!IsEmpty(txtUsername.Text))
            {
                member.Username = txtUsername.Text;
            }

            if (!InvalidInt(txtPIN.Text))
            {
                member.PIN = Convert.ToInt32(txtPIN.Text);
            }

            if (MemberDB.IsMember(member))
            {
                if (MemberDB.LogIn(member))
                {
                    Member dbMember =
                        CurrentMember.GetCurrentMember();

                    if (chkAdmin2.Checked is true &&
                        dbMember.IsAdmin is true)
                    {
                        this.Hide();

                        FrmAdmin addAdminForm =
                            new FrmAdmin();

                        addAdminForm.ShowDialog();

                        this.Close();
                    }
                    else
                    {
                        this.Hide();

                        FrmLibrary addLibraryForm =
                            new FrmLibrary();

                        addLibraryForm.ShowDialog();

                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("PIN incorrect. Try again.");
                }
            }
Example #2
0
        public void Register(object sender, EventArgs e)
        {
            Member member = new Member();

            if (SubmissionCorrect())
            {
                member.MemberID = MemberDB.CreateMemberID();

                member.Username = txtUsername2.Text;

                member.PIN = Convert.ToInt32(txtPIN2.Text);

                member.LastName = txtLastName.Text;

                member.FirstName = txtFirstName.Text;

                if (chkAdmin.Checked is true)
                {
                    member.IsAdmin = true;
                }

                if (MemberDB.IsMember(member))
                {
                    MessageBox.Show("Already a member. Sign-in below.");
                }
                else
                {
                    if (MemberDB.Register(member))
                    {
                        MessageBox.Show("Registration successful.");
                    }
                    else
                    {
                        MessageBox.Show("Registration failed. Try again.");
                    }
                }
            }
            else
            {
                MessageBox.Show("Incorrect submission. " +
                                "Please try again.");
            }

            Clear();
        }