Skip to content

Settings and activity

1 result found

  1. 8 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)
    How important is this to you?

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    An error occurred while saving the comment
    Anonymous commented  · 

    sp_helptext usp_BulkC
    CREATE PROCEDURE [dbo].[usp_BulkCrudPurchaseDetail]
    (
    @param0 PurchaseOrderDetailTableType1 READONLY
    ,@param1 PurchaseOrderDetailTableType1 READONLY
    ,@param2 NVARCHAR(50) --CreatedBy
    ,@param3 INT -- PurchaseOrderID
    ,@param4 INT
    )
    AS
    BEGIN


    --Delete Record
    UPDATE PurchaseOrderDetail SET IsActive=0,ModifiedBy=@param2,ModifiedDate=CAST(GETDATE() AS SMALLDATETIME)
    FROM @param1 D JOIN PurchaseOrderDetail E ON E.ItemID=D.ItemID AND
    E.PurchaseOrderID=@param3 AND 1=@param4--D.PurchaseOrderTypeID

    --Enable already deleted Record
    UPDATE PurchaseOrderDetail SET IsActive=1,
    Quantity=D.Quantity,
    Rate=D.Rate,
    Amount=D.Amount,ModifiedBy=@param2,
    ModifiedDate=CAST(GETDATE() AS SMALLDATETIME) FROM @param0 D JOIN
    PurchaseOrderDetail E ON E.ItemID=D.ItemID AND E.PurchaseOrderID=@param3
    AND 1=@param4--D.PurchaseOrderTypeID

    MERGE PurchaseOrderDetail AS [Target]
    USING @param0 AS [Source]
    ON [Target].PurchaseOrderDetailID = [Source].PurchaseOrderDetailID
    AND [Target].PurchaseOrderID = [Source].PurchaseOrderID
    AND 1=@param4--[Source].PurchaseOrderTypeID
    WHEN MATCHED THEN
    UPDATE SET
    ItemID=[Source].ItemID,
    Quantity=[Source].Quantity,
    Rate=[Source].Rate,
    Amount=[Source].Amount
    ,ModifiedBy=@param2
    ,ModifiedDate = GETDATE()
    WHEN NOT MATCHED AND (SELECT COUNT(PurchaseOrderDetailID) FROM PurchaseOrderDetail WHERE 1=[Source].PurchaseOrderTypeID
    AND PurchaseOrderID=@param3 AND ItemID=[source].ItemID)<=0 THEN
    INSERT (
    PurchaseOrderID
    ,ItemID
    ,Quantity
    ,Rate
    ,Amount
    ,CreatedBy
    ,CreatedDate
    )
    VALUES (@param3,[Source].ItemID,[Source].Quantity,[Source].Rate,[Source].Amount,
    @param2, GETDATE());

    END rudPurchaseDetail

    convert linq