fb:porticula NoPaste
Adressen Speichern mit Datei Datenbank
Uploader: | RockTheSchock |
Datum/Zeit: | 06.09.2013 13:24:14 |
#Lang "fb"
#include "file.bi"
Const CRLF = Chr(13)+Chr(10)
Type TAdresse
Anschrift As String*64
Strasse As String*64
Ort As String*64
End Type
Type TKonto
Bank As String*64
BLZ As String*64
Nummer As String*10
IBAN As String*34
BIC As String*11
End Type
Type TFirma
Public:
Declare Static Function LadeAlle(datei As String="firma.db") As Integer
Declare Operator Cast() As String
Declare Sub Eingabe(datei As String="firma.db")
Declare Sub Laden(nummer As Integer, datei As String="firma.db")
Declare Sub Speichern(datei As String="firma.db")
Private:
Nummer As Integer
Bezeichnung As String*16
Adresse(3) As TAdresse '4 Adressen
Konto(1) As TKonto '2 Kontoverbindungen
Memo As String*1024
End Type
ReDim Shared firma() As TFirma
Dim neuefirma AS TFirma
Screen 0
Width 120,50
Print "Firmen Laden: "; TFirma.LadeAlle
neuefirma.Eingabe
Print neuefirma
'neuefirma.Speichern
sleep
End
Function TFirma.LadeAlle(datei As String="firma.db") As Integer
Dim As Integer anzahl = FileLen(datei) \ Len(TFirma)
ReDim Preserve firma(anzahl) As TFirma
Dim db As Integer = FreeFile
Open datei For Random As db Len = Len(TFirma)
For i As Integer = 1 To anzahl
Get #db,i,firma(i)
Print firma(i)
Sleep 500
Next
Close db
Return anzahl
End Function
Operator TFirma.cast () As String
Dim text As String
text = "Nummer: " & Nummer & CRLF
text+= "Bezeichnung: " & Bezeichnung & CRLF
For i As Integer = LBound(Adresse) To UBound(Adresse)
text+= (i+1) & ". Adresse" & CRLF
text+= Chr(9) & "Anschrift:" & Adresse(i).Anschrift & CRLF
text+= Chr(9) & "Strasse:" & Adresse(i).Strasse & CRLF
text+= Chr(9) & "Ort:" & Adresse(i).Ort & CRLF
Next
For i As Integer = LBound(Konto) To UBound(Konto)
text+= (i+1) & ". Konto" & CRLF
text+= Chr(9) & "Bank:" & Konto(i).Bank & CRLF
text+= Chr(9) & "BLZ:" & Konto(i).BLZ & CRLF
text+= Chr(9) & "IBAN:" & Konto(i).IBAN & CRLF
text+= Chr(9) & "BIC:" & Konto(i).BIC & CRLF
Next
text+= "Memo:" & CRLF
text+= memo & CRLF
Return text
End Operator
Sub TFirma.Eingabe(datei As String="firma.db")
If Nummer = 0 Then 'Nummer für neuen Datensatz errechnen
Nummer = FileLen(datei) \ Len(TFirma) + 1
EndIf
Input "Bezeichnung:";Bezeichnung
For i As Integer = LBound(Adresse) To UBound(Adresse)
Print (i+1) & ". Adresse"
Input "Anschrift:" , This.Adresse(i).Anschrift
If Adresse(i).Anschrift="" Then Exit For
Input "Strasse:" , Adresse(i).Strasse
Input "Ort:" , Adresse(i).Ort
Next
For i As Integer = LBound(Konto) To UBound(Konto)
Print (i+1) & ". Konto"
Input "Bank:" , Konto(i).Bank
If Konto(i).Bank="" Then Exit For
Input "BLZ:" ; Konto(i).BLZ
Input "IBAN:" ; Konto(i).IBAN
Input "BIC:" ; Konto(i).BIC
Next
Input "Memo:", memo
End Sub
Sub TFirma.Laden(nummer As Integer, datei As String="firma.db")
Dim db As Integer = FreeFile
Open datei For Random As db Len = Len(TFirma)
Get #db,Nummer,This
Close db
End Sub
Sub TFirma.Speichern(datei As String="firma.db")
If Nummer = 0 Then 'Nummer für neuen Datensatz errechnen
Nummer = FileLen(datei) \ Len(TFirma) + 1
EndIf
Dim db As Integer = FreeFile
Open datei For Random As db Len = Len(TFirma)
Put #db,Nummer,This
Close db
End Sub