private void buttonAdd_Click(object sender, EventArgs e)
        {
            RealEstateSet realEstate = new RealEstateSet();

            realEstate.Adress_City            = textBoxAdress_City.Text;
            realEstate.Adress_Street          = textBoxAdress_Street.Text;
            realEstate.Adress_House           = textBoxAdress_House.Text;
            realEstate.Adress_Number          = textBoxAdress_Number.Text;
            realEstate.Coordinate_latitude    = Convert.ToDouble(textBoxCoordinate_latitude.Text);
            realEstate.Coordinate_longtitiude = Convert.ToDouble(textBoxCoordinate_longtitude.Text);
            realEstate.TotalArea = Convert.ToDouble(textBoxTotalArea.Text);

            if (comboBoxType.SelectedIndex == 0)
            {
                realEstate.Type  = 0;
                realEstate.Rooms = Convert.ToInt32(textBoxRooms.Text);
                realEstate.Floor = Convert.ToInt32(textBoxFloor.Text);
            }
            else if (comboBoxType.SelectedIndex == 1)
            {
                realEstate.Type        = 1;
                realEstate.TotalFloors = Convert.ToInt32(textBoxTotalFloors);
            }
            else
            {
                realEstate.Type = 2;
            }
            Program.eSoftDB.RealEstateSet.Add(realEstate);
            Program.eSoftDB.SaveChanges();
            ShowRealEstateSet();
        }
示例#2
0
 private void listViewRealEstateSet_Land_SelectedIndexChanged(object sender, EventArgs e)
 {
     //если выбран один элемент
     if (listViewRealEstateSet_Land.SelectedItems.Count == 1)
     {
         RealEstateSet realEstate = listViewRealEstateSet_Land.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_Number;
         textBoxCoordinate_latitude.Text   = realEstate.Coordinate_latitude.ToString();
         textBoxCoordinate_longtitude.Text = realEstate.Coordinate_longtitude.ToString();
         textBoxTotalArea.Text             = realEstate.TotalArea.ToString();
     }
     else
     {
         //если не выбран ни один элемент, задаём пустые строки
         textBoxAddress_City.Text          = "";
         textBoxAddress_House.Text         = "";
         textBoxAddress_Number.Text        = "";
         textBoxAddress_Street.Text        = "";
         textBoxCoordinate_latitude.Text   = "";
         textBoxCoordinate_longtitude.Text = "";
         textBoxTotalArea.Text             = "";
     }
 }
示例#3
0
 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_House.Text        = realEstate.Address_House;
         textBoxAddress_Street.Text       = realEstate.Address_Street;
         textBoxAddress_Number.Text       = realEstate.Address_Number;
         textBoxCoordinate_latitude.Text  = realEstate.Coordinate_Latitude.ToString();
         textBoxCoordinate_longitude.Text = realEstate.Coordinate_Longitude.ToString();
         textBoxTotalArea.Text            = realEstate.TotalArea.ToString();
     }
     else
     {
         //Если ничего не выбрано, очищаем поля
         textBoxAddress_City.Text         = "";
         textBoxAddress_House.Text        = "";
         textBoxAddress_Street.Text       = "";
         textBoxAddress_Number.Text       = "";
         textBoxCoordinate_latitude.Text  = "";
         textBoxCoordinate_longitude.Text = "";
         textBoxTotalArea.Text            = "";
     }
 }
示例#4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     if (comboBoxType.SelectedIndex == 0)
     {
         if (listViewApartament.SelectedItems.Count == 1)
         {
             RealEstateSet realEstateSet = listViewApartament.SelectedItems[0].Tag as RealEstateSet;
             Program.wftDb.RealEstateSet.Remove(realEstateSet);
             Program.wftDb.SaveChanges();
             ShowRealEstatesSet();
         }
     }
     else if (comboBoxType.SelectedIndex == 1)
     {
         if (listViewHouse.SelectedItems.Count == 1)
         {
             RealEstateSet realEstateSet = listViewHouse.SelectedItems[0].Tag as RealEstateSet;
             Program.wftDb.RealEstateSet.Remove(realEstateSet);
             Program.wftDb.SaveChanges();
             ShowRealEstatesSet();
         }
     }
     else if (comboBoxType.SelectedIndex == 2)
     {
         if (listViewLand.SelectedItems.Count == 1)
         {
             RealEstateSet realEstateSet = listViewLand.SelectedItems[0].Tag as RealEstateSet;
             Program.wftDb.RealEstateSet.Remove(realEstateSet);
             Program.wftDb.SaveChanges();
             ShowRealEstatesSet();
         }
     }
 }
示例#5
0
 private void ListViewRealEstateSet_Land_SelectedIndexChanged(object sender, EventArgs e)
 {
     //если выбран 1 элемент
     if (listViewRealEstateSet_Land.SelectedItems.Count == 1)
     {
         //ищем элемент из таблицы по тегу
         RealEstateSet realEstate = listViewRealEstateSet_Land.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_Number;
         textBoxCoordinate_latitude.Text  = realEstate.Coordinate_latitude.ToString();
         textBoxCoordinate_longitude.Text = realEstate.Coordinate_longitude.ToString();
         textBoxTotalArea.Text            = realEstate.TotalArea.ToString();
     }
     else
     {
         //если не выбран ни один элемент, задаём пустые поля
         textBoxAddress_City.Text         = "";
         textBoxAddress_Street.Text       = "";
         textBoxAddress_House.Text        = "";
         textBoxAddress_Number.Text       = "";
         textBoxCoordinate_latitude.Text  = "";
         textBoxCoordinate_longitude.Text = "";
         textBoxTotalArea.Text            = "";
     }
 }
示例#6
0
 private void listView2_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
     {
         RealEstateSet realEstate = listViewRealEstateSet_Apartment.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_Number;
         textBoxCoordinate_Latitude.Text  = realEstate.Coordinate_latitude.ToString();
         textBoxCoordinate_Longitude.Text = realEstate.Coordinate_longitude.ToString();
         textBoxTotalArea.Text            = realEstate.TotalArea.ToString();
         textBoxRooms.Text      = realEstate.Rooms.ToString();
         textBoxTotalFloor.Text = realEstate.TotalFloors.ToString();
     }
     else
     {
         textBoxAddress_City.Text         = "";
         textBoxAddress_Street.Text       = "";
         textBoxAddress_House.Text        = "";
         textBoxAddress_Number.Text       = "";
         textBoxCoordinate_Latitude.Text  = "";
         textBoxCoordinate_Longitude.Text = "";
         textBoxTotalArea.Text            = "";
         textBoxRooms.Text      = "";
         textBoxTotalFloor.Text = "";
     }
 }
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (comboBoxType.SelectedIndex == 0)
            {
                if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
                {
                    RealEstateSet realEstateSet = listViewRealEstateSet_Apartment.SelectedItems[0].Tag as RealEstateSet;
                    realEstateSet.Address_City         = textBoxAddress_City.Text;
                    realEstateSet.Address_House        = textBoxAddress_House.Text;
                    realEstateSet.Address_Street       = textBoxAddress_Street.Text;
                    realEstateSet.Address_Number       = textBoxAddress_Number.Text;
                    realEstateSet.Coordinate_latitude  = Convert.ToDouble(textBoxCoordinate_latitude.Text);
                    realEstateSet.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
                    realEstateSet.TotalArea            = Convert.ToDouble(textBoxTotalArea.Text);
                    realEstateSet.Rooms = Convert.ToInt32(textBoxRooms.Text);
                    realEstateSet.Floor = Convert.ToInt32(textBoxFloor.Text);

                    Program.wftDb.SaveChanges();
                    ShowRealEstateSet();
                }
            }
            else if (comboBoxType.SelectedIndex == 1)
            {
                if (listViewRealEstateSet_House.SelectedItems.Count == 1)
                {
                    RealEstateSet realEstateSet = listViewRealEstateSet_House.SelectedItems[0].Tag as RealEstateSet;
                    realEstateSet.Address_City         = textBoxAddress_City.Text;
                    realEstateSet.Address_House        = textBoxAddress_House.Text;
                    realEstateSet.Address_Street       = textBoxAddress_Street.Text;
                    realEstateSet.Address_Number       = textBoxAddress_Number.Text;
                    realEstateSet.Coordinate_latitude  = Convert.ToDouble(textBoxCoordinate_latitude.Text);
                    realEstateSet.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
                    realEstateSet.TotalArea            = Convert.ToDouble(textBoxTotalArea.Text);
                    realEstateSet.TotalFloors          = Convert.ToInt32(textBoxToyalFloors.Text);

                    Program.wftDb.SaveChanges();
                    ShowRealEstateSet();
                }
            }
            else
            {
                if (listViewRealEstateSet_Land.SelectedItems.Count == 1)
                {
                    RealEstateSet realEstateSet = listViewRealEstateSet_Land.SelectedItems[0].Tag as RealEstateSet;
                    realEstateSet.Address_City         = textBoxAddress_City.Text;
                    realEstateSet.Address_House        = textBoxAddress_House.Text;
                    realEstateSet.Address_Street       = textBoxAddress_Street.Text;
                    realEstateSet.Address_Number       = textBoxAddress_Number.Text;
                    realEstateSet.Coordinate_latitude  = Convert.ToDouble(textBoxCoordinate_latitude.Text);
                    realEstateSet.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
                    realEstateSet.TotalArea            = Convert.ToDouble(textBoxTotalArea.Text);

                    Program.wftDb.SaveChanges();
                    ShowRealEstateSet();
                }
            }
        }
