/// <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(); }