亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? viewandproc.sql

?? 這是用PB6開發的一個POS管理系統
?? SQL
?? 第 1 頁 / 共 4 頁
字號:
go

create procedure up_importcheck_update_by_checkviaamt
@VendorNo char(8),@Amt TAmt
as
declare @ImportNo TReceipt
declare @GoodsNo TGoods
declare @ImportQty TQty
declare @ExportQty TQty
declare @TaxPrice numeric(12,4)
declare @CheckQty TQty
declare @CheckAmt numeric(12,2)
declare @NoCheckQty numeric(12,3)
declare @NoCheckAmt numeric(12,2)

if @Amt > 0 
begin
	declare my_cursor cursor for
		select ImportNo,GoodsNo,isnull(ImportQty,0),isnull(ExportQty,0),isnull(TaxPrice,0),isnull(CheckQty,0),isnull(CheckAmt,0),isnull(NoCheckQty,0),isnull(NoCheckAmt,0) from Import_To_Check
		where VendorNo = @VendorNo and round((isnull(ImportQty,0) + isnull(ExportQty,0))*TaxPrice,2) > isnull(CheckAmt,0)
		order by ImportNo,GoodsNo
	OPEN my_cursor
	if @@error <> 0 return
	FETCH NEXT from my_cursor into @ImportNo,@GoodsNo,@ImportQty,@ExportQty,@TaxPrice,@CheckQty,@CheckAmt,@NoCheckQty,@NoCheckAmt
	while @@fetch_status = 0
   begin 
		if @Amt > (round((isnull(@ImportQty,0) + isnull(@ExportQty,0))*@TaxPrice,2) - @CheckAmt)  
		   begin
				update Import_To_Check
					set CheckQty = isnull(ImportQty,0) + isnull(ExportQty,0),
						 CheckAmt = round((isnull(ImportQty,0) + isnull(ExportQty,0))*TaxPrice,2),
						 NoCheckQty = 0,
						 NoCheckAmt = 0
   	   	WHERE current of my_cursor
				select @Amt = @Amt - @NoCheckAmt
   		end
		else
			begin
				update Import_To_Check
					SET CheckQty = isnull(CheckQty,0) + @Amt / TaxPrice,
						 CheckAmt = isnull(CheckAmt,0) + @Amt,
						 NoCheckQty = isnull(NoCheckQty,0) - @Amt / TaxPrice,
						 NoCheckAmt = isnull(NoCheckAmt,0) - @Amt
		      WHERE current of my_cursor
				select @Amt = 0
			   break
			end
		FETCH NEXT from my_cursor into @ImportNo,@GoodsNo,@ImportQty,@ExportQty,@TaxPrice,@CheckQty,@CheckAmt,@NoCheckQty,@NoCheckAmt
	end
end
close my_cursor
deallocate my_cursor
go

print 'up_importcheck_update_by_checkviaamt is created'
go



/*供貨商應付帳流水初始值錄入處理*/
if (select count(*) from sysobjects where name='up_payable_init') > 0
	drop procedure up_Payable_init
go

create procedure up_Payable_init 
@VendorNo TVendor,@businessdate datetime,@initamt TAmt 
as 
declare @tmp_value TAmt
declare @addamt TAmt
declare @subamt TAmt  

declare mycursor CURSOR FOR  
	select isnull(addamt,0),isnull(subamt,0)  from Payable
	where VendorNo = @VendorNo and businessdate > @businessdate order by businessdate
OPEN mycursor  
FETCH NEXT from mycursor into @addamt,@subamt
select @tmp_value = @initamt  
while @@fetch_status = 0 
   begin  
	 	select @tmp_value = @tmp_value + @addamt - @subamt
		update Payable set BalanceAmt = @tmp_value WHERE current of mycursor  
	 	FETCH NEXT from mycursor into @addamt,@subamt
   end 
close mycursor 
deallocate mycursor 
go

print 'up_Payable_Init is Created!'
go


