Esempio n. 1
0
        private void ladeInventarAusDatei(string path)
        {
            if (!System.IO.File.Exists(path))
            {
                MessageBox.Show("Es konnte im Verzeichnis keine Datei gefunden werden. Stelle sicher, dass die File.txt im selben Ordner liegt wie dieses Programm oder speicher erst eine Liste ab", "Fehler beim Laden!");
                return;
            }
            string[] lines = System.IO.File.ReadAllLines(path);
            this.inv = new Inventar();

            foreach (string line in lines)
            {
                string[] props = line.Split(';');
                Geraet   g     = new Geraet();
                g.setTyp(props[0]);
                g.setBezeichnung(props[1]);
                g.setHersteller(props[2]);
                g.setInventurnummer(props[3]);
                g.setSeriennummer(props[4]);
                DateTime dt = Convert.ToDateTime(props[5]);
                g.setKaufdatum(dt);
                this.inv.addItem(g);
            }
            populateListView(this.lvAllItems, this.inv.getAllItems());
        }
Esempio n. 2
0
 public Form1()
 {
     InitializeComponent();
     this.dtpKaufdatum.Format       = DateTimePickerFormat.Custom;
     this.dtpKaufdatum.CustomFormat = "dd/MM/yyyy";
     inv = new Inventar();
     setupListView(lvAllItems);
 }
Esempio n. 3
0
        private void saveInventarToFile(Inventar inv, string path)
        {
            List <Geraet> allItems = inv.getAllItems();

            if (System.IO.File.Exists(path))
            {
                System.IO.File.Delete(path);
            }


            if (allItems.Count > 0)
            {
                foreach (Geraet g in allItems)
                {
                    System.IO.File.AppendAllText(path, g.ToString() + "\r\n");
                }
                string info = "Die Geräte wurden unter: \"" + path + " gespeichert!";
                MessageBox.Show(info, "Erfolgreich gespeichert!");
            }
            else
            {
                MessageBox.Show("Kannst nicht speichern wenn du keine items hast lol", "Nope");
            }
        }