Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
FinFunction.sql
Package: 科思ERP部分源码及控件 [view]
Upload User: xgxgxg8
Upload Date: 2007-02-22
Package Size: 6882k
Code Size: 15k
Category:
ERP-EIP-OA-Portal
Development Platform:
Delphi
- Drop procedure sdRpt_FinFun
- ----财务取数
- create procedure sdRpt_FinData
- @FMonth varchar(6),
- @Glkm varchar(18),
- @Period varchar(18),
- @Type varchar(18),
- @PerInc int
- AS
- declare
- @AmtValue decimal(20, 2),
- @QtyValue decimal(20, 4)
- set @AmtValue = 0
- set @QtyValue = 0
- if @PerInc = -1
- begin
- select top 1 @FMonth = FCMonth from sdFc where FCMonth < @FMonth order by FcMonth Desc
- end
- else if @PerInc = 1
- begin
- select top 1 @FMonth = FCMonth from sdFc where FCMonth > @FMonth order by FcMonth
- end
- if @Period = '年初' ----年初
- begin
- if @Type = '金额' ----金额
- begin
- select top 1 @AmtValue = isNull(GlbBoyAmt, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- else if @Type = '外币金额'
- begin ----外币金额
- select top 1 @AmtValue = isNull(GlbBoyWbAmt, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- else if @Type = '数量'
- begin ----数量
- select top 1 @QtyValue = isNull(GlbBoyQty, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- end
- else if @Period = '期初' ----期初
- begin
- if @Type = '金额' ----金额
- begin
- select top 1 @AmtValue = isNull(GlbBopAmt, 0 )
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- else if @Type = '外币金额'
- begin
- select top 1 @AmtValue = isNull(GlbBopWbAmt, 0 )
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- else if @Type = '数量'
- begin
- select top 1 @QtyValue = isNull(GlbBopQty, 0 )
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- end
- else if @Period = '借方' ----本期借方金额
- begin
- if @Type = '金额'
- begin
- select top 1 @AmtValue = isNull(GlbDopAmt, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- else if @Type = '外币金额'
- begin
- select top 1 @AmtValue = isNull(GlbDopWbAmt, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- else if @Type = '数量'
- begin
- select top 1 @QtyValue = isNull(GlbDopQty, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- end
- else if @Period = '贷方'
- begin
- else if @Type = '金额' ----贷方金额
- begin
- select top 1 @AmtValue = isNull(GlbCopAmt, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- else if @Type = '外币金额' ----贷方外币金额
- begin
- select top 1 @AmtValue = isNull(GlbCopWbAmt, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- else if @Type = '数量' ----贷方数量
- begin
- select top 1 @QtyValue = isNull(GlbCopQty, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- end
- else if @Period = '本年' ----本年借方金额
- begin
- if @Type = '借方金额'
- begin
- select top 1 @AmtValue = isNull(GlbDoyAmt, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- else if @Type = '借方外币金额'
- begin
- select top 1 @AmtValue = isNull(GlbDoyWbAmt, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- else if @Type = '借方数量'
- begin
- select top 1 @QtyValue = isNull(GlbDoyQty, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- else if @Type = '贷方金额' ----本年贷方金额
- begin
- select top 1 @AmtValue = isNull(GlbCoyAmt, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- else if @Type = '贷方外币金额' ----
- begin
- select top 1 @AmtValue = isNull(GlbCoyWbAmt, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- else if @Type = '贷方数量' ---
- begin
- select top 1 @QtyValue = isNull(GlbCoyQty, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- end
- else if @Period = '累计' ----累计金额
- begin
- if @Type = '金额'
- begin
- select top 1 @AmtValue = isNull(GlbAoyAmt, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- else if @Type = '外币金额'
- begin
- select top 1 @AmtValue = isNull(GlbAoyWbAmt, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- else if @Type = '数量'
- begin
- select top 1 @QtyValue = isNull(GlbAoyQty, 0)
- from sdglb
- where GlbGlkm = @Glkm and GlbFMonth = @FMonth
- end
- end
- if @AmtValue <> 0
- select Value = @AmtValue
- else if @QtyValue <>0
- select Value = @QtyValue
- else
- select Value = 0
- -------------------------------------------------------------------------------
- Drop procedure sdRpt_FinSum
- create procedure sdRpt_FinSum
- @FMonth varchar(6),
- @Glkm varchar(18),
- @Glkm2 varchar(18),
- @Period varchar(18),
- @Type varchar(18),
- @PerInc int
- AS
- declare
- @AmtValue decimal(20, 2),
- @QtyValue decimal(20, 4)
- set @Glkm2 = @Glkm2+'99999999999999999'
- set @AmtValue = 0
- set @QtyValue = 0
- if @PerInc = -1
- begin
- select top 1 @FMonth = FCMonth from sdFc where FCMonth < @FMonth order by FcMonth Desc
- end
- else if @PerInc = 1
- begin
- select top 1 @FMonth = FCMonth from sdFc where FCMonth > @FMonth order by FcMonth
- end
- if @Period = '年初' ----年初
- begin
- if @Type = '金额' ----金额
- begin
- select @AmtValue = sum(GlbBoyAmt)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- else if @Type = '外币金额'
- begin ----外币金额
- select @AmtValue = sum(GlbBoyWbAmt)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- else if @Type = '数量'
- begin ----数量
- select @QtyValue = sum(GlbBoyQty)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- end
- else if @Period = '期初' ----期初
- begin
- if @Type = '金额' ----金额
- begin
- select @AmtValue = sum(GlbBopAmt)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- else if @Type = '外币金额'
- begin
- select @AmtValue = sum(GlbBopWbAmt)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- else if @Type = '数量'
- begin
- select @QtyValue = sum(GlbBopQty)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- end
- else if @Period = '本期借方金额' ----本期借方金额
- begin
- if @Type = '借方金额'
- begin
- select @AmtValue = sum(GlbDopAmt)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- else if @Type = '借方外币金额'
- begin
- select @AmtValue = sum(GlbDopWbAmt)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- else if @Type = '借方数量'
- begin
- select @QtyValue = sum(GlbDopQty)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- else if @Type = '贷方金额' ----贷方金额
- begin
- select @AmtValue = sum(GlbCopAmt)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- else if @Type = '贷方外币金额' ----贷方外币金额
- begin
- select @AmtValue = sum(GlbCopWbAmt)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- else if @Type = '贷方数量' ----贷方数量
- begin
- select @QtyValue = sum(GlbCopQty)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- end
- else if @Period = '本年' ----本年借方金额
- begin
- if @Type = '借方金额'
- begin
- select @AmtValue = sum(GlbDoyAmt)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- else if @Type = '借方外币金额'
- begin
- select @AmtValue = sum(GlbDoyWbAmt)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- else if @Type = '借方数量'
- begin
- select @QtyValue = sum(GlbDoyQty)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- else if @Type = '贷方金额' ----本年贷方金额
- begin
- select @AmtValue = sum(GlbCoyAmt)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- else if @Type = '贷方外币金额' ----
- begin
- select @AmtValue = sum(GlbCoyWbAmt)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- else if @Type = '贷方数量' ---
- begin
- select @QtyValue = sum(GlbCoyQty)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- end
- else if @Period = '累计' ----累计金额
- begin
- if @Type = '金额'
- begin
- select @AmtValue = sum(GlbAoyAmt)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- else if @Type = '外币金额'
- begin
- select @AmtValue = sum(GlbAoyWbAmt)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- else if @Type = '数量'
- begin
- select @QtyValue = sum(GlbAoyQty)
- from sdglb
- where GlbFMonth = @FMonth
- and glbGlkm in (select GlkmCode from sdGlkm
- where GlkmCode >= @Glkm and GlkmCode <= @Glkm2
- and glkmMx = 1)
- end
- end
- if @AmtValue <> 0
- select Value = @AmtValue
- else if @QtyValue <>0
- select Value = @QtyValue
- else
- select Value = 0
- -----------------------------------------------------------------------------
- exec sdRpt_FinData '200008', '102', '年初','金额', -1
- exec sdRpt_Findata '200007', '102', '年初','外币金额',0
- exec sdRpt_Findata '200007', '102', '年初','数量',0
- exec sdRpt_Findata '200007', '102', '期初','金额',0
- exec sdRpt_FinSum '200007', '102', '102','期初','金额',0
- exec sdRpt_FinFun '200007', '102', '期初','数量',0
- exec sdRpt_FinFun '200007', '102', '本年','借方金额',0
- exec sdRpt_FinFun '200007', '102', '本年','借方外币金额',0
- exec sdRpt_FinFun '200007', '102', '本年','借方数量',0
- exec sdRpt_FinFun '200007', '102', '本年','贷方金额',0
- exec sdRpt_FinFun '200007', '102', '本年','贷方外币金额',0
- exec sdRpt_FinFun '200007', '102', '本年','贷方数量',0
- exec sdRpt_FinFun '200007', '102', '本期','借方金额',0
- exec sdRpt_FinFun '200007', '102', '本期','借方外币金额',0
- exec sdRpt_FinFun '200007', '102', '本期','借方数量',0
- exec sdRpt_FinFun '200007', '102', '本期','贷方金额',0
- exec sdRpt_FinFun '200007', '102', '本期','贷方外币金额',0
- exec sdRpt_FinFun '200007', '102', '本期','贷方数量',0
- exec sdRpt_FinFun '200007', '102', '累计','金额',0
- exec sdRpt_FinFun '200007', '102', '累计','外币金额',0
- exec sdRpt_FinFun '200007', '102', '累计','数量',0
- select * from sdglb where glbglkm = '102' and glbfmonth = '200007'
- declare
- @Period varchar(18)
- select @period = '200007'
- select top 1 @period = FCMonth from sdFc where FCMonth < @Period order by FcMonth Desc
- select @period
- select sum(GlbBoyAmt)
- from sdglb
- where GlbGlkm >= '102' and GlbGlkm <= '105' and GlbFMonth = '200007'
- select * from sdglb order by glbfmonth, glbglkm