Search website

Access Stock Tutorial

Introduction

In this part of the tutorial, you will learn about accessing a Stock document via code.

In the first part of the tutorial, an example on how to programmatically add, edit and delete a Stock Item will be shown while in the second part of the tutorial, an example on how to programmatically add, edit and delete a Stock Issue document will be shown. Note: For all the property table, the red entries are compulsory property

Accessing Stock Item

Similarly to previous tutorials, we begin with creating an object that works as the data access bridge between the database with the data we wish to add, edit or delete. For Stock Item this bridge is the ItemDataAccess class.

Code Snippet
  1. BCE.AutoCount.Stock.Item.ItemDataAccess cmd = BCE.AutoCount.Stock.Item.ItemDataAccess.Create(myDBSetting);

After creating the object acting as the bridge, you may call the specific methods you need to create, edit or delete a Stock Item.

Action Method Name
Add NewItem
Edit LoadItem
Delete Delete

The following examples illustrates how to use the above methods to do each specific task:

Add Stock Item

Add Code Snippet
  1. public void AddItem()
  2. {
  3.     BCE.AutoCount.Stock.Item.ItemDataAccess cmd = BCE.AutoCount.Stock.Item.ItemDataAccess.Create(myDBSetting);
  4.     BCE.AutoCount.Stock.Item.ItemEntity doc = cmd.NewItem();
  5.     doc.ItemCode = “1234″;
  6.     doc.Description = “item 1234″;
  7.     doc.BaseUomRecord.Uom = “PCS”;
  8.     doc.BaseUomRecord.StandardCost = 10;
  9.     doc.BaseUomRecord.StandardSellingPrice = 5;
  10.     // To add new Uom, refer to code below
  11.     BCE.AutoCount.Stock.Item.ItemUomEntity uom = doc.NewUom(12);
  12.     uom.Uom = “BOX”;
  13.     uom.StandardSellingPrice = 120;
  14.     uom.StandardCost = 60;
  15.     // To access to any Uom, refer to code below.
  16.     BCE.AutoCount.Stock.Item.ItemUomEntity[] uoms = doc.GetUomByRate(12);
  17.     if (uoms != null && uoms.Length > 0)
  18.     {
  19.         uoms[0].BarCode = “123123″;
  20.     }
  21.     bool isSuccessRecalculate = false;
  22.     cmd.SaveData(doc, ref isSuccessRecalculate);
  23. }

Edit Stock Item

Edit Code Snippet
  1. public void EditItem()
  2. {
  3.     BCE.AutoCount.Stock.Item.ItemDataAccess cmd = BCE.AutoCount.Stock.Item.ItemDataAccess.Create(myDBSetting);
  4.     BCE.AutoCount.Stock.Item.ItemEntity doc = cmd.LoadItem(“1234″, BCE.AutoCount.Stock.Item.ItemEntryAction.Edit);
  5.     doc.Description = “special modified item”;
  6.     BCE.AutoCount.Stock.Item.ItemUomEntity uom = doc.NewUom(24);
  7.     uom.Uom = “CARTON”;
  8.     uom.StandardSellingPrice = 220;
  9.     uom.StandardCost = 110;
  10.     bool isSuccessRecalculate = false;
  11.     cmd.SaveData(doc, ref isSuccessRecalculate);
  12. }

Delete Stock Item

Delete Code Snippet
  1. public void DeleteItem()
  2. {
  3.     BCE.AutoCount.Stock.Item.ItemDataAccess cmd = BCE.AutoCount.Stock.Item.ItemDataAccess.Create(myDBSetting);
  4.     cmd.Delete(“1234″);
  5. }

Item Class Properties

ItemEntity Properties

