Beispiel #1
0
 private void buttonSaveInfo_Click(object sender, EventArgs e)
 {
     try
     {
         Room room = new Room();
         room.Footage       = trackBarRoomFootage.Value;
         room.Name          = textBoxRoomName.Text;
         room.AmountWindows = (int)numericUpDownAmountWindows.Value;
         if (radioButtonNorth.Checked)
         {
             room.SideWindows = radioButtonNorth.Text;
         }
         if (radioButtonEast.Checked)
         {
             room.SideWindows = radioButtonEast.Text;
         }
         if (radioButtonSouth.Checked)
         {
             room.SideWindows = radioButtonSouth.Text;
         }
         if (radioButtonWest.Checked)
         {
             room.SideWindows = radioButtonWest.Text;
         }
         XmlSerializeWrapper.Serialize(room, "room.xml");
     }
     catch (Exception ex)
     {
         MessageBox.Show($"{ex.Message}");
     }
     finally
     {
         MessageBox.Show($"Данные успешно записаны в файл \"room.xml\"");
     }
 }
Beispiel #2
0
 private void buttonOutputRoomInfo_Click(object sender, EventArgs e)
 {
     try
     {
         var           deserializeRoom = XmlSerializeWrapper.Deserialize <Room>("room.xml");
         StringBuilder roomInfo        = new StringBuilder();
         roomInfo.AppendLine($"Название комнаты: {deserializeRoom.Name}");
         roomInfo.AppendLine($"Метраж комнаты: {deserializeRoom.Footage}");
         roomInfo.AppendLine($"Количество окон: {deserializeRoom.AmountWindows}");
         roomInfo.AppendLine($"Сторона окон: {deserializeRoom.SideWindows}");
         textBoxRoomInfo.Text = roomInfo.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show($"{ex.Message}");
     }
 }
Beispiel #3
0
        private void buttonOutputInfo_Click(object sender, EventArgs e)
        {
            List <Flat> flatsCollection = XmlSerializeWrapper.Deserialize <List <Flat> >("flat.xml");
            int         counterFlats    = 0;

            textBoxFlatInfo.Text = string.Empty;
            foreach (var flat in flatsCollection)
            {
                counterFlats++;
                StringBuilder outputLine = new StringBuilder();
                outputLine.AppendLine($"Квартира [ {counterFlats} ]");
                outputLine.AppendLine("Метраж квартиры :" + flat.Footage.ToString() + ";");
                outputLine.AppendLine(labelRooms.Text + ":" + flat.AmountOfRooms.ToString() + ";");
                outputLine.AppendLine("Комнаты: ");
                if (flat.Balcony)
                {
                    outputLine.AppendLine(" - Балкон;");
                }
                if (flat.Basement)
                {
                    outputLine.AppendLine(" - Подвал;");
                }
                if (flat.Bathroom)
                {
                    outputLine.AppendLine(" - Ванная комната;");
                }
                if (flat.Kitchen)
                {
                    outputLine.AppendLine(" - Кухня");
                }
                if (flat.LivingRoom)
                {
                    outputLine.AppendLine(" - Спальня");
                }
                outputLine.AppendLine(labelYear.Text + " : " + flat.Year + ";");
                outputLine.AppendLine(labelMaterial.Text + " : " + flat.Material + ";");
                outputLine.AppendLine(labelFloor.Text + " : " + flat.Floor + ";");
                outputLine.AppendLine("Адрес:" + flat.address.Country + "\n" + flat.address.District + "," + flat.address.Street + "\n д." +
                                      flat.address.HouseNumber + ", кв." + flat.address.FlatNumber + ";");
                outputLine.AppendLine(labelCostFlat.Text + " : " + flat.Cost + "$ ;");
                outputLine.AppendLine("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
                textBoxFlatInfo.Text += outputLine.ToString();
            }
            toolStripStatusLabelAction.Text = "Вывод из файла";
        }
Beispiel #4
0
        private void buttonSortSave_Click(object sender, EventArgs e)
        {
            List <Flat> list = new List <Flat>();

            switch (sortType)
            {
            case 0:
                if (sortedYear.Count() > 0)
                {
                    foreach (var item in sortedYear)
                    {
                        list.Add(item);
                    }
                }
                break;

            case 1:
                if (sortedFootage.Count() > 0)
                {
                    foreach (var item in sortedFootage)
                    {
                        list.Add(item);
                    }
                }
                break;

            case 2:
                if (sortedPrice.Count() > 0)
                {
                    foreach (var item in sortedPrice)
                    {
                        list.Add(item);
                    }
                }
                break;
            }
            XmlSerializeWrapper.Serialize(list, "sort_result.xml");
            toolStripStatusLabelAction.Text = "Сохранены результаты сортировки";
        }
Beispiel #5
0
        private void buttonSearchSave_Click(object sender, EventArgs e)
        {
            List <Flat> list = new List <Flat>();

            switch (searchType)
            {
            case 1:
                if (searchedDistrict.Count() > 0)
                {
                    foreach (var item in searchedDistrict)
                    {
                        list.Add(item);
                    }
                }
                break;

            case 2:
                if (searchedRooms.Count() > 0)
                {
                    foreach (var item in searchedRooms)
                    {
                        list.Add(item);
                    }
                }
                break;

            case 0:
                if (searchedYear.Count() > 0)
                {
                    foreach (var item in searchedYear)
                    {
                        list.Add(item);
                    }
                }
                break;
            }
            XmlSerializeWrapper.Serialize(list, "search_result.xml");
            toolStripStatusLabelAction.Text = "Сохранены результаты поиска";
        }
Beispiel #6
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            double    footage;
            int       amountOfRooms;
            int       year;
            string    material;
            int       floor;
            string    country;
            string    district;
            string    street;
            string    houseNumber;
            string    flatNumber;
            string    index;
            bool      balcony    = false;
            bool      basement   = false;
            bool      bathroom   = false;
            bool      kitchen    = false;
            bool      livingRoom = false;
            string    property   = null;
            FlatState state      = FlatState.repairing;

            try
            {
                street        = textBoxStreet.Text;
                footage       = trackBarFootage.Value;
                amountOfRooms = (int)numericUpDownRooms.Value;
                year          = dateTimePickerYear.Value.Year;
                material      = comboBoxMaterial.Text;
                floor         = (int)numericUpDownFloor.Value;
                if (treeViewCountry.SelectedNode == null)
                {
                    throw new Exception("Выберите страну или город квартиры!");
                }
                else
                {
                    country = treeViewCountry.SelectedNode.Text;
                }
                district    = comboBoxDistrict.Text;
                street      = textBoxStreet.Text;
                houseNumber = textBoxNumberHouse.Text;
                flatNumber  = textBoxNumberFlat.Text;
                index       = textBoxIndex.Text;
                if (checkBoxBalcony.Checked)
                {
                    balcony = true;
                }
                if (checkBoxBasement.Checked)
                {
                    basement = true;
                }
                if (checkBoxBathroom.Checked)
                {
                    bathroom = true;
                }
                if (checkBoxKitchen.Checked)
                {
                    kitchen = true;
                }
                if (checkBoxLivingRoom.Checked)
                {
                    livingRoom = true;
                }
                if (tempFlat.Property == string.Empty)
                {
                    MessageBox.Show("Выберите, продается ли квартира!");
                }
                else
                {
                    property = tempFlat.Property;
                }
                if (radioButtonNotSalling.Checked)
                {
                    state = FlatState.notsalling;
                }
                if (radioButtonSalling.Checked)
                {
                    state = FlatState.salling;
                }
                if (radioButton1.Checked)
                {
                    state = FlatState.repairing;
                }

                Address address = new Address(country, district, street, houseNumber, flatNumber, index);
                Flat    flat    = new Flat(footage, amountOfRooms, year, material, floor, kitchen, balcony, basement, livingRoom, bathroom, property, state, address);
                flat.Cost        = flat.CountCost();
                textBoxCost.Text = flat.Cost.ToString();
                flats.Add(flat);
                XmlSerializeWrapper.Serialize(flats, "flat.xml");
            }
            catch (Exception ex)
            {
                MessageBox.Show($"{ex.Message}");
            }
            finally
            {
                MessageBox.Show($"Данные успешно записаны в файл \"flat.xml\"");
            }
            amountObjects++;
            toolStripStatusLabelAmount.Text = amountObjects.ToString();
            toolStripStatusLabelAction.Text = "Данные были записаны в файл";
        }
