private void Login()
        {
            SignChatDB db       = new SignChatDB();
            String     username = txt_username.Text;
            String     password = txt_password.Text;
            bool       validate = db.LoginValidation(username, password);

            if (validate)
            {
                FrmHomepage frm = new FrmHomepage(username);
                frm.StartPosition = FormStartPosition.Manual;
                frm.Location      = this.Location;
                this.Visible      = false;
                frm.ShowDialog();
                this.Close();
            }
            else
            {
                MessageBox.Show("Sorry. Invalid Login.", "Login failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        private bool ValidateFormInput()
        {
            bool isValid = true;

            List <Control> controls = new List <Control>();

            controls.Add(txt_username);
            controls.Add(txt_currentPw);
            controls.Add(txt_newPw);
            controls.Add(txt_reTypeNewPw);
            foreach (Control c in controls)
            {
                if (c.Text == "")
                {
                    errorProvider.SetError(c, "Required.");
                    errorProvider.SetIconPadding(c, -20);
                    isValid = false;
                }
                else
                {
                    errorProvider.SetError(c, "");
                }
            }

            if (!db.LoginValidation(adminUsername, txt_currentPw.Text))
            {
                errorProvider.SetError(txt_currentPw, "Invalid password.");
                errorProvider.SetIconPadding(txt_currentPw, -20);
                isValid = false;
            }

            if (txt_newPw.Text != txt_reTypeNewPw.Text)
            {
                errorProvider.SetError(txt_reTypeNewPw, "Does not match with the new password.");
                errorProvider.SetIconPadding(txt_reTypeNewPw, -20);
                isValid = false;
            }

            return(isValid);
        }