Field Name
Type(Length)
Read-only
Description
AllowDuplicateItemCodebooleanThe status flag to allow duplicate item code
AssemblyCostdecimal(18,8)The assembly cost assign to this entity
BackOrderControlbooleanThe status flag to show that the entity is under back order control
BaseUOMstring(8)The base UOM assign to this entity
BaseUOMRecordBCE.AutoCount.Stock.Item.ItemUomEntityReturns the base UOM record
CostingMethodintEnter either of the following:
0 - Fixed Cost,
1 - Weighted Average,
2 - FIFO,
3 - LIFO,
4 - Most Recently
CreatedTimeStampDateTimeReturns the creation time of this entity
CreatedUserIDstring(10)Returns the entity creator user id
DataDataSetReturns the DataSet object of this entity
DefaultUomBCE.AutoCount.Stock.Item.ItemUomEntityReturns the default UOM record
Desc2string(100)The secondary description assign to this entity
Descriptionstring(100)The description assign to this entity
DisableMissingDetailUomCheckingbooleanDisable the "missing detail UOM" checking
DisableRateOneCheckingbooleanDisable the "item must have at least Rate 1 UOM and BaseUOM is Rate 1" checking
DisableUomExistedCheckingbooleanDisable the "UOM column at item table value must exist at ItemUOM table" checking
DiscountinuedbooleanThe status flag to show that the entity has been discountinued
DocKeylongReturns the document key of this entity
DutyRatedecimal(18,6)The duty rate assign to this entity
ExternalLinkstringThe external link assign to this entity
FurtherDescriptionstringThe further description assign to this detail
HasBatchNobooleanThe status flag to show the entity has batch no
HasSerialNobooleanThe status flag to show the entity has serial no
ImageFileNamestring(120)The image file name assign to the entity
IsActivebooleanThe status flag to show the entity is active
IsCalcBonusPointbooleanThe status flag that entity uses calculate bonus point
ItemBatchTableDataTableThe Item Batch data table assign to the entity
ItemCodestring(30)The Item Code assign to the entity
ItemEntryActionBCE.AutoCount.Stock.Item.ItemEntryActionThe Item Entry Action assign to the entity
ItemGroupstring(8)The Item Group assign to the entity
ItemReplacementTableDataTableThe Item Replacement data table assign to the entity
ItemSubCodeTableDataTableThe Item SubCode data table assign to the entity
ItemTableDataTableThe Item data table assign to the entity
ItemTypestring(12)The Item Type assign to the entity
ItemUomTableDataTableThe Item UOM data table assign to the entity
LastModifiedDateTimeReturns the last modified time
LastModifiedUserIDstring(10)Returns the user id of the last modification
LastUpdateintReturns the number of update
LeadTimestring(40)The lead time assign to this document
NotestringThe notes assign to this document
POSPricePlanTableDataTableThe POS Price Plan data table assign to the entity
PuchaseTaxTypestring(14)The Purchase Tax Type assign to the entity
PurchaseUomstring(8)The Purchase UOM assign to the entity
ReportUomstring(8)The Report UOM assign to the entity
SalesUomstring(8)The Sales UOM assign to the entity
ScriptObjectBCE.AutoCount.Scripting.ScriptObjectReturns the ScriptObject of this document
ShowRecalculateStockCostingProgressWindowbooleanThe status flag to show the recalculate stock costing progress window
SNFormatNamestring(20)The serial number format name assign to the entity
StockControlbooleanThe status flag to show that the entity is under stock control
TaxTypestring(14)The tax type assign to the entity
UDFBCE.AutoCount.Data.UDFRecordReturns the UDF accessor
UomCountintReturns the UOM count of this entity

ItemUomEntity Properties

Field Name
Type(Length)
Read-only
Description
BalQtydecimal(18,6)Returns the balance qty
BarCodestring(30)The barcode assign to the entity
BonusPointdecimal(19,2)The bonus point assign to the entity
BonusPointQtydecimal(18,6)The bonus point qty assign to the entity
CSGNQtydecimal(18,6)Returns the consignment qty
FOCLeveldecimal(18,6)The FOC level assign to the entity
FOCQtydecimal(18,6)The FOC Qty assign to the entity
ItemCodestring(30)Returns the item code
LastUpdateintReturns the number of update
MaxPurchasePricedecimal(18,6)The maximum purchase price assign to the entity
MaxQtydecimal(18,6)The maximum qty assign to the entity
MaxSalePricedecimal(18,6)The maximum sale price assign to the entity
MinPurchasePricedecimal(18,6)The minimum purchase price assign to the entity
MinQtydecimal(18,6)The minimum qty assign to the entity
MinSalePricedecimal(18,6)The minimum sale price assign to the entity
MostRecentlyCostdecimal(18,8)The most recently cost assign to the entity
NormalLeveldecimal(18,6)The normal level qty assign to the entity
Ratedecimal(18,6)The rate assign to the entity
RealCostdecimal(18,8)The real cost assign to the entity
RedeemBonusPointintThe redeem bonus point assign to the entity
ReOLeveldecimal(18,6)The reorder level assign to the entity
ReOQtydecimal(18,6)The reorder qty assign to the entity
Shelfstring(20)The shelf assign to the entity
StandardCostdecimal(18,8)The standard cost assign to the entity
StandardSellingPricedecimal(18,6)The standard selling price assign to the entity
StandardSellingPrice2decimal(18,6)The standard selling price 2 assign to the entity
UDFBCE.AutoCount.Data.UDFRecordReturns the UDF accessor
Uomstring(8)The UOM assign to the entity
Volumedecimal(18,6)The volume assign to the entity
VolumeUOMstring(8)The volume UOM assign to the entity
Weightdecimal(18,6)The weight assign to the entity
WeightUOMstring(8)The weight UOM assign to the entity

