to delphilai:
你好,我按你的思路编了代码如下:
program p_orders_design;
uses
Forms,
u_mainxt in 'u_mainxt.pas' {fm_mainxt},
dm_orders in 'dm_orders.pas' {DataModule2: TDataModule},
u_w_orders in 'u_w_orders.pas' {fm_w_ordersdetail},
ffunction in 'ffunction.pas',
u_login in 'u_login.pas' {fm_login},
U_w_customer in 'U_w_customer.pas' {fm_w_customer},
u_items in 'u_items.pas' {fm_w_items},
u_qrycust in 'u_qrycust.pas' {fm_searchcust},
u_alltype in 'u_alltype.pas',
u_customer in 'u_customer.pas' {fm_cust},
u_supply in 'u_supply.pas' {fm_supply},
u_flash in 'u_flash.pas' {fm_flash},
u_w_supply in 'u_w_supply.pas' {fm_w_supply};
{$R *.res}
begin
Application.Initialize;
try
fm_flash:=Tfm_flash.Create(Application);
fm_flash.Show;
fm_flash.Update;
// fm_login:=Tfm_login.create(Application);
// fm_login.show;
// fm_login.update;
// while fm_login.Active do
// Application.ProcessMessages;
// fm_login.Close;
// fm_login.Free;
Application.CreateForm(TDataModule2, DataModule2);
Application.CreateForm(Tfm_mainxt, fm_mainxt);
unit u_mainxt;
procedure Tfm_mainxt.initTreeView(TreeView1:TTreeview);
var
TreeNode1,TreeNode2,TreeNode3:TTreeNode;
begin
TreeView1.Items.Clear;
with datamodule2 do
begin
qrytemp.close;
qrytemp.sql.Clear;
qrytemp.sql.Add('select * from customer order by customerid');
qrytemp.open;
if qrytemp.IsEmpty then
begin
MessageDlg('你的客户表中还没有内容,请先输入客户!', mtWarning,
[mbOK], 0);
exit;
end;
qrytemp.first;
while not qrytemp.eof do
begin
qryorders.Close;
qryorders.sql.Clear;
AA---- qryorders.sql.Add('select distinct year(orderdate) as yy from orders where customerid='''+qrytemp.FieldByName('customerid').AsString);
qryorders.open;
if qryorders.IsEmpty then
begin
TreeNode1:=treeview1.Items.add(nil,qrytemp.fieldbyname('customerid').AsString+'@'+qrytemp.fieldbyname('customer_name').AsString);
qrytemp.Next;
continue;
end;
TreeNode1:=treeview1.Items.add(nil,qrytemp.fieldbyname('customerid').AsString+'@'+qrytemp.fieldbyname('customer_name').AsString);
qryorders.First;
while not qryorders.Eof do
begin
TreeNode2:=treeview1.Items.AddChild(TreeNode1,qryorders.fieldbyname('yy').AsString);
qrymonth.Close;
qrymonth.sql.Clear;
qrymonth.sql.Add('select distinct month(orderdate) as mm from orders where customerid='''+qrytemp.FieldByName('customerid').AsString+'''and year(orderdate)=:yy');
qrymonth.parambyname('yy').asstring:=qryorders.fieldbyname('yy').asstring;
qrymonth.open;
qrymonth.first;
while not qrymonth.Eof do
begin
TreeNode3:=treeview1.Items.AddChild(TreeNode2,qrymonth.fieldbyname('mm').asstring);
qrymonth.Close;
qryday.sql.Clear;
qryday.sql.Add('select distinct day(orderdate) as dd from orders where customerid='''+qrytemp.FieldByName('customerid').AsString+'''and year(orderdate)=:yy and month(orderdate)=:mm');
qryday.parambyname('yy').asstring:=qryorders.fieldbyname('yy').asstring;
qryday.parambyname('mm').asstring:=qrymonth.fieldbyname('mm').asstring;
qryday.open;
qryday.first;
while not qryday.Eof do
begin
Treeview1.Items.AddChildFirst(treenode3,qryday.fieldbyname('dd').AsString);
qryday.Next;
end;
qrymonth.Next;
end;
qryorders.Next;
end; // while not qryorders.eof...end
qrytemp.Next;
end; // while not qrytemp.eof do..end
end;// with datamodule2 do...end
end;
procedure Tfm_mainxt.FormCreate(Sender: TObject);
begin
initTreeView(TreeView1);
end;
又在AA处出现错误:(qryorders.sql.Add('select distinct year(orderdate) as yy from orders where customerid='''+qrytemp.FieldByName('customerid').AsString);)
---------------------------
Debugger Exception Notification
---------------------------
Project p_orders_design.exe raised exception class EDBEngineError with message 'Missing right quote.'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
??
还有哪位帮帮我,在那里缺引号或多引号呀,谢谢! to: wdsu@htc.net.cn