Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
I m working in a library project.
I have two forms i.e frmBooks and frmIssueRegister
and tables books and Issue
My fields in table books are : Totalcopies, IssuedCopies,LeftCopies
when I m issuing a book (frmIssueRegister)and on saving it should
do the following changes in frmBooks:
Total copies= 10
Issued copies=3
Left Copies in library = 7

similarly on returning i book ,it should subtract:
Total copies= 10
Issued copies=2
Left Copies in library = 8

Please help me out !!!
Posted
Comments
Maciej Los 23-May-12 11:50am    
Not clear! What kind of database?

I would advice to store only the amount of total copies and issued copies. Copies left in library can be calculated at any time so when you fetch the data you can use something like:
SQL
SELECT TotalCopies,
       IssuedCopies,
       TotalCopies - IssuedCopies AS CopiesLeft
FROM ...

It's a good rule of thumb that calculated fields should never be store (at least in a way that they can be modified).
 
Share this answer
 
v2
Comments
Espen Harlinn 23-May-12 18:24pm    
Good points :-D
Wendelius 24-May-12 15:08pm    
Thank you Espen :)
use update query like
when Issue
SQL
update frmIssueRegister set Issuedcopies=Issuedcopies+1,leftCopies=leftCopies-1 where bookid='123'

hope it will helps you
 
Share this answer
 
Hi,
to maintain this u need to use before trigger
to write a trigger refer this[^]

Best luck
 
Share this answer
 
Comments
Member 8575950 24-May-12 1:47am    
I am new to vb.net. Can you pls help me in writting this trigger
Hi,
If You use SQL Server 2005 or letter version theh you can assign Left Copies field to Calculated field.
There is facility to set calculated field.
 
Share this answer
 
hi u can try this
assume ur having table name tblCopies
columns
cCopies(Money)
while adding from aspx page..u (add) + with numbers (means how many copies returned )
and while issuing -(minus) with numbers means how many issued

then now u just write simple query

Select SUM(cCopies) from tblCopies.


hope it will helps u
 
Share this answer
 
v2
use tracnstion for doing this
 
Share this answer
 

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