Click here to Skip to main content
15,888,000 members
Home / Discussions / C#
   

C#

 
QuestionRe: Edit text file using C# Pin
AlphaDeltaTheta29-May-13 23:12
AlphaDeltaTheta29-May-13 23:12 
AnswerRe: Edit text file using C# Pin
srikanth kamuju29-May-13 23:21
professionalsrikanth kamuju29-May-13 23:21 
AnswerRe: Edit text file using C# Pin
AlphaDeltaTheta29-May-13 23:37
AlphaDeltaTheta29-May-13 23:37 
GeneralRe: Edit text file using C# Pin
Richard MacCutchan29-May-13 23:43
mveRichard MacCutchan29-May-13 23:43 
GeneralRe: Edit text file using C# Pin
AlphaDeltaTheta30-May-13 0:01
AlphaDeltaTheta30-May-13 0:01 
QuestionC# window application Deployment Pin
AjitRaje29-May-13 21:57
AjitRaje29-May-13 21:57 
AnswerRe: C# window application Deployment Pin
Abhinav S29-May-13 22:32
Abhinav S29-May-13 22:32 
QuestionClasses containing Lists Pin
huge_superman29-May-13 21:34
huge_superman29-May-13 21:34 
Hi,

Hi have a question on classes that contains lists, and going to try hard not to make you confused.

If I have three classes:

public class Customer
{
public string CustomerCode { get; set; }
public List<warehouse> CustomerWarehouses { get; set; }
}

public class Warehouse
{
public string Name { get; set; }
public List<stock> StockCodes { get; set; }
}

public class Stock
{
public string StockCode { get; set; }
public string Description { get; set; }
public int QtyAvailable {get; set;}
}

The program starts by Populating the Customer Class.
So I will have CustomerCode "CUS123".
Then I select warehouses I want to check stock, "A1" and "B1".

So at this stage I will have the Customer Class containing customer "CUS123" and two warehouses "A1" and "B1".

Then I read stock from an excel file. Let's say I read stock code "CODEABC123".

Then for each warehouse I want to check stock and add it to the warehouse class in StockCodes list.

So warehouse "A1" and "B1" must have the stock code with their own values.

This is the code I have to populate the StockCodes list in the Warehouse Class:

public List<stock> GetStockCodeWarehouseInfo(List<stock> StockList, Customer CustomerInfo)
{
Stock tempStock = null;

foreach (Warehouse warehouse in CustomerInfo.CustomerWarehouses)
{
foreach (Stock stockcode in StockList)
{
tempStock = new Stock();
tempStock = stockcode;
//Get additional stock info
tempStock = GetAdditionalStockInfo(warehouse.Name, tempStock);
}

tempStockList.Add(tempStock);
warehouse.StockCodes.Add(tempStock);
}

return StockList;
}

When the Stock Code is added to the first Warehouse ("A1") StockCodes list the values are correct.

After the Stock Code is added to the second Warehouse ("B1") StockCodes list the first warehouse values for Stock Code is the same as values in Warehouse "B1".

So to put this in simple terms:

After Stock Code is added to first warehouse, I will have:
Customer.Name = "CUS123"
Customer.Warehouse.Name (LIST) = "A1"
Customer.Warehouse.StockCode = "CODEABC123"
Customer.Warehouse.Description = "A STOCK CODE"
Customer.Warehouse.QtyAvailable = 10

After Stock Code is added to second warehouse, I have:
Customer.Name = "CUS123"
Customer.Warehouse.Name (LIST) = "B1"
Customer.Warehouse.StockCode = "CODEABC123"
Customer.Warehouse.Description = "A STOCK CODE"
Customer.Warehouse.QtyAvailable = 5

Customer.Name = "CUS123"
Customer.Warehouse.Name (LIST) = "B1"
Customer.Warehouse.StockCode = "CODEABC123"
Customer.Warehouse.Description = "A STOCK CODE"
Customer.Warehouse.QtyAvailable = 5

Where I should have:
Customer.Name = "CUS123"
Customer.Warehouse.Name (LIST) = "A1"
Customer.Warehouse.StockCode = "CODEABC123"
Customer.Warehouse.Description = "A STOCK CODE"
Customer.Warehouse.QtyAvailable = 10

Customer.Name = "CUS123"
Customer.Warehouse.Name (LIST) = "B1"
Customer.Warehouse.StockCode = "CODEABC123"
Customer.Warehouse.Description = "A STOCK CODE"
Customer.Warehouse.QtyAvailable = 5

Ay ideas on what I am doing wronng?

Thanks
AnswerRe: Classes containing Lists Pin
Jasmine250130-May-13 9:50
Jasmine250130-May-13 9:50 
QuestionHow to create a setup with two startup object in visual studio 2010? Pin
Viswanathan Ramamoorthy29-May-13 21:14
Viswanathan Ramamoorthy29-May-13 21:14 
AnswerRe: How to create a setup with two startup object in visual studio 2010? Pin
Eddy Vluggen29-May-13 22:00
professionalEddy Vluggen29-May-13 22:00 
AnswerRe: How to create a setup with two startup object in visual studio 2010? Pin
Amol_B30-May-13 20:19
professionalAmol_B30-May-13 20:19 
Questionresize chart in winform using c# Pin
mit6229-May-13 21:00
mit6229-May-13 21:00 
AnswerRe: resize chart in winform using c# Pin
Richard MacCutchan29-May-13 21:03
mveRichard MacCutchan29-May-13 21:03 
QuestionProblems in handling windows forms Pin
Arun kumar Gautam29-May-13 18:58
Arun kumar Gautam29-May-13 18:58 
AnswerRe: Problems in handling windows forms Pin
Richard MacCutchan29-May-13 21:09
mveRichard MacCutchan29-May-13 21:09 
AnswerRe: Problems in handling windows forms Pin
Anna King30-May-13 2:49
professionalAnna King30-May-13 2:49 
AnswerRe: Problems in handling windows forms Pin
Eddy Vluggen30-May-13 2:56
professionalEddy Vluggen30-May-13 2:56 
GeneralTo overcome the load screen flashes with user control and images and controls Pin
Lương Tuấn Anh29-May-13 18:30
Lương Tuấn Anh29-May-13 18:30 
AnswerRe: To overcome the load screen flashes with user control and images and controls Pin
Eddy Vluggen29-May-13 22:33
professionalEddy Vluggen29-May-13 22:33 
GeneralRe: To overcome the load screen flashes with user control and images and controls Pin
Lương Tuấn Anh30-May-13 4:56
Lương Tuấn Anh30-May-13 4:56 
GeneralRe: To overcome the load screen flashes with user control and images and controls Pin
Eddy Vluggen30-May-13 4:58
professionalEddy Vluggen30-May-13 4:58 
GeneralRe: To overcome the load screen flashes with user control and images and controls Pin
Lương Tuấn Anh30-May-13 8:24
Lương Tuấn Anh30-May-13 8:24 
GeneralRe: To overcome the load screen flashes with user control and images and controls Pin
Eddy Vluggen30-May-13 9:05
professionalEddy Vluggen30-May-13 9:05 
GeneralRe: To overcome the load screen flashes with user control and images and controls Pin
Lương Tuấn Anh30-May-13 16:00
Lương Tuấn Anh30-May-13 16:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.