473,228 Members | 1,594 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,228 software developers and data experts.

How to relate product to category object

J-T

Hello All,

I have two objects one is Product and the otherone is the Category. Category
object is like Food,books,Medicine and etc which has different tax rates .
My product object has properties like name ,price , CategoryID. I need to
create a collection of my products and in this collection I want to have the
Categories tax rate too? How can I relate these two objects together?

Thanks
Feb 9 '06 #1
4 1964
Show me the code for the two classes in question.
Is your collection TYPED ?

Feb 9 '06 #2
J-T
this is my Product object :

public class Product
{
private string m_name;
private double m_price;
private Boolean m_imported;

public Product(string name, double price , Boolean imported)
{
m_name = name;
m_price = price;
m_imported = imported;
}

public string Name
{
set
{
m_name = value;
}
get
{
return m_name;
}
}

public double Price
{
set
{
m_price = value;
}

get
{
return m_price;
}
}

public Boolean Imported
{
set
{
m_imported = value;
}

get
{
return m_imported;
}
}

}

I have not completed the category object ,but here is what I written so far
(which is incomplete)

public class Category

{

private enum Categories {Food=1,Books=2,Medical=3,others=4};
}
As you can see I am trying to create a collection later on . maybe I have to
combine these two classes ,but I don;t know how.

Thanks

"Steven Nagy" <le*********@hotmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
Show me the code for the two classes in question.
Is your collection TYPED ?

Feb 9 '06 #3
Could I suggest that you use dataTables instead?
One datatable for each class.
Then, add them to a dataset. You can also define the relationship in
the dataset as well.
Otherwise, try something like this:
Add all your Categories to a collection in the same order that they
appear in the enumeration.
Make the collection a public static variable somewhere you can get to
from your Product class.
Then remove the enum all together from categories.
Add a property to your product class called CategoryID
Add a readonly property to your Product class of type Category. In the
GETTER for the property, check the products CategoryID, and retrieve
the relevent position from the Category collection.

This is kind abstract, but hopefully points you in a useful direction.

Feb 9 '06 #4
J-T
Steven,

Thanks a lot for your help, I will give a try tomorrow (it is 1:00 AM
here:-)) and if there is any moe questions I will let you knw. Thanks for
the help

"Steven Nagy" <le*********@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Could I suggest that you use dataTables instead?
One datatable for each class.
Then, add them to a dataset. You can also define the relationship in
the dataset as well.
Otherwise, try something like this:
Add all your Categories to a collection in the same order that they
appear in the enumeration.
Make the collection a public static variable somewhere you can get to
from your Product class.
Then remove the enum all together from categories.
Add a property to your product class called CategoryID
Add a readonly property to your Product class of type Category. In the
GETTER for the property, check the products CategoryID, and retrieve
the relevent position from the Category collection.

This is kind abstract, but hopefully points you in a useful direction.

Feb 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: J-T | last post by:
Hello All, I have two objects one is Product and the otherone is the Category. Category object is like Food,books,Medicine and etc which has different tax rates . My product object has...
1
by: ollielaroo | last post by:
Hi guys, Firstly I did do a search for this one first but I couldn't find anything related in this forum. I am using Dreamweaver MX and trying to build admin pages for an ASP site. My problem is...
0
by: David Troxell - Encourager Software | last post by:
Product Scope 7 (http://www.encouragersoftware.com/) and Profile Exchanges enhanced with SetupCast publishing methods NOTE: If you are a software author, releasing commercial and/or shareware...
0
by: cdelautour | last post by:
Hi there, I am currently working with the property grid and I am implementing an indexed category system (sorts categories via index before alphabetically). I should say that at this point my...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.