private void listViewRealEstateSet_House_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewRealEstateSet_House.SelectedItems.Count == 1)
            {
                RealEstateSet realEstate = listViewRealEstateSet_House.SelectedItems[0].Tag as RealEstateSet;

                textBoxAddress_City.Text         = realEstate.Address_City;
                textBoxAddress_Street.Text       = realEstate.Address_Street;
                textBoxAddress_House.Text        = realEstate.Address_House;
                textBoxAddress_Number.Text       = realEstate.Address_Numder;
                textBoxCoordinate_latitude.Text  = realEstate.Coordinate_latitude.ToString();
                textBoxCoordinate_longitude.Text = realEstate.Coordinate_longitude.ToString();
                textBoxTotalArea.Text            = realEstate.Rooms.ToString();
                textBoxTotalFloors.Text          = realEstate.Floor.ToString();
            }
            else
            {
                textBoxAddress_City.Text         = "";
                textBoxAddress_Street.Text       = "";
                textBoxAddress_House.Text        = "";
                textBoxAddress_Number.Text       = "";
                textBoxCoordinate_latitude.Text  = "";
                textBoxCoordinate_longitude.Text = "";
                textBoxTotalArea.Text            = "";
                textBoxTotalFloors.Text          = "";
                textBoxRooms.Text = "";
                textBoxFloor.Text = "";
            }
        }
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (Квартира.Enabled == false)
            {
                if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
                {
                    RealEstateSet realEstate = listViewRealEstateSet_Apartment.SelectedItems[0].Tag as RealEstateSet;

                    realEstate.Address_City         = textBoxAddress_City.Text;
                    realEstate.Address_Street       = textBoxAddress_Street.Text;
                    realEstate.Address_House        = textBoxAddress_House.Text;
                    realEstate.Address_Numder       = textBoxAddress_Number.Text;
                    realEstate.Coordinate_latitude  = Convert.ToDouble(textBoxCoordinate_latitude.Text);
                    realEstate.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
                    realEstate.TotalArea            = Convert.ToDouble(textBoxTotalArea.Text);
                    realEstate.Rooms = Convert.ToInt32(textBoxRooms.Text);
                    realEstate.Floor = Convert.ToInt32(textBoxFloor.Text);

                    Program.RPE.SaveChanges();
                    ShowRealEstateSet();
                }
            }
            else if (Дом.Enabled == false)
            {
                if (listViewRealEstateSet_House.SelectedItems.Count == 1)
                {
                    RealEstateSet realEstate = listViewRealEstateSet_House.SelectedItems[0].Tag as RealEstateSet;

                    realEstate.Address_City         = textBoxAddress_City.Text;
                    realEstate.Address_Street       = textBoxAddress_Street.Text;
                    realEstate.Address_House        = textBoxAddress_House.Text;
                    realEstate.Address_Numder       = textBoxAddress_Number.Text;
                    realEstate.Coordinate_latitude  = Convert.ToDouble(textBoxCoordinate_latitude.Text);
                    realEstate.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
                    realEstate.TotalArea            = Convert.ToDouble(textBoxTotalArea.Text);

                    Program.RPE.SaveChanges();
                    ShowRealEstateSet();
                }
            }
            else
            {
                if (listViewRealEstateSet_Land.SelectedItems.Count == 1)
                {
                    RealEstateSet realEstate = listViewRealEstateSet_Land.SelectedItems[0].Tag as RealEstateSet;

                    realEstate.Address_City         = textBoxAddress_City.Text;
                    realEstate.Address_Street       = textBoxAddress_Street.Text;
                    realEstate.Address_House        = textBoxAddress_House.Text;
                    realEstate.Address_Numder       = textBoxAddress_Number.Text;
                    realEstate.Coordinate_latitude  = Convert.ToDouble(textBoxCoordinate_latitude.Text);
                    realEstate.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
                    realEstate.TotalArea            = Convert.ToDouble(textBoxTotalArea.Text);
                    realEstate.TotalFloors          = Convert.ToInt32(textBoxTotalFloors.Text);

                    Program.RPE.SaveChanges();
                    ShowRealEstateSet();
                }
            }
        }
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            RealEstateSet realEstate = new RealEstateSet();

            realEstate.Address_City         = textBoxAddress_City.Text;
            realEstate.Address_Street       = textBoxAddress_Street.Text;
            realEstate.Address_House        = textBoxAddress_House.Text;
            realEstate.Address_Numder       = textBoxAddress_Number.Text;
            realEstate.Coordinate_latitude  = Convert.ToDouble(textBoxCoordinate_latitude.Text);
            realEstate.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
            realEstate.TotalArea            = Convert.ToDouble(textBoxTotalArea.Text);


            if (Квартира.Enabled == false)
            {
                realEstate.Rooms = Convert.ToInt32(textBoxRooms.Text);
                realEstate.Floor = Convert.ToInt32(textBoxFloor.Text);

                Program.RPE.RealEstateSet.Add(realEstate);
                Program.RPE.SaveChanges();
            }
            else if (Дом.Enabled == false)
            {
                Program.RPE.RealEstateSet.Add(realEstate);
                Program.RPE.SaveChanges();
            }
            else
            {
                realEstate.TotalFloors = Convert.ToInt32(textBoxTotalFloors.Text);

                Program.RPE.RealEstateSet.Add(realEstate);
                Program.RPE.SaveChanges();
            }
            ShowRealEstateSet();
            textBoxAddress_City.Text         = "";
            textBoxAddress_Street.Text       = "";
            textBoxAddress_House.Text        = "";
            textBoxAddress_Number.Text       = "";
            textBoxCoordinate_latitude.Text  = "";
            textBoxCoordinate_longitude.Text = "";
            textBoxTotalArea.Text            = "";
            textBoxTotalFloors.Text          = "";
            textBoxRooms.Text = "";
            textBoxFloor.Text = "";
        }
        private void buttonDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
                {
                    RealEstateSet realEstate = listViewRealEstateSet_Apartment.SelectedItems[0].Tag as RealEstateSet;

                    Program.RPE.RealEstateSet.Remove(realEstate);

                    Program.RPE.SaveChanges();

                    ShowRealEstateSet();
                }
            }
            catch
            {
                MessageBox.Show("Невозможно удалить, эта запись используется.", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }