public MainPage() { var LogPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "logs_micados.csv"); if (File.Exists(LogPath)) { LogFile = File.AppendText(LogPath); } else { LogFile = File.AppendText(LogPath); LogFile.WriteLine("Date:Type:Autre dépense:Commentaire autre dépense:Prix total:Destination:Marchandise ->"); LogFile.Flush(); } InitializeComponent(); string tag = "micados"; Achetables = new ListeMarchandises(); CommandesEnCours = new ListeMarchandises(); DepensesEnCours = new ListeMarchandises(); Achetables.ReadMarchandises(); C = new Comptes(); C.ReadComptes(); /// Log.Warning(tag, achetables.toString()); UpdateAll(); itemsRecettes.ItemsSource = new List <Marchandise>(Achetables.listM); itemsDepenses.ItemsSource = new List <Marchandise>(Achetables.listM); itemsAjoute.ItemsSource = new List <Marchandise>(Achetables.listM); }
private void AddToMenu(ref ListeMarchandises menu, Marchandise l, bool achat, bool check = true) { if (achat) { if (l.achat <= 0) { if (!check || !menu.toStringList(false).Contains(l.toString(false))) { menu.listM.Add(l); } } l.achat += 1; } if (!achat) { if (l.vente <= 0) { if (!check || !menu.toStringList(false).Contains(l.toString(false))) { menu.listM.Add(l); } } l.vente += 1; } }
private void DoTransaction(string type, bool achat = false) { DoLogs(type, achat); double prixdep = (PrixDepenseEnCours.Text.Length != 0) ? Math.Round(float.Parse(PrixDepenseEnCours.Text.Replace("€", string.Empty), CultureInfo.InvariantCulture.NumberFormat), 2) : 0; if (achat) { switch (type) { case "Banque": if (PrixDepenseEnCours.Text.Length != 0) { C.banque -= prixdep; } break; case "Caisse": C.caisse -= prixdep; break; case "Don": break; } DepensesEnCours = new ListeMarchandises(); } else { switch (type) { case "Banque": C.banque += CommandesEnCours.PrixTotal(false) + getAutresVentePrix(); break; case "Caisse": C.caisse += CommandesEnCours.PrixTotal(false) + getAutresVentePrix(); break; case "Don": break; } CommandesEnCours = new ListeMarchandises(); } Achetables.DoTransaction(); Achetables.SaveMarchandises(); }
private void RemoveFromMenu(ref ListeMarchandises menu, int index, bool achat) { if (achat) { menu.listM[index].achat -= 1; if (menu.listM[index].achat <= 0) { DepensesEnCours.listM.RemoveAt(index); } } else { menu.listM[index].vente -= 1; if (menu.listM[index].vente <= 0) { CommandesEnCours.listM.RemoveAt(index); } } }