0% found this document useful (0 votes)
26 views5 pages

Modul 15: Untuk Tingkat 3

1. The document provides instructions for an application module, including configuring queries, data sources, and controls on a form. 2. It specifies using the same table from a previous module, configuring two queries where one is active and requests live data, and placing a DB grid bound to the active query. 3. It also provides code for procedures to handle user interface interactions like refreshing, searching, editing, deleting records from the query and database table.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views5 pages

Modul 15: Untuk Tingkat 3

1. The document provides instructions for an application module, including configuring queries, data sources, and controls on a form. 2. It specifies using the same table from a previous module, configuring two queries where one is active and requests live data, and placing a DB grid bound to the active query. 3. It also provides code for procedures to handle user interface interactions like refreshing, searching, editing, deleting records from the query and database table.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Untuk Tingkat 3

Aplikasi Full-SQL

Modul 15

DBEdit1 DBEdit2 DBEdit3

Query1

Query2

Panel StatusBar

Cat: 1. Tabel Gunakan yang di modul tingkat II, tanpa field Foto 2. Query1 isi properti SQL dengan : Select * From Anggota, properti Active = True, Properti RequestLive = True 3. Query2 kosongkan properti SQL, properti Active = False 4. Dibawah panel letakkan DBGrid dan properti DataSource = Query1 5. DBEdit ubah semua properti DataSource = Query1

unit UAnggota; interface uses type TForm1 = class(TForm) procedure Bersih; procedure TampilkanHint(sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} //menampilkan hint pada status bar (lihat juga pada form create) procedure TForm1.TampilkanHint(sender: TObject); begin StatusBar1.Panels.Items[0].Text := Application.Hint; end; procedure TForm1.Bersih; begin edit1.Text :=''; edit2.Text :=''; edit3.Text :=''; end; procedure TForm1.FormCreate(Sender: TObject); begin bersih; application.OnHint := TampilkanHint; end; procedure TForm1.btBersihkanClick(Sender: TObject); begin bersih; edit1.SetFocus end; procedure TForm1.btSimpanClick(Sender: TObject); begin if not(edit1.Text <>'') or not(edit2.Text <>'') or not(edit3.Text <>'') then begin application.MessageBox('Isi semua dulu','Yuhu', Mb_ok or mb_iconInformation); exit; end;

try if application.MessageBox('Yakin simpan ha..ha..ha..','He', mb_YesNo + mb_IconInformation)=IdYes then begin query2.SQL.Clear; query2.SQL.Add('insert into anggota (id_anggota,nama,alamat)'+ 'values(:id_anggota, :nama, :alamat)'); query2.Prepare; query2.params[0].Asfloat:= strtoint(edit1.Text); query2.params[1].AsString := edit2.Text; query2.params[2].AsString := edit3.Text; query2.ExecSQL; Query1.Close; query1.Open; bersih; query1.Last; edit1.SetFocus; end; except Application.MessageBox('Data sudah ada','Oce', mb_Ok or mb_IconStop); edit1.SetFocus end; end; procedure TForm1.btTutupClick(Sender: TObject); begin application.Terminate end; procedure TForm1.btCariIdAnggotaClick(Sender: TObject); begin //masukkan angka jangan huruf atau kosong karena tipe data number try Query1.Close; query1.SQL.Clear; Query1.SQL.Add('select * from anggota where id_anggota= :id_anggota'); query1.Prepare; query1.Params[0].AsFloat := strtoint(edit1.Text); query1.Open; btUbah.Visible :=true except application.MessageBox('Masukkan Yang benar','Oi',mb_ok+mb_iconinformation); end; end; procedure TForm1.btSegarkanClick(Sender: TObject); begin query1.Close; query1.SQL.Clear; query1.SQL.Add('select * from anggota'); query1.Open; btUbah.Visible :=false end;

procedure TForm1.btCariNamaClick(Sender: TObject); begin query1.Close; query1.SQL.Clear; query1.SQL.Add('select * from anggota where nama= :nama'); query1.Prepare; query1.ParamByName('nama').AsString := edit2.Text; query1.Open; btUbah.Visible :=true end; procedure TForm1.btUbahClick(Sender: TObject); begin PanelUbahData.Visible :=true end; procedure TForm1.btMengubahDataClick(Sender: TObject); begin if application.MessageBox('Yakin ubah???','He..he', mb_YesNo + mb_IconWarning)=IdYes then begin query1.UpdateRecord; query1.Post; end; query1.Close; query1.Open; PanelUbahData.Visible :=false end; procedure TForm1.SpeedButton1Click(Sender: TObject); begin PanelUbahData.Visible :=false end; procedure TForm1.btHapusClick(Sender: TObject); var s : array[0..255] of char; begin strPCopy(s,format('Yakin hapus.....%s...... ?',[query1.Fields[1].AsString])); if application.MessageBox(s,'Ha..Haa..',mb_YesNo or mb_IconWarning)=IdNo then exit; with query2 do begin sql.Clear; sql.Add('delete from anggota where id_anggota= :id_anggota'); Prepare; Params[0].AsFloat := query1.Fields[0].AsFloat; ExecSQL; end; query1.Close; query1.Open; PanelUbahData.Visible := false end; end.

Created by: Ferry 085241035883

You might also like