Beispiel #1
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            _connection = DB_Connect.connect();

            _connection.Open();
            var sqlQuery = @"DELETE FROM[Users] WHERE[UserName] = '" + UNcb.Text + "'";

            _command = new SqlCommand(sqlQuery, _connection);
            _command.ExecuteNonQuery();
            _connection.Close();

            UNcb.Focus();
            LoadData();
        }
Beispiel #2
0
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            var error = "Password entered is too short. Please enter a password with 6 characters or more.";

            _connection = DB_Connect.connect();
            _connection.Open();

            if (PWTextBox.Text.Length > 1 && PWTextBox.Text.Length < 6)
            {
                MessageBox.Show(error);
            }
            else
            {
                var sqlQuery = @"UPDATE[Users] SET[Password] = '" + PWTextBox.Text + "', [AccessLevel] = '" + ALcb.Text + "' , [Department] = '" + DEPcb.Text + "' WHERE[UserName] = '" + UNcb.Text + "'";
                UNcb.Focus();
                _command = new SqlCommand(sqlQuery, _connection);
                _command.ExecuteNonQuery();
                _connection.Close();
                LoadData();
            }
        }