unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, Mask, DBCtrls,
DB, DBTables, ExtCtrls;
type
TForm2 = class(TForm)
MainMenu1: TMainMenu;
Date1: TMenuItem;
zurck1: TMenuItem;
N1: TMenuItem;
Schlieen1: TMenuItem;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
DBText1: TDBText;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
DBEdit3: TDBEdit;
DBEdit4: TDBEdit;
DBEdit5: TDBEdit;
DBEdit6: TDBEdit;
DBEdit7: TDBEdit;
DBEdit8: TDBEdit;
DBEdit9: TDBEdit;
DBEdit10: TDBEdit;
Table1: TTable;
DataSource1: TDataSource;
BtnFirst: TButton;
BtnPrior: TButton;
BtnNext: TButton;
BtnLast: TButton;
CheckBox1: TCheckBox;
BtnNew: TButton;
BtnStore: TButton;
BtnCancel: TButton;
BtnDelete: TButton;
procedure Schlieen1Click(Sender: TObject);
procedure BtnNewClick(Sender: TObject);
procedure BtnStoreClick(Sender: TObject);
procedure BtnDeleteClick(Sender: TObject);
procedure BtnPriorClick(Sender: TObject);
procedure BtnFirstClick(Sender: TObject);
procedure BtnNextClick(Sender: TObject);
procedure BtnLastClick(Sender: TObject);
procedure BtnCancelClick(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure Table1AfterEdit(DataSet: TDataSet);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
procedure setButtons(m: Byte);
public
{ Public-Deklarationen }
end;
var
Form2: TForm2;
implementation
uses JH_Designs;
{$R *.dfm}
var pos: TBookmark;
procedure TForm2.setButtons(m: Byte);
begin
case m of
0: begin BtnNew.Enabled := False; BtnStore.Enabled := False;
BtnCancel.Enabled := False; BtnDelete.Enabled := False end;
1: begin BtnNew.Enabled := True; BtnStore.Enabled := False;
BtnCancel.Enabled := False; BtnDelete.Enabled := True end;
2: begin BtnNew.Enabled := False; BtnStore.Enabled := True;
BtnCancel.Enabled := True; BtnDelete.Enabled := False end
end
end;
procedure TForm2.Schlieen1Click(Sender: TObject);
begin
Form1.Visible:=True;
Close;
end;
procedure TForm2.BtnPriorClick(Sender: TObject); // Zurück
begin
Table1.Prior;
BtnLast.Enabled := True; BtnNext.Enabled := True;
if Table1.BOF then BtnFirstClick(Self)
end;
procedure TForm2.BtnFirstClick(Sender: TObject); // Erster
begin
Table1.First;
BtnLast.Enabled := True; BtnNext.Enabled := True;
BtnPrior.Enabled := False; BtnFirst.Enabled := False
end;
procedure TForm2.BtnNextClick(Sender: TObject); // Vorwärts
begin
Table1.Next;
BtnFirst.Enabled := True; BtnPrior.Enabled := True;
if Table1.EOF then BtnLastClick(Self)
end;
procedure TForm2.BtnLastClick(Sender: TObject); // Letzter
begin
Table1.Last;
BtnFirst.Enabled := True; BtnPrior.Enabled := True;
BtnLast.Enabled := False; BtnNext.Enabled := False
end;
procedure TForm2.BtnNewClick(Sender: TObject); // Neu
begin
Table1.Append; setButtons(2)
end;
procedure TForm2.BtnCancelClick(Sender: TObject); // Rückgängig
begin
Table1.Cancel; Table1.Edit; setButtons(1)
end;
procedure TForm2.CheckBox1Click(Sender: TObject); // Lese-/Schreibzugriff
begin
pos := Table1.GetBookmark; // Position merken
Table1.Active := False;
if CheckBox1.Checked = True then // Schreibschutz
begin
Table1.ReadOnly := True;
setButtons(0)
end else // Lesen und Schreiben
begin
Table1.ReadOnly := False;
setButtons(1)
end;
Table1.Active := True;
Table1.GotoBookmark(pos); // Position wiederherstellen
end;
procedure TForm2.Table1AfterEdit(DataSet: TDataSet); // irgendwas eingegeben
begin
setButtons(2)
end;
procedure TForm2.BtnStoreClick(Sender: TObject); // Speichern
begin
Table1.Post; Table1.Edit; setButtons(1)
end;
procedure TForm2.BtnDeleteClick(Sender: TObject); // Löschen
begin
if MessageDlg('Wollen Sie den Kunden wirklich löschen?',
mtWarning,[mbYes, mbNo], 0) = mrYes then
begin Table1.Delete; Table1.Edit end
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
setButtons(0)
end;
end.