Contoh Aplikasi Data Siswa Delphi 7
Contoh Aplikasi Data Siswa Delphi 7
---------------------------------------------------
unit Siswa;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, DB, DBTables, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
GroupBox1: TGroupBox;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
GroupBox2: TGroupBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
GroupBox3: TGroupBox;
GroupBox4: TGroupBox;
GroupBox5: TGroupBox;
Edit7: TEdit;
Edit8: TEdit;
Label7: TLabel;
Label8: TLabel;
Button6: TButton;
DataSource1: TDataSource;
Table1: TTable;
DBGrid1: TDBGrid;
Edit6: TEdit;
Edit1: TEdit;
Label9: TLabel;
Button7: TButton;
procedure Button1Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure Edit6Change(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
table1.Append;
table1 ['NIP'] := Edit1.Text;
table1 ['Nama'] := edit2.Text;
table1 ['Tanggal_lahir'] := edit4.Text;
table1 ['alamat'] := edit3.Text;
table1 ['No_telp'] := edit5.Text;
table1.Post ;
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
Edit4.Text:='';
Edit5.Text:='';
Edit1.SetFocus;
label9.Caption:='';
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
begin
table1.IndexName := 'tanggal_idx';
table1.SetRangeStart;
Table1.FieldByName('Tanggal_lahir').AsString := (edit7.Text);
table1.SetRangeEnd;
Table1.FieldByName('Tanggal_lahir').AsString := (edit8.Text);
table1.ApplyRange;
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Edit1Change(Sender: TObject);
VAR ADA:BOOLEAN;
begin
IF LENGTH (Edit1.Text) < 5 THEN
EXIT;
ADA:=Table1.FindKey([Edit1.Text]);
IF ADA THEN
BEGIN
Edit1.Focused;
Edit1.SelectAll;
edit2.Text:=Table1['Nama'];
edit4.Text:=Table1['Tanggal_lahir'];
edit3.Text:=Table1['alamat'];
edit5.Text:=Table1['no_telp'];
Label9.Caption:='Maaf data sudah terdaftar';
Exit;
end;
end;
procedure TForm1.Edit6Change(Sender: TObject);
begin
table1.IndexName:= 'Nama_idx';
table1.FindNearest([Edit6.Text]);
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
if messagedlg('yakin akan dihapus??', mtconfirmation,
[mbyes,mbno],0)=mryes then
table1.Delete;
label9.Caption:='';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
table1.Edit;
Edit1.Focused;
Edit1.SelectAll;
Edit1.Text:=table1['NIP'];
Edit2.Text:=Table1['Nama'];
Edit3.Text:=Table1['Tanggal_lahir'];
Edit4.Text:=Table1['Alamat'];
Edit5.Text:=Table1['No_Telp'];
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
table1.Edit;
table1['NIP'] := Edit1.Text;
table1['Nama'] := Edit2.Text ;
table1['Tanggal_Lahir' ] := Edit3.Text;
table1['Alamat'] := Edit4.Text;
table1['No_Telp']:= Edit5.Text;
table1.Post;
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
Edit4.Text:='';
Edit5.Text:='';
edit1.SetFocus;
label9.Caption:='';
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
if messagedlg('yakin akan dibatalkan??', mtconfirmation,
[mbyes,mbno],0)=mryes then
Table1.Cancel;
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
Edit4.Text:='';
Edit5.Text:='';
edit1.SetFocus;
end;
end.
------------------------------------------------------------------------------------------------------------------
transaksi
--------------------------------------------------------------------------------------------------------------------
unit transaksi;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, DB, DBTables, StdCtrls, ComCtrls;
type
TForm2 = class(TForm)
Label1: TLabel;
GroupBox1: TGroupBox;
Label2: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit2: TEdit;
Edit3: TEdit;
Edit5: TEdit;
Edit1: TEdit;
GroupBox2: TGroupBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
DataSource1: TDataSource;
Table1: TTable;
DBGrid1: TDBGrid;
aa: TLabel;
Label3: TLabel;
Edit6: TEdit;
Table2: TTable;
Label7: TLabel;
Edit7: TEdit;
Button6: TButton;
DateTimePicker1: TDateTimePicker;
procedure Button1Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
table1.Append;
table1 ['no_pembayaran'] := edit7.Text;
table1 ['NIS'] := Edit1.Text;
table1 ['Nama'] := edit2.Text;
table1 ['Tanggal_Bayar'] := datetimepicker1.Date;
table1 ['alamat'] := edit3.Text;
table1 ['No_telp'] := edit5.Text;
table1 ['jumlah'] := edit6.Text;
table1.Post ;
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
Edit5.Text:='';
edit6.Text:='';
edit7.Text:='';
Edit7.Text:=Edit7.Text+inttostr(table1.RecordCount+1);
edit1.SetFocus;
Edit1.SetFocus;
end;
procedure TForm2.Button5Click(Sender: TObject);
begin
close;
end;
procedure TForm2.Button4Click(Sender: TObject);
begin
if messagedlg('yakin akan dihapus??', mtconfirmation,
[mbyes,mbno],0)=mryes then
table1.Delete;
end;
procedure TForm2.Edit1Change(Sender: TObject);
VAR ADA:BOOLEAN;
begin
IF LENGTH (Edit1.Text) < 5 THEN
EXIT;
ADA:=Table2.FindKey([Edit1.Text]);
IF ADA THEN
BEGIN
Edit1.Focused;
Edit1.SelectAll;
edit2.Text:=Table2['Nama'];
edit3.Text:=Table2['alamat'];
edit5.Text:=Table2['no_telp'];
end;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
table1.Edit;
Edit7.Focused;
Edit7.SelectAll;
Edit1.Text:=Table1['NIS'];
Edit2.Text:=Table1['Nama'];
datetimepicker1.Date:=Table1['Tanggal_Bayar'];
Edit3.Text:=Table1['Alamat'];
Edit5.Text:=Table1['No_Telp'];
edit6.Text:=Table1 ['jumlah'];
edit7.Text:= table1['no_pembayaran'];
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
table1.Edit;
table1['NIS'] := Edit1.Text;
table1['Nama'] := Edit2.Text ;
table1['Tanggal_Bayar' ] := datetimepicker1.Date;
table1['Alamat'] := Edit3.Text;
table1['No_Telp']:= Edit5.Text;
table1['jumlah']:= edit6.Text;
table1['no_pembayaran']:= edit7.Text;
table1.Post;
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
Edit5.Text:='';
edit6.Text:='';
edit7.Text:='' ;
edit7.SetFocus;
end;
procedure TForm2.Button6Click(Sender: TObject);
begin
if messagedlg('yakin akan dibatalkan??', mtconfirmation,
[mbyes,mbno],0)=mryes then
Table1.Cancel;
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
Edit5.Text:='';
edit6.Text:='';
edit7.Text:='' ;
edit7.SetFocus;
end;
end.
0 komentar:
Post a Comment