Einzelnen Beitrag anzeigen

Newbi

Registriert seit: 2. Apr 2008
15 Beiträge
 
#5

Re: Brauche Hilfe bei einer Adressverwaltung

  Alt 23. Mai 2008, 07:36
danke.

Ich speichere in eine Typisierte Datei.

Unit_Adress_Add
Delphi-Quellcode:
unit Unit_Adress_Add;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls,IniFiles;

type
  TFrm_Adress_Add = class(TForm)
    Pan_Standart: TPanel;
    Lbl_Anzeige_ID: TLabel;
    Lbl_Anzeige_Name: TLabel;
    Lbl_Anzeige_Vorname: TLabel;
    Lbl_Anzeige_Fax: TLabel;
    Lbl_Anzeige_Telefon_Arbeit: TLabel;
    Lbl_Anzeige_Telefon_Mobil: TLabel;
    Lbl_Anzeige_Street: TLabel;
    Lbl_Anzeige_Telefon_Privat: TLabel;
    Lbl_Anzeige_Land: TLabel;
    Lbl_Anzeige_PLZ: TLabel;
    Lbl_Anzeige_Stadt: TLabel;
    Lbl_Anzeige_Hausnummer: TLabel;
    Lbl_Ausgabe_ID: TLabel;
    Edt_Eingabe_Name: TEdit;
    Edt_Eingabe_Hausnummer: TEdit;
    Edt_Eingabe_PLZ: TEdit;
    Edt_Eingabe_Stadt: TEdit;
    Edt_Eingabe_Land: TEdit;
    Edt_Eingabe_Telefon_Privat: TEdit;
    Edt_Eingabe_Telefon_Mobil: TEdit;
    Edt_Eingabe_Telefon_Arbeit: TEdit;
    Edt_Eingabe_Fax: TEdit;
    Edt_Eingabe_Vorname: TEdit;
    Edt_Eingabe_Street: TEdit;
    Pan_Neu: TPanel;
    Lbl_Anzeige_ICQ: TLabel;
    Lbl_Anzeige_Mail_1: TLabel;
    Lbl_Anzeige_Mail_2: TLabel;
    Lbl_Anzeige_AIM: TLabel;
    Lbl_Anzeige_Yahoo: TLabel;
    Lbl_Anzeige_MSN: TLabel;
    Lbl_Anzeige_WWW: TLabel;
    Edt_Eingabe_Mail_1: TEdit;
    Edt_Eingabe_Mail_2: TEdit;
    Edt_Eingabe_WWW: TEdit;
    Edt_Eingabe_ICQ: TEdit;
    Edt_Eingabe_MSN: TEdit;
    Edt_Eingabe_Yahoo: TEdit;
    Edt_Eingabe_AIM: TEdit;
    Btn_Action_Save: TButton;
    Btn_Action_Clear: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Btn_Action_SaveClick(Sender: TObject);
    procedure Btn_Action_ClearClick(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Frm_Adress_Add: TFrm_Adress_Add;
  ID:Integer;
  Name:String;
  Vorname:String;
  Street:String;
  Hausnummer:String;
  PLZ:Integer;
  Stadt:String;
  Land:String;
  Telefon_Mobil:Integer;
  Telefon_Privat:Integer;
  Telefon_Arbeit:Integer;
  Fax:Integer;
  Mail_1:String;
  Mail_2:String;
  www:String;
  ICQ:String;
  MSN:String;
  AIM:String;
  Yahoo:String;
  Delete:boolean;
  DateiSizeCon:Integer;
  Fehler:Integer;
  EingabeFalsch1,EingabeFalsch2,SpeichernFalsch1,SpeichernFalsch2,Name_m,Vorname_m,PLZ_m,Tel_Mobil,Tel_Arbeit,Tel_Privat,Fax_m:String;

implementation
uses Unit_Variablen,Unit_Save;
{$R *.dfm}

procedure TFrm_Adress_Add.FormCreate(Sender: TObject);
begin
        // Sprachdateien abrufen
                Unit_Variablen.ini_lang_Adress_Add:=TIniFile.Create(Unit_Variablen.DirtoExe+Unit_Variablen.ini_lang_dir+Unit_Variablen.ini_lang+'/'+Unit_Variablen.ini_lang_Adress_Add_Name);
                        Btn_Action_Clear.Caption:=Unit_Variablen.ini_lang_Adress_Add.ReadString('Buttens','Btn_Action_Clear','');
                        Btn_Action_Save.Caption:=Unit_Variablen.ini_lang_Adress_Add.ReadString('Buttens','Btn_Action_Save','');
                        Lbl_Anzeige_Hausnummer.Caption:=Unit_Variablen.ini_lang_Adress_Add.ReadString('Labels','Lbl_Anzeige_Hausnummer','');
                        Lbl_Anzeige_Land.Caption:=Unit_Variablen.ini_lang_Adress_Add.ReadString('Labels','Lbl_Anzeige_Land','');
                        Lbl_Anzeige_Name.Caption:=Unit_Variablen.ini_lang_Adress_Add.ReadString('Labels','Lbl_Anzeige_Name','');
                        Lbl_Anzeige_PLZ.Caption:=Unit_Variablen.ini_lang_Adress_Add.ReadString('Labels','Lbl_Anzeige_PLZ','');
                        Lbl_Anzeige_Stadt.Caption:=Unit_Variablen.ini_lang_Adress_Add.ReadString('Labels','Lbl_Anzeige_Stadt','');
                        Lbl_Anzeige_Street.Caption:=Unit_Variablen.ini_lang_Adress_Add.ReadString('Labels','Lbl_Anzeige_Street','');
                        Lbl_Anzeige_Vorname.Caption:=Unit_Variablen.ini_lang_Adress_Add.ReadString('Labels','Lbl_Anzeige_Vorname','');
                        Lbl_Anzeige_Telefon_Arbeit.Caption:=Unit_Variablen.ini_lang_Adress_Add.ReadString('Labels','Lbl_Anzeige_Telefon_Arbeit','');
                        Lbl_Anzeige_Telefon_Mobil.Caption:=Unit_Variablen.ini_lang_Adress_Add.ReadString('Labels','Lbl_Anzeige_Telefon_Mobil','');
                        Lbl_Anzeige_Telefon_Privat.Caption:=Unit_Variablen.ini_lang_Adress_Add.ReadString('Labels','Lbl_Anzeige_Telefon_Privat','');
                        EingabeFalsch1:=Unit_Variablen.ini_lang_Adress_Add.ReadString('MsgBoxs','EingabeFalsch1','');
                        EingabeFalsch2:=Unit_Variablen.ini_lang_Adress_Add.ReadString('MsgBoxs','EingabeFalsch2','');
                        SpeichernFalsch1:=Unit_Variablen.ini_lang_Adress_Add.ReadString('MsgBoxs','SpeichernFalsch1','');
                        SpeichernFalsch2:=Unit_Variablen.ini_lang_Adress_Add.ReadString('MsgBoxs','SpeichernFalsch2','');
                        Name_m:=Unit_Variablen.ini_lang_Adress_Add.ReadString('MsgBoxs','Name','');
                        Vorname_m:=Unit_Variablen.ini_lang_Adress_Add.ReadString('MsgBoxs','Vorname','');
                        PLZ_m:=Unit_Variablen.ini_lang_Adress_Add.ReadString('MsgBoxs','PLZ','');
                        Tel_Mobil:=Unit_Variablen.ini_lang_Adress_Add.ReadString('MsgBoxs','Tel_Mobil','');
                        Tel_Privat:=Unit_Variablen.ini_lang_Adress_Add.ReadString('MsgBoxs','Tel_Privat','');
                        Tel_Arbeit:=Unit_Variablen.ini_lang_Adress_Add.ReadString('MsgBoxs','Tel_Arbeit','');
                        Fax_m:=Unit_Variablen.ini_lang_Adress_Add.ReadString('MsgBoxs','Fax','');
                Unit_Variablen.ini_lang_Adress_Add.free;
        // Id Ausgeben
                Lbl_Ausgabe_ID.Caption:=inttostr(Unit_Variablen.SpeichernDatei_Number);
end;

procedure TFrm_Adress_Add.Btn_Action_SaveClick(Sender: TObject);
begin
        // Eingaben abrufen
                ID:=Unit_Variablen.SpeichernDatei_Number;
                Name:=Edt_Eingabe_Name.Text;
                if Name=''
                        then
                                begin
                                        Fehler:=1;
                                        Application.MessageBox(Pchar(Name_m),Pchar(EingabeFalsch2),MB_OK);
                                end;
                Vorname:=Edt_Eingabe_Vorname.Text;
                if Vorname=''
                        then
                                begin
                                        Fehler:=1;
                                        Application.MessageBox(Pchar(Vorname_m),Pchar(EingabeFalsch2),MB_OK);
                                end;
                Street:=Edt_Eingabe_Street.Text;
                if Street=''
                        then
                                Street:='0';
                Hausnummer:=Edt_Eingabe_Hausnummer.Text;
                if Hausnummer=''
                        then
                                Hausnummer:='0';
                try
                        PLZ:=strtoint(Edt_Eingabe_PLZ.Text);
                except
                        Application.MessageBox(Pchar(PLZ_m),Pchar(EingabeFalsch2),MB_OK);
                        Fehler:=1;
                end;
                Stadt:=Edt_Eingabe_Stadt.Text;
                if Stadt=''
                        then
                                Stadt:='0';
                Land:=Edt_Eingabe_Land.Text;
                if Land=''
                        then
                                Land:='0';
                try
                        Telefon_Mobil:=strtoint(Edt_Eingabe_Telefon_Mobil.Text);
                except
                        Application.MessageBox(Pchar(Tel_Mobil),Pchar(EingabeFalsch2),MB_OK);
                        Fehler:=1;
                end;
                try
                        Telefon_Privat:=strtoint(Edt_Eingabe_Telefon_Privat.Text);
                except
                        Application.MessageBox(Pchar(Tel_Privat),Pchar(EingabeFalsch2),MB_OK);
                        Fehler:=1;
                end;
                try
                        Telefon_Arbeit:=strtoint(Edt_Eingabe_Telefon_Arbeit.Text);
                except
                        Application.MessageBox(Pchar(Tel_Arbeit),Pchar(EingabeFalsch2),MB_OK);
                        Fehler:=1;
                end;
                try
                        Fax:=strtoint(Edt_Eingabe_Fax.Text);
                except
                        Application.MessageBox(Pchar(Fax_m),Pchar(EingabeFalsch2),MB_OK);
                        Fehler:=1;
                end;
                Mail_1:=Edt_Eingabe_Mail_1.Text;
                if Mail_1=''
                        then
                                Mail_1:='0';
                Mail_2:=Edt_Eingabe_Mail_2.Text;
                if Mail_2=''
                        then
                                Mail_2:='0';
                www:=Edt_Eingabe_WWW.Text;
                if www=''
                        then
                                www:='0';
                ICQ:=Edt_Eingabe_ICQ.Text;
                if ICQ=''
                        then
                                ICQ:='0'
                        else
                                begin
                                        // Bindestriche entfernen
                                                ICQ :=StringReplace(ICQ, '-', '', [ rfReplaceAll ]);
                                end;
                MSN:=Edt_Eingabe_MSN.Text;
                if MSN=''
                        then
                                MSN:='0';
                AIM:=Edt_Eingabe_AIM.Text;
                if AIM=''
                        then
                                AIM:='0';
                Yahoo:=Edt_Eingabe_Yahoo.Text;
                if Yahoo=''
                        then
                                Yahoo:='0';
                Delete:=false;
        // Daten ins Array schreiben
                Unit_Variablen.Datensatz.vID:=ID;
                Unit_Variablen.Datensatz.vName:=Name;
                Unit_Variablen.Datensatz.vVorname:=Vorname;
                Unit_Variablen.Datensatz.vStreet:=Street;
                Unit_Variablen.Datensatz.vHausnummer:=Hausnummer;
                Unit_Variablen.Datensatz.vPLZ:=PLZ;
                Unit_Variablen.Datensatz.vStadt:=Stadt;
                Unit_Variablen.Datensatz.vLand:=Land;
                Unit_Variablen.Datensatz.vTelefon_Mobil:=Telefon_Mobil;
                Unit_Variablen.Datensatz.vTelefon_Privat:=Telefon_Privat;
                Unit_Variablen.Datensatz.vTelefon_Arbeit:=Telefon_Arbeit;
                Unit_Variablen.Datensatz.vFax:=Fax;
                Unit_Variablen.Datensatz.vMail_1:=Mail_1;
                Unit_Variablen.Datensatz.vMail_2:=Mail_2;
                Unit_Variablen.Datensatz.vMSN:=MSN;
                Unit_Variablen.Datensatz.vwww:=WWW;
                Unit_Variablen.Datensatz.vAIM:=Aim;
                Unit_Variablen.Datensatz.vYahoo:=Yahoo;
                Unit_Variablen.Datensatz.vDelete:=Delete;
        // Alle Eingaben Fehlerfrei
                if Fehler=1
                        then
                                begin
                                        application.MessageBox(Pchar(EingabeFalsch1),Pchar(EingabeFalsch2), MB_OK);
                                        Fehler:=0;
                                end
                        else
                                begin
                                        Unit_Variablen.Speichern_New:=true;
                                        Unit_Save.Form2.save;
                                                // Speichern erfolgreich ?
                                                        if Unit_Variablen.SpeichernDatei_Size_Check=true
                                                                then
                                                                        begin
                                                                                inc(Unit_Variablen.SpeichernDatei_Number);
                                                                                Lbl_Ausgabe_ID.Caption:=inttostr(Unit_Variablen.SpeichernDatei_Number);
                                                                                Unit_Variablen.SpeichernDatei_Size_Check:=false;
                                                                                Btn_Action_Clear.Click;
                                                                        end
                                                                else
                                                                        begin
                                                                                Application.MessageBox(Pchar(SpeichernFalsch1),Pchar(SpeichernFalsch2),MB_OK)
                                                                        end;
                                end;
end;

procedure TFrm_Adress_Add.Btn_Action_ClearClick(Sender: TObject);
begin
Edt_Eingabe_Fax.Text:='0';
Edt_Eingabe_Hausnummer.Text:='';
Edt_Eingabe_Name.Text:='';
Edt_Eingabe_Vorname.Text:='';
Edt_Eingabe_Land.Text:='';
Edt_Eingabe_Stadt.Text:='';
Edt_Eingabe_Street.Text:='';
Edt_Eingabe_PLZ.Text:='00000';
Edt_Eingabe_AIM.Text:='';
Edt_Eingabe_ICQ.Text:='';
Edt_Eingabe_Mail_1.Text:='';
Edt_Eingabe_Mail_2.Text:='';
Edt_Eingabe_MSN.Text:='';
Edt_Eingabe_WWW.Text:='';
Edt_Eingabe_Yahoo.Text:='';
Edt_Eingabe_Telefon_Mobil.Text:='0';
Edt_Eingabe_Telefon_Privat.Text:='0';
Edt_Eingabe_Telefon_Arbeit.Text:='0';
end;

end.

Unit_Save
Delphi-Quellcode:
unit Unit_Save;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IniFiles;

type
  TForm2 = class(TForm)
  procedure save;
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form2: TForm2;

implementation
uses Unit_Variablen;
{$R *.dfm}

procedure TForm2.save;
begin
        // Das Array in die SpeichernDatei schreiben
                // Größe der SpeicherDatei abfragen
                        FileMode:=0; // Datei wird nur mit LeseBerechtigung geöffnet
                        Reset(Unit_Variablen.Datei);
                        Unit_Variablen.SpeichernDatei_Size:=FileSize(Unit_Variablen.Datei);
                        CloseFile(Unit_Variablen.Datei);
                // Wird ein Eintrag hinzugefügt oder geändert?
                        If Unit_Variablen.Speichern_New=true
                                then
                                        begin
                                                // Ans Ende der Datei gehen
                                                        FileMode:=1; // Datei wird nur mit SchreibeBerechtigung geöffnet
                                                        Reset(Unit_Variablen.Datei);
                                                        seek(Unit_Variablen.Datei,Unit_Variablen.Datensatz.vID-1);
                                        end
                                else
                                        begin
                                                // An die entsprechende Position in der Datei gehen
                                                        FileMode:=1; // Datei wird nur mit SchreibeBerechtigung geöffnet
                                                        Reset(Unit_Variablen.Datei);
                                                        seek(Unit_Variablen.Datei,Unit_Variablen.SpeichernDatei_ID-1);
                                        end;
                // Dateien eintragen & Datei schließen
                        write(Unit_Variablen.Datei,Unit_Variablen.Datensatz);
                        CloseFile(Unit_Variablen.Datei);
                // SpeichernDatei prüfen
                        FileMode:=0; // Datei wird nur mit LeseBerechtigung geöffnet
                        Reset(Unit_Variablen.Datei);
                        Unit_Variablen.SpeichernDatei_Size_Con:=FileSize(Unit_Variablen.Datei);
                        CloseFile(Unit_Variablen.Datei);
                // Wurde ein Datensatz geändert oder Hinzugefügt?
                        If Unit_Variablen.Speichern_New=true
                                then
                                        begin
                                                // Wurde die Datei erfolgreich gespeichert?
                                                        If (Unit_Variablen.SpeichernDatei_Size=Unit_Variablen.SpeichernDatei_Size_Con) or (Unit_Variablen.SpeichernDatei_Size>Unit_Variablen.SpeichernDatei_Size_Con)
                                                                then
                                                                        begin
                                                                                // Nein die Daten wurden nicht gespeichert
                                                                                        Unit_Variablen.SpeichernDatei_Size_Check:=false;
                                                                                        Application.MessageBox(Pchar(ini_lang_Save_Done_no),Pchar(ini_lang_Save_Done_no2),MB_OK);
                                                                        end
                                                                else
                                                                        begin
                                                                                // Ja die Daten wurden erfolgreich gespeichert
                                                                                        Application.MessageBox(Pchar(ini_lang_Save_Done_yes),Pchar(ini_lang_Save_Done_yes2),MB_OK);
                                                                                        Unit_Variablen.SpeichernDatei_Size_Check:=true;
                                                                        end;
                                        end
                                else
                                        begin
                                                // Ja die Daten wurden erfolgreich gespeichert
                                                        Application.MessageBox(Pchar(ini_lang_Save_Done_yes),Pchar(ini_lang_Save_Done_yes2),MB_OK);
                                                        Unit_Variablen.SpeichernDatei_Size_Check:=true;
                                        end;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
        // Sprachdateien abrufen
                Unit_Variablen.ini_lang_Save:=TIniFile.Create(Unit_Variablen.DirtoExe+Unit_Variablen.ini_lang_dir+Unit_Variablen.ini_lang+'/'+Unit_Variablen.ini_lang_Save_Name);
                        Unit_Variablen.ini_lang_Save_Done_yes:=Unit_Variablen.ini_lang_Save.ReadString('MsgBoxs','ini_lang_Save_Done_yes','');
                        Unit_Variablen.ini_lang_Save_Done_no:=Unit_Variablen.ini_lang_Save.ReadString('MsgBoxs','ini_lang_Save_Done_no','');
                        Unit_Variablen.ini_lang_Save_Done_yes2:=Unit_Variablen.ini_lang_Save.ReadString('MsgBoxs','ini_lang_Save_Done_yes2','');
                        Unit_Variablen.ini_lang_Save_Done_no2:=Unit_Variablen.ini_lang_Save.ReadString('MsgBoxs','ini_lang_Save_Done_no2','');
                Unit_Variablen.ini_lang_Save.free;
end;

end.

Unit_Adress_Edit
Delphi-Quellcode:
unit Unit_Adress_Edit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls,IniFiles;

type
  TFrm_Adress_Edit = class(TForm)
    Btn_Action_Search: TButton;
    Btn_Action_Clear: TButton;
    Btn_Action_Save: TButton;
    Pan_Neu: TPanel;
    Lbl_Anzeige_ICQ: TLabel;
    Lbl_Anzeige_Mail_1: TLabel;
    Lbl_Anzeige_Mail_2: TLabel;
    Lbl_Anzeige_AIM: TLabel;
    Lbl_Anzeige_Yahoo: TLabel;
    Lbl_Anzeige_MSN: TLabel;
    Lbl_Anzeige_WWW: TLabel;
    Edt_Eingabe_Mail_1: TEdit;
    Edt_Eingabe_Mail_2: TEdit;
    Edt_Eingabe_WWW: TEdit;
    Edt_Eingabe_ICQ: TEdit;
    Edt_Eingabe_MSN: TEdit;
    Edt_Eingabe_Yahoo: TEdit;
    Edt_Eingabe_AIM: TEdit;
    Pan_Standart: TPanel;
    Lbl_Anzeige_ID: TLabel;
    Lbl_Anzeige_Name: TLabel;
    Lbl_Anzeige_Vorname: TLabel;
    Lbl_Anzeige_Fax: TLabel;
    Lbl_Anzeige_Telefon_Arbeit: TLabel;
    Lbl_Anzeige_Telefon_Mobil: TLabel;
    Lbl_Anzeige_Street: TLabel;
    Lbl_Anzeige_Telefon_Privat: TLabel;
    Lbl_Anzeige_Land: TLabel;
    Lbl_Anzeige_PLZ: TLabel;
    Lbl_Anzeige_Stadt: TLabel;
    Lbl_Anzeige_Hausnummer: TLabel;
    Lbl_Ausgabe_ID: TLabel;
    Edt_Eingabe_Name: TEdit;
    Edt_Eingabe_Hausnummer: TEdit;
    Edt_Eingabe_PLZ: TEdit;
    Edt_Eingabe_Stadt: TEdit;
    Edt_Eingabe_Land: TEdit;
    Edt_Eingabe_Telefon_Privat: TEdit;
    Edt_Eingabe_Telefon_Mobil: TEdit;
    Edt_Eingabe_Telefon_Arbeit: TEdit;
    Edt_Eingabe_Fax: TEdit;
    Edt_Eingabe_Vorname: TEdit;
    Edt_Eingabe_Street: TEdit;
    Edt_Eingabe_ID: TEdit;
    procedure Btn_Action_ClearClick(Sender: TObject);
    procedure Btn_Action_SaveClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Btn_Action_SearchClick(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Frm_Adress_Edit: TFrm_Adress_Edit;
  ID:Integer;
  Name:String;
  Vorname:String;
  Street:String;
  Hausnummer:String;
  PLZ:Integer;
  Stadt:String;
  Land:String;
  Telefon_Mobil:Integer;
  Telefon_Privat:Integer;
  Telefon_Arbeit:Integer;
  Fax:Integer;
  Mail_1:String;
  Mail_2:String;
  www:String;
  ICQ:String;
  MSN:String;
  AIM:String;
  Yahoo:String;
  Delete:boolean;
  DateiSizeCon:Integer;
  Fehler:Integer;
  EingabeFalsch1,EingabeFalsch2,SpeichernFalsch1,SpeichernFalsch2,Name_m,Vorname_m,PLZ_m,Tel_Mobil,Tel_Arbeit,Tel_Privat,Fax_m:String;
  ID_1,ID_2,ID_3,KeineDaten:String;

implementation
uses Unit_Variablen,Unit_Load,Unit_Save;
{$R *.dfm}

procedure TFrm_Adress_Edit.Btn_Action_ClearClick(Sender: TObject);
begin
// Felder leeren
        Edt_Eingabe_Fax.Clear;
        Edt_Eingabe_Hausnummer.Clear;
        Edt_Eingabe_Land.Clear;
        Edt_Eingabe_Name.Clear;
        Edt_Eingabe_PLZ.Clear;
        Edt_Eingabe_Stadt.Clear;
        Edt_Eingabe_Street.Clear;
        Edt_Eingabe_Telefon_Arbeit.Clear;
        Edt_Eingabe_Telefon_Mobil.Clear;
        Edt_Eingabe_Telefon_Privat.Clear;
        Edt_Eingabe_Vorname.Clear;
        Edt_Eingabe_AIM.Clear;
        Edt_Eingabe_ICQ.Clear;
        Edt_Eingabe_Mail_1.Clear;
        Edt_Eingabe_Mail_2.Clear;
        Edt_Eingabe_MSN.Clear;
        Edt_Eingabe_WWW.Clear;
        Edt_Eingabe_Yahoo.Clear;
end;

procedure TFrm_Adress_Edit.Btn_Action_SaveClick(Sender: TObject);
begin
// Eingaben abrufen
                ID:=Unit_Variablen.SpeichernDatei_Number;
                Name:=Edt_Eingabe_Name.Text;
                if Name=''
                        then
                                begin
                                        Fehler:=1;
                                        Application.MessageBox(Pchar(Name_m),Pchar(EingabeFalsch2),MB_OK);
                                end;
                Vorname:=Edt_Eingabe_Vorname.Text;
                if Vorname=''
                        then
                                begin
                                        Fehler:=1;
                                        Application.MessageBox(Pchar(Vorname_m),Pchar(EingabeFalsch2),MB_OK);
                                end;
                Street:=Edt_Eingabe_Street.Text;
                if Street=''
                        then
                                Street:='0';
                Hausnummer:=Edt_Eingabe_Hausnummer.Text;
                if Hausnummer=''
                        then
                                Hausnummer:='0';
                try
                        PLZ:=strtoint(Edt_Eingabe_PLZ.Text);
                except
                        Application.MessageBox(Pchar(PLZ_m),Pchar(EingabeFalsch2),MB_OK);
                        Fehler:=1;
                end;
                Stadt:=Edt_Eingabe_Stadt.Text;
                if Stadt=''
                        then
                                Stadt:='0';
                Land:=Edt_Eingabe_Land.Text;
                if Land=''
                        then
                                Land:='0';
                try
                        Telefon_Mobil:=strtoint(Edt_Eingabe_Telefon_Mobil.Text);
                except
                        Application.MessageBox(Pchar(Tel_Mobil),Pchar(EingabeFalsch2),MB_OK);
                        Fehler:=1;
                end;
                try
                        Telefon_Privat:=strtoint(Edt_Eingabe_Telefon_Privat.Text);
                except
                        Application.MessageBox(Pchar(Tel_Privat),Pchar(EingabeFalsch2),MB_OK);
                        Fehler:=1;
                end;
                try
                        Telefon_Arbeit:=strtoint(Edt_Eingabe_Telefon_Arbeit.Text);
                except
                        Application.MessageBox(Pchar(Tel_Arbeit),Pchar(EingabeFalsch2),MB_OK);
                        Fehler:=1;
                end;
                try
                        Fax:=strtoint(Edt_Eingabe_Fax.Text);
                except
                        Application.MessageBox(Pchar(Fax_m),Pchar(EingabeFalsch2),MB_OK);
                        Fehler:=1;
                end;
                Mail_1:=Edt_Eingabe_Mail_1.Text;
                if Mail_1=''
                        then
                                Mail_1:='0';
                Mail_2:=Edt_Eingabe_Mail_2.Text;
                if Mail_2=''
                        then
                                Mail_2:='0';
                www:=Edt_Eingabe_WWW.Text;
                if www=''
                        then
                                www:='0';
                ICQ:=Edt_Eingabe_ICQ.Text;
                if ICQ=''
                        then
                                ICQ:='0'
                        else
                                begin
                                        // Bindestriche entfernen
                                                ICQ :=StringReplace(ICQ, '-', '', [ rfReplaceAll ]);
                                end;
                MSN:=Edt_Eingabe_MSN.Text;
                if MSN=''
                        then
                                MSN:='0';
                AIM:=Edt_Eingabe_AIM.Text;
                if AIM=''
                        then
                                AIM:='0';
                Yahoo:=Edt_Eingabe_Yahoo.Text;
                if Yahoo=''
                        then
                                Yahoo:='0';
                Delete:=false;
        // Daten ins Array schreiben
                Unit_Variablen.Datensatz.vID:=ID;
                Unit_Variablen.Datensatz.vName:=Name;
                Unit_Variablen.Datensatz.vVorname:=Vorname;
                Unit_Variablen.Datensatz.vStreet:=Street;
                Unit_Variablen.Datensatz.vHausnummer:=Hausnummer;
                Unit_Variablen.Datensatz.vPLZ:=PLZ;
                Unit_Variablen.Datensatz.vStadt:=Stadt;
                Unit_Variablen.Datensatz.vLand:=Land;
                Unit_Variablen.Datensatz.vTelefon_Mobil:=Telefon_Mobil;
                Unit_Variablen.Datensatz.vTelefon_Privat:=Telefon_Privat;
                Unit_Variablen.Datensatz.vTelefon_Arbeit:=Telefon_Arbeit;
                Unit_Variablen.Datensatz.vFax:=Fax;
                Unit_Variablen.Datensatz.vMail_1:=Mail_1;
                Unit_Variablen.Datensatz.vMail_2:=Mail_2;
                Unit_Variablen.Datensatz.vMSN:=MSN;
                Unit_Variablen.Datensatz.vwww:=WWW;
                Unit_Variablen.Datensatz.vAIM:=Aim;
                Unit_Variablen.Datensatz.vYahoo:=Yahoo;
                Unit_Variablen.Datensatz.vDelete:=Delete;
        // Alle Eingaben Fehlerfrei
                if Fehler=1
                        then
                                begin
                                        application.MessageBox('Fehlerhafte / Unvollständige Eingabe. Daten wurden nicht gespeichert!','Eingabefehler');
                                        Fehler:=0;
                                end
                        else
                                begin
                                        Unit_Variablen.Speichern_New:=false;
                                        Unit_Save.Form2.save;
                                                // Speichern erfolgreich ?
                                                        if Unit_Variablen.SpeichernDatei_Size_Check=true
                                                                then
                                                                        begin
                                                                                inc(Unit_Variablen.SpeichernDatei_Number);
                                                                                Lbl_Ausgabe_ID.Caption:=inttostr(Unit_Variablen.SpeichernDatei_Number);
                                                                                Unit_Variablen.SpeichernDatei_Size_Check:=false;
                                                                                Btn_Action_Clear.Click;
                                                                                Btn_Action_Save.Visible:=false;
                                                                                Btn_Action_Search.Visible:=true;
                                                                                Edt_Eingabe_ID.Visible:=true;
                                                                                Lbl_Ausgabe_ID.Visible:=false;
                                                                        end
                                                                else
                                                                        begin

                                                                        end;
                                end;
end;

procedure TFrm_Adress_Edit.FormCreate(Sender: TObject);
begin
        // Sprachdateien abrufen
                Unit_Variablen.ini_lang_Adress_Edit:=TIniFile.Create(Unit_Variablen.DirtoExe+Unit_Variablen.ini_lang_dir+Unit_Variablen.ini_lang+'/'+Unit_Variablen.ini_lang_Adress_Edit_Name);
                        Btn_Action_Clear.Caption:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('Buttens','Btn_Action_Clear','');
                        Btn_Action_Save.Caption:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('Buttens','Btn_Action_Save','');
                        Btn_Action_Search.Caption:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('Buttens','Btn_Action_Search','');
                        Lbl_Anzeige_Hausnummer.Caption:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('Labels','Lbl_Anzeige_Hausnummer','');
                        Lbl_Anzeige_Land.Caption:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('Labels','Lbl_Anzeige_Land','');
                        Lbl_Anzeige_Name.Caption:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('Labels','Lbl_Anzeige_Name','');
                        Lbl_Anzeige_PLZ.Caption:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('Labels','Lbl_Anzeige_PLZ','');
                        Lbl_Anzeige_Stadt.Caption:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('Labels','Lbl_Anzeige_Stadt','');
                        Lbl_Anzeige_Street.Caption:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('Labels','Lbl_Anzeige_Street','');
                        Lbl_Anzeige_Vorname.Caption:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('Labels','Lbl_Anzeige_Vorname','');
                        Lbl_Anzeige_Telefon_Arbeit.Caption:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('Labels','Lbl_Anzeige_Telefon_Arbeit','');
                        Lbl_Anzeige_Telefon_Mobil.Caption:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('Labels','Lbl_Anzeige_Telefon_Mobil','');
                        Lbl_Anzeige_Telefon_Privat.Caption:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('Labels','Lbl_Anzeige_Telefon_Privat','');
                        EingabeFalsch1:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('MsgBoxs','EingabeFalsch1','');
                        EingabeFalsch2:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('MsgBoxs','EingabeFalsch2','');
                        SpeichernFalsch1:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('MsgBoxs','SpeichernFalsch1','');
                        SpeichernFalsch2:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('MsgBoxs','SpeichernFalsch2','');
                        Name_m:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('MsgBoxs','Name','');
                        Vorname_m:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('MsgBoxs','Vorname','');
                        PLZ_m:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('MsgBoxs','PLZ','');
                        Tel_Mobil:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('MsgBoxs','Tel_Mobil','');
                        Tel_Privat:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('MsgBoxs','Tel_Privat','');
                        Tel_Arbeit:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('MsgBoxs','Tel_Arbeit','');
                        Fax_m:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('MsgBoxs','Fax','');
                        ID_1:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('MsgBoxs','ID_1','');
                        ID_2:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('MsgBoxs','ID_2','');
                        ID_3:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('MsgBoxs','ID_3','');
                        KeineDaten:=Unit_Variablen.ini_lang_Adress_Edit.ReadString('MsgBoxs','KeineDaten','');
                Unit_Variablen.ini_lang_Adress_Edit.free;
end;

procedure TFrm_Adress_Edit.Btn_Action_SearchClick(Sender: TObject);
var
Text:String;
begin
        // Sind Einträge in der Datei vorhanden
                if Unit_Variablen.SpeichernDatei_Number < 2
                        then
                                begin
                                        // FehlerNachricht ausgeben
                                                application.MessageBox(Pchar(KeineDaten),Pchar(SpeichernFalsch2),MB_OK)
                                end
                        else
                                begin
                                        // Eingegebene ID Abrufen
                                                Unit_Variablen.SpeichernDatei_ID:=strtoint(Edt_Eingabe_ID.Text);
                                        // Ist die ID < 1 oder > als die gesammte Anzahl Einträge
                                                if (Unit_Variablen.SpeichernDatei_ID < 1) or (Unit_Variablen.SpeichernDatei_ID > Unit_Variablen.SpeichernDatei_Number)
                                                        then
                                                                begin
                                                                        //FehlerNachricht ausgeben
                                                                                Text:=ID_1+#10#13+ID_2+' '+inttostr(Unit_Variablen.SpeichernDatei_Number-1)+' '+ID_3;
                                                                                        application.MessageBox(pchar(Text), Pchar(EingabeFalsch2), MB_OK);
                                                                end
                                                        else
                                                                begin
                                                                        // LadenDatei aussführen
                                                                                Unit_Load.Form3.load;
                                                                        // Alles in die Felder schreiben
                                                                                // Daten aus dem Array in die Variablen übertragen
                                                                                        ID:=Unit_Variablen.Datensatz.vID;
                                                                                        Name:=Unit_Variablen.Datensatz.vName;
                                                                                        Vorname:=Unit_Variablen.Datensatz.vVorname;
                                                                                        Street:=Unit_Variablen.Datensatz.vStreet;
                                                                                        Hausnummer:=Unit_Variablen.Datensatz.vHausnummer;
                                                                                        PLZ:=Unit_Variablen.Datensatz.vPLZ;
                                                                                        Stadt:=Unit_Variablen.Datensatz.vStadt;
                                                                                        Land:=Unit_Variablen.Datensatz.vLand;
                                                                                        Telefon_Mobil:=Unit_Variablen.Datensatz.vTelefon_Mobil;
                                                                                        Telefon_Privat:=Unit_Variablen.Datensatz.vTelefon_Privat;
                                                                                        Telefon_Arbeit:=Unit_Variablen.Datensatz.vTelefon_Arbeit;
                                                                                        Fax:=Unit_Variablen.Datensatz.vFax;
                                                                                        Mail_1:=Unit_Variablen.Datensatz.vMail_1;
                                                                                        Mail_2:=Unit_Variablen.Datensatz.vMail_2;
                                                                                        MSN:=Unit_Variablen.Datensatz.vMSN;
                                                                                        WWW:=Unit_Variablen.Datensatz.vwww;
                                                                                        Aim:=Unit_Variablen.Datensatz.vAIM;
                                                                                        Yahoo:=Unit_Variablen.Datensatz.vYahoo;
                                                                                        Delete:=Unit_Variablen.Datensatz.vDelete;
                                                                                // Daten in die Felder schreiben
                                                                                        Lbl_Ausgabe_ID.Caption:=inttostr(ID);
                                                                                        Edt_Eingabe_Hausnummer.Text:=Hausnummer;
                                                                                        Edt_Eingabe_Fax.Text:=inttostr(Fax);
                                                                                        Edt_Eingabe_Land.Text:=Land;
                                                                                        Edt_Eingabe_Name.Text:=Name;
                                                                                        Edt_Eingabe_PLZ.Text:=inttostr(PLZ);
                                                                                        Edt_Eingabe_Stadt.Text:=Stadt;
                                                                                        Edt_Eingabe_Street.Text:=Street;
                                                                                        Edt_Eingabe_Vorname.Text:=Vorname;
                                                                                        Edt_Eingabe_Telefon_Arbeit.Text:=inttostr(Telefon_Arbeit);
                                                                                        Edt_Eingabe_Telefon_Mobil.Text:=inttostr(Telefon_Mobil);
                                                                                        Edt_Eingabe_Telefon_Privat.Text:=inttostr(Telefon_Privat);
                                                                                        Edt_Eingabe_AIM.Text:=AIM;
                                                                                        Edt_Eingabe_ICQ.Text:=ICQ;
                                                                                        Edt_Eingabe_Mail_1.Text:=Mail_1;
                                                                                        Edt_Eingabe_Mail_2.Text:=Mail_2;
                                                                                        Edt_Eingabe_MSN.Text:=MSN;
                                                                                        Edt_Eingabe_WWW.Text:=WWW;
                                                                                        Edt_Eingabe_Yahoo.Text:=Yahoo;
                                                                                // Buttens wechseln
                                                                                        Btn_Action_Search.Visible:=false;
                                                                                        Btn_Action_Save.Visible:=True;
                                                                                        Edt_Eingabe_ID.Visible:=false;
                                                                                        Lbl_Ausgabe_ID.Visible:=true;
                                                                end;
                                end;
end;

end.

Unit_Load
Delphi-Quellcode:
unit Unit_Load;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,IniFiles;

type
  TForm3 = class(TForm)
  procedure load;
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form3: TForm3;
  Fehler1,Fehler2:String;
implementation
uses Unit_Variablen;
{$R *.dfm}
procedure TForm3.load;
begin
        try
                // Datensatz auslesen und ins Array schreiben
                        // Zeiger vor den richtigen Eintrag setzen
                                FileMode:=0; // Datei wird nur mit LeseBerechtigung geöffnet
                                Reset(Unit_Variablen.Datei);
                                seek(Unit_Variablen.Datei, Unit_Variablen.SpeichernDatei_ID-1);
                        // Datensatz lesen & Datei schließen
                                read(Unit_Variablen.Datei,Unit_Variablen.Datensatz);
                                CloseFile(Unit_Variablen.Datei);
        except
                application.MessageBox(Pchar(Fehler1),Pchar(Fehler2) ,MB_OK);
        end;
end;

procedure TForm3.FormCreate(Sender: TObject);
begin
        // Sprachdateien abrufen
                Unit_Variablen.ini_lang_Load:=TIniFile.Create(Unit_Variablen.DirtoExe+Unit_Variablen.ini_lang_dir+Unit_Variablen.ini_lang+'/'+Unit_Variablen.ini_lang_Load_Name);
                        Fehler1:=Unit_Variablen.ini_lang_Load.ReadString('MsgBoxs','Fehler1','');
                        Fehler2:=Unit_Variablen.ini_lang_Load.ReadString('MsgBoxs','Fehler2','');
                Unit_Variablen.ini_lang_Load.free;
end;
end.

Ich hoffe, ich habe nichts vergessen.
  Mit Zitat antworten Zitat