LATIHAN PEMROGRAMAN DENGAN BORLAND DELPHI 7
Berikut ini Contoh Soal Delphi beserta jawabanya:
======================================
1. Buatlah desain tabel database dari "database dekstop" delphi seperti berikut ini :
2. Desain Form
end.
======================================
1. Buatlah desain tabel database dari "database dekstop" delphi seperti berikut ini :
2. Desain Form
3. Tampilan Form ketika dijalankan
4. Kemudian isikan kode programnya seperti yang ada dibawah ini :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, StdCtrls, Grids, DBGrids, DB, DBTables;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
ComboBox1: TComboBox;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Table1: TTable;
DataSource1: TDataSource;
Button1: TButton;
Button2: TButton;
Button3: TButton;
DBGrid1: TDBGrid;
procedure Button3Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure Edit3Change(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure
TForm1.Button3Click(Sender: TObject);
begin
close;
end;
procedure
TForm1.FormActivate(Sender: TObject);
begin
combobox1.Text:='';
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
edit4.Text:='';
edit5.Text:='';
edit6.Text:='';
edit1.Enabled:=False;
edit2.Enabled:=False;
edit3.Enabled:=true;
edit4.Enabled:=False;
edit5.Enabled:=False;
edit6.Enabled:=False;
Combobox1.enabled:=true;
button1.Enabled:=true;
button2.Enabled:=true;
button3.Enabled:=true;
end;
procedure
TForm1.ComboBox1Change(Sender: TObject);
var hasil : string [20];
hg :integer;
begin
if combobox1.Text='A' then
begin
edit1.Text:='ANTALGIN';
hg:=5000;
str(hg:20,hasil);
edit2.Text:=hasil;
end;
if combobox1.Text='B' then
begin
edit1.Text:='BODREX';
hg:=3000;
str(hg:20,hasil);
edit2.Text:=hasil;
end;
if combobox1.Text='C' then
begin
edit1.Text:='KONIDIN';
hg:=2000;
str(hg:20,hasil);
edit2.Text:=hasil;
end;
edit3.setfocus;
end;
procedure
TForm1.Edit3Change(Sender: TObject);
var hasil : string [20];
a,b,hr,disc,tb : single;
kode : integer;
begin
val(edit2.Text,a,kode);
val(edit3.Text,b,kode);
hr:=a*b;
str(hr:20:0,hasil);
edit4.Text:=hasil;
if (hr > 10000) then
disc:= (10/100)*hr
else
disc:=0*hr;
str(disc:20:0,hasil);
edit5.Text:=hasil;
tb:=hr-disc;
str(tb:20:0,hasil);
edit6.Text:=hasil;
end;
procedure
TForm1.Button2Click(Sender: TObject);
begin
combobox1.Text:='';
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
edit4.Text:='';
edit5.Text:='';
edit6.Text:='';
combobox1.SetFocus;
end;
procedure
TForm1.Button1Click(Sender: TObject);
begin
table1.Append;
table1['KD_OBAT']:=combobox1.Text;
table1['NAMA_OBAT']:=edit1.Text;
table1['HARGA']:=edit2.Text;
table1['JUMLAH']:=edit3.Text;
table1['HARGA_RESMI']:=edit4.Text;
table1['DISKON']:=edit5.Text;
table1['TOTAL_BAYAR']:=edit6.Text;
table1.Post;
end;
0 Response to "LATIHAN PEMROGRAMAN DENGAN BORLAND DELPHI 7"
Post a Comment