Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagec#
public class ApplicationManagerPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaApplicationManagerPlugin
{
    public override object InitializeLifetimeService()
    {
        // returning null here will prevent the lease manager
        // from deleting the Object.
        return null;
    }

    public void Setup(JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
		Plugin.Manager.LoggedOn += delegate() 
			{ 
				// code to execute when logged on here
			};
    }
}

CustomFieldPlugin class

The CustomFieldPlugin class is used for the display and interaction with custom fields. It uses the following methods:

FormatCell

This is used to format the Spread grid cell of the custom field contents. Often used for setting combo-box items, for example:

Code Block
languagec#
public void FormatCell(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic BusinessLogicHost, JiwaFinancials.Jiwa.JiwaApplication.Controls.JiwaGrid GridObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm FormObject, int Col, int Row, JiwaFinancials.Jiwa.JiwaApplication.IJiwaCustomFieldValues HostObject, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomField CustomField, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValue CustomFieldValue)
{
  // FormatCell handler for a combo custom field
  if (CustomField.PluginCustomField.Name == "MyCustomFieldName") 
  {
		var typeCell = new FarPoint.Win.Spread.CellType.ComboBoxCellType();			
		typeCell.Items = new string[] { "Option 1", "Option 2", "Option 3"};
		typeCell.ItemData = new string[] { "1", "2", "3"};
		typeCell.EditorValue = FarPoint.Win.Spread.CellType.EditorValue.ItemData;                  
		GridObject.ActiveSheet.Cells[Row, GridObject.ActiveSheet.GetColumnFromTag(null, "Contents"").Index].CellType = typeCell;
  }
}

ReadData

This is used most typically to map an ID from a custom field contents to a display value - such as an InventoryID to a Part No and / or Description, for example:

Code Block
languagec#
public void ReadData(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic BusinessLogicHost, JiwaFinancials.Jiwa.JiwaApplication.Controls.JiwaGrid GridObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm FormObject, int Row, JiwaFinancials.Jiwa.JiwaApplication.IJiwaCustomFieldValues HostObject, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomField CustomField, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValue CustomFieldValue)
{
  // ReadData handler for a lookup custom field for an inventory item
  if (CustomField.PluginCustomField.Name == "MyCustomFieldName") 
  {
		if (CustomFieldValue.Contents.Trim().Length > 0) 
		{
			JiwaFinancials.Jiwa.JiwaApplication.Entities.Inventory.Inventory inventoryItem = CustomField.Manager.EntityFactory.CreateEntity<JiwaFinancials.Jiwa.JiwaApplication.Entities.Inventory.Inventory>();
			try
			{
				inventoryItem.ReadRecord(CustomFieldValue.Contents);
				CustomFieldValue.DisplayContents = String.Format("{0} - {1}", inventoryItem.PartNo, inventoryItem.Description);
			}
			catch(JiwaFinancials.Jiwa.JiwaApplication.Exceptions.RecordNotFoundException notFoundEx)
			{
				CustomFieldValue.DisplayContents = "";
			}
		}
		else
		{
			CustomFieldValue.DisplayContents = "";
		}
  }
}

ButtonClicked

This is used to react to a button click of the lookup button to the right of the custom field contents for Lookup type custom fields - usually to display a search window - for example:

Code Block
languagec#
public void ButtonClicked(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic BusinessLogicHost, JiwaFinancials.Jiwa.JiwaApplication.Controls.JiwaGrid GridObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm FormObject, int Col, int Row, JiwaFinancials.Jiwa.JiwaApplication.IJiwaCustomFieldValues HostObject, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomField CustomField, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValue CustomFieldValue)
{
  // ButtonClicked handler for a lookup custom field for an inventory item
  if (CustomField.PluginCustomField.Name == "MyCustomFieldName") 
  {
		JiwaFinancials.Jiwa.JiwaApplication.Entities.Inventory.Inventory inventoryItem = CustomField.Manager.EntityFactory.CreateEntity<JiwaFinancials.Jiwa.JiwaApplication.Entities.Inventory.Inventory>();
		inventoryItem.Search(FormObject.Form, "", "");
		CustomFieldValue.Contents = inventoryItem.RecID;
		CustomFieldValue.DisplayContents = String.Format("{0} - {1}", inventoryItem.PartNo, inventoryItem.Description);
  }
}

LineCustomFieldPlugin class

...