private void change_btn_Click(object sender, EventArgs e)
        {
            if (newpassword_txt.Text == confirmpassword_txt.Text)
            {
                checklogin login        = new checklogin();
                bool       isSuccessful = login.CheckLoginCredential(UserUtils.USERNAME.ToString(), oldpassword_txt.Text);
                if (isSuccessful)
                {
                    string query = "update login set password ='******' where username = '******' ";
                    DbConnectionManager dbConnectionManager = new DbConnectionManager();
                    SqlConnection       connection          = dbConnectionManager.connectToDb();

                    SqlCommand command = new SqlCommand(query);
                    command.Connection = connection;
                    int result = command.ExecuteNonQuery();
                    if (result > 0)
                    {
                        MessageBox.Show("Password Successfully Changed");
                    }
                    else
                    {
                        MessageBox.Show("Unable to change password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        dbConnectionManager.diconnectFromDb(connection);
                    }
                }
                else
                {
                    MessageBox.Show("Password do not match", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #2
0
        private void login_button_Click(object sender, EventArgs e)
        {
            {
                if (validate())
                {

                    checklogin login = new checklogin();
                    bool isSuccessful = login.CheckLoginCredential(username_txtbox.Text, password_txtbox.Text);

                    if (isSuccessful)
                    {
                        alert.Text = "";
                        UserUtils.USERNAME = username_txtbox.Text;
                        MessageBox.Show("Welcome to the system!", "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MainWindow newfrom = new MainWindow();
                        newfrom.Show();
                        this.Hide();
                    }
                    else
                    {
                        alert.Text = "Wrong credentials";

                    }
                }
            }
        }
        private void change_btn_Click(object sender, EventArgs e)
        {
            if (newpassword_txt.Text == confirmpassword_txt.Text)
            {
                 checklogin login = new checklogin();
                bool isSuccessful = login.CheckLoginCredential(UserUtils.USERNAME.ToString(), oldpassword_txt.Text);
                if (isSuccessful)
                {
                    string query = "update login set password ='******' where username = '******' ";
                     DbConnectionManager dbConnectionManager= new DbConnectionManager ();
                    SqlConnection connection=dbConnectionManager.connectToDb();

                    SqlCommand command = new SqlCommand(query);
                    command.Connection = connection;
                    int result = command.ExecuteNonQuery();
                    if (result > 0)
                    {
                        MessageBox.Show("Password Successfully Changed");
                    }
                    else
                    {
                        MessageBox.Show("Unable to change password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            dbConnectionManager.diconnectFromDb(connection);

                }
            }
            else
            {
                MessageBox.Show("Password do not match", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            }
        }
Example #4
0
        private void login_button_Click(object sender, EventArgs e)
        {
            {
                if (validate())
                {
                    checklogin login        = new checklogin();
                    bool       isSuccessful = login.CheckLoginCredential(username_txtbox.Text, password_txtbox.Text);

                    if (isSuccessful)
                    {
                        alert.Text         = "";
                        UserUtils.USERNAME = username_txtbox.Text;
                        MessageBox.Show("Welcome to the system!", "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MainWindow newfrom = new MainWindow();
                        newfrom.Show();
                        this.Hide();
                    }
                    else
                    {
                        alert.Text = "Wrong credentials";
                    }
                }
            }
        }