Welcome to Abdul Malik Ikhsan's Blog

Error Handling Simpan data

Posted in Tutorial Delphi by samsonasik on January 13, 2007

procedure TFormInputDataBarang.BitBtnSimpanClick(Sender: TObject);
begin
if (not ((ADOQuery1.State=dsEdit) or
(ADOQuery1.State=dsInsert)))
then
begin
if (ADOQuery1.MaxRecords=0)
then
begin
showmessage(‘anda sedang tidak dalam mode edit/update data’);
ADOConnection1.Close;
DataSource1.DataSet.Close;
ADOQuery1.Close;
ADOConnection1.Open;
DataSource1.DataSet.Open;
ADOQuery1.Open;
end
else
begin
showmessage(‘anda sedang tidak dalam mode edit/update data’);
DataSource1.DataSet.Close;
ADOQuery1.Close;
ADOQuery1.Open;
DataSource1.DataSet.Open;
dbedit1.Text:=”;
dbedit2.Text:=”;
ComboBox1.Text:=”;
dbedit3.Text:=”;
dbgrid1.Refresh;
exit;
end;
end;

if ((ADOQuery1.State=dsEdit) or
(ADOQuery1.State=dsInsert))
then
begin
if ((dbedit1.Text=”) and (dbedit2.Text=”) or (dbedit2.Text=”)) then
begin
showmessage(‘isi dulu data’);
dbedit1.SetFocus;
end
else
begin
BitBtn1.Enabled:=true;
BitBtn2.Enabled:=true;
BitBtn3.Enabled:=true;
BitBtn4.Enabled:=true;
BitBtn5.Enabled:=true;
BitBtn6.Enabled:=true;
BitBtn7.Enabled:=true;
BitBtn8.Enabled:=true;
ADOQuery1.Post;
ADOQuery1.Close;
ADOQuery1.Prepared;
ADOQuery1.Open;
end;
end;
end;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: