|
楼主 |
发表于 2007-8-1 15:01:32
|
显示全部楼层
信息上的代码;;
unit WBRB;
interface
uses
Business.System, Business.Model, Business.Data;
const StrConn=' DATABASEURL=Biz:\TRJT\JTSJK.DATABASE ';
type
TWBRB = class(TInfo)
DataSetWBZ: TSQLDataSet;
DataSetWBC: TSQLDataSet;
FIELD_WBC_ZHJ: TAggField;
FIELD_WBC_JE: TUserDataField;
DataSetLJ: TUserDataSet;
FIELD_LJ_SZ: TUserDataField;
FIELD_LJ_XM: TUserDataField;
FIELD_LJ_JE: TUserDataField;
FIELD_WBC_JELJ: TCalcField;
procedure DataSetWBCCalcFields(DataSet: TDataSet);
private
{private declarations}
public
//网吧单项金额累计
Procedure SumByWbxm(Adate:String;BDate:String;Cdw:String);//(A:String;B:String;C:String);
procedure SumByWbLj(Adate:String;BDate:String;Cdw:String);
{public declarations}
end;
implementation
/////
Procedure TWBRB.SumByWbxm(Adate:String;BDate:String;Cdw:String);//(A:String;B:String;C:String);
var lQuery:TQuery;
lQuery_Str:String;
A:String;B:String;C:String;
begin
a:=DataSetWBC.FieldByName ('bc').AsString ;
b:=DataSetWBC.FieldByName ('xm').AsString ;
c:=DataSetWBC.FieldByName ('s_z').AsString ;
lQuery:=TQuery.Create (nil);
try
lQuery.ConnectionString :=StrConn;
lQuery_Str:='select bc,xm,s_z,lj=sum(je) from wbmxb '
+'where ZBGUID IN (select GUID from wbrbzb where '+
'tbdw= '''+Cdw+'''and tbrq<= '''+ADate+'''and tbrq>= '''+BDate+''')'+' and '+
'bc= '''+a+''' and xm= '''+b+''+'''and s_z= '''+c+''''
+' group by bc,xm,s_z ';
lQuery.CommandText :=lQuery_Str;
lQuery.open;
// DataSetWBC.Edit ;
DataSetWBC.FieldByName ('JELJ').AsFloat:=lQuery.Fields[3].AsFloat ;
// DataSetWBC.UpdateRecord ;
// DataSetWBC.Post ;
finally
lQuery.free;
end;
end;
/////
procedure TWBRB.SumByWbLj(Adate:String;BDate:String;Cdw:String);
var lQuery:TQuery;
lQuery_Str:String;
begin
if not DataSetLJ.Active then
DataSetLJ.Open ;
DataSetLJ.EmptyDataSet ;
lQuery := TQuery.Create(nil);
try
lQuery.ConnectionString :=StrConn;
lQuery_Str:='select s_z,xm,sumje=sum(je) from wbmxb '+
' where ZBGUID in (select guid from wbrbzb where '+
'tbdw= '''+Cdw+'''and tbrq<= '''+ADate+'''and tbrq>= '''+BDate+''''+
')group by s_z,xm';
lQuery.CommandText :=lQuery_Str;
lQuery.Open ;
while not lQuery.Eof do
begin
DataSetLJ.Append ;
DataSetLJ.FieldByName ('SZ').AsString :=lQuery.Fields[0].AsString ;
DataSetLJ.FieldByName ('XM').AsString :=lQuery.Fields[1].AsString ;
DataSetLJ.FieldByName ('JE').AsFloat :=lQuery.Fields[2].AsFloat ;
lQuery.Next ;
end;
finally
lQuery.Free;
end;
end;
///
procedure TWBRB.DataSetWBCCalcFields(DataSet: TDataSet);
var a,b,c:String;
begin
TWBRBD.
a:= SysUtils.DateToStr(TWBRBD(TWBRB).DateTimePicker1.Date );
b:= SysUtils.DateToStr(TWBRBD(TWBRB).DateTimePicker1.Date );
c:=TWBRBD(TWBRB).ComboBox1.Text ;
SumByWbxm(a,b,c);
//WBRBD.
end;
end. |
|