/// <summary> /// If the user clicks the save changes button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSaveChanges_Click(object sender, EventArgs e) { string id = textId.Text; 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)comboBox3.SelectedItem; var type = comboBox4.SelectedItem; string text = textBox6.Text; TypeAll typeAll = (TypeAll)comboBox4.SelectedItem; bool isModifyingEstate = true; estateHandler.createEstate(id, legalForm, country, city, zipCode, street, category, type, text, image, typeAll, isModifyingEstate); btnSaveChanges.Enabled = false; btnChangeEstate.Enabled = true; btnCreateEstate.Enabled = true; textId.ReadOnly = false; btnDeleteAll.Enabled = true; btnGenerateEstates.Enabled = true; btnSearch.Enabled = true; btnShowAll.Enabled = true; btnDelete.Enabled = true; btnSaveChanges.BackColor = Color.FromArgb(168, 165, 209); btnChangeEstate.BackColor = Color.FromArgb(140, 135, 222); btnCreateEstate.BackColor = Color.FromArgb(140, 135, 222); }
/// <summary> /// When the search button is clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSearch_Click_1(object sender, EventArgs e) { TypeAll typeAll = (TypeAll)comboBox5.SelectedItem; string city = textBox9.Text; estateHandler.SearchEstate(typeAll, city); }
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); }
public tabCreateChange() { InitializeComponent(); estateHandler = new EstateHandler(); comboBoxCountry.DataSource = Countries.GetValues(typeof(Countries)); comboBoxLegalForm.DataSource = LegalForms.GetValues(typeof(LegalForms)); comboBox3.DataSource = Category.GetValues(typeof(Category)); comboBoxLegalForm.DataSource = LegalForms.GetValues(typeof(LegalForms)); comboBox5.DataSource = TypeAll.GetValues(typeof(TypeAll)); lblDynamicTxt1.Text = "---------"; }
/// <summary> /// Sets the string in RichTextBox component to all the Estates that has the searched type and city /// </summary> /// <param name="type"></param> /// <param name="city"></param> /// <returns></returns> public void SearchEstate(TypeAll type, string city) { string estatesList = ""; foreach (Estate e in estates) { if (e.TypeAll.Equals(type) && e.Address.City.Equals(city)) { estatesList += e.ToString() + "\n"; } } listBox1.Items.Add(estatesList); }
private void btnCreateEstate_Click(object sender, EventArgs e) { string id = textId.Text; 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)comboBox3.SelectedItem; var type = comboBox4.SelectedItem; string text = textBox6.Text; TypeAll typeAll = (TypeAll)comboBox4.SelectedItem; estateHandler.createEstate(id, legalForm, country, city, zipCode, street, category, type, text, image, richTextBoxEstates, typeAll); }
public Estate SearchEstate(TypeAll type, string city) { string estatesList = ""; foreach (Estate e in estates) { if (e.TypeAll == type && e.Address.City == city) { estatesList += e.ToString() + "\n"; } richTxtBx.Text = estatesList; } return(null); }
/// <summary> /// Constructor to the components /// </summary> public tabCreateChange() { InitializeComponent(); btnSaveChanges.Enabled = false; estateHandler = new EstateHandler(listBox1); comboBoxCountry.DataSource = Countries.GetValues(typeof(Countries)); comboBoxLegalForm.DataSource = LegalForms.GetValues(typeof(LegalForms)); comboBox3.DataSource = Category.GetValues(typeof(Category)); comboBoxLegalForm.DataSource = LegalForms.GetValues(typeof(LegalForms)); comboBox5.DataSource = TypeAll.GetValues(typeof(TypeAll)); lblDynamicTxt1.Text = "---------"; btnChangeEstate.BackColor = Color.FromArgb(140, 135, 222); btnCreateEstate.BackColor = Color.FromArgb(140, 135, 222); btnChooseImage.BackColor = Color.FromArgb(140, 135, 222); btnSaveChanges.BackColor = Color.FromArgb(168, 165, 209); }
public Townhouse(string id, string height, LegalForms lf, Bitmap image, Address address, Category cat, TypeAll typeAll) { this.Address = address; this.Id = id; this.TypeAll = typeAll; this.typeRes = TypeRes.Townhouse; // The unique attribute for this class this.height = height; UniqueAttribute = height; this.LegalForm = lf; this.Image = image; this.Category = cat; }
/// <summary> /// /// </summary> /// <param name="address"></param> /// <param name="id"></param> /// <param name="floorNumber"></param> /// <param name="squareMeters"></param> /// <param name="lf"></param> /// <param name="image"></param> /// <param name="street"></param> /// <param name="city"></param> /// <param name="c"></param> /// <param name="ZipCode"></param> public Apartment(string id, string floorNumber, LegalForms lf, Bitmap image, Address address, Category cat, TypeAll typeAll) { floorNum = floorNumber; this.Id = id; this.Address = address; this.TypeAll = typeAll; this.typeRes = TypeRes.Apartment; // The unique attribute for this class this.UniqueAttribute = floorNumber; this.LegalForm = lf; this.Image = image; this.Category = cat; }
/// <summary> /// /// </summary> /// <param name="address"></param> /// <param name="id"></param> /// <param name="lawnSize"></param> /// <param name="squareMeters"></param> /// <param name="lf"></param> /// <param name="image"></param> /// <param name="street"></param> /// <param name="city"></param> /// <param name="c"></param> /// <param name="ZipCode"></param> public Villa(string id, string lawnSize, LegalForms lf, Bitmap image, Address address, Category cat, TypeAll type) { this.Address = address; this.Id = id; // The unique attribute for this class this.lawnSize = lawnSize; this.LegalForm = lf; this.Image = image; this.Category = cat; this.TypeAll = type; }
/// <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 }
public Estate ChangeEstate(string id, LegalForms legalForm, Countries country, string city, string zipCode, string street, Category category, object type, string text, Bitmap image, TypeAll typeAll) { if (!ids.Contains(id)) { MessageBox.Show($"There is no Estate that has the id {id}"); return(null); } foreach (Estate e in estates) { if (e.Id == id) { comboBoxLegalForm.SelectedItem = e.LegalForm; comboBoxCountry.SelectedItem = e.Address.Country; comboBocCategory.SelectedItem = e.Category; comboBoxType.SelectedItem = e.TypeAll; textId.Text = e.Id; textcity.Text = e.Address.City; textzip.Text = e.Address.ZIPCode; textStreet.Text = e.Address.Street; textUnique.Text = "kkkk"; } } return(null); }
/// <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(); }
public House(string id, string color, LegalForms lf, Bitmap image, Address address, Category cat, TypeAll typeAll) { this.color = color; this.Address = address; this.Id = id; this.TypeAll = typeAll; this.typeRes = TypeRes.House; // The unique attribute for this class this.UniqueAttribute = color; this.LegalForm = lf; this.Image = image; this.Category = cat; }
public Shop(string id, string typeOfShop, LegalForms lf, Bitmap image, Address address, Category cat, TypeAll type) { this.Address = address; this.Id = id; // The unique attribute for this class this.typeOfShop = typeOfShop; this.LegalForm = lf; this.Image = image; this.Category = cat; this.TypeAll = type; }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="cubicMeterCapacity"></param> /// <param name="lf"></param> /// <param name="image"></param> /// <param name="address"></param> /// <param name="cat"></param> /// <param name="typeAll"></param> public Warehouse(string id, string cubicMeterCapacity, LegalForms lf, Bitmap image, Address address, Category cat, TypeAll typeAll) { this.Address = address; this.Id = id; this.TypeAll = typeAll; this.typeCom = TypeCom.Warehouse; // The unique attribute for this class this.cubicMeterCapacity = cubicMeterCapacity; UniqueAttribute = cubicMeterCapacity; this.LegalForm = lf; this.Image = image; this.Category = cat; }
public void SaveFile(string id, LegalForms legalForm, Countries country, string city, string zipCode, string street, Category category, object type, string text, TypeAll typeAll) { String msg = "Id:" + id + "Legalform:" + legalForm + "Country:" + country + "City:" + city + "zipcode:" + zipCode + "Street:" + street + " Category:" + category + "Ttype:" + type + "Text:" + text + "Type:" + typeAll; String txt = "\file.txt"; // using (StringReader reader = new StringReader(msg.ToString()) // { // string readText = await reader.ReadToEndAsync // } // FileStream fileStream = new FileStream(txt, FileMode.Create, FileAccess.Write); // StreamWriter streamWriter = new StreamWriter(fileStream); // streamWriter.BaseStream.Seek(0, SeekOrigin.End); // streamWriter.Write(msg); // streamWriter.Flush(); // streamWriter.Close(); }