📄 uform_fw_list.~pas
字号:
unit Uform_fw_list;
//查询各种不同服务的消费情况
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ComCtrls, ExtCtrls, DB, ADODB, ImgList;
type
Tform_fw_list = class(TForm)
Panel1: TPanel;
Image1: TImage;
Label2: TLabel;
Label1: TLabel;
Bevel1: TBevel;
Image2: TImage;
Label5: TLabel;
Label6: TLabel;
Panel2: TPanel;
apart_list: TListView;
Panel3: TPanel;
Panel4: TPanel;
BitBtn3: TBitBtn;
BitBtn2: TBitBtn;
ImageList1: TImageList;
recordset_temp: TADOQuery;
recordset_temp2: TADOQuery;
Label3: TLabel;
Label4: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
BitBtn1: TBitBtn;
procedure FormShow(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
intCount:integer;
sdate:tdate;
edate:tdate;
end;
var
form_fw_list: Tform_fw_list;
implementation
uses Uform_fw_limit, Uform_fw_one;
{$R *.dfm}
procedure Tform_fw_list.FormShow(Sender: TObject);
//初始化窗口的显示
var
i:integer;
ListItem: TListItem;
p:^integer;
begin
//向数据库查询所有的服务项目
apart_list.Items.Clear ;
label8.Caption :='未限定';
label4.Caption :='未限定';
label10.Caption :=format('%8.2f¥',[0.0]);
sdate:=now;
edate:=now;
recordset_temp.SQL.Clear ;
recordset_temp.SQL.Add ('select * from [FW]');
recordset_temp.Open ;
intCount:=recordset_temp.RecordCount ;
Label5.Caption :=inttostr(intCount) + '个';
//在窗口上显示
for i:=1 to recordset_temp.RecordCount do
begin
listitem:=apart_LIST.Items.Add ;
listitem.Caption :=recordset_temp.Fields[1].AsString ;
listitem.SubItems.Add(format( '%8.2f¥',[recordset_temp.fields[2].asfloat]));
listitem.SubItems.Add('0');
listitem.SubItems.Add (format('%8.2f¥',[0.0]));
listitem.ImageIndex :=0;
new(p);
p^ := recordset_temp.Fields[0].AsInteger ;
listitem.Data :=p;
recordset_temp.Next;
end;
end;
procedure Tform_fw_list.BitBtn3Click(Sender: TObject);
//关闭窗口
begin
close;
end;
procedure Tform_fw_list.BitBtn2Click(Sender: TObject);
//选定消费查询的限定条件
var
i:integer;
ListItem: TListItem;
p:^integer;
money:real;
begin
//显示消费查询限定窗口
form_fw_limit.ShowModal ;
//是否选择了限定条件
if form_fw_limit.yesno =false then exit;
sdate:=form_fw_limit.sdate ;
edate:=form_fw_limit.edate ;
//按限定条件在数据库中查询
apart_list.Items.Clear ;
label8.Caption :=datetostr(sdate);
label4.Caption :=datetostr(edate);
money:=0;
recordset_temp.SQL.Clear ;
recordset_temp.SQL.Add ('select * from [FW]');
recordset_temp.Open ;
intCount:=recordset_temp.RecordCount ;
Label5.Caption :=inttostr(intCount) + '个';
//将查询结果显示在窗口中
for i:=1 to recordset_temp.RecordCount do
begin
listitem:=apart_LIST.Items.Add ;
listitem.Caption :=recordset_temp.Fields[1].AsString ;
listitem.SubItems.Add(format( '%8.2f¥',[recordset_temp.fields[2].asfloat]));
listitem.ImageIndex :=0;
recordset_temp2.SQL.Clear;
recordset_temp2.SQL.Add('select sum([JY_FWCOUNT]),sum([JY_ALLDOLLOR]) from [JY] where [JY_FWID]='
+ inttostr(recordset_temp.Fields[0].AsInteger) + ' and [JY_DATE]>=#' + datetostr(sdate) + '# and [JY_DATE]<=#' + datetostr(edate+1) + '#');
recordset_temp2.Open ;
if recordset_temp.RecordCount <>0 then
begin
listitem.SubItems.Add(inttostr(recordset_temp2.Fields[0].asinteger));
listitem.SubItems.Add (format('%8.2f¥',[recordset_temp2.Fields[1].asfloat]));
money:=money+recordset_temp2.Fields[1].asfloat;
end
else
begin
listitem.SubItems.Add('0');
listitem.SubItems.Add (format('%8.2f¥',[0.0]));
end;
recordset_temp2.Close;
new(p);
p^ := recordset_temp.Fields[0].AsInteger ;
listitem.Data :=p;
recordset_temp.Next;
end;
label10.Caption :=format('%8.2f¥',[money]);
end;
procedure Tform_fw_list.BitBtn1Click(Sender: TObject);
//显示该项目的详细消费情况
var
p:^integer;
begin
//是否选择了某条目
if apart_list.Selected =nil then exit;
//向数据库作相应的查询
p:=Apart_list.Selected.Data;
form_fw_one.id :=p^;
form_fw_one.stime:=datetostr(sdate) + '-' + datetostr(edate);
form_fw_one.fw_name :=apart_list.Selected.Caption ;
recordset_temp2.SQL.Clear;
recordset_temp2.SQL.Add('select sum([JY_FWCOUNT]),sum([JY_ALLDOLLOR]) from [JY] where [JY_FWID]='
+ inttostr(p^) + ' and [JY_DATE]>=#' + datetostr(sdate) + '# and [JY_DATE]<=#' + datetostr(edate+1) + '#');
recordset_temp2.Open ;
//设置查询显示窗口的标志变量
if recordset_temp.RecordCount <>0 then
begin
form_fw_one.cc:=inttostr(recordset_temp2.Fields[0].asinteger) + '套/' +
format('%8.2f¥',[recordset_temp2.Fields[1].asfloat]);
end
else
begin
form_fw_one.cc:='0套/'+ format('%8.2f¥',[0.0]);
end;
recordset_temp2.Close;
form_fw_one.sdate:=sdate;
form_fw_one.edate:=edate;
//显示项目消费情况窗口
form_fw_one.ShowModal ;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -