Latihan Delphi 6

A. Tampilan:

B. Source Code

Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, DB, ADODB, StdCtrls, Mask, Grids, DBGrids;

type

TForm1 = class(TForm)

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

txtNIS: TEdit;

txtNama: TEdit;

txtAlamat: TEdit;

meTglLhr: TMaskEdit;

txtOrtu: TEdit;

rbLaki: TRadioButton;

rbPerempuan: TRadioButton;

Label7: TLabel;

btnSimpan: TButton;

btnBersihkan: TButton;

btnKeluar: TButton;

ADOConnection1: TADOConnection;

adoSimpan: TADOTable;

DataSource1: TDataSource;

DBGrid1: TDBGrid;

procedure btnKeluarClick(Sender: TObject);

procedure btnBersihkanClick(Sender: TObject);

procedure btnSimpanClick(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btnKeluarClick(Sender: TObject);

begin

close;

end;

procedure TForm1.btnBersihkanClick(Sender: TObject);

begin

txtNIS.Clear;

txtNama.Clear;

meTglLhr.Clear;

txtAlamat.Clear;

txtOrtu.Clear;

end;

procedure TForm1.btnSimpanClick(Sender: TObject);

begin

with adoSimpan do

begin

insert;

FieldByName(‘NIS’).AsString:=txtNis.Text;

FieldByName(‘Nama’).AsString:=txtNama.Text;

FieldByName(‘Tgl_lahir’).AsDateTime:=StrToDate(meTglLhr.text);

FieldByName(‘Alamat’).AsString:=txtAlamat.Text;

if rbLaki.Checked=True and rbPerempuan.Checked=false then

FieldByName(‘Jenis_Kelamin’).Asstring:=’L’

else if rbPerempuan.Checked=true and rbLaki.Checked=false then

FieldByName(‘Jenis_Kelamin’).AsString:=’P’;

FieldByName(‘Ortu’).AsString:=txtOrtu.Text;

post;

end;

end;

end.

D.Tutorialnya ada disini. selamat coba!!!!

%d blogger menyukai ini: