473,609 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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,Medi cine 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 1998
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,othe rs=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*********@ho tmail.com> wrote in message
news:11******** *************@g 47g2000cwa.goog legroups.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*********@ho tmail.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.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
2765
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 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
1
2159
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 I have Categories and various Products in each Category. I'm trying to build a page to EDIT/UPDATE each product.I want to be able to change the Category that a product belongs to, but all I get in the drop-down menu is the one specific Category. ...
0
2090
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 software, this announcement will be of interest to you - particularly our Shareware and Search Engine Profile Exchanges - Even our Clarion 3rd Party Profile Exchange displays over 60 NON-Clarion products of interest to Developers including...
0
1571
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 current solution does work well, however it isn't the prettiest when it comes to specifying the attribute. Which at present looks either like: or I am trying to remove the "typeof(MyClass)" argument via reflection in the constructor of the...
0
8129
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8571
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6997
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6056
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5509
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4017
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4080
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2530
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.