Click here to Skip to main content
15,886,769 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
ALTER PROCEDURE [dbo].[spInventoryOutQuantityCheck]
AS
BEGIN
 Declare @Total_items_remaining int
 Declare @Item_ID int
 Declare @Store_ID int
 Declare @Quentity int
 
 SELECT @Total_items_remaining=@Quentity 
 from Items_Store
 where Item_ID = Item_ID And Store_ID=@Store_ID
 if (@Quentity<@Total_items_remaining)
 begin 
 UPDATE dbo.Items_Store
    SET @Total_items_remaining = @Total_items_remaining - @Quentity
    WHERE Item_ID = @Item_ID And Store_ID=@Store_ID
 end    
end

jquey for calling sp
JavaScript
$('#MainHolder_txtQuantity').focusout(function () {
        var quantity=$(this).val();
        var item = $('#MainHolder_ddItems').val();
        var store = $('#MainHolder_ddStores').val();
        var data = SilkSchoolWebService.spInventoryOutQuantityCheck(Item_ID, Store_ID);

        if (quantity > data)
            alert("Items out of stock");
        else
        {

        }
    });
Posted
Updated 15-Feb-15 22:50pm
v7
Comments
Kornfeld Eliyahu Peter 16-Feb-15 4:52am    
What is your question?

1 solution

You are missing the trick here
SQL
SELECT @Total_items_remaining=@Quentity
FROM Items_Store
WHERE Item_ID = Item_ID AND Store_ID=@Store_ID

This should be -
SQL
SELECT @Total_items_remaining=Quantity --Quanity/AvailableQuantity/Balance field of Items_Store table
FROM Items_Store
WHERE Item_ID = Item_ID AND Store_ID=@Store_ID

Hope, it helps :)
 
Share this answer
 
v2
Comments
[no name] 16-Feb-15 5:06am    
not works for me but thanku for ur attention
Suvendu Shekhar Giri 16-Feb-15 5:10am    
May be you need to sum out the "quantity out" values and then deduct that from the sum of "quantity in" values. If I can help anyway, please let me know :)
[no name] 16-Feb-15 5:12am    
this is sp it checks if item remaining not exist then show alert message using jquery
AS
BEGIN
Declare @Total_items_remaining int
Declare @Item_ID int
Declare @Store_ID int
Declare @Quentity int
if EXISTS (select Total_items_remaining from Items_Store where Total_items_remaining=@Total_items_remaining)
Return 1
else
return 0
end
[no name] 16-Feb-15 5:12am    
this is jquery code
$('#MainHolder_txtQuantity').focusout(function () {

var quantity = $('#MainHolder_txtQuantity').val();
var itemID = $('#MainHolder_ddItems').val();
var storeID = $('#MainHolder_ddStores').val();
//alert(itemID);

SilkSchoolWebService.spInventoryOutQuantityCheck(itemID, storeID);
//if (quantity > data)
// alert("Items out of stock");
//else
//{

//}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900