It is advisable that Item Group is assigned to an item. Refer to Item Group.
publicvoidNewStockItem(BCE.Data.DBSettingdbSetting){//If true, cost of this item will be recalculated upon saving//Since this is a new item, so there is no transactions to be recalculated.boolrecalculate=false;BCE.AutoCount.Stock.Item.ItemDataAccesscmd=BCE.AutoCount.Stock.Item.ItemDataAccess.Create(dbSetting);BCE.AutoCount.Stock.Item.ItemEntityitemEntity=cmd.NewItem();BCE.AutoCount.Stock.Item.ItemUomEntityuomEntity;itemEntity.ItemCode="FG001";itemEntity.ItemGroup="FINISHED";//ItemGroup must already exist in "Item Group Maintenance"itemEntity.Description="Finished Goods 001";//0 : Fixed Cost//1 : Weighted Average//2 : FIFO//3 : LIFO//If not assign, default Costing method will be auto assigneditemEntity.CostingMethod=1;//Sale Tax and Purchase Tax can be bound to this itemitemEntity.TaxType="SR-S";itemEntity.PurchaseTaxType="TX-S";//UOM//While creating new item, system will auto initiate a new empty UOM.//Here will remove the new empty uom, before adding my uom//or a loop to add more than one uom.itemEntity.DeleteItemUom("");//Add one UOM//The first UOM that is rate 1 will be auto assign to BaseUOM of this itemuomEntity=itemEntity.NewUom("UNIT",1);uomEntity.StandardCost=50;uomEntity.StandardSellingPrice=100;cmd.SaveData(itemEntity,refrecalculate);}
Edit
publicvoidChangeStockItemPricing(BCE.Data.DBSettingdbSetting){//If true, cost of this item will be recalculated upon savingboolrecalculate=true;BCE.AutoCount.Stock.Item.ItemDataAccesscmd=BCE.AutoCount.Stock.Item.ItemDataAccess.Create(dbSetting);BCE.AutoCount.Stock.Item.ItemEntityitemEntity;BCE.AutoCount.Stock.Item.ItemUomEntityuomEntity;itemEntity=cmd.LoadItem("FG001",BCE.AutoCount.Stock.Item.ItemEntryAction.Edit);//Load the UOM of this Item, where Cost and Price are storeduomEntity=itemEntity.GetUomByName("UNIT");uomEntity.StandardCost=45;//Calculate Standard Selling Price base on Standard Cost//Eg. Set the Selling Price at 80% of the costuomEntity.StandardSellingPrice=uomEntity.StandardCost*1.8M;cmd.SaveData(itemEntity,refrecalculate);}
publicvoidSetItemDiscontinue(booldiscontinue,BCE.Data.DBSettingdbSetting){//If true, cost of this item will be recalculated upon savingboolrecalculate=false;BCE.AutoCount.Stock.Item.ItemDataAccesscmd=BCE.AutoCount.Stock.Item.ItemDataAccess.Create(dbSetting);BCE.AutoCount.Stock.Item.ItemEntityitemEntity=cmd.LoadItem("FG001",BCE.AutoCount.Stock.Item.ItemEntryAction.Edit);//Discontinued = true, this item no longer can be selected in purchase documents itemEntity.Discontinued=discontinue;cmd.SaveData(itemEntity,refrecalculate);}
Inactive an Item
publicvoidSetItemActive(boolactive,BCE.Data.DBSettingdbSetting){//If true, cost of this item will be recalculated upon savingboolrecalculate=false;BCE.AutoCount.Stock.Item.ItemDataAccesscmd=BCE.AutoCount.Stock.Item.ItemDataAccess.Create(dbSetting);BCE.AutoCount.Stock.Item.ItemEntityitemEntity=cmd.LoadItem("FG001",BCE.AutoCount.Stock.Item.ItemEntryAction.Edit);//IsActive = false, this item no longer can be selected at all entry formitemEntity.IsActive=active;cmd.SaveData(itemEntity,refrecalculate);}
Auto Generate ItemCode for New Item with ItemCodeHelper
Auto generate item code depends on a valid Item Code Format setting.
Item Code Format is maintained in Tools | Options, go to Stock | General Stock Setting.
One of the 3 methods below can be used when generates item code.
Get an auto generate item code with the short code of Item Group
Get an auto generate item code with the short code of Item Type
Get an auto generate item code with the short code of both Item Group and Item Type