The widespread use of electric vehicles is a suitable solution to deal with the reduction of fossil fuel reserves and the increase in air pollution. Reducing pollution can be realized through optimal planning of charging and discharging of electric vehicles as consumers and storage of electric energy. Also, vehicles connected to the network increase the reliability of the network during power outages. However, the connection of electric vehicles to the grid can also bring limitations. The uncoordinated and unmanaged presence of electric vehicles as an additional load in the network can aggravate problems such as voltage drop, voltage stability and increase in network losses. Consequently, these problems will have economic costs. In this way, the management of charging and discharging of electric vehicles will be of special importance in the future of control and operation of distribution networks. In this article, electric vehicle charging and discharging management has been done in order to minimize the amount of active power loss, bus voltage deviation, increase the stability of the network voltage, and as a result, reduce the costs of the distribution company. For this purpose, a 33-bus distribution network that absorbed its required energy only through the connection point to the network was studied with different scenarios in which the objective function of the problem was different. The proposed algorithm was implemented to calculate the best state of charging and discharging of cars. In choosing these vehicles, it has been tried to examine all charging modes. The simulation results show the effectiveness of the proposed plan for planning the development of electric vehicles in the distribution network.