Source Code Adoquery CRUD
Source Code Adoquery CRUD
procedure tampil();
procedure reload();
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
input : Tcomponent;
jk : String;
implementation
{$R *.dfm}
procedure TForm2.tampil;
begin
ednoktp.text := ADOQuery1['noktp'];
ednama.text := ADOQuery1['nama'];
ednohp.Text := ADOQuery1.FieldByName('nohp').Value;
Edalamat.Text := ADOQuery1.FieldByName('alamat').Value;
Edlahir.Text := ADOQuery1.FieldValues['asal'];
Edkerja.Text := ADOQuery1.FieldValues['pekerjaan'];
Edumur.Text := ADOQuery1['umur'];
begin
rdblaki.Checked := True;
rdbperempuan.Checked := False;
end
else
begin
rdblaki.Checked := False;
rdbperempuan.Checked := True;
end;
end;
//procedure yang digunakan untuk memperbaharui isi tabel
procedure tform2.reload;
begin
adoquery1.SQL.Clear;
adoquery1.active:=true;
end;
begin
begin
begin
TEdit(input).SetFocus;
Exit;
end;
//cek radiobutton
begin
Exit;
end;
end;
//mencegah duplicate entry
begin
ednoktp.Clear; ednoktp.SetFocus;
end
else
begin
adoquery1.SQL.text :='INSERT INTO person VALUES(:ktp, :nama, :jk, :nohp, :alamat, :lahir, :kerja,
:umur)';
adoquery1.Parameters.ParamByName('ktp').Value :=ednoktp.text;
adoquery1.Parameters.ParamByName('nama').Value :=ednama.text;
adoquery1.Parameters.ParamByName('jk').Value :=jk;
adoquery1.Parameters.ParamByName('nohp').Value :=ednohp.text;
adoquery1.Parameters.ParamByName('alamat').Value :=edalamat.text;
adoquery1.Parameters.ParamByName('lahir').Value :=edlahir.text;
adoquery1.Parameters.ParamByName('kerja').Value :=edkerja.text;
adoquery1.Parameters.ParamByName('umur').Value :=edumur.text;
adoquery1.ExecSQL;
reload();
end;
end;
begin
ednoktp.Clear;
ednoktp.SetFocus;
end
else
begin
if Application.MessageBox('Yakin mau hapus data ini?', 'Konfirmasi Hapus', 4)= mrYes then
adoquery1.SQL.Clear;
adoquery1.ExecSQL;
reload();
end;
end;
begin
begin
begin
TEdit(input).SetFocus;
Exit;
end;
//cek radiobutton
begin
Exit;
end;
end;
begin
ednoktp.Clear;
ednoktp.SetFocus;
end
else
begin
adoquery1.ExecSQL;
reload();
end;
end;
procedure TForm2.btnnextClick(Sender: TObject);
begin
adoquery1.next;
tampil;
end;
begin
begin
ADOquery1.Prior;
tampil;
end
else
begin
end;
end;
begin
end;
begin
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
adoquery1.Active:= true;
end;
end.