15,891,943 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by ahmed yousif (Top 3 by date)
ahmed yousif
10-Jul-20 11:08am
View
how can i upload my sql database??
ahmed yousif
10-Jul-20 10:49am
View
after execute the query it returns '0 rows affected' means nothing changed in stock columns (there is no any error messages)
what iam expecting,
* if i sold 1 full box + 0 strips==> only box column decrease by 1 nothing happen to strips column
------------------------------------------------
* if i sold only 10 tablets(one strip)==> here there is two probabilities:
1- if column strips already contains stock from this item for example, 10 tablets
then column strips should decrease by 10 tablets (column box remains as it is)
2- if column strips is 0 stock for this item,for example i have 3 boxes : 0 loose
and i sold only 10 tablets(one strip) now i want stock to be [2 boxes: 20 loose]
----------------------------------note-----------------------------------------
i predefined total number of tablets of each box (i.e: box of 30 tablets,50 tablets,....)
i hope i explained my issue
ahmed yousif
10-Jul-20 9:42am
View
Dear originalgriff,
thank you for your reply
i tried another code as follow
now i have three tables
all_medicines ==> contains all medicine data
medicine_stock ==> medicine inventory
sales tables ==> parameters values
==========================================
create proc dbo.test_update
@a char(5),
@b smallint,
@c smallint
as
UPDATE dbo.medicine_stock
SET box = medicine_stock.box - @b,
loose = CASE
WHEN loose > 0 THEN loose - @c
WHEN loose = 0 THEN (box * all_medicines.box_content) - @c / all_medicines.box_content
WHEN loose = 0 THEN all_medicines.box_content - @c
END
FROM dbo.all_medicines
INNER JOIN dbo.medicine_stock
ON dbo.all_medicines.medicine_id = dbo.medicine_stock.medicine_id
where dbo.medicine_id = @a;
-----------------------note-------------------------------
box_content column from all_medicines table represent number of tablets per box
this code does not work
what should i do ??
thanks in advance