Пример #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text == "Telefon")
     {
         try
         {
             Phone.AddPhone(dateTimePicker1.Value, comboBox2.SelectedIndex, textBox1.Text);
             this.Close();
         }
         catch (Exception exception)
         {
             Error errorBox = new Error(exception.Message);
             errorBox.Show();
         }
     }
     else if (comboBox1.Text == "Spotkanie")
     {
         try
         {
             Meeting.AddMeeting(dateTimePicker1.Value, comboBox2.SelectedIndex, textBox1.Text);
             this.Close();
         }
         catch (Exception exception)
         {
             Error errorBox = new Error(exception.Message);
             errorBox.Show();
         }
     }
     else if (comboBox1.Text == "Praca domowa")
     {
         try
         {
             Homework.AddHomework(dateTimePicker1.Value, comboBox2.SelectedIndex, textBox1.Text);
             this.Close();
         }
         catch (Exception exception)
         {
             Error errorBox = new Error(exception.Message);
             errorBox.Show();
         }
     }
     else if (comboBox1.Text == "Obowiązek domowy")
     {
         try
         {
             Duty.AddDuty(dateTimePicker1.Value, comboBox2.SelectedIndex, textBox1.Text);
             this.Close();
         }
         catch (Exception exception)
         {
             Error errorBox = new Error(exception.Message);
             errorBox.Show();
         }
     }
 }
Пример #2
0
 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();
             }
         }
     }
 }
Пример #3
0
 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();
         }
     }
 }