public Buch(string titel, string autor, IKategorie eingeordneteKategorie, string barcode, string stichwort) { Titel = titel; Autor = autor; EingeordneteKategorie = eingeordneteKategorie; Barcode = barcode; Stichwort = stichwort; }
//Verknüpfung zu Kategorie über Tabelle BücherInKategorie muss noch erfolgen public bool BuchAnlegen(string titel, string autor, IKategorie kategorie, string barcode, string stichwort = "") { IBuch newBuch = _factory.CreateBuch(titel, autor, kategorie, barcode, stichwort); BuchInKategorieLegen(newBuch, kategorie); string data = titel + ", " + autor + ", " + barcode + ", " + stichwort; _dbAnbindung.InsertNewRow(ExistingTables.Bücher, data); string[] sqlret = _dbAnbindung.SelectRows(ExistingTables.Bücher); int key = -1; foreach (string str in sqlret) { string[] args = str.Split(' '); int id = int.Parse(args[0]); if (!_bücherei.BücherListe.ContainsKey(id)) { if (args[1] == titel && args[2] == autor && args[3] == kategorie.Name && args[4] == barcode && args[5] == stichwort) { key = id; break; } } } if (key > 0) { _bücherei.BücherListe.Add(key, newBuch); return true; } return false; }
public bool BuchInKategorieLegen(IBuch buch, IKategorie kategorie) { throw new NotImplementedException(); }
public bool KategorieLöschen(IKategorie kategorie) { int id = -1; foreach (int key in _bücherei.Kategorien.Keys) { if (_bücherei.Kategorien[key].Equals(kategorie)) { id = key; break; } } if (id > 0) { string data = id.ToString(); _dbAnbindung.DeleteRow(ExistingTables.Kategorie, data); return true; } return false; }
IBuch IClassFactory.CreateBuch(string titel, string autor, IKategorie kategorie, string barcode, string stichwort) { return new Buch(titel, autor, kategorie, barcode, stichwort); }