6
Answers

Save and Update difference table

when press button save and update difference table sql with C#...
 
jest i develop stoke management i want a current stroke level. when i enter GRN (Good received Note)  data and after submit save button on time happn
01.. GRN data insert into GRN Code /Item Code..
02 .. where  Item Code.. to find and update current stroke table 
i want SP and C# Cord Plz help me 
 
 
ALTER PROCEDURE [dbo].[GRNInfo]
@GrnId int ,
@GrnCode nchar(10) ,
@ItemCode nchar(10) ,
@Qty int ,
@TotalPrice decimal(18, 0) ,
@GrnDate date,
@NewQty int
AS
BEGIN
if not exists (select GrnId from atoGRN where GrnId=@GrnId)
begin
insert into atoGRN (GrnCode,FK_ItemCode,Qty,TotalPrice,GrnDate) values (@GrnCode,@ItemCode,@Qty,@TotalPrice,@GrnDate)
end
else
begin
update atoGRN set GrnCode=@GrnCode ,FK_ItemCode=@ItemCode ,Qty=@Qty ,TotalPrice=@TotalPrice ,GrnDate=@GrnDate where GrnId=@GrnId
end
DECLARE @CurrentQty AS INT;
select @CurrentQty = Quantity from atoQuantityDisc where FK_ItemCode=@ItemCode
begin
SET @NewQty = @CurrentQty + @Qty
UPDATE atoQuantityDisc
SET Quantity = @NewQty
WHERE FK_ItemCode=@ItemCode;
end
END
 
Answers (6)
0
Hima Bindu

Hima Bindu

NA 347 127.4k 8y

Sorry, Please be specific of your requirement when you ask a question .

If I understand it, youneed to insert/update in a tableand update in another table with stokeid, So when you are submitting you know that its an update / insert from UIthere are 2 caseshere

a. Insert - in your sp it will be an identity column use @@identity to insertID in Table1
Then Take this ID and update currentstoke
b. update - get the id that you are updating update the query in SP
Its easy here as you know id update currentstoke.
Accepted
0
Bikesh Srivastava

Bikesh Srivastava

NA 19.8k 835k 8y
Hi,
Simply you should use Trigger.
0
Mayoorann Nava

Mayoorann Nava

NA 94 3.3k 8y

hi Hima Bindu

when press save or insert button i want different 2 function 01. save --GRN tableand 02. update --current stroke table and currentstrokehow to do that in same SP
0
Hima Bindu

Hima Bindu

NA 347 127.4k 8y
0
Mayoorann Nava

Mayoorann Nava

NA 94 3.3k 8y

hi Vasanti THank u... 
 
stoke management.. i want a current stroke level. when i enter the GRN (Good received Note) data to database will save when press save or insert or submit button that time two tables(GRN table and current stroke table)are update .....
01.. GRN table Insert or update where GRN ID / or Item Code....
02 .. where Item Code.. to find and update current stroke table
i want SP and C# Cord Plz help me
0
Dipika

Dipika

NA 1.2k 14.6k 8y
Hi Mayoorann
Sorry but not understood your question