예제 #1
0
        private void buttonAutoFill_Click(object sender, EventArgs e)
        {
            double footage       = 58;
            int    amountOfRooms = 3;
            int    year          = 1865;
            string material      = "Блоки";
            int    floor         = 2;
            string country       = "Страна";

            country = "Беларусь";
            string district = "Казимировка";

            district = "Казимировка";
            string street = "Ленинская";

            street = "Ленинская";
            string houseNumber = "21а";

            houseNumber = "21a";
            string flatNumber = "59";

            flatNumber = "59";
            string  index      = "34ABC56";
            bool    balcony    = false;
            bool    basement   = false;
            bool    bathroom   = true;
            bool    kitchen    = true;
            bool    livingRoom = true;
            string  property   = "Квартира продается!";
            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, address);

            trackBarFootage.Value          = 58;
            labelFootage.Text              = $"Метраж: {trackBarFootage.Value}  М^2";
            numericUpDownRooms.Value       = 3;
            dateTimePickerYear.Value       = DateTime.Parse("1856-02-02");
            comboBoxMaterial.SelectedIndex = 2;
            numericUpDownFloor.Value       = 2;
            comboBoxDistrict.SelectedIndex = 3;
            textBoxStreet.Text             = "Ленинская";
            textBoxNumberHouse.Text        = "21a";
            textBoxNumberFlat.Text         = "59";
            textBoxIndex.Text              = "34ABC56";
            checkBoxBalcony.Checked        = false;
            checkBoxBasement.Checked       = false;
            checkBoxBathroom.Checked       = true;
            checkBoxKitchen.Checked        = true;
            radioButtonSalling.Checked     = true;
            checkBoxLivingRoom.Checked     = true;
            textBoxCost.Text     = flat.CountCost().ToString();
            textBoxFlatInfo.Text = string.Empty;
            treeViewCountry.ExpandAll();
            treeViewCountry.SelectedNode    = treeViewCountry.GetNodeAt(0, 0);
            textBoxStreet.ReadOnly          = false;
            textBoxNumberFlat.ReadOnly      = false;
            textBoxNumberHouse.ReadOnly     = false;
            toolStripStatusLabelAction.Text = "Автозаполнение";
        }
예제 #2
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 = "Данные были записаны в файл";
        }
예제 #3
0
        private void buttonGetCost_Click(object sender, EventArgs e)
        {
            double footage;
            int    amountOfRooms;
            int    year;
            string material;
            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;
            int    floor;

            try
            {
                street        = textBoxStreet.Text;
                footage       = trackBarFootage.Value;
                amountOfRooms = (int)numericUpDownRooms.Value;
                year          = dateTimePickerYear.Value.Year;
                floor         = (int)numericUpDownFloor.Value;
                material      = comboBoxMaterial.Text;
                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);
                cost             = flat.CountCost();
                textBoxCost.Text = cost.ToString();
                flat.Cost        = cost;
            }
            catch (Exception ex)
            {
                MessageBox.Show($"{ex.Message}");
            }
        }