zoukankan      html  css  js  c++  java
  • 七、K3 WISE 开发插件《Update字段级更新触发器

    审核成功触发,是一个比较典型的场景。需要用到update触发器,跟踪到审核状态的变化。

    引用的源码《采购检验单审核后反写收料通知单》,其中采购检验单是BOS自定义单据。

    if (object_id('bobang_tgr_check_update', 'TR') is not null)
        drop trigger bobang_tgr_check_update
    go
    create trigger cl_tgr_check_update
    on bobang_bos_check
    after update
    as 
    declare @FID int
    declare @FMultiCheckStatus  varchar(100)
    declare @FAuxQtyPass float --合格数量
    declare @FQtyPass float --基本单位合格数量
    declare @FAuxNotPassQty float --不合格数量
    declare @FNotPassQty float --基本单位不合格数量
    declare @FAuxConPassQty float --让步接收数量
    declare @FConPassQty float --基本单位让步接收数量
    declare @FID_Src bigint --源单ID
    declare @FEntryID_SRC bigint --源单FEntryID
    
    select @FID=FID,@FMultiCheckStatus=FMultiCheckStatus
    from inserted
    
    --审核时
    if update(FMultiCheckStatus) and @FMultiCheckStatus=16 
    begin 
        declare mycursor cursor for 
        select FAuxPassQty,FPassQty,FAuxUnPassQty,FUnPassQty,FAuxConcessQty,FConcessQty,FID_Src,FEntryID_Src 
        from bobang_bos_checkentry where FID=@FID
        open mycursor  
        fetch next from mycursor 
        into @FAuxQtyPass,@FQtyPass,@FAuxNotPassQty,@FNotPassQty,@FAuxConPassQty,@FConPassQty,@FID_Src,@FEntryID_SRC
        while (@@fetch_status=0) 
        begin 
            update t1 
            set t1.FAuxQtyPass=t1.FAuxQtyPass+isnull(@FAuxQtyPass,0),
            t1.FQtyPass=t1.FQtyPass+isnull(@FQtyPass,0),
            t1.FAuxNotPassQty=t1.FAuxNotPassQty+isnull(@FAuxNotPassQty,0),
            t1.FNotPassQty=t1.FNotPassQty+isnull(@FNotPassQty,0),
            t1.FAuxConPassQty=t1.FAuxConPassQty+isnull(@FAuxConPassQty,0),
            t1.FConPassQty=t1.FConPassQty+isnull(@FConPassQty,0)
            from POInStockEntry t1 
            left join POInStock t2 on t1.FInterID=t2.FInterID
            where t1.FInterID=@FID_Src and t1.FEntryID=@FEntryID_SRC
            and t2.FTranType=72
        fetch next from mycursor 
        into @FAuxQtyPass,@FQtyPass,@FAuxNotPassQty,@FNotPassQty,@FAuxConPassQty,@FConPassQty,@FID_Src,@FEntryID_SRC
        end 
        close mycursor 
        DEALLOCATE mycursor 
    end 
    
    --驳回前检查
    declare @isTuiLiao int
    declare @isRuKu int
    if update(FMultiCheckStatus) and @FMultiCheckStatus=4 
    begin 
        declare mycursor cursor for 
        select FAuxPassQty,FPassQty,FAuxUnPassQty,FUnPassQty,FAuxConcessQty,FConcessQty,FID_Src,FEntryID_Src 
        from bobang_bos_checkentry where FID=@FID
        open mycursor  
        fetch next from mycursor 
        into @FAuxQtyPass,@FQtyPass,@FAuxNotPassQty,@FNotPassQty,@FAuxConPassQty,@FConPassQty,@FID_Src,@FEntryID_SRC
        while (@@fetch_status=0) 
        begin 
            select @isTuiLiao=COUNT(*) from POInStockEntry 
            where FSourceTrantype=72 and  FSourceInterId=@FID_Src and FSourceEntryID=@FEntryID_SRC
            if @isTuiLiao>0
            begin
                raiserror ('已下推退料通知单,不能反审核!',16,1)
                rollback tran    
            end
            
            select @isRuKu=COUNT(*) from ICStockBillEntry 
            where FSourceTrantype=72 and  FSourceInterId=@FID_Src and FSourceEntryID=@FEntryID_SRC
            if @isTuiLiao>0
            begin
                raiserror ('已下推外购入库单,不能反审核!',16,1)
                rollback tran    
            end
            
        fetch next from mycursor 
        into @FAuxQtyPass,@FQtyPass,@FAuxNotPassQty,@FNotPassQty,@FAuxConPassQty,@FConPassQty,@FID_Src,@FEntryID_SRC
        end 
        close mycursor 
        DEALLOCATE mycursor 
    end
    
    --驳回初始时
    if update(FMultiCheckStatus) and @FMultiCheckStatus=2 
    begin 
        declare mycursor cursor for 
        select FAuxPassQty,FPassQty,FAuxUnPassQty,FUnPassQty,FAuxConcessQty,FConcessQty,FID_Src,FEntryID_Src 
        from bobang_bos_checkentry where FID=@FID
        open mycursor  
        fetch next from mycursor 
        into @FAuxQtyPass,@FQtyPass,@FAuxNotPassQty,@FNotPassQty,@FAuxConPassQty,@FConPassQty,@FID_Src,@FEntryID_SRC
        while (@@fetch_status=0) 
        begin 
            update t1 
            set t1.FAuxQtyPass=t1.FAuxQtyPass-isnull(@FAuxQtyPass,0),
            t1.FQtyPass=t1.FQtyPass-isnull(@FQtyPass,0),
            t1.FAuxNotPassQty=t1.FAuxNotPassQty-isnull(@FAuxNotPassQty,0),
            t1.FNotPassQty=t1.FNotPassQty-isnull(@FNotPassQty,0),
            t1.FAuxConPassQty=t1.FAuxConPassQty-isnull(@FAuxConPassQty,0),
            t1.FConPassQty=t1.FConPassQty-isnull(@FConPassQty,0)
            from POInStockEntry t1 
            left join POInStock t2 on t1.FInterID=t2.FInterID
            where t1.FInterID=@FID_Src and t1.FEntryID=@FEntryID_SRC
            and t2.FTranType=72
        fetch next from mycursor 
        into @FAuxQtyPass,@FQtyPass,@FAuxNotPassQty,@FNotPassQty,@FAuxConPassQty,@FConPassQty,@FID_Src,@FEntryID_SRC
        end 
        close mycursor 
        DEALLOCATE mycursor 
    end 
  • 相关阅读:
    使用Lua编写Wireshark插件解析KCP UDP包,解析视频RTP包
    开源自己用python封装的一个Windows GUI(UI Automation)自动化工具,支持MFC,Windows Forms,WPF,Metro,Qt
    2019 WebRtc AudioMixer混音流程
    记录一次定位视频通话 音视频卡顿的原因分析过程。
    C++标准库里自带的数值类型和字符串互相转换函数
    C++ raw string literal
    使用multiprocessing解决PyMuPDF不支持多线程加载导致的界面卡死无响应问题,及一个PyQt5实现的简易PDF阅读器例子
    使用ctypes调用系统C API函数需要注意的问题,函数参数中有指针或结构体的情况下最好不要修改argtypes
    使用python uiautomation从钉钉网页版提取公司所有联系人信息
    使用python UIAutomation从QQ2017(v8.9)群界面获取所有群成员详细资料,
  • 原文地址:https://www.cnblogs.com/star-studio/p/7483908.html
Copyright © 2011-2022 走看看