While anesthesia is given to a patient what changes in the chemistry of brain happens. Which part of the brain is affected by the medicine which causes anesthetic effects. Can anesthesia be considered as sleep+painless state of body? Or is it more than that.
General anesthesia is a reversible drug-induced neurophysiological state comprised of unconsciousness, amnesia, analgesia, and immobility with maintenance of physiological stability. How anesthetic drugs create the state of general anesthesia is still not completely understood, but general anesthesia is essential for the safe and humane conduct of surgical and invasive diagnostic procedures.
The goals of general anesthesia include amnesia, analgesia, unconsciousness, and immobilization. The ability of general anesthetics to produce these distinct therapeutic endpoints is not equal. For example, explicit memory is the most sensitive target of inhaled general anesthetics; consciousness (assessed by appropriate response to spoken commands) is preserved in the absence of memory during exposure to low doses; and unconsciousness is produced by lower concentrations of most general anesthetics than those that ablate movement in response to noxious stimuli. 
General anesthetics consist of many different drugs. [2,3] These different drugs display distinct relative potencies in their ability to produce different components of general anesthesia. For example, the ratio of the drug concentration producing immobility during incision to that producing unconsciousness is 1.5 for nitrous oxide, about 3 for most of the inhaled halogenated ether, and over 4 for the intravenous anesthetic propofol. They also have different effects on EEG during anesthesia. Thus, clinically, general anesthetics can be classified into 3 groups based on their relative potencies for different clinical endpoints and their impact on EEG:
Group 1 consists of etomidate, propofol, methoxital, and barbiturates. These are intravenous drugs that are much more potent at producing unconsciousness than immobilization and shift cortical EEG toward lower frequencies. Their effects are mediated mainly by a subset of γ-aminobutyric acid type A (GABA-A) receptors, which, when activated, reduce neuronal excitation.
Group 2 includes the gaseous anesthetics nitrous oxide (N2O), xenon (Xe) and cyclopropane, along with an intravenous agent, ketamine. Clinically, these drugs produce significant analgesia, while their potency as hypnotics and immobilizers are relatively weak, and they may increase cortical EEG frequencies. Anesthetic agents in this group have little or no effect on GABA-A receptors, but they instead potently inhibit N-methyl-D-aspartate (NMDA) receptors, which are excitatory cation channels activated by the amino acid glutamate. In addition, agents in this group also inhibit α4β2 neuronal nicotinic acetylcholine receptors, which modulate synaptic release of neurotransmitters.
Group 3 consists of the volatile halogenated anesthetics: halothane, enflurane, isoflurane, sevoflurane, and desflurane. These drugs induce amnesia, hypnosis, and immobility in a predictable manner and reduce the spectral edge frequency of cortical EEG. General anesthetics in this group lack significant selectivity for general anesthetic target molecules. They enhance the function of inhibitory GABA-A and glycine receptors while also activating 2P potassium channels and inhibiting excitatory glutamate receptors and a variety of excitatory cation channels.
Group 1 and Group 3 drugs that act by enhancing GABA-A receptor activity in various neural circuits appear to impair both unconscious and conscious processing, including associative cortex and synchronous integration among multiple cortical areas. Cortical EEG activity shifts toward lower frequencies in the presence of these drugs, and large doses can lead to the total loss of coordinated neural activity (iso-electric EEG). On the other hand, Group 2 drugs such as ketamine and nitrous oxide appear to act by impairing signal filtration to the consciousness, perhaps altering the amounts or intensities of sensory inputs, or by allowing leakage of unconscious signals into conscious processing. This lack of filtering “jams” or overwhelms the consciousness with signals, leading to a “dissociative” state, frequently associated with reports of vivid dreamlike experiences.
Therefore, while being under general anesthesia, the brain is still functioning, but it is functioning differently from when it is awake or sleeping.  Neural circuits that are responsible for consciousness, sensation perception, memory, and motor are not functioning as they do when being awake or sleeping. For different general anesthetics, different effects on neruotransmitter receptors and neural circuits are different; thus, various neural circuits in the different areas of the brain are affected differently, and the whole brain will function in different unconscious states even though, outwardly, the anesthetic patients appear to be in similar unconscious states. Also, for different dosages of the same anesthetics, overall neural circuits are affected differently, and the brain in different anesthetic stages will function differently too.
N.B. The above is a simplified answer about the complex actions of general anesthetics. More details can be found in the following references.
Akeju O, Brown EN. Neural oscillations demonstrate that general anesthesia and sedative states are neurophysiologically distinct from sleep. Curr Opin Neurobiol. 2017 Jun; 44: 178–185.
Forman SA, Chin VA. General Anesthetics and Molecular Mechanisms of Unconsciousness. Int Anesthesiol Clin. 2008 Summer; 46(3): 43–53.doi: 10.1097/AIA.0b013e3181755da5
Brown EN, Purdon PL, Van Dort CJ. General Anesthesia and Altered States of Arousal: A Systems Neuroscience Analysis. Annu Rev Neurosci. 2011; 34: 601–628.doi: 10.1146/annurev-neuro-060909-153200
Müller CP, Pum ME, Amato D, Schüttler J, Huston JP, Silva MA.The in vivo neurochemistry of the brain during general anesthesia. J. Neurochem. (2011) 119, 419–446. https://doi.org/10.1111/j.1471-4159.2011.07445.x
General anesthesia is a drug-induced reversible state defined by five end points: Unconsciousness, lack of awareness of sensory input Analgesia, lack of pain Akinesia, lack of movement Amnesia, lack of recall Physiological stability, the preservation of normal levels of all vital physiological functions, such as respiration, heart rate, blood pressure, and temperature E.N. Brown et al., “General anesthesia, sleep and coma,” New Engl J Med, 363:2638–50, 2010.
Some anesthetics, such as ketamine, which was synthesized in 1962, and nitrous oxide block the channel of the N-methyl D-aspartate (NMDA) glutamate receptor. Normally activated by the neurotransmitter glutamate released from excitatory neurons, the NMDA receptor allows the flow of potassium ions out of the cell and allows calcium and sodium ions in, increasing the relative voltage of the neuron’s interior and thereby increasing the probability of firing an action potential. Anesthetic drugs that target this receptor act as antagonists to block these ions fluxes, decreasing the ability of the cell to fire. This then produces an anesthetic-induced oscillation, which alters when neurons can spike, and impede communication between brain regions that play a role in consciousness. Research (done with an fMRI) suggests that all the regions of the brain relevant to the maintenance of anesthesia are already affected at 0.5–0.7 MAC. This would therefore mean that anesthesia, while it does "put you to sleep," your body is more in an in-between stage, where you are alive, but in a comatose state. During sleep, a body still moves, and can still remember things, such as dreams. However, whilst under the anesthesia, neither of these actions occur. Hope this helps!