private void btAdd_Click(object sender, EventArgs e) { Address address = new Address(CountryBox.Text, CityTxtBox.Text, StreetTxtBox.Text, ZipCodeTxtBox.Text); // estate newestate = new estate(id ,CategoryBox.Text, TypeBox.Text, LegalFormBox.Text, address); rsl.AddItem(CategoryBox.Text, TypeBox.Text, LegalFormBox.Text, address, pictureBox.Image); AEstate estate = rsl.GetAt(); UserItemViewer.Items.Add(estate.GetId() + " " + estate.GetCategory() + " " + estate.GetTypeEstate() + " " + estate.GetLegal() + " " + estate.GetCountry() + " " + estate.GetCity() + " " + estate.GetStreet() + " " + estate.GetZipCode()); //UserItemViewer.DataSource = list.ToString(); ListViewItem lv = new ListViewItem(estate.GetId().ToString()); lv.SubItems.Add(estate.GetCategory()); lv.SubItems.Add(estate.GetTypeEstate()); lv.SubItems.Add(estate.GetLegal()); lv.SubItems.Add(estate.GetCountry()); lv.SubItems.Add(estate.GetCity()); lv.SubItems.Add(estate.GetStreet()); lv.SubItems.Add(estate.GetZipCode()); UserlistView.Items.Add(lv); }
private void saveChange_Click(object sender, EventArgs e) { // Now is only work for list view if u want to use listBox have to change index and if sats line 31 if (UserlistView.SelectedItems.Count > 0) { int index = UserlistView.SelectedItems[0].Index; AEstate estate = rsl.GetAt(index); // int id = rsl.GetId(); estate.SetCategory(CategoryBox.Text); estate.SetType(TypeBox.Text); estate.SetLegal(LegalFormBox.Text); estate.SetCountry(CountryBox.Text); estate.SetCity(CityTxtBox.Text); estate.SetStreet(StreetTxtBox.Text); estate.SetZipCode(ZipCodeTxtBox.Text); estate.SetImage(pictureBox.Image); //estate.SetId = estate.SetId(int.Parse(IdLb.Text)); Address address = new Address(CountryBox.Text, CityTxtBox.Text, StreetTxtBox.Text, ZipCodeTxtBox.Text); //rsl.SaveEditedItem(estate.GetId(), estate.Category(), estate.TypeEstate(), estate.Legal(), address, pictureBox.Image); rsl.SaveEditedItem(index, estate.GetId(), estate.GetCategory(), estate.GetTypeEstate(), estate.GetLegal(), address, pictureBox.Image); UserItemViewer.Items.RemoveAt(index); UserItemViewer.Items.Insert(index, estate.GetId() + " " + estate.GetCategory() + " " + estate.GetTypeEstate() + " " + estate.GetLegal() + " " + estate.GetCountry() + " " + estate.GetCity() + " " + estate.GetStreet() + " " + estate.GetZipCode()); UserlistView.Items.RemoveAt(index); ListViewItem lv = new ListViewItem(estate.GetId().ToString()); lv.SubItems.Add(estate.GetCategory()); lv.SubItems.Add(estate.GetTypeEstate()); lv.SubItems.Add(estate.GetLegal()); lv.SubItems.Add(estate.GetCountry()); UserlistView.Items.Insert(index, lv); } }
private void UserItemViewer_SelectedIndexChanged(object sender, EventArgs e) { if (UserItemViewer.SelectedIndex > -1) { saveChange.Enabled = true; int index = UserItemViewer.Items.IndexOf(UserItemViewer.SelectedItem); AEstate estate = rsl.GetAt(index); CategoryBox.Text = estate.GetCategory(); TypeBox.Text = estate.GetTypeEstate(); LegalFormBox.Text = estate.GetLegal(); CountryBox.Text = estate.GetCountry(); StreetTxtBox.Text = estate.GetStreet(); CityTxtBox.Text = estate.GetCity(); ZipCodeTxtBox.Text = estate.GetZipCode(); pictureBox.Image = estate.GetImage(); IdLb.Text = estate.GetId().ToString(); } }