private void button2_Click(object sender, EventArgs e) { int year, month, day; try { year = int.Parse(textBox2.Text); month = int.Parse(textBox3.Text); day = int.Parse(textBox4.Text); } catch (Exception) { month = 0; day = 0; year = 0; } if (month > 0 && month < 13 && day > 0 && day < 32 && year < 3000) { int code = int.Parse(comboBox1.GetItemText(this.comboBox1.SelectedItem)); MenuForm.listOuvrages.ModifyOuvrage(code, textBox1.Text, new DateTime(year, month, day)); Ouvrage ouvrage = MenuForm.listOuvrages.Recherche(code); ouvrage.Auteurs.Clear(); foreach (string x in listBox1.Items) { ouvrage.AddAuteur(x); MenuForm.ouvrage.AddAuteur(x); } label7.Text = ""; MessageBox.Show("Modification avec succés"); this.Close(); } else { textBox2.Text = ""; textBox5.Text = ""; textBox4.Text = ""; label7.Text = "verifié la date "; } }
private void button1_Click(object sender, EventArgs e) { int year, month, day; try { year = int.Parse(textBox2.Text); month = int.Parse(textBox4.Text); day = int.Parse(textBox5.Text); } catch (Exception) { month = 0; day = 0; year = 0; } if (month > 0 && month < 13 && day > 0 && day < 32 && year < 3000) { Ouvrage ouvrage = new Ouvrage(textBox1.Text, new DateTime(year, month, day)); foreach (string x in listBox1.Items) { ouvrage.AddAuteur(x); MenuForm.ouvrage.AddAuteur(x); } MenuForm.listOuvrages.Liste.Add(ouvrage); MessageBox.Show("Ajouter avec succés"); this.Close(); label7.Text = ""; } else { textBox2.Text = ""; textBox5.Text = ""; textBox4.Text = ""; label7.Text = "verifié la date "; } }