/// <summary> /// Przycisk dodający nowe miejsce zamieszkania do tabeli ResidencePlaces /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonAdd_Click(object sender, EventArgs e) { try { country = textBoxCountry.Text; city = textBoxCity.Text; postCode = textBoxPostCode.Text; street = textBoxStreet.Text; number = int.Parse(textBoxNumber.Text); } catch { } if (country == null || country == "" || city == "" || city == null || postCode == "" || postCode == null || number == null) { MessageBox.Show("Niepoprawne dane"); } else { try { formAdmin.residencePlacesRepository.AddResidencePlace(country, city, postCode, street, number); } catch (Exception) { MessageBox.Show("Niepoprawne dane"); } formAdmin.RefreshDataGridView(); } }
/// <summary> /// Przycisk aktualizujący dane adresu /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonUpdate_Click(object sender, EventArgs e) { try { country = textBoxCountry.Text; city = textBoxCity.Text; postCode = textBoxPostCode.Text; street = textBoxStreet.Text; number = int.Parse(textBoxNumber.Text); } catch { } if (country == null || country == "" || city == "" || city == null || postCode == "" || postCode == null || number == null) { MessageBox.Show("Niepoprawne dane"); } else { try { if (formAdmin.residencePlacesRepository.UpdateAddress(formAdmin.AddressId, country, city, postCode, street, number)) { formAdmin.setOperationStatusLabel("ZAKTUALIZOWANO ADRES"); } else { formAdmin.setOperationStatusLabel("BŁĄD PRZY AKTUALIZOWANIU NOWEGO ADRESU"); } } catch (Exception) { formAdmin.setOperationStatusLabel("BŁĄD PRZY AKTUALIZOWANIU ADRESU"); MessageBox.Show("Niepoprawne dane"); } formAdmin.RefreshDataGridView(); } }