示例#8
0
 private void listViewLand_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewLand.SelectedItems.Count == 1)
     {
         RealEstateSet realEstate = listViewLand.SelectedItems[0].Tag as RealEstateSet;
         textBoxTotalArea.Text      = realEstate.TotalArea.ToString();
         textBoxAdress_City.Text    = realEstate.Address_City;
         textBoxAddress_Street.Text = realEstate.Address_Street;
         textBoxLatitude.Text       = realEstate.Coordinate_latitude.ToString();
         textBoxLongtitude.Text     = realEstate.Coordinate_longitude.ToString();
     }
 }
示例#9
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            RealEstateSet realEstateSet = new RealEstateSet();

            realEstateSet.Address_City   = textBoxAddress_City.Text;
            realEstateSet.Address_Street = textBoxAddress_Street.Text;
            realEstateSet.Address_House  = textBoxAddress_House.Text;
            realEstateSet.Address_Number = textBoxAddress_Number.Text;
            Program.bazadb.RealEstateSet.Add(realEstateSet);
            Program.bazadb.SaveChanges();
            ShowClient();
            ShowRealEstateSet();
        }
示例#10
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            RealEstateSet realEstateSet = new RealEstateSet();

            realEstateSet.Type           = comboBoxType.SelectedIndex;
            realEstateSet.Address_City   = textBoxAdress_City.Text;
            realEstateSet.Address_Street = textBoxAddress_Street.Text;
            if (textBoxLongtitude.Text != "")
            {
                realEstateSet.Coordinate_longitude = Convert.ToDouble(textBoxLongtitude.Text);
            }
            if (textBoxLatitude.Text != "")
            {
                realEstateSet.Coordinate_latitude = Convert.ToDouble(textBoxLatitude.Text);
            }
            if (textBoxTotalArea.Text != "")
            {
                realEstateSet.TotalArea = Convert.ToDouble(textBoxTotalArea.Text);
            }
            if (comboBoxType.SelectedIndex == 0)
            {
                realEstateSet.Address_House  = textBoxAddress_House.Text;
                realEstateSet.Address_Number = textBoxAddress_Number.Text;
                if (textBoxFloors_Number.Text != "")
                {
                    realEstateSet.TotalFloors = Convert.ToInt32(textBoxFloors_Number.Text);
                }
                if (textBoxFloor.Text != "")
                {
                    realEstateSet.Floor = Convert.ToInt32(textBoxFloor.Text);
                }
                if (textBoxRooms.Text != "")
                {
                    realEstateSet.Rooms = Convert.ToInt32(textBoxRooms.Text);
                }
            }
            else if (comboBoxType.SelectedIndex == 1)
            {
                realEstateSet.Address_House  = textBoxAddress_House.Text;
                realEstateSet.Address_Number = textBoxAddress_Number.Text;
                if (textBoxRooms.Text != "")
                {
                    realEstateSet.Rooms = Convert.ToInt32(textBoxRooms.Text);
                }
            }
            Program.wftDb.RealEstateSet.Add(realEstateSet);
            Program.wftDb.SaveChanges();
            ShowRealEstatesSet();
        }
示例#11
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            //Широта и долгота
            double latitude  = Convert.ToDouble(textBoxCoordinate_latitude.Text);
            double longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);

            //Они должны быть в пределах -90 до +90 и -180 до +180 соответственно
            if (((-90.0 <= latitude) && (latitude <= 90.0)) && ((-180.0 <= latitude) && (latitude <= 180.0)))
            {
                //Новый экземпляр класса Объект недвижимости
                RealEstateSet realEstate = new RealEstateSet();
                //Заполняем его значениями из textbox-ов(общее)
                realEstate.Address_City         = textBoxAddress_City.Text;
                realEstate.Address_House        = textBoxAddress_House.Text;
                realEstate.Address_Street       = textBoxAddress_Street.Text;
                realEstate.Address_Number       = 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 (comboBoxType.SelectedIndex == 0)
                {
                    realEstate.Type  = 0;
                    realEstate.Rooms = Convert.ToInt32(textBoxRooms.Text);
                    realEstate.Floor = Convert.ToInt32(textBoxFloor.Text);
                }
                //Дополнительные поля типа Дом
                else if (comboBoxType.SelectedIndex == 1)
                {
                    realEstate.Type        = 1;
                    realEstate.TotalFloors = Convert.ToInt32(textBoxTotalFloors.Text);
                }
                //Дополнительные поля типа Земля
                else if (comboBoxType.SelectedIndex == 2)
                {
                    realEstate.Type = 2;
                }
                //Добавляем новый объект недвижимости realEstate в таблицу RealEstateSet
                Program.wftDB.RealEstateSet.Add(realEstate);
                //Сохраняем изменения
                Program.wftDB.SaveChanges();
                ShowRealEstateSet();
            }
            else
            {
                MessageBox.Show("Широта и долгота должны быть в пределах -90 до +90 и -180 до +180 соответственно", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#12
0
 private void listViewHouse_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewHouse.SelectedItems.Count == 1)
     {
         RealEstateSet realEstate = listViewHouse.SelectedItems[0].Tag as RealEstateSet;
         textBoxAddress_House.Text  = realEstate.Address_House;
         textBoxAdress_City.Text    = realEstate.Address_City;
         textBoxTotalArea.Text      = realEstate.TotalArea.ToString();
         textBoxAddress_Street.Text = realEstate.Address_Street;
         textBoxFloors_Number.Text  = realEstate.TotalFloors.ToString();
         textBoxLatitude.Text       = realEstate.Coordinate_latitude.ToString();
         textBoxLongtitude.Text     = realEstate.Coordinate_longitude.ToString();
         textBoxRooms.Text          = realEstate.Rooms.ToString();
         comboBoxType.Text          = realEstate.Type.ToString();
     }
 }
示例#13
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
         {
             RealEstateSet realEstateSet = listViewRealEstateSet_Apartment.SelectedItems[0].Tag as RealEstateSet;
             Program.bazadb.RealEstateSet.Remove(realEstateSet);
             Program.bazadb.SaveChanges();
             ShowClient();
         }
         textBoxAddress_City.Text   = "";
         textBoxAddress_Street.Text = "";
         textBoxAddress_House.Text  = "";
         textBoxAddress_Number.Text = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#14
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            //Создаём новый экземпляр класс Объект недвижимости
            RealEstateSet realEstate = new RealEstateSet();

            //Делаем ссылку на объект, который хранится в texBo-ах (сначала общие поля)
            realEstate.Address_City         = textBoxAddress_City.Text;
            realEstate.Address_House        = textBoxAddress_House.Text;
            realEstate.Address_Street       = textBoxAddress_Street.Text;
            realEstate.Address_Number       = 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 (comboBoxType.SelectedIndex == 0)
            {
                realEstate.Type  = 0;
                realEstate.Rooms = Convert.ToInt32(textBoxRooms.Text);
                realEstate.Floor = Convert.ToInt32(textBoxFloor.Text);
            }
            //Дополнительные поля для типа "Дом"
            else if (comboBoxType.SelectedIndex == 1)
            {
                realEstate.Type        = 1;
                realEstate.TotalFloors = Convert.ToInt32(textBoxTotalFloors.Text);
            }

            //Дополнительные поля для типа "Земли"
            else
            {
                realEstate.Type = 2;
            }
            //Добавляем в таблицу RealEstateSet новый объект недвижимости realEstate
            Program.wftDb.RealEstateSet.Add(realEstate);
            //Сохраняем изменение в модели wftDb
            Program.wftDb.SaveChanges();
            ShowRealEstateSet();
        }
