|
|
|
|
|
insert into tSysBillType(BillCode,BillName,BillGrp,IsRule,NoLength,IsPrefix,PrefixLen,PrefixNo,IsDate,DateFmt,SerialLen,YearNo,MonthNo,DayNo,MaxSerial,BillHeadTbl,IsOrgPrefix,GID,IsEmpPrefix)values('WM01','入库计划','仓储管理','1',18,'1',4,'RKPL','1','YYYYMMDD',6,'2020','01','01',57,'OP_WMS_IN_PLAN','0','7D83C9B6-05B0-4BA7-A4D4-E64C4304B070',NULL)
|
|
|
insert into tSysBillType(BillCode,BillName,BillGrp,IsRule,NoLength,IsPrefix,PrefixLen,PrefixNo,IsDate,DateFmt,SerialLen,YearNo,MonthNo,DayNo,MaxSerial,BillHeadTbl,IsOrgPrefix,GID,IsEmpPrefix)values('WM02','入库执行','仓储管理','1',18,'1',4,'RK','1','YYYYMMDD',6,'2020','01','01',57,'OP_WMS_IN_DO','0','AD960660-2861-44AD-9FE7-4C2287069BDF',NULL)
|
|
|
insert into tSysBillType(BillCode,BillName,BillGrp,IsRule,NoLength,IsPrefix,PrefixLen,PrefixNo,IsDate,DateFmt,SerialLen,YearNo,MonthNo,DayNo,MaxSerial,BillHeadTbl,IsOrgPrefix,GID,IsEmpPrefix)values('WM03','出库计划','仓储管理','1',18,'1',4,'CKPL','1','YYYYMMDD',6,'2020','01','01',57,'OP_WMS_OUT_PLAN','0','54FCB386-EFA3-4BF5-9E95-C3A39CC1E729',NULL)
|
|
|
insert into tSysBillType(BillCode,BillName,BillGrp,IsRule,NoLength,IsPrefix,PrefixLen,PrefixNo,IsDate,DateFmt,SerialLen,YearNo,MonthNo,DayNo,MaxSerial,BillHeadTbl,IsOrgPrefix,GID,IsEmpPrefix)values('WM04','出库执行','仓储管理','1',18,'1',4,'CK','1','YYYYMMDD',6,'2020','01','01',57,'OP_WMS_OUT_DO','0','FDB5A71E-91DB-41C2-B72B-66E5E13B9648',NULL)
|
|
|
insert into tSysBillType(BillCode,BillName,BillGrp,IsRule,NoLength,IsPrefix,PrefixLen,PrefixNo,IsDate,DateFmt,SerialLen,YearNo,MonthNo,DayNo,MaxSerial,BillHeadTbl,IsOrgPrefix,GID,IsEmpPrefix)values('WM05','过磅','仓储管理','1',18,'1',4,'GB','1','YYYYMMDD',6,'2020','01','01',57,'OP_WMS_GB','0','44553084-EEC3-4D36-8555-1109E6EE26EF',NULL)
|
|
|
insert into tSysBillType(BillCode,BillName,BillGrp,IsRule,NoLength,IsPrefix,PrefixLen,PrefixNo,IsDate,DateFmt,SerialLen,YearNo,MonthNo,DayNo,MaxSerial,BillHeadTbl,IsOrgPrefix,GID,IsEmpPrefix)values('WM06','移库','仓储管理','1',18,'1',4,'YK','1','YYYYMMDD',6,'2020','01','01',57,'OP_WMS_YK','0','CE7EEF24-E114-4302-B890-B6C6F37E4F49',NULL)
|
|
|
insert into tSysBillType(BillCode,BillName,BillGrp,IsRule,NoLength,IsPrefix,PrefixLen,PrefixNo,IsDate,DateFmt,SerialLen,YearNo,MonthNo,DayNo,MaxSerial,BillHeadTbl,IsOrgPrefix,GID,IsEmpPrefix)values('WM07','盘点','仓储管理','1',18,'1',4,'PD','1','YYYYMMDD',6,'2020','01','01',57,'OP_WMS_PD','0','C0D5DD8E-B9AE-4D15-B9E2-58A0DE483158',NULL)
|
|
|
insert into tSysBillType(BillCode,BillName,BillGrp,IsRule,NoLength,IsPrefix,PrefixLen,PrefixNo,IsDate,DateFmt,SerialLen,YearNo,MonthNo,DayNo,MaxSerial,BillHeadTbl,IsOrgPrefix,GID,IsEmpPrefix)values('WM08','费率协议','仓储管理','1',18,'1',4,'FL','1','YYYYMMDD',6,'2020','01','01',57,'OP_WMS_FEERATE','0','4AFEF44E-DC33-470F-86B6-A2B67FAA2957',NULL)
|
|
|
insert into tSysBillType(BillCode,BillName,BillGrp,IsRule,NoLength,IsPrefix,PrefixLen,PrefixNo,IsDate,DateFmt,SerialLen,YearNo,MonthNo,DayNo,MaxSerial,BillHeadTbl,IsOrgPrefix,GID,IsEmpPrefix)values('WM09','月结仓储费账单','仓储管理','1',18,'1',4,'MF','1','YYYYMMDD',6,'2020','01','01',57,'OP_WMS_FEEDUI_STORAGE','0','7A55DAF5-0D0D-4F09-85C3-ACC47A76E57F',NULL)
|
|
|
|
|
|
|
|
|
|
|
|
insert sys_billno_set(GID,OPLBNAME,RULEBLNO,RULEDATETYPE,BILLTYPE,COMPANYID,CREATEUSER,CREATETIME,ISEDIT,ISAUTO,CUSTOMHEAD) values( '7D83C9B6-05B0-4BA7-A4D4-E64C4304B070' , '入库计划' , '委托编号' , '业务日期' , 'WM01' , 'Comcab2d43f60454327af30a131fc1d3abd' , NULL , NULL , '1' , NULL , NULL )
|
|
|
insert sys_billno_set(GID,OPLBNAME,RULEBLNO,RULEDATETYPE,BILLTYPE,COMPANYID,CREATEUSER,CREATETIME,ISEDIT,ISAUTO,CUSTOMHEAD) values( 'AD960660-2861-44AD-9FE7-4C2287069BDF' , '入库执行' , '委托编号' , '业务日期' , 'WM02' , 'Comcab2d43f60454327af30a131fc1d3abd' , NULL , NULL , '1' , NULL , NULL )
|
|
|
insert sys_billno_set(GID,OPLBNAME,RULEBLNO,RULEDATETYPE,BILLTYPE,COMPANYID,CREATEUSER,CREATETIME,ISEDIT,ISAUTO,CUSTOMHEAD) values( '54FCB386-EFA3-4BF5-9E95-C3A39CC1E729' , '出库计划' , '委托编号' , '业务日期' , 'WM03' , 'Comcab2d43f60454327af30a131fc1d3abd' , NULL , NULL , '1' , NULL , NULL )
|
|
|
insert sys_billno_set(GID,OPLBNAME,RULEBLNO,RULEDATETYPE,BILLTYPE,COMPANYID,CREATEUSER,CREATETIME,ISEDIT,ISAUTO,CUSTOMHEAD) values( 'FDB5A71E-91DB-41C2-B72B-66E5E13B9648' , '出库执行' , '委托编号' , '业务日期' , 'WM04' , 'Comcab2d43f60454327af30a131fc1d3abd' , NULL , NULL , '1' , NULL , NULL )
|
|
|
insert sys_billno_set(GID,OPLBNAME,RULEBLNO,RULEDATETYPE,BILLTYPE,COMPANYID,CREATEUSER,CREATETIME,ISEDIT,ISAUTO,CUSTOMHEAD) values( '44553084-EEC3-4D36-8555-1109E6EE26EF' , '过磅' , '委托编号' , '业务日期' , 'WM05' , 'Comcab2d43f60454327af30a131fc1d3abd' , NULL , NULL , '1' , NULL , NULL )
|
|
|
insert sys_billno_set(GID,OPLBNAME,RULEBLNO,RULEDATETYPE,BILLTYPE,COMPANYID,CREATEUSER,CREATETIME,ISEDIT,ISAUTO,CUSTOMHEAD) values( 'CE7EEF24-E114-4302-B890-B6C6F37E4F49' , '移库' , '委托编号' , '业务日期' , 'WM06' , 'Comcab2d43f60454327af30a131fc1d3abd' , NULL , NULL , '1' , NULL , NULL )
|
|
|
insert sys_billno_set(GID,OPLBNAME,RULEBLNO,RULEDATETYPE,BILLTYPE,COMPANYID,CREATEUSER,CREATETIME,ISEDIT,ISAUTO,CUSTOMHEAD) values( 'C0D5DD8E-B9AE-4D15-B9E2-58A0DE483158' , '盘点' , '委托编号' , '业务日期' , 'WM07' , 'Comcab2d43f60454327af30a131fc1d3abd' , NULL , NULL , '1' , NULL , NULL )
|
|
|
insert sys_billno_set(GID,OPLBNAME,RULEBLNO,RULEDATETYPE,BILLTYPE,COMPANYID,CREATEUSER,CREATETIME,ISEDIT,ISAUTO,CUSTOMHEAD) values( '4AFEF44E-DC33-470F-86B6-A2B67FAA2957' , '费率协议' , '委托编号' , '业务日期' , 'WM08' , 'Comcab2d43f60454327af30a131fc1d3abd' , NULL , NULL , '1' , NULL , NULL )
|
|
|
insert sys_billno_set(GID,OPLBNAME,RULEBLNO,RULEDATETYPE,BILLTYPE,COMPANYID,CREATEUSER,CREATETIME,ISEDIT,ISAUTO,CUSTOMHEAD) values( '7A55DAF5-0D0D-4F09-85C3-ACC47A76E57F' , '月结仓储费账单' , '委托编号' , '业务日期' , 'WM09' , 'Comcab2d43f60454327af30a131fc1d3abd' , NULL , NULL , '1' , NULL , NULL )
|
|
|
|
|
|
--select newid()
|
|
|
|
|
|
insert into tSysBillType(BillCode,BillName,BillGrp,IsRule,NoLength,IsPrefix,PrefixLen,PrefixNo,IsDate,DateFmt,SerialLen,YearNo,MonthNo,DayNo,MaxSerial,BillHeadTbl,IsOrgPrefix,GID,IsEmpPrefix)values('WM10','库存信息','仓储管理','1',18,'1',4,'WMS','1','YYYYMMDD',4,'2020','01','01',57,'OP_WMS','0','C0778808-BFE9-4C39-9501-54A86950C212',NULL)
|
|
|
|
|
|
--delete from sys_billno_set where gid= 'C0778808-BFE9-4C39-9501-54A86950C212'
|
|
|
insert sys_billno_set(GID,OPLBNAME,RULEBLNO,RULEDATETYPE,BILLTYPE,COMPANYID,CREATEUSER,CREATETIME,ISEDIT,ISAUTO,CUSTOMHEAD) values( 'C0778808-BFE9-4C39-9501-54A86950C212' , '库存信息' , '委托编号' , '业务日期' , 'WM10' , 'Comcab2d43f60454327af30a131fc1d3abd' , NULL , NULL , '1' , NULL , NULL )
|
|
|
|
|
|
--select newid()
|
|
|
|
|
|
insert into tSysBillType(BillCode,BillName,BillGrp,IsRule,NoLength,IsPrefix,PrefixLen,PrefixNo,IsDate,DateFmt,SerialLen,YearNo,MonthNo,DayNo,MaxSerial,BillHeadTbl,IsOrgPrefix,GID,IsEmpPrefix)values('WM11','货权转移','仓储管理','1',18,'1',4,'WT','1','YYYYMMDD',4,'2020','01','01',57,'OP_WMS','0','8FBE0A35-BA8E-45AD-B0C4-3595CDB6B361',NULL)
|
|
|
|
|
|
--delete from sys_billno_set where gid= 'C0778808-BFE9-4C39-9501-54A86950C212'
|
|
|
insert sys_billno_set(GID,OPLBNAME,RULEBLNO,RULEDATETYPE,BILLTYPE,COMPANYID,CREATEUSER,CREATETIME,ISEDIT,ISAUTO,CUSTOMHEAD) values( '8FBE0A35-BA8E-45AD-B0C4-3595CDB6B361' , '货权转移' , '委托编号' , '业务日期' , 'WM11' , 'Comcab2d43f60454327af30a131fc1d3abd' , NULL , NULL , '1' , NULL , NULL )
|
|
|
|
|
|
insert into tSysBillType(BillCode,BillName,BillGrp,IsRule,NoLength,IsPrefix,PrefixLen,PrefixNo,IsDate,DateFmt,SerialLen,YearNo,MonthNo,DayNo,MaxSerial,BillHeadTbl,IsOrgPrefix,GID,IsEmpPrefix)values('WM12','移库','仓储管理','1',18,'1',4,'WMV','1','YYYYMMDD',4,'2020','01','01',57,'OP_WMS_MOVE','0','716451F8-88B8-4152-BC4E-5F3E2F6A6688',NULL)
|
|
|
|
|
|
--delete from sys_billno_set where gid= 'C0778808-BFE9-4C39-9501-54A86950C212'
|
|
|
insert sys_billno_set(GID,OPLBNAME,RULEBLNO,RULEDATETYPE,BILLTYPE,COMPANYID,CREATEUSER,CREATETIME,ISEDIT,ISAUTO,CUSTOMHEAD) values( '716451F8-88B8-4152-BC4E-5F3E2F6A6688' , '移库' , '委托编号' , '业务日期' , 'WM12' , 'Comcab2d43f60454327af30a131fc1d3abd' , NULL , NULL , '1' , NULL , NULL )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--delete from tSysBillType where gid= 'ADF75C64-EEF3-4F03-9689-D9A7B1C538DE'
|
|
|
|
|
|
--delete from sys_billno_set where gid= 'ADF75C64-EEF3-4F03-9689-D9A7B1C538DE'
|
|
|
insert into tSysBillType(BillCode,BillName,BillGrp,IsRule,NoLength,IsPrefix,PrefixLen,PrefixNo,IsDate,DateFmt,SerialLen,YearNo,MonthNo,DayNo,MaxSerial,BillHeadTbl,IsOrgPrefix,GID,IsEmpPrefix)values('WM13','区间库存统计报表','仓储管理','1',18,'1',4,'MF','1','YYYYMMDD',6,'2020','01','01',57,'OP_WMS_REPORT_TIMEZONES','0','ADF75C64-EEF3-4F03-9689-D9A7B1C538DE',NULL)
|
|
|
|
|
|
insert sys_billno_set(GID,OPLBNAME,RULEBLNO,RULEDATETYPE,BILLTYPE,COMPANYID,CREATEUSER,CREATETIME,ISEDIT,ISAUTO,CUSTOMHEAD) values( 'ADF75C64-EEF3-4F03-9689-D9A7B1C538DE' , '区间库存统计报表' , '委托编号' , '业务日期' , 'WM13' , 'Comcab2d43f60454327af30a131fc1d3abd' , NULL , NULL , '1' , NULL , NULL )
|
|
|
|
|
|
/****** Object: StoredProcedure [dbo].[sSysGetBillNo_new] Script Date: 2020/9/16 14:12:16 ******/
|
|
|
SET ANSI_NULLS ON
|
|
|
GO
|
|
|
|
|
|
SET QUOTED_IDENTIFIER ON
|
|
|
GO
|
|
|
|
|
|
|
|
|
alter PROCEDURE [dbo].[sSysGetBillNo_new]
|
|
|
( @ps_BillType varchar(4),
|
|
|
@ps_OrgCode varchar(100)='',
|
|
|
@ps_EmpCode varchar(100)='',
|
|
|
@ps_Date varchar(10)='',
|
|
|
@ps_BillNo varchar(20) output,
|
|
|
@ps_RefBillNo varchar(20)=Null --这个字段暂时没有使用
|
|
|
)
|
|
|
--WITH ENCRYPTION
|
|
|
AS
|
|
|
declare
|
|
|
@vs_TmpBillNo varchar(20),
|
|
|
@vs_IsUpdate varchar(1),
|
|
|
@vi_ID numeric(27,0),
|
|
|
@vi_ID_A numeric(27,0),
|
|
|
@vi_ID_B numeric(27,0),
|
|
|
@vi_Times integer,
|
|
|
@vi_DelaySec integer,
|
|
|
@vs_HeadTbl varchar(100),
|
|
|
@vs_NowDate varchar(10),
|
|
|
@vs_IsPrefix varchar(100),
|
|
|
@vi_PrefixLen integer,
|
|
|
@vs_PrefixNo varchar(100),
|
|
|
@vs_IsDate varchar(100),
|
|
|
@vi_DateLen integer,
|
|
|
@vs_DateFmt varchar(100),
|
|
|
@vi_SerialLen integer,
|
|
|
@vs_YearNo varchar(100),
|
|
|
@vs_MonthNo varchar(100),
|
|
|
@vs_DayNo varchar(100),
|
|
|
@vs_IsOrgPrefix varchar(100),
|
|
|
@vs_IsEmpPrefix varchar(100),
|
|
|
@vi_ii int,
|
|
|
@vi_MaxSerial integer,
|
|
|
@vs_dateNo varchar(10),
|
|
|
@vi_BillNoLength int,
|
|
|
@vi_BillHeadLength int,
|
|
|
@vs_BanksHead varchar(10),
|
|
|
@BsNo int
|
|
|
Begin
|
|
|
/*=================初始化变量=================*/
|
|
|
Set @vs_IsUpdate='0'
|
|
|
Set @ps_BillNo=null
|
|
|
Set @vs_TmpBillNo=''
|
|
|
if @ps_Date='' begin
|
|
|
Set @vs_NowDate=convert(varchar(10),getdate(),120)
|
|
|
end else
|
|
|
Set @vs_NowDate=left(@ps_Date,10)
|
|
|
|
|
|
/*=================取得单据号结构=================*/
|
|
|
If not exists(select BillCode from tSysBillType where BillCode=@ps_BillType)
|
|
|
Begin
|
|
|
return(-1)
|
|
|
End
|
|
|
|
|
|
Select @vs_IsPrefix=IsPrefix,@vi_PrefixLen=PrefixLen,@vs_PrefixNo=PrefixNo,
|
|
|
@vs_IsDate=IsDate,@vs_DateFmt=DateFmt,@vi_SerialLen=SerialLen,
|
|
|
@vs_YearNo=IsNull(YearNo,''),@vs_MonthNo=IsNull(MonthNo,''),@vs_DayNo=IsNull(DayNo,''),
|
|
|
@vi_MaxSerial=MaxSerial,@vs_HeadTbl=IsNull(BillHeadTbl,''),
|
|
|
@vs_IsOrgPrefix=IsOrgPrefix,@vs_IsEmpPrefix=IsEmpPrefix
|
|
|
from tSysBillType
|
|
|
where BillCode=@ps_BillType
|
|
|
|
|
|
/*=================如果要分组织生成(ww)=================*/
|
|
|
if @vs_IsOrgPrefix='1'
|
|
|
begin
|
|
|
set @vs_HeadTbl = @vs_HeadTbl + '_' + @ps_OrgCode;
|
|
|
end
|
|
|
|
|
|
if @vs_IsEmpPrefix='1'
|
|
|
begin
|
|
|
set @vs_HeadTbl = @vs_HeadTbl + '_' + @ps_EmpCode;
|
|
|
end
|
|
|
If @vi_MaxSerial=0 Set @vi_MaxSerial=1
|
|
|
/*=================更新年月日=================*/
|
|
|
If @vs_IsDate='1' and
|
|
|
( (@vs_DateFmt in ('YYYYMMDD','YYMMDD') and @vs_NowDate<>@vs_YearNo+'-'+@vs_MonthNo+'-'+@vs_DayNo) or
|
|
|
(@vs_DateFmt in ('YYYYMM','YYMM') and Left(@vs_NowDate,7)<>@vs_YearNo+'-'+@vs_MonthNo) or
|
|
|
(@vs_DateFmt in ('YYYY','YY') and Left(@vs_NowDate,4)<>@vs_YearNo)
|
|
|
)
|
|
|
Begin --更新并锁定表tSysBillType
|
|
|
Set @vs_IsUpdate='1'
|
|
|
|
|
|
|
|
|
Set @vs_YearNo=left(@vs_NowDate,4)
|
|
|
Set @vs_DayNo=right(@vs_NowDate,2)
|
|
|
Set @vs_MonthNo=substring(@vs_NowDate,6,2)
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
|
/*=================取得数据库标志=================*/
|
|
|
-- Select @vs_TmpBillNo=IsNull(DBID,'0000') from tComDataBase where isself='1'
|
|
|
|
|
|
/*=================设置分公司前缀=================*/
|
|
|
if @vs_IsOrgPrefix='1'
|
|
|
begin
|
|
|
select @vs_BanksHead=BANKSHEAD
|
|
|
from company
|
|
|
where CODENAME=@ps_OrgCode;
|
|
|
|
|
|
set @vs_TmpBillNo=@vs_TmpBillNo+UPPER(@vs_BanksHead)
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
/*=================取得前缀=================*/
|
|
|
if (@vs_IsPrefix='1' and @vi_PrefixLen>0 and @vs_PrefixNo<>'')
|
|
|
Set @vs_TmpBillNo=@vs_TmpBillNo+substring(@vs_PrefixNo,1,@vi_PrefixLen)
|
|
|
|
|
|
if @vs_IsEmpPrefix='1'
|
|
|
begin
|
|
|
select @vs_BanksHead=NOCODE
|
|
|
from [USER]
|
|
|
where CODENAME=@ps_EmpCode;
|
|
|
set @vs_TmpBillNo =@vs_TmpBillNo+UPPER(@vs_BanksHead);
|
|
|
end
|
|
|
|
|
|
|
|
|
/*=================取得年月日=================*/
|
|
|
if @vs_IsDate='1'
|
|
|
begin
|
|
|
If @vs_DateFmt='YYYYMMDD'
|
|
|
Set @vs_TmpBillNo=@vs_TmpBillNo+@vs_YearNo+@vs_MonthNo+@vs_DayNo
|
|
|
Else If @vs_DateFmt='YYMMDD'
|
|
|
Set @vs_TmpBillNo=@vs_TmpBillNo+Right(@vs_YearNo,2)+@vs_MonthNo+@vs_DayNo
|
|
|
Else If @vs_DateFmt='YYYYMM'
|
|
|
Set @vs_TmpBillNo=@vs_TmpBillNo+@vs_YearNo+@vs_MonthNo
|
|
|
Else If @vs_DateFmt='YYMM'
|
|
|
Set @vs_TmpBillNo=@vs_TmpBillNo+Right(@vs_YearNo,2)+@vs_MonthNo
|
|
|
Else If @vs_DateFmt='YYYY'
|
|
|
Set @vs_TmpBillNo=@vs_TmpBillNo+@vs_YearNo
|
|
|
Else If @vs_DateFmt='YY'
|
|
|
Set @vs_TmpBillNo=@vs_TmpBillNo+right(@vs_YearNo,2)
|
|
|
End
|
|
|
|
|
|
delete FROM sys_no where ISUSE=0 and BSNO in (select custno from v_op_bill)
|
|
|
|
|
|
/*=================目前单据号最大为 20,加上分公司后可能超过20,需要特殊处理=================*/
|
|
|
set @vi_BillHeadLength=LEN(@vs_TmpBillNo)
|
|
|
set @vi_BillNoLength=20-@vi_BillHeadLength
|
|
|
if @vi_SerialLen > @vi_BillNoLength
|
|
|
set @vi_SerialLen=@vi_BillNoLength
|
|
|
|
|
|
if isnull((select top 1 BSNO from sys_no where ISUSE=0 and (substring (BSNO,1,@vi_BillHeadLength) =@vs_TmpBillNo) and (LEN(BSNO)=(@vi_SerialLen+@vi_BillHeadLength))),'1')='1'
|
|
|
begin
|
|
|
if (select count(ID) from sys_wtno where HEADSTR=@vs_TmpBillNo and NOTYPE=@ps_BillType)=0
|
|
|
begin
|
|
|
select @BsNo=1
|
|
|
insert sys_wtno ( HEADSTR, MAXNO,NOTYPE) values (@vs_TmpBillNo,1,@ps_BillType)
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
select @BsNo =1+(select MAXNO from sys_wtno where HEADSTR=@vs_TmpBillNo and NOTYPE=@ps_BillType)
|
|
|
update sys_wtno set MAXNO=@BsNo where HEADSTR=@vs_TmpBillNo and NOTYPE=@ps_BillType
|
|
|
end
|
|
|
Set @vs_TmpBillNo=@vs_TmpBillNo+right('00000000000000000000'+Cast(@BsNo as varchar(100)),@vi_SerialLen)
|
|
|
Set @ps_BillNo=@vs_TmpBillNo
|
|
|
insert sys_no (BSNO, ISUSE) values (@ps_BillNo,1)
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
select @vs_TmpBillNo=(select top 1 BSNO from sys_no where ISUSE=0 and (substring (BSNO,1,@vi_BillHeadLength) =@vs_TmpBillNo) and (LEN(BSNO)=(@vi_SerialLen+@vi_BillHeadLength)))
|
|
|
Set @ps_BillNo=@vs_TmpBillNo
|
|
|
update sys_no set ISUSE=1 where BSNO=@ps_BillNo
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
select @ps_BillNo as BillNo
|
|
|
End
|
|
|
|
|
|
|
|
|
GO
|