1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101:
| procedure Tfrm_book.save; var FS: TFileStream; L,len, i: integer; begin try copyfileto('C:\Programme\D-Verwaltung\'+users[c_user].name+'\save_book.mdb','C:\Programme\D-Verwaltung\'+users[c_user].name+'\save_book2.mdb'); deletefile('C:\Programme\D-Verwaltung\'+users[c_user].name+'\save_book.mdb'); fs:=Tfilestream.Create('C:\Programme\D-Verwaltung\'+users[c_user].name+'\save_book.mdb',fmcreate); except copyfileto('C:\Programme\D-Verwaltung\'+users[c_user].name+'\save_book2.mdb','C:\Programme\D-Verwaltung\'+users[c_user].name+'\save_book.mdb'); deletefile('C:\Programme\D-Verwaltung\'+users[c_user].name+'\save_book2.mdb'); Showmessage('Speichern von Book-Daten fehlgeschlagen!Datei konnte nicht gesichert werden!'); exit; end; deletefile('C:\Programme\D-Verwaltung\'+users[c_user].name+'\save_book2.mdb'); len:=length(books); fs.write(len,sizeof(len)); for i:=0 to len-1 do begin l:=length(books[i].titel); fs.Write(l,sizeof(l)); fs.Write(PChar(books[i].titel)^, l);
l:=length(books[i].RSN); fs.Write(l,sizeof(L)); fs.Write(PChar(books[i].rsn)^, L);
l:=length(books[i].BC); fs.Write(l,sizeof(L)); fs.Write(PChar(books[i].bc)^, L);
l:=length(books[i].Autor); fs.Write(l,sizeof(L)); fs.Write(PChar(books[i].autor)^, L);
l:=length(books[i].kommentar); fs.Write(l,sizeof(L)); fs.Write(PChar(books[i].kommentar)^, L);
fs.Write(books[i].category,sizeof(books[i].category));
fs.Write(books[i].bibo,sizeof(books[i].bibo));
fs.Write(books[i].sprache,sizeof(books[i].sprache));
fs.Write(books[i].status,sizeof(books[i].status));
fs.Write(books[i].datum,sizeof(books[i].datum)) end; fs.Free; end;
procedure Tfrm_book.open; var FS: TFileStream; Len,l, i: Cardinal; begin try FS := TFileStream.Create('C:\Programme\D-Verwaltung\'+users[c_user].name+'\save_book.mdb', fmShareDenynone); except showmessage('öffnen von modulbook fehlgeschlagen! bitte nutzen sie ggf. die Notfalltools!'); end; try fs.read(len,sizeof(len)); Setlength(books,len); for I:=0 to len-1 do begin fs.read(l,sizeof(l)); Setlength(books[i].titel,l); fs.read(PChar(books[i].titel)^, L);
fs.read(l,sizeof(L)); Setlength(books[i].RSN,l); fs.read(PChar(books[i].rsn)^, L);
fs.read(l,sizeof(L)); Setlength(books[i].BC,l); fs.read(PChar(books[i].bc)^, L);
fs.read(l,sizeof(L)); Setlength(books[i].Autor,l); fs.read(PChar(books[i].autor)^, L);
fs.read(l,sizeof(L)); Setlength(books[i].kommentar,l); fs.read(PChar(books[i].kommentar)^, L);
fs.read(books[i].category, sizeof(books[i].category));
fs.read(books[i].bibo, sizeof(books[i].bibo));
fs.read(books[i].sprache, sizeof(books[i].sprache));
fs.read(books[i].status, sizeof(books[i].status));
fs.read(books[i].datum, sizeof(books[i].datum)); end; fs.Free; except fs.Free; Showmessage('Öffnen von Bookdatei fehlgeschlagen, obwohl Datei vorhanden. Sollte dieser Fehler öfter auftreten nutzen sie bitte die Notfalltools!'); end; end; |