private void btn_add_Click(object sender, RoutedEventArgs e) { if (!this.checkFields()) { return; } //this.listBox.ItemsSource = null; StudentAddressBook obj = new StudentAddressBook(this.txtBox_firstName.Text, this.txtBox_lastName.Text, this.txtBox_company.Text, this.txtBox_jobTitle.Text, this.txtBox_email.Text, this.txtBox_address.Text, this.txtBox_phCountryCode.Text, this.txtBox_ph.Text, this.txtBox_photoAddress.Text); this.listBox.Items.Add(obj); //this.listBox.Items.Remove(); AddressBook.list.Add(obj); this.listBox.Items.Refresh(); MessageBox.Show("Successfully ADDED"); }
private void btn_update_Click(object sender, RoutedEventArgs e) { if (!this.checkFields()) { return; } StudentAddressBook obj = (StudentAddressBook)this.listBox.SelectedItem; obj.FirstName = this.txtBox_firstName.Text; obj.LastName = this.txtBox_lastName.Text; obj.CompanyName = this.txtBox_company.Text; obj.JobTitle = this.txtBox_jobTitle.Text; obj.Email = this.txtBox_email.Text; obj.Address = this.txtBox_address.Text; obj.CountryCode = this.txtBox_phCountryCode.Text; obj.PhNumber = this.txtBox_ph.Text; obj.Photo = this.txtBox_photoAddress.Text; this.img_user.Source = null; this.listBox.Items.Refresh(); MessageBox.Show("Successfully UPDATED"); }