/*進貨結算登帳*/
if(select count(*) from sysobjects where type='p' and name='up_import_account')>0
	drop proc up_import_account
go

create proc up_import_account
@saccount_date char(8),
@eaccount_date char(8)
as
declare @importno Treceipt
declare @vendorno Tvendor
declare @importdate Tdate
declare @goodsno Tgoods
declare @ntaxprice Tprice
declare @taxprice Tprice
declare @retailprice Tprice
declare @importqty Tqty
declare @taxamt TAmt
declare @balanceamt TAmt
set nocount on

declare my_cursor cursor for
select auditdate,ImportNo,VendorNo,Amt from import
		where convert(char(8),auditdate,112) >= @saccount_date
			and convert(char(8),auditdate,112) <= @eaccount_date and auditflag='1'
		order by auditdate 
open my_cursor
fetch next from my_cursor into @importdate,@importno,@vendorno,@Taxamt
while @@fetch_status = 0 
begin
	select @balanceamt = isnull(balanceamt,0) from Payable where id = (select max(id) from Payable where vendorno = @vendorno and businesstype<>'期初值')
	if @@rowcount = 0 select @balanceamt = 0
   insert into Payable(vendorno,businessdate,businesstype,invoiceno,addamt,balanceamt)
		values(@vendorno,@importdate,'進貨',@importno,@taxamt,@taxamt + @balanceamt)
	fetch next from my_cursor into @importdate,@importno,@vendorno,@Taxamt
end
close my_cursor
deallocate my_cursor

declare  import_account cursor for 
    select i.importno,i.vendorno,i.auditdate,d.goodsno,d.ntaxprice,d.taxprice,
	   d.retailprice,d.auditqty from import i,importdetail d
    where i.importno=d.importno and i.auditflag='1' 
          and convert(char(8),i.auditdate,112)>=@saccount_date
          and convert(char(8),i.auditdate,112)<=@eaccount_date
    order by i.auditdate asc
open import_account
fetch next from import_account 
into @importno,@vendorno,@importdate,@goodsno,@ntaxprice,@taxprice,@retailprice,@importqty
while @@fetch_status=0
begin
	if @importqty>0
		insert import_to_check(VendorNo,ImportNo,ImportDate,GoodsNo,NTaxPrice,
				       TaxPrice,RetailPrice,ImportQty,NoCheckQty,NoCheckAmt)
		values(@vendorno,@importno,@importdate,@goodsno,@ntaxprice,
		       @taxprice,@retailprice,@importqty,@importqty,round(@importqty*@Taxprice,2))
	else
		insert import_to_check(VendorNo,ImportNo,ImportDate,GoodsNo,NTaxPrice,
				       TaxPrice,RetailPrice,exportQty,NoCheckQty,NoCheckAmt)
		values(@vendorno,@importno,@importdate,@goodsno,@ntaxprice,
		       @taxprice,@retailprice,@importqty,@importqty,round(@importqty*@taxprice,2))

	exec up_importcheck_update_by_import @goodsno,@importno,@importqty,@vendorno

	fetch next from import_account 
	into @importno,@vendorno,@importdate,@goodsno,@ntaxprice,@taxprice,@retailprice,@importqty
end
close import_account
deallocate import_account
go

print 'up_Import_Account is Created!'
go

/*銷售結算登帳*/
if(select count(*) from sysobjects where type='p' and name='up_retail_account')>0
	drop proc up_retail_account
go

create proc up_retail_account
@saccount_date char(8),
@eaccount_date char(8)
as
declare @GoodsNo Tgoods
declare @RetailQty Tqty
set nocount on
begin transaction
declare retail_account cursor for
	select goodsno,sum(isnull(qty,0)) from deptretail 
        where convert(char(8),retaildate,112)>=@saccount_date
              and convert(char(8),retaildate,112)<=@eaccount_date
        group by goodsno

open retail_account
fetch next from retail_account into @goodsno,@retailqty
while @@fetch_status=0
begin
	exec up_importcheck_update_by_retail @goodsno,@retailqty
   if @@error <> 0
   begin
		rollback transaction
		close retail_account
		deallocate retail_account
      return
	end
	fetch next from retail_account into @goodsno,@retailqty
end
close retail_account
commit transaction
deallocate retail_account

go

print 'proc up_retail_account is Created! '
go

/* End for 結算   Procedure   */

if exists ( select * from sysobjects where name='up_UpdateOrderQtywithImportQty' and type='p')
  drop Proc up_UpdateOrderQtywithImportQty
go


/*訂貨數量*/
CREATE proc up_UpdateOrderQtywithImportQty
as
 Declare @Day int
 Declare @Inputdate char(8)

   if datepart(hh,getdate())<19 
   	Select @Day=-1
   else
   	Select @Day=0

   Select @InputDate=Convert(char(8),Dateadd(dd,@day,getdate()),112)
   
   Update a set a.OrderQty=b.Qty - a.OrderQty 
   from TopandBottom a,Vimport b
   Where a.goodsno=b.goodsno and a.deptNo=b.InputDept and b.auditDate=@Inputdate
   
   Update TopandBottom set OrderQty=0 where OrderQty <=0   
go

print ' up_UpdateOrderQtywithImportQty is created '
go

if exists ( select * from sysobjects where name='up_ProcessStat' and type='p')
  drop Proc up_ProcessStat
go

/*日終統計過程*/
CREATE PROCEDURE up_ProcessStat
AS

Declare @day int
Declare @Inputdate char(8)

   if datepart(hh,getdate())<19 
   	Select @Day=-1
   else
   	Select @Day=0

Select @InputDate=Convert(char(8),Dateadd(dd,@day,getdate()),112)


/*進貨統計*/
insert into importstat(deptno,groupno,classno,importdate,amt,ntaxamt,qty)
select a.inputdept,c.groupno,c.classno,convert(char(8),a.auditdate,112),sum(b.amt),sum(b.ntaxamt),sum(b.qty)
from goods c,import a,importdetail b
where a.importno=b.importno and b.goodsno=c.goodsno and convert(char(8),a.auditdate,112)=@inputdate and a.AuditFlag='1'
group by a.inputdept,c.groupno,c.classno,convert(char(8),a.auditdate,112)


/*品類進貨統計*/
insert into categoryimportstat(categoryno,importdate,amt,ntaxamt,qty)
select isnull(c.categoryno,'99999999'),convert(char(8),a.auditdate,112),sum(b.amt),sum(b.ntaxamt),sum(b.qty)
from goods c,import a,importdetail b
where a.importno=b.importno and b.goodsno=c.goodsno and convert(char(8),a.auditdate,112)=@inputdate and a.AuditFlag='1'
group by isnull(c.categoryno,'99999999'),convert(char(8),a.auditdate,112)


/*廠商進貨統計*/
insert into vendorimportstat(vendorno,importdate,amt,ntaxamt,qty)
select isnull(c.vendorno,'00000000'),convert(char(8),a.auditdate,112),sum(b.amt),sum(b.ntaxamt),sum(b.qty)
from goods c,import a,importdetail b
where a.importno=b.importno and b.goodsno=c.goodsno and convert(char(8),a.auditdate,112)=@inputdate and a.AuditFlag='1'
group by isnull(c.vendorno,'00000000'),convert(char(8),a.auditdate,112)


/*配送統計*/
insert into allocstat(deptno,groupno,classno,alloctdate,amt,ntaxamt,qty)
select a.destdept,c.groupno,c.classno,convert(char(8),a.auditdate,112),sum(b.amt),sum(b.ntaxamt),sum(b.qty)
from alloc a,allocdetail b,goods c
where a.allocno=b.allocno and b.goodsno=c.goodsno and convert(char(8),a.auditdate,112)=@inputdate and a.AuditFlag='1'
group by a.destdept,c.groupno,c.classno,convert(char(8),a.auditdate,112)



