Tampilan awal/Form1 dari program ini.
Dibawah ini adalah script untuk form1 yang diatas :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, DB, ADODB, jpeg, ExtCtrls;
type
TFRMUTAMA = class(TForm)
MainMenu1: TMainMenu;
MASTER1: TMenuItem;
MASTERBARANG1: TMenuItem;
USER1: TMenuItem;
ENTRYDATA1: TMenuItem;
RANSAKSIPEMBELIAN1: TMenuItem;
RANSAKSIPENJUALAN1: TMenuItem;
RETURPEMBELIAN1: TMenuItem;
RETURPENJUALAN1: TMenuItem;
REPORT1: TMenuItem;
DAFTARBARANG1: TMenuItem;
DAFTARPEMBELIAN1: TMenuItem;
DAFTARPENJUALAN1: TMenuItem;
LAPORANRETURPEMBELIAN1: TMenuItem;
LAPORANRETURPENJUALAN1: TMenuItem;
LAPORANSTOKBARANG1: TMenuItem;
PERHITUNGANRUGILABA1: TMenuItem;
EXIT1: TMenuItem;
CLOSE1: TMenuItem;
Label1: TLabel;
Label2: TLabel;
con1: TADOConnection;
ADOQuery1: TADOQuery;
img1: TImage;
procedure CLOSE1Click(Sender: TObject);
procedure MASTERBARANG1Click(Sender: TObject);
procedure RANSAKSIPEMBELIAN1Click(Sender: TObject);
procedure USER1Click(Sender: TObject);
procedure RANSAKSIPENJUALAN1Click(Sender: TObject);
procedure RETURPEMBELIAN1Click(Sender: TObject);
procedure RETURPENJUALAN1Click(Sender: TObject);
procedure DAFTARBARANG1Click(Sender: TObject);
procedure DAFTARPEMBELIAN1Click(Sender: TObject);
procedure DAFTARPENJUALAN1Click(Sender: TObject);
procedure LAPORANRETURPEMBELIAN1Click(Sender: TObject);
procedure LAPORANRETURPENJUALAN1Click(Sender: TObject);
procedure LAPORANSTOKBARANG1Click(Sender: TObject);
procedure PERHITUNGANRUGILABA1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FRMUTAMA: TFRMUTAMA;
implementation
uses Unit2, Unit3;
{$R *.dfm}
procedure TFRMUTAMA.CLOSE1Click(Sender: TObject);
begin
close;
end;
procedure TFRMUTAMA.MASTERBARANG1Click(Sender: TObject);
begin
FRMMASTERBARANG.SHOW;
end;
procedure TFRMUTAMA.RANSAKSIPEMBELIAN1Click(Sender: TObject);
begin
frmTransaksiMasuk.show;
end;
procedure TFRMUTAMA.USER1Click(Sender: TObject);
begin
MessageDlg('PROGRAM BELUM SELESAI',mtInformation,MBOKCANCEL,0);
end;
procedure TFRMUTAMA.RANSAKSIPENJUALAN1Click(Sender: TObject);
begin
MessageDlg('PROGRAM BELUM SELESAI',mtInformation,MBOKCANCEL,0);
end;
procedure TFRMUTAMA.RETURPEMBELIAN1Click(Sender: TObject);
begin
MessageDlg('PROGRAM BELUM SELESAI',mtInformation,MBOKCANCEL,0);
end;
procedure TFRMUTAMA.RETURPENJUALAN1Click(Sender: TObject);
begin
MessageDlg('PROGRAM BELUM SELESAI',mtInformation,MBOKCANCEL,0);
end;
procedure TFRMUTAMA.DAFTARBARANG1Click(Sender: TObject);
begin
MessageDlg('PROGRAM BELUM SELESAI',mtInformation,MBOKCANCEL,0);
end;
procedure TFRMUTAMA.DAFTARPEMBELIAN1Click(Sender: TObject);
begin
MessageDlg('PROGRAM BELUM SELESAI',mtInformation,MBOKCANCEL,0);
end;
procedure TFRMUTAMA.DAFTARPENJUALAN1Click(Sender: TObject);
begin
MessageDlg('PROGRAM BELUM SELESAI',mtInformation,MBOKCANCEL,0);
end;
procedure TFRMUTAMA.LAPORANRETURPEMBELIAN1Click(Sender: TObject);
begin
MessageDlg('PROGRAM BELUM SELESAI',mtInformation,MBOKCANCEL,0);
end;
procedure TFRMUTAMA.LAPORANRETURPENJUALAN1Click(Sender: TObject);
begin
MessageDlg('PROGRAM BELUM SELESAI',mtInformation,MBOKCANCEL,0);
end;
procedure TFRMUTAMA.LAPORANSTOKBARANG1Click(Sender: TObject);
begin
MessageDlg('PROGRAM BELUM SELESAI',mtInformation,MBOKCANCEL,0);
end;
procedure TFRMUTAMA.PERHITUNGANRUGILABA1Click(Sender: TObject);
begin
MessageDlg('PROGRAM BELUM SELESAI',mtInformation,MBOKCANCEL,0);
end;
end.
2. Tampilan untuk master barang / form2.
Dibawah ini adalah script untuk form2 yang diatas :
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls, DB, ADODB;
type
TFRMMASTERBARANG = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit1: TEdit;
Edit2: TEdit;
ComboBox1: TComboBox;
Edit3: TEdit;
DBGrid1: TDBGrid;
qry1: TADOQuery;
ds1: TDataSource;
btn1: TButton;
procedure Button2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure ComboBox1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure DBGrid1DblClick(Sender: TObject);
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure REFRES();
end;
var
FRMMASTERBARANG: TFRMMASTERBARANG;
implementation
uses UNIT1;
{$R *.dfm}
procedure TFRMMASTERBARANG.REFRES;
begin
qry1.Close;
qry1.SQL.Text:='SELECT * FROM TBMASTERBARANG';
qry1.Open;
end;
procedure TFRMMASTERBARANG.Button2Click(Sender: TObject);
begin
close;
end;
procedure TFRMMASTERBARANG.FormShow(Sender: TObject);
begin
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
ComboBox1.Text:='';
Edit1.SetFocus;
REFRES;
end;
procedure TFRMMASTERBARANG.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
Edit2.SetFocus;
end;
procedure TFRMMASTERBARANG.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
ComboBox1.SetFocus;
end;
procedure TFRMMASTERBARANG.ComboBox1Click(Sender: TObject);
begin
Edit3.SetFocus;
end;
procedure TFRMMASTERBARANG.Button1Click(Sender: TObject);
var
SBR:TADOQuery;
begin
SBR:=TADOQuery.Create(Self);
SBR.Connection:=FRMUTAMA.con1;
SBR.Close;
SBR.SQL.Text:='INSERT INTO TBMASTERBARANG (KDBARANG,NMBARANG,SATUAN,HARGASATUAN)'+
'VALUES(:VKDBARANG,:VNMBARANG,:VSATUAN,:VHARGASATUAN)';
SBR.Parameters.ParamByName('VKDBARANG').Value:=Edit1.Text;
SBR.Parameters.ParamByName('VNMBARANG').Value:=Edit2.Text;
SBR.Parameters.ParamByName('VSATUAN').Value:=ComboBox1.Text;
SBR.Parameters.ParamByName('VHARGASATUAN').Value:=Edit3.Text;
SBR.ExecSQL;
MessageDlg('DATA SUDAH DI SIMPAN',mtInformation,MBOKCANCEL,0);
REFRES;
end;
procedure TFRMMASTERBARANG.DBGrid1DblClick(Sender: TObject);
begin
Edit1.Text:=qry1.FIELDBYNAME('KDBARANG').Value;
Edit2.Text:=qry1.FIELDBYNAME('NMBARANG').Value;
ComboBox1.Text:=qry1.FIELDBYNAME('SATUAN').Value;
Edit3.Text:=qry1.FIELDBYNAME('HARGASATUAN').Value;
end;
procedure TFRMMASTERBARANG.btn1Click(Sender: TObject);
var
UBR:TADOQuery;
begin
UBR:=TADOQuery.Create(Self);
UBR.Connection:=FRMUTAMA.con1;
UBR.Close;
UBR.SQL.Text:='UPDATE
TBMASTERBARANG SET
KDBARANG=:VKDBARANG,NMBARANG=:VNMBARANG,SATUAN=:VSATUAN,HARGASATUAN=:VHARGASATUAN
WHERE KDBARANG=:PKDBARANG';
UBR.Parameters.ParamByName('VKDBARANG').Value:=Edit1.Text;
UBR.Parameters.ParamByName('VNMBARANG').Value:=Edit2.Text;
UBR.Parameters.ParamByName('VSATUAN').Value:=ComboBox1.Text;
UBR.Parameters.ParamByName('VHARGASATUAN').Value:=Edit3.Text;
UBR.Parameters.ParamByName('PKDBARANG').Value:=Edit1.Text;
UBR.ExecSQL;
MessageDlg('DATA SUDAH DIUBAH',mtInformation,MBOKCANCEL,0);
REFRES;
end;
end.
3. Tampilan untuk transaksi pembelian / form3.
Dibawah ini adalah script untuk form2 yang diatas :
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Grids, DBGrids, DB, ADODB, ExtCtrls;
type
TfrmTransaksiMasuk = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
DateTimePicker1: TDateTimePicker;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Edit7: TEdit;
Label8: TLabel;
Edit8: TEdit;
Label9: TLabel;
DBGrid1: TDBGrid;
Label10: TLabel;
Edit9: TEdit;
Label11: TLabel;
Edit10: TEdit;
Label12: TLabel;
Edit11: TEdit;
Button1: TButton;
ADOQuery1: TADOQuery;
ds1: TDataSource;
Button2: TButton;
Label13: TLabel;
Label14: TLabel;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Edit8KeyPress(Sender: TObject; var Key: Char);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure Edit3KeyPress(Sender: TObject; var Key: Char);
procedure FormShow(Sender: TObject);
procedure Edit7KeyPress(Sender: TObject; var Key: Char);
procedure Edit10KeyPress(Sender: TObject; var Key: Char);
procedure DBGrid1DblClick(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure segarnota();
end;
var
frmTransaksiMasuk: TfrmTransaksiMasuk;
implementation
uses Unit1;
{$R *.dfm}
procedure TfrmTransaksiMasuk.segarnota();
begin
ADOQuery1.Close;
ADOQuery1.SQL.Text:='SELECT * FROM qdetail WHERE KDNOTA = '''+Edit1.Text+'''';
ADOQuery1.Open;
end;
procedure TfrmTransaksiMasuk.Button1Click(Sender: TObject);
var
im,id,tampil,total,ut1:TADOQuery;
begin
tampil:=TADOQuery.Create(self);
tampil.Connection:=FRMUTAMA.con1;
tampil.Close;
tampil.SQL.Text:='select * from qdetail where kdnota='''+Edit1.Text+''' and kdbarang='''+edit3.Text+'''';
tampil.Open;
if tampil.IsEmpty then
begin
id:=TADOQuery.Create(self);
id.Connection:=FRMUTAMA.con1;
id.Close;
id.SQL.Text:='insert into tbDETAIL(KDBARANG,JUMLAH,KDNOTA,JMLHARGA) values(:vkdbarang,:vjumlah,:vkdnota,:vjmlharga)';
id.Parameters.ParamByName('vkdbarang').Value:=Edit3.Text;
id.Parameters.ParamByName('vjumlah').Value:=Edit7.Text;
id.Parameters.ParamByName('vkdnota').Value:=Edit1.Text;
id.Parameters.ParamByName('vjmlharga').Value:=Edit8.Text;
id.ExecSQL;
Edit3.SetFocus;
Edit4.Text:='';
Edit5.Text:='';
edit6.Text:='';
Edit7.Text:='';
Edit8.Text:='';
Edit9.Text:=Edit8.Text;
total:=TADOQuery.Create(Self);
total.Connection:=FRMUTAMA.con1;
total.Close;
total.SQL.Text:='select sum(jmlharga) as totalharga from tbdetail where kdnota = '''+Edit1.Text+'''';
total.Open;
//Mencari jumlah harga menurut nota
Edit9.Text:=total.fieldbyname('totalharga').Value;
im:=TADOQuery.Create(self);
im.Connection:=FRMUTAMA.con1;
im.Close;
im.SQL.Text:='insert into tbmaster(kdnota,tgl,kasir,total) values(:vkdnota,:vtgl,:vkasir,:vtotal)';
im.Parameters.ParamByName('vkdnota').Value:=Edit1.Text;
im.Parameters.ParamByName('vtgl').Value:='1/2/2013';
im.Parameters.ParamByName('vkasir').Value:=Edit2.Text;
im.Parameters.ParamByName('vtotal').Value:=Edit9.Text;
im.ExecSQL;
end else
begin
id:=TADOQuery.Create(self);
id.Connection:=FRMUTAMA.con1;
id.Close;
id.SQL.Text:='insert into tbDETAIL(KDBARANG,JUMLAH,KDNOTA,JMLHARGA) values(:vkdbarang,:vjumlah,:vkdnota,:vjmlharga)';
id.Parameters.ParamByName('vkdbarang').Value:=Edit3.Text;
id.Parameters.ParamByName('vjumlah').Value:=Edit7.Text;
id.Parameters.ParamByName('vkdnota').Value:=Edit1.Text;
id.Parameters.ParamByName('vjmlharga').Value:=Edit8.Text;
id.ExecSQL;
total:=TADOQuery.Create(Self);
total.Connection:=FRMUTAMA.con1;
total.Close;
total.SQL.Text:='select sum(jmlharga) as totalharga from tbdetail where kdnota = '''+Edit1.Text+'''';
total.Open;
//Mencari jumlah harga menurut nota
Edit9.Text:=total.fieldbyname('totalharga').Value;
//Update tabel1
ut1:=TADOQuery.Create(self);
ut1.Connection:=FRMUTAMA.con1;
ut1.Close;
ut1.SQL.Text:='update tbmaster set kdnota:=vkdnota,tgl:=vtgl,kasir:=vkasir,total:=vtotal where kdnota:=pkdnota';
ut1.Parameters.ParamByName('vkdnota').Value:=Edit1.Text;
ut1.Parameters.ParamByName('vtgl').Value:='1/2/2013';
ut1.Parameters.ParamByName('vkasir').Value:=Edit2.Text;
ut1.Parameters.ParamByName('vtotal').Value:=Edit9.Text;
ut1.Parameters.ParamByName('pkdnota').Value:=Edit1.Text;
ut1.ExecSQL;
Edit3.SetFocus;
Edit4.Text:='';
Edit5.Text:='';
edit6.Text:='';
Edit7.Text:='';
Edit8.Text:='';
ADOQuery1.Close;
ADOQuery1.SQL.Text:='select * from qdetail where kdnota='''+Edit1.Text+'''';
ADOQuery1.Open;
end;
ADOQuery1.Close;
ADOQuery1.SQL.Text:='select * from qdetail where kdnota='''+Edit1.Text+'''';
ADOQuery1.Open;
end;
procedure TfrmTransaksiMasuk.Edit8KeyPress(Sender: TObject; var Key: Char);
var
IM:TADOQuery;
begin
if Key = #13 then
begin
im:=TADOQuery.Create(self);
im.Connection:=FRMUTAMA.con1;
im.Close;
im.SQL.Text:='insert into tbmaster(kdnota,tgl,kasir,total) values(:vkdnota,:vtgl,:vkasir,:vtotal)';
im.Parameters.ParamByName('vkdnota').Value:=Edit1.Text;
im.Parameters.ParamByName('vtgl').Value:='1/2/2013';
im.Parameters.ParamByName('vkasir').Value:=Edit2.Text;
im.Parameters.ParamByName('vtotal').Value:=Edit9.Text;
im.ExecSQL;
MessageDlg('tersimpan',mtInformation,mbOKCancel,0);
end;
end;
procedure TfrmTransaksiMasuk.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
ADOQuery1.Close;
ADOQuery1.SQL.Text:='SELECT * FROM TBMASTER WHERE KDNOTA = '''+Edit1.Text+'''';
ADOQuery1.Open;
if ADOQuery1.IsEmpty then
begin
Edit2.SetFocus;
end ELSE
BEGIN
//DateTimePicker1.DateTime:=ADOQuery1.Fieldbyname('TGL').Value;
Edit2.Text:=ADOQuery1.Fieldbyname('KASIR').Value;
Edit9.Text:=ADOQuery1.fieldbyname('total').Value;
ADOQuery1.Close;
ADOQuery1.SQL.Text:='SELECT * FROM QDETAIL WHERE KDNOTA = '''+Edit1.Text+'''';
ADOQuery1.Open;
Edit3.SetFocus;
END;
end;
end;
procedure TfrmTransaksiMasuk.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
Edit3.SetFocus;
end;
end;
procedure TfrmTransaksiMasuk.Edit3KeyPress(Sender: TObject; var Key: Char);
var
t:TADOQuery;
begin
IF Key = #13 then
begin
ADOQuery1.Close;
ADOQuery1.SQL.Text:='SELECT * FROM TBMASTERBARANG WHERE KDBARANG = '''+Edit3.Text+'''';
ADOQuery1.Open;
IF ADOQuery1.IsEmpty then
begin
MessageDlg('DATA BELUM ADA',mtInformation,mbOKCancel,0);
end else
begin
t:=TADOQuery.Create(Self);
t.Connection:=FRMUTAMA.con1;
t.Close;
t.SQL.Text:='select * from qdetail where kdnota='''+Edit1.Text+''' and kdbarang='''+edit3.Text+'''';
t.Open;
if t.IsEmpty then
begin
Edit4.Text:=ADOQuery1.Fieldbyname('NMBARANG').Value;
Edit6.Text:=ADOQuery1.Fieldbyname('HARGASATUAN').Value;
Edit5.Text:=ADOQuery1.Fieldbyname('SATUAN').Value;;
Edit7.SetFocus;
segarnota;
end else
begin
segarnota;
MessageDlg('Duplicate data',mtInformation,mbOKCancel,0);
end;
end;
end;
end;
procedure TfrmTransaksiMasuk.FormShow(Sender: TObject);
begin
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
Edit4.Text:='';
Edit5.Text:='';
Edit6.Text:='';
Edit7.Text:='';
Edit8.Text:='';
Edit9.Text:='';
Edit10.Text:='';
Edit11.Text:='';
end;
procedure TfrmTransaksiMasuk.Edit7KeyPress(Sender: TObject; var Key: Char);
var
hs,jml,jhs : Integer;
begin
if Key = #13 then
begin
hs:=StrToInt(Edit6.Text);
jml:=StrToInt(Edit7.Text);
jhs:=hs*jml;
Edit8.Text:=IntToStr(jhs);
Button1.SetFocus;
end;
end;
procedure TfrmTransaksiMasuk.Edit10KeyPress(Sender: TObject;
var Key: Char);
begin
if key=#13 then
begin
Edit11.Text:=IntToStr(StrToInt(Edit10.Text)-StrToInt(Edit9.Text));
MessageDlg('Total = ' + edit9.text + ' bayar = '+edit10.text+' kembali = '+Edit11.Text+'',mtInformation,mbOKCancel,0);
Button2.SetFocus;
end;
end;
procedure TfrmTransaksiMasuk.DBGrid1DblClick(Sender: TObject);
var
db:TADOQuery;
begin
db:=TADOQuery.Create(Self);
db.Connection:=FRMUTAMA.con1;
edit3.Text:=ADOQuery1.FieldByName('kdbarang').value;
edit4.Text:=ADOQuery1.FieldByName('nmbarang').value;
edit5.Text:=ADOQuery1.FieldByName('satuan').value;
edit6.Text:=ADOQuery1.FieldByName('hargasatuan').value;
edit7.Text:=ADOQuery1.FieldByName('jumlah').value;
edit8.Text:=ADOQuery1.FieldByName('jmlharga').value;
db.close;
db.sql.text:='delete from tbdetail where kdnota =:vkdnota and kdbarang=:vkdbarang';
db.parameters.parambyname('vkdnota').value:=edit1.text;
db.parameters.parambyname('vkdbarang').value:=edit3.text;
db.execSQL;
segarnota;
end;
procedure TfrmTransaksiMasuk.Button2Click(Sender: TObject);
begin
close;
end;
procedure TfrmTransaksiMasuk.Timer1Timer(Sender: TObject);
begin
if label13.font.Color=clwhite then
label13.font.Color:=clyellow
else
label13.font.Color:=clwhite
end;
end.