Guest User

Untitled

a guest
Apr 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.43 KB | None | 0 0
  1. voila le code de mon resize dans ma classe inscriptions
  2.  
  3. if (nbJoueurs == vectJoueurs.Length)
  4.             {
  5.                 Array.Resize(ref vectJoueurs, vectJoueurs.Length + 5);//Rajout de 5 à sa longueur
  6.             }
  7.  
  8. //=============================
  9. //Fichier : FrmPrincipal.cs
  10. //Programmeur : Kevin Fortier
  11. //Date : Décembre 2011
  12. //=============================
  13. using System;
  14. using System.Collections.Generic;
  15. using System.ComponentModel;
  16. using System.Data;
  17. using System.Drawing;
  18. using System.Linq;
  19. using System.Text;
  20. using System.Windows.Forms;
  21. using System.IO;
  22.  
  23. namespace Fortier_Kevin_TP4A2011
  24. {
  25.     public partial class FrmPrincipal : Form
  26.     {
  27.         //============
  28.         //Attributs
  29.         //============
  30.         private Inscriptions uneInscription;
  31.         private Joueur unJoueur;
  32.  
  33.         //============
  34.         //Constructeur
  35.         //============
  36.         public FrmPrincipal()
  37.         {
  38.             InitializeComponent();
  39.             this.uneInscription = new Inscriptions();
  40.         }
  41.  
  42.         private void btnCreerJoueur_Click(object sender, EventArgs e)
  43.         {
  44.             try
  45.             {
  46.                 FrmJoueur frmJoueur = new FrmJoueur();
  47.                 DialogResult joueurAccepter = frmJoueur.ShowDialog();
  48.  
  49.                 if (joueurAccepter != DialogResult.OK)
  50.                 {
  51.                     MessageBox.Show("Aucune donnee n'a ete retenue");
  52.                 }
  53.                 else
  54.                 {
  55.             //ICICICICICIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
  56.                     unJoueur = frmJoueur.joueur;
  57.                         //Ajout du joueur aux inscriptions
  58.                         lesInscriptions.AjouterJoueur(unJoueur);
  59.                         break;
  60.                 }
  61.                 frmJoueur.Dispose();
  62.             }
  63.             catch (Exception err)
  64.             {
  65.                 MessageBox.Show("Erreur imprevue : " + err.Message);
  66.             }
  67.         }
  68.  
  69.         private void btnQuitter_Click(object sender, EventArgs e)
  70.         {
  71.             this.Close();
  72.         }
  73.  
  74.         private void btnLifrFichierJoueur_Click(object sender, EventArgs e)
  75.         {
  76.             try
  77.             {
  78.                 OpenFileDialog dlgOuvrir = new OpenFileDialog();
  79.                 dlgOuvrir.Title = "Ouverture de fichier";
  80.                 dlgOuvrir.Filter = "Fichier texte (*.txt)|*.txt" + "|Tous les fichiers (*.*)|*.*";
  81.                 dlgOuvrir.InitialDirectory = "C:\\Users\\Kevin\\École\\Prog 2\\TP\\Fortier Kevin TP4A2011\\Fortier Kevin TP4A2011\\bin\\Debug";
  82.  
  83.                 DialogResult resultat = dlgOuvrir.ShowDialog();
  84.                 string nomFichier = dlgOuvrir.FileName;
  85.  
  86.                 if (resultat == DialogResult.Cancel)
  87.                 {
  88.                     MessageBox.Show("Aucun fichier selectionne");
  89.                 }
  90.                 else
  91.                 {
  92.                     MessageBox.Show(nomFichier);
  93.                    
  94.                     uneInscription.LireFichierJoueur(nomFichier);
  95.                 }
  96.             }
  97.             catch (NullReferenceException err)
  98.             {
  99.                 MessageBox.Show("Aucun joueur enregistrer : " + err);
  100.             }
  101.             catch (Exception err)
  102.             {
  103.                 MessageBox.Show("Erreur inprevue : " + err.Message);
  104.             }
  105.         }
  106.         private void btnSauvegarderJoueurs_Click(object sender, EventArgs e)
  107.         {
  108.             try
  109.             {
  110.                 SaveFileDialog svgFichier = new SaveFileDialog();
  111.                 svgFichier.Title = "Ouverture de fichier";
  112.                 svgFichier.Filter = "Fichier texte (*.txt)|*.txt" + "|Tous les fichiers (*.*)|*.*";
  113.                 svgFichier.InitialDirectory = "C:\\Users\\Kevin\\École\\Prog 2\\TP\\Fortier Kevin TP4A2011\\Fortier Kevin TP4A2011\\bin\\Debug";
  114.  
  115.                 DialogResult resultat = svgFichier.ShowDialog();
  116.                 string nomFichier = svgFichier.FileName;
  117.  
  118.                 if (resultat == DialogResult.Cancel)
  119.                 {
  120.                     MessageBox.Show("Aucun fichier sauvegarder");
  121.                 }
  122.                 else
  123.                 {
  124.                     MessageBox.Show(nomFichier);
  125.                 }
  126.  
  127.                 if (uneInscription.Joueurs == null)
  128.                 {
  129.                     MessageBox.Show("Aucun joueur sauvegarder");
  130.                 }
  131.                 else
  132.                 {
  133.                     uneInscription.EcrireFichierJoueurs(nomFichier);
  134.                 }
  135.             }
  136.             catch (Exception err)
  137.             {
  138.                 MessageBox.Show("Erreur inprevue : " + err.Message);
  139.             }
  140.         }
  141.         private void btnAffJoueurs_Click(object sender, EventArgs e)
  142.         {
  143.             try
  144.             {
  145.                 FrmListeJoueurs frmJoueur = new FrmListeJoueurs(uneInscription);
  146.                 frmJoueur.ShowDialog();
  147.             }
  148.             catch (NullReferenceException err)
  149.             {
  150.                 MessageBox.Show("Aucun joueur enregistrer : " + err);
  151.             }
  152.         }
  153.  
  154.         private void btnJouer_Click(object sender, EventArgs e)
  155.         {
  156.             if (uneInscription.Joueurs == null)
  157.             {
  158.                 MessageBox.Show("Il n'y a aucun joueur");
  159.             }
  160.             else
  161.             {
  162.                 FrmAttributionPoints frmAttributionPoints = new FrmAttributionPoints(uneInscription);
  163.             }            
  164.         }
  165.     }
  166. }
Add Comment
Please, Sign In to add comment