private void button5_Click(object sender, EventArgs e) { if (button5.Text == "Ajouter") { textenablT(); textBox1.Clear(); textBox2.Clear(); textBox4.Clear(); textBox3.Clear(); textBox5.Clear(); button5.Text = "Valider"; buttonEnablF(); buttonposF(); button9.Enabled = true; } else // try khesha tkon hna { if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && button5.Text == "Valider") { if (Chs.NombreChasseursParticipant <= 0) { buttonposF(); button8.Enabled = false; } else { if (Chs.NombreChasseursParticipant == 1) { button8.Enabled = false; buttonposF(); button2.Enabled = true; button3.Enabled = true; } else { buttonposT(); button8.Enabled = true; } } Chs.Ajouter(CreerCh()); button5.Text = "Ajouter"; position(); button9.Enabled = false; button7.Enabled = true; button6.Enabled = true; textenablF(); } else { MessageBox.Show("Remplire les zones de text vide .", "Champs vide", MessageBoxButtons.OK); } } }
private void button5_Click(object sender, EventArgs e) { if (button5.Text == "Ajouter") { #region getion intrface bouton Ajouter textBox1.Clear(); textBox1.ReadOnly = false; textBox2.Clear(); textBox2.ReadOnly = false; textBox3.Clear(); textBox3.ReadOnly = false; textBox4.Clear(); textBox4.ReadOnly = false; textBox5.Clear(); textBox5.ReadOnly = false; button1.Enabled = false; button2.Enabled = false; button3.Enabled = false; button4.Enabled = false; button6.Enabled = false; button7.Enabled = false; button8.Enabled = false; button9.Enabled = true; #endregion button5.Text = "Valider"; } else { try { if (!Chs.RechercheDoublon(int.Parse(textBox1.Text))) { Chs.Ajouter(CréerChasseur()); } else { MessageBox.Show("Impossible d'ajouter le chasseur: " + textBox2.Text + " , car il y a déja un vchasseur qui porte ce numéro"); } } catch (DepacementNombrePartissipantException ex) { MessageBox.Show(ex.MessageDétaillé); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally{ EtatInitiale(); AfficherChasseur(Chs.ChasseurEncours); label6.Text = EnregistrementEncours(); } } }