|
楼主 |
发表于 2007-7-30 16:01:01
|
显示全部楼层
unit MKCXCYWXX;
interface
uses
Business.System, Business.Model, Business.Data;
const
STRCONN = 'DATABASEURL=Biz:\TRJT\JTSJK.DATABASE';
//生产累计
SqlStr_SCLJ='select mz,hc,jj,yk,xs,hclj=sum(hc) ,jjlj=sum(jj),yklj=sum(yk),hjlj=sum(hc+jj+yk),xslj=sum(xs),kclj=sum(hc+jj+yk-xs),bz from MKRBMXB ';
//销售累计
SqlStr_XSLJ='select xsfl,xsdd,xsl,xslhj=sum(xsl),dj,drysk=dj*xsl,yskhj=sum(dj*xsl),sk,skhj=sum(sk),xsbz from MKXSMXB';
type
TMKCXCYWXX = class(TInfo)
DataSetTB_Z: TSQLDataSet;
DataSetTB_C_SC: TSQLDataSet;
DataSetTB_C_XS: TSQLDataSet;
FIELD_TB_C_SC_DRZCL: TExprCalcField;
FIELD_TB_C_SC_DRKC: TExprCalcField;
FIELD_TB_C_XS_YSK: TExprCalcField;
FIELD_TB_C_SC_DRHCHJ: TAggField;
FIELD_TB_C_SC_DRJJHJ: TAggField;
FIELD_TB_C_SC_DRYKHJ: TAggField;
FIELD_TB_C_SC_DRXSHJ: TAggField;
FIELD_TB_C_SC_DRZCLHJ: TAggField;
FIELD_TB_C_SC_DRKCHJ: TAggField;
FIELD_TB_C_XS_DRXSLHJ: TAggField;
FIELD_TB_C_XS_DRYSKHJ: TAggField;
FIELD_TB_C_XS_DRSJSKHJ: TAggField;
DataSetLJ_SC: TUserDataSet;
FIELD_LJ_ZDY_MZ: TUserDataField;
FIELD_LJ_ZDY_HC: TUserDataField;
FIELD_LJ_ZDY_HCLJ: TUserDataField;
FIELD_LJ_ZDY_JJ: TUserDataField;
FIELD_LJ_ZDY_JJLJ: TUserDataField;
FIELD_LJ_ZDY_YK: TUserDataField;
FIELD_LJ_ZDY_YKLJ: TUserDataField;
FIELD_LJ_ZDY_HJ: TUserDataField;
FIELD_LJ_ZDY_HJLJ: TUserDataField;
FIELD_LJ_ZDY_XS: TUserDataField;
FIELD_LJ_ZDY_XSLJ: TUserDataField;
FIELD_LJ_ZDY_KC: TUserDataField;
FIELD_LJ_ZDY_KCLJ: TUserDataField;
FIELD_LJ_ZDY_BZ: TUserDataField;
DataSetLJ_XS: TUserDataSet;
FIELD_LJ_XS_XSFS: TUserDataField;
FIELD_LJ_XS_XSDD: TUserDataField;
FIELD_LJ_XS_XSL: TUserDataField;
FIELD_LJ_XS_DJ: TUserDataField;
FIELD_LJ_XS_LJXSL: TUserDataField;
FIELD_LJ_XS_YSK: TUserDataField;
FIELD_LJ_XS_YSKLJ: TUserDataField;
FIELD_LJ_XS_SJSK: TUserDataField;
FIELD_LJ_XS_SJSKLJ: TUserDataField;
FIELD_LJ_XS_XSBZ: TUserDataField;
DataSetFX_RB: TPivotDataSet;
private
{private declarations}
public
//生产累计 三个参数,1、开始时间 2、结束时间 3、单位
procedure Sum_SCLj(ADate:String;BDate:String;Cdw:String);
//销售累计 三个参数,1、开始时间 2、结束时间 3、单位
procedure SumbyXSLJ(ADate:String;BDate:String;Cdw:String);
end;
implementation
procedure TMKCXCYWXX.Sum_SCLj(ADate:String;BDate:String;Cdw:String);
var Sql_SCLJ:TQuery;
Sql_SCLJ_Str:string;
begin
if not DataSetLJ_SC.Active then
DataSetLJ_SC.Open ;
DataSetLJ_SC.EmptyDataSet ;
Sql_SCLj:=TQuery.Create (nil);
try
Sql_SCLj.ConnectionString:=STRConn;
Sql_SCLJ_Str:= SqlStr_SCLJ;
Sql_SCLJ_Str:=Sql_SCLJ_Str
+ 'where ZBGUID in (Select guid from mkrbb where TBRQ>= '''+Adate+''' and TBRQ <= '''+BDate+''
+'''and TBDW= '''+Cdw+''')'
+'group by mz,hc,jj,yk,xs,bz';
Sql_SCLj.CommandText:=Sql_sclj_str;
Sql_sclj.open;
finally
Sql_SCLJ.Free ;
end;
//jsDialogs.showmsg('','');
end;
//----------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
procedure TMKCXCYWXX.SumbyXSLJ(ADate:String;BDate:String;Cdw:String);
var
Sql_XSLJ:TQuery;
Sql_SCXS_Str:string;
begin
if not DataSetLJ_XS.Active then
DataSetLJ_XS.Open;
DataSetLJ_XS.EmptyDataSet;
Sql_XSLJ:=TQuery.Create (nil);
try
Sql_XSLJ.CommandText :=STRCONN;
SQl_SCXS_STR:= SqlStr_XSLJ;
SQl_SCXS_STR:=SQl_SCXS_STR
+ 'where ZBGUID in (Select guid from mkrbb where TBRQ>= '''+Adate+''' and TBRQ <= '''+BDate+''
+'''and TBDW= '''+Cdw+''')'
+'group by xsfl,xsdd,xsl,dj,sk,xsbz';
Sql_XSLJ.CommandText :=SQl_SCXS_STR;
Sql_XSLJ.Execute ;
finally
end;
end;
end.
呵呵.初学者..这是全部单元的代码..帮忙看看。
unit MKCXCYWXX;
interface
uses
Business.System, Business.Model, Business.Data;
const
STRCONN = 'DATABASEURL=Biz:\TRJT\JTSJK.DATABASE';
//生产累计
SqlStr_SCLJ='select mz,hc,jj,yk,xs,hclj=sum(hc) ,jjlj=sum(jj),yklj=sum(yk),hjlj=sum(hc+jj+yk),xslj=sum(xs),kclj=sum(hc+jj+yk-xs),bz from MKRBMXB ';
//销售累计
SqlStr_XSLJ='select xsfl,xsdd,xsl,xslhj=sum(xsl),dj,drysk=dj*xsl,yskhj=sum(dj*xsl),sk,skhj=sum(sk),xsbz from MKXSMXB';
type
TMKCXCYWXX = class(TInfo)
DataSetTB_Z: TSQLDataSet;
DataSetTB_C_SC: TSQLDataSet;
DataSetTB_C_XS: TSQLDataSet;
FIELD_TB_C_SC_DRZCL: TExprCalcField;
FIELD_TB_C_SC_DRKC: TExprCalcField;
FIELD_TB_C_XS_YSK: TExprCalcField;
FIELD_TB_C_SC_DRHCHJ: TAggField;
FIELD_TB_C_SC_DRJJHJ: TAggField;
FIELD_TB_C_SC_DRYKHJ: TAggField;
FIELD_TB_C_SC_DRXSHJ: TAggField;
FIELD_TB_C_SC_DRZCLHJ: TAggField;
FIELD_TB_C_SC_DRKCHJ: TAggField;
FIELD_TB_C_XS_DRXSLHJ: TAggField;
FIELD_TB_C_XS_DRYSKHJ: TAggField;
FIELD_TB_C_XS_DRSJSKHJ: TAggField;
DataSetLJ_SC: TUserDataSet;
FIELD_LJ_ZDY_MZ: TUserDataField;
FIELD_LJ_ZDY_HC: TUserDataField;
FIELD_LJ_ZDY_HCLJ: TUserDataField;
FIELD_LJ_ZDY_JJ: TUserDataField;
FIELD_LJ_ZDY_JJLJ: TUserDataField;
FIELD_LJ_ZDY_YK: TUserDataField;
FIELD_LJ_ZDY_YKLJ: TUserDataField;
FIELD_LJ_ZDY_HJ: TUserDataField;
FIELD_LJ_ZDY_HJLJ: TUserDataField;
FIELD_LJ_ZDY_XS: TUserDataField;
FIELD_LJ_ZDY_XSLJ: TUserDataField;
FIELD_LJ_ZDY_KC: TUserDataField;
FIELD_LJ_ZDY_KCLJ: TUserDataField;
FIELD_LJ_ZDY_BZ: TUserDataField;
DataSetLJ_XS: TUserDataSet;
FIELD_LJ_XS_XSFS: TUserDataField;
FIELD_LJ_XS_XSDD: TUserDataField;
FIELD_LJ_XS_XSL: TUserDataField;
FIELD_LJ_XS_DJ: TUserDataField;
FIELD_LJ_XS_LJXSL: TUserDataField;
FIELD_LJ_XS_YSK: TUserDataField;
FIELD_LJ_XS_YSKLJ: TUserDataField;
FIELD_LJ_XS_SJSK: TUserDataField;
FIELD_LJ_XS_SJSKLJ: TUserDataField;
FIELD_LJ_XS_XSBZ: TUserDataField;
DataSetFX_RB: TPivotDataSet;
private
{private declarations}
public
//生产累计 三个参数,1、开始时间 2、结束时间 3、单位
procedure Sum_SCLj(ADate:String;BDate:String;Cdw:String);
//销售累计 三个参数,1、开始时间 2、结束时间 3、单位
procedure SumbyXSLJ(ADate:String;BDate:String;Cdw:String);
end;
implementation
procedure TMKCXCYWXX.Sum_SCLj(ADate:String;BDate:String;Cdw:String);
var Sql_SCLJ:TQuery;
Sql_SCLJ_Str:string;
begin
if not DataSetLJ_SC.Active then
DataSetLJ_SC.Open ;
DataSetLJ_SC.EmptyDataSet ;
Sql_SCLj:=TQuery.Create (nil);
try
Sql_SCLj.ConnectionString:=STRConn;
Sql_SCLJ_Str:= SqlStr_SCLJ;
Sql_SCLJ_Str:=Sql_SCLJ_Str
+ 'where ZBGUID in (Select guid from mkrbb where TBRQ>= '''+Adate+''' and TBRQ <= '''+BDate+''
+'''and TBDW= '''+Cdw+''')'
+'group by mz,hc,jj,yk,xs,bz';
Sql_SCLj.CommandText:=Sql_sclj_str;
Sql_sclj.open;
finally
Sql_SCLJ.Free ;
end;
//jsDialogs.showmsg('','');
end;
//----------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
procedure TMKCXCYWXX.SumbyXSLJ(ADate:String;BDate:String;Cdw:String);
var
Sql_XSLJ:TQuery;
Sql_SCXS_Str:string;
begin
if not DataSetLJ_XS.Active then
DataSetLJ_XS.Open;
DataSetLJ_XS.EmptyDataSet;
Sql_XSLJ:=TQuery.Create (nil);
try
Sql_XSLJ.CommandText :=STRCONN;
SQl_SCXS_STR:= SqlStr_XSLJ;
SQl_SCXS_STR:=SQl_SCXS_STR
+ 'where ZBGUID in (Select guid from mkrbb where TBRQ>= '''+Adate+''' and TBRQ <= '''+BDate+''
+'''and TBDW= '''+Cdw+''')'
+'group by xsfl,xsdd,xsl,dj,sk,xsbz';
Sql_XSLJ.CommandText :=SQl_SCXS_STR;
Sql_XSLJ.Execute ;
finally
end;
end;
end. |
|