Ejemplo n.º 1
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_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();
                textBoxTotalFloors.Text          = realEstate.TotalFloors.ToString();
            }
            else
            {
                textBoxAddress_City.Text         = "";
                textBoxAddress_House.Text        = "";
                textBoxAddress_Street.Text       = "";
                textBoxAddress_Number.Text       = "";
                textBoxCoordinate_latitude.Text  = "";
                textBoxCoordinate_longitude.Text = "";
                textBoxTotalArea.Text            = "";
                textBoxTotalFloors.Text          = "";
            }
        }
Ejemplo n.º 2
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;
            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;
            }
            Program.wftDb.RealEstateSet.Add(realEstate);

            Program.wftDb.SaveChanges();
            ShowRealEstateSet();
        }
Ejemplo n.º 3
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            = "";
                    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("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 4
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);

                    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);

                    Program.wftDb.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_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);

                    Program.wftDb.SaveChanges();

                    ShowRealEstateSet();
                }
            }
        }