Monday, 25 April 2011

Delphi Part II

Listing Delphi

Checkbox:

begin if checkbox1.checked=true then
oli.text:='20000'
else
oli.clear;
end;

utk checkbox berikutnya listingnya sama.

nopolkeypress:

begin
if key=#13 then
begin
if sender=nopol then nama.setfocus;
if sender=nama then checkbox1.setfocus;
end;

Proses:

var a,b,c,d:currency;
begin
if checkbox1.checked=true then
a:strtocurr(oli.text)
else
a:=0
if checkbox2.checked=true then
b:strtocurr(service.text)
else
b:=0
if checkbox3.checked=true then
c:strtocurr(sparepart.text)
else
c:=0
d:=a+b+c;
total.text:=currtostr(d);
end;

Keluar:

begin
if(application.messagebox('Mau Keluar?','info',mb_yesno+32)=IDyes) then
application.terminate;
end;

Bersih:

begin
nopol.clear;
nama.clear;
oli.clear;
service.clear;
total.clear;
checkbox1.checked:=false;
checkbox2.checked:=false;
checkbox3.checked:=false;
nopol.setfocus;
end;

Cara Menambahkan Combobox:
Klik form>isi listing:
jabatan.items.add('Direktur');
jabatan.items.add('Manager');
jabatan.items.add('Karyawan');

Listing Combobox:
properties>events>onclick(2x)

if jabatan.text='Direktur' then
begin
gapok.text:='7000000';
fasilitas.text='Rumah';
end
else
if jabatan.text='Manager' then
begin
gapok.text:='5000000';
fasilitas.text='Mobil';
end
else
if jabatan.text='Karyawan' then
begin
gapok.text:='3000000';
fasilitas.text='Motor';
end
else
gapok.text:='0';
end;
end.


Listing Radio Button:


ketikkan listing di tengah" form:

var
form1:Tform1
a,hasil:real;
implementation
{$R*.dfm}

lalu Listingnya:

begin
if tunai.checked=true then
a:=strtofloat(harga.text);
hasil:=a-(0.1*a);
satuan.text:=floattostr(hasil);
end;

end.

Total:

properties>event>onkeypress>doubleklik>isi listing

begin
if key=#13 then
total.text:=floattostr(strtofloat(harga.text)*strtofloat(jumlah,text));
end;

Sunday, 24 April 2011

Pemrograman C++

Latihan Percabangan:


#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<string.h>
main()
{
char no,menu[20],nm[20];
int hrg,jml,ppn,byr;
clrscr();
cout<<"DAFTAR MENU RUMAH MAKAN"<<endl;
cout<<"1.Nasi Goreng"<<endl;
cout<<"1.Nasi Rames"<<endl;
cout<<"1.Nasi Soto"<<endl;
cout<<"1.Nasi Gudeg"<<endl;
cout<<"Nama Pembeli=";cin>>nm;
cout<<"Pilihan Anda Adalah[1|2|3|4]=";cin>>n0;
cout<<"Jumlah Porsi =";cin>>jml;
cout<<endl;
cout<<"\tSTRUK PEMBAYARAN"<<endl;
cout<<"#################"<<endl;
cout<'Nama Pembeli ="<<nm<<endl;

if(no=='1')
{
strcpy(menu,"Nasi Goreng");
hrg=4500;}

else if(no=='2')
{
strcpy(menu,"Nasi Rames");
hrg=3500;}
else if(no=='3')
{
strcpy(menu,"Nasi Soto");
hrg=5000;}

else
{
strcpy(menu,"Nasi Gudeg");
hrg=6000;}

cout<<"Menu Pilihan="<<menu<<endl;
cout<<"Jumlah Porsi="<<jml<<endl;
ppn=0.1*hrg;
cout<<"PPN 10%="<<ppn<<ensl;
byr=(hrg*jml)+ppn;
cout<<"Jumlah Bayar="<<byr<<endl;
cout<<"*****************<<endl;
getch();
}

Monday, 11 April 2011

Aplikasi Sistem Penggajian Karyawan Menggunakan Borland Delhi.

 Listing Program:
unit tugas;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label8: TLabel;
    nip: TEdit;
    nama: TEdit;
    gapok: TEdit;
    fasilitas: TEdit;
    jabatan: TComboBox;
    total: TEdit;
    bersih: TButton;
    keluar: TButton;
    GroupBox1: TGroupBox;
    honorer: TRadioButton;
    tetap: TRadioButton;
    procedure FormCreate(Sender: TObject);
    procedure jabatanClick(Sender: TObject);
    procedure bersihClick(Sender: TObject);
    procedure keluarClick(Sender: TObject);
    procedure honorerClick(Sender: TObject);
    procedure tetapClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
 Form1: TForm1;
a,hasil:real;
implementation
{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
jabatan.Items.add('Direktur');
jabatan.Items.add('Manager');
jabatan.Items.add('Karyawan');
end;
procedure TForm1.jabatanClick(Sender: TObject);
begin
if jabatan.Text='Direktur' then
begin
gapok.text:='10000000';
fasilitas.Text:='Rumah'
end
else
if jabatan.Text='Manager' then
begin
gapok.text:='7000000';
fasilitas.Text:='Mobil'
end
else
if jabatan.Text='Karyawan' then
begin
gapok.text:='5000000';
fasilitas.Text:='Motor'
end
else
gapok.Text:='0';
end;

procedure TForm1.bersihClick(Sender: TObject);
begin
nip.Text:='';
nama.Text:='';
jabatan.Text:='';
gapok.Text:='';
fasilitas.text:='';
total.Text:='';
end;

procedure TForm1.keluarClick(Sender: TObject);
begin
close
end;

procedure TForm1.honorerClick(Sender: TObject);
begin
if honorer.checked=true then
a:=strtofloat(gapok.text);
hasil:=a-(0.1*a);
total.text:=floattostr(hasil);
end;

procedure TForm1.tetapClick(Sender: TObject);
begin
if honorer.checked=true then
a:=strtofloat(gapok.text);
hasil:=a+(0.1*a);
total.text:=floattostr(hasil);
end;

end.