private void Cancel_button_Click(object sender, EventArgs e) { FN_box.Clear(); LN_box.Clear(); Address_box.Clear(); Phone_box.Clear(); Email_box.Clear(); this.Close(); add_bool = false; }
private void Save_button_Click(object sender, EventArgs e) { bool empty_FN = string.IsNullOrWhiteSpace(FN_box.Text); bool empty_LN = string.IsNullOrWhiteSpace(LN_box.Text); bool empty_Address = string.IsNullOrWhiteSpace(Address_box.Text); bool empty_Phone = string.IsNullOrWhiteSpace(Phone_box.Text); bool empty_Email = string.IsNullOrWhiteSpace(Email_box.Text); if (FN_box.Text.Contains(" ") == true || LN_box.Text.Contains(" ") == true || Phone_box.Text.Contains(" ") == true || Email_box.Text.Contains(" ") == true) { MessageBox.Show("Serio?? Usun ta spacje deklu!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (empty_FN == true) { MessageBox.Show("Podaj imie!", "Error", MessageBoxButtons.OK); FN_box.Clear(); return; } if (empty_LN == true) { MessageBox.Show("Podaj nazwisko!", "Error", MessageBoxButtons.OK); LN_box.Clear(); return; } if (empty_Address == true) { MessageBox.Show("Podaj adres!", "Error", MessageBoxButtons.OK); Address_box.Clear(); return; } if (empty_Phone == true || is_numeric() == false || Phone_box.Text.Length != 9) { MessageBox.Show("Podaj poprawny numer telefonu!", "Error", MessageBoxButtons.OK); Phone_box.Clear(); return; } if (empty_Email == true) { MessageBox.Show("Podaj email!", "Error", MessageBoxButtons.OK); Email_box.Clear(); return; } Person person = new Person(); person.First_name = FN_box.Text; person.Last_name = LN_box.Text; person.Address = Address_box.Text; person.Phone_number = Phone_box.Text; person.Email_address = Email_box.Text; new_Person = person; full_name = FN_box.Text + " " + LN_box.Text; add_bool = true; FN_box.Clear(); LN_box.Clear(); Address_box.Clear(); Phone_box.Clear(); Email_box.Clear(); this.Close(); }