Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello there, my name is ade and i need help on a task, am working on project in vb.net. i have a listview on a form, the listview has 4 fixed columns and as many rows as possible based on user entries at the click several buttons. if a user clicks a garment button a row is inserted and it looks like this:

Desc,        Amount      Quantity    No. Piece
-----------------------------------------------
2pc suit      500           2           2

(inserting a garment with its cost, the quantity of garments brought and how many pieces makes that garment type)

when he clicks a color button another row is inserted now making the list view look like this:

Desc,            Amount          Quantity        No. Pieces
-----------------------------------------------------------
2pc suit          500               2               2
black


when he clicks a fabric button another row is inserted now making the list view look like this:

Desc,        Amount      Quantity    No. Pieces
------------------------------------------------
2pc suit      500           2           2
black
wool


The above mentioned tasks i can achieve, but now at the click of a button i need to generate a ticket or invoice along with some tags(short descriptive/details) report . Generating these tag is the issue, from the above you can see that two 2piece suit has been entered (inserted) and 2 items make up a 2pc suit( 2 piece suit) this implies 4 tags (that is 2piece times quantity 2).

these tags will carry name of item, color, fabric, amount and total quantity (listing it as 1of4,2of4,3of4 and 4of4).

something like this:
===================================================
= (1/4)  Due date 23/05/2017 User:2               =
= customer name: Tom Jones Contact No: 08023345677=
= 2pc Suit 500/blue/cotton                        =
===================================================

It gets more complicated when you now have something like this,

Desc,        Amount      Quantity    No. Pieces
-------------------------------------------------
2pc suit      500           2           2
black
wool
-------------------------------------------------
Shirt        200            1           1
blue
cotton
-------------------------------------------------
Shirt        200            1           1
white
cotton
-------------------------------------------------
Shirt        200            1           1
pink
cotton
-------------------------------------------------

please will appreciate any assistance , as am stuck and don't know where to start. on generating these tags

warm regards

What I have tried:

i have not tried anything yet on this very issue
please will appreciate any assistance , as am stuck and don't know where to start. on generating these tags
Posted
Updated 24-May-17 9:38am
v2

1 solution

Well... You're keeping a focus on a ListView control instead of data. I'm sorry, but this is wrong approach.

To spare you trouble i'd suggest to think about invoice as a set of objects:
invoice
    (
    invoice no.,
    date of sale,
    item on invoice
        (
          selled object /a garment in your case/,
          amount,
          price,
          etc.
        )
    ),
seller (seller no., name, etc.),
buyer (buyer no., name, etc.)


Every single object should be represented as a Class[^], which contains several properties. For example, Customer may be defined as:

VB.NET
Public Class Customer
	Private sName As String = String.Empty
	Private sContactNo As String = String.Empty
	
	Public Sub New()
		'default - empty constructor
	End Sub

	Public Sub New(ByVal _Name As String, ByVal _ContactNo As String)
		sName = _Name
		sContactNo = _ContactNo
	End Sub
	
	Public Property Name As String
		Get
			Return sName
		End Get
		Set (value As String)
			sName = value
		End Set
	End Property

	Public Property ContactNo As String
		Get
			Return sContactNo
		End Get
		Set (value As String)
			sContactNo = value
		End Set
	End Property
End Class


So, to create Customer object:
VB.NET
Dim cust As Customer = New Customer("Maciej Los", "0123654789")


I wan't to provide complete code, because it's your job. Conclusion is: you should start from basics:
Objects and classes in Visual Basic | Microsoft Docs[^]
Defining Classes (Visual Basic) | Microsoft Docs[^]
Walkthrough: Creating Your Own Collection Class[^]

Good luck!
 
Share this answer
 
Comments
CPallini 24-May-17 16:16pm    
My 5.
Maciej Los 24-May-17 16:22pm    
Thank you, Carlo.

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