How to programmatically add a comment line to a document in Small Business Accounting (920195)



The information in this article applies to:

  • Microsoft Office Small Business Accounting 2006 Software Development Kit 1.2
  • Microsoft Office Small Business Accounting 2006
  • Microsoft Office Small Business Management Edition 2006

Notice

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

INTRODUCTION

There are certain documents in Microsoft Office Small Business Accounting that can contain comment line items. Comment line items are used to enter miscellaneous comments in the document. You can add comment line items programmatically by using the Small Business Accounting Software Development Kit (SDK). To programmatically add the comment line items by using the SDK, you must add an instance of IDescriptionLine to the document.

MORE INFORMATION

The following code sample creates a new purchase order in Northwind Traders. Northwind Traders is the fictitious company that is used for demonstration in Small Business Accounting. Two line items are then added to the purchase order. The first line item is an item line. The second line item is a comment line.
ISmallBusinessInstance iSbi = // Initialize iSbi

// This code contains hard-coded values that work with Northwind Traders, the sample product company.

// First, retrieve the vendor for the purchase order.
IVendorAccount vendor = (IVendorAccount) GetAccountByName(iSbi.VendorAccounts, "Novelty Bikes");

// Now, we create the purchase order.
IPurchaseOrder po = iSbi.CreatePurchaseOrder();
po.FinancialDateTime = DateTime.Now;
po.VendorAccount = vendor;

// This is the item that we add to the purchase order.
IItemAccount item = (IItemAccount) GetAccountByName(iSbi.ItemAccounts, "Baseball Bat");

// We add one item line and one description line.
// First, we add the item line.
IItemLine itemLine = (IItemLine) po.CreatePurchaseOrderLine(DocumentLineType.ContractItemLineType);
itemLine.LineItem = item;
itemLine.Quantity = 1;

// Now, we add the description line.
IDescriptionLine descLine = (IDescriptionLine) po.CreatePurchaseOrderLine(DocumentLineType.ContractDescriptionLineType);
descLine.Description = "this is our comment";

po.Save();


static IAccount GetAccountByName(IBaseMasterView view, string acctName)
{
	IAccount account = null;
	DataRow row = null;

	if (view != null)
	{
		DataView dv = view.DataView;

		// Make sure that there is a column that is named Name, or we receive a runtime exception.
		if (dv.Table.Columns.Contains("Name"))
		{
			dv.RowFilter = String.Format("Name='{0}'", acctName);
		}
		// The IJobAccount does not have a Name column; therefore, we search on JobName.
		else if (dv.Table.Columns.Contains("JobName"))
		{
			dv.RowFilter = String.Format("JobName='{0}'", acctName);
		}
		
		// Make sure that there is a column that is named ModifiedDateTime, or we receive a runtime exception.
		if (dv.Table.Columns.Contains("ModifiedDateTime"))
		{
			dv.Sort = "ModifiedDateTime DESC";
		}
    
		// In case there is more than one row, we obtain the latest one.
		if (dv.Count > 0)
		{
			row = dv[0].Row;
		}
	}

	if (row != null)
	{
		account = (IAccount) view.GetByDataRow(row);
	}

	return account;
}


Modification Type:MajorLast Reviewed:6/29/2006
Keywords:kbExpertiseAdvanced kbhowto KB920195 kbAudDeveloper kbAudEndUser