Rule 1: With the verb to be and auxiliary verbs such as can and may, you place that verb at the beginning of a question. In a negative sentence, you place not/n’t after that verb.
Rule 2: With any other main verb, you add the verb to do. You place a form of to do at the beginning of a question. In a negative sentence, you place not/n’t after a form of to do. The main verb changes to the infinitive.
Tenses other than the present and past simple always have an auxiliary verb, such as to be in the present continuous and to have in the present perfect. To make questions and negations in these tenses, you always use Rule 1.