ItemBatchEntity Properties

Field Name
Type(Length)
Read-only
Description
BalQtydecimal(18,6)Returns the balance quantity
BatchNostring(20)The batch number assign to this entity
Descriptionstring(40)The description assign to this entity
ExpiryDateDateTimeThe expiry date assign to this entity
ItemCodestring(30)The item code assign to this entity
LastSaleDateDateTimeThe last sale date assign to this entity
ManufacturedDateDateTimeThe manufactured date assign to this entity

ItemReplacementEntity Properties

Field Name
Type(Length)
Read-only
Description
ItemCodestring(30)Returns the Item Code assign to this entity
NotestringThe notes assign to this entity
ReplacementDegreedecimal(18,6)The replacement degree assign to this entity
ReplacementItemCodestring(30)The replacement item code assign to this entity

ItemSubCodeEntity Properties

Field Name
Type(Length)
Read-only
Description
ItemCodestring(30)Returns the Item Code assign to this entity
SubCodestring(30)The sub code assign to this entity

Accessing Stock Documents

As previously mentioned, the following examples will use the Stock Issue document to illustrate how to access a Stock Document programmatically to do the 3 basic functions.

Similarly to previous tutorials, we begin with creating an object that works as the data access bridge between the database with the data we wish to add, edit or delete. For Stock Issue this bridge is the StockIssueCommand class.

Code Snippet
  1. BCE.AutoCount.Stock.StockIssue.StockIssueCommand cmd = BCE.AutoCount.Stock.StockIssue.StockIssueCommand.Create(myDBSetting);

After creating the object acting as the bridge, you may call the specific methods you need to create, edit or delete a Stock Issue document.

Action Method Name
Add AddNew
Edit Edit
Delete Delete

The following examples illustrates how to use the above methods to do each specific task:

Add Stock Issue

Add Code Snippet
  1. public void AddStockIssue()
  2. {
  3.     BCE.AutoCount.Stock.StockIssue.StockIssueCommand cmd = BCE.AutoCount.Stock.StockIssue.StockIssueCommand.Create(myDBSetting);
  4.     BCE.AutoCount.Stock.StockIssue.StockIssue doc = cmd.AddNew();
  5.     doc.Description = “Stock Issue from program code”;
  6.     BCE.AutoCount.Stock.StockIssue.StockIssueDetail detail = doc.AddDetail();
  7.     detail.ItemCode = “1234″;
  8.     detail.Qty = 2;
  9.     doc.Save(BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(myDBSetting).LoginUserID);
  10. }

Edit Stock Issue

Edit Code Snippet
  1. public void EditStockIssue()
  2. {
  3.     BCE.AutoCount.Stock.StockIssue.StockIssueCommand cmd = BCE.AutoCount.Stock.StockIssue.StockIssueCommand.Create(myDBSetting);
  4.     BCE.AutoCount.Stock.StockIssue.StockIssue doc = cmd.Edit(“SI-000001″);
  5.     doc.Description = “Modified Stock Issue from program code”;
  6.     doc.ClearDetails();
  7.     BCE.AutoCount.Stock.StockIssue.StockIssueDetail detail = doc.AddDetail();
  8.     detail.ItemCode = “1234″;
  9.     detail.Qty = 5;
  10.     doc.Save(BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(myDBSetting).LoginUserID);
  11. }

Delete Stock Issue

Delete Code Snippet
  1. public void DeleteStockIssue()
  2. {
  3.     BCE.AutoCount.Stock.StockIssue.StockIssueCommand cmd = BCE.AutoCount.Stock.StockIssue.StockIssueCommand.Create(myDBSetting);
  4.     cmd.Delete(“SI-000001″);
  5. }

StockIssue Class Properties

StockIssue Properties