示例#15
0
 private void listViewRealEstateSet_Land_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewRealEstateSet_Land.SelectedItems.Count == 1)
     {
         RealEstateSet realEstateSet = listViewRealEstateSet_Land.SelectedItems[0].Tag as RealEstateSet;
         textBoxAddress_City.Text         = realEstateSet.Address_City;
         textBoxAddress_House.Text        = realEstateSet.Address_House;
         textBoxAddress_Number.Text       = realEstateSet.Address_Number;
         textBoxAddress_Street.Text       = realEstateSet.Address_Street;
         textBoxCoordinate_longitude.Text = Convert.ToString(realEstateSet.Coordinate_longitude);
         textBoxCoordinate_latitude.Text  = Convert.ToString(realEstateSet.Coordinate_latitude);
         textBoxTotalArea.Text            = Convert.ToString(realEstateSet.TotalArea);
     }
     else
     {
         textBoxAddress_City.Text         = "";
         textBoxAddress_House.Text        = "";
         textBoxAddress_Number.Text       = "";
         textBoxAddress_Street.Text       = "";
         textBoxCoordinate_latitude.Text  = "";
         textBoxCoordinate_longitude.Text = "";
         textBoxTotalArea.Text            = "";
     }
 }
示例#16
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         RealEstateSet realEstate = new RealEstateSet();
         if (textBoxAddress_City.Text != "")
         {
             realEstate.Address_City = textBoxAddress_City.Text;
         }
         if (textBoxAddress_House.Text != "")
         {
             realEstate.Address_House = textBoxAddress_House.Text;
         }
         if (textBoxAddress_Street.Text != "")
         {
             realEstate.Address_Street = textBoxAddress_Street.Text;
         }
         if (textBoxAddress_Number.Text != "")
         {
             realEstate.Address_Number = textBoxAddress_Number.Text;
         }
         if (textBoxCoordinate_latitude.Text != "")
         {
             realEstate.Coordinate_latitude = Convert.ToDouble(textBoxCoordinate_latitude.Text);
         }
         if (textBoxCoordinate_longitude.Text != "")
         {
             realEstate.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
         }
         if (textBoxTotalArea.Text != "")
         {
             realEstate.TotalArea = Convert.ToDouble(textBoxTotalArea.Text);
         }
         if (comboBoxType.SelectedIndex == 0)
         {
             realEstate.Type = 0;
             if (textBoxRooms.Text != "")
             {
                 realEstate.Rooms = Convert.ToInt32(textBoxRooms.Text);
             }
             if (textBoxFloor.Text != "")
             {
                 realEstate.Floor = Convert.ToInt32(textBoxFloor.Text);
             }
         }
         else if (comboBoxType.SelectedIndex == 1)
         {
             realEstate.Type = 1;
             if (textBoxTotalFloors.Text != "")
             {
                 realEstate.TotalFloors = Convert.ToInt32(textBoxTotalFloors.Text);
             }
         }
         else
         {
             realEstate.Type = 2;
         }
         if (textBoxCoordinate_latitude.Text != "")
         {
             realEstate.Coordinate_latitude = Convert.ToDouble(textBoxCoordinate_latitude.Text);
         }
         if ((realEstate.Coordinate_latitude < -90) || (realEstate.Coordinate_latitude > 90))
         {
             throw new Exception("Диапазон широты от -90 до 90" + "\n" + "Диапазон долготы от - 180 до 180");
         }
         if (textBoxCoordinate_longitude.Text != "")
         {
             realEstate.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
         }
         if ((realEstate.Coordinate_longitude < -90) || (realEstate.Coordinate_longitude > 90))
         {
             throw new Exception("Диапазон широты от -90 до 90" + "\n" + "Диапазон долготы от - 180 до 180");
         }
         Program.wftDb.RealEstateSet.Add(realEstate);
         Program.wftDb.SaveChanges();
         ShowRealEstateSet();
     }
     catch (Exception expection)
     { MessageBox.Show(expection.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); }
 }
示例#17
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     //Пробуем удалить
     try
     {
         //Если выбрана Квартира
         if (comboBoxType.SelectedIndex == 0)
         {
             //И выбран элемент списка
             if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
             {
                 //Ищем элемент из таблицы по тегу
                 RealEstateSet realEstate = listViewRealEstateSet_Apartment.SelectedItems[0].Tag as RealEstateSet;
                 //И удаляем его из базы данных
                 Program.wftDB.RealEstateSet.Remove(realEstate);
                 //Сохраняем изменения
                 Program.wftDB.SaveChanges();
                 //Обновляем список
                 ShowRealEstateSet();
             }
             //Очищаем поля формы
             textBoxAddress_City.Text         = "";
             textBoxAddress_House.Text        = "";
             textBoxAddress_Street.Text       = "";
             textBoxAddress_Number.Text       = "";
             textBoxCoordinate_latitude.Text  = "";
             textBoxCoordinate_longitude.Text = "";
             textBoxTotalArea.Text            = "";
             textBoxRooms.Text = "";
             textBoxFloor.Text = "";
         }
         //Если выбран Дом
         if (comboBoxType.SelectedIndex == 1)
         {
             //И выбран элемент списка
             if (listViewRealEstateSet_House.SelectedItems.Count == 1)
             {
                 //Ищем элемент из таблицы по тегу
                 RealEstateSet realEstate = listViewRealEstateSet_House.SelectedItems[0].Tag as RealEstateSet;
                 //И удаляем его из базы данных
                 Program.wftDB.RealEstateSet.Remove(realEstate);
                 //Сохраняем изменения
                 Program.wftDB.SaveChanges();
                 //Обновляем список
                 ShowRealEstateSet();
             }
             //Очищаем поля формы
             textBoxAddress_City.Text         = "";
             textBoxAddress_House.Text        = "";
             textBoxAddress_Street.Text       = "";
             textBoxAddress_Number.Text       = "";
             textBoxCoordinate_latitude.Text  = "";
             textBoxCoordinate_longitude.Text = "";
             textBoxTotalArea.Text            = "";
             textBoxTotalFloors.Text          = "";
         }
         //Если выбрана Земля
         else if (comboBoxType.SelectedIndex == 2)
         {
             //И выбран элемент списка
             if (listViewRealEstateSet_Land.SelectedItems.Count == 1)
             {
                 //Ищем элемент из таблицы по тегу
                 RealEstateSet realEstate = listViewRealEstateSet_Land.SelectedItems[0].Tag as RealEstateSet;
                 //И удаляем его из базы данных
                 Program.wftDB.RealEstateSet.Remove(realEstate);
                 //Сохраняем изменения
                 Program.wftDB.SaveChanges();
                 //Обновляем список
                 ShowRealEstateSet();
             }
             //Очищаем поля формы
             textBoxAddress_City.Text         = "";
             textBoxAddress_House.Text        = "";
             textBoxAddress_Street.Text       = "";
             textBoxAddress_Number.Text       = "";
             textBoxCoordinate_latitude.Text  = "";
             textBoxCoordinate_longitude.Text = "";
             textBoxTotalArea.Text            = "";
         }
     }
     //Если что-то пошло не так
     catch
     {
         MessageBox.Show("Невозможно удалить запись, возможно она используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#18
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     //Если выбрана Квартира
     if (comboBoxType.SelectedIndex == 0)
     {
         //И выбран элемент списка
         if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
         {
             //Ищем элемент из таблицы по тегу
             RealEstateSet realEstate = listViewRealEstateSet_Apartment.SelectedItems[0].Tag as RealEstateSet;
             //Обновляем данные
             realEstate.Address_City         = textBoxAddress_City.Text;
             realEstate.Address_House        = textBoxAddress_House.Text;
             realEstate.Address_Street       = textBoxAddress_Street.Text;
             realEstate.Address_Number       = 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);
             //Сохраняем изминения в модели wftDB
             Program.wftDB.SaveChanges();
             //Обновляем списки
             ShowRealEstateSet();
         }
     }
     //Если выбран Дом
     else if (comboBoxType.SelectedIndex == 1)
     {
         //И выбран элемент списка
         if (listViewRealEstateSet_House.SelectedItems.Count == 1)
         {
             //Ищем элемент из таблицы по тегу
             RealEstateSet realEstate = listViewRealEstateSet_House.SelectedItems[0].Tag as RealEstateSet;
             //Обновляем данные
             realEstate.Address_City         = textBoxAddress_City.Text;
             realEstate.Address_House        = textBoxAddress_House.Text;
             realEstate.Address_Street       = textBoxAddress_Street.Text;
             realEstate.Address_Number       = 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);
             //Сохраняем изминения в модели wftDB
             Program.wftDB.SaveChanges();
             //Обновляем списки
             ShowRealEstateSet();
         }
     }
     //Если выбрана Земля
     else if (comboBoxType.SelectedIndex == 2)
     {
         //И выбран элемент списка
         if (listViewRealEstateSet_Land.SelectedItems.Count == 1)
         {
             //Ищем элемент из таблицы по тегу
             RealEstateSet realEstate = listViewRealEstateSet_Land.SelectedItems[0].Tag as RealEstateSet;
             //Обновляем данные
             realEstate.Address_City         = textBoxAddress_City.Text;
             realEstate.Address_House        = textBoxAddress_House.Text;
             realEstate.Address_Street       = textBoxAddress_Street.Text;
             realEstate.Address_Number       = 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);
             //Сохраняем изминения в модели wftDB
             Program.wftDB.SaveChanges();
             //Обновляем списки
             ShowRealEstateSet();
         }
     }
 }
