求即时库存查询源码!
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了求即时库存查询源码!相关的知识,希望对你有一定的参考价值。
要求:
ASP+ACCESS 或 php+ACCESS
管理员可入库商品编号,名称,上传图片,及时库存
可以建立会员账号,但只能查询及时库存
简单点来说就是一个即时库存入库与查询,可以增加商品库存(名称,编号,图片,备注)可以设置账号让会员登陆,但是只能查询库存,无法增加删除库存
满意在加200分
EXEC CheckInventory
2、我们进入SQL企业管理器,也不难得到CheckInventory的详细代码[K/310.1]
CREATE Procedure CheckInventory
as
Declare @CurYear Int, --当前年份
@CurPeriod int, --起始的会计期间
@StartPeriod SmallInt, --启用期间
@NowPeriod Smallint, --当前期间
@StartTime DateTime, --期间开始日期
@EndTime DateTime, --期间结束日期
@DiffCount Decimal(28,0) --计算是否有差异数量
--2.取出当前年份
SELECT @CurPeriod=FValue FROM t_Systemprofile WHERE FKey=\'CurrentPeriod\' And FCategory=\'IC\'
SELECT @CurYear=FValue FROM t_Systemprofile WHERE FKey=\'CurrentYear\' And FCategory=\'IC\'
--3.取出当前期间的起始日期
EXEC GetPeriodStartEnd @CurPeriod,@StartTime output,@EndTime output
SELECT FItemID,FStockID,FBatchNo,FStockPlaceID,case when FKFDate is null then \'\' else convert(varchar(10),FKFDate,120) End as FKFDate,ISNULL(FKFPeriod,\'\') as FKFPeriod,
Sum(FBegQty) As FQty ,0 As FQtyLock Into #RealTimeQty
FROM ICInvBal WHERE FPeriod=@CurPeriod And FYear=@CurYear
Group By FItemID,FStockID,FBatchNo,FStockPlaceID,FKFDate,FKFPeriod
Having sum(FBegQty)<>0
--SELECT FItemID,FStockID,FBatchNo,FQty FROM #RealTimeQty
Insert Into #RealTimeQty
SELECT t1.FItemID,t2.FDCStockID As FStockID,IsNull(t1.FBatchNO,\'\'),ISNULL(t1.FDCSPID,\'\') as FStockPlaceID, case when FKFDate is null then \'\' else convert(varchar(10),FKFDate,120) end ,ISNULL(t1.FKFPeriod,\'\'),
Sum(t1.FQty) As FQty,0 As FQtyLock
FROM ICStockBillEntry t1,ICStockBill t2
WHERE t1.FInterID=t2.FInterID And (t2.FCheckerID>0 or t2.FCheckerID <0 or FUpStockWhenSave=1)
And t2.FCancelLation=0
And t2.FTranType In (1,2,5,10,40,41) And FDate>=@StartTime
Group By t1.FItemID,t2.FDCStockID,t1.FBatchNo,t1.FDCSPID,t1.FKFDate,t1.FKFPeriod
......[以下代码省略]
3、我们也不难看出其中几个参数的意思
@CurYear Int, --当前年份
@CurPeriod int, --起始的会计期间 [原代码注释可能有歧义,应为当前期间,当然,也可以解释为校对即时库存的起始期间]
@StartPeriod SmallInt, --启用期间 [该参数基本没有用]
@NowPeriod Smallint, --当前期间 [源代码注释错了,该参数基本没有用]
@StartTime DateTime, --期间开始日期
@EndTime DateTime, --期间结束日期[该参数基本没有用]
@DiffCount Decimal(28,0) --计算是否有差异数量
除了几个没有使用的参数外,其他几个重要的参数就是时间节点了。
从SQL代码可以看出,“校对”即时库存的功能应该就是从当前期间的第一天开始的。
4、我们是否可以经过改进,来控制校对即时库存的起始点呢?应该是可以的。
CREATE Procedure CheckInventoryEX
@CurYear Int=0, --起始年份
@CurPeriod int=0, --起始会计期间
as
Declare @StartPeriod SmallInt, --启用期间
@NowPeriod Smallint, --当前期间
@StartTime DateTime, --期间开始日期
@EndTime DateTime, --期间结束日期
@DiffCount Decimal(28,0) --计算是否有差异数量
--2.取出当前年份
if @CurPeriod<=0 or @CurPeriod>12
begin
SELECT @CurPeriod=FValue FROM t_Systemprofile WHERE FKey=\'CurrentPeriod\' And FCategory=\'IC\'
end
if @CurYear<=0
begin
SELECT @CurYear=FValue FROM t_Systemprofile WHERE FKey=\'CurrentYear\' And FCategory=\'IC\'
end
--3.取出当前期间的起始日期
EXEC GetPeriodStartEnd @CurPeriod,@StartTime output,@EndTime output
SELECT FItemID,FStockID,FBatchNo,FStockPlaceID,case when FKFDate is null then \'\' else convert(varchar(10),FKFDate,120) End as FKFDate,ISNULL(FKFPeriod,\'\') as FKFPeriod,
Sum(FBegQty) As FQty ,0 As FQtyLock Into #RealTimeQty
FROM ICInvBal WHERE FPeriod=@CurPeriod And FYear=@CurYear
Group By FItemID,FStockID,FBatchNo,FStockPlaceID,FKFDate,FKFPeriod
Having sum(FBegQty)<>0
--SELECT FItemID,FStockID,FBatchNo,FQty FROM #RealTimeQty
Insert Into #RealTimeQty
SELECT t1.FItemID,t2.FDCStockID As FStockID,IsNull(t1.FBatchNO,\'\'),ISNULL(t1.FDCSPID,\'\') as FStockPlaceID, case when FKFDate is null then \'\' else convert(varchar(10),FKFDate,120) end ,ISNULL(t1.FKFPeriod,\'\'),
Sum(t1.FQty) As FQty,0 As FQtyLock
FROM ICStockBillEntry t1,ICStockBill t2
WHERE t1.FInterID=t2.FInterID And (t2.FCheckerID>0 or t2.FCheckerID <0 or FUpStockWhenSave=1)
And t2.FCancelLation=0
And t2.FTranType In (1,2,5,10,40,41) And FDate>=@StartTime
Group By t1.FItemID,t2.FDCStockID,t1.FBatchNo,t1.FDCSPID,t1.FKFDate,t1.FKFPeriod
参考资料:http://community.kingdee.com/pages/fengqiao/blog/archive/2006/12/28/174966.aspx
参考技术A 可以到http://www.jb51.net/codes/16126.html页面去下载或者直接复制下列地址链接,导入迅雷即可下载或者留下邮箱发送给你!
http://wt.jb51.net/200905/yuanma/ygshop.rar
以上是关于求即时库存查询源码!的主要内容,如果未能解决你的问题,请参考以下文章