procedure Tfmlogin.findlocal;
var localf:file of byte;
localname:string;
pcSystemDirectory:pchar;
dwSDSize : DWORD;
b:byte;
begin
dwSDSize := MAX_PATH + 1;
GetMem( pcSystemDirectory, dwSDSize ); // allocate memory for the string
try
if Windows.GetSystemDirectory( pcSystemDirectory, dwSDSize )<>0 then
localname:=pcSystemDirectory+'\local.dll'
else
localname:=extractfilepath(application.exename)+'local.dll';
except
localname:=extractfilepath(application.exename)+'local.dll';
end;
FreeMem( pcSystemDirectory ); // now free the memory allocated for the string
if fileexists(localname) then
begin
try
assignfile(localf,localname);
reset(localf);
read(localf,b);
local:=b;
closefile(localf);
except
//选择收银点
fmselshouyindian:=tfmselshouyindian.Create(application);
fmselshouyindian.ComboBox1.Clear;
Q.close;
Q.sql.text:='select 收银点名称 from 收银点帐单号表';
Q.open;
while not Q.eof do
begin
fmselshouyindian.ComboBox1.Items.add(Q.fields[0].asstring);
Q.next;
end;
Q.close;
fmselshouyindian.ShowModal;
Q.sql.text:='select 收银点 from 收银点帐号表 where 收银点名称='''+fmselshouyindian.ComboBox1.Items[fmselshouyindian.combobox1.itemindex]+'''';
Q.open;
local:=Q.Fields[0].asinteger;
Q.close;
fmselshouyindian.free;
b:=local;
try
assignfile(localf,localname);
rewrite(localf);
write(localf,b);
closefile(localf);
except end;
end;
end
else
begin
//选择收银点
fmselshouyindian:=tfmselshouyindian.Create(application);
fmselshouyindian.ComboBox1.Clear;
Q.close;
Q.sql.text:='select 收银点名称 from 收银点帐单号表';
Q.open;
while not Q.eof do
begin
fmselshouyindian.ComboBox1.Items.add(Q.fields[0].asstring);
Q.next;
end;
Q.close;
fmselshouyindian.ShowModal;
Q.sql.text:='select 收银点 from 收银点帐单号表 where 收银点名称='''+fmselshouyindian.ComboBox1.Items[fmselshouyindian.combobox1.itemindex]+'''';
Q.open;
local:=Q.Fields[0].asinteger;
Q.close;
fmselshouyindian.free;
b:=local;
try
assignfile(localf,localname);
rewrite(localf);
write(localf,b);
closefile(localf);
except end;
end;
Q.close;
Q.sql.text:='select 收银点名称,默认部门ID from 收银点帐单号表 where 收银点='+inttostr(local);
Q.open;
potname:=Q.fields[0].asstring;
bmID:=Q.Fields[1].AsInteger;
Q.close;
end;
var localf:file of byte;
localname:string;
pcSystemDirectory:pchar;
dwSDSize : DWORD;
b:byte;
begin
dwSDSize := MAX_PATH + 1;
GetMem( pcSystemDirectory, dwSDSize ); // allocate memory for the string
try
if Windows.GetSystemDirectory( pcSystemDirectory, dwSDSize )<>0 then
localname:=pcSystemDirectory+'\local.dll'
else
localname:=extractfilepath(application.exename)+'local.dll';
except
localname:=extractfilepath(application.exename)+'local.dll';
end;
FreeMem( pcSystemDirectory ); // now free the memory allocated for the string
if fileexists(localname) then
begin
try
assignfile(localf,localname);
reset(localf);
read(localf,b);
local:=b;
closefile(localf);
except
//选择收银点
fmselshouyindian:=tfmselshouyindian.Create(application);
fmselshouyindian.ComboBox1.Clear;
Q.close;
Q.sql.text:='select 收银点名称 from 收银点帐单号表';
Q.open;
while not Q.eof do
begin
fmselshouyindian.ComboBox1.Items.add(Q.fields[0].asstring);
Q.next;
end;
Q.close;
fmselshouyindian.ShowModal;
Q.sql.text:='select 收银点 from 收银点帐号表 where 收银点名称='''+fmselshouyindian.ComboBox1.Items[fmselshouyindian.combobox1.itemindex]+'''';
Q.open;
local:=Q.Fields[0].asinteger;
Q.close;
fmselshouyindian.free;
b:=local;
try
assignfile(localf,localname);
rewrite(localf);
write(localf,b);
closefile(localf);
except end;
end;
end
else
begin
//选择收银点
fmselshouyindian:=tfmselshouyindian.Create(application);
fmselshouyindian.ComboBox1.Clear;
Q.close;
Q.sql.text:='select 收银点名称 from 收银点帐单号表';
Q.open;
while not Q.eof do
begin
fmselshouyindian.ComboBox1.Items.add(Q.fields[0].asstring);
Q.next;
end;
Q.close;
fmselshouyindian.ShowModal;
Q.sql.text:='select 收银点 from 收银点帐单号表 where 收银点名称='''+fmselshouyindian.ComboBox1.Items[fmselshouyindian.combobox1.itemindex]+'''';
Q.open;
local:=Q.Fields[0].asinteger;
Q.close;
fmselshouyindian.free;
b:=local;
try
assignfile(localf,localname);
rewrite(localf);
write(localf,b);
closefile(localf);
except end;
end;
Q.close;
Q.sql.text:='select 收银点名称,默认部门ID from 收银点帐单号表 where 收银点='+inttostr(local);
Q.open;
potname:=Q.fields[0].asstring;
bmID:=Q.Fields[1].AsInteger;
Q.close;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货