diff --git a/Sources/Data/LoadOperation.cs b/Sources/Data/LoadOperation.cs new file mode 100644 index 0000000..4ad9a0d --- /dev/null +++ b/Sources/Data/LoadOperation.cs @@ -0,0 +1,132 @@ +using Model; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Formats.Asn1; +using System.Globalization; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using static System.Net.Mime.MediaTypeNames; + +namespace Data +{ + public class LoadOperation + { + public static IList LoadOperationsFromOFX(string csv) + { + //liste des opérations d'un compte + IList lesOpe = new List(); + + //détail d'une Operation + string intituleOperation; + double montant; + DateTime dateOperation; + MethodePayement modePayement; + bool isDebit; + + //info compte + string identifiantCompte=""; + double solde=0; + + using (StreamReader reader = new StreamReader(csv)) + { + if (reader != null) + { + string row; + while ((row = reader.ReadLine()) != null) + { + if (row.Contains("")) + { + row = ""; + } + else if (row.Contains("")) + { + identifiantCompte = CutRow(row).Last(); + } + else if (row.Contains("")) + { + solde = Convert.ToDouble(GetValueInRow(row, 4)); + } + else if (row.Contains("")) + { + row = ""; + intituleOperation = ""; + montant = 0; + dateOperation = new DateTime(); + modePayement = MethodePayement.None; + isDebit = false; + while ((row = reader.ReadLine()) != "") + { + if (row.Contains("")) + { + DateTime.TryParseExact(CutRow(row).Last(), "yyyyMMdd", null, DateTimeStyles.None, out dateOperation); + } + else if (row.Contains("")) + { + montant = double.Parse(CutRow(row).Last(), CultureInfo.InvariantCulture); + if (montant < 0) + { + isDebit = true; + montant = Math.Abs(montant); + } + } + else if (row.Contains("")) + { + intituleOperation = CutRow(row).Last(); + } + else if (row.Contains("")) + { + if (row.Contains("PAIEMENT")) + { + modePayement = MethodePayement.Cb; + } + else + { + modePayement = MethodePayement.None; + } + + } + else + { + row = ""; + } + } + lesOpe.Add(new Operation(intituleOperation, identifiantCompte, montant, dateOperation, modePayement, isDebit)); + } + else + { + row = ""; + } + } + } + } + return lesOpe; + + } + + public static string[] CutRow(string row) + { + string[] cutRow; + if (row == null) throw new ArgumentNullException(); + cutRow = row.Split('>'); + return cutRow; + } + + public static string GetValueInRow(string row, int position) + { + string value; + string[] cutedRow = CutRow(row); + if (cutedRow != null) + { + if(cutedRow.Count() > position || position < 0) throw new IndexOutOfRangeException(); + value = cutedRow[position]; + return value; + } + + throw new ArgumentNullException(); + + } + } +} diff --git a/Sources/Data/PersLinqToPgSQL.cs b/Sources/Data/PersLinqToPgSQL.cs index c20020c..2927b13 100644 --- a/Sources/Data/PersLinqToPgSQL.cs +++ b/Sources/Data/PersLinqToPgSQL.cs @@ -243,7 +243,7 @@ namespace LinqToPgSQL while (dbReader.Read()) { - ListeCompte.Add(new Compte(dbReader.GetString(0), dbReader.GetInt64(1))); + ListeCompte.Add(new Compte("NULL",dbReader.GetString(0), dbReader.GetInt64(1)));//a patch NULL } dbReader.Close(); return ListeCompte; diff --git a/Sources/IHM/AppShell.xaml.cs b/Sources/IHM/AppShell.xaml.cs index d4af711..1ced756 100644 --- a/Sources/IHM/AppShell.xaml.cs +++ b/Sources/IHM/AppShell.xaml.cs @@ -13,6 +13,8 @@ namespace IHM Routing.RegisterRoute("Inscription", typeof(Inscription)); Routing.RegisterRoute("ForgetPassword", typeof(ForgetPassword)); Routing.RegisterRoute("ChangePassword", typeof(ChangePassword)); + + } diff --git a/Sources/IHM/Dashboard.xaml b/Sources/IHM/Dashboard.xaml index 751ce20..d3ac65d 100644 --- a/Sources/IHM/Dashboard.xaml +++ b/Sources/IHM/Dashboard.xaml @@ -2,10 +2,100 @@ - - + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Sources/IHM/IHM.csproj b/Sources/IHM/IHM.csproj index 9ef10c6..cd7edb2 100644 --- a/Sources/IHM/IHM.csproj +++ b/Sources/IHM/IHM.csproj @@ -32,7 +32,10 @@ - + + PreserveNewest + + @@ -46,6 +49,9 @@ PreserveNewest + + PreserveNewest + @@ -54,6 +60,10 @@ + + + + diff --git a/Sources/IHM/MainPage.xaml b/Sources/IHM/MainPage.xaml index 109a56e..a251167 100644 --- a/Sources/IHM/MainPage.xaml +++ b/Sources/IHM/MainPage.xaml @@ -10,26 +10,27 @@ VerticalOptions="Start">