I have written the followin two classes in mY BLL:
C# |
The above two classse are within the same namesapce BLL
then i tried to access the members of ItemStockLevel from the reference myIventoryItem.MyItemStockLevels from my client app as:
using BLL:
public class Form{
private void btnSave_Click(object sender, EventArgs e)
{
myIventoryItem._MyItemStockLevel.StockTakeDate = int.Parse(cmbStockTakeDate.Text);
byte scode = myIventoryItem.Save();
}
}
the line :
myIventoryItem._MyItemStockLevel.StockTakeDate = int.Parse(cmbStockTakeDate.Text);
gives the followig error
Error 1 'ICSBLL.InventoryItem' does not contain a definition for '_MyItemStockLevel' and no extension method '_MyItemStockLevel' accepting a first argument of type 'ICSBLL.InventoryItem' could be found (are you missing a using directive or an assembly reference?) F:\C#\Lab\InventoryControlSystem\InventoryControlSystem\frmInventoryItemAdmin.cs 60 36 InventoryControlSystem
Why this happense and how do i fix this?

Amit ChoudharyRank #145 · 15.8K reputationPosted Mar 8, 2010, 9:59 PM EST
i don't think you can set the value of a class member using its object in another class and accessing it like the member. Try the following
code your problem will get solved
public class InventoryItem { public static setStockDate(DateTime value) { ItemStockLevel _MyItemStockLevel = new ItemStockLevel();}
and your line should be like thisHope it helps you.
Please Don't forget to mark as answer if it helps you.
Sam HobbsRank #107 · 20.5K reputationPosted Mar 9, 2010, 11:41 AM EST
petre ricardo155 reputationPosted Mar 9, 2010, 3:08 PM EST
you program compiles well : ) at follows the pattern of my buggy pogram but it doesnt show any issues, but in my program it's areally annoying pain in back side issue that i cannot see where problem is... any way before the link to the code i would like state all the things that i have done:
1. each time when sit i reopn the VS, but it didnt fx the problem
2. i cant see any issus with namespace, sam hobs sample app follows the same pattern but tt doesnt give any error
3. when i remove the lines that gives error it builds. But i need those lines so that i could assign values to ItemStockLevel object
4.I'v tried re typing, it even shows the reference variables _MyItemStockLevel under insellisense it even show the members of ItemStocklevel under _MyItemStockLevel but when i assign a value with the correct type it gives the issue
here is link to the complete code http://www.mediafire.com/?hm0ywwzjzym
thanks