Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- publiczny :
- DECLARE @name nvarchar(MAX) = 'pełna nazwa dostawcy';
- DECLARE @email nvarchar(MAX) = 'adres@email.com';
- DECLARE @isPrivate bit = 0; -- 0 = publiczny / 1 = prywatny
- DECLARE @taxId nvarchar(10) = '1234567890'; -- nip max 10 znaków
- INSERT INTO [dbo].[Sellers]
- ([Name]
- ,[Email]
- ,[TaxId]
- ,[IsPrivate])
- VALUES
- (@name
- ,@email
- ,@taxId
- ,@isPrivate)
- -- publiczny + powiazanie go z userem :
- DECLARE @name nvarchar(MAX) = 'pełna nazwa dostawcy3';
- DECLARE @email nvarchar(MAX) = 'adres@email.com';
- DECLARE @isPrivate bit = 0; -- 0 = publiczny / 1 = prywatny
- DECLARE @taxId nvarchar(10) = '1234567890'; -- nip max 10 znaków
- DECLARE @customerId INT = 3; -- id usera
- DECLARE @SellerIdentityValue INT;
- DECLARE @SellerIdentityOutput TABLE ( ID INT )
- DECLARE @InvoiceType INT = 2 -- 1 papierowa / 2 = elektroniczna
- INSERT INTO [dbo].[Sellers]
- ([Name]
- ,[Email]
- ,[TaxId]
- ,[IsPrivate])
- output inserted.Id INTO @SellerIdentityOutput
- VALUES
- (@name,
- @email,
- @taxId,
- @isPrivate)
- SELECT @SellerIdentityValue = (SELECT ID FROM @SellerIdentityOutput)
- INSERT INTO [dbo].[CustomerSellers]
- ([SellerId]
- ,[CustomerId]
- ,[InvoiceType]
- ,[PaperInvoicePaymentDate])
- VALUES
- ( @SellerIdentityValue,
- @customerId,
- @InvoiceType,
- NULL) -- data dla notyfikacji jak papierowa ( nie potrzebne przy wrzucaniu dostawców )
- GO
- ---- tworzenie prywatnego dostawcy ( analogicznie jak publiczny z powiązaniem z jedyną róznicą @isPrivate = 1) :
- DECLARE @name nvarchar(MAX) = 'pełna nazwa dostawcy4';
- DECLARE @email nvarchar(MAX) = 'adres@email.com';
- DECLARE @isPrivate bit = 1; -- 0 = publiczny / 1 = prywatny
- DECLARE @taxId nvarchar(10) = '1234567890'; -- nip max 10 znaków
- DECLARE @customerId INT = 3; -- id usera
- DECLARE @SellerIdentityValue INT;
- DECLARE @SellerIdentityOutput TABLE ( ID INT )
- DECLARE @InvoiceType INT = 2 -- 1 papierowa / 2 = elektroniczna
- INSERT INTO [dbo].[Sellers]
- ([Name]
- ,[Email]
- ,[TaxId]
- ,[IsPrivate])
- output inserted.Id INTO @SellerIdentityOutput
- VALUES
- (@name,
- @email,
- @taxId,
- @isPrivate)
- SELECT @SellerIdentityValue = (SELECT ID FROM @SellerIdentityOutput)
- INSERT INTO [dbo].[CustomerSellers]
- ([SellerId]
- ,[CustomerId]
- ,[InvoiceType]
- ,[PaperInvoicePaymentDate])
- VALUES
- ( @SellerIdentityValue,
- @customerId,
- @InvoiceType,
- NULL) -- data dla notyfikacji jak papierowa ( nie potrzebne przy wrzucaniu dostawców )
- GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement