Ditutorial sebelumnya telah dibahas cara mencetak Multiselect di delphi dengan Single user, selanjutnya jika pemakai sistem banyak (Multi User)
maka kita harus merubah codingnya seperti berikut
Resep Programming
Syntak Delphi
|
procedure TFcetak_barcode.bcetakClick(Sender:
TObject);
var
i : integer;
begin
if DBGrid1.SelectedRows.Count > 0 then
Begin
with
DBGrid1.DataSource.DataSet do
Begin
with
qr2 do
Begin
close;
sql.Clear;
sql.Add(' DROP TABLE IF EXISTS `'+'temp'+main.usr+'` ' );
ExecSQL;
close;
sql.Clear;
sql.Add('CREATE TABLE `'+'temp'+main.usr+'` (');
sql.Add('idbcode VARCHAR(20) NULL
DEFAULT NULL,');
sql.Add('tglinput DATE NULL DEFAULT
NULL,');
sql.Add('idrak VARCHAR(10) NULL
DEFAULT NULL,');
sql.Add('nam_wh VARCHAR(50) NULL DEFAULT NULL,');
sql.Add('idmat INT(11) NULL DEFAULT
NULL,');
sql.add('qty_datang INT(11) NULL DEFAULT
NULL,');
sql.Add('unit_basic VARCHAR(50) NULL
DEFAULT NULL,');
sql.Add('no_po VARCHAR(50) NULL
DEFAULT NULL,');
sql.Add('brg VARCHAR(50) NULL DEFAULT
NULL,');
sql.Add('supplier VARCHAR(50) NULL
DEFAULT NULL');
sql.Add(')COLLATE="utf8_general_ci" ');
sql.Add('ENGINE=MyISAM ');
sql.Add('; ');
ExecSQL;
close;
end;
end;
for i :=
0 to DBGrid1.SelectedRows.Count-1 do
begin
//GotoBookmark(pointer(DBGrid1.SelectedRows.items[i]));
qr1.GotoBookmark(pointer(DBGrid1.SelectedRows[i]));
begin
// Buat tabel baru
with qr2 do
begin
close;
sql.Clear;
sql.Add('insert into
`'+'temp'+main.usr+'`(idbcode,tglinput,idrak,nam_wh,
idmat,qty_datang,unit_basic,no_po,brg,supplier)');
sql.Add('values(:idbcode,:tgl,:idrak,:nam_wh,:idmat,
:qtydatang,:ub,:nopo,:brg,:supp)');
ParamByName('idbcode').AsString := qr1idbcode.AsString;
ParamByName('tgl').AsDate := qr1tglinput.AsDateTime;
ParamByName('idrak').AsString
:= qr1idrak.AsString;
ParamByName('nam_wh').AsString := qr1nam_wh.AsString;
ParamByName('idmat').AsString := qr1idmat.AsString;
ParamByName('qtydatang').AsString := qr1qtydatang.AsString;
ParamByName('ub').AsString := qr1unit_basic.AsString;
ParamByName('nopo').AsString := qr1no_po.AsString;
ParamByName('brg').AsString := qr1brg.AsString;
ParamByName('supp').AsString :=
qr1supplier.AsString;
ExecSQL;
close;
end;
end;
end;
with
qr3 do
begin
close;
sql.Clear;
sql.Add('select * from `'+'temp'+main.usr+'` ');
open;
close;
end;
frxReport1.Report.ShowReport(false);
end;
end;
|
Selamat Mencoba
PADEPOKAN IT COURSES
IT Tutorial, Training Center & IT Solution
No comments:
Post a Comment