Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Greetings All, I am working on a POS System in VB.NET 2010. i need to display the profit of a single item using barcode which is working but i need also to retrieve all the item's details as well. I can only pull the profit but not with the item's details too.


[Code added from answer/comment]
VB
'Adapter query:

SELECT        SUM((ItemSellPrice - ItemBuyPrice) * ItemCount) AS ItemTotalProfit
FROM            ReceiptDetails
WHERE        (Barcode = ?)

'button Code:
If ComboBox1.Text = "Item Total Profit" Then
            txtRptBarcode.Show()

            Me.ItemTotalProfitTableAdapter.FillByItemTotalProfit(Me.POSDS.ItemTotalProfit, txtRptBarcode.Text)

            ITPRV.Show()
Posted
Updated 19-Sep-14 3:56am
v2
Comments
Pheonyx 19-Sep-14 8:08am    
Then you need to write some code to do so... especially as you have told us nothing here about your issue. What code you are using and where it is failing. Also it would be useful to know a bit about your item objects and how they are stored in what ever database you are using.......
TechVille 19-Sep-14 8:22am    
Sorry for Posting my question that shallow....
I am using a TableAdapter in which i have added this query:

SELECT SUM((ItemSellPrice - ItemBuyPrice) * ItemCount) AS ItemTotalProfit
FROM ReceiptDetails
WHERE (Barcode = ?)
On the Form I have a button in which i have the following code which displays the "Item's Profit" in a Report (ITPRV):
If ComboBox1.Text = "Item Total Profit" Then
txtRptBarcode.Show()

Me.ItemTotalProfitTableAdapter.FillByItemTotalProfit(Me.POSDS.ItemTotalProfit, txtRptBarcode.Text)

ITPRV.Show()
The other item's details which i need to display are: Barcode, ItemName, ItemSellPrice
Pheonyx 19-Sep-14 9:58am    
You need to tell us how your "ReceiptDetails" table links to your Item/Stock details table and the field names.
TechVille 19-Sep-14 10:06am    
Both ReceiptDetails table and Items table are in a relationship with the barcode as the primary key.
i have not used complex connections as i am a begginner, just added the db to my application and used tableadapter queries for nearly all my queries.
Please excuse my poor terminology.... am still a beginner in vb.net

1 solution

Based on what you have said, I believe this sql query should pull all the information:
SQL
SELECT SUM((rd.ItemSellPrice - rd.ItemBuyPrice) * rd.ItemCount) AS ItemTotalProfit, i.Barcode, i.ItemName, i.ItemSellPrice
FROM ReceiptDetails as rd join Items as i on rd.Barcode = i.Barcode
WHERE (rd.Barcode = ?) 


I've assumed that Barcode, ItemName and ItemSellPrice are all fields in the Item table.
You need to extend your dataset to be able to hold these additional fields.

Let me know how that goes for you.
 
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