0% found this document useful (0 votes)
106 views3 pages

Source Code Delphi

The document contains code for creating a student registration form application in Delphi. It includes code for buttons to save, edit, delete data and clear form fields. It also includes code to populate combo boxes with course and religion options, and code to check if a student ID already exists when entering a new ID. When an existing ID is found, it will populate the form fields with the student's data.

Uploaded by

any more
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views3 pages

Source Code Delphi

The document contains code for creating a student registration form application in Delphi. It includes code for buttons to save, edit, delete data and clear form fields. It also includes code to populate combo boxes with course and religion options, and code to check if a student ID already exists when entering a new ID. When an existing ID is found, it will populate the form fields with the student's data.

Uploaded by

any more
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

Button Simpan (Klik 2 x button Simpan diantara Begin dan End ketik koding
erikut ini) :

With TMahasiswa do
begin
Append;
FieldByName('Nim').AsString:=Edit1.Text;
FieldByName('Nama').AsString:=Edit2.Text;
FieldByName('Jurusan').AsString:=ComboBox1.Text;
FieldByName('Agama').AsString:=ComboBox2.Text;
FieldByName('Alamat').AsString:=Edit3.Text;
FieldByName('Kota').AsString:=Edit4.Text;
FieldByName('Telp').AsString:=Edit5.Text;
Post;
end;

2. Button Edit ((Klik 2 x button Simpan diantara Begin dan End ketik koding erikut
ini) :

With TMahasiswa do
begin
Edit;
FieldByName('Nim').AsString:=Edit1.Text;
FieldByName('Nama').AsString:=Edit2.Text;
FieldByName('Jurusan').AsString:=ComboBox1.Text;
FieldByName('Agama').AsString:=ComboBox2.Text;
FieldByName('Alamat').AsString:=Edit3.Text;
FieldByName('Kota').AsString:=Edit4.Text;
FieldByName('Telp').AsString:=Edit5.Text;
Post;
end;
TMahasiswa.Refresh;

3. Button Hapus

procedure TFMahasiswa.btnHapusClick(Sender: TObject);


var
d : pChar;
s : Array[0..255] of Char;
begin
d := StrPCopy(s, Format('Anda yakin ingin menghapus NIM %s ??',
[TMahasiswa.Fields[0].AsString]));
if MessageBox(Self.Handle, d, 'Peringatan', Mb_YesNo or mb_iconError) = IDYes
then
TMahasiswa.Delete
end;
4. Button Batal (klik 2 x button batal kemudian ketik koding berikut ini dinatara
begin dan end).

bersih;
Edit1.SetFocus;
btnSImpan.Enabled:=false;
btnEdit.Enabled:=false;
btnHapus.Enabled:=false;

5. Membuat prosedur Bersih

Procedure TFMahasiswa.bersih;
begin
Edit1.Text:='';
Edit2.Text:='';
ComboBox1.Text:='Pilih Jurusan';
ComboBox2.Text:='Pilih Agama';
Edit3.Text:='';
Edit4.Text:='';
Edit5.Text:='';
end;

6. Event Form (OnActive)

Edit1.Setfocus;

7. Event Form (OnCreate)

//enable false
btnSImpan.Enabled:=false;
btnEdit.Enabled:=false;
btnHapus.Enabled:=false;

Edit1.Text:='';
Edit2.Text:='';
ComboBox1.Text:='Pilih Jurusan';
ComboBox2.Text:='Pilih Agama';
Edit3.Text:='';
Edit4.Text:='';
Edit5.Text:='';

//membuat pilihan jurusan


ComboBox1.Items.Clear;
ComboBox1.Items.Append('Teknik Informatika');
ComboBox1.Items.Append('Sistem Informasi');

//membuat pilihan agama


ComboBox2.Items.Clear;
ComboBox2.Items.Append('Islam');
ComboBox2.Items.Append('Hindu');
ComboBox2.Items.Append('Budha');
ComboBox2.Items.Append('Kristen Katolik');
ComboBox2.Items.Append('Kristen Protestan');
//Focus

8. Event (OnChange) Edit1 /NIM (Klik 2 x Edit1 dan ketik berikut ini :

procedure TFMahasiswa.Edit1Change(Sender: TObject);


Var Ada : Boolean;
begin
if Length(Edit1.Text) < 10 then exit;
ada := TMahasiswa.FindKey([Edit1.Text]);
if ada then
begin
MessageDlg('Data sudah terekam',mtWarning,[mbOk],0);
Edit1.SelectAll;
btnEdit.Enabled:=true;
btnHapus.Enabled:=true;
btnSImpan.Enabled:=false;
Edit2.Text:=TMahasiswa['Nama'];
ComboBox1.Text:=TMahasiswa['Jurusan'];
ComboBox2.Text:=TMahasiswa['Agama'];
Edit3.Text:=TMahasiswa['Alamat'];
Edit4.Text:=TMahasiswa['Kota'];
Edit5.Text:=TMahasiswa['Telp'];
Exit;
Edit1.SetFocus;
end;
Edit2.Text:='';
ComboBox1.Text:='';
ComboBox2.Text:='';
Edit3.Text:='';
Edit4.Text:='';
Edit5.Text:='';
btnEdit.Enabled:=false;
btnHapus.Enabled:=false;
end;

9. Edit1 (OnKeyPress)
procedure TFMahasiswa.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if not (key=chr(13)) then exit;
Edit2.SetFocus;
btnSImpan.Enabled:=True;
end;

You might also like