using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace VP
{
///
/// Class : Contenant la liste de tous les employés
/// Date : 26//11/2011
///
[Serializable]
class AllEmployee
{
private ArrayList emp = new ArrayList();
public AllEmployee()
{
// création des employee (Ils sont déjà sérialisés alors on les a laissé en commentaires)
/*
Employee e1 = new Employee("BUCHELE", "Lionel", new DateTime(1989, 11, 29), "IT Engineer", "M", "12B, Place des Vosges 75016 PARIS");
emp.Add(e1);
Employee e2 = new Employee("GABRIEL", "Bruno", new DateTime(1990, 4, 27), "IT Engineer", "M", "7A, avenue Foch 75016 PARIS");
emp.Add(e2);
Employee e3 = new Employee("KADAFI", "Bennur", new DateTime(1937, 3, 3), "Developer", "M", "7B, avenue Foch 75016 PARIS");
emp.Add(e3);
Employee e4 = new Employee("RAMIREZ", "Adolpho", new DateTime(1989, 4, 20), "Diktator", "M", "8, avenue Foch 75016 PARIS");
emp.Add(e4);
Employee e5 = new Employee("GASTRO", "Fidel", new DateTime(1946, 5, 28), "Cooker", "M", "8 bis, avenue Foch 75016 PARIS");
emp.Add(e5);
Employee e6 = new Employee("STALINE", "Sylvester", new DateTime(1959, 5, 28), "Communist", "M", "9 bis, avenue Foch 75016 PARIS");
emp.Add(e6);
Employee e7 = new Employee("C'EST DONG", "Mao", new DateTime(1940, 9, 13), "Artist", "M", "10, avenue Foch 75016 PARIS");
emp.Add(e7);
Employee e8 = new Employee("ROBAISE", "Pierre", new DateTime(1923, 3, 12), "Actor", "M", "20, avenue de Mademoiselle 75001 PARIS");
emp.Add(e8);
Employee e9 = new Employee("POTE", "Paul", new DateTime(1952, 3, 1), "Efreien", "M", "78, Boulevard du Massacre 75016 PARIS");
emp.Add(e9);
* */
}
/**
Recherche Si l'employée existe déja
*/
public bool IsAlreadyExist(String Name, String FirstName)
{
bool exist = false;
foreach (Employee e in emp)
{
if ((e.getName().Equals(Name) == true) && (e.getFname().Equals(FirstName)))
{
exist = true;
}
}
return exist;
}
public bool AddEmployee(string Name, string Firstname, DateTime birthday, string job, string sex, string adress, string zipCode, string city)
{
if (IsAlreadyExist(Name, Firstname)) return false;
string newFirstname = Firstname[0].ToString().ToUpper() + Firstname.Substring(1).ToLower();
emp.Add(new Employee(Name.ToUpper(), newFirstname, birthday, job.ToLower(), sex, adress + " " + zipCode.ToUpper() + " " + city.ToUpper()));
return true;
}
public ArrayList getAllEmployee()
{
return emp;
}
}
}