Field Name
Type(Length)
Read-only
Description
ActionBCE.AutoCount.Stock.StockIssue.StockIssueActionReturns the StockIssueAction object of this document
CancelledbooleanReturns true if the document is cancelled
CanSyncbooleanThe status flag to allow sync for the document
CommandBCE.AutoCount.Stock.StockIssue.StockIssueCommandReturns the StockIssueCommand object of this document
CreatedTimeStampBCE.Data.DBDateTimeReturns the creation time of this document
CreatedUserIDBCE.Data.DBString(10)Returns the creator user id of this document
DataTableDetailDataTableReturns the detail table of this document
DataTableMasterDataTableReturns the master table of this document
DataTableSerialNoDataTableReturns the Serial No table of this document
DescriptionBCE.Data.DBString(100)The description assign to this document
DetailCountintReturns the detail count of this document
DocDateBCE.Data.DBDateTimeThe document date assign to this document
DocKeylongReturns the document key of this document
DocNoBCE.Data.DBString(20)The document number assign to this document
DocNoFormatNameBCE.Data.DBStringThe document number format name assign to this document
EnableAutoLoadItemDetailbooleamThe status flag to enable auto loading of item detail
ExternalLinkBCE.AutoCount.Common.ExtrenalLinkReturns the ExternalLink accessor
ExternalLinkTextBCE.Data.DBStringThe ExternalLink text assign to this document
LastModifiedBCE.Data.DBDateTimeReturns the last modified time
LastModifiedUserIDBCE.Data.DBString(10)Returns the user id of the last modification
NoteBCE.Data.DBStringThe notes assign to this document
PrintCountshortReturns the print count of this document
ReallocatePurchaseByProjectbooleanThe status flag to reallocate purchase by project
ReallocatePurchaseByProjectJEDocKeylongReturns the journal entry document key for reallocate purchase by project
ReallocatePurchaseByProjectNoBCE.Data.DBString(10)The project number use for reallocate purchase by project assign to this document
RefDocNoBCE.Data.DBString(20)The reference document number assign to this document
Remark1BCE.Data.DBString(40)The Remark1 assign to this document
Remark2BCE.Data.DBString(40)The Remark2 assign to this document
Remark3BCE.Data.DBString(40)The Remark3 assign to this document
Remark4BCE.Data.DBString(40)The Remark4 assign to this document
ScriptObjectBCE.AutoCount.Scripting.ScriptObjectReturns the ScriptObject of this document
StockIssueDataSetDataSetReturns the Stock Issue DataSet object of this document
TotalBCE.Data.DBDecimal(18,4)Returns the Total amount assign to this document
UDFBCE.AutoCount.Data.UDFRecordReturns the UDF accessor
UserDataobjectThe object that contains user data. This is use for scripting purposes.

StockIssueDetail Properties

Field Name
Type(Length)
Read-only
Description
BatchNoBCE.Data.DBString(20)The Batch Number assign to this detail
DeptNoBCE.Data.DBString(10)The Department Number assign to this detail
DescriptionBCE.Data.DBString(100)The Description assign to this detail
FurtherDescriptionBCE.Data.DBStringThe further description assign to this detail
ItemCodeBCE.Data.DBString(30)The Item Code assign to this detail
LocationBCE.Data.DBString(8)The Location assign to this detail
NumberingBCE.Data.DBString(6)The Numbering assign to this detail
PrintOutbooleanThe status flag to print out this detail
ProjNoBCE.Data.DBString(10)The project number assign to this detail
QtyBCE.Data.DBDecimal(18,6)The Qty assign to this detail
RowDataRowReturns the Row of this detail
SeqintReturns the sequence of this detail
SerialNoListBCE.Data.DBStringReturns the serial number list of this detail
SubTotalBCE.Data.DBDecimal(18,4)The Sub Total assign to this detail
UDFBCE.AutoCount.Data.UDFRecordReturns the UDF accessor
UnitPriceBCE.Data.DBDecimal(18,8)The Unit Price assign to this detail
UOMBCE.Data.DBString(8)The UOM assign to this detail

Full example

Code Snippet
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using BCE.Data;
  5. namespace AccessingAccounting
  6. {
  7.     public class AccessStock
  8.     {
  9.         private DBSetting myDBSetting;
  10.         public AccessStock(DBSetting dbSetting)
  11.         {
  12.             myDBSetting = dbSetting;
  13.         }
  14.         #region Accessing Stock Item
  15.         public void AddItem()
  16.         {
  17.             BCE.AutoCount.Stock.Item.ItemDataAccess cmd = BCE.AutoCount.Stock.Item.ItemDataAccess.Create(myDBSetting);
  18.             BCE.AutoCount.Stock.Item.ItemEntity doc = cmd.NewItem();
  19.             doc.ItemCode = “1234″;
  20.             doc.Description = “item 1234″;
  21.             doc.BaseUomRecord.Uom = “PCS”;
  22.             doc.BaseUomRecord.StandardCost = 10;
  23.             doc.BaseUomRecord.StandardSellingPrice = 5;
  24.             // To add new Uom, refer to code below
  25.             BCE.AutoCount.Stock.Item.ItemUomEntity uom = doc.NewUom(12);
  26.             uom.Uom = “BOX”;
  27.             uom.StandardSellingPrice = 120;
  28.             uom.StandardCost = 60;
  29.             // To access to any Uom, refer to code below.
  30.             BCE.AutoCount.Stock.Item.ItemUomEntity[] uoms = doc.GetUomByRate(12);
  31.             if (uoms != null && uoms.Length > 0)
  32.             {
  33.                 uoms[0].BarCode = “123123″;
  34.             }
  35.             bool isSuccessRecalculate = false;
  36.             cmd.SaveData(doc, ref isSuccessRecalculate);
  37.         }
  38.         public void EditItem()
  39.         {
  40.             BCE.AutoCount.Stock.Item.ItemDataAccess cmd = BCE.AutoCount.Stock.Item.ItemDataAccess.Create(myDBSetting);
  41.             BCE.AutoCount.Stock.Item.ItemEntity doc = cmd.LoadItem(“1234″, BCE.AutoCount.Stock.Item.ItemEntryAction.Edit);
  42.             doc.Description = “special modified item”;
  43.             BCE.AutoCount.Stock.Item.ItemUomEntity uom = doc.NewUom(24);
  44.             uom.Uom = “CARTON”;
  45.             uom.StandardSellingPrice = 220;
  46.             uom.StandardCost = 110;
  47.             bool isSuccessRecalculate = false;
  48.             cmd.SaveData(doc, ref isSuccessRecalculate);
  49.         }
  50.         public void DeleteItem()
  51.         {
  52.             BCE.AutoCount.Stock.Item.ItemDataAccess cmd = BCE.AutoCount.Stock.Item.ItemDataAccess.Create(myDBSetting);
  53.             cmd.Delete(“1234″);
  54.         }
  55.         #endregion
  56.         #region Accessing Stock Issue
  57.         public void AddStockIssue()
  58.         {
  59.             BCE.AutoCount.Stock.StockIssue.StockIssueCommand cmd = BCE.AutoCount.Stock.StockIssue.StockIssueCommand.Create(myDBSetting);
  60.             BCE.AutoCount.Stock.StockIssue.StockIssue doc = cmd.AddNew();
  61.             doc.Description = “Stock Issue from program code”;
  62.             BCE.AutoCount.Stock.StockIssue.StockIssueDetail detail = doc.AddDetail();
  63.             detail.ItemCode = “1234″;
  64.             detail.Qty = 2;
  65.             doc.Save(BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(myDBSetting).LoginUserID);
  66.         }
  67.         public void EditStockIssue()
  68.         {
  69.             BCE.AutoCount.Stock.StockIssue.StockIssueCommand cmd = BCE.AutoCount.Stock.StockIssue.StockIssueCommand.Create(myDBSetting);
  70.             BCE.AutoCount.Stock.StockIssue.StockIssue doc = cmd.Edit(“SI-000001″);
  71.             doc.Description = “Modified Stock Issue from program code”;
  72.             doc.ClearDetails();
  73.             BCE.AutoCount.Stock.StockIssue.StockIssueDetail detail = doc.AddDetail();
  74.             detail.ItemCode = “1234″;
  75.             detail.Qty = 5;
  76.             doc.Save(BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(myDBSetting).LoginUserID);
  77.         }
  78.         public void DeleteStockIssue()
  79.         {
  80.             BCE.AutoCount.Stock.StockIssue.StockIssueCommand cmd = BCE.AutoCount.Stock.StockIssue.StockIssueCommand.Create(myDBSetting);
  81.             cmd.Delete(“SI-000001″);
  82.         }
  83.         #endregion
  84.     }
  85. }