Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, Grids, StdCtrls;
- type
- TForm1 = class(TForm)
- GroupBox1: TGroupBox;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- Label5: TLabel;
- Label6: TLabel;
- ComboBox1: TComboBox;
- Edit1: TEdit;
- Edit2: TEdit;
- Edit3: TEdit;
- Edit4: TEdit;
- Edit5: TEdit;
- Button1: TButton;
- StringGrid1: TStringGrid;
- Button2: TButton;
- Button3: TButton;
- Label7: TLabel;
- Label8: TLabel;
- Label9: TLabel;
- Edit6: TEdit;
- Edit7: TEdit;
- Edit8: TEdit;
- procedure FormCreate(Sender: TObject);
- procedure ComboBox1Click(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- procedure bersih;
- procedure hitung;
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- procedure TForm1.bersih;
- begin
- Edit1.Clear;
- Edit2.Clear;
- Edit3.Clear;
- Edit4.Clear;
- Edit5.Clear;
- Edit6.Clear;
- Edit7.Clear;
- Edit8.Clear;
- ComboBox1.Text:='';
- StringGrid1.RowCount:=1;
- end;
- procedure TForm1.hitung;
- var i,t,D:Integer;
- begin
- With StringGrid1 Do Begin
- t:=0;
- D:=0;
- for i := 1 to RowCount - 1 do begin
- Cells[0,i]:=IntToStr(i);
- t:=t + StrToInt(Cells[6,i]);
- D:=D + StrToInt(Cells[7,i]);
- end;
- Edit6.Text:=IntToStr(t);
- Edit7.Text:=IntToStr(D);
- Edit8.Text:=CurrToStr(StrToCurr(Edit6.Text)-StrToCurr(Edit7.Text));
- End;
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- if Length(Edit5.Text)=0 then begin
- Application.MessageBox('Jumlah Belum Benar','Cek Pengisian Jumlah', MB_ICONWARNING);
- Edit5.SetFocus;
- EXIT;
- end;
- if StrToInt(Edit5.Text)<=0 then begin
- Application.MessageBox('Jumlah Belum Benar','Cek Pengisian Jumlah', MB_ICONWARNING);
- Edit5.SetFocus;
- EXIT;
- end;
- With StringGrid1 Do Begin
- RowCount:= RowCount+ 1;
- FixedCols:=1;
- FixedRows:=1;
- Cells[1,RowCount - 1]:=ComboBox1.Text;
- Cells[2,RowCount - 1]:=Edit1.Text;
- Cells[3,RowCount - 1]:=Edit2.Text;
- Cells[4,RowCount - 1]:=Edit3.Text;
- Cells[5,RowCount - 1]:=Edit5.Text;
- Cells[6,RowCount - 1]:=CurrToStr(StrToCurr(Edit3.Text)*StrToCurr(Edit5.Text));
- Cells[7,RowCount - 1]:=CurrToStr(((StrToCurr(Edit3.Text) * StrToCurr(Edit4.Text))/100) * StrToInt(Edit5.Text));
- hitung;
- End;
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- Bersih;
- end;
- procedure TForm1.Button3Click(Sender: TObject);
- begin
- Close;
- end;
- procedure TForm1.ComboBox1Click(Sender: TObject);
- begin
- if ComboBox1.Text='BRG01' then begin
- Edit1.Text:='Nasi Goreng';
- Edit2.Text:='Porsi';
- Edit3.Text:='6000';
- Edit4.Text:='5';
- Edit5.SetFocus;
- end
- else if ComboBox1.Text='BRG02' then begin
- Edit1.Text:='Mie Goreng';
- Edit2.Text:='Porsi';
- Edit3.Text:='6000';
- Edit4.Text:='10';
- Edit5.SetFocus;
- end
- else if ComboBox1.Text='BRG03' then begin
- Edit1.Text:='Bakso';
- Edit2.Text:='Porsi';
- Edit3.Text:='8000';
- Edit4.Text:='2';
- Edit5.SetFocus;
- end
- else if ComboBox1.Text='BRG04' then begin
- Edit1.Text:='Pangsit';
- Edit2.Text:='Porsi';
- Edit3.Text:='8000';
- Edit4.Text:='0';
- Edit5.SetFocus;
- end
- else if ComboBox1.Text='BRG05' then begin
- Edit1.Text:='Soto';
- Edit2.Text:='Porsi';
- Edit3.Text:='9000';
- Edit4.Text:='3';
- Edit5.SetFocus;
- end;
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- bersih;
- ComboBox1.Clear;
- ComboBox1.Items.Add('BRG01');
- ComboBox1.Items.Add('BRG02');
- ComboBox1.Items.Add('BRG03');
- ComboBox1.Items.Add('BRG04');
- ComboBox1.Items.Add('BRG05');
- With StringGrid1 Do Begin
- RowCount:=1;
- ColCount:=8;
- Cells[0,0]:='NO';
- Cells[1,0]:='KODE';
- Cells[2,0]:='BARANG';
- Cells[3,0]:='SATUAN';
- Cells[4,0]:='HARGA';
- Cells[5,0]:='JUMLAH';
- Cells[6,0]:='TOTAL';
- Cells[7,0]:='DISKON';
- ColWidths[0]:=30;
- ColWidths[1]:=80;
- ColWidths[2]:=100;
- ColWidths[3]:=80;
- ColWidths[4]:=80;
- ColWidths[5]:=80;
- ColWidths[6]:=80;
- ColWidths[7]:=80;
- End;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement