static List <BonLivraison> LoadBLs() { List <BonLivraison> bls = new List <BonLivraison>(); foreach (string f in Directory.GetFiles(Ref.DIR_BL)) { if (File.Exists(f)) { string[] vs = f.Split('\\', '/'); string final = vs[vs.Length - 1]; final = final.Substring(0, final.Length - 4); Serialisateur <BonLivraison> ser = new Serialisateur <BonLivraison>(final, Ref.DIR_BL); BonLivraison bl = ser.Load(out bool ok); if (ok) { bls.Add(bl); } else { Debug.MsgErr("La récupération du bon de livraison dans le fichier \" " + string.Join("/", vs) + " \" n'a pas été possible, faites attention à ne pas déposer de fichier MANUELLEMENT dans le dossier \" " + Ref.DIR_BL + ".", "Dx165", ser.GetException()); } } } return(bls); }
static bool SaveBLs() { bool ret = false; foreach (BonLivraison bonLivraison in bonLivraisons) { Serialisateur <BonLivraison> ser = new Serialisateur <BonLivraison>(bonLivraison.GETID, Ref.DIR_BL); if (!ser.Save(bonLivraison)) { Debug.MsgErr("La sauvegarde du bon de livraison \"" + bonLivraison.GETID + "\" a échouée.", "Dx139", ser.GetException()); ret = false; } } bonLivraisons.Clear(); return(ret); }