bouchnina

Class Enfant

Jul 12th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Collections;
  6. namespace nbr_enfant
  7. {
  8.     class enfanat
  9.     {
  10.         public static ArrayList E = new ArrayList();
  11.         private int matricuel;
  12.        
  13.         private string nom;
  14.         private string prenom;
  15.         private DateTime date_naiss;
  16.          private string sexe;
  17.      
  18.        
  19.        
  20.         public int GetMatricule()
  21.         {
  22.  
  23.             return this.matricuel;
  24.         }
  25.         public string GetNom()
  26.         {
  27.             return this.nom;
  28.  
  29.  
  30.         }
  31.         public string Getprenom()
  32.         {
  33.             return this.prenom;
  34.  
  35.         }
  36.         public string GetSexe()
  37.         {
  38.             return this.sexe;
  39.  
  40.         }
  41.         public DateTime GetDate_naiss()
  42.         {
  43.  
  44.             return this.date_naiss;
  45.         }
  46.        
  47.         //les methode d'acces en ecriture
  48.         public void SetNom(string nom)
  49.         {
  50.  
  51.             this.nom = nom.ToUpper();
  52.  
  53.         }
  54.         public void SetPrenom(string prenom)
  55.         {
  56.             this.prenom = prenom.Substring(0, 1).ToUpper() + prenom.Substring(1).ToLower();
  57.  
  58.  
  59.         }
  60.         public void SetMat(int mat)
  61.         {
  62.             this.matricuel = mat;
  63.  
  64.         }
  65.         public void SetSexe(string sexe)
  66.         {
  67.             this.sexe = sexe;
  68.  
  69.         }
  70.         public void SetDate(DateTime date)
  71.         {
  72.             this.date_naiss = date;
  73.  
  74.         }
  75.        
  76.         // les constructeur
  77.         public enfanat()
  78.         {
  79.  
  80.  
  81.         }
  82.         public enfanat(int mat, string nom, string prenom, DateTime date,string sexe ){
  83.  
  84.  
  85.  
  86.             this.SetMat(mat);
  87.             this.SetNom(nom);
  88.             this.SetPrenom(prenom);
  89.             this.sexe = sexe;
  90.  
  91.          
  92.             this.SetDate(date);
  93.  
  94.         }
  95.         public void afficher()
  96.         {
  97.  
  98.  
  99.             Console.WriteLine("Matricule " + this.GetMatricule() + "nom" + this.GetNom() + "prenom" + this.Getprenom() + "la date de naissance " + this.GetDate_naiss());
  100.  
  101.         }
  102.         public static void ajoutenfant(enfanat r)
  103.         {
  104.             E.Add(r);
  105.  
  106.  
  107.         }
  108.  
  109.  
  110.  
  111.      
  112.     }
  113.  
  114. }
  115.  
  116.  
  117. using System;
  118. using System.Collections.Generic;
  119. using System.ComponentModel;
  120. using System.Data;
  121. using System.Drawing;
  122. using System.Linq;
  123. using System.Text;
  124. using System.Windows.Forms;
  125.  
  126. namespace nbr_enfant
  127. {
  128.     public partial class da : Form
  129.     {
  130.         public da()
  131.         {
  132.             InitializeComponent();
  133.         }
  134.         public bool verifier()
  135.         {
  136.  
  137.             if (textBoxMatricule.Text == "" || textBoxNom.Text == "" || textBoxPrenom.Text == "")
  138.             {
  139.                 return true;
  140.             }
  141.             return false;
  142.         }
  143.  
  144.         private void btnAjouter_Click(object sender, EventArgs e)
  145.         {
  146.             if (verifier() == true)
  147.             {
  148.  
  149.                 MessageBox.Show("veuillez remplir tout les champs ");
  150.  
  151.             }
  152.  
  153.             else
  154.             {
  155.                 string r;
  156.                 if (radioButtonFille.Checked == true)
  157.                 {
  158.                     r= "fille";
  159.                 }
  160.                 else
  161.                 {
  162.  
  163.  
  164.  
  165.                     r = "garçans";
  166.                 }
  167.  
  168.                 enfanat l = new enfanat(int.Parse(textBoxMatricule.Text), textBoxNom.Text, textBoxPrenom.Text, dateTimePicker1.Value,r);
  169.  
  170.                 enfanat.E.Add(l);
  171.              
  172.  
  173.                 textBoxMatricule.Text = "";
  174.                 textBoxNom.Text = "";
  175.                 textBoxPrenom.Text = "";
  176.                 dataGridView1.Rows.Add(l.GetMatricule(), l.GetNom(), l.Getprenom(), l.GetDate_naiss(), l.GetSexe());
  177.  
  178.  
  179.  
  180.  
  181.             }
  182.  
  183.         }
  184.  
  185.         private void btnModifier_Click(object sender, EventArgs e)
  186.         {
  187.             for (int i=0;i<enfanat.E.Count;i++){
  188.                 if (int.Parse(textBoxMatricule.Text)==enfanat.E[i].
  189.  
  190.  
  191.  
  192.             }
  193.         }
  194.  
  195.     }
  196. }
Advertisement
Add Comment
Please, Sign In to add comment