/// <summary> /// Lecture depuis un fichier CSV /// </summary> /// <param name="pNum"></param> /// <returns></returns> public static Client fromCSV(Int32 pNum) { Client oReturn = null; if (pNum < 1) { throw new InvalidOperationException("Le numéro doit être supérieur à 1"); } try { String strFilename = "CLT" + pNum + ".csv"; if (File.Exists(strFilename)) { String[] strLines = System.IO.File.ReadAllLines(strFilename); String[] tabLine1 = strLines[0].Split(';'); MyEnums.TYPECLIENT nType = (MyEnums.TYPECLIENT)Enum.Parse(typeof(MyEnums.TYPECLIENT), tabLine1[2]); String strNom = tabLine1[1]; oReturn = ClientFactory.creerClient(nType, strNom); oReturn.Num = Convert.ToInt32(tabLine1[0]); oReturn.EnCours = Convert.ToSingle(tabLine1[3]); Boolean bPremiereligne = true; foreach (String str in strLines) { if (bPremiereligne) { bPremiereligne = false; } else { String[] tabcontact = str.Split(';'); Contact oContact = new Contact(tabcontact[0], tabcontact[1]); oReturn.lstContact.Add(oContact); } } } else { oReturn = null; } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("ERR en lecture" + ex.Message); oReturn = null; } return(oReturn); }
public static Client creerClient(MyEnums.TYPECLIENT pType, String pNom) { Client oClient = null; switch (pType) { case MyEnums.TYPECLIENT.ASURVEILLER: oClient = new ClientASurveiller(pNom); break; case MyEnums.TYPECLIENT.NORMAL: oClient = new ClientNormal(pNom); break; case MyEnums.TYPECLIENT.PREMIUM: oClient = new ClientPremium(pNom); break; } return(oClient); }
public Client(String pNom, MyEnums.TYPECLIENT pType) { this.Nom = pNom; this.TypeClient = pType; lstContact = new List <Contact>(); }