+++ ARJUNA +++: coding delphi sederhana
SELAMAT DATANG DI BLOGKU " ARJUNA"

tulisan arjun

Kamis, 19 April 2012

coding delphi sederhana


buat temen temen yang butuh sourche code delphi tentang kereta 


unit kereta;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    ejam: TEdit;
    hrg: TEdit;
    tggl: TEdit;
    jml: TEdit;
    ttl: TEdit;
    ubay: TEdit;
    ukem: TEdit;
    enmk: TEdit;
    tlp: TEdit;
    almat: TEdit;
    nmp: TEdit;
    kd: TComboBox;
    kls: TComboBox;
    odw: TRadioButton;
    oan: TRadioButton;
    bbersih: TButton;
    bkeluar: TButton;
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure bkeluarClick(Sender: TObject);
    procedure bbersihClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure kdClick(Sender: TObject);
    procedure klsClick(Sender: TObject);
    procedure jmlKeyPress(Sender: TObject; var Key: Char);
    procedure ubayKeyPress(Sender: TObject; var Key: Char);
    procedure nmpKeyPress(Sender: TObject; var Key: Char);
    procedure almatKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure bersih;
    procedure aktif;
    procedure nonaktif;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
procedure tform1.bersih ;
begin
nmp.Text :='';
almat.Text :='';
tlp.Text :='';
kd.Text :='=Pilih=';
enmk.Text :='';
odw.Checked :=false;
oan.Checked :=false;
kls.Text :='=Pilih=';
hrg.Text :='0';
jml.Text :='0';
ttl.Text :='0';
ubay.Text :='0';
ukem.Text :='0';
end;

procedure tform1.aktif ;
begin
nmp.Enabled :=true;
almat.Enabled :=true;
tlp.Enabled :=true;
kd.Enabled :=true;
enmk.Enabled :=true;
odw.Enabled :=true;
oan.Enabled :=true;
kls.Enabled :=true;
hrg.Enabled :=true;
jml.Enabled :=true;
ttl.Enabled :=true;
ubay.Enabled :=true;
ukem.Enabled :=true;
end;

procedure tform1.nonaktif ;
begin
nmp.Enabled :=false;
almat.Enabled :=false;
tlp.Enabled :=false;
kd.Enabled :=false;
enmk.Enabled :=false;
odw.Enabled :=false;
oan.Enabled :=false;
kls.Enabled :=false;
hrg.Enabled :=false;
jml.Enabled :=false;
ttl.Enabled :=false;
ubay.Enabled :=false;
ukem.Enabled :=false;
end;


procedure TForm1.Timer1Timer(Sender: TObject);
begin
ejam.Text := timetostr(now);
tggl.Text := datetostr(now);
ejam.Enabled :=false;
tggl.Enabled :=false;
end;

procedure TForm1.bkeluarClick(Sender: TObject);
begin
if (application.MessageBox('Anda Yakin Ingin Keluar?','Pemberitahuan',MB_yesno)=idyes)then
close
end;

procedure TForm1.bbersihClick(Sender: TObject);
begin
bersih;
aktif;
nmp.SetFocus;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
kd.Items.Add('SN');
kd.Items.Add('PT');
kd.Items.Add('JK');
kls.Items.Add('Bisnis');
kls.Items.Add('Eksekutif');
kls.Items.Add('Ekonomi');
nonaktif;
end;

procedure TForm1.kdClick(Sender: TObject);
begin
if kd.ItemIndex =0 then
enmk.Text :='Senja Utama'
else if kd.ItemIndex =1 then
enmk.Text :='Parayangan'
else
enmk.Text :='Jakarta Kota';
end;

procedure TForm1.klsClick(Sender: TObject);
begin
if odw.Checked = true then
  begin
    if kls.ItemIndex =0 then
    begin
    hrg.Text :='100000';
    jml.Text :='';
    jml.SetFocus;
    end
    else if kls.ItemIndex =1 then
    begin
    hrg.Text :='80000';
    jml.Text :='';
    jml.SetFocus;
    end
    else
    begin
    hrg.Text :='50000';
    jml.Text :='';
    jml.SetFocus;
    end
  end
else
  begin
    if kls.ItemIndex =0 then
    begin
    hrg.Text :='75000';
    jml.Text :='';
    jml.SetFocus;
    end
    else if kls.ItemIndex =1 then
    begin
    hrg.Text :='45000';
    jml.Text :='';
    jml.SetFocus;
    end
    else
    begin
    hrg.Text :='25000';
    jml.Text :='';
    jml.SetFocus;
    end
  end
end;

procedure TForm1.jmlKeyPress(Sender: TObject; var Key: Char);
begin
if (key=#13) then
begin
ttl.Text :=floattostr (strtofloat(jml.Text)*strtofloat(hrg.Text));
ubay.Text :='';
ubay.SetFocus ;
end
end;

procedure TForm1.ubayKeyPress(Sender: TObject; var Key: Char);
begin
if (key=#13) then
  begin
  if strtofloat(ubay.Text)<strtofloat(ttl.Text) then
  begin
  application.MessageBox('Uang Anda Kurang!!!','Info');
  ubay.Text :='';
  end
  else
  ukem.Text := floattostr (strtofloat(ubay.Text)-strtofloat(ttl.Text));
  end
end;

procedure TForm1.nmpKeyPress(Sender: TObject; var Key: Char);
begin
if (key=#13) then
almat.SetFocus;
end;

procedure TForm1.almatKeyPress(Sender: TObject; var Key: Char);
begin
if (key=#13) then
tlp.SetFocus;
end;

end.

Tidak ada komentar:

Posting Komentar