Aplikasi Perpustakaan - Edisi 5 (Form Data Peminjaman)

Program Perpustakaan.


Tampilan Menu Utama
1. Membuat Form Data Peminjaman.

Selanjutnya kita membuat Form Data Pemijaman, untuk source kode kalian bisa lihat di bawah sini:

source code:
1: unit Unit9;
2:
3: interface
4:
5: uses
6: Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7: Dialogs, StdCtrls, Buttons, DB, ADODB, XPMan;
8:
9: type
10: TForm_DataPeminjaman = class(TForm)
11: GroupBox1: TGroupBox;
12: ListBox1: TListBox;
13: ListBox2: TListBox;
14: Label1: TLabel;
15: Label2: TLabel;
16: Edit1: TEdit;
17: Label3: TLabel;
18: Label4: TLabel;
19: Edit2: TEdit;
20: Label5: TLabel;
21: Edit3: TEdit;
22: Label6: TLabel;
23: Edit4: TEdit;
24: XPManifest1: TXPManifest;
25: Query: TADOQuery;
26: BitBtn1: TBitBtn;
27: Edit5: TEdit;
28: Label7: TLabel;
29: procedure FormActivate(Sender: TObject);
30: procedure ListBox2Click(Sender: TObject);
31: procedure ListBox1Click(Sender: TObject);
32: procedure BitBtn1Click(Sender: TObject);
33: procedure FormClose(Sender: TObject; var Action: TCloseAction);
34: private
35: { Private declarations }
36: public
37: procedure bersih;
38: { Public declarations }
39: end;
40:
41: var
42: Form_DataPeminjaman: TForm_DataPeminjaman;
43:
44: implementation
45:
46: uses unit2;
47:
48: {$R *.dfm}
49:
50: procedure TForm_DataPeminjaman.bersih;
51: begin
52: edit1.Clear;
53: edit2.Clear;
54: edit3.Clear;
55: edit4.Clear;
56: edit5.Clear;
57: end;
58:
59: procedure TForm_DataPeminjaman.FormActivate(Sender: TObject);
60: begin
61: listbox1.Clear;
62: listbox2.Clear;
63: bersih;
64:
65: Query.Connection := Form_Utama.Koneksi;
66: Query.SQL.Add('select id_anggota from tabel_peminjaman group by id_anggota order by
id_anggota asc;');
67: Query.Active := true;
68:
69: if Query.Eof then
70: begin
71: MessageDlg('Data masih kosong!',mtInformation,[mbOk],0);
72: end
73: else
74: begin
75: while not Query.Eof do
76: begin
77: listbox1.Items.Add(Query['id_anggota']);
78: Query.Next;
79: end;
80: end;
81:
82: Query.Active := false;
83: Query.SQL.Clear;
84: end;
85:
86: procedure TForm_DataPeminjaman.ListBox2Click(Sender: TObject);
87: var
88: i,j: integer;
89: begin
90: i := listbox2.ItemIndex;
91: if i < 0 then
92: exit;
93: j := listbox1.ItemIndex;
94: bersih;
95: Query.SQL.Add('select judul from tabel_buku where kd_buku="' + listbox2.Items[i] +
'";');
96: Query.Active := true;
97:
98: edit1.Text := Query['judul'];
99:
100: Query.Active := false;
101: Query.SQL.Clear;
102:
103: Query.SQL.Add('select tgl_pinjam,tgl_kembali,status,denda from tabel_peminjaman where
id_anggota="' + listbox1.Items[j] + '" and kd_buku="' + listbox2.Items[i] + '";');
104: Query.Active := true;
105:
106: edit2.Text := Query['tgl_pinjam'];
107: edit3.Text := Query['tgl_kembali'];
108: if (Query['status'] = 0) then
109: edit4.Text := 'Dikembalikan'
110: else if (Query['status'] = 1) then
111: edit4.Text := 'Dipinjam'
112: else
113: edit4.Text := 'Hilang';
114: edit5.Text := Query['denda'];
115:
116: Query.Active := false;
117: Query.SQL.Clear;
118: end;
119:
120: procedure TForm_DataPeminjaman.ListBox1Click(Sender: TObject);
121: var
122: i: integer;
123: begin
124: i := listbox1.ItemIndex;
125: if i < 0 then
126: exit;
127: listbox2.Clear;
128: bersih;
129: Query.SQL.Add('select kd_buku from tabel_peminjaman where id_anggota="' +
listbox1.Items[i] + '";');
130: Query.Active := true;
131:
132: while not Query.Eof do
133: begin
134: listbox2.Items.Add(Query['kd_buku']);
135: Query.Next;
136: end;
137:
138: Query.Active := false;
139: Query.SQL.Clear;
140: end;
141:
142: procedure TForm_DataPeminjaman.BitBtn1Click(Sender: TObject);
143: begin
144: close;
145: end;
146:
147: procedure TForm_DataPeminjaman.FormClose(Sender: TObject;
148: var Action: TCloseAction);
149: begin
150: Form_Utama.Panel1.Show;
151: end;
152:
153: end.

Comments