database.temp.SQL.Append('(SELECT dbo.csale.code AS 单据编号, dbo.csale.billdate AS 开单日期, '+
'dbo.client.shortname AS 往来单位, dbo.operator.opname AS 操作员, '+
'dbo.shop.name AS 部门, dbo.employ.name AS 业务员, dbo.csale.totalamt AS 金额, '+
'dbo.csale.totalamt AS 已收款, dbo.credtype.name AS 收款方式, ''现款销售单'' AS 单据类型 '+
'FROM dbo.shop INNER JOIN '+
'dbo.csale INNER JOIN '+
'dbo.operator ON dbo.csale.opid = dbo.operator.opid INNER JOIN '+
'dbo.client ON dbo.csale.clientid = dbo.client.clientid ON '+
'dbo.shop.shopid = dbo.csale.shopid INNER JOIN '+
'dbo.employ ON dbo.csale.exemanid = dbo.employ.empid INNER JOIN '+
'dbo.credence ON dbo.csale.credid = dbo.credence.credid INNER JOIN '+
'dbo.credtype ON dbo.credence.credtypeid = dbo.credtype.id '+
'WHERE (csale.totalamt<>csale.totalamt)and (dbo.employ.name='''+man.Text+''') and (dbo.csale.billdate <= '''+datetostr(date-d3.Value)+''') '+
'UNION ALL '+
'SELECT TOP 100 PERCENT dbo.invoice.code AS 单据编号, '+
'dbo.invoice.billdate AS 开单日期, dbo.client.shortname AS 往来单位, '+
'dbo.operator.opname AS 操作员, dbo.shop.name AS 部门, '+
'dbo.employ.name AS 业务员, dbo.invoice.totalamt AS 金额, '+
'dbo.invoice.totalrcvd AS 已收款, dbo.credtype.name AS 收款方式, ''销售开单'' AS 单据类型 '+
'FROM dbo.invoice INNER JOIN '+
'dbo.shop ON dbo.invoice.shopid = dbo.shop.shopid INNER JOIN '+
'dbo.operator ON dbo.invoice.opid = dbo.operator.opid INNER JOIN '+
'dbo.employ ON dbo.invoice.exemanid = dbo.employ.empid INNER JOIN '+
'dbo.client ON dbo.invoice.clientid = dbo.client.clientid INNER JOIN '+
'dbo.credence ON dbo.invoice.credid = dbo.credence.credid INNER JOIN '+
'dbo.credtype ON dbo.credence.credtypeid = dbo.credtype.id WHERE (invoice.totalamt<>invoice.totalrcvd) and (dbo.employ.name='''+man.Text+''') and dbo.invoice.billdate < '''+datetostr(date-d3.Value)+''' ) '+
'UNION ALL '+
'SELECT TOP 100 PERCENT dbo.sreturn.code AS 单据编号, '+
'dbo.sreturn.billdate AS 开单日期, dbo.client.shortname AS 往来单位, '+
'dbo.operator.opname AS 操作员, dbo.shop.name AS 部门, '+
'dbo.employ.name AS 业务员, dbo.sreturn.totalamt AS 金额, '+
'dbo.sreturn.totalrcvd AS 已收款, dbo.credtype.name AS 收款方式, ''销售退货单'' AS 单据类型 '+
'FROM dbo.sreturn INNER JOIN '+
'dbo.client ON dbo.sreturn.clientid = dbo.client.clientid INNER JOIN '+
'dbo.operator ON dbo.sreturn.opid = dbo.operator.opid INNER JOIN '+
'dbo.employ ON dbo.sreturn.exemanid = dbo.employ.empid INNER JOIN '+
'dbo.shop ON dbo.sreturn.shopid = dbo.shop.shopid INNER JOIN '+
'dbo.credence ON dbo.sreturn.credid = dbo.credence.credid INNER JOIN '+
'dbo.credtype ON dbo.credence.credtypeid = dbo.credtype.id WHERE (sreturn.totalamt<>sreturn.totalrcvd)and (dbo.employ.name='''+man.Text+''') and(dbo.sreturn.billdate < '''+datetostr(date-d3.Value)+''') '+
'order by 开单日期')