示例#1
0
        private void createEstate()
        {
            // Gets all the value from the GUI to create an Estate object
            LegalForms legalForm = (LegalForms)comboBoxLegalForm.SelectedItem;
            Countries  country   = (Countries)comboBoxCountry.SelectedItem;
            string     city      = textBoxCity.Text;
            string     zipCode   = textBoxZipCode.Text;
            string     street    = textBoxStreet.Text;
            Category   category  = (Category)comboBoxCategory.SelectedItem;
            var        type      = comboBoxType.SelectedItem;
            string     text      = textBox6.Text;
            TypeAll    typeAll   = (TypeAll)comboBoxType.SelectedItem;
            string     id        = textId.Text;

            // Id must be unique and in a valid format and all the fields int the GUI must be filled´, else do not create an Estate
            if (!isIdValid(id) || !uniqueId(id) || !estateManager.allFieldsFilled(city, zipCode, street, text))
            {
                return;
            }

            // Creates an address from the given address data
            Address address = new Address(street, zipCode, city, country);
            Estate  estate  = null;

            // Creates an estate in the correct type, depending on what type the user has chosen
            switch (type)
            {
            case TypeCom.Shop:
                estate = new Shop(id, text, legalForm, image, address, category, typeAll);
                break;

            case TypeCom.Warehouse:
                estate = new Warehouse(id, text, legalForm, image, address, category, typeAll);
                break;

            case TypeRes.Apartment:
                estate = new Apartment(id, text, legalForm, image, address, category, typeAll);
                break;

            case TypeRes.House:
                estate = new House(id, text, legalForm, image, address, category, typeAll);
                break;

            case TypeRes.Townhouse:
                estate = new Townhouse(id, text, legalForm, image, address, category, typeAll);
                break;

            case TypeRes.Villa:
                estate = new Villa(id, text, legalForm, image, address, category, typeAll);
                break;

            default:
                break;
            }

            estateManager.Add(indexToChange, estate);
            dictionaryHandler.Add(estate);
        }
示例#2
0
        public bool AddEstate(Estate estate)
        {
            Estate estateCopy = CopyEstate(estate);

            Clear(estate);
            return(_estateManager.Add(estateCopy));
        }
示例#3
0
        /// <summary>
        ///method to add a object to the list in listmanager and add to the view.
        ///creates a Property and uses the switch case to give the property a value.
        /// </summary>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Property property;
            string   typeOfProperty = cbType.Text;

            switch (typeOfProperty)
            {
            case "Apartment":
                property = new Apartment();
                break;

            case "House":
                property = new House();
                break;

            case "Shop":
                property = new Shop();
                break;

            case "Townhouse":
                property = new Townhouse();
                break;

            case "Warehouse":
                property = new Warehouse();
                break;

            case "Villa":
                property = new Villa();
                break;

            default:
                typeOfProperty = cbType.Text;
                return;
            }
            property.Id = id;
            AddProperty(property);
            estateManager.Add(property);
            id++;
            test(); // check how many objects in listmanager.
            fillList();
        }
示例#4
0
        public void CreateEstate(int id, String estateType, Address address, String legalForm, Image imgEstate)
        {
            Estate estate = null;

            if (id < 0)
            {
                id = GetNewID();
            }

            switch (estateType)
            {
            case "Villa":
                estate = new Villa(id, address, (Legal)Enum.Parse(typeof(Legal), legalForm), imgEstate);
                break;

            case "House":
                estate = new House(id, address, (Legal)Enum.Parse(typeof(Legal), legalForm), imgEstate);
                break;

            case "Townhouse":
                estate = new Townhouse(id, address, (Legal)Enum.Parse(typeof(Legal), legalForm), imgEstate);
                break;

            case "Apartment":
                estate = new Apartment(id, address, (Legal)Enum.Parse(typeof(Legal), legalForm), imgEstate);
                break;

            case "Shop":
                estate = new Shop(id, address, (Legal)Enum.Parse(typeof(Legal), legalForm), imgEstate);
                break;

            case "Warehouse":
                estate = new Warehouse(id, address, (Legal)Enum.Parse(typeof(Legal), legalForm), imgEstate);
                break;
            }
            estates.Add(estate);
            ui.AddToTable(estate);
        }