示例#19
0
        private void ButtonAdd_Click(object sender, EventArgs e)
        {
            try
            {
                RealEstateSet realEstate = new RealEstateSet();

                realEstate.Address_City   = textBoxAddress_City.Text;
                realEstate.Address_House  = textBoxAddress_House.Text;
                realEstate.Address_Street = textBoxAddress_Street.Text;
                realEstate.Address_Number = textBoxAddress_Number.Text;
                if (textBoxCoordinate_Iatitude.Text != "")
                {
                    realEstate.Coordinate_Iatitude = Convert.ToDouble(textBoxCoordinate_Iatitude.Text);
                }
                else
                {
                    realEstate.Coordinate_Iatitude = null;
                }
                if (textBoxCoordinate_Iongitude.Text != "")
                {
                    realEstate.Coordinate_Iongitude = Convert.ToDouble(textBoxCoordinate_Iongitude.Text);
                }
                else
                {
                    realEstate.Coordinate_Iongitude = null;
                }
                if (textBoxTotalArea.Text != "")
                {
                    realEstate.TotalArea = Convert.ToDouble(textBoxTotalArea.Text);
                }
                else
                {
                    realEstate.TotalArea = null;
                }
                if (realEstate.Coordinate_Iatitude < -90 || realEstate.Coordinate_Iatitude > 90)
                {
                    throw new Exception("Широта принимает значения только от -90 до +90");
                }
                if (realEstate.Coordinate_Iongitude < -180 || realEstate.Coordinate_Iongitude > 180)
                {
                    throw new Exception("Долгота принимает значения только от -180 до +180");
                }


                //доп. поля для квартиры
                if (comboBoxType.SelectedIndex == 0)
                {
                    realEstate.Type = 0;
                    if (textBoxRooms.Text != "")
                    {
                        realEstate.Rooms = Convert.ToInt32(textBoxRooms.Text);
                    }
                    else
                    {
                        realEstate.Rooms = null;
                    }
                    if (textBoxFloor.Text != "")
                    {
                        realEstate.Floor = Convert.ToInt32(textBoxFloor.Text);
                    }
                    else
                    {
                        realEstate.Floor = null;
                    }
                }

                //доп. поля для дома
                else if (comboBoxType.SelectedIndex == 1)
                {
                    realEstate.Type = 1;
                    if (textBoxTotalFloors.Text != "")
                    {
                        realEstate.TotalFloors = Convert.ToInt32(textBoxTotalFloors.Text);
                    }
                    else
                    {
                        realEstate.TotalFloors = null;
                    }
                }

                //доп. поля для земли
                else
                {
                    realEstate.Type = 2;
                }
                Program.wftDb.RealEstateSet.Add(realEstate);
                Program.wftDb.SaveChanges();
                ShowRealEstateSet();
            }
            catch (Exception ex)
            { MessageBox.Show("" + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
示例#20
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            //Выбран тип "Квартира", работа с listViewEstateSet_Apartament
            if (comboBoxType.SelectedIndex == 0)
            {
                //если в listView из таблицы выбран элемент
                if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
                {
                    //Ищем элемент из таблицы по тегу
                    RealEstateSet realEstate = listViewRealEstateSet_Apartment.SelectedItems[0].Tag as RealEstateSet;
                    //указываем, что может быть изменено
                    realEstate.Address_City   = textBoxAddress_City.Text;
                    realEstate.Address_House  = textBoxAddress_House.Text;
                    realEstate.Address_Street = textBoxAddress_Street.Text;
                    realEstate.Address_Number = textBoxAddress_Number.Text;
                    //Проверяем textBox-ы на заполненость
                    if (textBoxCoordinate_latitude.Text != "")
                    {
                        realEstate.Coordinate_latitude = Convert.ToDouble(textBoxCoordinate_latitude.Text);
                    }
                    else
                    {
                        realEstate.Coordinate_latitude = null;
                    }
                    if (realEstate.Coordinate_latitude < 90)
                    {
                        realEstate.Coordinate_latitude  = -90;
                        textBoxCoordinate_latitude.Text = "-90";
                    }
                    if (realEstate.Coordinate_latitude > 90)
                    {
                        realEstate.Coordinate_latitude  = 90;
                        textBoxCoordinate_latitude.Text = "90";
                    }

                    if (textBoxCoordinate_longitude.Text != "")
                    {
                        realEstate.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
                    }
                    else
                    {
                        realEstate.Coordinate_longitude = null;
                    }
                    if (realEstate.Coordinate_longitude < 180)
                    {
                        realEstate.Coordinate_longitude  = -180;
                        textBoxCoordinate_longitude.Text = "-180";
                    }
                    if (realEstate.Coordinate_longitude > 180)
                    {
                        realEstate.Coordinate_longitude  = 180;
                        textBoxCoordinate_longitude.Text = "180";
                    }

                    if (textBoxTotalArea.Text != "")
                    {
                        realEstate.TotalArea = Convert.ToDouble(textBoxTotalArea.Text);
                    }
                    else
                    {
                        realEstate.TotalArea = null;
                    }
                    if (textBoxRooms.Text != "")
                    {
                        realEstate.Rooms = Convert.ToInt32(textBoxRooms.Text);
                    }
                    else
                    {
                        realEstate.Rooms = null;
                    }
                    if (textBoxFloor.Text != "")
                    {
                        realEstate.Floor = Convert.ToInt32(textBoxFloor.Text);
                    }
                    else
                    {
                        realEstate.Floor = null;
                    }
                    //Сохраняем изменения в модели wftDb
                    Program.wftDb.SaveChanges();
                    //Отображаем в listViewRealEstateSet_Apartment
                    ShowRealEstateSet();
                }
            }
            //Выбран тип "Дом", работа с listViewEstateSet_House
            else if (comboBoxType.SelectedIndex == 1)
            {
                //если в listView из таблицы выбран элемент
                if (listViewRealEstateSet_House.SelectedItems.Count == 1)
                {
                    //Ищем элемент из таблицы по тегу
                    RealEstateSet realEstate = listViewRealEstateSet_House.SelectedItems[0].Tag as RealEstateSet;
                    //указываем, что может быть изменено
                    realEstate.Address_City   = textBoxAddress_City.Text;
                    realEstate.Address_House  = textBoxAddress_House.Text;
                    realEstate.Address_Street = textBoxAddress_Street.Text;
                    realEstate.Address_Number = textBoxAddress_Number.Text;
                    //Проверяем textBox-ы на заполненость
                    if (textBoxCoordinate_latitude.Text != "")
                    {
                        realEstate.Coordinate_latitude = Convert.ToDouble(textBoxCoordinate_latitude.Text);
                    }
                    else
                    {
                        realEstate.Coordinate_latitude = null;
                    }
                    if (textBoxCoordinate_longitude.Text != "")
                    {
                        realEstate.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
                    }
                    else
                    {
                        realEstate.Coordinate_longitude = null;
                    }
                    if (textBoxTotalArea.Text != "")
                    {
                        realEstate.TotalArea = Convert.ToDouble(textBoxTotalArea.Text);
                    }
                    else
                    {
                        realEstate.TotalArea = null;
                    }
                    if (textBoxTotalFloors.Text != "")
                    {
                        realEstate.TotalFloors = Convert.ToInt32(textBoxTotalFloors.Text);
                    }
                    else
                    {
                        realEstate.TotalFloors = null;
                    }
                    //Сохраняем изменения в модели wftDb
                    Program.wftDb.SaveChanges();
                    //Отображаем в listViewRealEstateSet_Apartment
                    ShowRealEstateSet();
                }
            }
            //Выбран тип "Земля", работа с listViewEstateSet_Land
            else
            {
                //если в listView из таблицы выбран элемент
                if (listViewRealEstateSet_Land.SelectedItems.Count == 1)
                {
                    //Ищем элемент из таблицы по тегу
                    RealEstateSet realEstate = listViewRealEstateSet_Land.SelectedItems[0].Tag as RealEstateSet;
                    //указываем, что может быть изменено
                    realEstate.Address_City   = textBoxAddress_City.Text;
                    realEstate.Address_House  = textBoxAddress_House.Text;
                    realEstate.Address_Street = textBoxAddress_Street.Text;
                    realEstate.Address_Number = textBoxAddress_Number.Text;
                    //Проверяем textBox-ы на заполненость
                    if (textBoxCoordinate_latitude.Text != "")
                    {
                        realEstate.Coordinate_latitude = Convert.ToDouble(textBoxCoordinate_latitude.Text);
                    }
                    else
                    {
                        realEstate.Coordinate_latitude = null;
                    }
                    if (textBoxCoordinate_longitude.Text != "")
                    {
                        realEstate.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
                    }
                    else
                    {
                        realEstate.Coordinate_longitude = null;
                    }
                    if (textBoxTotalArea.Text != "")
                    {
                        realEstate.TotalArea = Convert.ToDouble(textBoxTotalArea.Text);
                    }
                    else
                    {
                        realEstate.TotalArea = null;
                    }
                    //Сохраняем изменения в модели wftDb
                    Program.wftDb.SaveChanges();
                    //Отображаем в listViewRealEstateSet_Apartment
                    ShowRealEstateSet();
                }
            }
        }
示例#21
0
 private void ButtonDel_Click(object sender, EventArgs e)
 {
     //попробуем совершить действие
     try
     {
         //Выбран тип "Квартира", работа с listViewRealEstateSet_Apartment
         if (comboBoxType.SelectedIndex == 0)
         {
             //если в listViwe выбран элемент
             if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
             {
                 //ищем этот элементв базе по тегу
                 RealEstateSet realEstate = listViewRealEstateSet_Apartment.SelectedItems[0].Tag as RealEstateSet;
                 //удаляем из модели базы данных
                 Program.wftDb.RealEstateSet.Remove(realEstate);
                 //сохраняем изменения
                 Program.wftDb.SaveChanges();
                 //отображаем обновлённый список
                 ShowRealEstateSet();
             }
             //очищаем текстовые поля
             textBoxAddress_City.Text         = "";
             textBoxAddress_House.Text        = "";
             textBoxAddress_Street.Text       = "";
             textBoxAddress_Number.Text       = "";
             textBoxCoordinate_latitude.Text  = "";
             textBoxCoordinate_longitude.Text = "";
             textBoxTotalArea.Text            = "";
             textBoxRooms.Text = "";
             textBoxFloor.Text = "";
         }
         //Выбран тип "Дом", работа с listViewRealEstateSet_House
         else if (comboBoxType.SelectedIndex == 1)
         {
             //если в listView выбран элемент
             if (listViewRealEstateSet_House.SelectedItems.Count == 1)
             {
                 //ищем этот элементв базе по тегу
                 RealEstateSet realEstate = listViewRealEstateSet_House.SelectedItems[0].Tag as RealEstateSet;
                 //удаляем из модели базы данных
                 Program.wftDb.RealEstateSet.Remove(realEstate);
                 //сохраняем изменения
                 Program.wftDb.SaveChanges();
                 //отображаем обновлённый список
                 ShowRealEstateSet();
             }
             //очищаем текстовые поля
             textBoxAddress_City.Text         = "";
             textBoxAddress_House.Text        = "";
             textBoxAddress_Street.Text       = "";
             textBoxAddress_Number.Text       = "";
             textBoxCoordinate_latitude.Text  = "";
             textBoxCoordinate_longitude.Text = "";
             textBoxTotalArea.Text            = "";
             textBoxTotalFloors.Text          = "";
         }
         //Выбран тип "Земля", работа с listViewRealEstateSet_Land
         else
         {
             //если в listView выбран элемент
             if (listViewRealEstateSet_Land.SelectedItems.Count == 1)
             {
                 //ищем этот элементв базе по тегу
                 RealEstateSet realEstate = listViewRealEstateSet_Land.SelectedItems[0].Tag as RealEstateSet;
                 //удаляем из модели базы данных
                 Program.wftDb.RealEstateSet.Remove(realEstate);
                 //сохраняем изменения
                 Program.wftDb.SaveChanges();
                 //отображаем обновлённый список
                 ShowRealEstateSet();
             }
             //очищаем текстовые поля
             textBoxAddress_City.Text         = "";
             textBoxAddress_House.Text        = "";
             textBoxAddress_Street.Text       = "";
             textBoxAddress_Number.Text       = "";
             textBoxCoordinate_latitude.Text  = "";
             textBoxCoordinate_longitude.Text = "";
             textBoxTotalArea.Text            = "";
         }
     }
     //если возникает какая то ошибка
     catch
     {
         MessageBox.Show("Не возможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#22
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (comboBoxType.SelectedIndex == 0)
         {
             if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
             {
                 //ищем этот элемент в базе по тегу
                 RealEstateSet realEstate = listViewRealEstateSet_Apartment.SelectedItems[0].Tag as RealEstateSet;
                 //удаляем из модели базы данных
                 Program.epDb.RealEstateSet.Remove(realEstate);
                 Program.epDb.SaveChanges();
                 ShowRealEstateSet();
             }
             //очищаем тектовые поля
             textBoxAddress_City.Text          = "";
             textBoxAddress_House.Text         = "";
             textBoxAddress_Number.Text        = "";
             textBoxAddress_Street.Text        = "";
             textBoxCoordinate_latitude.Text   = "";
             textBoxCoordinate_longtitude.Text = "";
             textBoxTotalArea.Text             = "";
             textBoxFloor.Text = "";
             textBoxRooms.Text = "";
         }
         else if (comboBoxType.SelectedIndex == 1)
         {
             if (listViewRealEstateSet_House.SelectedItems.Count == 1)
             {
                 //ищем этот элемент в базе по тегу
                 RealEstateSet realEstate = listViewRealEstateSet_House.SelectedItems[0].Tag as RealEstateSet;
                 //удаляем из модели базы данных
                 Program.epDb.RealEstateSet.Remove(realEstate);
                 Program.epDb.SaveChanges();
                 ShowRealEstateSet();
             }
             //очищаем тектовые поля
             textBoxAddress_City.Text          = "";
             textBoxAddress_House.Text         = "";
             textBoxAddress_Number.Text        = "";
             textBoxAddress_Street.Text        = "";
             textBoxCoordinate_latitude.Text   = "";
             textBoxCoordinate_longtitude.Text = "";
             textBoxTotalArea.Text             = "";
             textBoxTotalFloors.Text           = "";
         }
         else if (comboBoxType.SelectedIndex == 2)
         {
             if (listViewRealEstateSet_Land.SelectedItems.Count == 1)
             {
                 //ищем этот элемент в базе по тегу
                 RealEstateSet realEstate = listViewRealEstateSet_Land.SelectedItems[0].Tag as RealEstateSet;
                 //удаляем из модели базы данных
                 Program.epDb.RealEstateSet.Remove(realEstate);
                 Program.epDb.SaveChanges();
                 ShowRealEstateSet();
             }
             //очищаем тектовые поля
             textBoxAddress_City.Text          = "";
             textBoxAddress_House.Text         = "";
             textBoxAddress_Number.Text        = "";
             textBoxAddress_Street.Text        = "";
             textBoxCoordinate_latitude.Text   = "";
             textBoxCoordinate_longtitude.Text = "";
             textBoxTotalArea.Text             = "";
         }
     }
     //если возникает какая-то ошибка
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#23
0
 private void ButtonEdit_Click(object sender, EventArgs e)
 {
     //Выбран тип "Квартира", работа с listViewRealEstateSet_Apartment
     if (comboBoxType.SelectedIndex == 0)
     {
         //Если в listView выбраен элемент
         if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
         {
             //ищем элемент из таблицы по тегу
             RealEstateSet realEstate = listViewRealEstateSet_Apartment.SelectedItems[0].Tag as RealEstateSet;
             //указываем что может быть изменено
             realEstate.Address_City         = textBoxAddress_City.Text;
             realEstate.Address_House        = textBoxAddress_House.Text;
             realEstate.Address_Street       = textBoxAddress_Street.Text;
             realEstate.Address_Number       = textBoxAddress_Number.Text;
             realEstate.Coordinate_latitude  = Convert.ToDouble(textBoxCoordinate_latitude.Text);
             realEstate.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
             if (textBoxTotalArea.Text != "")
             {
                 realEstate.TotalArea = Convert.ToDouble(textBoxTotalArea.Text);
             }
             if (textBoxRooms.Text != "")
             {
                 realEstate.Rooms = Convert.ToInt32(textBoxRooms.Text);
             }
             if (textBoxFloor.Text != "")
             {
                 realEstate.Floor = Convert.ToInt32(textBoxFloor.Text);
             }
             //сохраняем изменения в модели wftDb
             Program.wftDb.SaveChanges();
             //ОТОБРАЖАЕМ В listViewRealEstateSet_Apartment
             ShowRealEstateSet();
         }
     }
     //Выбран тип "Дом", работа с listViewRealEstateSet_House
     else if (comboBoxType.SelectedIndex == 1)
     {
         //Если в listView выбраен элемент
         if (listViewRealEstateSet_House.SelectedItems.Count == 1)
         {
             //ищем элемент из таблицы по тегу
             RealEstateSet realEstate = listViewRealEstateSet_House.SelectedItems[0].Tag as RealEstateSet;
             //указываем что может быть изменено
             realEstate.Address_City   = textBoxAddress_City.Text;
             realEstate.Address_House  = textBoxAddress_House.Text;
             realEstate.Address_Street = textBoxAddress_Street.Text;
             realEstate.Address_Number = textBoxAddress_Number.Text;
             if (textBoxCoordinate_latitude.Text != "")
             {
                 realEstate.Coordinate_latitude = Convert.ToDouble(textBoxCoordinate_latitude.Text);
             }
             if (textBoxCoordinate_longitude.Text != "")
             {
                 realEstate.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
             }
             if (textBoxTotalArea.Text != "")
             {
                 realEstate.TotalArea = Convert.ToDouble(textBoxTotalArea.Text);
             }
             if (textBoxTotalFloors.Text != "")
             {
                 realEstate.TotalFloors = Convert.ToInt32(textBoxTotalFloors.Text);
             }
             //сохраняем изменения в модели wftDb
             Program.wftDb.SaveChanges();
             //ОТОБРАЖАЕМ В listViewRealEstateSet_House
             ShowRealEstateSet();
         }
     }
     //Выбран тип "Земля", работа с listViewRealEstateSet_Land
     else
     {
         //Если в listView выбраен элемент
         if (listViewRealEstateSet_Land.SelectedItems.Count == 1)
         {
             //ищем элемент из таблицы по тегу
             RealEstateSet realEstate = listViewRealEstateSet_Land.SelectedItems[0].Tag as RealEstateSet;
             //указываем что может быть изменено
             realEstate.Address_City   = textBoxAddress_City.Text;
             realEstate.Address_House  = textBoxAddress_House.Text;
             realEstate.Address_Street = textBoxAddress_Street.Text;
             realEstate.Address_Number = textBoxAddress_Number.Text;
             if (textBoxCoordinate_latitude.Text != "")
             {
                 realEstate.Coordinate_latitude = Convert.ToDouble(textBoxCoordinate_latitude.Text);
             }
             if (textBoxCoordinate_longitude.Text != "")
             {
                 realEstate.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
             }
             if (textBoxTotalArea.Text != "")
             {
                 realEstate.TotalArea = Convert.ToDouble(textBoxTotalArea.Text);
             }
             //сохраняем изменения в модели wftDb
             Program.wftDb.SaveChanges();
             //ОТОБРАЖАЕМ В listViewRealEstateSet_Land
             ShowRealEstateSet();
         }
     }
 }
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (comboBoxType.SelectedIndex == 0)
         {
             if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
             {
                 RealEstateSet realEstate = listViewRealEstateSet_Apartment.SelectedItems[0].Tag as RealEstateSet;
                 Program.wftDB.RealEstateSet.Remove(realEstate);
                 Program.wftDB.SaveChanges();
                 ShowRealEstateSet();
             }
             textBoxAddress_City.Text         = "";
             textBoxAddress_House.Text        = "";
             textBoxAddress_Street.Text       = "";
             textBoxAddress_Number.Text       = " ";
             textBoxCoordinate_latitude.Text  = "";
             textBoxCoordinate_longitude.Text = "";
             textBoxTotalArea.Text            = "";
             textBoxRooms.Text = "";
             textBoxFloor.Text = "";
         }
         else if (comboBoxType.SelectedIndex == 1)
         {
             if (listViewRealEstateSet_House.SelectedItems.Count == 1)
             {
                 RealEstateSet realEstate = listViewRealEstateSet_House.SelectedItems[0].Tag as RealEstateSet;
                 Program.wftDB.RealEstateSet.Remove(realEstate);
                 Program.wftDB.SaveChanges();
                 ShowRealEstateSet();
             }
             textBoxAddress_City.Text         = "";
             textBoxAddress_House.Text        = "";
             textBoxAddress_Street.Text       = "";
             textBoxAddress_Number.Text       = " ";
             textBoxCoordinate_latitude.Text  = "";
             textBoxCoordinate_longitude.Text = "";
             textBoxTotalArea.Text            = "";
             textBoxTotalFloors.Text          = "";
         }
         else
         {
             if (listViewRealEstateSet_Land.SelectedItems.Count == 1)
             {
                 RealEstateSet realEstate = listViewRealEstateSet_Land.SelectedItems[0].Tag as RealEstateSet;
                 Program.wftDB.RealEstateSet.Remove(realEstate);
                 Program.wftDB.SaveChanges();
                 ShowRealEstateSet();
             }
             textBoxAddress_City.Text         = "";
             textBoxAddress_House.Text        = "";
             textBoxAddress_Street.Text       = "";
             textBoxAddress_Number.Text       = "";
             textBoxCoordinate_latitude.Text  = "";
             textBoxCoordinate_longitude.Text = "";
         }
     }
     catch
     {
         MessageBox.Show(" не возможно удалить");
     }
 }
示例#25
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (comboBoxType.SelectedIndex == 0)
            {
                if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
                {
                    try
                    {
                        RealEstateSet realEstate = listViewRealEstateSet_Apartment.SelectedItems[0].Tag as RealEstateSet;

                        realEstate.Address_City   = textBoxAddress_City.Text;
                        realEstate.Address_House  = textBoxAddress_House.Text;
                        realEstate.Address_Street = textBoxAddress_Street.Text;
                        realEstate.Address_Number = textBoxAddress_Number.Text;

                        if (textBoxCoordinate_latitude.Text != "")
                        {
                            realEstate.Coordinate_latitude = Convert.ToDouble(textBoxCoordinate_latitude.Text);
                        }
                        else
                        {
                            realEstate.Coordinate_latitude = null;
                        }

                        if (textBoxCoordinate_longitude.Text != "")
                        {
                            realEstate.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
                        }
                        else
                        {
                            realEstate.Coordinate_longitude = null;
                        }

                        if (textBoxTotalArea.Text != "")
                        {
                            realEstate.TotalArea = Convert.ToDouble(textBoxTotalArea.Text);
                        }
                        else
                        {
                            realEstate.TotalArea = null;
                        }

                        if (textBoxRooms.Text != "")
                        {
                            realEstate.Rooms = Convert.ToInt32(textBoxRooms.Text);
                        }
                        else
                        {
                            realEstate.Rooms = null;
                        }

                        if (textBoxFloor.Text != "")
                        {
                            realEstate.Floor = Convert.ToInt32(textBoxFloor.Text);
                        }
                        else
                        {
                            realEstate.Floor = null;
                        }

                        if (realEstate.Coordinate_latitude < -90 || realEstate.Coordinate_latitude > 90)
                        {
                            throw new Exception("Широта может принимать значения от -90 до +90");
                        }
                        if (realEstate.Coordinate_longitude < -180 || realEstate.Coordinate_longitude > 180)
                        {
                            throw new Exception("Долгота может принимать значения от -180 до +180");
                        }

                        Program.wftDb.SaveChanges();
                        ShowRealEstateSet();
                    }
                    catch (Exception ex) { MessageBox.Show("" + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); }
                }
            }
            else if (comboBoxType.SelectedIndex == 1)
            {
                if (listViewRealEstateSet_House.SelectedItems.Count == 1)
                {
                    try
                    {
                        RealEstateSet realEstate = listViewRealEstateSet_House.SelectedItems[0].Tag as RealEstateSet;

                        realEstate.Address_City   = textBoxAddress_City.Text;
                        realEstate.Address_House  = textBoxAddress_House.Text;
                        realEstate.Address_Street = textBoxAddress_Street.Text;
                        realEstate.Address_Number = textBoxAddress_Number.Text;

                        if (textBoxCoordinate_latitude.Text != "")
                        {
                            realEstate.Coordinate_latitude = Convert.ToDouble(textBoxCoordinate_latitude.Text);
                        }
                        else
                        {
                            realEstate.Coordinate_latitude = null;
                        }

                        if (textBoxCoordinate_longitude.Text != "")
                        {
                            realEstate.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
                        }
                        else
                        {
                            realEstate.Coordinate_longitude = null;
                        }

                        if (textBoxTotalArea.Text != "")
                        {
                            realEstate.TotalArea = Convert.ToDouble(textBoxTotalArea.Text);
                        }
                        else
                        {
                            realEstate.TotalArea = null;
                        }

                        if (textBoxTotalFloors.Text != "")
                        {
                            realEstate.TotalFloors = Convert.ToInt32(textBoxTotalFloors.Text);
                        }
                        else
                        {
                            realEstate.TotalFloors = null;
                        }

                        if (realEstate.Coordinate_latitude < -90 || realEstate.Coordinate_latitude > 90)
                        {
                            throw new Exception("Широта может принимать значения от -90 до +90");
                        }
                        if (realEstate.Coordinate_longitude < -180 || realEstate.Coordinate_longitude > 180)
                        {
                            throw new Exception("Долгота может принимать значения от -180 до +180");
                        }

                        Program.wftDb.SaveChanges();
                        ShowRealEstateSet();
                    }
                    catch (Exception ex) { MessageBox.Show("" + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); }
                }
            }
            else
            {
                if (listViewRealEstateSet_Land.SelectedItems.Count == 1)
                {
                    try
                    {
                        RealEstateSet realEstate = listViewRealEstateSet_Land.SelectedItems[0].Tag as RealEstateSet;

                        realEstate.Address_City   = textBoxAddress_City.Text;
                        realEstate.Address_House  = textBoxAddress_House.Text;
                        realEstate.Address_Street = textBoxAddress_Street.Text;
                        realEstate.Address_Number = textBoxAddress_Number.Text;

                        if (textBoxCoordinate_latitude.Text != "")
                        {
                            realEstate.Coordinate_latitude = Convert.ToDouble(textBoxCoordinate_latitude.Text);
                        }
                        else
                        {
                            realEstate.Coordinate_latitude = null;
                        }

                        if (textBoxCoordinate_longitude.Text != "")
                        {
                            realEstate.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
                        }
                        else
                        {
                            realEstate.Coordinate_longitude = null;
                        }

                        if (textBoxTotalArea.Text != "")
                        {
                            realEstate.TotalArea = Convert.ToDouble(textBoxTotalArea.Text);
                        }
                        else
                        {
                            realEstate.TotalArea = null;
                        }

                        if (realEstate.Coordinate_latitude < -90 || realEstate.Coordinate_latitude > 90)
                        {
                            throw new Exception("Широта может принимать значения от -90 до +90");
                        }
                        if (realEstate.Coordinate_longitude < -180 || realEstate.Coordinate_longitude > 180)
                        {
                            throw new Exception("Долгота может принимать значения от -180 до +180");
                        }

                        Program.wftDb.SaveChanges();
                        ShowRealEstateSet();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("" + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
示例#26
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (comboBoxType.SelectedIndex == 0)
         {
             if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
             {
                 RealEstateSet realEstate = listViewRealEstateSet_Apartment.SelectedItems[0].Tag as RealEstateSet;
                 Program.wftDb.RealEstateSet.Remove(realEstate);
                 Program.wftDb.SaveChanges();
                 ShowRealEstateSet();
             }
             textBoxAddress_City.Text         = "";
             textBoxAddress_House.Text        = "";
             textBoxAddress_Street.Text       = "";
             textBoxAddress_Number.Text       = "";
             textBoxCoordinate_latitude.Text  = "";
             textBoxCoordinate_longitude.Text = "";
             textBoxTotalArea.Text            = "";
             textBoxRooms.Text = "";
             textBoxFloor.Text = "";
         }
         else if (comboBoxType.SelectedIndex == 1)
         {
             if (listViewRealEstateSet_House.SelectedItems.Count == 1)
             {
                 RealEstateSet realEstate = listViewRealEstateSet_House.SelectedItems[0].Tag as RealEstateSet;
                 Program.wftDb.RealEstateSet.Remove(realEstate);
                 Program.wftDb.SaveChanges();
                 ShowRealEstateSet();
             }
             textBoxAddress_City.Text         = "";
             textBoxAddress_House.Text        = "";
             textBoxAddress_Street.Text       = "";
             textBoxAddress_Number.Text       = "";
             textBoxCoordinate_latitude.Text  = "";
             textBoxCoordinate_longitude.Text = "";
             textBoxTotalArea.Text            = "";
             textBoxFloor.Text = "";
         }
         else
         {
             //если в ListView выбран элемент
             if (listViewRealEstateSet_Land.SelectedItems.Count == 1)
             {
                 //ищем элемент по тегу
                 RealEstateSet realEstate = listViewRealEstateSet_Land.SelectedItems[0].Tag as RealEstateSet;
                 //удаляем из модели БД
                 Program.wftDb.RealEstateSet.Remove(realEstate);
                 //сохраняем изменения
                 Program.wftDb.SaveChanges();
                 //отображаем обновленный список
                 ShowRealEstateSet();
             }
             //очищаем текстовые поля
             textBoxAddress_City.Text         = "";
             textBoxAddress_House.Text        = "";
             textBoxAddress_Street.Text       = "";
             textBoxAddress_Number.Text       = "";
             textBoxCoordinate_latitude.Text  = "";
             textBoxCoordinate_longitude.Text = "";
         }
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#27
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (comboBoxType.SelectedIndex == 0)
         {
             if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
             {
                 RealEstateSet realEstate = listViewRealEstateSet_Apartment.SelectedItems[0].Tag as RealEstateSet;
                 Program.eSoftDB.RealEstateSet.Remove(realEstate);
                 Program.eSoftDB.SaveChanges();
                 ShowRealEstateSet();
             }
             textBoxAdress_City.Text           = "";
             textBoxAdress_Street.Text         = "";
             textBoxAdress_House.Text          = "";
             textBoxAdress_Number.Text         = "";
             textBoxCoordinate_latitude.Text   = "";
             textBoxCoordinate_longtitude.Text = "";
             textBoxTotalArea.Text             = "";
             textBoxRooms.Text = "";
             textBoxFloor.Text = "";
         }
         else if (comboBoxType.SelectedIndex == 1)
         {
             if (listViewRealEstateSet_House.SelectedItems.Count == 1)
             {
                 ;
             }
             {
                 RealEstateSet realEstate = listViewRealEstateSet_House.SelectedItems[0].Tag as RealEstateSet;
                 Program.eSoftDB.RealEstateSet.Remove(realEstate);
                 Program.eSoftDB.SaveChanges();
                 ShowRealEstateSet();
             }
             textBoxAdress_City.Text           = "";
             textBoxAdress_Street.Text         = "";
             textBoxAdress_House.Text          = "";
             textBoxAdress_Number.Text         = "";
             textBoxCoordinate_latitude.Text   = "";
             textBoxCoordinate_longtitude.Text = "";
             textBoxTotalArea.Text             = "";
             textBoxTotalFloors.Text           = "";
         }
         else
         {
             if (listViewRealEstateSet_Land.SelectedItems.Count == 1)
             {
                 ;
             }
             {
                 RealEstateSet realEstate = listViewRealEstateSet_Land.SelectedItems[0].Tag as RealEstateSet;
                 Program.eSoftDB.RealEstateSet.Remove(realEstate);
                 Program.eSoftDB.SaveChanges();
                 ShowRealEstateSet();
             }
             textBoxAdress_City.Text           = "";
             textBoxAdress_Street.Text         = "";
             textBoxAdress_House.Text          = "";
             textBoxAdress_Number.Text         = "";
             textBoxCoordinate_latitude.Text   = "";
             textBoxCoordinate_longtitude.Text = "";
             textBoxTotalArea.Text             = "";
         }
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись уже используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#28
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            RealEstateSet realEstate = new RealEstateSet();

            realEstate.Address_City   = textBoxAddress_City.Text;
            realEstate.Address_House  = textBoxAddress_House.Text;
            realEstate.Address_Street = textBoxAddress_Street.Text;
            realEstate.Address_Number = textBoxAddress_Number.Text;
            if (textBoxCoordinate_latitude.Text != "")
            {
                realEstate.Coordinate_latitude = Convert.ToDouble(textBoxCoordinate_latitude.Text);
            }
            if (realEstate.Coordinate_latitude < -90)
            {
                realEstate.Coordinate_latitude  = -90;
                textBoxCoordinate_latitude.Text = "-90";
            }
            if (realEstate.Coordinate_latitude > +90)
            {
                realEstate.Coordinate_latitude  = +90;
                textBoxCoordinate_latitude.Text = "+90";
            }
            if (textBoxCoordinate_longitude.Text != "")
            {
                realEstate.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
            }
            if (realEstate.Coordinate_longitude < -180)
            {
                realEstate.Coordinate_longitude  = -180;
                textBoxCoordinate_longitude.Text = "-180";
            }
            if (realEstate.Coordinate_longitude > +180)
            {
                realEstate.Coordinate_longitude  = +180;
                textBoxCoordinate_longitude.Text = "+180";
            }
            if (textBoxTotalArea.Text != "")
            {
                realEstate.TotalArea = Convert.ToDouble(textBoxTotalArea.Text);
            }


            if (comboBoxType.SelectedIndex == 0)
            {
                realEstate.Type = 0;
                if (textBoxRooms.Text != "")
                {
                    realEstate.Rooms = Convert.ToInt32(textBoxRooms.Text);
                }
                if (textBoxFloor.Text != "")
                {
                    realEstate.Floor = Convert.ToInt32(textBoxFloor.Text);
                }
            }
            else if (comboBoxType.SelectedIndex == 1)
            {
                realEstate.Type = 1;
                if (textBoxTotalFloors.Text != "")
                {
                    realEstate.TotalFloors = Convert.ToInt32(textBoxTotalFloors.Text);
                }
            }
            else
            {
                realEstate.Type = 2;
            }

            Program.wftDb.RealEstateSet.Add(realEstate);
            Program.wftDb.SaveChanges();
            ShowRealEstateSet();
        }
示例#29
0
        private void ButtonAdd_Click(object sender, EventArgs e)
        {
            try
            {
                //создаём новый экзэмпляр класса Объект недвижимости
                RealEstateSet realEstate = new RealEstateSet();
                //делаем ссылку на объект, который хранится в textBox-ах (сначала общие поля)
                realEstate.Address_City         = textBoxAddress_City.Text;
                realEstate.Address_House        = textBoxAddress_House.Text;
                realEstate.Address_Street       = textBoxAddress_Street.Text;
                realEstate.Address_Number       = 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 (textBoxCoordinate_latitude.Text != "")
                {
                    realEstate.Coordinate_latitude = Convert.ToDouble(textBoxCoordinate_latitude.Text);
                }
                if (realEstate.Coordinate_latitude < -90 || realEstate.Coordinate_latitude > 90)
                {
                    throw new Exception("Введите широту в диапазоне от -90 до 90");
                }

                if (textBoxCoordinate_longitude.Text != "")
                {
                    realEstate.Coordinate_longitude = Convert.ToDouble(textBoxCoordinate_longitude.Text);
                }
                if (realEstate.Coordinate_longitude < -180 || realEstate.Coordinate_longitude > 180)
                {
                    throw new Exception("Введите долготу в диапазоне от -180 до 180");
                }

                //доп. поля для типа "Квартира"
                if (comboBoxType.SelectedIndex == 0)
                {
                    realEstate.Type  = 0;
                    realEstate.Rooms = Convert.ToInt32(textBoxRooms.Text);
                    realEstate.Floor = Convert.ToInt32(textBoxFloor.Text);
                }
                //доп. поля для типа "Дом"
                else if (comboBoxType.SelectedIndex == 1)
                {
                    realEstate.Type        = 1;
                    realEstate.TotalFloors = Convert.ToInt32(textBoxTotalFloors.Text);
                }
                //доп. поля для типа "Земля"
                else
                {
                    realEstate.Type      = 2;
                    realEstate.TotalArea = Convert.ToDouble(textBoxTotalArea.Text);
                }
                //добавляем в таблицу RealEstateSet новый объект недвижимости realEstate
                Program.wftDb.RealEstateSet.Add(realEstate);
                //сохраняем изменения в модели wftDb
                Program.wftDb.SaveChanges();
                ShowRealEstateSet();
            }
            catch (Exception a)
            {
                MessageBox.Show("" + a.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#30
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (comboBoxType.SelectedIndex == 0)
     {
         //если в listView выбран элемент
         if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
         {
             //ищем элемент из таблицы по тегу
             RealEstateSet realEstate = listViewRealEstateSet_Apartment.SelectedItems[0].Tag as RealEstateSet;
             //указываем, что может быть изменено
             realEstate.Address_City          = textBoxAddress_City.Text;
             realEstate.Address_House         = textBoxAddress_House.Text;
             realEstate.Address_Street        = textBoxAddress_Street.Text;
             realEstate.Address_Number        = textBoxAddress_Number.Text;
             realEstate.Coordinate_latitude   = Convert.ToDouble(textBoxCoordinate_latitude.Text);
             realEstate.Coordinate_longtitude = Convert.ToDouble(textBoxCoordinate_longtitude.Text);
             realEstate.TotalArea             = Convert.ToDouble(textBoxTotalArea.Text);
             realEstate.Rooms = Convert.ToInt32(textBoxRooms.Text);
             realEstate.Floor = Convert.ToInt32(textBoxFloor.Text);
             Program.epDb.SaveChanges();
             ShowRealEstateSet();
         }
     }
     else if (comboBoxType.SelectedIndex == 1)
     {
         //если в listView выбран элемент
         if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
         {
             //ищем элемент из таблицы по тегу
             RealEstateSet realEstate = listViewRealEstateSet_Apartment.SelectedItems[0].Tag as RealEstateSet;
             //указываем, что может быть изменено
             realEstate.Address_City          = textBoxAddress_City.Text;
             realEstate.Address_House         = textBoxAddress_House.Text;
             realEstate.Address_Street        = textBoxAddress_Street.Text;
             realEstate.Address_Number        = textBoxAddress_Number.Text;
             realEstate.Coordinate_latitude   = Convert.ToDouble(textBoxCoordinate_latitude.Text);
             realEstate.Coordinate_longtitude = Convert.ToDouble(textBoxCoordinate_longtitude.Text);
             realEstate.TotalArea             = Convert.ToDouble(textBoxTotalArea.Text);
             realEstate.TotalFloors           = Convert.ToInt32(textBoxTotalFloors.Text);
             Program.epDb.SaveChanges();
             ShowRealEstateSet();
         }
     }
     else
     {
         //если в listView выбран элемент
         if (listViewRealEstateSet_Apartment.SelectedItems.Count == 1)
         {
             //ищем элемент из таблицы по тегу
             RealEstateSet realEstate = listViewRealEstateSet_Apartment.SelectedItems[0].Tag as RealEstateSet;
             //указываем, что может быть изменено
             realEstate.Address_City          = textBoxAddress_City.Text;
             realEstate.Address_House         = textBoxAddress_House.Text;
             realEstate.Address_Street        = textBoxAddress_Street.Text;
             realEstate.Address_Number        = textBoxAddress_Number.Text;
             realEstate.Coordinate_latitude   = Convert.ToDouble(textBoxCoordinate_latitude.Text);
             realEstate.Coordinate_longtitude = Convert.ToDouble(textBoxCoordinate_longtitude.Text);
             realEstate.TotalArea             = Convert.ToDouble(textBoxTotalArea.Text);
             Program.epDb.SaveChanges();
             ShowRealEstateSet();
         }
     }
 }