1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| class Personne
{
private string Nom;
private string Prenom;
private DateTime DateNaiss;
private Boolean Genre;
private string EtatCivil;
private string Adresse;
private int TelFixe;
private int TelPort;
private int TelProf;
public Personne(string Nom,string Prenom, DateTime DateNaiss, Boolean Genre, string EtatCivil, string Adresse, int TelFixe, int TelPort, int TelProf)
{
this.Nom = Nom;
this.Prenom = Prenom;
this.DateNaiss = DateNaiss;
this.Genre = Genre;
this.EtatCivil = EtatCivil;
this.Adresse = Adresse;
this.TelFixe = TelFixe;
this.TelPort = TelPort;
this.TelProf = TelProf;
}
public void Print()
{
FileStream fs = new FileStream("c:\\InfoUtilisateur.txt", FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write);
fs.Close();
StreamWriter sw = new StreamWriter("c:\\InfoUtilisateur.txt", true, Encoding.ASCII);
sw.WriteLine(lbNom.Text + " ",Nom);
sw.WriteLine(lbPrenom.Text + " ",Prenom);
sw.WriteLine(lbDateNaiss.Text + " ",DateNaiss);
sw.WriteLine(lbSexe.Text + " ",Genre);
sw.WriteLine(lbEtatCiv.Text + " ",EtatCivil);
sw.WriteLine(lbAdress.Text + " ",Adresse);
sw.WriteLine(lbTelFixe.Text + " ",TelFixe);
sw.WriteLine(lbTelPort.Text + " ",TelPort);
sw.WriteLine(lbTelProf.Text + " ", TelProf);
sw.Close();
}
public void Affiche()
{
Personne p1 = new Personne(txtBoxNom.Text, txtBoxPrenom.Text, maskedTextBoxDateNaiss.Text, cmbBoxSexe.Text, txtBoxEtatCiv.Text, txtBoxAdress.Text, txtBoxTelFixe.Text, txtBoxTelPort.Text, txtBoxTelProf.Text);
p1.Print();
}
} |
Partager