示例#5
0
        private void AddBtn_Click(object sender, EventArgs e)
        {
            string cat     = CategoryCB.Text;
            string type    = TypeCB.Text;
            string country = CountryCB.Text;
            string city    = CityTB.Text;
            string street  = StreetTB.Text;
            string zip     = ZipTB.Text;
            string spec    = SpecTB.Text;

            Adress Aobj = new Adress(city, street, zip, country);

            try
            {
                if (!string.IsNullOrEmpty(cat) && !string.IsNullOrEmpty(type) && !string.IsNullOrEmpty(country) && !string.IsNullOrEmpty(city) && !string.IsNullOrEmpty(street) && !string.IsNullOrEmpty(zip))
                {
                    if (type == "Appartment")
                    {
                        Appartment Bobj = new Appartment(cat, Aobj, spec, type);
                        Em.Add(Bobj);
                        MessageBox.Show("Added");
                        Update();
                    }
                    if (type == "House")
                    {
                        House Bobj = new House(cat, Aobj, spec, type);
                        Em.Add(Bobj);

                        MessageBox.Show("Added");

                        Update();
                    }
                    if (type == "Villa")
                    {
                        Villa Bobj = new Villa(cat, Aobj, spec, type);
                        Em.Add(Bobj);

                        MessageBox.Show("Added");

                        Update();
                    }
                    if (type == "Townhouse")
                    {
                        Townhouse Bobj = new Townhouse(cat, Aobj, spec, type);
                        Em.Add(Bobj);

                        MessageBox.Show("Added");

                        Update();
                    }
                    if (type == "Shop")
                    {
                        Shop Bobj = new Shop(cat, Aobj, spec, type);
                        Em.Add(Bobj);

                        MessageBox.Show("Added");

                        Update();
                    }
                    if (type == "Warehouse")
                    {
                        Warehouse Bobj = new Warehouse(cat, Aobj, spec, type);
                        Em.Add(Bobj);

                        MessageBox.Show("Added");

                        Update();
                    }
                }
                else
                {
                    MessageBox.Show("Please fill all the forms!!");
                }
            }

            catch (Exception exc)
            {
                throw exc;
            }
        }
        private void AddBtn_Click(object sender, EventArgs e)
        {
            RealEstateObject objectToAdd;

            //Create the type of object according to what type of estate it is
            string typeOfEstate = typeOfEstateCBox.GetItemText(typeOfEstateCBox.SelectedItem);

            switch (typeOfEstate)
            {
            case "WareHouse":
                objectToAdd = new Warehouse();
                if (landSizeTBox.Text.ToString() != "")
                {
                    Warehouse warehouse = (Warehouse)objectToAdd;
                    warehouse.LandSizeInSquareMeters = Int32.Parse(landSizeTBox.Text);
                }
                else
                {
                    MessageBox.Show("Please enter land size", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                break;

            case "Store":
                objectToAdd = new Store();
                break;

            case "Apartment":
                objectToAdd = new Apartment();
                if (floorTBox.Text.ToString() != "")
                {
                    Apartment apartment = (Apartment)objectToAdd;
                    apartment.Floor = floorTBox.Text;
                }
                else
                {
                    MessageBox.Show("Please enter floor", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                break;

            case "Villa":
                objectToAdd = new Villa();
                break;

            case "RowHouse":
                objectToAdd = new RowHouse();
                break;

            default:
                MessageBox.Show("Please choose type of estate", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            SetLegalForm(objectToAdd);

            //Check so the correct fields are filled in,
            //then add the object to the list
            if (CheckFields())
            {
                MakeObjectToAdd(objectToAdd);
            }
            else
            {
                MessageBox.Show("Please enter text in all fields", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            objectToAdd.Id = id;

            estateManager.Add(objectToAdd);
            ShowAllObjectsInListBox();
            ClearFields();
            id++;
        }