Question:
How to handle expiration date in pharmacy inventory system using vb.net?
1970-01-01 00:00:00 UTC
How to handle expiration date in pharmacy inventory system using vb.net?
Four answers:
TheMadProfessor
2010-09-30 09:11:56 UTC
That all depends on what level of detail how you need to track inventory...do you need to track each individual box or do you just need to track a class of medicine (12 boxes of XYZ expiring 12/2010; 9 boxes of XYZ expiring 01/2011, etc.)



In the first case, your key to the medicine will be a serial number of some sort and expiration date is merely an attribute.



In the second (more likely, given the question) case, the key is a composite one of medicine ID plus expiration date. Assuming this is your situation, the process for logging new inventory is:



1) Capure the medicine ID and expiration date into @medicine and @expiration_date

2) SELECT COUNT(*) INTO @row_count FROM inventory

WHERE medicine = @medicine AND expiration_date = @expiration_date

3) If @row_count = 0 THEN

INSERT INTO inventory (medicine, expiration_date, on_hand)

VALUES (@medicine, @expiration_date, 1)

ELSE

UPDATE inventory SET on_hand = on_hand + 1

WHERE medicine = @medicine AND expiration_date = @expiration_date



Logging sales would be a similar process to decrease inventory except that if @row_count is 0, it indicates an error of some sort (how to address it would be up to you)
?
2016-11-16 06:23:10 UTC
sure, I additionally NOW comprehend additionally that condoms have an expiration date. I used a equipment of cream cheese the former day that hadn't been opened that expired on march tenth - and sure, counting on the product, i exploit previous the expiration date. i won't be able to arise with the money for to throw nutrition away.
Zorro
2010-09-30 06:22:34 UTC
Step 1:



Switch to a different language VB .NET is stupid.
stratsandlespauls
2010-09-30 08:26:18 UTC
What you need to be doing is using collections.

I don't know all the details of what you are doing so I'm winging it but...

You should have a Pharmacy Class and inside that class should have a collection class called Medicines.

The medicines could have a type (usually a byte) that helps identify it.

What you want to do is not overwrite your exisiting stock but add another Medicine to your collection, sort of like an arraylist



Dim myPharamacy as Pharmacy

myPharamacy=new Pharmacy

myPharmacy.Load(pPharmacyID)

myPharamcy.getMedicines(MedicineTypes.SleepingAids)

dim myMedicines as Medicines

myMedicines=myPharmacy.Medicines

dim myMedicine as Medicine=nothing

myMedicine=myMedicines.GetByExpirationDate(10/10/2010)

if not myMedicine is nothing then

console.out.writeline(myMedine.Name)

end if



So you want to add another medicine to a collection of medicines, this way they keep their own unique expiration, you also know how many unique quantites you have altogether as orders or all counts.



Don't let anyone tell you VB is not a good language, I develop in VB.net for a College.

It kicks butt!

So yes use another table and use collections!


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...