Beispiel #7
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            double footage;
            int    amountOfRooms;
            int    year;
            string material;
            int    floor;
            string country;
            string district;
            string street;
            string houseNumber;
            string flatNumber;
            bool   balcony    = false;
            bool   basement   = false;
            bool   bathroom   = false;
            bool   kitchen    = false;
            bool   livingRoom = false;

            try
            {
                street        = textBoxStreet.Text;
                footage       = trackBarFootage.Value;
                amountOfRooms = (int)numericUpDownRooms.Value;
                year          = dateTimePickerYear.Value.Year;
                material      = comboBoxMaterial.Text;
                floor         = (int)numericUpDownFloor.Value;
                if (treeViewCountry.SelectedNode == null)
                {
                    throw new Exception("Выберите страну или город квартиры!");
                }
                else
                {
                    country = treeViewCountry.SelectedNode.Text;
                }
                district    = textBoxDistrict.Text;
                street      = textBoxStreet.Text;
                houseNumber = textBoxNumberHouse.Text;
                flatNumber  = textBoxNumberFlat.Text;
                if (checkBoxBalcony.Checked)
                {
                    balcony = true;
                }
                if (checkBoxBasement.Checked)
                {
                    basement = true;
                }
                if (checkBoxBathroom.Checked)
                {
                    bathroom = true;
                }
                if (checkBoxKitchen.Checked)
                {
                    kitchen = true;
                }
                if (checkBoxLivingRoom.Checked)
                {
                    livingRoom = true;
                }
                Address address = new Address(country, district, street, houseNumber, flatNumber);
                Flat    flat    = new Flat(footage, year, material, floor, kitchen, balcony, basement, livingRoom, bathroom, address);
                flat.Cost = cost;
                XmlSerializeWrapper.Serialize(flat, "flat.xml");
            }
            catch (Exception ex)
            {
                MessageBox.Show($"{ex.Message}");
            }
            finally
            {
                MessageBox.Show($"Данные успешно записаны в файл \"flat.xml\"");
            }
        }