Hello,
I develop in ASP.NET with VB.NET code.
I need some help constructing a class: Worker. I'm designing the
properties of this class.
The class is filled reading tables in database.
Properties of Class Worker:
- ID_Card
- Names of Person
- ID_Current_Comp any
- Name of Current Company
- Is Worker working at the company? (Yes, No)
- Projects that worker worked in
- Project 1 (ID and name)
- Project 2 (ID and name)
- Project 3 (ID and name)
- ...
My problem is with property Projects_Worked _In. A worker could have
been in many projects. I don't know how many projects a worker has
worked at. It could be only 1 project or 5 projects.
How would you desing this property Projects_Worked _In of class Worker?
I was thinking to:
- Define 50 properties like Project1, Project2, Project3,... Project50,
all of them initialized in NULL
- Define a property Number_Of_Proje cts and according to that I will
know if I have to display Project1, Project2, Project3, etc.
Problem is what happen if Number_Of_Proje cts 50
Thank you for your help ! 6 1242
pass it in as a delimited string then parse it in the class.
"Big George" <jb*****@gmail. comwrote in message news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
Hello,
I develop in ASP.NET with VB.NET code.
I need some help constructing a class: Worker. I'm designing the
properties of this class.
The class is filled reading tables in database.
Properties of Class Worker:
- ID_Card
- Names of Person
- ID_Current_Comp any
- Name of Current Company
- Is Worker working at the company? (Yes, No)
- Projects that worker worked in
- Project 1 (ID and name)
- Project 2 (ID and name)
- Project 3 (ID and name)
- ...
My problem is with property Projects_Worked _In. A worker could have
been in many projects. I don't know how many projects a worker has
worked at. It could be only 1 project or 5 projects.
How would you desing this property Projects_Worked _In of class Worker?
I was thinking to:
- Define 50 properties like Project1, Project2, Project3,... Project50,
all of them initialized in NULL
- Define a property Number_Of_Proje cts and according to that I will
know if I have to display Project1, Project2, Project3, etc.
Problem is what happen if Number_Of_Proje cts 50
Thank you for your help !
You use a collection instead. You could actually do this in several ways.
You could create a NameValueCollec tion (located in the
System.Collecti ons.Specialized namespace). This way you could put an id and
name into the collection. In this case, most people would probably put the
ID number as the name, and the name of the project as the value. You create
the namevaluecollec tion just as you would any other field. Then, you can add
projects to it as needed.
for example:
// initialize the collection
private NameValueCollec tion col = new NameValueCollec tion
then you can add to it such as:
col.Add(Id1.ToS tring(),"Projec tName1");
That's assuming that Id1 is a number.
Now, what if you wanted to make that a property. You woud do it like so
public NameValueCollec tion Projects
{
get
{
return col;
}
set
{
col = value;
}
}
You cuold then access it like so:
Worker.Projects .Add("1","Proje ct1");
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"Big George" <jb*****@gmail. comwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
Hello,
I develop in ASP.NET with VB.NET code.
I need some help constructing a class: Worker. I'm designing the
properties of this class.
The class is filled reading tables in database.
Properties of Class Worker:
- ID_Card
- Names of Person
- ID_Current_Comp any
- Name of Current Company
- Is Worker working at the company? (Yes, No)
- Projects that worker worked in
- Project 1 (ID and name)
- Project 2 (ID and name)
- Project 3 (ID and name)
- ...
My problem is with property Projects_Worked _In. A worker could have
been in many projects. I don't know how many projects a worker has
worked at. It could be only 1 project or 5 projects.
How would you desing this property Projects_Worked _In of class Worker?
I was thinking to:
- Define 50 properties like Project1, Project2, Project3,... Project50,
all of them initialized in NULL
- Define a property Number_Of_Proje cts and according to that I will
know if I have to display Project1, Project2, Project3, etc.
Problem is what happen if Number_Of_Proje cts 50
Thank you for your help !
Properties of Class Worker:
- ID_Card
- Names of Person
- ID_Current_Comp any
- Name of Current Company
- Is Worker working at the company? (Yes, No)
- Projects that worker worked in
- Project 1 (ID and name)
- Project 2 (ID and name)
- Project 3 (ID and name)
- ...
My problem is with property Projects_Worked _In. A worker could have
been in many projects. I don't know how many projects a worker has
worked at. It could be only 1 project or 5 projects.
How would you desing this property Projects_Worked _In of class Worker?
I was thinking to:
- Define 50 properties like Project1, Project2, Project3,... Project50,
all of them initialized in NULL
- Define a property Number_Of_Proje cts and according to that I will
know if I have to display Project1, Project2, Project3, etc.
Problem is what happen if Number_Of_Proje cts 50
Forget these ways to hell...
1) You have to make second class - Project (props ID and Name).
2) Add property Worker.Projects of type IList(Of Project), or other
collection-type.
....than, you can have any number of project that the worker worked on and
coding like this:
Worker.Project. Add(FirstProjec t)
Worker.Project. Add(SecondProje ct)
Worker.Project. Remove(FirstPro ject)
Worker.Project. Count
Robert Haken [MVP ASP/ASP.NET]
HAVIT, s.r.o., www.havit.cz http://knowledge-base.havit.cz
Thank you Robert !
>
Forget these ways to hell...
1) You have to make second class - Project (props ID and Name).
2) Add property Worker.Projects of type IList(Of Project), or other
collection-type.
...than, you can have any number of project that the worker worked on and
coding like this:
Worker.Project. Add(FirstProjec t)
Worker.Project. Add(SecondProje ct)
Worker.Project. Remove(FirstPro ject)
Worker.Project. Count
Robert Haken [MVP ASP/ASP.NET]
HAVIT, s.r.o., www.havit.cz http://knowledge-base.havit.cz
Maybe you are stil on line:
How do you declare and instance these classes:
Private oWorker as Worker(myID_Car d)
' Then how do you instance or call class "Project" ?
' Is enough to do:
oWorker.Project .Add(FirstProje ct)
But .NET doesn't allow this
Sorry about my ignorance
It depends on what type the "Project" field is.
Let's just say for the sake of argument that it's some type of
collection, Depending on the requirements of the class, you usually
instantiate it when you make a new instance of your Worker class:
public class Worker {
private List<Project_pr ojects;
public List<ProjectPro jects {
get { return _projects; }
set { _projects = value; }
}
public Worker() {
_projects = new List<Project>() ;
}
}
Then, whereever else in your code you can then add like so:
private oWorker = new Worker();
oWorker.Project s.Add(FirstProj ect);
oWorker.Project s.Add(SecondPro ject);
int projectCount = oWorker.Project s.Count;
you get the idea.
hope that helps!
Sean
Big George wrote:
Maybe you are stil on line:
How do you declare and instance these classes:
Private oWorker as Worker(myID_Car d)
' Then how do you instance or call class "Project" ?
' Is enough to do:
oWorker.Project .Add(FirstProje ct)
But .NET doesn't allow this
Sorry about my ignorance
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Simon Harvey |
last post by:
Hi all,
I am trying to get my win forms application to start, but I'm hitting a
problem which I am certain is really simple.
The start for my application is ApplicationManager.cs. This class contains
the Main() method and a very simple constructor. The class looks something
like this:
public class{
|
by: Don |
last post by:
I have a third party C++ DLL that I am trying to use from C#. The
specific function I am trying to use is declared in C++ as follows:
ladybugConvertToMultipleBGRU32(
LadybugContext context,
const LadybugImage* pimage,
unsigned char* arpszDestBuffers,
LadybugImageInfo* pImageInfo );
|
by: perryschon |
last post by:
Can someone please help me out with the Visual Basic source code needed that allows configuration and usage of comm ports in any PC?
I am constructing an asynchronous serial communication RS-232 circuit which will include serial cables (transmitter and receiver) connected from one pc to another pc with a 9-pin null modem in between. The VB program will be used to input the data and the output will appear on the remote PC.
I need help in...
|
by: JoshforRefugee |
last post by:
heard that we can do automatic code generation using macros, but not
sure how can I pursue this. Here is my problem.
In my env, I have class A,B and C. All of them has constructors, and
few common methods, like reset, and execute.
now my env(main) class actually is where I am creating this objects.
in .h
A myA;
B myB;
|
by: davecph |
last post by:
I'm constructing a website with a layout created with div-tags. They have a fixed width, float left, and display inline. When one of the div's contain a select-element the right-most div floats down for no apparent reason, but when the select-elements are gone they all align as expected. No css apply to the select-elements.
image of prob.: http://sdc.novasol.com/site/nov/TMP/withSelectBoxes.gif
image of expected:...
| |
by: nabil |
last post by:
Hi
I have probleam while while initilazing nested class ...
I needs to create a object 'b' of B(nested class) in A(surrounding class).
while constructing b I have to pass pointer of funtion in Class A.
But when I am doing this compilr throws error.
|
by: hjast |
last post by:
test has exited due to signal 10 (SIGBUS).
This is the circle class
#include <iostream.h>
class Shape
{
|
by: Brent White |
last post by:
I can't figure out what I'm doing differently with this one drop-down
list control from the other two that are working just fine.
Background:
I am constructing a page that will allow a user to select style,
color, size from dropdown boxes and get a short datagrid report based
on that selection. When they select the style and hit a button, the
color (and eventually size) dropdown lists will automatically fill
based on the style...
|
by: Joe, G.I. |
last post by:
Can anyone help me w/ a priority_queue. I'm generating MyEvent classes
and I put them on a priority_queue, but I don't know how to get them in
priority. The priority is the event w/ the smallest timestamp.
// just a wrapper around priority_queue
pq = new MyPriorityQueue();
// I generate 10 events w/ a random timestamp
for (int i = 0; i < 10; i++) {
MyEvent *event = new MyEvent();
|
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...
|
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...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |