public
procedure clear;
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function ComboTest(
const acombo : TCombobox): boolean;
begin
result := Length (acombo.Text) > 0;
end;
function DateEditTest(
const aDateEdit : TDateEdit): Boolean;
begin
result := Length (aDateEdit.Text) >0;
// Ein Passender Code
end;
function MaskEditTest(
const aMaskEdit : TMaskEdit): Boolean;
begin
result := Length (aMaskEdit.text) >0;
// und noch ein Code;
end;
procedure TForm1.clear;
begin
edvim.text:='
';
edbenr.Text:='
';
edlief.Text:='
';
delterm.Text:='
';
edkunde.Text:='
';
edabnr.Text:='
';
cbaufgabe.Text:='
';
dekterm.Text:='
';
edbemerk.Text:='
';
edvim.SetFocus;
end;
procedure TForm1.btnspeichernClick(Sender: TObject);
var datum:TDate;
zeit:TTime;
begin
datum:=date;
zeit:=time;
qrmain.Sql.Clear;
qrmain.Sql.Text:='
Insert into Anforderungen (vim,benr,lieferant,ltermin,kunde,'+
'
abnr,aufgabe,ktermin,bemerkung,anfdat,anfuhr)' +
'
VALUES ('+quotedstr(edvim.text)+'
,'+quotedstr(edbenr.text)+'
,'+
quotedstr(edlief.text)+'
,'+quotedstr(delterm.text)+'
,'+
quotedstr(edkunde.text)+'
,'+quotedstr(edabnr.text)+'
,'+
quotedstr(cbaufgabe.text)+'
,'+quotedstr(dekterm.text)+'
,'+
quotedstr(edbemerk.text)+'
,'+quotedstr(datetostr(datum))+'
,'+
quotedstr(timetostr(zeit))+'
);';
qrmain.ExecSql;
body.Clear;
body.Lines.Add('
VIM: '+edvim.text);
body.Lines.Add('
BE_NR: '+edbenr.text);
smtp.MailMessage:=body.Lines;
smtp.Mail;
clear;
end;
procedure TForm1.btnabbruchClick(Sender: TObject);
begin
clear;
end;
procedure TForm1.btnendeClick(Sender: TObject);
begin
application.Terminate;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
smtp.Connect;
end;
procedure TForm1.qrmainBeforePost(DataSet: TDataSet);
var i: integer;
test:boolean;
tmpComponent : TComponent;
begin
test:=true;
for i := 0
to Form1.ComponentCount -1
do
begin
tmpComponent := Components[i];
if (tmpComponent
is TMaskEdit)
then // Test des MaskEdit
begin
test := MaskEditTest (tmpComponent
as TMaskEdit);
end;
if (tmpComponent
is TDateEdit)
then // Test des DateEdit
begin
test := DateEditTest (tmpComponent
as TDateEdit);
end;
if (tmpComponent
is TCombobox)
then // Test der VomboBox
begin
test := ComboTest (tmpComponent
as TCombobox);
end;
if not (test)
then
begin
break;
end;
end;
if not (Test)
then
begin
ShowMessage('
Fehler bei der Eingabe');
Dataset.Cancel;
end;
end;
end.