コード例 #1
0
ファイル: FlatForm.cs プロジェクト: antikd8/oop_2k2sem
        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
        public void printInfoToOriginal(Flat item)
        {
            ogForm.countModifiedFlats++;
            StringBuilder outputLine = new StringBuilder();

            outputLine.AppendLine($"Квартира [ {ogForm.countModifiedFlats} ]");
            outputLine.AppendLine("Метраж квартиры :" + item.Footage.ToString() + ";");
            outputLine.AppendLine($"Количество комнат: {item.AmountOfRooms};");
            outputLine.AppendLine("Комнаты: ");
            if (item.Balcony)
            {
                outputLine.AppendLine(" - Балкон;");
            }
            if (item.Basement)
            {
                outputLine.AppendLine(" - Подвал;");
            }
            if (item.Bathroom)
            {
                outputLine.AppendLine(" - Ванная комната;");
            }
            if (item.Kitchen)
            {
                outputLine.AppendLine(" - Кухня");
            }
            if (item.LivingRoom)
            {
                outputLine.AppendLine(" - Спальня");
            }
            outputLine.AppendLine($"Год постройки: {item.Year};");
            outputLine.AppendLine($"Материал постройки: {item.Material};");
            outputLine.AppendLine($"Этаж: {item.Floor};");
            outputLine.AppendLine("Адрес:" + item.address.Country + "\n" + item.address.District + "," + item.address.Street + "\n д." +
                                  item.address.HouseNumber + ", кв." + item.address.FlatNumber + ";");
            outputLine.AppendLine($"Цена квартиры: {item.Cost}");
            outputLine.AppendLine("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ");
            ogForm.textBoxSearched.Text += outputLine.ToString();
            MessageBox.Show($"Результат поиска добавлен на \nглавную форму под номером {ogForm.countModifiedFlats}");
        }
コード例 #3
0
ファイル: FlatForm.cs プロジェクト: antikd8/oop_2k2sem
        public void printSortedInfo(Flat item)
        {
            countSortedFlats++;
            StringBuilder outputLine = new StringBuilder();

            outputLine.AppendLine($"Квартира [ {countSortedFlats} ]");
            outputLine.AppendLine("Метраж квартиры :" + item.Footage.ToString() + ";");
            outputLine.AppendLine($"Количество комнат: {item.AmountOfRooms};");
            outputLine.AppendLine("Комнаты: ");
            if (item.Balcony)
            {
                outputLine.AppendLine(" - Балкон;");
            }
            if (item.Basement)
            {
                outputLine.AppendLine(" - Подвал;");
            }
            if (item.Bathroom)
            {
                outputLine.AppendLine(" - Ванная комната;");
            }
            if (item.Kitchen)
            {
                outputLine.AppendLine(" - Кухня");
            }
            if (item.LivingRoom)
            {
                outputLine.AppendLine(" - Спальня");
            }
            outputLine.AppendLine($"Год постройки: {item.Year};");
            outputLine.AppendLine($"Материал постройки: {item.Material};");
            outputLine.AppendLine($"Этаж: {item.Floor};");
            outputLine.AppendLine("Адрес:" + item.address.Country + "\n" + item.address.District + "," + item.address.Street + "\n д." +
                                  item.address.HouseNumber + ", кв." + item.address.FlatNumber + ";");
            outputLine.AppendLine($"Цена квартиры: {item.Cost}");
            outputLine.AppendLine("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ");
            textBoxSorted.Text += outputLine.ToString();
        }
コード例 #4
0
ファイル: FlatForm.cs プロジェクト: antikd8/oop_2k2sem
        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 = "Данные были записаны в файл";
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: antikd8/oop_2k2sem
 public FathersFlat(Flat flat) : base("Квартира отца", flat)
 {
 }
コード例 #6
0
ファイル: Program.cs プロジェクト: antikd8/oop_2k2sem
 public HomeFlat(Flat flat) : base("Домашний адрес", flat)
 {
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: antikd8/oop_2k2sem
 public FlatDecorator(string flatName, Flat flat) : base(flatName)
 {
     this.flat = flat;
 }
コード例 #8
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}");
            }
        }