/*品類銷售統計*/
insert into categoryretailstat(categoryno,retaildate,retailmode,taxratio,amt,costamt,disamt)
select isnull(c.categoryno,'99999999'),convert(char(8),b.retaildate,112),isnull(c.retailmode,'0'),c.taxratio,sum(b.amt),sum(b.costamt),sum(b.disamt)
from goods c,deptretail b
where b.goodsno=c.goodsno and convert(char(8),b.retaildate,112)=@inputdate 
group by isnull(c.categoryno,'99999999'),convert(char(8),b.retaildate,112),c.retailmode,c.taxratio


/*廠商銷售統計*/
insert into vendorretailstat(vendorno,retaildate,retailmode,taxratio,amt,costamt,disamt)
select isnull(c.vendorno,'9999999999'),convert(char(8),b.retaildate,112),isnull(c.retailmode,'0'),isnull(c.taxratio,0),sum(b.amt),sum(b.costamt),sum(b.disamt)
from goods c,deptretail b
where b.goodsno=c.goodsno and convert(char(8),b.retaildate,112)=@inputdate
group by c.vendorno,convert(char(8),b.retaildate,112),isnull(c.retailmode,'0'),isnull(c.taxratio,0)


/*銷售統計*/

insert into retailstat(deptno,GroupNo,ClassNO,taxRatio,RetailMode,RetailDate,Amt,CostAmt,DisAmt,Qty) 
select b.deptno,c.groupno,c.classno,isnull(c.taxratio,0),isnull(c.retailmode,'0'),convert(char(8),b.retaildate,112),sum(b.amt),sum(b.costamt),sum(b.disamt),sum(b.qty)
from goods c,deptretail b
where c.goodsno=b.goodsno and convert(char(8),b.retaildate,112)=@inputdate 
group by b.deptno,c.groupno,c.classno,isnull(c.taxratio,0),isnull(c.retailmode,'0'),convert(char(8),b.retaildate,112)


go

print 'up_processStat is Created!'
go

if exists ( select * from sysobjects where name='up_InserthRetailFromRetail' and type='p')
  drop Proc up_InserthRetailFromRetail
go

CREATE PROCEDURE up_InserthRetailFromRetail 
AS
 Declare @day Int
 if datepart(hh,getdate())<19 
    Select @day=-1
 else
    Select @day=0

 if exists ( select 1 from hRetail Where Convert(char(8),InputDate,112)=Convert(char(8),DAteAdd(dd,@Day,Getdate()),112)) Return

 Insert hRetail
	 ( GoodsNo,DeptNo,SaleMan,Casher,PosNo,InvoiceNo,ReceiptNo,BusinessFlag,PayMode,
	  CustNo,Qty,Amt,DisCount,RetailPrice,CostPrice,DisAmt,BatchNo,ud1,ud2,ud3,ud4,inputdate) 
Select GoodsNo,DeptNo,SaleMan,Casher,PosNo,InvoiceNo,ReceiptNo,BusinessFlag,PayMode,
	  CustNo,Qty,Amt,DisCount,RetailPrice,CostPrice,DisAmt,BatchNo,ud1,ud2,ud3,ud4,inputdate
From Retail
Where Convert(char(8),inputdate,112)=Convert(char(8),dateadd(dd,@day,getdate()),112)

go

print 'proc up_InserthRetailFromRetail is Created!'
go

if exists ( select * from sysobjects where name='up_InsertCasherReport' and type='p')
  drop Proc up_InsertCasherReport
go

CREATE Proc up_InsertCasherreport 
 as
 Declare @day Int
 if datepart(hh,getdate())<19 
    Select @day=-1
 else
    Select @day=0

 Insert CasherReport (Casher,RetailDate,PayMode,Amt,DisAmt)
 select casher,Max(InputDate),paymode,sum(amt),sum(DisAmt)
 From PosRetail
 Where Convert(char(8),InputDate,112)=Convert(char(8),DAteAdd(dd,@Day,Getdate()),112)
 Group by Casher,PayMode

go

print ' proc up_insertCasherReport is created!'
go


if exists ( select * from sysobjects where name='up_ProcessDayEnd' and type='p')
  drop Proc up_ProcessDayEnd
go

/*日終處理過程*/
CREATE PROCEDURE up_ProcessDayEnd AS
Declare @mysql varchar(300)

Declare c1 cursor for select ProcessSql from ProcessDayEnd where ProcessFlag='1'
Open c1
Fetch c1 into @Mysql

While @@Fetch_Status=0
  begin
    Execute @Mysql
    Fetch c1 into @mysql
  end
close c1
deallocate c1
go

print 'up_ProcessDayEnd is created!'
go

Insert ProcessDayEnd (processsql,processflag,Remark)
Values ('ProcessPosAndSuspendRetail','1',null)
go

Insert ProcessDayEnd (processsql,processflag,Remark)
values ('Up_insertCasherReport','1',null)
go

Insert ProcessDayEnd (ProcessSql,processFlag,Remark)
Values ('Up_InserthRetailFromRetail','1',null)
go

Insert ProcessDayEnd (ProcessSql,processFlag,Remark)
Values ('Up_ProcessStat','1',null)
go



/* End Create Procedure */









?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91国产丝袜在线播放| 在线视频一区二区免费| 色一情一乱一乱一91av| 日韩一区二区三区四区| 亚洲美女淫视频| 国产福利一区二区三区视频在线 | 欧美激情综合在线| 午夜免费久久看| 婷婷成人综合网| 一区二区理论电影在线观看| 日韩电影网1区2区| 久久不见久久见免费视频7| 在线视频观看一区| 经典三级一区二区| 蜜桃视频在线观看一区二区| 国产九九视频一区二区三区| 国产美女精品人人做人人爽 | 亚洲国产岛国毛片在线| 欧美经典三级视频一区二区三区| 一二三区精品福利视频| 国产精品1024| 国产欧美日韩一区二区三区在线观看| 国产成人午夜精品5599 | 亚洲日本韩国一区| 精品盗摄一区二区三区| 日韩欧美高清一区| 欧美日韩另类国产亚洲欧美一级| 日韩极品在线观看| 久久蜜桃av一区精品变态类天堂 | 性欧美疯狂xxxxbbbb| 精品国产一区二区三区久久久蜜月 | 国产精品小仙女| 久久久久久久国产精品影院| 26uuu久久综合| 国产欧美一区二区精品性色| 亚洲综合自拍偷拍| 成人精品免费看| 1024成人网| 欧美人xxxx| 午夜精品成人在线| 2023国产精品视频| 成人免费不卡视频| 国产调教视频一区| 一区二区三区日韩在线观看| 亚洲国产三级在线| 国产专区欧美精品| 欧美性生活大片视频| 久久久五月婷婷| 亚洲人成伊人成综合网小说| 成人国产精品视频| 欧美精品v日韩精品v韩国精品v| 蜜臀av国产精品久久久久| 奇米影视一区二区三区| 国产成人精品一区二区三区四区 | 久久精品国产一区二区三区免费看| 国产乱人伦偷精品视频免下载| 日韩一级精品视频在线观看| 99re成人精品视频| 一区二区三区欧美| ww亚洲ww在线观看国产| 久久精品国产亚洲aⅴ| 6080午夜不卡| 亚洲一级片在线观看| 在线视频一区二区三| 水蜜桃久久夜色精品一区的特点| 亚洲成人在线观看视频| 欧美性受xxxx| 麻豆国产精品官网| 国内精品不卡在线| 在线播放/欧美激情| 国产精品免费久久| 欧美亚洲国产一区二区三区va| 99精品热视频| 欧美日韩亚洲另类| 国产精品美女久久久久aⅴ| 国产一二三精品| 欧美国产日韩一二三区| 欧美日韩不卡一区二区| 99久久精品国产一区二区三区| |精品福利一区二区三区| 国产三级欧美三级日产三级99 | 日韩国产精品久久久久久亚洲| 日韩精品资源二区在线| 色综合色狠狠综合色| 一区二区国产视频| 精品视频色一区| 成人天堂资源www在线| 亚洲精品免费在线播放| 日本福利一区二区| 日韩高清不卡在线| 中文字幕在线不卡国产视频| 国产激情一区二区三区桃花岛亚洲| 成人动漫在线一区| 亚洲欧美在线视频观看| 欧美成人精品1314www| 99久久久精品| 久久亚洲精精品中文字幕早川悠里 | 成人午夜免费电影| 91蜜桃视频在线| 国产精品一区二区果冻传媒| 午夜精品福利一区二区三区av| 欧美日韩中文字幕一区| 在线观看亚洲专区| 欧美zozozo| 亚洲成人第一页| 国产成人无遮挡在线视频| 欧洲人成人精品| 337p日本欧洲亚洲大胆精品| 亚洲一级二级三级在线免费观看| 国产精品久久久爽爽爽麻豆色哟哟| 成人高清视频在线| 美女高潮久久久| 日韩精品久久理论片| 自拍av一区二区三区| 久久久久久久久伊人| 精品国产青草久久久久福利| 精品福利一区二区三区免费视频| 欧美日韩免费不卡视频一区二区三区 | 欧美日韩精品专区| 欧美视频一区二区三区四区 | 午夜精品久久久久久久99水蜜桃| 精品国产乱码久久久久久久久| 日韩欧美在线观看一区二区三区| 宅男噜噜噜66一区二区66| ...xxx性欧美| 97精品久久久久中文字幕 | 精品成人a区在线观看| 日韩av午夜在线观看| 欧美人妇做爰xxxⅹ性高电影| 国产午夜精品一区二区三区视频| 精品成人一区二区| 久久香蕉国产线看观看99| 国产精品国产三级国产普通话99 | 国产在线国偷精品产拍免费yy| 久久久久久久久99精品| 国产精品不卡在线观看| 91老师片黄在线观看| 91麻豆成人久久精品二区三区| 国产传媒日韩欧美成人| www.欧美色图| 精品视频资源站| 精品国产99国产精品| 国产精品理伦片| 一级精品视频在线观看宜春院| 亚洲第一成人在线| 精品一区二区三区久久| 波多野洁衣一区| 777精品伊人久久久久大香线蕉| 欧美xfplay| 亚洲欧洲av一区二区三区久久| 伊人一区二区三区| 精品一区二区精品| 欧美日韩夫妻久久| 国产精品网站在线观看| 午夜激情一区二区三区| 国产精品一区二区在线观看不卡 | 日韩亚洲欧美综合| 中文字幕一区二区三区不卡在线| 中文字幕不卡在线观看| 一区二区三区不卡在线观看| 免费观看在线综合| 一本大道久久a久久精二百| 欧美不卡123| 一区二区不卡在线视频 午夜欧美不卡在| 亚洲二区在线视频| 99热这里都是精品| 欧美电影免费提供在线观看| 一区二区三区在线视频观看| 激情欧美日韩一区二区| 欧美日韩精品欧美日韩精品一 | 亚洲欧美在线另类| 久久超级碰视频| 欧美日韩不卡在线| 亚洲精品免费在线播放| 粉嫩一区二区三区性色av| 日韩视频在线一区二区| 夜夜亚洲天天久久| 99在线热播精品免费| 久久久午夜精品理论片中文字幕| 一区二区三区在线观看动漫| 国产69精品久久777的优势| 欧美成人a∨高清免费观看| 午夜影院久久久| 欧美性受xxxx黑人xyx| 亚洲免费视频成人| 99久久精品国产一区| 中文字幕精品综合| 国内精品国产三级国产a久久 | 亚洲精品国产精华液| 97久久精品人人澡人人爽| 国产喷白浆一区二区三区| 国产真实精品久久二三区| 精品国产一区二区三区四区四| 亚洲a一区二区| 欧美日韩不卡一区二区| 日韩电影在线一区二区三区| 欧美日韩一区在线观看| 亚洲福利一二三区| 欧美卡1卡2卡| 免费久久精品视频|