1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice
Welcome to our Education website, plz like our page facebook to support us. Thank You and wish you good navigation

examen programmation evenementielle c#: programmation événementielle c# exercices corrigés :

abdelouafiMay 18, 2017

    1. abdelouafi

      abdelouafi Administrator Staff Member

      Messages:
      402
      Likes Received:
      9
      Trophy Points:
      18
      Joined
      Sep 13, 2016
      programmation évenementielle 3.png
      programmation évenementielle.png
      programmation évenementielle 2.png
      programmation évenementielle c#.png
       
      Last edited: May 19, 2017
      Loading...
      1-
      Code:
      public static List<Employe> collec = new List<Employe>();
      2-

      Code:
      private void Form1_Load(object sender, EventArgs e)
              {           
                  txt_salaire.Text = "0";
                  txt_categorie.Text = "0";
                  txt_mtle.Enabled = false;
                  list_employes.BorderStyle = BorderStyle.FixedSingle;
                  list_employes.View = View.Details;
                  list_employes.Columns.Add("Matricule");
                  list_employes.Columns.Add("Nom");
                  list_employes.Columns.Add("Date naissance");
                  list_employes.Columns.Add("Date Embauche");
                  list_employes.Columns.Add("Age à la retraite");
                  list_employes.Columns.Add("Salaire à payer");
              }
      
      3-
      Code:
      private void rb_agent_CheckedChanged(object sender, EventArgs e)
              {
                  if (rb_agent.Checked)
                      lbl_categorie.Text = "Prime:";
                  else
                      lbl_categorie.Text = "Heure sup:";           
              }
      
              private void rb_formateur_CheckedChanged(object sender, EventArgs e)
              {
                  rb_agent_CheckedChanged(sender, e);
              }
      4-

      Code:
      private void btn_ajouter_Click(object sender, EventArgs e)
              {
                  try
                  {
                      if (!Vides())
                      {
                          double salaire = double.Parse(txt_salaire.Text);
                          if (salaire >= 0)
                          {
                              if (rb_agent.Checked)
                              {
                                  Program.col.Add(new Agent(txt_nom.Text,dp_dNaissance.Value,dp_Embauche.Value,salaire,double.Parse(txt_categorie.Text)));
                                 
                              }
                              else
                              {
                                  Program.col.Add(new Formateur(txt_nom.Text, dp_dNaissance.Value, dp_Embauche.Value, salaire, int.Parse(txt_categorie.Text)));                           
                              }
                              Employe ag=Program.col[Program.col.Count-1];
                              string[] detail = { ag.Matricule.ToString(), ag.Nom, ag.DateNaissance.ToString("dd/MM/yyyy"), ag.DateEmbauche.ToString("dd/MM/yyyy"), ag.DateRetraite(60).ToString("dd/MM/yyyy"), ag.SalaireAPayer().ToString() };
                              list_employes.Items.Add(new ListViewItem(detail));
                          }
                      }
                  }
                  catch (Exception ex)
                  {
                      MessageBox.Show(ex.Message);
                  }
              }
      
      public bool Vides()
              {
                  return (txt_nom.Text == "") || (txt_salaire.Text == "") || (txt_categorie.Text == "");
              }
      
      
      5-
      Code:
      private void btn_supprimer_Click(object sender, EventArgs e)
              {
                  try
                  {
                      if (MessageBox.Show("Vous voulez supprimer cet employé?", "Confirmer suppression:", MessageBoxButtons.YesNo) == DialogResult.Yes)
                      {
                          int index = list_employes.SelectedIndices[0];
                          Program.col.RemoveAt(index);
                          list_employes.Items.RemoveAt(index);
                      }
                  }
                  catch (Exception ex)
                  {
                     
                     MessageBox.Show(ex.Message);
                  }
              }
      6-
      Code:
      private void btn_exporter_Click(object sender, EventArgs e)
              {
                  try
                  {
                      FileStream f = new FileStream("Liste_employes.bin", FileMode.Create);
                      BinaryFormatter bf = new BinaryFormatter();
                      bf.Serialize(f, Program.col);
                      f.Close();
                      MessageBox.Show("Enregistrement effectué avec succès!");
                  }
                  catch (Exception ex)
                  {
      
                      MessageBox.Show(ex.Message);
                  }
              }
      7-
      Code:
      private void list_employes_SelectedIndexChanged(object sender, EventArgs e)
              {           
                  try
                  {
                      int index = list_employes.SelectedIndices[0];
                      if (Program.col[index] is Agent)
                      {
                          rb_agent.Checked = true;
                          Agent ag = (Agent)Program.col[index];
                          txt_mtle.Text = ag.Matricule.ToString();
                          txt_nom.Text = ag.Nom;
                          dp_dNaissance.Value = ag.DateNaissance;
                          dp_Embauche.Value = ag.DateEmbauche;
                          txt_salaire.Text = ag.SalaireBase.ToString();
                          txt_categorie.Text = ag.PrimeResponsabilite.ToString();
                      }
                      else
                      {
                          rb_formateur.Checked = true;
                          Formateur ag = (Formateur)Program.col[index];
                          txt_mtle.Text = ag.Matricule.ToString();
                          txt_nom.Text = ag.Nom;
                          dp_dNaissance.Value = ag.DateNaissance;
                          dp_Embauche.Value = ag.DateEmbauche;
                          txt_salaire.Text = ag.SalaireBase.ToString();
                          txt_categorie.Text = ag.HeureSup.ToString();
                      }
                  }
                  catch (ArgumentOutOfRangeException ex)
                  {
                  }
                  catch (Exception ex)
                  {
      
                      MessageBox.Show(ex.Message);
                  }
              }
Tags:

Share This Page

Share