Example #1
0
        private void UpdateAccount_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (tbUserID.Text == "" || tbPassword.Text == "" || tbConfirmPassword.Text == "")
            {
                MessageBox.Show("Please fill in all the required fields !", "Required Fields", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ReqID.Visible          = true;
                ReqPassword.Visible    = true;
                ReqConPassword.Visible = true;
            }
            else if (tbPassword.Text != tbConfirmPassword.Text)
            {
                MessageBox.Show("Oops ! The passwords you have entered did not match");
            }
            else
            {
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    //      string testUsername = row.Cells[0].Value.ToString();
                    //      string testPassword = row.Cells[6].Value.ToString();
                    try
                    {
                        if (tbUserID.Text == row.Cells[0].Value.ToString())
                        {
                            if (row.Cells[6].Value.ToString().Contains(tbPassword.Text))
                            {
                                SetValueForUserID = tbUserID.Text;
                                DialogResult result = MessageBox.Show("Your account details are currently saved as the following :", "Success ! Access Granted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                if (result == DialogResult.OK)
                                {
                                    EditAccount edit = new EditAccount();
                                    edit.Show();
                                    refreshPage();
                                    break;
                                }
                                else
                                {
                                    this.Close();
                                }
                            }
                            else
                            {
                                DialogResult result4 = MessageBox.Show("Please enter a Valid Account to edit or refer to the forgot ID or forgot Password link", "Unsuccesfull, Access Denied", MessageBoxButtons.RetryCancel);
                                if (result4 == DialogResult.Retry)
                                {
                                    tbUserID.Focus();
                                    break;
                                }
                                if (result4 == DialogResult.Cancel)
                                {
                                    refreshPage();
                                }
                            }
                        }


                        else
                        {
                            DialogResult result2 = MessageBox.Show("The System ID or Password you have entered does not exist", "Unsuccesfull Login", MessageBoxButtons.OK);
                            if (result2 == DialogResult.OK)
                            {
                                break;
                            }
                        }
                    }
                    catch (System.NullReferenceException)
                    {
                        System.NullReferenceException nullex = new System.NullReferenceException("Account not found");
                        throw nullex;
                    }
                }
            }
        }
        private void btnChange_Click(object sender, EventArgs e)
        {
            EditAccount edit = new EditAccount();

            edit.Show();
        }