/// <summary> /// Helper method to fill the estates with 10 estate object to make it easier for the user to test the search /// Removes the previously estates in the estates ArrayList /// </summary> public void genereateEstates() { //C: \Users\h_o_l\source\repos\Assignment_2.0\Resources\estate.jpg //Bitmap image = new Bitmap("/Resources/estate.jpg"); Address address1 = new Address("Street1", "24010", "Lund", Countries.Sverige); Address address2 = new Address("Street2", "22224", "Malmö", Countries.Sverige); Address address3 = new Address("Street3", "08122", "Ystad", Countries.Sverige); Estate shop1 = new Shop("0001", "Food", LegalForms.Rental, null, address1, Category.Commercial, TypeAll.Shop); Estate shop2 = new Shop("0002", "Paint", LegalForms.Rental, null, address2, Category.Commercial, TypeAll.Shop); Estate shop3 = new Shop("0003", "Pizza", LegalForms.Ownership, null, address3, Category.Commercial, TypeAll.Shop); Estate warehouse1 = new Warehouse("0004", "1000", LegalForms.Ownership, null, address1, Category.Commercial, TypeAll.Warehouse); Estate warehouse2 = new Warehouse("0005", "2000", LegalForms.Rental, null, address1, Category.Commercial, TypeAll.Warehouse); Estate warehouse3 = new Warehouse("0006", "3000", LegalForms.Ownership, null, address2, Category.Commercial, TypeAll.Warehouse); Estate villa1 = new Villa("0007", "100", LegalForms.Rental, null, address2, Category.Residential, TypeAll.Villa); Estate villa2 = new Villa("0008", "200", LegalForms.Ownership, null, address3, Category.Residential, TypeAll.Villa); Estate villa3 = new Villa("0009", "300", LegalForms.Rental, null, address3, Category.Residential, TypeAll.Villa); deleteAllEstates(); estates.Add(shop1); estates.Add(shop2); estates.Add(shop3); estates.Add(warehouse1); estates.Add(warehouse2); estates.Add(warehouse3); estates.Add(villa1); estates.Add(villa2); estates.Add(villa3); ids.Add(shop1.Id); ids.Add(shop2.Id); ids.Add(shop3.Id); ids.Add(warehouse1.Id); ids.Add(warehouse2.Id); ids.Add(warehouse3.Id); ids.Add(villa1.Id); ids.Add(villa2.Id); ids.Add(villa3.Id); updateTxtWindow(); }
/// <summary> /// Validates that all the information is filled in correctly and then creates an estate object /// and puts it into the estates list. /// </summary> /// <param name="id"></param> /// <param name="legalForm"></param> /// <param name="country"></param> /// <param name="city"></param> /// <param name="zipCode"></param> /// <param name="street"></param> /// <param name="category"></param> /// <param name="type"></param> /// <param name="text"></param> /// <param name="image"></param> public void createEstate(string id, LegalForms legalForm, Countries country, string city, string zipCode, string street, Category category, object type, string text, Bitmap image, RichTextBox richTxtBx, TypeAll typeAll) { if (!isIdValid(id) || !uniqueId(id) || !hasChosenImage(image) || !allFieldsFilled(city, zipCode, street, text)) { return; } Address address = new Address(street, zipCode, city, country); this.richTxtBx = richTxtBx; switch (type) { case TypeCom.Shop: Shop shop = new Shop(id, text, legalForm, image, address, category, typeAll); estates.Add(shop); ids.Add(id); break; case TypeCom.Warehouse: Estate warehouse = new Warehouse(id, text, legalForm, image, address, category, typeAll); estates.Add(warehouse); ids.Add(id); break; case TypeRes.Apartment: Estate apartment = new Apartment(id, text, legalForm, image, address, category, typeAll); estates.Add(apartment); ids.Add(id); break; case TypeRes.House: Estate house = new House(id, text, legalForm, image, address, category, typeAll); estates.Add(house); ids.Add(id); break; case TypeRes.Townhouse: Estate townhouse = new Townhouse(id, text, legalForm, image, address, category, typeAll); estates.Add(townhouse); ids.Add(id); break; case TypeRes.Villa: Estate villa = new Villa(id, text, legalForm, image, address, category, typeAll); estates.Add(villa); ids.Add(id); break; default: break; } MessageBox.Show("För debug \n, ids count: " + ids.Count + " estate i ArrayList count: " + estates.Count); MessageBox.Show("Estate successfully created, to browse the esates go to the Search/Delete tab"); updateTxtWindow(); MessageBox.Show("Richtextbox succesfully updated!"); // skriv ut i search }
/// <summary> /// Validates that all the information is filled in correctly and then creates an estate object /// and puts it into the estates list. /// </summary> /// <param name="id"></param> /// <param name="legalForm"></param> /// <param name="country"></param> /// <param name="city"></param> /// <param name="zipCode"></param> /// <param name="street"></param> /// <param name="category"></param> /// <param name="type"></param> /// <param name="text"></param> /// <param name="image"></param> public void createEstate(string id, LegalForms legalForm, Countries country, string city, string zipCode, string street, Category category, object type, string text, Bitmap image, TypeAll typeAll, bool isModifyingEstate) { if (isModifyingEstate) { Estate oldEstate = GetEstate(id); estates.Remove(oldEstate); ids.Remove(id); } // || !hasChosenImage(image) ?? Maybe remove?? if (!isIdValid(id) || !uniqueId(id) || !allFieldsFilled(city, zipCode, street, text)) { return; } Address address = new Address(street, zipCode, city, country); switch (type) { case TypeCom.Shop: Shop shop = new Shop(id, text, legalForm, image, address, category, typeAll); estates.Add(shop); ids.Add(id); break; case TypeCom.Warehouse: Estate warehouse = new Warehouse(id, text, legalForm, image, address, category, typeAll); estates.Add(warehouse); ids.Add(id); break; case TypeRes.Apartment: Estate apartment = new Apartment(id, text, legalForm, image, address, category, typeAll); estates.Add(apartment); ids.Add(id); break; case TypeRes.House: Estate house = new House(id, text, legalForm, image, address, category, typeAll); estates.Add(house); ids.Add(id); break; case TypeRes.Townhouse: Estate townhouse = new Townhouse(id, text, legalForm, image, address, category, typeAll); estates.Add(townhouse); ids.Add(id); break; case TypeRes.Villa: Estate villa = new Villa(id, text, legalForm, image, address, category, typeAll); estates.Add(villa); ids.Add(id); break; default: break; } updateTxtWindow(); }