USE [PSSCM]
GO
/****** Object: StoredProcedure [dbo].[P_OrderMainOrder_ADD] Script Date: 06/02/2010 19:59:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[P_OrderMainOrder_ADD]
@KeyId nvarchar(50), --
@TypeId nvarchar(50), --
@OrderCode nvarchar(50), --订单编码
@OrderCustomer_S nvarchar(50), --订单客户简称
@OrderCustomerKeyId nvarchar(50), --订单客户KeyId
@Remark nvarchar(50), --备注
@Rcorder nvarchar(50), --录入员
@RecordTime nvarchar(50), --录入时间
@UpdatePeople nvarchar(50), --修改人
@UpdateTime nvarchar(50), --修改时间
@Checker nvarchar(50), --审核人
@CheckTime nvarchar(50), --审核时间
@CustomerSign nvarchar(50), --客户单号
@OrderDate nvarchar(50), --下单日期
@OperationType nvarchar(50), --业务类型
@DwonOrderPeople nvarchar(50), --下订单人
@LinkPeople nvarchar(50), --联系人
@CheckState nvarchar(50), --审核状态
@FinanceState nvarchar(50), --财务状态
@DataBaseKeyId nvarchar(50), --数据来源KEYID
@DataBaseCome nvarchar(50), --数据来源
@DateState nvarchar(50), --数据状态
@OperationState nvarchar(50), --作业状态
@WarehouseName nvarchar(50),
@WarehouseKeyId nvarchar(50)
AS
declare @number int --用于接收数据
declare @var nvarchar(50)--声明一个字符串
declare @count int--声明一个数,用来存位数
exec P_PublicSerialNumber_AddNubmer '2', @number out
set @var=CAST (@number as varchar)
set @count=LEN(@var)
if ( @count<5)
set @count=5
set @OrderCode='PSO-'+right(cast(power(10,@count) as varchar)+@number,@count)
INSERT INTO T_OrderMainOrder(
[KeyId],
[TypeId],
[OrderCode],
[OrderCustomer_S],
[OrderCustomerKeyId],
[Remark],
[Rcorder],
[RecordTime],
[UpdatePeople],
[UpdateTime],
[Checker],
[CheckTime],
[CustomerSign],
[OrderDate],
[OperationType],
[DwonOrderPeople],
[LinkPeople],
[CheckState],
[FinanceState],
[DataBaseKeyId],
[DataBaseCome],
[DateState],
[OperationState],
WarehouseName,
WarehouseKeyId
)
VALUES(
@KeyId,
@TypeId,
@OrderCode,
@OrderCustomer_S,
@OrderCustomerKeyId,
@Remark,
@Rcorder,
CONVERT(nvarchar(19),getdate(),120),
@UpdatePeople,
@UpdateTime,
@Checker,
@CheckTime,
@CustomerSign,
@OrderDate,
@OperationType,
@DwonOrderPeople,
@LinkPeople,
'N',
'N',
@DataBaseKeyId,
@DataBaseCome,
'N',
'N',
@WarehouseName,
@WarehouseKeyId
)
--写个流水好表即可,然后更新
--如果不符合条件自定错误
if exists(select * from T_VehicleCardManage where CardType=@CardType and CardSign=@CardSign)
begin
raiserror('证书编号不能重复',16,1)
return
end