两个窗体互相调用?有关TQuery和TDBgrid!

restart2001 2001-09-11 04:21:59
有两个窗体:一个窗体负责取得“定单号”信息,另一个负责根据“定单号”在dbgrid上显示“商品类别”、

“规格型号”、“单位”、“数量”。现在问题是定单号不只有一个可能有多个,所以我定义了一个

tstringlist对象来存储定单号,但如果选择了几个定单号后,只能显示第一张定单号的信息,不能显示全部定

单号的信息。不知道为什么,相关代码如下,如有疑问我再贴出:
(2)、“添加入单”按钮代码
var
Index:integer;
begin
if MyList.Find(jh_ddqk.Fields[1].AsString,Index) then {mylists是一个Tstringlist对象,在窗体的

oncreate事件中已经初始化}
begin
messagedlg('此定单已作选择,请重新选择!',MtError,[mbok],0);
end else
begin
mylist.Add(jh_ddqk.Fields[1].AsString);
xddd.Caption:=InttoStr(mylist.count);
end;
(1)、“确 定”按钮代码
var
i,j,k:integer;
begin
j:=mylist.Count;
k:=j;
if j=0 then
begin
messagedlg('您没有选择,请至少选择一条记录或按“取消”键退出!',MtError,[mbok],0);
end else
begin
{ 根据mylist上的定单号往dbgrid上输入信息 }
c_cgxqdfrm.jh_cgxqd.close;
c_cgxqdfrm.jh_cgxqd.SQL.Clear;
for I:=0 to k-1 do
begin
with c_cgxqdfrm.jh_cgxqd do
begin
sql.Add('select a.lbmc,b.spmc,b.jldw,c.spsl');
sql.Add('from splbb as a,spmlb as b,xsdmxb as c');
sql.Add('where c.xsdh=:xsdh and c.spbh=b.spbh and a.lbbh=b.splb');
Parambyname('xsdh').Asstring:=mylist.Strings[i];
mylist.EndUpdate;
if i<>j-1 then sql.Add(#13+'union');
end;
end;
with c_cgxqdfrm.jh_cgxqd do
begin
update;
if not prepared then prepare;
try
open;
except
execsql;
end;
c_cgxqdfrm.DBGrid1.Columns[0].FieldName:='lbmc';
c_cgxqdfrm.DBGrid1.Columns[1].FieldName:='spmc';
c_cgxqdfrm.DBGrid1.Columns[2].FieldName:='jldw';
c_cgxqdfrm.DBGrid1.Columns[3].FieldName:='spsl';
end;
c_ddxzFrm.Close;
end;
end;

...全文
72 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
restart2001 2001-09-14
  • 打赏
  • 举报
回复
先给20分,另一个问题还有30分哦,欢迎大家去拿!
newyj 2001-09-11
  • 打赏
  • 举报
回复
解决ss:string;
ss:='';
for I:=0 to k-1 do
begin
ss:=ss+''''+ mylist.Strings[i]+'''';
if i<>j-1 then ss:=ss+',');
end;

with c_cgxqdfrm.jh_cgxqd do
begin

sql.Add('select a.lbmc,b.spmc,b.jldw,c.spsl');
sql.Add('from splbb as a,spmlb as b,xsdmxb as c');
sql.Add('where c.xsdh in (:xsdh) and c.spbh=b.spbh and a.lbbh=b.splb');
Parambyname('xsdh').Asstring:=ss;
end;


newyj 2001-09-11
  • 打赏
  • 举报
回复
就是
Parambyname('xsdh').Asstring:=mylist.Strings[i];
的问题

5,931

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