CONTOH PROGRAM DELPHI
















unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, DB, DBTables, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    GroupBox1: TGroupBox;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    DataSource1: TDataSource;
    Table1: TTable;
    DBGrid1: TDBGrid;
    procedure Edit4Change(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Edit4Change(Sender: TObject);
begin
edit5.Text := inttostr(strtoint(edit4.Text)*strtoint(edit3.Text));
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
table1.Append ;
table1['kode']:=edit1.Text ;
table1['nama_brg']:=edit2.Text ;
table1['harga_sat']:=edit3.Text ;
table1['jum_beli']:=edit4.Text ;
table1['total']:=edit5.Text ;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if(application.MessageBox('Yakin akan Menghapus Data ini ?','KONFIRMASI', mb_yesno or mb_iconwarning)=idyes) then table1.Delete;
end;

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

procedure TForm1.Button3Click(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
edit3.Text:='0';
edit4.Text:='0';
edit5.Text:='0';
edit1.SetFocus;
end;

end.

0 تعليقات

إرسال تعليق

Post a Comment (0)

أحدث أقدم