Example #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUsername.Text != "" &&
                txtPassword.Text != "")
            {
                int error = _controller.Authenticate(txtUsername.Text, txtPassword.Text);

                if (error == 0)
                {
                    // Save username and if should remember
                    Properties.Settings.Default.ShouldRemember = chkRemember.Checked;
                    Properties.Settings.Default.Username       = chkRemember.Checked ? txtUsername.Text : "";
                    Properties.Settings.Default.MineSite       = chkRemember.Checked ? (int)cboMineSites.SelectedValue : -1;

                    Properties.Settings.Default.Save();

                    _controller.OpenMainForm((int)cboMineSites.SelectedValue);
                }
                else if (error == 1)
                {
                    MessageBox.Show("Invalid username", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (error == 2)
                {
                    MessageBox.Show("Invalid password", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #2
0
        private void btnNewPass_Click(object sender, EventArgs e)
        {
            if (txtCNP.Text.Equals(txtNPW.Text))
            {
                if (_controller.Authenticate(User.GetInstance().username, txtOPW.Text) == 0)
                {
                    bool didSucceed = _controller.UserPasswordUpdate(txtNPW.Text);

                    if (didSucceed)
                    {
                        btnSave.Enabled = false;

                        MessageBox.Show("You've successfully changed Your password.", "Password Changed", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        chkPW.Checked = false;
                        txtOPW.Text   = "";
                        txtNPW.Text   = "";
                        txtCNP.Text   = "";
                    }
                    else
                    {
                        MessageBox.Show("Password could not be changed", "Password Change Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }