• 存储过程前台2


    代码
    Create
    代码
    ALTER proc [dbo].[P_ADDCalltype]
    (
    @ret int=-1 output,
    @nId int,
    @cName nvarchar(50),
    @cCode nvarchar(50),
    @nBaseTimeLong int=0,
    @nMinPrice money=0,
    @nUnitPrice money=0,
    @nUnitTime int=0,
    @nFreeTimeLong int=0,
    @nServicePrice money=0,
    @nServiceType int=0,
    @nAddPrice money=0,
    @nAddType int=0,
    @nHotelId int=0,
    @nCallTypeKindId int,
    @tag int
    )
    as
    begin
        
    if @tag=1
        
    begin
            
    if @cName<>'' and @cCode<>'' and 
    代码
    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go

    ALTER proc [dbo].[P_BackImprest]
    /*************************************************
    **AZ:TLM
    **FN:
    **TIME:
    *************************************************
    */
    (
        
    @ret int=-1 output,
        
    @nHotelId int,
        
    @nId int,
        
    @nUserId    int,
        
    @nJobTimeListId int,
        
    @cComputer nvarchar(100),
        
    @cRemark nvarchar(4000),
        
    @tag int
    )
    as
    begin
        
    if dbo.F_GetOptionLock(@nHotelId)=1
        
    begin
            
    return
        
    end

        
    declare @cContent nvarchar(1000)
        
    set @cContent=''
        
    declare @nLogTypeId int
        
    declare @nBillId int,@nPayTypeId int,@BackMoney decimal(18,2)
        
    if @tag=1        --bill
        begin
            
    if exists(select 1 from C_BillImprest where nRecordStateId=1 and nId=@nId and nHotelId =@nHotelId)
            
    begin
                
    select @nBillId=nBillId,@nPayTypeId=nPayTypeId,@BackMoney=nMoney from C_BillImprest 
                
    where nId=@nId and nHotelId =@nHotelId
                
    begin tran
                    
    exec P_LogBackImprest @ret output,@nHotelId,@nId,@nPayTypeId,@BackMoney,0,@nUserId,@nJobTimeListId,@cComputer,@cRemark,1
                    
    if @ret<>1
                    
    begin
                        
    set @ret=-1
                        
    rollback tran 
                        
    return
                    
    end
                    
    update C_BillImprest set nRecordStateId=2,
                    dCashTime
    =getdate(),nCashUserId=@nUserId,cCashComputer=@cComputer,cCashRemark=@cRemark
                    
    where nId=@nId and nHotelId =@nHotelId
                    
    if @@error <>0
                    
    begin
                        
    set @ret=-1
                        
    rollback tran
                        
    return
                    
    end
                    
    -----------------------------------------------------
                    -------Begin Log-------------------------------------
                    set @cContent='[收银押金整退] 退回押金: '+convert(nvarchar(50),@BackMoney)+' 元,该押金原付款方式为: '+[dbo].[F_GetPayTypeName](@nPayTypeId)+' 备注: '+@cRemark                
                    
    set @nLogTypeId=[dbo].[F_GetLogTypeId_Bill]()
                    
    exec P_DoLog @ret output,@nHotelId,@cComputer,@cContent,'C_BillImprest',@nUserId,null,null,@nBillId,null,@nLogTypeId
    --                2009-04-17
                    -------End Log---------------------------------------
                    -----------------------------------------------------
                    set @ret=1
                
    commit tran
            
    end
            
    else set @ret=-1
        
    end
        
    else if @tag=2    --guest
        begin
            
    if exists(select 1 from C_GuestImprest where nRecordStateId=1 and nId=@nId and nHotelId =@nHotelId)
            
    begin
                
    declare @nGuestId int
                
    select @nGuestId=nGuestId,@nPayTypeId=nPayTypeId,@BackMoney=nMoney from C_GuestImprest 
                
    where nId=@nId  and nHotelId =@nHotelId
                
    begin tran
                    
    exec P_LogBackImprest @ret output,@nHotelId,@nId,@nPayTypeId,@BackMoney,0,@nUserId,@nJobTimeListId,@cComputer,@cRemark,2
                    
    if @ret<>1
                    
    begin
                        
    set @ret=-1
                        
    rollback tran 
                        
    return
                    
    end
                    
    update C_GuestImprest set nRecordStateId=2,
                    dCashTime
    =getdate(),nCashUserId=@nUserId,cCashComputer=@cComputer,cCashRemark=@cRemark
                    
    where nId=@nId and nHotelId =@nHotelId
                    
    if @@error <>0
                    
    begin
                        
    set @ret=-1
                        
    rollback tran
                        
    return
                    
    end
                    
    -----------------------------------------------------
                    -------Begin Log-------------------------------------
                    set @cContent='[收银押金整退] 退回押金: '+convert(nvarchar(50),@BackMoney)+' 元,该押金原付款方式为: '+[dbo].[F_GetPayTypeName](@nPayTypeId)+' 备注: '+@cRemark                                
                    
    set @nLogTypeId=[dbo].[F_GetLogTypeId_Guest]()
                    
    exec P_DoLog @ret output,@nHotelId,@cComputer,@cContent,'C_GuestImprest',@nUserId,null,@nGuestId,null,null,@nLogTypeId
    --                2009-04-17
                    -------End Log---------------------------------------
                    -----------------------------------------------------
                    set @ret=1
                
    commit tran
            
    end
            
    else set @ret=-1
        
    end
    End

    (select 1 from C_Calltype where nHotelId=@nHotelId and cName=@cNameand not exists (select 1 from C_Calltype where nHotelId=@nHotelId and cCode=@cCodeand @nCallTypeKindId>0
            
    begin
                
    insert into C_Calltype(cName,cCode,nBaseTimeLong,nMinPrice,nUnitPrice,nUnitTime,nFreeTimeLong,nServicePrice,nServiceType,nAddPrice,nAddType,nHotelId,nCallTypeKindId)
                
    values(@cName,@cCode,@nBaseTimeLong,@nMinPrice,@nUnitPrice,@nUnitTime,@nFreeTimeLong,@nServicePrice,@nServiceType,@nAddPrice,@nAddType,@nHotelId,@nCallTypeKindId)
                
    set @ret=1
            
    end
        
    end
        
    else if @tag=2
        
    begin
            
    if @cName<>'' and @cCode<>'' and not exists (select 1 from C_Calltype where nHotelId=@nHotelId and cName=@cName and nId<>@nIdand not exists (select 1 from C_Calltype where nHotelId=@nHotelId and cCode=@cCode and nId<>@nIdand @nCallTypeKindId>0
            
    begin
                
    update C_Calltype
                
    set cName=@cName,cCode=@cCode,nBaseTimeLong=@nBaseTimeLong,nMinPrice=@nMinPrice,nUnitPrice=@nUnitPrice,nUnitTime=@nUnitTime,
                    nFreeTimeLong
    =@nFreeTimeLong,nServicePrice=@nServicePrice,nServiceType=@nServiceType,nAddPrice=@nAddPrice,nAddType=@nAddType,nCallTypeKindId=@nCallTypeKindId
                
    where nId=@nId and nHotelId=@nHotelId
                
    set @ret=1
            
    end
        
    end

    end
     
    PROCEDURE [dbo].[P_ADDAreaCode]
    (
        
    @ret int=-1 output,
        
    @nId int output,
        
    @cCode nvarchar(50),
        
    @nCallTypeId int,
        
    @cAddress nvarchar(50),
        
    @nHotelId int
    )
    AS 
    begin
        
    INSERT INTO [C_AreaCode]([cCode],[nCallTypeId],[cAddress],[nHotelId])
        
    VALUES(@cCode,@nCallTypeId,@cAddress,@nHotelId)

        
    SET @nId = @@IDENTITY
        
    SET @ret=1
    end
    代码
    ALTER function [dbo].[F_GetOptionLock]
    (
        
    @nHotelId int
    )
    returns bit
    /*************************************************

    **FN:
    **TIME:
    *************************************************
    */
    as
    begin
        
    declare @ret bit
        
    if exists(select 1 from A_SystemParms 
        
    where cName='OptionKey' and cType='bit' and nHotelId =@nHotelId)
        
    begin
            
    select @ret=cast(cValue as bitfrom A_SystemParms 
            
    where cName='OptionKey' and cType='bit' and nHotelId =@nHotelId
        
    end
        
    if @ret is null
        
    begin
         
    set @ret=0
        
    end
        
    return @ret
    end

  • 相关阅读:
    Golang map 的底层原理
    sync.map 原理分析
    系统库 SQL Server隐藏系统库Resource探究
    系统库 SQL Server隐藏系统库Resource Database探究
    SQLSERVER如何正确修改主机名和IP地址
    从 SQL Server 创建到 MySQL 的链接服务器
    关于SQLSERVER Model Database探究
    java 获取方法参数名字
    一个基于 JavaScript 的开源可视化图表库
    HTML颜色名称和颜色代码表
  • 原文地址:https://www.cnblogs.com/callbin/p/1634793.html
Copyright © 2020-2023  润新知