private void button2_Click(object sender, EventArgs e) { if (t == 1) { if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox2.Text) && !string.IsNullOrWhiteSpace(textBox3.Text)) { try { Contact.AddContact(textBox1.Text, textBox2.Text, textBox3.Text); this.Close(); } catch (Exception exception) { Error errorBox = new Error(exception.Message); errorBox.Show(); } } } else if (t == 2) { if (!string.IsNullOrWhiteSpace(textBox1.Text)) { try { Homework.AddSubject(textBox1.Text); this.Close(); } catch (Exception exception) { Error errorBox = new Error(exception.Message); errorBox.Show(); } } } else if (t == 3) { if (!string.IsNullOrWhiteSpace(textBox1.Text)) { try { Duty.AddDutyType(textBox1.Text); this.Close(); } catch (Exception exception) { Error errorBox = new Error(exception.Message); errorBox.Show(); } } } }
private void button2_Click(object sender, EventArgs e) { if (t == 1) { try { Contact.RemoveContact(listBox1.SelectedIndex); } catch (Exception exception) { Error errorBox = new Error(exception.Message); errorBox.Show(); } } else if (t == 2) { try { Homework.RemoveSubject(listBox1.SelectedIndex); } catch (Exception exception) { Error errorBox = new Error(exception.Message); errorBox.Show(); } } else if (t == 3) { try { Duty.RemoveDutyType(listBox1.SelectedIndex); } catch (Exception exception) { Error errorBox = new Error(exception.Message); errorBox.Show(); } } }