Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Threading;
- using System.Text;
- using System.Linq;
- namespace ProjetFinalP2O
- {
- public class DepotVente
- {
- public List<Don> dons;
- public double Total;
- public string NomDepot;
- public DepotVente(string nom)
- {
- this.NomDepot = nom;
- this.Total = 1000;
- this.dons = new List<Don>();
- }
- }
- public abstract class PersonneMorale
- {
- string EntrepriseNom;
- string Dirigeant;
- }
- public class Don : IComparable<Don>
- {
- public string Date;
- public string Type;
- public string Référence;
- public string Nom;
- public string Tel;
- public string Adresse;
- public string Description;
- public int Statut; // 0 RIEN 1 ACCEPTE 2 REFUSE 3 STOCKE 4 ARCHIVE
- public Beneficiaire beneficiaire;
- public double Montant;
- public Don(string a, string b, string c, string d, string e, string f, string g, int h)
- {
- this.Date = a;
- this.Type = b;
- this.Référence = c;
- this.Nom = d;
- this.Tel = e;
- this.Adresse = f;
- this.Description = g;
- this.Statut = h;
- this.beneficiaire = null;
- this.Montant = 0.0;
- }
- public void AjouterBenef(Beneficiaire b)
- {
- this.beneficiaire = b;
- }
- public void AjouterMontant(double x)
- {
- this.Montant = x;
- }
- public void SetStatut(int statut)
- {
- this.Statut = statut;
- }
- public virtual string ToString()
- {
- string retour = null;
- retour += "Date : ";
- retour += this.Date;
- retour += "\n";
- retour += "Type : ";
- retour += this.Type;
- retour += "\n";
- retour += "Reference : ";
- retour += this.Référence;
- retour += "\n";
- retour += "Nom : ";
- retour += this.Nom;
- retour += "\n";
- retour += "Tel : ";
- retour += this.Tel;
- retour += "\n";
- retour += "Adresse : ";
- retour += this.Adresse;
- retour += "\n";
- retour += "Description : ";
- retour += this.Description;
- retour += "\n";
- return retour;
- }
- public int TriDate(Don objet)
- {
- DateTime date1 = Convert.ToDateTime(this.Date);
- DateTime date2 = Convert.ToDateTime(objet.Date);
- if(date1 > date2)
- {
- return 1;
- }
- if(date2 > date1)
- {
- return -1;
- }
- return 0;
- }
- }
- public class Objet_Volumineux : Don
- {
- public double longueur;
- public double largeur;
- public string meuble;
- public Objet_Volumineux(string a, string b, string c, string d, string e, string f, string g, int h, double i,double j, string k)
- :base(a,b,c,d,e,f,g,h)
- {
- this.longueur = i;
- this.largeur = j;
- this.meuble = k;
- }
- public override string ToString()
- {
- string retour = base.ToString();
- retour += "Longueur : ";
- retour += this.longueur;
- retour += "\n";
- retour += "Largeur : ";
- retour += this.largeur;
- retour += "\n";
- retour += "Meuble : ";
- retour += this.meuble;
- retour += "\n";
- return retour;
- }
- }
- public class Cuisiniere : Objet_Volumineux
- {
- double puissance;
- int nombre_de_plaque;
- public Cuisiniere(string a, string b, string c, string d, string e, string f, string g, int h, double i, double j,double k, int l, string m)
- :base(a, b, c, d, e, f, g, h,i,j,m)
- {
- this.puissance = k;
- this.nombre_de_plaque = l;
- }
- public override string ToString()
- {
- string retour = base.ToString();
- retour += "Puissance : ";
- retour += this.puissance;
- retour += "\n";
- retour += "Nombre de plaques : ";
- retour += this.nombre_de_plaque;
- retour += "\n";
- return retour;
- }
- }
- public class Table : Objet_Volumineux
- {
- string Type_Table;
- string Forme;
- public Table(string a, string b, string c, string d, string e, string f, string g, int h, double i, double j, string k, string l, string m)
- :base(a, b, c, d, e, f, g, h, i, j,m)
- {
- this.Type_Table = k;
- this.Forme = l;
- }
- public override string ToString()
- {
- string retour = base.ToString();
- retour += "Type de table : ";
- retour += this.Type_Table;
- retour += "\n";
- retour += "Forme : ";
- retour += this.Forme;
- retour += "\n";
- return retour;
- }
- }
- public class Vaisselle : Don
- {
- string vaisselle;
- int nombre;
- public Vaisselle(string a, string b, string c, string d, string e, string f, string g, int h, string i, int j)
- :base(a, b, c, d, e, f, g, h)
- {
- this.vaisselle = i;
- this.nombre = j;
- }
- public override string ToString()
- {
- string retour = base.ToString();
- retour += "Vaisselle : ";
- retour += this.vaisselle;
- retour += "\n";
- retour += "Nombre : ";
- retour += this.nombre;
- retour += "\n";
- return retour;
- }
- }
- public class Stock
- {
- public Don Objets;
- public Stock(Don objets)
- {
- this.Objets = objets;
- }
- public virtual string ToString()
- {
- return Objets.ToString();
- }
- }
- public class Garde_Meuble : Stock
- {
- public Beneficiaire Benef;
- public string Date_Depot;
- public string Date_Enlevement;
- public Garde_Meuble(Don objets, Beneficiaire benef, string date_depot, string date_enlevement)
- : base(objets)
- {
- this.Benef = benef;
- this.Date_Depot = date_depot;
- this.Date_Enlevement = date_enlevement;
- }
- public override string ToString()
- {
- string retour = base.ToString();
- retour += "Beneficiaire : \n";
- retour += Benef.ToString();
- retour += "\n";
- retour += "Date de Depot :";
- retour += this.Date_Depot;
- retour += "\n";
- retour += "Date d'enlevement ";
- retour += this.Date_Enlevement;
- return retour;
- }
- }
- public class Adherent
- {
- public int ID;
- public string Nom;
- public string Adresse;
- public string Telephone;
- public string Prenom;
- public string Statut;
- public Adherent(int a, string b, string c, string d, string e, string f)
- {
- this.ID = a;
- this.Nom = b;
- this.Adresse = c;
- this.Telephone = d;
- this.Prenom = e;
- this.Statut = f;
- }
- }
- public class Beneficiaire
- {
- public int ID;
- public string Nom;
- public string Adresse;
- public string Telephone;
- public string Prenom;
- public string DateNaissance;
- public Beneficiaire(int a, string b, string c, string d, string e, string f)
- {
- this.ID = a;
- this.Nom = b;
- this.Adresse = c;
- this.Telephone = d;
- this.Prenom = e;
- this.DateNaissance = f;
- }
- public override string ToString()
- {
- return "ID : " + Convert.ToString(this.ID) + "\n" + "Nom : " + this.Nom + "\n" + "Adresse : " + this.Adresse + "\n" + "Telephone : " + this.Telephone + "\n" + "Prenom : " + this.Prenom + "\n" + "Date de Naissance : " + this.DateNaissance;
- }
- }
- class MainClass
- {
- public static void AjouterBenef(List<Beneficiaire> beneficiaires)
- {
- Console.WriteLine("Nom ? ");
- string nom = Console.ReadLine();
- Console.WriteLine("Adresse ? ");
- string adresse = Console.ReadLine();
- Console.WriteLine("Telephone ? ");
- string telephone = Console.ReadLine();
- Console.WriteLine("Prenom ?");
- string prenom = Console.ReadLine();
- Console.WriteLine("Date de naissance ?");
- string datenaissance = Console.ReadLine();
- Beneficiaire temp = new Beneficiaire(beneficiaires.Count+1, nom, adresse, telephone, prenom, datenaissance);
- beneficiaires.Add(temp);
- }
- delegate int Operation(int valeur1, int valeur2);
- static int Addition(int v1, int v2)
- {
- return v1 + v2;
- }
- static int Soustraction(int v1, int v2)
- {
- return v1 - v2;
- }
- static int Multiplication(int v1, int v2)
- {
- return v1 * v2;
- }
- static int Division(int v1, int v2)
- {
- return v1 / v2;
- }
- static int AppliquerOperation(Operation o, int v1, int v2)
- {
- return o(v1, v2);
- }
- public static void Calculatrice()
- {
- Console.WriteLine("Valeur 1 :");
- int val1 = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Valeur 2 :");
- int val2 = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("+ - * / ?");
- string ope = Console.ReadLine();
- int resultat = 0;
- if(ope == "+")
- {
- resultat = AppliquerOperation(Addition, val1, val2);
- }
- if (ope == "-")
- {
- resultat = AppliquerOperation(Soustraction, val1, val2);
- }
- if (ope == "/")
- {
- resultat = AppliquerOperation(Division, val1, val2);
- }
- if (ope == "*")
- {
- resultat = AppliquerOperation(Multiplication, val1, val2);
- }
- Console.WriteLine(resultat);
- }
- public static void MoyDepotRecep(List<Garde_Meuble> GM)
- {
- List<int> intervalle = new List<int>();
- int days;
- foreach(Garde_Meuble item in GM)
- {
- days = Convert.ToInt32(Convert.ToDateTime(item.Date_Enlevement) - Convert.ToDateTime(item.Date_Depot));
- intervalle.Add(days);
- }
- Console.WriteLine(intervalle.Average());
- }
- public static void MoyPrixDepotVente(List<DepotVente> DV)
- {
- List<double> prix = new List<double>();
- foreach(DepotVente item in DV) {
- foreach(Don item2 in item.dons)
- {
- prix.Add(item2.Montant);
- }
- }
- Console.WriteLine(prix.Average());
- }
- public static void MoyAgeBenef(List<Beneficiaire> BL)
- {
- List<int> Age = new List<int>();
- int age;
- foreach(Beneficiaire item in BL)
- {
- age = Convert.ToInt32(DateTime.Now - Convert.ToDateTime(item.DateNaissance));
- Age.Add(age);
- }
- Console.WriteLine(Age.Average());
- }
- public static void TriDepotPrix(List<DepotVente> DV)
- {
- List<Don> DonTrieFinal = new List<Don>();
- List<Don> DonTemporaire = new List<Don>();
- foreach(DepotVente item in DV)
- {
- DonTemporaire.AddRange(item.dons);
- DonTemporaire.OrderBy(d => d.Montant);
- DonTrieFinal.AddRange(DonTemporaire);
- DonTemporaire.Clear();
- }
- }
- public static void TriDonVendu(List<Don> dons)
- {
- List<Don> nouveauDons = new List<Don>();
- foreach(Don item in dons)
- {
- if(item.Statut == 2)
- {
- nouveauDons.Add(item);
- }
- }
- nouveauDons.OrderBy(d => Convert.ToDateTime(d.Date)).ThenBy(d => d.beneficiaire.ID);
- foreach(Don item in nouveauDons)
- {
- Console.WriteLine(item.ToString());
- }
- }
- public static void TriDonStockeType(List<Garde_Meuble> GM, List<DepotVente> DV)
- {
- List<Don> DonTrieFinal = new List<Don>();
- List<Don> nouveauDons = new List<Don>();
- foreach(Garde_Meuble item in GM)
- {
- nouveauDons.Add(item.Objets);
- }
- nouveauDons.OrderBy(d => d.Type);
- DonTrieFinal.AddRange(nouveauDons);
- nouveauDons.Clear();
- foreach(DepotVente item in DV)
- {
- nouveauDons.AddRange(item.dons);
- nouveauDons.OrderBy(d => d.Type);
- DonTrieFinal.AddRange(nouveauDons);
- nouveauDons.Clear();
- }
- foreach(Don item in DonTrieFinal)
- {
- Console.WriteLine(item.ToString());
- }
- }
- public static void AfficherDV(List<DepotVente> depotVentes)
- {
- foreach(DepotVente item in depotVentes)
- {
- Console.WriteLine("###########");
- Console.WriteLine(item.NomDepot);
- Console.WriteLine(item.Total);
- Console.WriteLine("###########");
- foreach (Don item2 in item.dons)
- {
- Console.WriteLine(item2.ToString());
- }
- }
- }
- public static void CreerDV(List<DepotVente> depotVentes)
- {
- Console.WriteLine("Entrez le nom du Depot Vente :");
- string nom = Console.ReadLine();
- DepotVente temp = new DepotVente(nom);
- depotVentes.Add(temp);
- }
- public static void TransfertDonBenef(List<Don> dons, List<Beneficiaire> beneficiaires)
- {
- bool ok = false;
- while(ok == false)
- {
- foreach(Don item in dons)
- {
- if(item.Statut == 1 || item.Statut == 3)
- {
- Console.WriteLine("Objet : " + dons.IndexOf(item));
- Console.WriteLine(item.ToString());
- }
- }
- Console.WriteLine("Votre choix :");
- int choix = Convert.ToInt32(Console.ReadLine());
- foreach(Beneficiaire benef in beneficiaires)
- {
- Console.WriteLine("Beneficiaire : " + beneficiaires.IndexOf(benef));
- Console.WriteLine(benef.ToString());
- }
- Console.WriteLine("Votre choix :");
- int choix2 = Convert.ToInt32(Console.ReadLine());
- dons[choix].AjouterBenef(beneficiaires[choix2]);
- dons[choix].Statut = 4;
- Console.WriteLine("Effectué appuyez pour retourner au menu");
- Console.ReadLine();
- ok = true;
- }
- }
- public static void AfficherArchives(List<Don> dons)
- {
- foreach(Don item in dons)
- {
- if(item.Statut == 4)
- {
- Console.WriteLine(item.ToString());
- }
- }
- }
- public static void TriDonTraitement(List<Don> dons)
- {
- List<Don> DonBackup = dons;
- dons.OrderBy(x => x.Nom);
- foreach(Don item in dons)
- {
- if(item.Statut == 0 || item.Statut == 1)
- {
- Console.WriteLine(item.ToString());
- Console.WriteLine(" ");
- }
- }
- dons = DonBackup;
- }
- public static void TriDonRefuseDate(List<Don> dons)
- {
- List<Don> DonBackup = dons;
- dons.Sort((x, y) => x.TriDate(y));
- foreach(Don item in dons)
- {
- if(item.Statut == 2)
- {
- Console.WriteLine(item.ToString());
- Console.WriteLine(" ");
- }
- }
- dons = DonBackup;
- }
- public static void StockerMenu(List<Don> dons, List<Adherent> adherents, List<Beneficiaire> beneficiaires, List<Garde_Meuble> Garde_Meuble, List<DepotVente> depotVentes)
- {
- int i = 0;
- int j = 0;
- while(i < dons.Count)
- {
- if (dons[i].Statut == 1)
- {
- Console.WriteLine("(" + Convert.ToString(i) + ") " + dons[i].Type + " " + dons[i].Référence + " " + dons[i].Description);
- j++;
- }
- i++;
- }
- bool ok = false;
- while(ok == false)
- {
- Console.WriteLine("ID à stocker ?");
- string lecture = Console.ReadLine();
- if(lecture == "")
- {
- MenuDons(adherents, beneficiaires, dons, Garde_Meuble, depotVentes);
- }
- int choix = Convert.ToInt32(lecture);
- if(choix < j)
- {
- Console.WriteLine(dons[choix].ToString());
- bool ok2 = false;
- while(ok2 == false)
- {
- Console.WriteLine("1 pour stocker asso / 2 pour stocker garde-meuble / 3 pour stocker dépot vente");
- int choix2 = Convert.ToInt32(Console.ReadLine());
- if(choix2 == 1)
- {
- StockageAsso(dons, adherents, beneficiaires, choix);
- ok2 = true;
- }
- if(choix2 == 2)
- {
- StockageGardeMeuble(dons, adherents, beneficiaires, Garde_Meuble, choix, depotVentes);
- ok2 = true;
- }
- if(choix2 == 3)
- {
- StockageDV(dons, adherents, beneficiaires, Garde_Meuble, choix, depotVentes);
- ok2 = true;
- }
- ok = true;
- }
- }
- }
- }
- public static void StockageAsso(List<Don> dons, List<Adherent> adherents, List<Beneficiaire> beneficiaires, int choix)
- {
- dons[choix].Statut = 3;
- Console.WriteLine("Don stocké dans l'association. Appuyez sur une touche pour revenir au menu");
- Console.ReadLine();
- }
- public static void StockageGardeMeuble(List<Don> dons, List<Adherent> adherents, List<Beneficiaire> beneficiaire, List<Garde_Meuble> Garde_Meuble, int choix, List<DepotVente> depotVentes)
- {
- bool ok = false;
- int index = 0;
- while (ok == false)
- {
- Console.WriteLine("Nom du beneficiaire :");
- string benef = Console.ReadLine();
- try
- {
- index = beneficiaire.IndexOf(beneficiaire.Find(item => item.Nom == benef));
- ok = true;
- }
- catch
- {
- Console.WriteLine("Nom introuvable");
- }
- }
- Console.WriteLine("Date de Depot");
- string date_depot = Console.ReadLine();
- Console.WriteLine("Date de retrait");
- string date_retrait = Console.ReadLine();
- dons[choix].Statut = 3;
- Garde_Meuble temp = new Garde_Meuble(dons[choix], beneficiaire[index], date_depot, date_retrait);
- Garde_Meuble.Add(temp);
- Console.WriteLine("Appuyez pour retourner au menu");
- Console.ReadKey();
- MenuDons(adherents, beneficiaire, dons, Garde_Meuble, depotVentes);
- }
- public static void StockageDV(List<Don> dons, List<Adherent> adherents, List<Beneficiaire> beneficiaire, List<Garde_Meuble> Garde_Meuble, int choix, List<DepotVente> depotVentes)
- {
- foreach(DepotVente item in depotVentes)
- {
- Console.Write(depotVentes.IndexOf(item));
- Console.Write(" ");
- Console.Write(item.NomDepot);
- Console.Write("\n");
- }
- Console.WriteLine("Choisissez votre depot vente");
- int choix2 = Convert.ToInt32(Console.ReadLine());
- dons[choix].Statut = 3;
- depotVentes[choix2].dons.Add(dons[choix]);
- Console.WriteLine("Montant ? ");
- double montant = Convert.ToDouble(Console.ReadLine());
- dons[choix].Montant = montant;
- depotVentes[choix2].Total += dons[choix].Montant;
- Console.WriteLine("Don Stocké !");
- Console.ReadLine();
- }
- public static void AfficherGardeMeuble(List<Don> dons, List<Adherent> adherents, List<Beneficiaire> beneficiaires, List<Garde_Meuble> garde_Meubles, List<DepotVente> depotVentes)
- {
- int i = 0;
- foreach(Garde_Meuble item in garde_Meubles)
- {
- Console.WriteLine("############");
- Console.WriteLine("Objet :" + i);
- Console.WriteLine("############");
- Console.WriteLine(" ");
- Console.WriteLine(item.ToString());
- Console.WriteLine("\n");
- }
- Console.WriteLine("Appuyez sur une touche pour retourner au menu.");
- Console.ReadKey();
- MenuDons(adherents, beneficiaires, dons, garde_Meubles, depotVentes);
- }
- public static void CreerDons(List<Don> dons, List<Adherent> adherents, List<Beneficiaire> beneficiaires, List<Garde_Meuble> Garde_Meuble, List<DepotVente> depotVentes)
- {
- Console.WriteLine("Creation d'un don");
- Console.WriteLine("");
- Console.WriteLine("Date ? ");
- string date = Console.ReadLine();
- Console.WriteLine("Type ? ");
- string type = Console.ReadLine();
- Console.WriteLine("Référence ? ");
- string reference = Console.ReadLine();
- Console.WriteLine("Nom ? ");
- string nom = Console.ReadLine();
- Console.WriteLine("Téléphone ? ");
- string tel = Console.ReadLine();
- Console.WriteLine("Adresse ? ");
- string adresse = Console.ReadLine();
- Console.WriteLine("Description ? ");
- string description = Console.ReadLine();
- bool ok = false;
- string choix = "";
- string Type = "";
- while (ok == false)
- {
- Console.WriteLine("Vaisselle ? (O/N)");
- choix = Console.ReadLine();
- if(choix == "O")
- {
- ok = true;
- Type = "Vaisselle";
- }
- if(choix == "N")
- {
- ok = true;
- }
- }
- if(Type == "Vaisselle")
- {
- ok = false;
- while (ok == false)
- {
- Console.WriteLine("Nombre ? ");
- int nb = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Couverts ou Assiettes ?");
- choix = Console.ReadLine().ToLower();
- if(choix == "couverts")
- {
- Vaisselle temp = new Vaisselle(date, type, reference, nom, tel, adresse, description, 0, "Couverts", nb);
- dons.Add(temp);
- ok = true;
- }
- if(choix == "assiettes")
- {
- Vaisselle temp = new Vaisselle(date, type, reference, nom, tel, adresse, description, 0, "Assiettes", nb);
- dons.Add(temp);
- ok = true;
- }
- }
- MenuDons(adherents, beneficiaires, dons, Garde_Meuble, depotVentes);
- }
- ok = false;
- while (ok == false)
- {
- Console.WriteLine("Table ? (O/N)");
- choix = Console.ReadLine();
- if (choix == "O")
- {
- ok = true;
- Type = "Table";
- }
- if (choix == "N")
- {
- ok = true;
- }
- }
- if(Type == "Table")
- {
- string Table_Type = null;
- ok = false;
- while(ok == false)
- {
- Console.WriteLine("Cuisine ou Salon ?");
- Table_Type = Console.ReadLine().ToLower();
- if(Table_Type == "cuisine")
- {
- ok = true;
- }
- if (Table_Type == "salon")
- {
- ok = true;
- }
- }
- ok = false;
- string Table_Forme = null;
- while(ok == false)
- {
- Console.WriteLine("Rectangulaire, Carree, ou Ronde ?");
- Table_Forme = Console.ReadLine().ToLower();
- if(Table_Forme == "rectangulaire")
- {
- ok = true;
- }
- if (Table_Forme == "carree")
- {
- ok = true;
- }
- if (Table_Forme == "ronde")
- {
- ok = true;
- }
- }
- ok = false;
- while(ok == false)
- {
- Console.WriteLine("Longueur ?");
- double longueur = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("Largeur ?");
- double largeur = Convert.ToDouble(Console.ReadLine());
- Table temp = new Table(date, type, reference, nom, tel, adresse, description, 0, longueur, largeur, Table_Type, Table_Forme, "Table");
- dons.Add(temp);
- ok = true;
- }
- MenuDons(adherents, beneficiaires, dons,Garde_Meuble, depotVentes);
- }
- ok = false;
- while (ok == false)
- {
- Console.WriteLine("Cuisiniere ? (O/N)");
- choix = Console.ReadLine();
- if (choix == "O")
- {
- ok = true;
- Type = "Cuisiniere";
- }
- if (choix == "N")
- {
- ok = true;
- }
- }
- if(Type == "Cuisiniere")
- {
- Console.WriteLine("Puissance ?");
- double puissance = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("Nombre de plaques ?");
- int plaques = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Longueur ?");
- double Longueur = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("Largeur ?");
- double largeur = Convert.ToDouble(Console.ReadLine());
- Cuisiniere temp = new Cuisiniere(date, type, reference, nom, tel, adresse, description, 0, Longueur, largeur, puissance, plaques, "Cuisiniere");
- dons.Add(temp);
- MenuDons(adherents, beneficiaires, dons, Garde_Meuble, depotVentes);
- }
- if(Type == "")
- {
- Console.WriteLine("Type de meuble ?");
- string meuble = Console.ReadLine();
- Console.WriteLine("Longueur ?");
- double Longueur = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("Largeur ? ");
- double Largeur = Convert.ToDouble(Console.ReadLine());
- Objet_Volumineux temp = new Objet_Volumineux(date, type, reference, nom, tel, adresse, description, 0, Longueur, Largeur, meuble);
- dons.Add(temp);
- MenuDons(adherents, beneficiaires, dons, Garde_Meuble, depotVentes);
- }
- }
- public static List<Don> ChargerDons()
- {
- int i = 0;
- List<Don> dons = new List<Don>();
- string[] lines = System.IO.File.ReadAllLines(@"/Users/Paul/Projects/ProjetFinalP2O/Accepte.txt");
- string[] lignes;
- while (i < lines.Length )
- {
- lignes = lines[i].Split(';');
- Don temp = new Don(lignes[0], lignes[1], lignes[2], lignes[3], lignes[4], lignes[5], lignes[6], 1);
- dons.Add(temp);
- i++;
- }
- i = 0;
- lines = System.IO.File.ReadAllLines(@"/Users/Paul/Projects/ProjetFinalP2O/Refuse.txt");
- while (i < lines.Length )
- {
- lignes = lines[i].Split(';');
- Don temp = new Don(lignes[0], lignes[1], lignes[2], lignes[3], lignes[4], lignes[5], lignes[6], 2);
- dons.Add(temp);
- i++;
- }
- i = 0;
- lines = System.IO.File.ReadAllLines(@"/Users/Paul/Projects/ProjetFinalP2O/EnCours.txt");
- while (i < lines.Length)
- {
- lignes = lines[i].Split(';');
- Don temp = new Don(lignes[0], lignes[1], lignes[2], lignes[3], lignes[4], lignes[5], lignes[6], 0);
- dons.Add(temp);
- i++;
- }
- i = 0;
- lines = System.IO.File.ReadAllLines(@"/Users/Paul/Projects/ProjetFinalP2O/Stocke.txt");
- while (i < lines.Length )
- {
- lignes = lines[i].Split(';');
- Don temp = new Don(lignes[0], lignes[1], lignes[2], lignes[3], lignes[4], lignes[5], lignes[6], 3);
- dons.Add(temp);
- i++;
- }
- return dons;
- }
- public static void AfficherDonsReduit(List<Don> L, List<Adherent> A, List<Beneficiaire> B, List<Garde_Meuble> G, List<DepotVente> D)
- {
- int i = 0;
- Console.WriteLine("Liste des dons à Accepter/Refuser");
- foreach(Don item in L)
- {
- if(item.Statut == 0)
- {
- Console.WriteLine("(" + L.IndexOf(item) + ") " + item.Type + " " + item.Référence + " " + item.Description);
- i++;
- }
- }
- int choix = -1;
- int choix2 = -1;
- do
- {
- Console.WriteLine("Choisissez le don à accepter/Refuser");
- string lecture = Console.ReadLine();
- if(lecture == "")
- {
- MenuDons(A, B, L, G, D);
- }
- choix = Convert.ToInt32(lecture);
- if (choix < L.Count)
- {
- do
- {
- Console.Clear();
- Console.WriteLine(L[choix].ToString());
- Console.WriteLine("Accepter (1) ou Refuser (2) ?");
- choix2 = Convert.ToInt32(Console.ReadLine());
- if (choix2 == 1)
- {
- L[choix].Statut = 1;
- Console.WriteLine("Don Accepté appuyez sur un touche pour revenir au menu");
- Console.ReadKey();
- Menu(A, B, L,G, D);
- }
- if (choix2 == 2)
- {
- L[choix].Statut = 4;
- Console.WriteLine("Don refusé appuyez sur une touche pour revenir au menu");
- Console.ReadKey();
- Menu(A, B, L,G, D);
- }
- } while (choix2 != 1 || choix2 != 2);
- }
- } while (choix > i-1);
- }
- public static List<Adherent> ChargerAdherents()
- {
- int i = 0;
- List<Adherent> adherents = new List<Adherent>();
- string[] lines = System.IO.File.ReadAllLines(@"/Users/Paul/Projects/ProjetFinalP2O/Adherents.txt");
- string[] lignes;
- while (i < lines.Length-1)
- {
- lignes = lines[i].Split(';');
- Adherent temp = new Adherent(Convert.ToInt32(lignes[0]), lignes[1], lignes[2], lignes[3], lignes[4], lignes[5]);
- adherents.Add(temp);
- i++;
- }
- return adherents;
- }
- public static List<Beneficiaire> ChargerBeneficiaires()
- {
- int i = 0;
- List<Beneficiaire> beneficiaires = new List<Beneficiaire>();
- string[] lines = System.IO.File.ReadAllLines(@"/Users/Paul/Projects/ProjetFinalP2O/Beneficiaires.txt");
- string[] lignes;
- while (i < lines.Length)
- {
- lignes = lines[i].Split(';');
- Beneficiaire temp = new Beneficiaire(Convert.ToInt32(lignes[0]), lignes[1], lignes[2], lignes[3], lignes[4], lignes[5]);
- beneficiaires.Add(temp);
- i++;
- }
- return beneficiaires;
- }
- public static string RechercheBeneficiaireTel(string Tel, List<Beneficiaire> benef)
- {
- try
- {
- Beneficiaire resultat = benef.Find(item => item.Telephone == Tel);
- return resultat.ToString();
- } catch {
- return "Aucune personne trouvée";
- }
- }
- public static string RechercheBeneficiaireNom(string Nom, List<Beneficiaire> benef)
- {
- try
- {
- Beneficiaire resultat = benef.Find(item => item.Nom == Nom);
- return resultat.ToString();
- }
- catch
- {
- return "Aucune personne trouvée";
- }
- }
- public static List<Garde_Meuble> ChargerGardeMeuble()
- {
- List<Garde_Meuble> Garde_Meuble = new List<Garde_Meuble>();
- int i = 0;
- string[] lines = System.IO.File.ReadAllLines(@"/Users/Paul/Projects/ProjetFinalP2O/Garde_Meuble.txt");
- while (i < lines.Length)
- {
- string[] lignes = lines[i].Split(';');
- Don temp = new Don(lignes[0], lignes[1], lignes[2], lignes[3], lignes[4], lignes[5], lignes[6], 3);
- Beneficiaire temp2 = new Beneficiaire(Convert.ToInt32(lignes[7]), lignes[8], lignes[9], lignes[10], lignes[11], lignes[12]);
- string Datedepot = lignes[13];
- string DateEnlevement = lignes[14];
- Garde_Meuble temp3 = new Garde_Meuble(temp, temp2, Datedepot, DateEnlevement);
- Garde_Meuble.Add(temp3);
- i++;
- }
- return Garde_Meuble;
- }
- public static void Menu(List<Adherent> adherents, List<Beneficiaire> beneficiaires, List<Don> dons, List<Garde_Meuble> Garde_Meuble, List<DepotVente> depots_ventes)
- {
- bool passe = false;
- int choix = 0;
- do
- {
- Console.WriteLine(" ");
- Console.WriteLine(" ");
- Console.WriteLine(" ");
- Console.WriteLine(" ");
- Console.WriteLine(" ");
- Console.WriteLine(" ");
- Console.WriteLine(" Gestion de Dons ");
- Console.WriteLine(" ");
- Console.WriteLine(" ");
- Console.WriteLine("(1) Module Personnes");
- Console.WriteLine("(2) Module Dons");
- Console.WriteLine("(3) Module Tris");
- Console.WriteLine("(4) Module Statistique");
- Console.WriteLine("(5) Module Autres");
- Console.WriteLine("(6) Sauvegarder et quitter");
- Console.WriteLine("Votre choix ?");
- choix = Convert.ToInt32(Console.ReadLine());
- if(choix == 1)
- {
- MenuPersonnes(adherents, beneficiaires, dons, Garde_Meuble, depots_ventes);
- passe = true;
- }
- if (choix == 2)
- {
- MenuDons(adherents, beneficiaires, dons, Garde_Meuble, depots_ventes);
- passe = true;
- }
- if (choix == 3)
- {
- MenuTris(adherents,beneficiaires,dons, Garde_Meuble, depots_ventes);
- passe = true;
- }
- if(choix == 4)
- {
- MenuStats(adherents, beneficiaires, dons, Garde_Meuble, depots_ventes);
- passe = true;
- }
- if (choix == 5)
- {
- MenuBonus(adherents, beneficiaires, dons, Garde_Meuble, depots_ventes);
- passe = true;
- }
- if (choix == 6)
- {
- Sauvegarder(adherents, beneficiaires, dons, Garde_Meuble, depots_ventes);
- passe = true;
- }
- } while (passe == false);
- }
- public static void MenuPersonnes(List<Adherent> adherents, List<Beneficiaire> beneficiaires, List<Don> dons, List<Garde_Meuble> Garde_Meuble, List<DepotVente> depots_ventes)
- {
- int choix = 0;
- bool passe = false;
- do
- {
- Console.WriteLine(" Module Personnes ");
- Console.WriteLine(" ");
- Console.WriteLine(" ");
- Console.WriteLine("(1) Rechercher un beneficiaire par nom");
- Console.WriteLine("(2) Rechercher un beneficiaire par Téléphone");
- Console.WriteLine("Votre choix ? ");
- choix = Convert.ToInt32(Console.ReadLine());
- if(choix == 1)
- {
- Console.WriteLine("Entrez le nom du beneficiaire à chercher");
- string nom = Console.ReadLine();
- string resultat = RechercheBeneficiaireNom(nom, beneficiaires);
- Console.WriteLine(resultat);
- passe = true;
- Menu(adherents, beneficiaires, dons, Garde_Meuble, depots_ventes);
- }
- if(choix == 2)
- {
- Console.WriteLine("Entrez le numéro du beneficiaire à chercher");
- string Tel = Console.ReadLine();
- string resultat = RechercheBeneficiaireTel(Tel, beneficiaires);
- Console.WriteLine(resultat);
- passe = true;
- Menu(adherents, beneficiaires, dons, Garde_Meuble, depots_ventes);
- }
- } while (passe == false);
- }
- public static void MenuDons(List<Adherent> adherents, List<Beneficiaire> beneficiaires, List<Don> dons, List<Garde_Meuble> Garde_Meuble, List<DepotVente> depots_ventes)
- {
- int choix = 0;
- bool passe = false;
- do
- {
- Console.WriteLine(" Module Dons ");
- Console.WriteLine(" ");
- Console.WriteLine(" ");
- Console.WriteLine("(1) Creer un Don");
- Console.WriteLine("(2) Accepter/Refuser un Don");
- Console.WriteLine("(3) Stockage d'un Don");
- Console.WriteLine("(4) Contenu du Garde Meuble");
- Console.WriteLine("(5) Contenu des archives");
- Console.WriteLine("(6) Transfert Don beneficiaire");
- Console.WriteLine("(7) Creer depot vente");
- Console.WriteLine("(8) Afficher depot vente");
- Console.WriteLine("(9) Retour");
- Console.WriteLine("Votre choix ? ");
- choix = Convert.ToInt32(Console.ReadLine());
- if(choix == 1)
- {
- CreerDons(dons, adherents, beneficiaires, Garde_Meuble, depots_ventes);
- passe = true;
- Menu(adherents, beneficiaires, dons, Garde_Meuble, depots_ventes);
- }
- if(choix == 2)
- {
- AfficherDonsReduit(dons,adherents,beneficiaires, Garde_Meuble, depots_ventes);
- passe = true;
- Menu(adherents, beneficiaires, dons, Garde_Meuble, depots_ventes);
- }
- if(choix == 3 )
- {
- StockerMenu(dons, adherents,beneficiaires, Garde_Meuble, depots_ventes);
- passe = true;
- Menu(adherents, beneficiaires, dons, Garde_Meuble, depots_ventes);
- }
- if (choix == 4)
- {
- AfficherGardeMeuble(dons, adherents, beneficiaires, Garde_Meuble, depots_ventes);
- passe = true;
- Menu(adherents, beneficiaires, dons, Garde_Meuble, depots_ventes);
- }
- if(choix == 5)
- {
- AfficherArchives(dons);
- passe = true;
- Menu(adherents, beneficiaires, dons, Garde_Meuble, depots_ventes);
- }
- if(choix == 6)
- {
- TransfertDonBenef(dons, beneficiaires);
- passe = true;
- Menu(adherents, beneficiaires, dons, Garde_Meuble, depots_ventes);
- }
- if(choix == 7)
- {
- CreerDV(depots_ventes);
- passe = true;
- Menu(adherents, beneficiaires, dons, Garde_Meuble, depots_ventes);
- }
- if(choix == 8)
- {
- AfficherDV(depots_ventes);
- passe = true;
- Menu(adherents, beneficiaires, dons, Garde_Meuble, depots_ventes);
- }
- if (choix == 9)
- {
- passe = true;
- Menu(adherents, beneficiaires, dons, Garde_Meuble, depots_ventes);
- }
- } while (passe == false);
- }
- public static void MenuTris(List<Adherent> adherents, List<Beneficiaire> beneficiaires, List<Don> dons, List<Garde_Meuble> garde_Meubles, List<DepotVente> depots_ventes)
- {
- int choix = 0;
- bool ok = false;
- while(ok == false)
- {
- Console.WriteLine(" Module Tris ");
- Console.WriteLine(" ");
- Console.WriteLine(" ");
- Console.WriteLine("(1) Lister les dons refuses tries par date ");
- Console.WriteLine("(2) Lister les dons en traitement (accepté ou stocké) par ordre d’identifiant et de Nom de Donataire ");
- Console.WriteLine("(3) Lister les dons vendus/donnés par mois /numéro de bénéficiaire");
- Console.WriteLine("(4) Lister les dons stockés par entrepôt et par catégorie/description");
- Console.WriteLine("(5) Lister les dons stockés par entrepôt et par volume");
- Console.WriteLine("(6) Lister les dons par dépôt-vente et par prix");
- Console.WriteLine("(7) Retour");
- Console.WriteLine("Votre choix ? ");
- choix = Convert.ToInt32(Console.ReadLine());
- if(choix == 1)
- {
- TriDonRefuseDate(dons);
- ok = true;
- Menu(adherents, beneficiaires, dons, garde_Meubles, depots_ventes);
- }
- if (choix == 2)
- {
- TriDonTraitement(dons);
- ok = true;
- Menu(adherents, beneficiaires, dons, garde_Meubles, depots_ventes);
- }
- if (choix == 3)
- {
- TriDonVendu(dons);
- ok = true;
- Menu(adherents, beneficiaires, dons, garde_Meubles, depots_ventes);
- }
- if(choix == 4)
- {
- TriDonStockeType(garde_Meubles, depots_ventes);
- ok = true;
- Menu(adherents, beneficiaires, dons, garde_Meubles, depots_ventes);
- }
- if(choix == 5)
- {
- }
- if(choix == 6)
- {
- TriDepotPrix(depots_ventes);
- ok = true;
- Menu(adherents, beneficiaires, dons, garde_Meubles, depots_ventes);
- }
- if(choix == 7)
- {
- ok = true;
- Menu(adherents, beneficiaires, dons, garde_Meubles, depots_ventes);
- }
- }
- }
- public static void MenuStats(List<Adherent> adherents, List<Beneficiaire> beneficiaires, List<Don> dons, List<Garde_Meuble> garde_Meubles, List<DepotVente> depots_ventes)
- {
- int choix = 0;
- bool ok = false;
- while (ok == false)
- {
- Console.WriteLine(" Module Stats ");
- Console.WriteLine(" ");
- Console.WriteLine(" ");
- Console.WriteLine("(1) Calculer la moyenne de temps entre la date de réception et la date de retrait des dons\ndans les zones de stockage ");
- Console.WriteLine("(2) Calculer la moyenne de prix des objets dans les dépôts-ventes ");
- Console.WriteLine("(3) Calculez la moyenne d’âge des bénéficiaires");
- Console.WriteLine("(4) Retour");
- Console.WriteLine("Votre choix ? ");
- choix = Convert.ToInt32(Console.ReadLine());
- if(choix == 1)
- {
- MoyDepotRecep(garde_Meubles);
- ok = true;
- Menu(adherents, beneficiaires, dons, garde_Meubles, depots_ventes);
- }
- if(choix == 2)
- {
- MoyPrixDepotVente(depots_ventes);
- ok = true;
- Menu(adherents, beneficiaires, dons, garde_Meubles, depots_ventes);
- }
- if(choix == 3)
- {
- MoyAgeBenef(beneficiaires);
- ok = true;
- Menu(adherents, beneficiaires, dons, garde_Meubles, depots_ventes);
- }
- if(choix == 4)
- {
- ok = true;
- Menu(adherents, beneficiaires, dons, garde_Meubles, depots_ventes);
- }
- }
- }
- public static void MenuBonus(List<Adherent> adherents, List<Beneficiaire> beneficiaires, List<Don> dons, List<Garde_Meuble> garde_Meubles, List<DepotVente> depots_ventes)
- {
- int choix = 0;
- bool ok = false;
- while (ok == false)
- {
- Console.WriteLine(" Module Stats ");
- Console.WriteLine(" ");
- Console.WriteLine(" ");
- Console.WriteLine("(1) Calculatrice ");
- Console.WriteLine("(2) Ajouter Beneficiaire ");
- Console.WriteLine("(3) ??? ");
- Console.WriteLine("(4) ??? ");
- Console.WriteLine("(5) Retour");
- Console.WriteLine("Votre choix ? ");
- choix = Convert.ToInt32(Console.ReadLine());
- if(choix == 1)
- {
- Calculatrice();
- ok = true;
- Menu(adherents, beneficiaires, dons, garde_Meubles, depots_ventes);
- }
- if(choix == 2)
- {
- AjouterBenef(beneficiaires);
- ok = true;
- Menu(adherents, beneficiaires, dons, garde_Meubles, depots_ventes);
- }
- }
- }
- public static void Sauvegarder(List<Adherent> adherents, List<Beneficiaire> beneficiaires, List<Don> dons, List<Garde_Meuble> garde_Meubles,List<DepotVente> depotVentes)
- {
- SaveAdherents(adherents);
- SaveBeneficiaires(beneficiaires);
- Environment.Exit(0);
- }
- public static void SaveAdherents(List<Adherent> A)
- {
- int i = 0;
- int longueur = A.Count;
- string[] lines = new string[longueur];
- string str = null;
- foreach(Adherent item in A)
- {
- str = "";
- str += Convert.ToString(item.ID);
- str += ";";
- str += item.Nom;
- str += ";";
- str += item.Adresse;
- str += ";";
- str += item.Telephone;
- str += ";";
- str += item.Prenom;
- str += ";";
- str += item.Statut;
- lines[i] = str;
- i++;
- }
- System.IO.File.WriteAllLines(@"/Users/Paul/Projects/ProjetFinalP2O/Adherents.txt", lines);
- }
- public static void SaveBeneficiaires(List<Beneficiaire> B)
- {
- int i = 0;
- int longueur = B.Count;
- string[] lines = new string[longueur];
- string str = null;
- foreach(Beneficiaire item in B)
- {
- str = "";
- str += Convert.ToString(item.ID);
- str += ";";
- str += item.Nom;
- str += ";";
- str += item.Adresse;
- str += ";";
- str += item.Telephone;
- str += ";";
- str += item.Nom;
- str += ";";
- str += item.DateNaissance;
- lines[i] = str;
- i++;
- }
- System.IO.File.WriteAllLines(@"/Users/Paul/Projects/ProjetFinalP2O/Beneficiaires.txt", lines);
- }
- public static void Main(string[] args)
- {
- List<Adherent> adherents = ChargerAdherents();
- List<Beneficiaire> beneficiaires = ChargerBeneficiaires();
- List<Don> dons = ChargerDons();
- List<Garde_Meuble> garde_meuble = ChargerGardeMeuble();
- List<DepotVente> depots_ventes = new List<DepotVente>();
- Menu(adherents, beneficiaires, dons, garde_meuble, depots_ventes);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement